/* scanner's one stylesheet, picam's design. Dark first, light from prefers-color-scheme;
   every colour, size and radius is a token here at the top. */

:root {
  color-scheme: dark;

  /* Colours (dark) */
  --bg: #0c0e13;
  --surface: #13161d;
  --surface-2: #191d26;
  --surface-3: #212633;
  --border: #252b37;
  --border-strong: #353c4b;
  --text: #e8ebf1;
  --muted: #9aa3b3;
  --accent: #4361ee;        /* fills, with white text */
  --accent-hover: #3651d6;
  --accent-text: #93a6ff;   /* links and marks on the surface */
  --accent-soft: rgba(110, 135, 255, .14);
  --on-accent: #fff;
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, .12);
  --bad: #f87171;
  --bad-fill: #c62828;
  --bad-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --focus: #9db0ff;
  --stage: #000;
  --glass: rgba(19, 22, 29, .72);   /* bars over content, blurred */
  --scrim: rgba(8, 10, 14, .58);    /* chips over a picture, either scheme */
  --found: #34d399;                 /* the outline of what was found */

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 999px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.625rem;

  /* Layout */
  --side-w: 244px;
  --tabbar-h: 64px;
  --control-h: 40px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f9;
    --surface: #fff;
    --surface-2: #f7f8fb;
    --surface-3: #eceff5;
    --border: #e0e4eb;
    --border-strong: #cbd1dc;
    --text: #12151c;
    --muted: #586174;
    --accent: #3a56e4;
    --accent-hover: #2f48c8;
    --accent-text: #2f48c8;
    --accent-soft: rgba(58, 86, 228, .1);
    --good: #15803d;
    --good-soft: rgba(21, 128, 61, .1);
    --bad: #c42020;
    --bad-fill: #c42020;
    --bad-soft: rgba(196, 32, 32, .08);
    --warn: #9a5b00;
    --warn-soft: rgba(180, 110, 0, .12);
    --focus: #3a56e4;
    --glass: rgba(255, 255, 255, .78);
    --found: #059669;
    --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-2: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .07);
    --shadow-3: 0 12px 40px rgba(16, 24, 40, .18);
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: var(--fs-xl); line-height: 1.2; letter-spacing: -.02em; font-weight: 650; margin: 0 0 var(--s-4); }
h1 .muted { font-weight: 500; }
h2 { font-size: var(--fs-lg); line-height: 1.3; letter-spacing: -.01em; font-weight: 600; margin: var(--s-6) 0 var(--s-3); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: var(--fs-sm); }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-3) 0; }
strong { font-weight: 600; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.icon { width: 20px; height: 20px; flex: none; display: block; }

/* App frame: a sidebar on wide screens, a bar along the bottom on phones */

.app {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  /* the sidebar's column, also below the sticky sidebar on a long page */
  background: linear-gradient(to right, var(--surface) calc(var(--side-w) - 1px), var(--border) 0, var(--border) var(--side-w), transparent 0);
}
main { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--s-6) var(--s-6) var(--s-7); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.02em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--on-accent); }
.logo .icon { width: 22px; height: 22px; }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-5) var(--s-3) var(--s-4);
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.side .brand { padding: 0 var(--s-2) var(--s-5); }
.side hr { margin: var(--s-3) var(--s-2); }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3); border-radius: 10px;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); }
.nav a.on .icon { color: var(--accent-text); }

.account {
  margin: auto 0 0; display: flex; align-items: center; gap: 10px;
  padding: var(--s-3) var(--s-2) 0; border-top: 1px solid var(--border);
}
.avatar {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text); font-weight: 650; font-size: var(--fs-sm);
}
.who { display: grid; min-width: 0; line-height: 1.25; }
.who .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .role { color: var(--muted); font-size: var(--fs-xs); }
.account button { margin-left: auto; }
.side .account button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.side .account button { width: var(--control-h); padding: 0; justify-content: center; }

.topbar, .tabbar { display: none; }

