/* 문서 스캔 - mobile first, in the manner of an iPhone app.
   Layout: grouped grey ground, white cards and inset lists, translucent bars
   that stay put; one system blue for actions, red only to delete. Editing and
   the camera are black screens like Photos and Camera, where the one call to
   action is yellow. Type is the system face at the iOS sizes (34 / 17 / 13). */
:root {
  --bg: #f2f2f7;                       /* systemGroupedBackground */
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);   /* tertiarySystemFill: tracks, wells */
  --fill-strong: rgba(118, 118, 128, 0.2);
  --text: #000000;
  --muted: rgba(60, 60, 67, 0.6);      /* secondaryLabel */
  --faint: rgba(60, 60, 67, 0.3);
  --line: rgba(60, 60, 67, 0.29);      /* separator */
  --accent: #007aff;                   /* systemBlue */
  --accent-press: #0062cc;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --on-accent: #ffffff;
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --ok: #34c759;
  --warn: #ff9500;
  --warn-bg: rgba(255, 149, 0, 0.16);
  --paper: #ffffff;
  --paper-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.12), 0 4px 14px rgba(0, 0, 0, 0.08);
  --bar: rgba(249, 249, 249, 0.86);
  --scrim: rgba(0, 0, 0, 0.35);
  --hud: rgba(30, 30, 32, 0.86);

  /* the black screens look the same in both themes */
  --stage: #000000;
  --stage-bar: rgba(22, 22, 24, 0.82);
  --stage-text: #ffffff;
  --stage-muted: rgba(235, 235, 245, 0.6);
  --stage-fill: rgba(118, 118, 128, 0.24);
  --stage-fill-press: rgba(118, 118, 128, 0.4);
  --stage-accent: #ffd60a;             /* systemYellow: 완료, active camera modes */
  --stage-warn: #ffd60a;
  --stage-danger: #ff453a;

  --r-sm: 4px;                         /* paper corners */
  --r-md: 10px;                        /* inset lists, cards */
  --r-lg: 12px;                        /* buttons */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --text: #ffffff;
    --muted: rgba(235, 235, 245, 0.6);
    --faint: rgba(235, 235, 245, 0.3);
    --line: rgba(84, 84, 88, 0.65);
    --accent: #0a84ff;
    --accent-press: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.18);
    --ok: #30d158;
    --warn: #ff9f0a;
    --warn-bg: rgba(255, 159, 10, 0.2);
    --paper: #f5f5f3;
    --paper-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.6), 0 6px 16px rgba(0, 0, 0, 0.55);
    --bar: rgba(22, 22, 24, 0.82);
    --scrim: rgba(0, 0, 0, 0.55);
    --hud: rgba(58, 58, 60, 0.9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 var(--font);
  letter-spacing: -0.01em;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.35; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabular { font-variant-numeric: tabular-nums; }

#app { height: 100vh; height: 100dvh; }
.view { height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
.view.dark { background: var(--stage); color: var(--stage-text); max-width: none; color-scheme: dark; }

/* ---- navigation bars ---- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-t) + 6px) 8px 6px 16px;
  min-height: calc(var(--safe-t) + 50px);
  flex: none;
}
.view.dark .bar {
  background: var(--stage-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  padding-left: 4px; padding-right: 4px;
}
.bar h1 { font: 700 34px/1.12 var(--font-display); margin: 0; letter-spacing: 0.01em; }
.bar-title { font-size: 17px; font-weight: 600; text-align: center; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; color: var(--accent); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { opacity: 0.5; }
.bar-link { min-height: 44px; padding: 0 10px; font-size: 17px; color: var(--accent); }
.bar-link:active { opacity: 0.5; }
.text-btn { min-width: 52px; height: 44px; padding: 0 10px; font-size: 17px; color: var(--stage-text); }
.text-btn.strong { color: var(--stage-accent); font-weight: 600; }
.text-btn:active { opacity: 0.5; }
.text-btn.back { display: inline-flex; align-items: center; gap: 0; padding-left: 2px; color: var(--stage-accent); }
.text-btn.back svg { width: 24px; height: 24px; stroke-width: 2.4; }

.home-bar { align-items: flex-end; padding-top: calc(var(--safe-t) + 10px); padding-bottom: 8px;
  background: var(--bg); }
.title-block { min-width: 0; }
.sub { margin: 2px 0 0; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 20px; }
.select-bar { padding-left: 6px; padding-right: 6px; background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--line); }
.select-bar .bar-title { font-variant-numeric: tabular-nums; }

/* ---- sign in ---- */
.view.login { justify-content: center; overflow-y: auto; }
.login-box { padding: calc(var(--safe-t) + 28px) 24px calc(var(--safe-b) + 28px); text-align: center; max-width: 420px; margin: 0 auto; }
.login-icon { border-radius: 22px; box-shadow: var(--paper-shadow); }
.login-box h1 { font: 700 28px/1.2 var(--font-display); margin: 18px 0 6px; }
.login-lead { margin: 0 0 24px; color: var(--muted); font-size: 17px; }
.login-box .btn { margin-top: 10px; }
.login-points { text-align: left; margin: 24px 0 10px; padding: 12px 16px 12px 34px;
  border-radius: var(--r-md); background: var(--surface); font-size: 15px; color: var(--muted); }
.login-points li { margin: 6px 0; }
.account { width: 32px; height: 32px; margin: 0 6px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 15px;
  display: grid; place-items: center; }
.account.stale { background: var(--fill); color: var(--muted); }

/* ---- home: the pages ---- */
#home-main { flex: 1; overflow-y: auto; padding: 8px 16px 20px; -webkit-overflow-scrolling: touch; }
.empty { text-align: center; padding: 11vh 20px 0; color: var(--muted); }
.empty h2 { color: var(--text); font: 600 22px/1.25 var(--font-display); margin: 18px 0 6px; }
.empty p { margin: 0 auto; max-width: 22em; font-size: 15px; }
.empty-art { width: 96px; height: 96px; }
.art-sheet { fill: var(--surface); stroke: var(--faint); stroke-width: 2; }
.art-line { stroke: var(--faint); stroke-width: 4; }
.art-scan { stroke: var(--accent); stroke-width: 4; }

.pages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
@media (min-width: 540px) { .pages { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 740px) { .pages { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.page { position: relative; display: grid; gap: 6px; width: 100%; text-align: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.paper {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; max-width: 100%;
  border-radius: var(--r-sm); background: var(--paper); box-shadow: var(--paper-shadow);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
}
.paper img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: var(--r-sm); }
button.page:active .paper { transform: scale(0.97); }
.cap { display: flex; justify-content: center; align-items: baseline; gap: 5px; font-size: 13px; min-width: 0; }
.cap .no { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.cap .mode { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-me { position: absolute; left: 6px; top: 6px; padding: 1px 7px; border-radius: 9px;
  background: var(--warn); color: #ffffff; font-size: 11px; font-weight: 700; letter-spacing: 0; }

/* sections on home: PDF files first, then the scanned pages */
.section-head { margin: 4px 4px 10px; font-size: 20px; font-weight: 700; font-family: var(--font-display); }
#files-section { margin-bottom: 26px; }
.page.file .paper::after {
  content: "PDF"; position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: 5px;
  background: var(--danger); color: #ffffff; font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
}
.page.file .cap { flex-direction: column; align-items: center; gap: 0; }
.page.file .cap .no { font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* picking, the way Photos does it: a circle per sheet, numbered in tap order */
.pick {
  position: absolute; right: 6px; bottom: 6px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.12); box-shadow: inset 0 0 0 1.5px #ffffff, 0 1px 3px rgba(0, 0, 0, 0.3);
  color: transparent;
}
.pick.on { background: var(--accent); color: #ffffff; box-shadow: 0 0 0 1.5px #ffffff, 0 1px 3px rgba(0, 0, 0, 0.3); }
.page.picked .paper { transform: scale(0.94); }
.page.picked .paper img { opacity: 0.82; }

.page.pending .paper { display: grid; place-items: center; background: var(--surface); box-shadow: inset 0 0 0 0.5px var(--line); }
.page.pending .cap .mode { color: var(--faint); }

/* ---- bottom toolbar: nothing sticks out over the pages ---- */
.dock {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 6px 12px calc(var(--safe-b) + 6px);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -0.5px 0 var(--line);
}
.dock-btn { display: grid; justify-items: center; gap: 2px; padding: 4px 10px; border-radius: var(--r-md);
  font-size: 10px; font-weight: 500; letter-spacing: 0.01em; color: var(--accent); min-height: 50px; justify-self: center; align-content: center; }
.dock-btn svg { width: 26px; height: 26px; }
.dock-btn:not(:disabled):active { opacity: 0.5; }
.dock-btn.danger { color: var(--danger); }
.dock-btn.accent { color: var(--accent); }
.shoot {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
}
.shoot svg { width: 26px; height: 26px; }
.shoot:active { background: var(--accent-press); transform: scale(0.95); }
.select-dock { grid-template-columns: auto 1fr auto; gap: 8px; }
.sel-hint { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }

/* ---- black screens: camera, crop, adjust, one page ---- */
.stage { flex: 1; position: relative; min-height: 0; overflow: hidden; }
#cam-video, #cam-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#cam-video { object-fit: cover; background: var(--stage); }   /* always fills the screen; camera.js maps its drawing the same way */
#cam-overlay { pointer-events: none; }
/* the camera picture fills the whole screen; bars and buttons float on it */
#v-camera { position: relative; }
#cam-stage { position: absolute; inset: 0; }
#v-camera .bar { position: relative; z-index: 2; background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  -webkit-backdrop-filter: none; backdrop-filter: none; padding-bottom: 18px; }
#v-camera .cam-debug { position: relative; z-index: 2; }
#v-camera .cam-options { position: relative; z-index: 2; margin-top: auto; }
#v-camera .cam-controls { position: relative; z-index: 2; background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.55)); }
#cam-hint { font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.cam-fail { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center;
  padding: 24px; text-align: center; color: var(--stage-muted); background: var(--stage); }
.cam-fail p { margin: 4px 0; }
.cam-controls, .tools {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 14px 20px calc(var(--safe-b) + 16px);
}
.cam-controls > :first-child { justify-self: start; }
.cam-controls > :last-child { justify-self: end; }
.cam-controls .shutter { grid-column: 2; }
.cam-controls .stack { grid-column: 1; }
.cam-controls #cam-done { grid-column: 3; }
.cam-options { flex: none; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 10px 12px 2px; }
.cam-options .pill { min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 600; background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
/* camera modes read like the Camera app: yellow when on */
.pill.check input { position: absolute; opacity: 0; pointer-events: none; }
.pill.check { position: relative; color: var(--stage-muted); }
.pill.check:has(input:checked) { color: var(--stage-accent); }
.pill.strong { background: none; color: var(--stage-accent); font-weight: 600; font-size: 17px; padding: 0 6px; }
.stack { position: relative; width: 48px; height: 48px; border-radius: 8px; overflow: visible;
  background: var(--stage-fill); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.stack img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; }
.stack span { position: absolute; right: -8px; top: -8px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--stage-accent); color: #000000; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.stack.busy span { background: #ffffff; }
.cam-debug { flex: none; margin: 0; padding: 6px 12px; font: 11.5px/1.4 var(--mono);
  color: #a7f3d0; background: rgba(0, 0, 0, 0.55); white-space: pre-wrap; }
.tools { display: flex; justify-content: center; gap: 10px; }
.tools.wrap { flex-direction: column; align-items: center; gap: 12px; }
/* the shutter of the Camera app: a white disc in a white ring */
.shutter {
  width: 72px; height: 72px; border-radius: 50%; background: #ffffff;
  border: 4px solid #000000; box-shadow: 0 0 0 4px #ffffff;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.shutter:active { transform: scale(0.92); }
.shutter.busy { opacity: 0.5; transform: scale(0.9); }
.pill {
  min-height: 36px; padding: 0 14px; border-radius: 18px; font-size: 15px;
  background: var(--stage-fill); color: var(--stage-text); display: inline-flex; align-items: center; gap: 6px;
}
.pill:active { background: var(--stage-fill-press); }
.pill:disabled { opacity: 0.35; }
.note { flex: none; margin: 0; padding: 10px 16px 0; text-align: center; font-size: 13px; color: var(--stage-muted); min-height: 30px;
  font-variant-numeric: tabular-nums; }
.note.warn { color: var(--stage-warn); }

.crop-canvas { position: absolute; inset: 0; }
.crop-loupe {
  position: absolute; border-radius: 50%; border: 3px solid #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6); pointer-events: none; z-index: 2;
}
#adj-canvas, #pv-canvas, #fv-canvas { background: #ffffff; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7); will-change: transform; }
.zoom-badge { position: absolute; right: 12px; top: 10px; z-index: 2; pointer-events: none;
  padding: 3px 9px; border-radius: 11px; font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, 0.55); color: #ffffff; font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.row-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tip { margin: 0; font-size: 12px; color: var(--stage-muted); text-align: center; }

/* mode choice: an iOS segmented control on the black screens */
.chips {
  display: inline-flex; gap: 0; padding: 2px; border-radius: 9px; background: var(--stage-fill);
  flex-wrap: nowrap; justify-content: center; max-width: 100%;
}
#pv-filters { align-self: center; margin: 10px 16px 0; }
.chip {
  min-height: 30px; padding: 0 16px; border-radius: 7px; font-size: 13px; font-weight: 500;
  color: var(--stage-text); white-space: nowrap;
}
.chip.on { background: rgba(255, 255, 255, 0.28); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12); }
.chip:not(.on):active { opacity: 0.5; }

/* one page screen */
.stage-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.35); z-index: 3; }
.pv-nav {
  position: absolute; top: 50%; width: 36px; height: 56px; margin-top: -28px; z-index: 2;
  display: grid; place-items: center; color: var(--stage-text); border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.3); opacity: 0.7;
}
.pv-nav svg { width: 22px; height: 22px; stroke-width: 2.2; }
.pv-nav.prev { left: 6px; }
.pv-nav.next { right: 6px; }
.pv-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: none) { .pv-nav { background: none; opacity: 0.5; } }
.toolbar {
  flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
  padding: 8px 6px calc(var(--safe-b) + 6px);
  background: var(--stage-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.toolbar.three { grid-template-columns: repeat(3, 1fr); }
.bar-spacer { min-width: 72px; }
.tool { display: grid; justify-items: center; gap: 3px; min-height: 50px; padding: 4px 2px; border-radius: var(--r-md);
  font-size: 10px; font-weight: 500; letter-spacing: 0.01em; color: var(--stage-text); align-content: center; }
.tool svg { width: 25px; height: 25px; }
.tool:active { opacity: 0.5; }
.tool.danger { color: var(--stage-danger); }

/* ---- sheets: grouped, like an iOS form sheet ---- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 640px; margin: 0 auto;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); color: var(--text);
  border-radius: 12px 12px 0 0; box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
  padding: 6px 16px calc(var(--safe-b) + 16px);
  animation: rise 0.32s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.sheet.tall { max-height: 94vh; max-height: 94dvh; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .paper { transition: none; }
}
.grab { width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 2px auto 12px; }
.sheet h2 { font: 700 22px/1.25 var(--font-display); margin: 2px 4px 14px; text-wrap: balance; }
.sheet h2 + .scope { margin-top: -8px; }
.sheet h3 { font-size: 13px; margin: 24px 16px 6px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.card { background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; margin: 12px 0; }
.card h3 { margin: 0 0 4px; color: var(--text); font-size: 17px; font-weight: 600; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.steps { margin: 0 0 12px; padding-left: 1.3em; font-size: 15px; }
.steps li { margin: 3px 0; }
a { color: var(--accent); }

.field { display: block; margin: 14px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 16px 6px; }
.field input {
  width: 100%; height: 44px; padding: 0 16px; border-radius: var(--r-md);
  border: 0; background: var(--surface); outline: none; font-size: 17px;
}
.field input:focus { box-shadow: 0 0 0 2px var(--accent); }
/* the iOS segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 2px;
  border-radius: 9px; background: var(--fill); }
.seg button { min-height: 30px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text); padding: 0 6px; }
.seg button.on { background: var(--surface); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }
/* a checkbox becomes an iOS switch */
.check-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 12px 0;
  padding: 10px 16px; background: var(--surface); border-radius: var(--r-md); font-size: 17px; }
.check-row > span { order: 1; flex: 1; }
.check-row input { order: 2; flex: none; appearance: none; -webkit-appearance: none; margin: 0;
  width: 51px; height: 31px; border-radius: 16px; background: var(--fill-strong); position: relative; cursor: pointer;
  transition: background 0.2s ease; }
.check-row input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s ease; }
.check-row input:checked { background: var(--ok); }
.check-row input:checked::after { transform: translateX(20px); }
.check-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 16px; overflow-wrap: anywhere; }
.hint.center { text-align: center; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
.login-box .hint { margin-left: 0; margin-right: 0; }
code { font: 13px var(--mono); background: var(--fill); padding: 2px 6px; border-radius: 6px; }

.actions { display: grid; gap: 10px; margin: 18px 0 8px; }
.btn {
  width: 100%; min-height: 50px; border-radius: var(--r-lg); padding: 0 16px; font-size: 17px; font-weight: 600;
  background: var(--surface); color: var(--accent); margin-top: 8px;
}
.actions .btn { margin-top: 0; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:not(:disabled):active { background: var(--accent-press); }
.btn.ghost { background: none; color: var(--accent); font-weight: 400; }
.btn.danger-soft { background: var(--surface); color: var(--danger); font-weight: 400; }
.btn:not(:disabled):active { opacity: 0.7; }
.link { display: block; margin: 4px auto; color: var(--accent); font-size: 15px; min-height: 40px; }
/* an inset grouped list */
.list { display: grid; gap: 0; margin-bottom: 8px; background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.row { text-align: left; min-height: 44px; padding: 0 16px; font-size: 17px; color: var(--accent); }
.row + .row { box-shadow: inset 0 0.5px 0 var(--line); }
.row:not(:disabled):active { background: var(--fill); }
.row.danger { color: var(--danger); }

/* ---- import sheet ---- */
.import-row { display: flex; align-items: center; gap: 14px; min-height: 60px; color: var(--text); }
.import-row svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.import-row span { display: grid; }
.import-row small { font-size: 13px; color: var(--muted); }

/* ---- fax sheet: the free way first ---- */
.fax-summary { margin: 4px 4px 0; font-size: 17px; font-weight: 600; }
.fax-steps { margin: 4px 0 14px; padding: 12px 16px 12px 34px; background: var(--surface); border-radius: var(--r-md); font-size: 15px; }
.fax-steps li { margin: 4px 0; }
.fax-groups { display: grid; gap: 8px; }
.fax-groups .btn { margin: 0; font-variant-numeric: tabular-nums; }
.btn.sent { color: var(--muted); font-weight: 400; }

/* ---- Drive folder: the row on the export sheet and the folder sheet ---- */
.folder-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; margin-top: 10px;
  padding: 8px 16px; border-radius: var(--r-md); background: var(--surface); text-align: left;
}
.folder-row svg { width: 24px; height: 24px; color: var(--accent); flex: none; }
.folder-row-text { flex: 1; min-width: 0; display: grid; }
.folder-row-text small { font-size: 12px; color: var(--muted); }
.folder-row-text b { font-size: 17px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row-go { font-size: 17px; color: var(--accent); flex: none; }
.folder-row:active { background: var(--fill); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 2px; margin: -6px 4px 10px; font-size: 15px; }
.crumbs button { min-height: 32px; padding: 0 4px; color: var(--accent); }
.crumbs button:disabled { opacity: 1; color: var(--text); font-weight: 600; cursor: default; }
.crumbs .sep { color: var(--faint); }
.folder-list { display: grid; gap: 0; background: var(--surface); border-radius: var(--r-md); overflow: hidden; min-height: 44px; }
.folder-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px 0 16px; text-align: left; font-size: 17px; }
.folder-item + .folder-item { box-shadow: inset 52px 0.5px 0 -52px var(--line), inset 0 0.5px 0 var(--line); }
.folder-item svg { width: 24px; height: 24px; color: var(--accent); flex: none; }
.folder-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .chev { flex: none; width: 16px; height: 16px; color: var(--faint); stroke-width: 2.4; }
.folder-item:active { background: var(--fill); }
.new-folder { display: flex; gap: 8px; margin: 12px 0 0; }
.new-folder input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: var(--r-md);
  border: 0; background: var(--surface); outline: none; font-size: 17px;
}
.new-folder input:focus { box-shadow: 0 0 0 2px var(--accent); }
.new-folder .btn { width: auto; margin: 0; min-height: 44px; padding: 0 18px; flex: none; }

/* ---- busy + toast: iOS style HUDs ---- */
.busy { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.2); display: grid; place-items: center; }
.busy-box { background: var(--hud); color: #ffffff; border-radius: 14px; padding: 22px 24px 18px;
  min-width: 150px; max-width: 78vw; text-align: center;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.busy-box p { margin: 12px 0 0; font-size: 15px; }
.spinner { display: block; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--fill-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.busy-box .spinner { border-color: rgba(255, 255, 255, 0.25); border-top-color: #ffffff; }
.spinner.light { border-color: rgba(255, 255, 255, 0.25); border-top-color: #ffffff; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%);
  z-index: 50; width: max-content; max-width: min(92vw, 520px); padding: 11px 18px; border-radius: 14px;
  background: var(--hud); color: #ffffff; font-size: 15px; text-align: center;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.toast a { color: #64d2ff; }
