/* Sejda: crop readings for print. One stylesheet for every page. */

:root {
  color-scheme: light dark;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --surface-3: #efece5;
  --ink: #1c1b18;
  --ink-2: #4b4943;
  --muted: #7b776e;
  --line: #e4e0d7;
  --line-strong: #d2ccc0;
  --accent: #2b5d8a;
  --accent-hover: #234e75;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --accent-line: #b9cde2;
  --good: #2e7a4d;  --good-soft: #e2f0e7;
  --ok: #56701e;    --ok-soft: #ecf1dc;
  --warn: #93650d;  --warn-soft: #f6ecd3;
  --bad: #a4382c;   --bad-soft: #f7e2de;
  --desk: #e8e5de;
  --paper: #ffffff;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(28, 27, 24, .06);
  --shadow-2: 0 1px 2px rgba(28, 27, 24, .06), 0 8px 24px rgba(28, 27, 24, .07);
  --shadow-sheet: 0 1px 2px rgba(0, 0, 0, .10), 0 10px 30px rgba(0, 0, 0, .10);
  --topbar: 56px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1b1c1f;
    --surface-2: #202124;
    --surface-3: #27282c;
    --ink: #ecebe6;
    --ink-2: #c7c4bc;
    --muted: #8f8b82;
    --line: #2d2e33;
    --line-strong: #3b3d43;
    --accent: #8cb6e2;
    --accent-hover: #a6c7ea;
    --accent-ink: #0c1a28;
    --accent-soft: #1d2a38;
    --accent-line: #34506c;
    --good: #7cc596;  --good-soft: #1b2d22;
    --ok: #b4ca79;    --ok-soft: #262d19;
    --warn: #e3b765;  --warn-soft: #2f2716;
    --bad: #ee9082;   --bad-soft: #35201d;
    --desk: #0e0f10;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-sheet: 0 1px 3px rgba(0, 0, 0, .5), 0 12px 36px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; flex: none; }
.crumb-sep { color: var(--line-strong); font-size: 18px; font-weight: 300; }
.doc-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.doc-title h1 { font: 600 15px/1.2 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-title .muted { font-size: 12.5px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topnav { display: flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-weight: 550; font-size: 13.5px; white-space: nowrap;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  box-shadow: var(--shadow-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-big { height: 46px; font-size: 15px; border-radius: 10px; width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 550; }
.link-button:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- pills, chips */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.ok   { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad  { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }

.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- home */
.home { max-width: 1040px; margin: 0 auto; padding: 44px 22px 80px; }
.hero { max-width: 660px; margin: 0 auto 26px; text-align: center; }
.hero h1 { font: 600 34px/1.15 var(--serif); letter-spacing: -.01em; }
.hero p { margin: 12px 0 0; color: var(--ink-2); font-size: 15.5px; }

.drop {
  position: relative; display: block;
  max-width: 760px; margin: 0 auto;
  padding: 44px 24px 38px; border-radius: 18px;
  border: 1.5px dashed var(--line-strong);
  background: var(--surface);
  text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  box-shadow: var(--shadow-1);
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.drop.is-over { transform: scale(1.01); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 58px; height: 58px; margin: 0 auto 14px; color: var(--accent); }
.drop-title { font-size: 17px; font-weight: 600; }
.drop-title u { text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.drop-sub { margin-top: 6px; color: var(--muted); font-size: 13px; }
.uploads { max-width: 760px; margin: 14px auto 0; display: grid; gap: 8px; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.upload-row .bar { grid-column: 1 / -1; }
.upload-row.is-error { border-color: var(--bad); color: var(--bad); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.bar.is-indeterminate > i { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 48px 0 14px; }
.section-head h2 { font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.doc-card {
  position: relative; display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start;
  padding: 12px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--line); color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.doc-card:hover { text-decoration: none; border-color: var(--accent-line); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.doc-card .thumb { width: 64px; aspect-ratio: 8.5 / 11; border-radius: 4px; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.doc-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.doc-card h3 { font: 600 14.5px/1.3 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 22px; }
.doc-card .meta { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.doc-card .hide {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s, background .15s;
}
.doc-card:hover .hide, .doc-card .hide:focus-visible { opacity: 1; }
.doc-card .hide:hover { background: var(--surface-3); color: var(--ink); }
.empty-note { text-align: center; color: var(--muted); padding: 22px; }

/* ---------------------------------------------------------------- document workspace */
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 372px;
  height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar));
}
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--desk); }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; min-height: 48px; }
.stage-head .where { font-size: 13px; color: var(--ink-2); }
.stage-head .where b { color: var(--ink); font-weight: 650; }
.stage-view { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 60px 12px; }
.sheet {
  position: relative; margin: 0; max-width: 100%; max-height: 100%;
  aspect-ratio: var(--sheet-aspect, 11 / 8.5);
  background: var(--paper); box-shadow: var(--shadow-sheet); border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.sheet img { width: 100%; height: 100%; object-fit: contain; transition: opacity .2s; }
.sheet.is-loading img { opacity: .55; }
.sheet .sheet-spin { position: absolute; top: 12px; right: 12px; color: var(--muted); opacity: 0; transition: opacity .2s; }
.sheet.is-loading .sheet-spin { opacity: 1; }
.nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-2);
  transition: opacity .15s, background .15s;
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn:disabled { opacity: 0; pointer-events: none; }
.nav-btn svg { width: 18px; height: 18px; }
.nav-prev { left: 12px; }
.nav-next { right: 12px; }

.filmstrip {
  display: flex; gap: 10px; overflow-x: auto; padding: 10px 16px 14px;
  scrollbar-width: thin; scroll-snap-type: x proximity;
}
.film {
  flex: none; display: grid; gap: 4px; justify-items: center; padding: 0; border: 0; background: none;
  cursor: pointer; color: var(--muted); font-size: 11px; scroll-snap-align: center;
}
.film .frame {
  height: 62px; aspect-ratio: var(--sheet-aspect, 11 / 8.5); background: var(--paper);
  border-radius: 2px; overflow: hidden; outline: 2px solid transparent; outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--line-strong); transition: outline-color .15s;
}
.film .frame img { width: 100%; height: 100%; object-fit: cover; }
.film[aria-current="true"] { color: var(--ink); font-weight: 650; }
.film[aria-current="true"] .frame { outline-color: var(--accent); }

/* analysis / error overlay on the stage */
.stage-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--desk); z-index: 5; }
.status-card {
  width: min(440px, 100%); padding: 26px 26px 22px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); text-align: center;
}
.status-card h2 { font: 600 20px/1.3 var(--serif); margin-bottom: 6px; }
.status-card p { margin: 0 0 16px; color: var(--ink-2); }
.status-card .bar { margin: 18px 0 8px; }
.status-card .actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.status-art { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--accent); }
.status-art .scan { animation: scan 1.8s ease-in-out infinite; }
.status-card.is-error .status-art { color: var(--bad); }
.status-card.is-error .scan { display: none; }
.workspace.is-waiting .panel-body { opacity: .45; pointer-events: none; }
body.is-planning .summary { opacity: .6; transition: opacity .2s .15s; }
@keyframes scan { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(26px); } }

/* ---------------------------------------------------------------- settings panel */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.panel-body { flex: 1; overflow-y: auto; padding: 18px 18px 8px; }
.panel-foot { padding: 14px 18px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.panel-foot .fine { text-align: center; margin-top: 8px; }
.control { padding: 16px 0; border-top: 1px solid var(--line); }
.control:first-of-type { border-top: 0; }
.control-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.control h3 { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.hint.is-cost { color: var(--warn); }

.summary {
  padding: 16px 16px 14px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 4px;
}
.summary-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pt-big { display: flex; align-items: baseline; gap: 4px; font: 600 40px/1 var(--serif); letter-spacing: -.02em; }
.pt-big .unit { font: 600 15px/1 var(--font); color: var(--muted); letter-spacing: 0; }
.pt-label { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.gain { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; margin: 14px 0 2px; font-size: 12px; color: var(--muted); }
.gain .track { height: 6px; border-radius: 99px; background: var(--surface-3); position: relative; overflow: hidden; }
.gain .track i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; }
.gain .was i { background: var(--line-strong); }
.gain .now i { background: var(--accent); }
.gain b { color: var(--ink); font-weight: 650; }
.facts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 3px; font-size: 12.5px; color: var(--ink-2); }
.facts li { display: flex; gap: 7px; align-items: baseline; }
.facts li::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); flex: none; transform: translateY(-2px); }
.suggest { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.suggest button { color: inherit; text-decoration: underline; }

/* segmented control */
.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-3); }
.seg button {
  display: grid; justify-items: center; gap: 2px; padding: 8px 6px 7px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
  font-size: 12.5px; font-weight: 550; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.seg svg { width: 26px; height: 20px; color: var(--muted); }
.seg button[aria-checked="true"] svg { color: var(--accent); }
.seg small { font-size: 11px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.seg.compact button { padding: 7px 6px; }

/* scan clean-up swatches */
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.swatch {
  display: grid; gap: 0; padding: 0; overflow: hidden; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.swatch:hover { border-color: var(--line-strong); }
.swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.swatch .img { aspect-ratio: 16 / 9; background: var(--paper) center / cover no-repeat; border-bottom: 1px solid var(--line); }
.swatch .img.is-loading { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.swatch .txt { padding: 6px 9px 7px; }
.swatch b { display: block; font-size: 12.5px; font-weight: 600; }
.swatch span { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.pages-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pages-line p { margin: 0; font-size: 13px; color: var(--ink-2); }
.notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.notes li { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

details.more { margin-top: 10px; }
details.more summary { list-style: none; cursor: pointer; text-align: center; font-size: 12.5px; color: var(--muted); padding: 4px; border-radius: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary:hover { color: var(--ink); }
.more-menu { display: grid; gap: 2px; margin-top: 6px; }
.more-menu .btn { justify-content: flex-start; width: 100%; }

/* download button progress */
.btn-big .progress-fill { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, .18); width: 0; transition: width .3s; }
.btn-big { position: relative; overflow: hidden; }
.btn-big .label { position: relative; display: inline-flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- dialogs */
body:has(dialog[open]) { overflow: hidden; }
dialog.sheet-dialog {
  width: min(1180px, calc(100vw - 32px)); max-width: none;
  height: min(860px, calc(100vh - 32px)); max-height: none;
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}
dialog.sheet-dialog[open] { display: flex; flex-direction: column; }
dialog.sheet-dialog::backdrop { background: rgba(20, 18, 14, .45); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dialog-head h2 { font: 600 18px/1.3 var(--serif); }
.dialog-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.dialog-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dialog-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 16px 14px; }
.page-tile { display: grid; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; color: var(--ink-2); font-size: 12px; }
.page-tile .frame { position: relative; width: 100%; aspect-ratio: var(--aspect, 1.294); background: var(--paper); border-radius: 3px; box-shadow: 0 0 0 1px var(--line-strong); overflow: hidden; transition: opacity .15s, box-shadow .15s; }
.page-tile .frame img { width: 100%; height: 100%; object-fit: contain; }
.page-tile .crop { position: absolute; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); box-shadow: 0 0 0 9999px rgba(20, 18, 14, .16); border-radius: 1px; }
.page-tile .check {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.page-tile .check svg { width: 12px; height: 12px; }
.page-tile .tag { position: absolute; left: 6px; bottom: 6px; }
.page-tile[aria-pressed="false"] .frame { opacity: .38; box-shadow: 0 0 0 1px var(--line); }
.page-tile[aria-pressed="false"] .check { background: var(--surface); color: transparent; box-shadow: 0 0 0 1.5px var(--line-strong); }
.page-tile[aria-pressed="false"] .crop { display: none; }
.page-tile b { color: var(--ink); font-weight: 600; }

/* enhancement comparison (auto page + manual editor) */
.compare-grid { display: grid; grid-template-columns: repeat(var(--compare-columns, 4), minmax(0, 1fr)); gap: 10px; }
.compare-columns { position: sticky; top: -18px; z-index: 2; padding: 4px 0 8px; background: var(--surface); }
.compare-column { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 12.5px; font-weight: 600; }
.compare-column.is-chosen { border-color: var(--accent); color: var(--accent); }
.compare-row h4 { margin: 14px 0 7px; color: var(--muted); font-size: 12px; font-weight: 550; }
.compare-cell { overflow: hidden; border-radius: 8px; background: var(--paper); cursor: zoom-in; box-shadow: 0 0 0 1px var(--line); }
.compare-cell img { width: 100%; height: auto; transition: transform .15s ease; }
.compare-row.is-zoomed .compare-cell { cursor: zoom-out; }
.compare-row.is-zoomed .compare-cell img { transform: scale(3); }
.compare-cell.is-loading { aspect-ratio: 8.5 / 11; cursor: progress; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.compare-cell.is-loading img { display: none; }
.compare-error { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--bad); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 60; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 13.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--bad); color: #fff; }

/* ---------------------------------------------------------------- manual editor */
.editor .stage-view { padding: 16px 24px 20px; overflow: auto; align-items: flex-start; }
.crop-panels { display: grid; gap: 18px; width: 100%; max-width: 980px; margin: 0 auto; }
.crop-panels.two { grid-template-columns: 1fr 1fr; max-width: 1400px; }
.crop-panel h3 { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.canvas-wrap { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; background: var(--paper); box-shadow: var(--shadow-sheet); border-radius: 2px; overflow: hidden; }
.canvas-wrap img { max-width: 100%; max-height: calc(100vh - var(--topbar) - 110px); width: auto; height: auto; }
.crop-panels.two .canvas-wrap img { max-height: calc(100vh - var(--topbar) - 140px); }
.canvas-wrap canvas { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); margin: 8px 0; }
.field input[type="number"], .field select {
  height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); min-width: 0;
}
.field input[type="number"] { width: 84px; }
.field select { max-width: 190px; }
.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); cursor: pointer; transition: background .2s; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.button-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); padding: 30px 28px 26px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); }
.login-card .brand { margin-bottom: 18px; }
.login-card h1 { font: 600 24px/1.2 var(--serif); margin-bottom: 4px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.login-card input[type="password"] { width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); margin-bottom: 14px; }
.login-card input[type="password"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .stage { min-height: 0; }
  .stage-view { flex: none; padding: 4px 12px 10px; min-height: 0; }
  .stage-overlay { position: relative; inset: auto; min-height: 60vh; }
  .nav-btn, #stageHint { display: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-foot { position: sticky; bottom: 0; }
  .crop-panels.two { grid-template-columns: 1fr; }
  .doc-title .muted { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand span { display: none; }
  .hero h1 { font-size: 27px; }
  .home { padding-top: 28px; }
  .drop { padding: 34px 16px 30px; }
  .compare-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