@media (max-width: 760px) {
  .app { display: block; background: none; }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; height: 56px; padding: 0 var(--s-4);
    padding-top: env(safe-area-inset-top);
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .logo { width: 28px; height: 28px; border-radius: 9px; }
  .topbar .logo .icon { width: 19px; height: 19px; }
  main { padding: var(--s-5) var(--s-4) calc(var(--tabbar-h) + var(--s-6) + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.375rem; }
  .tabbar {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    display: flex; align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 var(--s-1) env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  @supports (backdrop-filter: blur(1px)) {
    .tabbar { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); }
  }
  .tabbar > a, .tabbar summary {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none; cursor: pointer;
    border-radius: var(--r-md); margin: 6px 2px;
  }
  .tabbar .icon { width: 24px; height: 24px; }
  .tabbar > a.on, .tabbar summary.on { color: var(--accent-text); }
  .tabbar > a.on .icon, .tabbar summary.on .icon { background: var(--accent-soft); border-radius: var(--r-full); padding: 3px 14px; width: 22px; height: 22px; box-sizing: content-box; margin: -3px 0; }
  .more { flex: 1; display: flex; min-width: 0; }
  .more summary { list-style: none; }
  .more summary::-webkit-details-marker { display: none; }
  .more[open] summary { color: var(--text); }
  .more .sheet {
    position: fixed; right: var(--s-3); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2));
    width: min(280px, calc(100vw - 2 * var(--s-3)));
    padding: var(--s-2); border-radius: var(--r-lg);
    background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-3);
  }
  .more .sheet hr { margin: var(--s-2) var(--s-1); }
  .more .account { border-top: 0; padding: var(--s-2); }
  .more .account button { width: auto; }
}

/* Signed out: one card in the middle */

body.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
body.bare main { max-width: 420px; padding: var(--s-5) var(--s-4); }
.login { padding: var(--s-6); display: grid; gap: var(--s-2); }
.login .brand { font-size: var(--fs-xl); margin: 0 0 var(--s-1); }
.login .logo { width: 40px; height: 40px; border-radius: 12px; }
.login .logo .icon { width: 26px; height: 26px; }
.login h1 { font-size: var(--fs-md); font-weight: 500; color: var(--muted); letter-spacing: 0; margin: 0 0 var(--s-3); }
.login label { margin-top: var(--s-2); }
.login input { width: 100%; }
.login button { margin-top: var(--s-4); width: 100%; height: 44px; }
body.bare .error { margin-bottom: var(--s-4); }

/* Surfaces */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-1);
}
.card > :last-child { margin-bottom: 0; }
.card + .card { margin-top: var(--s-3); }
.card + p, .card + .muted { margin-top: var(--s-3); }
.page-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin: 0 0 var(--s-5); }
.page-head h1 { margin: 0; }
.page-head + .muted, .lead { max-width: 72ch; }
.lead { color: var(--muted); margin-bottom: var(--s-5); }

.notice, .error {
  display: block; padding: var(--s-3) var(--s-4) var(--s-3) calc(var(--s-4) + 14px); border-radius: var(--r-md);
  border: 1px solid; position: relative; margin: 0 0 var(--s-4);
}
.notice::before, .error::before {
  content: ""; position: absolute; left: var(--s-4); top: calc(var(--s-3) + .75em - 4px);
  width: 8px; height: 8px; border-radius: var(--r-full); background: currentColor;
}
.notice { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.notice::before { color: var(--good); }
.error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--text); }
.error::before { color: var(--bad); }
.notice, .error { padding-left: calc(var(--s-4) + 18px); }

/* State words and dots */

.on-line { color: var(--good); font-weight: 600; }
.off-line { color: var(--bad); font-weight: 600; }
.state {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; line-height: 1.6;
  background: var(--surface-3); color: var(--muted);
}
.state::before { content: ""; width: 7px; height: 7px; border-radius: var(--r-full); background: currentColor; }
.state.on { background: var(--good-soft); color: var(--good); }
.state.off { background: var(--bad-soft); color: var(--bad); }
.state.paused { background: var(--warn-soft); color: var(--warn); }
.pill {
  display: inline-block; padding: 1px 10px; border-radius: var(--r-full); margin: 0 2px 4px 0;
  background: var(--surface-3); border: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.6;
}

/* Controls */

label { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); margin: 0 0 var(--s-1); }
label.toggle { display: inline-flex; align-items: center; gap: var(--s-2); font-size: inherit; font-weight: inherit; color: inherit; cursor: pointer; margin: 0; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 10px;
  min-height: var(--control-h); padding: 7px var(--s-3); max-width: 100%;
}
input:not([type=checkbox]), select { height: var(--control-h); }
/* the browser's own autofill tint, in our colours */
input:autofill, input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: inset 0 0 0 100px var(--surface-2); caret-color: var(--text); }
input::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover { border-color: color-mix(in srgb, var(--border-strong) 50%, var(--muted)); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
input[type=date] { min-width: 10em; }
input.wide { width: 100%; }

button, a.button {
  font: inherit; font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 var(--s-4); border-radius: 10px; cursor: pointer;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong);
  text-decoration: none; white-space: nowrap;
}
button:hover, a.button:hover { background: color-mix(in srgb, var(--surface-3) 80%, var(--text) 8%); text-decoration: none; }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { background: var(--surface-3); }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: var(--bad-fill); border-color: var(--bad-fill); color: #fff; }
button.danger:hover { background: color-mix(in srgb, var(--bad-fill) 85%, #000); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-3); color: var(--text); }
button[aria-pressed=true] { box-shadow: inset 0 0 0 1px var(--accent); }

form { margin: 0; }
form.stack { display: grid; gap: var(--s-1); max-width: 560px; }
form.stack label { margin-top: var(--s-3); }
form.stack label:first-of-type { margin-top: 0; }
form.stack .toggle { margin-top: var(--s-3); }
form.stack .muted { font-size: var(--fs-sm); margin: var(--s-1) 0 0; }
form.stack .actions { margin-top: var(--s-4); }
form.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: end; margin: 0 0 var(--s-5); }
form.filters label { margin-bottom: var(--s-1); }
.card form.filters { margin-bottom: var(--s-3); }
form.choices { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-3); }
form.inline { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
form.inline input { min-width: 0; flex: 1 1 140px; }

.actions { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; margin: var(--s-4) 0; }
.pager { margin: var(--s-5) 0; display: flex; gap: var(--s-2); }
.pager a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-4); border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500;
}
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager:empty { display: none; }

