/* FauxScan styles, shared by every page (index.html and the translated pages in lang/). */
@font-face { font-family: "Geist"; font-weight: 400; font-display: optional; src: url("fonts/geist-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 600; font-display: optional; src: url("fonts/geist-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 400; font-display: optional; src: url("fonts/geist-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 500; font-display: optional; src: url("fonts/geist-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-display: optional; src: url("fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }

/* The scan head position, animatable so the head and the reveal move together. */
@property --head { syntax: "<percentage>"; inherits: true; initial-value: 46%; }

:root {
  --shell: #e6e8ea; --panel: #f7f8f9; --card: #ffffff; --line: #cdd2d7; --line-soft: #d5d9dd;
  --fg: #15181c; --muted: #4d5761; --ctl: #7a848e; --seg: #e6e8ea; --seg-on: #ffffff;
  --accent: #2f37be; --accent-fg: #ffffff; --accent-text: #2f37be; --accent-hover: #1e248a;
  --changed: #262c9c; --tag-bg: #e3e5f8; --tag-fg: #262c9c; --focus: #2f37be; --ok: #1b6b3a; --warn: #9a3412;
  --logo-tile: #15181c; --logo-lid: #3b424a;
  --glass: #0e1216; --glass-hi: #1b222a; --glow: #dff7ff; --glow-2: #9fe3ff;
  --glass-fg: #e9f7ff; --glass-muted: #b7c1ca; --glass-dim: #a9b4be; --glass-line: #252c33; --glass-ctl: #3c454e;
  --f-display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --f-ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --row: 70px;
  --caps-track: .1em;   /* letter-spacing for small uppercase labels; off for scripts it would break */
  --range: var(--accent);
  color-scheme: light;
}
/* Dark mode follows the system unless the theme button set data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shell: #121518; --panel: #1a1f24; --card: #22282e; --line: #343c44; --line-soft: #2c333a;
    --fg: #e8ecef; --muted: #a7b1ba; --ctl: #808b95; --seg: #121518; --seg-on: #333b43;
    --accent-text: #b4b8ff; --accent-hover: #d2d4ff; --changed: #c3c6ff; --tag-bg: #2a2f6b; --tag-fg: #dcdeff;
    --focus: #b4b8ff; --ok: #7fe0a6; --warn: #f4ad86; --logo-tile: #050709;
    --range: var(--accent-text);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --shell: #121518; --panel: #1a1f24; --card: #22282e; --line: #343c44; --line-soft: #2c333a;
  --fg: #e8ecef; --muted: #a7b1ba; --ctl: #808b95; --seg: #121518; --seg-on: #333b43;
  --accent-text: #b4b8ff; --accent-hover: #d2d4ff; --changed: #c3c6ff; --tag-bg: #2a2f6b; --tag-fg: #dcdeff;
  --focus: #b4b8ff; --ok: #7fe0a6; --warn: #f4ad86; --logo-tile: #050709;
  --range: var(--accent-text);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--shell); color: var(--fg); font: 15px/1.5 var(--f-ui); -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img, svg { display: block; }
[hidden] { display: none !important; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
.vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.label { font-family: var(--f-mono); font-size: 12px; font-weight: 500; letter-spacing: var(--caps-track); text-transform: uppercase; color: var(--muted); }
@media (min-width: 761px) { .phone-only { display: none !important; } }

.skip { position: absolute; left: 12px; top: -200px; z-index: 50; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--accent-fg); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; color: var(--accent-fg); }

/* ---------- shell: fills the window on desktop; the page itself never scrolls ---------- */
.shell { height: 100vh; height: 100dvh; min-height: 560px; display: flex; flex-direction: column; overflow: hidden; }

.top { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 16px 28px 14px; padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 36px; height: 36px; flex: none; }
.wordmark { font-family: var(--f-display); font-weight: 800; font-size: 26px; line-height: 1; letter-spacing: -.02em; }
.tagline { font-size: 13.5px; color: var(--muted); }
.grow { flex: 1; }
.privacy { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13.5px; }
.privacy svg { stroke: var(--ok); flex: none; }
.privacy strong { font-weight: 600; }
.theme { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
.theme:hover { border-color: var(--ctl); }
.theme .i-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme .i-sun { display: block; } :root:not([data-theme="light"]) .theme .i-moon { display: none; } }
:root[data-theme="dark"] .theme .i-sun { display: block; }
:root[data-theme="dark"] .theme .i-moon { display: none; }
.gh { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; text-decoration: none; }

.work {
  flex: 1; min-height: 0; display: grid; gap: 20px;
  grid-template-columns: clamp(176px, 18vw, 260px) minmax(0, 1fr) clamp(290px, 28vw, 400px);
  padding: 0 28px 12px; padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right));
}

.foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 24px; padding: 0 28px 12px; font-size: 13.5px; color: var(--muted); }
.langs { display: flex; flex-wrap: wrap; gap: 2px; }
.langs a { display: inline-flex; align-items: center; min-height: 24px; padding: 0 7px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--accent-text); text-decoration: underline; }
.langs a[aria-current="page"] { color: var(--fg); font-weight: 600; }

