:root {
  --ink: #0d1117;
  --ink-soft: #20262f;
  --paper: #f5f3ee;
  --surface: #ffffff;
  --surface-soft: #eeece6;
  --line: #d9d6ce;
  --line-dark: #bdc1c8;
  --text: #11151b;
  --muted: #69707b;
  --accent: #307cf6;
  --accent-deep: #285fd7;
  --violet: #7654ee;
  --ok: #16875a;
  --warn: #a56600;
  --err: #c94040;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 60px rgba(13, 17, 23, 0.08);
  --header-h: 78px;
  --bar-h: calc(88px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; }
html { background: var(--paper); }
body {
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(118, 84, 238, 0.05), transparent 25rem),
    var(--paper);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Arial, sans-serif;
  font-feature-settings: "ss01", "cv02", "cv03";
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; }
button, label, select, summary { touch-action: manipulation; }
button { color: inherit; }
svg { display: block; }

#app { height: 100dvh; display: flex; flex-direction: column; }

/* Header */
#chrome {
  position: relative;
  z-index: 20;
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  border-bottom: 1px solid rgba(13, 17, 23, 0.1);
  background: rgba(245, 243, 238, 0.9);
  backdrop-filter: blur(18px);
}
.chrome-inner {
  width: min(100%, 1440px);
  height: 100%;
  margin: 0 auto;
  padding: 0 42px;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  align-items: center;
  gap: 26px;
}
.brand {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.035em;
}
.brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(13, 17, 23, 0.12);
}
.brand b { font-weight: 760; }
.brand span { background: linear-gradient(90deg, var(--ink) 44%, var(--accent) 45%, var(--violet)); -webkit-background-clip: text; color: transparent; }
.chrome-back {
  display: none;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 8px 10px 8px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
}
.chrome-back:not([hidden]) { display: flex; }
body:not([data-screen="upload"]) #chrome .brand { display: none; }
.chrome-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.chrome-back:hover { background: rgba(13, 17, 23, 0.06); }
.dots { display: flex; justify-content: center; align-items: center; gap: 0; }
.progress-step {
  position: relative;
  min-width: 112px;
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px;
  color: #8a9099;
}
.progress-step::after {
  content: "";
  position: absolute;
  left: 26px;
  right: 0;
  top: 12px;
  height: 1px;
  background: #c9c7c1;
}
.progress-step:last-child::after { display: none; }
.progress-num {
  grid-row: 1 / 3;
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid #c3c1bb;
  border-radius: 50%;
  background: var(--paper);
  font-size: 11px;
  font-weight: 760;
}
.progress-label { align-self: end; font-size: 11px; font-weight: 680; letter-spacing: 0.01em; }
.progress-meta { font-size: 10px; color: #a0a4aa; }
.progress-step.active { color: var(--ink); }
.progress-step.active .progress-num { color: #fff; border-color: var(--ink); background: var(--ink); }
.progress-step.done { color: #4e5660; }
.progress-step.done .progress-num { color: #fff; border-color: var(--accent); background: var(--accent); }
.progress-step.done::after { background: var(--accent); }
.support-chip { justify-self: end; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.support-dot { width: 8px; height: 8px; border-radius: 50%; background: #26aa75; box-shadow: 0 0 0 5px rgba(38, 170, 117, 0.12); }
.support-copy { display: flex; flex-direction: column; line-height: 1.2; }
.support-copy b { font-size: 12px; font-weight: 720; }
.support-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }

/* Screen system */
#screens { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transform: translateX(28px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,.7,.2,1);
}
.screen.active { visibility: visible; opacity: 1; transform: translateX(0); pointer-events: auto; }
.screen.exit-left { opacity: 0; transform: translateX(-28px); }
.content {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 44px 42px calc(32px + var(--bar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.narrow-content { max-width: 1060px; }
.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 30px;
}
.stage-head > div:first-child { max-width: 760px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-deep);
  font-size: 11px;
  line-height: 1;
  font-weight: 780;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.screen-title {
  margin: 0;
  max-width: 880px;
  color: var(--ink);
  font-family: "Segoe UI Variable Display", "Segoe UI", Arial, sans-serif;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 0.98;
  font-weight: 710;
  letter-spacing: -0.055em;
  text-wrap: balance;
}
.screen-sub {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.trust-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid rgba(13,17,23,.11);
  border-radius: 999px;
  background: rgba(255,255,255,.46);
  color: #4e5660;
  font-size: 11px;
  font-weight: 630;
}
.trust-row svg { width: 14px; height: 14px; fill: none; stroke: var(--ok); stroke-width: 1.8; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(360px, .82fr); gap: 26px; align-items: start; }
.pane { min-width: 0; }

/* Upload */
.drop {
  min-height: 400px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #c9c6bf;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(13,17,23,.025) 1px, transparent 1px),
    linear-gradient(rgba(13,17,23,.025) 1px, transparent 1px),
    rgba(255,255,255,.55);
  background-size: 24px 24px;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}
.drop::before, .drop::after {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-color: var(--ink);
  opacity: .28;
  pointer-events: none;
}
.drop::before { top: 18px; left: 18px; border-top: 1px solid; border-left: 1px solid; }
.drop::after { right: 18px; bottom: 18px; border-right: 1px solid; border-bottom: 1px solid; }
.drop:hover { border-color: #969ca5; background-color: rgba(255,255,255,.78); }
.drop.drag { border-color: var(--accent); background-color: rgba(48,124,246,.06); transform: scale(.995); }
.drop-inner { max-width: 380px; padding: 42px 26px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.drop-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 0 0 8px rgba(13,17,23,.06);
}
.drop-mark svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drop-mark.error-mark { background: var(--err); font-size: 20px; font-weight: 800; }
.mini-spinner { width: 21px; height: 21px; border: 2px solid rgba(255,255,255,.38); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.drop-inner strong { color: var(--ink); font-size: 23px; line-height: 1.2; letter-spacing: -.035em; }
.drop-inner > span:not(.drop-mark) { margin-top: 8px; color: var(--muted); font-size: 14px; }
.drop-inner em { margin-top: 26px; color: #969ba2; font-size: 11px; font-style: normal; letter-spacing: .02em; }
.preview { width: 100%; height: 100%; max-height: 560px; object-fit: contain; background: #e8e6e0; }
.quality-card {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 22px;
  padding: 20px 22px;
  border: 1px solid rgba(13,17,23,.1);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.38);
}
.section-kicker { color: var(--muted); font-size: 10px; font-weight: 780; letter-spacing: .11em; text-transform: uppercase; }
.quality-intro { display: flex; flex-direction: column; gap: 7px; }
.quality-intro strong, .panel-heading strong { font-size: 17px; line-height: 1.15; letter-spacing: -.025em; }
.quality-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.quality-list li { display: flex; gap: 10px; }
.quality-list li > span { color: var(--accent); font-size: 10px; font-weight: 800; }
.quality-list p { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.quality-list b { font-size: 12px; }
.quality-list small { color: var(--muted); font-size: 10px; line-height: 1.4; }

/* Panels and controls */
.setup-panel, .crop-panel, .review-card, .download-panel {
  padding: 26px;
  border: 1px solid rgba(13,17,23,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  box-shadow: 0 12px 40px rgba(13,17,23,.045);
}
.panel-heading { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.field { margin-bottom: 22px; }
.field > label, .field-heading label, .key-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}
.field-heading { display: flex; align-items: center; justify-content: space-between; }
.field-heading > span { color: var(--muted); font-size: 10px; }
select, input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 42px 0 13px;
  border: 1px solid #d2d0ca;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #747b84 50%), linear-gradient(135deg, #747b84 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
select:focus, input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(48,124,246,.1); }
.field small { display: block; margin-top: 7px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: #eceae5; }
.seg-btn { min-height: 36px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.seg-btn.active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(13,17,23,.09); font-weight: 700; }
.outfits { display: flex; gap: 9px; overflow-x: auto; margin: 12px -2px 0; padding: 2px 2px 8px; scrollbar-width: thin; }
.outfit { flex: 0 0 auto; width: 68px; padding: 0; border: 0; background: none; cursor: pointer; }
.outfit img, .outfit .none { width: 68px; height: 82px; display: grid; place-items: center; object-fit: cover; border: 2px solid transparent; border-radius: 9px; background: #eceae5; transition: transform .12s ease, border-color .12s ease; }
.outfit .none { color: var(--muted); font-size: 22px; }
.outfit .none svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linejoin: round; }
.outfit:active img, .outfit:active .none { transform: scale(.96); }
.outfit.selected img, .outfit.selected .none { border-color: var(--accent); }
.outfit .cap { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.25; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.outfit.selected .cap { color: var(--ink); font-weight: 700; }
.settings-accordion { border-top: 1px solid #dedbd4; border-bottom: 1px solid #dedbd4; }
.settings-accordion summary { min-height: 64px; display: flex; justify-content: space-between; align-items: center; list-style: none; cursor: pointer; }
.settings-accordion summary::-webkit-details-marker { display: none; }
.settings-accordion summary > span { display: flex; flex-direction: column; gap: 3px; }
.settings-accordion summary b { font-size: 12px; }
.settings-accordion summary small { color: var(--muted); font-size: 10px; }
.settings-accordion summary svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.6; transition: transform .18s ease; }
.settings-accordion[open] summary svg { transform: rotate(180deg); }
.checks { display: flex; flex-direction: column; gap: 2px; }
.retouch-grid { padding-bottom: 12px; }
.check { min-height: 38px; display: flex; align-items: center; gap: 10px; color: #333a43; font-size: 12px; cursor: pointer; }
.check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  display: grid;
  place-items: center;
  border: 1px solid #aeb2b8;
  border-radius: 5px;
  background: #fff;
}
.check input[type="checkbox"]::before { content: ""; width: 8px; height: 5px; border-left: 1.8px solid #fff; border-bottom: 1.8px solid #fff; transform: rotate(-45deg) scale(0); transition: transform .1s ease; }
.check input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
.check input[type="checkbox"]:checked::before { transform: rotate(-45deg) scale(1); }
.retouch-note { margin: 4px 0 18px; padding: 11px 12px; border-radius: 8px; background: #f2f0eb; color: var(--muted); font-size: 10px; line-height: 1.45; }
.health { margin-top: 18px; color: var(--muted); font-size: 10px; }
.health::first-letter { color: currentColor; }
.health.ok { color: var(--ok); }
.health.bad { color: var(--err); }
.key-info { margin-top: 15px; color: #4f5761; font-size: 11px; font-weight: 620; }
.linkish { padding: 0; border: 0; background: none; color: var(--accent-deep); font: inherit; text-decoration: underline; cursor: pointer; }

/* Buttons and action bar */
.btn-primary, .btn-secondary, .btn-ghost {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  transition: transform .12s ease, background-color .14s ease, border-color .14s ease, opacity .14s ease;
}
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--ink); color: #fff; }
.btn-primary svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.btn-primary:hover:not(:disabled) { background: var(--ink-soft); }
.btn-primary:active:not(:disabled), .btn-secondary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .32; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #d2d0ca; }
.btn-secondary:hover { border-color: #9fa4aa; }
.btn-ghost { min-height: 40px; padding: 0 12px; background: transparent; color: var(--muted); border: 0; font-weight: 620; }
.btn-inline { width: auto; min-height: 36px; padding: 0; color: var(--accent-deep); }
.btn-small { width: 100%; min-height: 42px; padding-inline: 12px; font-size: 11px; }
.actionbar { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; padding: 14px 42px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(13,17,23,.1); background: rgba(245,243,238,.92); backdrop-filter: blur(18px); }
.actionbar-inner { width: min(100%, 1156px); margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 24px; }
.actionbar .btn-primary { min-width: 250px; }
.action-hint { color: var(--muted); font-size: 11px; }

/* Key gate */
.key-gate { position: fixed; z-index: 100; inset: 0; padding: 22px; display: grid; place-items: center; overflow-y: auto; background: #eceae5; }
.key-shell { width: min(100%, 1050px); min-height: 620px; display: grid; grid-template-columns: 1.08fr .92fr; overflow: hidden; border-radius: 24px; background: #fff; box-shadow: 0 26px 90px rgba(13,17,23,.16); }
.key-story { position: relative; overflow: hidden; padding: 42px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; background: #090c11; }
.key-story::before { content: ""; position: absolute; inset: 0; opacity: .55; background: radial-gradient(circle at 100% 0%, rgba(113,81,235,.75), transparent 36%), radial-gradient(circle at 0% 100%, rgba(37,142,250,.55), transparent 34%); }
.key-story::after { content: ""; position: absolute; inset: 22px; border: 1px solid rgba(255,255,255,.15); border-radius: 16px; }
.key-story-logo { position: absolute; z-index: 1; top: 32px; left: 32px; width: 105px; height: 105px; border-radius: 50%; object-fit: cover; opacity: .92; }
.key-story-copy, .key-story-meta { position: relative; z-index: 1; }
.eyebrow-light { color: #94c7ff; }
.key-story h2 { max-width: 440px; margin: 0; font-size: clamp(42px, 5vw, 64px); line-height: .96; letter-spacing: -.06em; }
.key-story-copy > p:last-child { max-width: 430px; margin: 24px 0 0; color: #aeb7c4; font-size: 14px; line-height: 1.6; }
.key-story-meta { margin-top: 44px; padding-top: 16px; display: flex; gap: 18px; border-top: 1px solid rgba(255,255,255,.14); color: #949eaa; font-size: 10px; }
.key-card { padding: 54px; display: flex; flex-direction: column; justify-content: center; }
.brand-key { display: none; margin-bottom: 50px; }
.key-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 28px; border-radius: 12px; color: #fff; background: var(--ink); }
.key-icon svg { width: 21px; height: 21px; fill: currentColor; }
.key-card .screen-title { font-size: 39px; line-height: 1.02; }
.key-card .screen-sub { margin: 16px 0 30px; font-size: 13px; }
.key-card .btn-primary { width: 100%; margin-top: 12px; }
#keyInput { height: 58px; padding: 0 16px; color: var(--ink); font-size: 21px; font-weight: 760; letter-spacing: .12em; text-align: center; text-transform: uppercase; }
.key-error { margin: 9px 0 0; color: var(--err); font-size: 12px; line-height: 1.4; }
.key-help { margin: 20px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; text-align: center; }

/* Review and loading */
.review-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(250px, .6fr); gap: 22px; align-items: start; }
.review-card { min-height: 340px; }
.wait-copy { margin-inline: auto; text-align: center; }
#revSpin { margin: 80px auto 18px; }
#revNote { padding-inline: 13px; }
.big-spinner { width: 38px; height: 38px; border: 2px solid #d9d6ce; border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rev-note { margin-bottom: 18px; padding: 13px 14px; border-left: 3px solid var(--warn); border-radius: 7px; background: #f7f1e6; color: #6e562c; font-size: 12px; line-height: 1.5; }
.quiet-check { padding-top: 12px; border-top: 1px solid #e2dfd9; color: var(--muted); }
.guide-card { min-height: 310px; position: relative; overflow: hidden; padding: 28px; border-radius: var(--radius); color: #fff; background: var(--ink); }
.guide-card::after { content: ""; position: absolute; width: 170px; height: 170px; right: -75px; bottom: -75px; border: 1px solid rgba(84,143,255,.65); border-radius: 50%; box-shadow: 0 0 0 30px rgba(118,84,238,.08); }
.guide-number { display: block; margin-bottom: 88px; color: #8fb8ff; font-size: 11px; font-weight: 800; }
.guide-card .section-kicker { color: #8fb8ff; }
.guide-card h3 { max-width: 240px; margin: 8px 0 12px; font-size: 25px; line-height: 1.04; letter-spacing: -.04em; }
.guide-card p:last-child { max-width: 250px; margin: 0; color: #9da7b4; font-size: 11px; line-height: 1.55; }
.loading-content { height: 100%; padding-bottom: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.loading-content .screen-title { font-size: clamp(38px, 4vw, 58px); }
.loading-content .screen-sub { max-width: 560px; }
.loading-visual { width: 150px; height: 180px; margin-bottom: 30px; display: grid; place-items: center; }
.scan-frame { width: 116px; height: 146px; position: relative; border: 1px solid #b8b5ae; border-radius: 8px; background: rgba(255,255,255,.48); }
.scan-frame > span { width: 20px; height: 20px; position: absolute; border-color: var(--ink); }
.scan-frame > span:nth-of-type(1) { top: 10px; left: 10px; border-top: 2px solid; border-left: 2px solid; }
.scan-frame > span:nth-of-type(2) { top: 10px; right: 10px; border-top: 2px solid; border-right: 2px solid; }
.scan-frame > span:nth-of-type(3) { bottom: 10px; left: 10px; border-bottom: 2px solid; border-left: 2px solid; }
.scan-frame > span:nth-of-type(4) { right: 10px; bottom: 10px; border-right: 2px solid; border-bottom: 2px solid; }
.scan-line { position: absolute; z-index: 1; left: 8px; right: 8px; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), var(--violet), transparent); box-shadow: 0 8px 24px rgba(48,124,246,.45); animation: scan 2s ease-in-out infinite; }
@keyframes scan { 0%,100% { top: 16px; } 50% { top: 126px; } }
.sr-spinner { position: absolute; width: 1px; height: 1px; opacity: 0; }
.elapsed { min-width: 72px; margin-top: 16px; padding: 7px 10px; border-radius: 99px; color: var(--ink); background: rgba(255,255,255,.72); font-size: 11px; font-variant-numeric: tabular-nums; }
.loading-steps { width: min(100%, 480px); margin-top: 32px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #cfccc5; }
.loading-steps span { position: relative; padding-top: 13px; color: #999da3; font-size: 9px; }
.loading-steps span::before { content: ""; position: absolute; top: -4px; left: calc(50% - 4px); width: 7px; height: 7px; border-radius: 50%; background: #c4c1ba; }
.loading-steps .done, .loading-steps .active { color: var(--ink); }
.loading-steps .done::before { background: var(--ok); }
.loading-steps .active::before { background: var(--accent); box-shadow: 0 0 0 5px rgba(48,124,246,.12); }
.load-error { margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.err-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--err); font-weight: 800; }
.err-text { max-width: 440px; margin: 0; color: var(--err); font-size: 12px; line-height: 1.5; }

/* Results */
.legend { display: flex; gap: 6px; }
.legend span { padding: 6px 8px; border-radius: 999px; font-size: 9px; font-weight: 750; }
.legend .ok { color: #0a6c45; background: #dff3e9; }
.legend .warn { color: #7f5200; background: #f4ead4; }
.legend .bad { color: #9e3434; background: #f4dddd; }
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.result-item { position: relative; min-width: 0; }
.result-thumb { width: 100%; display: block; aspect-ratio: 7/9; object-fit: cover; border: 2px solid transparent; border-radius: var(--radius-sm); background: #e7e4de; cursor: pointer; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.result-thumb:hover { transform: translateY(-2px); }
.result-thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(48,124,246,.12); }
.sim-badge { position: absolute; top: 10px; right: 10px; padding: 6px 8px; border-radius: 7px; color: #fff; background: rgba(13,17,23,.86); backdrop-filter: blur(8px); font-size: 10px; font-weight: 760; }
.sim-badge.sim-ok { color: #7ce3b5; }
.sim-badge.sim-warn { color: #ffd37b; }
.sim-badge.sim-bad { color: #ff9c9c; }
.inline-guide { margin-top: 18px; padding: 15px 18px; display: flex; gap: 20px; border-top: 1px solid #d3d0ca; color: var(--muted); font-size: 11px; line-height: 1.5; }
.inline-guide b { flex: none; color: var(--ink); }

/* Crop */
.crop-grid { grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr); }
.crop-pane { min-width: 0; }
.crop-stage { width: 100%; display: flex; justify-content: center; overflow: hidden; border-radius: var(--radius); background: #dcd9d2; box-shadow: inset 0 0 0 1px rgba(13,17,23,.08); }
#cropCanvas { display: block; width: auto; max-width: 100%; height: min(60vh, 680px); max-height: 680px; object-fit: contain; background: #c9c7c1; cursor: grab; touch-action: none; outline: none; }
#cropCanvas.grabbing { cursor: grabbing; }
.canvas-tip { margin: 10px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.canvas-tip span { color: var(--accent); font-weight: 800; }
.crop-panel { position: sticky; top: 12px; }
.crop-controls { display: flex; flex-direction: column; gap: 22px; }
.ctl-block { display: flex; flex-direction: column; gap: 10px; }
.ctl-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.rot-val { color: var(--ink); font-weight: 760; font-variant-numeric: tabular-nums; }
.ctl-row { display: flex; align-items: center; gap: 9px; }
.ctl-row input[type="range"], .ctl-block > input[type="range"] { flex: 1; width: 100%; height: 24px; accent-color: var(--accent); }
.icon-btn { width: 38px; height: 38px; flex: none; padding: 0; border: 1px solid #d2d0ca; border-radius: 9px; background: #fff; color: var(--ink); font-size: 20px; cursor: pointer; }
.ctl-row-btns { display: flex; flex-direction: column; gap: 5px; }
.crop-rule { margin-top: 22px; padding: 14px; border-radius: 9px; background: #f0eee9; }
.crop-rule span { color: var(--accent-deep); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.crop-rule p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

/* Download */
.success-head { margin-bottom: 24px; }
.download-grid { display: grid; grid-template-columns: minmax(320px, .78fr) minmax(400px, 1.22fr); gap: 26px; align-items: start; }
.final-pane { min-width: 0; }
.final-frame { min-height: 420px; padding: 24px; display: grid; place-items: center; border-radius: var(--radius); background: #dcd9d2; }
.final-preview { display: block; width: auto; max-width: 100%; height: auto; max-height: 560px; border-radius: 5px; box-shadow: 0 16px 45px rgba(13,17,23,.16); }
.download-panel { padding: 24px; }
.layout-box { padding: 0; }
.sheet-preview { display: block; width: 100%; max-height: 260px; object-fit: contain; margin: 14px 0; border: 1px solid #d7d4cd; border-radius: 8px; background: #f3f1ec; }
.sheet-hint { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.bw-check { padding: 4px 0 14px; }
.print-opts { border-top: 1px solid #dedbd4; border-bottom: 1px solid #dedbd4; }
.print-opts > summary { padding: 16px 0; list-style: none; color: var(--accent-deep); font-size: 11px; font-weight: 720; cursor: pointer; }
.print-opts > summary::-webkit-details-marker { display: none; }
.print-opts > summary::before { content: "+"; display: inline-block; width: 18px; }
.print-opts[open] > summary::before { content: "−"; }
.print-opts .field { margin-top: 12px; }
.print-spec { margin: 12px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.print-spec-muted { opacity: .78; }
.downloads { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.downloads .btn-primary, .downloads .btn-secondary { width: 100%; padding-inline: 12px; }
.downloads #dlZip { grid-column: 1 / -1; }
.dl-status { min-height: 18px; margin-top: 11px; color: var(--muted); font-size: 11px; }
.dl-status.ok { color: var(--ok); }
.dl-status.err { color: var(--err); }
.download-backlinks { margin-top: 8px; display: flex; gap: 20px; }
.key-left { margin-top: 12px; padding: 15px 17px; display: flex; align-items: center; gap: 12px; border: 1px solid #d4d1ca; border-radius: 10px; background: rgba(255,255,255,.5); }
.key-left-num { color: var(--accent-deep); font-size: 28px; font-weight: 780; line-height: 1; }
.key-left-cap { color: var(--text); font-size: 11px; line-height: 1.4; }
.key-left.empty .key-left-num { color: var(--err); }
.key-left.empty .key-left-cap { color: var(--muted); }

/* Batch and history */
.batch-wrap { margin-top: 12px; }
.batch-title, .history-title { margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 650; }
.batch-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.batch-item { position: relative; width: 64px; }
.batch-item img { width: 64px; height: 78px; display: block; object-fit: cover; border: 1px solid #d4d1ca; border-radius: 8px; }
.batch-del { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; padding: 0; border: 1px solid rgba(255,255,255,.6); border-radius: 50%; background: rgba(13,17,23,.88); color: #fff; font-size: 12px; cursor: pointer; }
.history { margin-top: 18px; }
.history-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.history-item { flex: 0 0 auto; width: 62px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 9px; cursor: pointer; }
.history-item img { width: 62px; height: 78px; display: block; object-fit: cover; border: 1px solid #d4d1ca; border-radius: 8px; transition: transform .12s ease; }
.history-item:active img { transform: scale(.96); }
.history-item .h-date { margin-top: 4px; text-align: center; }

/* Responsive */
@media (max-width: 980px) {
  :root { --header-h: 64px; --bar-h: calc(82px + env(safe-area-inset-bottom)); }
  .chrome-inner { padding: 0 20px; grid-template-columns: 150px 1fr 150px; gap: 14px; }
  .brand { font-size: 15px; }
  .brand img { width: 32px; height: 32px; }
  .progress-step { min-width: 86px; grid-template-columns: 22px 1fr; column-gap: 6px; }
  .progress-step::after { left: 22px; top: 10px; }
  .progress-num { width: 22px; height: 22px; font-size: 9px; }
  .progress-label { font-size: 9px; }
  .progress-meta, .support-copy small { display: none; }
  .content { padding: 34px 20px calc(28px + var(--bar-h)); }
  .screen-title { font-size: 42px; }
  .workspace-grid { grid-template-columns: minmax(0, 1.2fr) minmax(310px, .8fr); gap: 18px; }
  .quality-card { grid-template-columns: 1fr; }
  .quality-list { gap: 10px; }
  .key-card { padding: 42px; }
}

@media (max-width: 720px) {
  body { background: var(--paper); }
  #chrome { border-bottom-color: rgba(13,17,23,.08); }
  .chrome-inner { padding: 0 16px; grid-template-columns: 1fr auto; }
  .brand { grid-column: 1; grid-row: 1; }
  .chrome-back:not([hidden]) { grid-column: 1; grid-row: 1; padding-left: 0; background: var(--paper); }
  .chrome-back:not([hidden]) + .dots { grid-column: 2; }
  .dots { grid-column: 2; gap: 5px; }
  .progress-step { min-width: 0; width: 24px; display: block; }
  .progress-step::after, .progress-label, .progress-meta { display: none; }
  .progress-num { width: 24px; height: 24px; }
  .progress-step.active { width: auto; }
  .progress-step.active .progress-num { width: auto; min-width: 72px; padding: 0 9px; border-radius: 99px; }
  .progress-step.active .progress-num::after { content: " / 4"; margin-left: 2px; opacity: .64; }
  .support-chip { display: none; }
  .content { padding: 27px 16px calc(24px + var(--bar-h)); }
  .stage-head { display: block; margin-bottom: 21px; }
  .eyebrow { margin-bottom: 10px; font-size: 9px; }
  .screen-title { font-size: 33px; line-height: 1; }
  .screen-sub { margin-top: 13px; font-size: 13px; line-height: 1.5; }
  .trust-row { margin-top: 16px; justify-content: flex-start; }
  .trust-row span { padding: 6px 8px; font-size: 9px; }
  .workspace-grid, .review-layout, .download-grid { display: flex; flex-direction: column; gap: 14px; }
  .pane, .setup-panel, .crop-panel, .review-card, .download-panel, .final-pane { width: 100%; }
  .drop { min-height: 285px; border-radius: 14px; }
  .drop::before, .drop::after { width: 42px; height: 42px; }
  .drop-inner { padding: 28px 18px; }
  .drop-mark { width: 50px; height: 50px; margin-bottom: 19px; }
  .drop-inner strong { font-size: 19px; }
  .drop-inner > span:not(.drop-mark) { max-width: 230px; font-size: 12px; }
  .drop-inner em { margin-top: 18px; font-size: 0; }
  .drop-inner em::after { content: "JPG, PNG или HEIC · до 20 МБ"; font-size: 9px; }
  .preview { max-height: 430px; }
  .quality-card { padding: 17px; display: block; }
  .quality-intro { margin-bottom: 15px; }
  .quality-list { grid-template-columns: 1fr; gap: 10px; }
  .quality-list li { padding-top: 9px; border-top: 1px solid rgba(13,17,23,.08); }
  .quality-list small { font-size: 10px; }
  .setup-panel, .crop-panel, .review-card, .download-panel { padding: 20px; border-radius: 14px; }
  .setup-panel { margin-top: 0; }
  .panel-heading { margin-bottom: 20px; }
  .field { margin-bottom: 18px; }
  select, input[type="text"] { min-height: 50px; font-size: 12px; }
  .actionbar { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .actionbar-inner { display: block; }
  .actionbar .btn-primary { width: 100%; min-width: 0; min-height: 52px; }
  .action-hint { display: none; }
  .guide-card { min-height: 210px; padding: 22px; }
  .guide-number { margin-bottom: 48px; }
  .loading-content { padding-bottom: 30px; }
  .loading-visual { width: 115px; height: 140px; margin-bottom: 22px; transform: scale(.82); }
  .loading-content .screen-title { font-size: 35px; }
  .loading-content .screen-sub { max-width: 330px; }
  .legend { margin-top: 16px; }
  .results { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .inline-guide { gap: 12px; padding-inline: 4px; }
  .crop-panel { position: static; }
  #cropCanvas { height: min(53vh, 500px); }
  .final-frame { min-height: 330px; padding: 18px; }
  .final-preview { max-height: 460px; }
  .downloads { grid-template-columns: 1fr; }
  .downloads #dlZip { grid-column: auto; }
  .download-backlinks { justify-content: space-between; }
  .key-gate { padding: 0; place-items: stretch; background: #fff; }
  .key-shell { min-height: 100dvh; display: block; border-radius: 0; box-shadow: none; }
  .key-story { display: none; }
  .key-card { min-height: 100dvh; padding: 150px 24px max(34px, env(safe-area-inset-bottom)); justify-content: flex-start; }
  .brand-key { display: inline-flex; position: absolute; top: 24px; left: 24px; }
  .key-icon { margin-bottom: 22px; }
  .key-card .screen-title { font-size: 35px; }
  .key-card .screen-sub { font-size: 12px; }
}

@media (max-width: 380px) {
  .brand span { display: none; }
  .screen-title { font-size: 30px; }
  .trust-row span:last-child { display: none; }
  .results { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ================= Починка нижней части экранов на мобильных =================
   .content — единственный ребёнок .screen в потоке и одновременно скролл-контейнер.
   Без явного flex он получает `flex: 0 1 auto`, и WebKit на iOS не применяет к нему
   автоматический минимальный размер 0: блок вырастает во всю высоту содержимого,
   вылезает за пределы .screen и обрезается `#screens { overflow: hidden }`. Сам он
   при этом не переполняется — значит, и не скроллится, и низ экрана недостижим.
   Проявляется ровно тогда, когда контент перестаёт помещаться, — после загрузки
   фото. Задаём размер явно. */
.content { flex: 1 1 auto; min-height: 0; }

/* Активный экран больше не держит на себе transform: он создаёт содержащий блок и
   отдельный слой композитора вокруг скролла — на этом iOS теряет перерисовку
   нижней части. Анимация въезда сохраняется: translateX(28px) → none. */
.screen.active { transform: none; }

@media (max-width: 720px) {
  /* backdrop-filter на панелях, висящих поверх скролла, — главный источник
     неперерисованных областей в вебвью iOS. Полосы и так почти непрозрачные,
     на телефоне просто делаем их сплошными. */
  #chrome { background: #f5f3ee; backdrop-filter: none; }
  .actionbar { background: #f5f3ee; backdrop-filter: none; }
}