/* Tables */

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px var(--s-3) 10px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child > th, tr:last-child > td { border-bottom: 0; }
th { font-weight: 500; color: var(--muted); width: 220px; }
th a { font-weight: 600; }
table.list th { width: auto; font-size: var(--fs-sm); }
table.list th, table.list td { vertical-align: middle; }
table.list td:last-child, table.list th:last-child { padding-right: 0; }
.card > table { margin: calc(-1 * var(--s-1)) 0; }

@media (max-width: 760px) {
  .card { padding: var(--s-3) var(--s-4); }
  /* key and value tables: the key above its value */
  table:not(.list) tr { display: block; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
  table:not(.list) tr:last-child { border-bottom: 0; }
  table:not(.list) th, table:not(.list) td { display: block; width: auto; border: 0; padding: 0; }
  table:not(.list) th { font-size: var(--fs-sm); margin-bottom: 2px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr:has(> th) { display: none; }
  table.stack tr { padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: inline-block; width: auto; border: 0; padding: 2px var(--s-3) 2px 0; color: var(--muted); }
  table.stack td:first-child { display: block; color: var(--text); font-weight: 600; }
  table.stack td:has(form) { display: block; width: 100%; padding: var(--s-2) 0; }
  table.stack td:empty { display: none; }
}

/* Pictures and shared bits */

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.empty { padding: var(--s-7) var(--s-5); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-xl); color: var(--muted); }
.empty p:last-child { margin: 0; }
.empty-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--surface-3); color: var(--accent-text); margin-bottom: var(--s-3); }
.empty-icon .icon { width: 28px; height: 28px; }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong);
}
.icon-button:hover { background: color-mix(in srgb, var(--surface-3) 80%, var(--text) 10%); text-decoration: none; }
.icon-button .icon { width: 18px; height: 18px; }
a.button.wide, button.wide { grid-column: 1 / -1; }
.button.danger-ghost, button.danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.button.danger-ghost:hover { background: var(--bad-soft); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-3); }
.section-head h2 { margin: 0; }
/* A page or print on its own sheet: the thumbnail on a quiet surface */
.paper { display: grid; place-items: center; aspect-ratio: 3 / 4; padding: var(--s-4); background: var(--surface-3); overflow: hidden; }
.paper img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; background: #fff; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 22px rgba(0, 0, 0, .22);
}
.pill.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.pill.photo { background: color-mix(in srgb, var(--found) 14%, transparent); border-color: color-mix(in srgb, var(--found) 35%, transparent); color: var(--found); }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); font-size: var(--fs-sm); }
.meta-line .pill { margin: 0; font-size: var(--fs-xs); }
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: var(--s-6); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-4); padding: 10px var(--s-3) 10px var(--s-5); border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-3); font-weight: 550;
}
.toast a { padding: 6px 14px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); }
.toast a:hover { text-decoration: none; background: var(--accent-hover); }

/* Segmented control: one choice of a few, as a pill of buttons */

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; gap: 2px; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border); }
.segmented label { margin: 0; cursor: pointer; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); position: relative; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 var(--s-4); border-radius: var(--r-full); white-space: nowrap; }
.segmented .icon { width: 17px; height: 17px; }
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--border-strong); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.segmented.small { display: grid; width: 100%; }
.segmented.small span { padding: 0 var(--s-2); }

/* A switch, for an option that is on or off */

