:root {
  color-scheme: dark;
  --bg: #11101a;
  --panel: #1c1929;
  --panel-raised: #242033;
  --line: #383249;
  --text: #f5f3ff;
  --muted: #a8a2b8;
  --purple: #7c3aed;
  --violet: #a78bfa;
  --green: #24d17e;
  font: 16px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  padding-top: env(safe-area-inset-top);
  background: radial-gradient(ellipse at 50% -15%, #2a2048 0, transparent 48%), var(--bg);
  color: var(--text);
}

.app-header {
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 max(20px, calc((100vw - 790px) / 2));
  border-bottom: 1px solid #ffffff12;
  background: #11101add;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 13px; letter-spacing: .09em; }
.brand b { font-weight: 800; }
.brand small { display: block; color: #c2bad5; font-size: 9px; letter-spacing: .15em; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 40px;
  border-radius: 13px; background: linear-gradient(140deg, #ae83ff, #702be6);
  font-size: 14px; font-weight: 850; letter-spacing: -.06em; box-shadow: 0 5px 22px #7c3aed40;
}

.app-main { width: min(100% - 36px, 790px); margin: 17px auto 0; padding-bottom: 20px; }
.stepper { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 4px 17px; margin-bottom: 3px; }
.stepper i { height: 1px; flex: 1; margin: 14px 7px 0; background: var(--line); }
.step {
  min-width: 55px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 0; border: 0; background: none; color: #aaa4b8; cursor: pointer;
}
.step span { width: 29px; height: 29px; display: grid; place-items: center; border: 1.5px solid #655e72; border-radius: 50%; background: #15131d; font-size: 12px; font-weight: 700; }
.step b { font-size: 11px; font-weight: 500; white-space: nowrap; }
.step.active, .step.done { color: var(--text); }
.step.active b { font-weight: 750; }
.step.active span, .step.done span { border-color: transparent; background: linear-gradient(140deg, #a36af8, #7629eb); color: white; box-shadow: 0 3px 13px #7c3aed55; }
.step:disabled { cursor: default; opacity: .68; }

.card { padding: 24px; border: 1px solid #ffffff12; border-radius: 18px; background: linear-gradient(145deg, #211e30, #191723); box-shadow: 0 17px 45px #0002; }
.stage-title { display: flex; align-items: center; gap: 13px; margin: 0 0 19px; }
.stage-icon { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; color: #b68bff; font-size: 29px; line-height: 1; }
.stage-title h1 { margin: 0 0 5px; font-size: 21px; line-height: 1.2; letter-spacing: -.025em; }
.stage-title p { margin: 0; color: var(--muted); font-size: 12px; }

.dropzone {
  min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  padding: 24px; border: 1.5px dashed #776995; border-radius: 16px; background: #171420; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--violet); background: #211b31; }
.dropzone input, .upload-button input { display: none; }
.upload-icon { width: 57px; height: 57px; display: grid; place-items: center; margin-bottom: 3px; border: 3px solid #a779fb; border-radius: 50%; color: #b68bff; font-size: 38px; font-weight: 300; line-height: 1; }
.dropzone b { font-size: 16px; }
.dropzone > span:last-of-type { max-width: 280px; color: var(--muted); font-size: 12px; }
.photo-count-row { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }
.badge { padding: 5px 10px; border: 1px solid var(--line); border-radius: 24px; color: #d0c5e5; font-size: 11px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 9px; margin-top: 12px; }
.photo-tile { position: relative; overflow: hidden; aspect-ratio: 1; border: 1px solid #ffffff15; border-radius: 11px; background: #0c0b12; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-tile button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: #171321e8; color: white; font-size: 18px; }
.photo-tile span { position: absolute; right: 0; bottom: 0; left: 0; overflow: hidden; padding: 15px 5px 4px; background: linear-gradient(transparent, #000c); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 12px; }
.stage > #photoHint { margin: 11px 0 0; }

.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-raised);
  font-size: 12px; font-weight: 650; white-space: nowrap; cursor: pointer;
}
.button:disabled, .step-adjust:disabled, .text-button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { border-color: #9959f3; background: linear-gradient(100deg, #8e43f4, #7025e9); color: white; box-shadow: 0 5px 17px #6721cb35; }
.button.secondary { border-color: #514a63; background: #201d2c; color: #e8e3f2; }
.button.danger-button { color: #ffb5c0; }
.field-label { display: block; margin: 0 0 6px; color: #d8d2e4; font-size: 12px; }

.preset-panel { margin-bottom: 11px; padding: 11px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: #171520; }
.preset-row { display: flex; align-items: center; gap: 7px; }
.preset-row select, .control-main select, .advanced-grid select, .advanced-grid input[type="number"] {
  width: 100%; min-width: 0; height: 42px; padding: 0 10px; border: 1px solid #4a4359; border-radius: 9px; background: #15131f; color: var(--text); font-size: 12px;
}
.preset-row select { flex: 1; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #211e2c; color: var(--violet); font-size: 17px; letter-spacing: 1px; }
.preset-actions { display: flex; gap: 7px; margin-top: 9px; }
.preset-actions .button { min-width: 0; min-height: 38px; flex: 1; padding: 6px; font-size: 11px; }

.control-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; background: #1b1926; }
.control-icon { width: 29px; flex: 0 0 29px; display: grid; place-items: center; color: #c2a2ff; font-size: 19px; }
.control-main { min-width: 0; flex: 1; }
.control-row .field-label { margin: 0 0 4px; }
.control-row select { height: 38px; }
.watermark-row { align-items: center; }
.watermark-row .control-main select { height: 37px; }
.wm-preview { width: 100%; height: 31px; display: flex; align-items: center; margin-top: 6px; color: var(--muted); font-size: 10px; }
.wm-preview img { max-width: 100%; max-height: 29px; object-fit: contain; }
.upload-button { min-width: 78px; flex: 0 0 auto; }
.watermark-actions { margin: -7px 4px 8px; text-align: right; }
.text-button { padding: 6px; border: 0; background: none; color: #cbb9ee; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.validation-hint { margin: 8px 4px; color: #ffb7c4; font-size: 12px; }

.slider-control { margin: 9px 0; padding: 9px 10px 8px; border: 1px solid var(--line); border-radius: 12px; background: #1b1926; }
.slider-head { min-height: 31px; display: flex; align-items: center; gap: 8px; }
.slider-head .control-icon { font-size: 18px; }
.slider-head label { flex: 1; font-size: 12px; }
.slider-head output { min-width: 49px; padding: 5px 7px; border: 1px solid #4b4458; border-radius: 8px; background: #15131f; font-size: 12px; font-weight: 700; text-align: center; }
.step-adjust { width: 34px; height: 33px; border: 1px solid #4d465d; border-radius: 8px; background: #282438; color: #eee7fa; font-size: 18px; line-height: 1; cursor: pointer; }
.slider-control input[type="range"], .quality-control input[type="range"] { width: 100%; height: 30px; margin: 3px 0 0; accent-color: #a875fa; touch-action: pan-y; }

.advanced { overflow: hidden; margin-top: 11px; border: 1px solid var(--line); border-radius: 12px; background: #1b1926; }
.advanced summary { min-height: 46px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; list-style: none; font-size: 12px; font-weight: 650; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { margin-left: auto; color: #c9b9e7; content: '⌄'; font-size: 18px; }
.advanced[open] summary::after { content: '⌃'; }
.advanced-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 12px; border-top: 1px solid var(--line); }
.advanced-grid > label { min-width: 0; color: var(--muted); font-size: 11px; }
.advanced-grid select, .advanced-grid input[type="number"] { display: block; margin-top: 5px; }
.quality-control { grid-column: 1 / -1; padding: 3px 2px; }
.quality-control .slider-head output { margin-left: auto; }

.preview-frame { width: 100%; min-height: 200px; display: grid; place-items: center; overflow: hidden; border: 1px solid #ffffff14; border-radius: 12px; background: #0e0c14; }
.preview-frame canvas { width: 100%; max-height: min(58vh, 590px); display: block; object-fit: contain; }
.preview-meta { margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.empty-state { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-state > span { color: var(--violet); font-size: 38px; }
.empty-state b { color: var(--text); font-size: 14px; }
.empty-state p { margin: 0; font-size: 12px; }
.success-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 11px 13px; border: 1px solid #138e51; border-radius: 11px; background: #123327; color: #e2ffef; font-size: 12px; }
.success-banner span { width: 23px; height: 23px; display: grid; place-items: center; border: 1.5px solid var(--green); border-radius: 50%; color: var(--green); font-weight: 800; }
.progress-panel { margin-bottom: 12px; }
.progress { height: 7px; overflow: hidden; border-radius: 8px; background: #373147; }
.progress > div { width: 0; height: 100%; background: linear-gradient(90deg, #7c3aed, #c4b5fd); transition: width .15s; }
.progress-panel p { margin: 7px 0; }
.result-list { display: grid; gap: 8px; }
.result-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #211e2c; font-size: 11px; overflow-wrap: anywhere; }
.result-item a { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid #514967; border-radius: 9px; color: #f4eaff; font-size: 18px; text-decoration: none; }
.result-actions { display: flex; gap: 9px; margin-top: 13px; }
.result-actions .primary { flex: 1; }
.share-button { width: 48px; height: 48px; font-size: 20px; }
.wizard-actions { position: sticky; z-index: 4; bottom: 0; display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 0 max(10px, env(safe-area-inset-bottom)); background: linear-gradient(#11101a00, #11101a 22%); }
.wizard-actions .button { min-width: 112px; min-height: 47px; }
.wizard-actions .primary { min-width: 145px; }
.action-spacer { flex: 1; }
.intro, .nav, footer { display: none; }

@media (min-width: 700px) {
  .app-main { margin-top: 23px; }
  .card { padding: 28px; }
  .dropzone { min-height: 300px; }
  .wizard-actions { position: static; padding: 14px 0 28px; background: none; }
  .wizard-actions .button { min-width: 130px; }
  .stage-title h1 { font-size: 23px; }
}

@media (max-width: 520px) {
  .app-header { height: 62px; padding: 0 17px; }
  .brand { gap: 9px; font-size: 11px; }
  .brand-mark { width: 37px; height: 37px; flex-basis: 37px; border-radius: 12px; }
  .brand small { font-size: 8px; }
  .app-main { width: calc(100% - 24px); margin-top: 13px; padding-bottom: 5px; }
  .stepper { padding: 0 0 14px; }
  .stepper i { margin: 13px 3px 0; }
  .step { min-width: 45px; gap: 4px; }
  .step span { width: 27px; height: 27px; }
  .step b { font-size: 9px; }
  .card { padding: 16px; border-radius: 15px; }
  .stage-title { gap: 9px; margin-bottom: 14px; }
  .stage-icon { width: 35px; height: 35px; flex-basis: 35px; font-size: 25px; }
  .stage-title h1 { font-size: 17px; }
  .stage-title p { font-size: 10px; }
  .dropzone { min-height: 255px; padding: 17px; }
  .dropzone b { font-size: 15px; }
  .dropzone > span:last-of-type { font-size: 11px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 7px; }
  .control-row { gap: 8px; padding: 9px; }
  .control-icon { width: 26px; flex-basis: 26px; }
  .preset-panel { padding: 9px; }
  .preset-row { gap: 5px; }
  .preset-row .button { padding: 8px; font-size: 10px; }
  .preset-row .icon-button { width: 37px; height: 39px; }
  .preset-actions .button { padding: 6px 4px; font-size: 10px; }
  .upload-button { min-width: 67px; padding: 8px; font-size: 11px; }
  .slider-control { padding: 8px 9px; }
  .step-adjust { width: 34px; height: 34px; }
  .advanced-grid { gap: 10px; padding: 10px; }
  .advanced-grid > label { font-size: 10px; }
  .advanced-grid select, .advanced-grid input[type="number"] { padding: 0 7px; font-size: 11px; }
  .preview-frame { min-height: 175px; }
  .wizard-actions { margin: 9px -12px 0; padding: 11px 12px max(10px, env(safe-area-inset-bottom)); }
  .wizard-actions .button { min-width: 101px; min-height: 46px; }
  .wizard-actions .primary { min-width: 137px; }
  .wizard-actions .new-process { min-width: 153px; }
  .result-item { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
.app-dialog{width:min(calc(100% - 32px),410px);padding:22px;border:1px solid #514967;border-radius:16px;background:#211e30;color:var(--text);box-shadow:0 20px 70px #0009}.app-dialog::backdrop{background:#05040bd9;backdrop-filter:blur(3px)}.app-dialog h2{margin:0 0 7px;font-size:19px}.app-dialog p{margin:0 0 15px;color:var(--muted);font-size:13px}.app-dialog label{display:block;margin-bottom:6px;font-size:12px;color:#d8d2e4}.app-dialog input{width:100%;height:44px;padding:0 11px;border:1px solid #514967;border-radius:10px;background:#15131f;color:var(--text);font:inherit}.app-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}
@media(max-width:520px){.app-main{padding-bottom:88px}.wizard-actions{position:fixed;right:0;bottom:0;left:0;width:min(calc(100% - 24px),790px);margin:0 auto;padding:11px 12px max(10px,env(safe-area-inset-bottom));background:linear-gradient(#11101a00,#11101a 20%);border-top:1px solid #ffffff08}}