/* Scripts the Latin web fonts don't cover fall back to good system fonts; letter-spacing would break their shaping. */
:root:lang(hi), :root:lang(zh) { --caps-track: 0; }
:root:lang(hi) {
  --f-ui: "Geist", "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", "Mangal", system-ui, sans-serif;
  --f-display: "Bricolage Grotesque", "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", system-ui, sans-serif;
  --f-mono: var(--f-ui);   /* monospace spacing breaks up Devanagari words */
}
:root:lang(zh) {
  --f-ui: "Geist", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --f-display: "Bricolage Grotesque", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
  --f-mono: var(--f-ui);
}

/* ---------- files (the document feeder) ---------- */
.feed { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.feed-head { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.feed-head h2 { flex: 1; }
.link-btn { min-height: 32px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--accent-text); font-size: 13.5px; font-weight: 600; }
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }
.summary { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.filter { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--ctl); background: var(--card); }
.filter:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.filter svg { stroke: var(--muted); flex: none; }
.filter input { flex: 1; min-width: 0; min-height: 36px; border: 0; background: transparent; font-size: 14px; outline: none; }
.empty { padding: 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.vlist { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: -3px; padding: 3px; scrollbar-width: thin; scrollbar-color: var(--ctl) transparent; }
.vspace { position: relative; }
.qlist { position: absolute; left: 0; right: 0; top: 0; list-style: none; margin: 0; padding: 0; }
.qlist li { display: flex; gap: 4px; height: calc(var(--row) - 8px); margin-bottom: 8px; }
.row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.row:hover { border-color: var(--ctl); }
.row[aria-current="true"] { border: 2px solid var(--accent); padding: 7px; background: var(--card); }
.thumb { flex: 0 0 34px; height: 46px; border-radius: 3px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--line); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { stroke: #7a848e; }
.row-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.row-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-family: var(--f-mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta.err { color: var(--warn); }
.row-x { flex: 0 0 32px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.row-x:hover { background: var(--seg); color: var(--fg); }
.add { flex: none; display: flex; flex-direction: column; gap: 6px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 84px; padding: 10px; border-radius: 12px; border: 1.5px dashed var(--ctl); background: transparent; }
.dropzone:hover, body.dragging .dropzone { border-color: var(--accent); background: var(--card); }
.dropzone strong { font-size: 14px; font-weight: 600; }
.dropzone span { font-size: 12.5px; color: var(--muted); }
.add .link-btn { align-self: center; }
.hint { flex: none; font-size: 13px; color: var(--muted); line-height: 1.4; }

/* ---------- the glass ---------- */
.glass {
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; border-radius: 20px; overflow: hidden;
  background: radial-gradient(130% 90% at 25% 0%, var(--glass-hi) 0%, var(--glass) 62%); color: var(--glass-fg);
  box-shadow: inset 0 0 0 1px #2a3138, 0 18px 40px -24px rgba(10, 14, 18, .6);
}
.glass :focus-visible { outline-color: var(--glow-2); }
.stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; padding: 38px 24px 24px 40px; container-type: size; }
/* The page. Pointer dragging of the scan head is handled on it; #head (the range input) serves keyboards and screen readers. */
.doc {
  --ar: 0.7075; --wmm: 210; --hmm: 297;
  position: relative; width: min(100cqw, 100cqh * var(--ar)); height: min(100cqh, 100cqw / var(--ar)); container-type: size;
  cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none;
}
.doc.dragging { cursor: grabbing; }
.doc img { position: absolute; inset: 0; width: 100%; height: 100%; -webkit-user-drag: none; }
.base { z-index: 0; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .7); }
/* The layer above the head is the scanned page. The wrapper slides up so its bottom edge sits on the head, the image slides back down
   by the same amount, so only transforms change while the head moves. */
.reveal { position: absolute; inset: 0; z-index: 1; overflow: hidden; transform: translateY(calc(var(--head) - 100%)); will-change: transform; pointer-events: none; }
.reveal img { transform: translateY(calc(100% - var(--head))); will-change: transform; }
.ruler-x, .ruler-y { position: absolute; pointer-events: none; color: var(--glass-dim); font-family: var(--f-mono); font-size: 11px; line-height: 1; }
.ruler-x {
  left: 0; bottom: calc(100% + 4px); width: 100%; height: 30px;
  background:
    repeating-linear-gradient(90deg, rgba(190,204,216,.6) 0 1px, transparent 1px calc(100% * 50 / var(--wmm))) bottom / 100% 12px no-repeat,
    repeating-linear-gradient(90deg, rgba(190,204,216,.45) 0 1px, transparent 1px calc(100% * 10 / var(--wmm))) bottom / 100% 8px no-repeat,
    repeating-linear-gradient(90deg, rgba(190,204,216,.25) 0 1px, transparent 1px calc(100% * 2 / var(--wmm))) bottom / 100% 4px no-repeat;
}
.ruler-x span { position: absolute; top: 2px; left: calc(100% * var(--i) * 50 / var(--wmm)); transform: translateX(-50%); white-space: nowrap; }
.ruler-x span:first-child { transform: none; }
.ruler-y {
  top: 0; right: calc(100% + 4px); width: 30px; height: 100%;
  background:
    repeating-linear-gradient(180deg, rgba(190,204,216,.6) 0 1px, transparent 1px calc(100% * 50 / var(--hmm))) right / 12px 100% no-repeat,
    repeating-linear-gradient(180deg, rgba(190,204,216,.45) 0 1px, transparent 1px calc(100% * 10 / var(--hmm))) right / 8px 100% no-repeat,
    repeating-linear-gradient(180deg, rgba(190,204,216,.25) 0 1px, transparent 1px calc(100% * 2 / var(--hmm))) right / 4px 100% no-repeat;
}
.ruler-y span { position: absolute; top: 10px; left: 0; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10.5px; letter-spacing: calc(var(--caps-track) * 1.2); }
.corner { position: absolute; right: calc(100% + 12px); bottom: calc(100% + 12px); width: 20px; height: 20px; pointer-events: none; }
.corner path { fill: var(--glow-2); }

.head-in { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; margin: 0; opacity: 0; writing-mode: vertical-lr; direction: ltr; pointer-events: none; }
.headclip { position: absolute; z-index: 2; top: -32px; bottom: -32px; left: -28px; right: -28px; overflow: hidden; pointer-events: none; transition: opacity .3s; }
.head { position: absolute; left: 0; right: 0; top: 32px; height: calc(100% - 64px); transform: translateY(var(--head)); will-change: transform; }
.doc.glide { transition: --head .22s cubic-bezier(.2, .7, .3, 1); }
.doc.intro { --head: 0%; }
.doc.intro .headclip { opacity: 0; }
.bar { position: absolute; left: 0; right: 0; top: -3px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, rgba(223,247,255,0) 0%, var(--glow) 14%, #fff 50%, var(--glow) 86%, rgba(223,247,255,0) 100%); box-shadow: 0 0 16px 4px rgba(150,225,255,.6), 0 0 60px 14px rgba(120,200,255,.22); }
.grip { position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: #f2fbff; color: #0e1216; font-family: var(--f-mono); font-size: 12px; font-weight: 500; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.head-in:focus-visible ~ .headclip .grip { outline: 3px solid var(--glow-2); outline-offset: 3px; }
.tag-up, .tag-down { position: absolute; left: 34px; padding: 3px 8px; border-radius: 6px; background: rgba(14,18,22,.85); color: var(--glass-fg); font-family: var(--f-mono); font-size: 11px; letter-spacing: var(--caps-track); }
.tag-up { top: -31px; }
.tag-down { top: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .doc.sweep { animation: sweep 1.5s cubic-bezier(.25, .6, .25, 1) both; }
  .is-saving .reveal, .is-saving .reveal img, .is-saving .head { animation: 3.2s cubic-bezier(.55, 0, .35, 1) infinite; }
  .is-saving .reveal { animation-name: save-reveal; }
  .is-saving .reveal img { animation-name: save-reveal-img; }
  .is-saving .head { animation-name: save-head; }
  .pad-page { transition: transform .35s cubic-bezier(.3, .7, .3, 1); }
}
@keyframes sweep { from { --head: 0%; } to { --head: 46%; } }
/* The same as --head going 0% → 100%, written as transforms. */
@keyframes save-reveal { 0% { transform: translateY(-100%); } 85%, 100% { transform: none; } }
@keyframes save-reveal-img { 0% { transform: translateY(100%); } 85%, 100% { transform: none; } }
@keyframes save-head { 0% { transform: none; } 85%, 100% { transform: translateY(100%); } }

/* 100% zoom: the stage scrolls */
.stage.actual { display: block; overflow: auto; container-type: normal; }
.stage.actual .doc { width: calc(var(--pw) * 1px); height: calc(var(--pw) * 1px / var(--ar)); }

.readouts { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 18px 14px; border-top: 1px solid var(--glass-line); }
.pager { display: flex; align-items: center; gap: 4px; }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 34px; min-height: 34px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--glass-ctl); background: transparent; color: var(--glass-fg); font-size: 13.5px; font-weight: 600; }
.gbtn:hover:not(:disabled) { border-color: var(--glass-dim); background: #1a2026; }
.gbtn:disabled { opacity: .4; }
.gbtn.wide { min-height: 40px; padding: 6px 14px; border-radius: 10px; }
.pagelbl { min-width: 64px; text-align: center; font-family: var(--f-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.meta { flex: 1 1 260px; font-family: var(--f-mono); font-size: 12.5px; color: var(--glass-muted); font-variant-numeric: tabular-nums; }
.gseg { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: #1a2026; border: 1px solid #2f373f; }
.gseg button { min-height: 34px; padding: 4px 12px; border-radius: 7px; border: 0; background: transparent; color: #d7e0e7; font-size: 13px; font-weight: 600; }
.gseg button[aria-pressed="true"] { background: var(--glass-fg); color: var(--glass); }

/* saving */
.svpanel { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 20px; padding: 16px 22px 18px; border-top: 1px solid var(--glass-line); }
.svpanel > * { grid-column: 1; }
.svpanel > .sv-cancel { grid-column: 2; grid-row: 1 / span 4; }
.sv-text { display: flex; flex-direction: column; gap: 4px; }
.sv-count { font-family: var(--f-mono); font-size: 12px; letter-spacing: var(--caps-track); text-transform: uppercase; color: var(--glass-dim); }
.sv-title { font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1.05; letter-spacing: -.02em; }
.sv-bar { height: 6px; border-radius: 3px; background: var(--glass-line); overflow: hidden; }
.sv-fill { width: 0; height: 100%; border-radius: 3px; background: var(--glow-2); transition: width .2s; }
.sv-note { font-size: 14px; color: #c3ccd4; }
.sv-cancel { min-height: 48px; padding: 0 22px; border-radius: 14px; border: 1px solid #4a545e; background: transparent; color: var(--glass-fg); font-weight: 600; }
.sv-cancel:hover { background: #1a2026; }
.is-saving .base { opacity: .55; }
.is-saving .doc { cursor: default; }
.is-saving .head-in, .is-saving .grip, .is-saving .tag-up, .is-saving .tag-down { display: none; }

/* ---------- settings (the control deck) ---------- */
.deck { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.deck-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 22px; scrollbar-width: thin; scrollbar-color: var(--ctl) transparent; }
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec + .sec.ruled { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tag { padding: 2px 9px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-fg); font-size: 12.5px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); text-align: left; }
.tile:hover { border-color: var(--ctl); }
.tile[aria-pressed="true"] { border-color: var(--accent); }
.tile-img { height: 78px; border-radius: 7px; overflow: hidden; background: var(--glass); margin-bottom: 2px; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; object-position: left top; }
.tile-name { font-weight: 600; padding: 0 4px; }
.tile-desc { font-size: 13px; color: var(--muted); padding: 0 4px; line-height: 1.35; }
.pad { position: relative; height: 132px; border-radius: 12px; overflow: hidden; background: #10151a; box-shadow: inset 0 0 0 1px #2a3138; }
.pad .corner { right: auto; bottom: auto; top: 6px; left: 6px; width: 16px; height: 16px; }
.pad-outline, .pad-page { position: absolute; top: 14px; left: 14px; width: 74px; height: 104px; border-radius: 2px; }
.pad-outline { border: 1px dashed #5c6772; }
.pad-page { background: #fff; transform-origin: 50% 50%; box-shadow: 0 6px 14px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 5px; padding: 10px 9px; }
.pad-page i { display: block; height: 3px; border-radius: 2px; background: #b9c0c7; }
.pad-page i:first-child { height: 5px; width: 70%; background: var(--accent); }
.pad-note { position: absolute; right: 10px; bottom: 8px; font-family: var(--f-mono); font-size: 11px; color: var(--glass-dim); }
.ctl { display: grid; grid-template-columns: 1fr auto; row-gap: 2px; align-items: center; }
.ctl label { font-weight: 600; font-size: 14.5px; }
/* The value is a real number field: type a value, or use the arrow keys. */
.val { display: inline-flex; align-items: center; gap: 4px; font-family: var(--f-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.val input { width: calc(5ch + 14px); min-height: 26px; margin: 0; padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.val input::-webkit-inner-spin-button, .val input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.val input:hover:not(:disabled) { border-color: var(--ctl); }
.val input:focus { border-color: var(--accent); outline-offset: 1px; }
.val input:disabled { color: var(--muted); background: transparent; }
.val input.bad { border-color: var(--warn); }
.val .u { min-width: 3ch; }
.ctl.changed .val, .ctl.changed .val input { color: var(--changed); font-weight: 500; }
.ctl input[type="range"] { grid-column: 1 / -1; width: 100%; height: 26px; margin: 0; accent-color: var(--range); }
.ctl input[type="range"]:disabled { opacity: .45; }
.ctl .note { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.adv-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; border: 0; background: transparent; font-weight: 600; text-align: left; }
.adv-btn svg { transition: transform .2s; transform: rotate(90deg); flex: none; }
.adv-btn[aria-expanded="false"] svg { transform: none; }
.adv-btn .count { margin-left: auto; font-family: var(--f-mono); font-size: 12.5px; font-weight: 400; color: var(--muted); }
.adv-btn .count.on { color: var(--changed); }
.adv-panel { display: flex; flex-direction: column; gap: 18px; }
.adv.closed .adv-panel { display: none; }
fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { padding: 0 0 8px; font-family: var(--f-mono); font-size: 11.5px; font-weight: 500; letter-spacing: var(--caps-track); text-transform: uppercase; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--ctl); background: var(--card); font-weight: 600; font-size: 14px; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .55; }
.reset { align-self: flex-start; }
.outgrid { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 14px; font-size: 14px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 3px; border-radius: 10px; background: var(--seg); }
.seg button { min-height: 34px; padding: 2px 6px; border-radius: 7px; border: 0; background: transparent; font-weight: 600; font-size: 13.5px; }
.seg button:hover { text-decoration: underline; text-underline-offset: 3px; }
.seg button[aria-pressed="true"] { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0,0,0,.16), inset 0 0 0 1px var(--line); text-decoration: none; }
.deck-save { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line-soft); background: var(--panel); }
.save { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; padding: 8px 16px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-fg); font-family: var(--f-display); font-size: 19px; font-weight: 800; letter-spacing: 0; box-shadow: 0 8px 20px -10px rgba(47,55,190,.7); }
.save:hover:not(:disabled) { background: #262c9c; }
.save:disabled { opacity: .6; }
.savemeta { display: flex; justify-content: space-between; gap: 8px; font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); }
.savemeta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savemeta span:last-child { white-space: nowrap; }

/* toast, drag overlay */
.toast { position: fixed; z-index: 40; left: 50%; top: 16px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px; background: #15181c; color: #f2f5f7; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.toast:empty { display: none; }
.toast.warn { background: #6b1f0a; }
.drop-cover { position: fixed; inset: 0; z-index: 45; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(14,18,22,.72); pointer-events: none; }
.drop-cover p { padding: 22px 28px; border-radius: 18px; border: 2px dashed var(--glow-2); background: var(--glass); color: var(--glass-fg); font-family: var(--f-display); font-size: 24px; font-weight: 800; }
body.dragging .drop-cover { display: flex; }

/* ---------- narrower desktops ---------- */
@media (max-width: 1100px) and (min-width: 761px) {
  .top, .work, .foot { padding-left: 16px; padding-right: 16px; }
  .work { gap: 14px; }
  .tagline, .gh span { display: none; }
  .tiles { gap: 8px; }
  .deck-scroll { padding: 18px; }
  .deck-save { padding: 12px 18px 16px; }
}

/* ---------- phone: a normal scrolling page; Files and Adjust open as their own screens ---------- */
@media (max-width: 760px) {
  :root { --row: 72px; }
  body { background: var(--glass); }
  .desk-only { display: none !important; }
  .shell { height: auto; min-height: 100vh; min-height: 100svh; overflow: visible; background: radial-gradient(140% 70% at 20% 0%, var(--glass-hi) 0%, var(--glass) 60%); }
  .top { gap: 10px; padding: 14px 16px 6px; color: var(--glass-fg); }
  .logo { width: 30px; height: 30px; }
  .wordmark { font-size: 22px; }
  .tagline, .gh { display: none; }
  .privacy { padding: 5px 10px; background: transparent; border-color: #3a434c; color: #d7e0e7; font-size: 12.5px; }
  .privacy svg { stroke: #7fe0a6; }
  .theme { width: 44px; height: 44px; background: transparent; border-color: #3a434c; color: var(--glass-fg); }
  .theme:hover { border-color: var(--glass-dim); }
  .privacy .pl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .work { flex: 1; display: flex; flex-direction: column; gap: 0; padding: 0; }
  .feed, .deck { display: none; }
  .glass { flex: none; border-radius: 0; background: transparent; box-shadow: none; }
  .stage { flex: none; height: max(320px, calc(100vh - 470px)); height: max(320px, calc(100svh - 470px)); padding: 30px 26px 18px; }
  .ruler-x { height: 12px; bottom: calc(100% + 6px); }
  .ruler-x span, .ruler-y, .grip span { display: none; }
  .corner { right: auto; left: -18px; bottom: calc(100% + 4px); width: 16px; height: 16px; }
  .grip { left: auto; right: 18px; width: 44px; height: 44px; padding: 0; justify-content: center; transform: translateY(-50%); }
  .tag-up, .tag-down { left: 20px; font-size: 10.5px; padding: 2px 7px; }
  .readouts { padding: 6px 16px 12px; border-top: 0; gap: 8px 12px; }
  .gbtn { min-width: 44px; min-height: 44px; }
  .meta { flex-basis: 150px; font-size: 12px; }
  .readouts .gseg, .readouts .gbtn.wide { display: none; }
  .svpanel { display: flex; flex-direction: column; align-items: stretch; padding: 16px 22px 26px; border-top: 0; gap: 12px; }
  .sv-title { font-size: 34px; }
  .sv-cancel { min-height: 50px; margin-top: 8px; }

  .sheet { flex: 1 0 auto; display: flex; flex-direction: column; gap: 14px; padding: 10px 16px 18px; border-radius: 22px 22px 0 0; background: var(--panel); color: var(--fg); }
  .grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: #b4bbc2; }
  .pill { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); text-align: left; }
  .pill-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
  .pill-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pill-meta { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
  .pill-go { font-size: 13.5px; font-weight: 600; color: var(--accent-text); }
  .seg.big { border-radius: 14px; padding: 4px; gap: 6px; }
  .seg button { min-height: 44px; border-radius: 10px; font-size: 15px; }
  .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .btn { min-height: 44px; border-radius: 12px; font-size: 15px; }
  .langs a { min-height: 44px; padding: 0 9px; }
  .foot { padding: 0 16px 22px; padding-bottom: max(22px, env(safe-area-inset-bottom)); background: var(--panel); margin-top: -1px; }

  /* Files screen */
  body[data-screen], body[data-screen] .shell { background: var(--shell); }
  body[data-screen] .top, body[data-screen] .glass, body[data-screen] .sheet, body[data-screen] .foot { display: none; }
  body[data-screen="files"] .feed { display: flex; height: 100vh; height: 100svh; gap: 10px; padding: 12px 16px 0; }
  .back { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -10px; border: 0; border-radius: 12px; background: transparent; }
  .feed-head { min-height: 44px; }
  .feed-head h2, .adj-head h2 { font-family: var(--f-display); font-weight: 800; font-size: 24px; letter-spacing: -.02em; text-transform: none; color: var(--fg); }
  .link-btn { min-height: 44px; padding: 0 10px; font-size: 15px; }
  .summary { font-size: 12.5px; }
  .filter { min-height: 44px; }
  .row { min-height: 60px; gap: 12px; padding: 8px 10px; border-radius: 14px; background: var(--card); border-color: var(--line-soft); }
  .row[aria-current="true"] { padding: 7px 9px; }
  .row-name { font-size: 14.5px; }
  .row-x { flex-basis: 44px; }
  .qlist li { gap: 2px; }
  .add { flex-direction: row; flex-wrap: wrap; margin: 0 -16px; padding: 12px 16px 0; border-top: 1px solid var(--line-soft); background: var(--panel); }
  .dropzone { flex: 1 1 60%; min-height: 48px; flex-direction: row; gap: 8px; border-radius: 14px; }
  .dropzone span { display: none; }
  .dropzone strong { font-size: 15px; }
  .add .link-btn { flex: 1 1 30%; }
  .hint { display: none; }
  .feed-save { display: block; margin: 0 -16px; padding: 10px 16px 22px; padding-bottom: max(22px, env(safe-area-inset-bottom)); background: var(--panel); }
  .feed-save .save { width: 100%; }

  /* Adjust screen */
  body[data-screen="adjust"] .deck { display: flex; border: 0; border-radius: 0; background: var(--shell); overflow: visible; }
  .deck-scroll { overflow: visible; padding: 0 16px 8px; gap: 14px; }
  .adj-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; margin: 0 -16px; padding: 12px 12px 12px 16px; background: var(--shell); border-bottom: 1px solid var(--line-soft); }
  .done { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--fg); color: var(--shell); font-weight: 600; }
  .adj-strip { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: #10151a; color: var(--glass-fg); }
  .adj-strip img { flex: none; height: 132px; width: auto; aspect-ratio: var(--ar, 0.7075); object-fit: contain; }
  .adj-strip .mono { font-size: 12px; color: var(--glass-muted); line-height: 1.5; overflow-wrap: anywhere; }
  .adj-strip .sub { font-size: 13px; color: var(--glass-muted); }
  .sec { padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line-soft); }
  .sec.look { padding: 0; background: none; border: 0; }
  .sec + .sec.ruled { padding-top: 16px; }
  .tile { min-height: 64px; padding: 10px 12px; border-radius: 14px; gap: 2px; }
  .tile-img, .pad { display: none; }
  .tile-name, .tile-desc { padding: 0; }
  .adv { gap: 14px; }
  .adv-btn { display: none; }
  .adv.closed .adv-panel { display: flex; }
  .adv-panel { gap: 20px; }
  .ctl input[type="range"] { height: 28px; }
  .val { font-size: 14px; }
  .val input { min-height: 44px; width: calc(5ch + 20px); border-radius: 10px; }
  .outgrid { grid-template-columns: 1fr; gap: 6px; font-size: 15px; }
  .outgrid .seg { margin-bottom: 8px; padding: 4px; border-radius: 12px; }
  .reset { align-self: stretch; min-height: 48px; border-radius: 14px; }
  .deck-save { padding: 6px 16px 22px; padding-bottom: max(22px, env(safe-area-inset-bottom)); background: var(--shell); border-top: 0; }

  /* Saving: the glass fills the screen */
  body.saving .top, body.saving .sheet, body.saving .foot { display: none; }
  body.saving .stage { height: max(320px, calc(100vh - 230px)); height: max(320px, calc(100svh - 230px)); }
}

@media (max-width: 380px) {
  .save { font-size: 17px; }
  .top { padding-left: 12px; padding-right: 12px; }
  .privacy { font-size: 12px; }
  .stage { padding-left: 20px; padding-right: 20px; }
  .tiles { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .doc.intro { --head: 46%; }
  .doc.intro .headclip { opacity: 1; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .bar { background: Highlight; forced-color-adjust: none; }
  .row[aria-current="true"], .tile[aria-pressed="true"], .seg button[aria-pressed="true"], .gseg button[aria-pressed="true"] { outline: 3px solid Highlight; }
}