.switch { display: inline-flex; align-items: center; gap: var(--s-2); margin: 0; cursor: pointer; color: var(--text); font-size: var(--fs-sm); font-weight: 550; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border-strong); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--r-full); background: var(--muted); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { left: 18px; background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch .icon { width: 18px; height: 18px; color: var(--muted); }

/* Scan: a camera. The viewfinder fills the width; under it a dock with the
   mode, the round shutter and the PDF; then the latest scans as a strip. */

body.page-scan main { max-width: 1320px; }
.scan-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin: 0 0 var(--s-4); }
.scan-head h1 { margin: 0; }
.doc-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); padding: 4px 12px 4px 8px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--text); font-size: var(--fs-sm);
}
.doc-chip .icon { width: 18px; height: 18px; color: var(--accent-text); }
.camera { margin: 0 auto; max-width: 1100px; }
.viewfinder {
  position: relative; overflow: hidden; isolation: isolate; border-radius: var(--r-xl); background: var(--stage);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), var(--shadow-3);
  aspect-ratio: 16 / 9; max-height: calc(100vh - 290px); max-height: calc(100dvh - 290px); min-height: 220px; margin: 0 auto;
}
.viewfinder .live { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: var(--stage); }
.viewfinder.off .live { opacity: .4; filter: grayscale(.7) blur(1px); }
.outline { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; }
.outline polygon {
  fill: color-mix(in srgb, var(--found) 12%, transparent); stroke: var(--found); stroke-width: 3; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--found) 60%, transparent));
}
.outline.photos polygon { fill: color-mix(in srgb, var(--found) 8%, transparent); stroke-dasharray: 10 6; }
/* Corner marks, as a camera's frame */
.frame { position: absolute; inset: 18px; z-index: 1; pointer-events: none; }
.frame i { position: absolute; width: 26px; height: 26px; border: 0 solid rgba(255, 255, 255, .55); }
.frame i:nth-child(1) { left: 0; top: 0; border-width: 2px 0 0 2px; border-top-left-radius: 8px; }
.frame i:nth-child(2) { right: 0; top: 0; border-width: 2px 2px 0 0; border-top-right-radius: 8px; }
.frame i:nth-child(3) { right: 0; bottom: 0; border-width: 0 2px 2px 0; border-bottom-right-radius: 8px; }
.frame i:nth-child(4) { left: 0; bottom: 0; border-width: 0 0 2px 2px; border-bottom-left-radius: 8px; }
.viewfinder.found .frame i { border-color: color-mix(in srgb, var(--found) 80%, #fff); }
.viewfinder .badge {
  position: absolute; z-index: 3; left: 30px; top: 30px;
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border-radius: var(--r-full);
  background: var(--scrim); color: #fff; backdrop-filter: blur(10px);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; pointer-events: none;
}
.viewfinder .badge::before { content: ""; width: 8px; height: 8px; border-radius: var(--r-full); background: #9aa0a6; }
.viewfinder .badge.on::before { background: #ff4d4d; box-shadow: 0 0 0 3px rgba(255, 77, 77, .25); }
.viewfinder .badge .fps { font-weight: 500; opacity: .85; letter-spacing: .02em; }
.viewfinder .hint {
  position: absolute; z-index: 3; left: 50%; bottom: var(--s-4); transform: translateX(-50%); max-width: calc(100% - 2 * var(--s-4));
  display: flex; align-items: center; gap: var(--s-2); margin: 0; padding: 7px 14px 7px 12px; border-radius: var(--r-full);
  background: var(--scrim); color: #e8ebf1; backdrop-filter: blur(10px); font-size: var(--fs-sm); text-align: center;
}
.viewfinder .hint .dot { flex: none; width: 8px; height: 8px; border-radius: var(--r-full); background: #6b7280; }
.viewfinder.found .hint .dot { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .3); }
.viewfinder.off .hint { display: none; }
.viewfinder .message {
  position: absolute; inset: 0; z-index: 2; margin: 0; display: flex; align-items: center; justify-content: center;
  padding: var(--s-5); text-align: center; color: #fff; font-size: var(--fs-lg);
}
.viewfinder .message code { background: rgba(255, 255, 255, .16); color: #fff; }
/* Scanning, Straightening, Done: chips over the picture */
.steps {
  position: absolute; z-index: 4; left: 50%; top: var(--s-4); transform: translateX(-50%);
  display: flex; gap: 4px; margin: 0; padding: 4px; list-style: none; border-radius: var(--r-full);
  background: var(--scrim); backdrop-filter: blur(12px); color: rgba(255, 255, 255, .6); font-size: var(--fs-sm); font-weight: 600;
}
.steps li { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r-full); white-space: nowrap; }
.steps .tick { width: 14px; height: 14px; border-radius: var(--r-full); border: 2px solid currentColor; opacity: .7; }
.steps li.now { color: #fff; background: rgba(255, 255, 255, .12); }
.steps li.now .tick { border-color: #fff; border-right-color: transparent; opacity: 1; }
.steps li.done { color: #fff; }
.steps li.done .tick { background: #34d399; border-color: #34d399; opacity: 1; box-shadow: inset 0 0 0 2px var(--scrim); }
.flash { position: absolute; inset: 0; z-index: 5; background: #fff; opacity: 0; pointer-events: none; }

/* Zoom and focus, on the picture */
.zoom { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.zoom button, .zoom-pill { pointer-events: auto; }
.zoom-pill {
  position: absolute; z-index: 4; right: var(--s-4); bottom: var(--s-4); display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: var(--r-full); background: var(--scrim); backdrop-filter: blur(10px); color: #fff;
}
.zoom-pill button {
  min-width: 34px; min-height: 34px; padding: 0 8px; border: 0; border-radius: var(--r-full); background: transparent; color: #fff;
  font-size: var(--fs-lg); font-weight: 600; line-height: 1;
}
.zoom-pill button:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.zoom-pill button:disabled { opacity: .35; }
.zoom-pill .zoom-reset { font-size: var(--fs-sm); background: rgba(255, 255, 255, .14); }
.zoom-pill output { min-width: 2.8em; text-align: center; font-weight: 700; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.zoom-pill.viewer { padding: 6px 12px; }
.pan {
  position: absolute; display: grid; place-items: center; width: 40px; height: 40px; min-height: 0; padding: 0; border: 0; border-radius: var(--r-full);
  background: var(--scrim); color: #fff; backdrop-filter: blur(10px);
}
.pan:hover { background: rgba(8, 10, 14, .8); }
.pan-left { left: var(--s-3); top: calc(50% - 20px); }
.pan-right { right: var(--s-3); top: calc(50% - 20px); }
.pan-up { top: var(--s-3); left: calc(50% - 20px); }
.pan-down { bottom: 64px; left: calc(50% - 20px); }
.viewfinder:has(.zoom) .live { cursor: crosshair; }
.focus-ring { position: absolute; z-index: 5; width: 76px; height: 76px; margin: -38px 0 0 -38px; pointer-events: none; }
.focus-ring i { position: absolute; inset: 0; border: 2px solid #fff; border-radius: 14px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(0, 0, 0, .15); }
.focus-ring b {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 2px 9px; border-radius: var(--r-full); background: var(--scrim); color: #fff; font-size: var(--fs-xs); font-weight: 650;
}
.focus-ring b:empty { display: none; }
.focus-ring.ok i { border-color: #34d399; }
.focus-ring.fail i { border-color: #fbbf24; }
.tap-hint { margin: var(--s-2) 0 0; text-align: center; color: var(--muted); font-size: var(--fs-xs); }
.cam-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-full); background: var(--surface-3); color: var(--text); font-size: var(--fs-xs); font-weight: 650; }

.dock {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-4);
  max-width: 1100px; margin: var(--s-4) auto 0; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-2);
}
.dock .segmented { justify-self: start; }
.dock-side { justify-self: end; display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; justify-content: flex-end; }
.glare-option { display: none; }
.dock:has(input[value=photo]:checked) .glare-option { display: inline-flex; }
.doc-actions { display: inline-flex; gap: var(--s-1); }
.doc-start { color: var(--text); }
.scan-message { grid-column: 1 / -1; margin: 0; text-align: center; font-size: var(--fs-sm); }
.scan-message:empty { display: none; }
.shutter-wrap { display: grid; place-items: center; }
.shutter {
  position: relative; width: 76px; height: 76px; min-height: 0; padding: 0; border-radius: var(--r-full);
  background: transparent; border: 4px solid var(--text); box-shadow: var(--shadow-2);
}
.shutter::after {
  content: ""; position: absolute; inset: 5px; border-radius: var(--r-full);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent) 60%);
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, .25);
}
.shutter:hover { background: transparent; }
.shutter:hover::after { filter: brightness(1.08); }
.shutter:active::after { transform: scale(.9); }
.shutter:disabled { opacity: .35; }
.shutter:disabled:hover { background: transparent; }
.shutter.busy { opacity: 1; border-color: color-mix(in srgb, var(--text) 25%, transparent); border-top-color: var(--accent-text); }
.shutter.busy::after { transform: scale(.55); border-radius: 30%; }
.viewer-note { display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin: var(--s-4) 0 0; color: var(--muted); font-size: var(--fs-sm); }

.film { margin-top: var(--s-6); max-width: 1100px; margin-left: auto; margin-right: auto; }
.strip { display: flex; gap: var(--s-3); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding: 2px 2px var(--s-3); scrollbar-width: thin; }
.film-card { flex: 0 0 132px; scroll-snap-align: start; color: var(--text); text-decoration: none; }
.film-card:hover { text-decoration: none; }
.film-card .paper { border-radius: var(--r-md); padding: var(--s-3); border: 1px solid var(--border); }
.film-card:hover .paper { border-color: var(--border-strong); }
.film-name { display: block; margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-empty { color: var(--muted); margin: var(--s-3) 0; }

@media (max-width: 760px) {
  body.page-scan main { padding-bottom: calc(var(--tabbar-h) + 190px + env(safe-area-inset-bottom)); }
  .scan-head { margin-bottom: var(--s-3); }
  /* The whole picture, never cropped: the outlines are drawn over all of it. */
  /* No minimum height: with the 16:9 shape it would force a width. */
  .viewfinder { border-radius: var(--r-lg); max-height: none; min-height: 0; margin: 0; }
  .frame { inset: 12px; }
  .viewfinder .badge { left: 22px; top: 22px; }
  /* The zoom at the top right, out of the hint's way; the hint on one line. */
  .zoom-pill { right: var(--s-2); top: var(--s-2); bottom: auto; }
  .viewfinder .hint { white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; display: block; }
  .viewfinder .hint .dot { display: inline-block; margin-right: 6px; vertical-align: 1px; }
  .zoom-pill button { min-width: 30px; min-height: 30px; padding: 0 6px; }
  .pan { width: 34px; height: 34px; }
  .pan-left, .pan-right { top: calc(50% - 17px); }
  .pan-down { bottom: 44px; }
  .pan-up { top: 52px; }
  .viewfinder .hint { font-size: var(--fs-xs); bottom: var(--s-3); }
  .steps { font-size: var(--fs-xs); }
  .steps li { padding: 5px 9px; }
  /* The dock sits above the tab bar, where a thumb reaches the shutter. */
  .dock {
    position: fixed; z-index: 9; left: var(--s-2); right: var(--s-2); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2));
    grid-template-columns: 1fr auto 1fr; grid-template-areas: "modes modes modes" "left shutter right" "msg msg msg";
    gap: var(--s-3) var(--s-2); margin: 0; padding: var(--s-3); border-radius: var(--r-xl);
    background: var(--glass); backdrop-filter: saturate(1.4) blur(18px); border-color: var(--border-strong);
  }
  .dock .segmented { grid-area: modes; justify-self: stretch; }
  .dock .segmented span { padding: 0 var(--s-2); }
  .shutter-wrap { grid-area: shutter; }
  .dock-side { grid-area: right; flex-direction: column; align-items: flex-end; gap: var(--s-2); }
  .scan-message { grid-area: msg; }
  .shutter { width: 72px; height: 72px; }
  .doc-start span { font-size: var(--fs-xs); }
  .glare-option > span:last-child { font-size: var(--fs-xs); }
  .film { margin-top: var(--s-5); }
  .film-card { flex-basis: 108px; }
}

/* Scans: a grid of sheets, with quick actions on hover (always on touch),
   and picking several for one PDF */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-4); }
.scan-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.scan-card:hover, .scan-card:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.scan-card .paper { border-radius: 0; }
.scan-card.is-photo .paper img { border-radius: 1px; }
.scan-card .caption { display: grid; gap: 4px; padding: var(--s-3) var(--s-4) var(--s-4); }
.scan-card .name { color: var(--text); font-weight: 600; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.quick { position: absolute; top: var(--s-2); right: var(--s-2); display: flex; gap: 6px; opacity: 0; transform: translateY(-4px); }
.quick .icon-button { background: var(--scrim); color: #fff; border-color: transparent; backdrop-filter: blur(8px); }
.quick .icon-button:hover { background: rgba(8, 10, 14, .8); }
.scan-card:hover .quick, .scan-card:focus-within .quick { opacity: 1; transform: none; }
.pick { position: absolute; top: var(--s-2); left: var(--s-2); margin: 0; cursor: pointer; opacity: 0; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick .box {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--scrim); border: 2px solid rgba(255, 255, 255, .8); color: transparent; backdrop-filter: blur(8px);
}
.pick .box .icon { width: 17px; height: 17px; }
.pick input:checked + .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick input:focus-visible + .box { outline: 2px solid var(--focus); outline-offset: 2px; }
.pick[data-n]:not([data-n=""]) .box::after {
  content: attr(data-n); position: absolute; top: -6px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: var(--r-full);
  background: var(--text); color: var(--bg); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.pick .box { position: relative; }
.scan-card:hover .pick, .scan-card:focus-within .pick, .picker:has(.pick input:checked) .pick, .picker.picking .pick { opacity: 1; }
.scan-card:has(.pick input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-2); }
.selection {
  position: sticky; bottom: var(--s-4); z-index: 8; display: none; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin: var(--s-5) auto 0; width: fit-content; max-width: 100%; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-5);
  border-radius: var(--r-full); background: var(--glass); backdrop-filter: saturate(1.4) blur(16px);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-3);
}
.picker:has(.pick input:checked) .selection, .picker.picking .selection { display: flex; }
@media (hover: none) {
  .quick, .pick { opacity: 1; transform: none; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .paper { padding: var(--s-3); }
  .scan-card .caption { padding: var(--s-2) var(--s-3) var(--s-3); }
  .quick .icon-button { width: 32px; height: 32px; }
  .selection { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2)); padding-left: var(--s-4); }
  #picked-hint { display: none; }
}

/* One scan */

.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); margin: 0 0 var(--s-4); }
.view-head h1 { margin: 0; }
.back { color: var(--muted); font-weight: 500; white-space: nowrap; }
.rename { display: flex; gap: var(--s-2); flex: 1; min-width: min(100%, 320px); }
.rename input { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 650; background: transparent; border-color: transparent; }
.rename input:hover { border-color: var(--border-strong); }
.rename input:focus-visible { background: var(--surface-2); }
.warning {
  display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); margin: 0 0 var(--s-4);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--r-md);
}
.warning .icon { color: var(--warn); margin-top: 2px; }
.view-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: var(--s-5); align-items: start; }
.sheet-view { display: grid; place-items: center; padding: var(--s-6); background: var(--surface-3); border-radius: var(--r-xl); }
.sheet-view img { max-width: 100%; max-height: calc(100vh - 200px); width: auto; height: auto; display: block; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 14px 36px rgba(0, 0, 0, .25); }
.sheet-view.is-photo { background: radial-gradient(120% 90% at 50% 30%, var(--surface-3), var(--surface-2)); }
.view-side { display: grid; gap: var(--s-3); position: sticky; top: var(--s-5); }
.view-side .card + .card { margin-top: 0; }
.actions-card { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); padding: var(--s-3); }
.actions-card .button, .actions-card button { padding: 0 var(--s-3); }
.turns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.turns button { padding: 0; }
.redo { display: grid; gap: var(--s-3); padding: var(--s-3); }
.glare-card { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
.glare-card > span { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm); line-height: 1.35; }
.glare-card .icon { color: var(--accent-text); }
table.facts th { width: 90px; }
table.facts td { overflow-wrap: anywhere; }
.confirm-thumb { width: 220px; border-radius: var(--r-md); margin: var(--s-3) 0; }
@media (max-width: 1000px) {
  .view-layout { grid-template-columns: minmax(0, 1fr); }
  .view-side { position: static; }
  .sheet-view { padding: var(--s-3); border-radius: var(--r-lg); }
  .sheet-view img { max-height: none; }
}

/* PDFs */

.doc-open {
  display: flex; align-items: center; gap: var(--s-3); margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); background: var(--accent-soft); color: var(--text);
}
.doc-open:hover { text-decoration: none; }
.doc-open .icon { color: var(--accent-text); }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.doc-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon name button" "icon meta button";
  align-items: center; gap: 2px var(--s-4); padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.doc-row:hover { border-color: var(--border-strong); }
.doc-icon { grid-area: icon; display: grid; place-items: center; width: 44px; height: 52px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 14%, var(--surface-3)); color: var(--bad); }
.doc-icon .icon { width: 24px; height: 24px; }
.doc-name { grid-area: name; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { grid-area: meta; font-size: var(--fs-sm); color: var(--muted); }
.doc-meta .pill { margin: 0; font-size: var(--fs-xs); }
.doc-row .button { grid-area: button; }
.doc-summary { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); padding: var(--s-4) var(--s-5); }
.doc-big { display: grid; place-items: center; width: 56px; height: 66px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 14%, var(--surface-3)); color: var(--bad); }
.doc-big .icon { width: 30px; height: 30px; }
.doc-facts { flex: 1; min-width: 200px; line-height: 1.6; }
.doc-buttons { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.grid.pages { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.page-card { margin: 0; }
.page-card .paper { border-radius: var(--r-md); border: 1px solid var(--border); }
.page-card .paper.gone { color: var(--muted); font-size: var(--fs-xs); text-align: center; }
.page-card figcaption { margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); text-align: center; }
.new-doc { display: grid; gap: var(--s-2); max-width: 720px; }
.order { list-style: none; margin: var(--s-4) 0 0; padding: 0; display: grid; gap: var(--s-2); }
.order-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.order-row .paper { padding: 4px; border-radius: 8px; }
.order-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; font-size: var(--fs-sm); }
.order-place input { width: 3.5em; text-align: center; }
.order-moves { display: none; gap: 4px; }
.js .order-moves { display: flex; }
.js .order-place { display: none; }
.order-moves button:disabled { opacity: .3; }
@media (max-width: 560px) {
  .doc-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon name" "icon meta" "button button"; }
  .doc-row .button { margin-top: var(--s-2); }
  .order-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
}

/* Settings */

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s-4); align-items: start; }
.settings .card + .card { margin-top: 0; }
.setting h2 { margin-top: 0; }
.choices-list { display: grid; gap: var(--s-2); margin: var(--s-3) 0; }
.choice { display: flex; align-items: center; gap: var(--s-3); margin: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--border-strong); border-radius: var(--r-md); color: var(--text); font-weight: 550; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; min-height: 0; }
.setting-state { font-size: var(--fs-sm); }

/* Fix corners */

.corners-form { display: grid; gap: var(--s-3); }
.stage { position: relative; overflow: hidden; border-radius: var(--r-lg); background: var(--stage); box-shadow: var(--shadow-2); isolation: isolate; }
.stage.photo { width: fit-content; max-width: 100%; margin: 0 auto; touch-action: none; overflow: visible; }
.stage.photo img { border-radius: var(--r-lg); display: block; max-width: 100%; max-height: calc(100vh - 300px); width: auto; height: auto; user-select: none; -webkit-user-select: none; }
.handles { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.handles polygon { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.handle { fill: var(--accent); stroke: #fff; stroke-width: 3; vector-effect: non-scaling-stroke; cursor: grab; outline: none; }
.handle:hover, .handle.dragging { fill: var(--accent-hover); }
.handle.dragging { cursor: grabbing; }
.handle:focus-visible { stroke: var(--focus); stroke-width: 5; }
.corner-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-2) var(--s-4); }
.corner-fields legend { grid-column: 1 / -1; }
.corner-field { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.corner-field > span { min-width: 7.5em; color: var(--muted); }
.corner-field input { width: 5.5em; }
.js .corner-fields { display: none; }
@media (max-width: 760px) {
  .stage.photo img { max-height: none; }
}

/* Motion, only for those who want it */

@media (prefers-reduced-motion: no-preference) {
  a, button, .nav a, input, select, .pager a, .tabbar > a, .tabbar summary, .segmented span, .switch .track, .switch .track::after {
    transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), left .18s var(--ease);
  }
  .scan-card { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
  .scan-card:hover { transform: translateY(-3px); }
  .quick, .pick { transition: opacity .18s var(--ease), transform .18s var(--ease); }
  .film-card .paper { transition: transform .2s var(--ease), border-color .2s var(--ease); }
  .film-card:hover .paper { transform: translateY(-3px); }
  .outline polygon { animation: found .35s var(--ease); }
  .outline.photos polygon { animation: found .35s var(--ease), march 1.2s linear infinite; }
  .viewfinder .frame i { transition: border-color .3s var(--ease); }
  .shutter::after { transition: transform .2s var(--ease), border-radius .25s var(--ease), filter .15s; }
  .shutter.busy { animation: spin 1s linear infinite; }
  .shutter.busy::after { animation: spin 1s linear infinite reverse; }
  .steps { animation: drop .25s var(--ease); }
  .steps li.now .tick { animation: spin .8s linear infinite; }
  .flash.go { animation: flash .5s var(--ease); }
  .focus-ring:not([hidden]) i { animation: ring-in .25s var(--ease); }
  .focus-ring.focusing i { animation: ring-in .25s var(--ease), ring-pulse .9s var(--ease) .25s infinite; }
  .focus-ring.ok i, .focus-ring.fail i { animation: ring-done .3s var(--ease); }
  @keyframes ring-in { from { transform: scale(1.6); opacity: 0; } }
  @keyframes ring-pulse { 50% { transform: scale(.88); } }
  @keyframes ring-done { 40% { transform: scale(.85); } }
  .film-card.arrive { animation: arrive .7s var(--ease); }
  .toast:not([hidden]) { animation: toast-in .3s var(--ease); }
  .toast.out { opacity: 0; transform: translate(-50%, 8px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
  .viewfinder .badge.on::before { animation: pulse 2s var(--ease) infinite; }
  .more[open] .sheet { animation: rise .16s var(--ease); }
  .selection { animation: rise .2s var(--ease); }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes found { from { opacity: 0; } }
  @keyframes march { to { stroke-dashoffset: -32; } }
  @keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }
  @keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }
  @keyframes arrive { 0% { opacity: 0; transform: translate(-40px, -120px) scale(1.6) rotate(-4deg); } 60% { opacity: 1; } 100% { transform: none; } }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
  @keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 77, 77, 0); } }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
