/* ============================================================================
   Scent Log — design system
   Notion-like, product register. Light-first with true dark mode.
   All color in OKLCH. Neutrals tinted warm. See DESIGN.md.
   ========================================================================== */

/* ---- Tokens ---------------------------------------------------------------*/
:root {
  color-scheme: light;

  /* neutrals — light */
  --paper: oklch(0.992 0.003 95);
  --surface: oklch(0.999 0.002 95);
  --surface-2: oklch(0.972 0.004 90);
  --ink: oklch(0.24 0.008 75);
  --ink-2: oklch(0.46 0.008 75);
  --ink-3: oklch(0.62 0.006 75);
  --line: oklch(0.90 0.004 85);
  --line-2: oklch(0.84 0.005 85);

  --primary: oklch(0.26 0.01 75);
  --primary-hover: oklch(0.32 0.01 75);
  --on-primary: oklch(0.98 0.003 95);
  --accent: oklch(0.55 0.13 245);
  --accent-hover: oklch(0.49 0.13 245);
  --accent-bg: oklch(0.95 0.03 245);
  --selection: oklch(0.9 0.05 245);

  /* semantic status — light */
  --ok: oklch(0.66 0.14 155);
  --ok-strong: oklch(0.52 0.13 155);
  --ok-bg: oklch(0.95 0.04 155);
  --warn: oklch(0.74 0.13 78);
  --warn-strong: oklch(0.60 0.12 70);
  --warn-bg: oklch(0.95 0.05 85);
  --danger: oklch(0.58 0.20 25);
  --danger-hover: oklch(0.52 0.20 25);
  --danger-bg: oklch(0.95 0.04 25);
  --on-danger: oklch(0.99 0.003 95);

  /* typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, system-ui, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.9rem;

  /* space */
  --s1: 0.25rem;  --s2: 0.375rem; --s3: 0.5rem;  --s4: 0.75rem;
  --s5: 1rem;     --s6: 1.25rem;  --s7: 1.5rem;  --s8: 2rem;
  --s9: 2.5rem;   --s10: 3rem;

  /* radius */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px; --pill: 999px;

  /* elevation */
  --shadow-sm: 0 1px 2px oklch(0.24 0.008 75 / 0.06),
               0 1px 1px oklch(0.24 0.008 75 / 0.04);
  --shadow-md: 0 6px 24px oklch(0.24 0.008 75 / 0.10),
               0 2px 6px oklch(0.24 0.008 75 / 0.06);
  --shadow-lg: 0 16px 48px oklch(0.2 0.008 75 / 0.22);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 200ms;

  --header-h: 56px;
  --maxw: 640px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: oklch(0.205 0.006 75);
  --surface: oklch(0.24 0.006 75);
  --surface-2: oklch(0.285 0.007 75);
  --ink: oklch(0.945 0.004 90);
  --ink-2: oklch(0.74 0.006 85);
  --ink-3: oklch(0.60 0.006 85);
  --line: oklch(0.32 0.007 75);
  --line-2: oklch(0.40 0.008 75);

  --primary: oklch(0.94 0.004 90);
  --primary-hover: oklch(0.86 0.004 90);
  --on-primary: oklch(0.22 0.006 75);
  --accent: oklch(0.72 0.13 245);
  --accent-hover: oklch(0.78 0.13 245);
  --accent-bg: oklch(0.32 0.06 245);
  --selection: oklch(0.4 0.08 245);

  --ok: oklch(0.74 0.15 155);
  --ok-strong: oklch(0.80 0.15 155);
  --ok-bg: oklch(0.30 0.05 155);
  --warn: oklch(0.80 0.14 80);
  --warn-strong: oklch(0.85 0.14 82);
  --warn-bg: oklch(0.33 0.05 80);
  --danger: oklch(0.68 0.19 25);
  --danger-hover: oklch(0.74 0.19 25);
  --danger-bg: oklch(0.33 0.07 25);
  --on-danger: oklch(0.99 0.003 95);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-md: 0 8px 28px oklch(0 0 0 / 0.5);
  --shadow-lg: 0 18px 52px oklch(0 0 0 / 0.62);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: oklch(0.205 0.006 75);
    --surface: oklch(0.24 0.006 75);
    --surface-2: oklch(0.285 0.007 75);
    --ink: oklch(0.945 0.004 90);
    --ink-2: oklch(0.74 0.006 85);
    --ink-3: oklch(0.60 0.006 85);
    --line: oklch(0.32 0.007 75);
    --line-2: oklch(0.40 0.008 75);
    --primary: oklch(0.94 0.004 90);
    --primary-hover: oklch(0.86 0.004 90);
    --on-primary: oklch(0.22 0.006 75);
    --accent: oklch(0.72 0.13 245);
    --accent-hover: oklch(0.78 0.13 245);
    --accent-bg: oklch(0.32 0.06 245);
    --selection: oklch(0.4 0.08 245);
    --ok: oklch(0.74 0.15 155);
    --ok-strong: oklch(0.80 0.15 155);
    --ok-bg: oklch(0.30 0.05 155);
    --warn: oklch(0.80 0.14 80);
    --warn-strong: oklch(0.85 0.14 82);
    --warn-bg: oklch(0.33 0.05 80);
    --danger: oklch(0.68 0.19 25);
    --danger-hover: oklch(0.74 0.19 25);
    --danger-bg: oklch(0.33 0.07 25);
    --on-danger: oklch(0.99 0.003 95);
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.4);
    --shadow-md: 0 8px 28px oklch(0 0 0 / 0.5);
    --shadow-lg: 0 18px 52px oklch(0 0 0 / 0.62);
  }
}

/* ---- Reset / base ---------------------------------------------------------*/
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-family: var(--font);
}
body {
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
::selection { background: var(--selection); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
h1, h2, h3 { line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---- Layout ---------------------------------------------------------------*/
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s5);
  padding-top: env(safe-area-inset-top);
  background: color-mix(in oklch, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar h1 { font-size: var(--fs-md); font-weight: 600; }
.appbar .grow { flex: 1; min-width: 0; }
.appbar__title { display: flex; flex-direction: column; min-width: 0; }
.appbar__title small { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 500; }
.appbar__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--s5) var(--s5) calc(var(--s10) + env(safe-area-inset-bottom));
}
.main--wide { max-width: 960px; }

.stack { display: flex; flex-direction: column; gap: var(--s5); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--s3); }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.section-label {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ---- Buttons --------------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  border-radius: var(--r);
  font-size: var(--fs-base); font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), transform 120ms var(--ease), box-shadow var(--dur);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn--ghost { color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { background: var(--danger); color: var(--on-danger); }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn--block { width: 100%; }
.btn--lg { min-height: 56px; font-size: var(--fs-md); font-weight: 600; border-radius: var(--r-lg); }
.btn--sm { min-height: 36px; padding: 0 var(--s4); font-size: var(--fs-sm); border-radius: var(--r-sm); }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r);
  color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn--sm { width: 36px; height: 36px; }

/* segmented control */
.segment { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2);
  border-radius: var(--r); border: 1px solid var(--line); }
.segment button {
  min-height: 34px; padding: 0 var(--s4); border-radius: 7px;
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
  transition: background var(--dur), color var(--dur);
}
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---- Cards / list items ---------------------------------------------------*/
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s5);
}
.tap {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s5);
  color: inherit;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), transform 120ms var(--ease);
}
.tap:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.tap:active { transform: scale(0.995); }

.locard__top { display: flex; align-items: flex-start; gap: var(--s4); }
.locard__name { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
.locard__addr { font-size: var(--fs-sm); color: var(--ink-2); margin-top: 2px; }
.locard__meta { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4);
  font-size: var(--fs-sm); color: var(--ink-2); }
.chev { color: var(--ink-3); flex: none; }

/* device row */
.devrow { display: flex; align-items: center; gap: var(--s4); }
.devrow__thumb {
  width: 52px; height: 52px; border-radius: var(--r); flex: none;
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--line);
}
.devrow__body { flex: 1; min-width: 0; }
.devrow__name { font-weight: 600; font-size: var(--fs-base); }
.devrow__scent { font-size: var(--fs-sm); color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Stats ----------------------------------------------------------------*/
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
@media (min-width: 480px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: var(--s4) var(--s5);
}
.stat__num { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat__label { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 2px; font-weight: 500; }
.stat--danger .stat__num { color: var(--danger); }
.stat--warn .stat__num { color: var(--warn-strong); }

/* ---- Badges / status ------------------------------------------------------*/
.badge {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 24px; padding: 0 var(--s3);
  border-radius: var(--pill); font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge--ok { background: var(--ok-bg); color: var(--ok-strong); }
.badge--warn { background: var(--warn-bg); color: var(--warn-strong); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--accent { background: var(--accent-bg); color: var(--accent-hover); }
.badge--ghost { background: transparent; border: 1px solid var(--line-2); }

.dot { width: 9px; height: 9px; border-radius: var(--pill); flex: none; background: var(--ink-3); }
.dot--ok { background: var(--ok); } .dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); } .dot--none { background: var(--ink-3); }

/* usage bar */
.usage { display: flex; flex-direction: column; gap: var(--s2); }
.usage__track { height: 8px; border-radius: var(--pill); background: var(--surface-2); overflow: hidden; }
.usage__fill { height: 100%; border-radius: var(--pill); background: var(--ok);
  transition: width 400ms var(--ease); }
.usage__fill--warn { background: var(--warn); } .usage__fill--danger { background: var(--danger); }
.usage__meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-2); }

/* ---- Forms ----------------------------------------------------------------*/
.field { display: flex; flex-direction: column; gap: var(--s2); }
.field > label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field .err { font-size: var(--fs-xs); color: var(--danger); font-weight: 500; }
.input, .textarea, .select {
  width: 100%; min-height: 46px; padding: var(--s3) var(--s4);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: var(--fs-md); /* 16px stops iOS zoom */
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field[data-invalid] .input, .field[data-invalid] .textarea { border-color: var(--danger); }

.search {
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4); height: 46px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.search svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-size: var(--fs-md); }

/* password field with show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); border-radius: var(--r-sm); transition: color var(--dur), background var(--dur);
}
.pw-eye:hover { color: var(--ink); background: var(--surface-2); }
.pw-eye svg { width: 18px; height: 18px; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track { position: absolute; inset: 0; background: var(--line-2); border-radius: var(--pill);
  transition: background var(--dur) var(--ease); }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: var(--surface); border-radius: var(--pill); box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track + .switch__thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* settings rows */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.rows > * + * { border-top: 1px solid var(--line); }
.orow { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5); min-height: 56px; }
.orow__body { flex: 1; min-width: 0; }
.orow__title { font-weight: 500; }
.orow__sub { font-size: var(--fs-sm); color: var(--ink-2); }
button.orow { width: 100%; text-align: left; transition: background var(--dur); }
button.orow:hover { background: var(--surface-2); }

/* ---- Photos ---------------------------------------------------------------*/
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.photo {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); cursor: zoom-in;
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo__label {
  position: absolute; left: var(--s3); bottom: var(--s3);
  font-size: var(--fs-xs); font-weight: 600; color: #fff;
  background: oklch(0.2 0.01 75 / 0.62); padding: 3px var(--s3); border-radius: var(--pill);
  backdrop-filter: blur(4px);
}
.photo--empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s2); color: var(--ink-3); font-size: var(--fs-xs); cursor: default; }
.photo--empty svg { width: 24px; height: 24px; }

.imgup { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.imgup__slot {
  position: relative; aspect-ratio: 4/3; border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-2); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s2); color: var(--ink-3); font-size: var(--fs-xs); text-align: center; padding: var(--s3);
  overflow: hidden; cursor: pointer; transition: border-color var(--dur), color var(--dur);
}
.imgup__slot:hover { border-color: var(--accent); color: var(--ink-2); }
.imgup__slot svg { width: 22px; height: 22px; }
.imgup__slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.imgup__slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.imgup__clear { position: absolute; top: var(--s2); right: var(--s2); z-index: 2;
  width: 28px; height: 28px; border-radius: var(--pill); background: oklch(0.2 0.01 75 / 0.6);
  color: #fff; display: flex; align-items: center; justify-content: center; }
.imgup__clear svg { width: 15px; height: 15px; }

/* ---- History timeline -----------------------------------------------------*/
.log { display: flex; gap: var(--s4); padding: var(--s4) 0; }
.log + .log { border-top: 1px solid var(--line); }
.log__rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 3px; }
.log__body { flex: 1; min-width: 0; }
.log__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.log__when { font-weight: 500; font-size: var(--fs-sm); }
.log__ago { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.log__who { font-size: var(--fs-sm); color: var(--ink-2); }
.log__note { font-size: var(--fs-sm); color: var(--ink-2); margin-top: 2px; }
.log--void .log__when, .log--void .log__who { text-decoration: line-through; color: var(--ink-3); }
.log__void { font-size: var(--fs-xs); color: var(--danger); margin-top: var(--s2);
  background: var(--danger-bg); padding: var(--s2) var(--s3); border-radius: var(--r-sm); }

/* ---- Toast ----------------------------------------------------------------*/
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--s6) + env(safe-area-inset-bottom));
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  pointer-events: none; padding: 0 var(--s5);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--s4);
  max-width: 460px; width: fit-content;
  background: var(--ink); color: var(--paper);
  padding: var(--s3) var(--s3) var(--s3) var(--s5); border-radius: var(--pill);
  box-shadow: var(--shadow-md); font-size: var(--fs-sm); font-weight: 500;
  animation: toast-in 260ms var(--ease);
}
.toast[data-leaving] { animation: toast-out 200ms var(--ease) forwards; }
.toast__action {
  color: var(--paper); font-weight: 600; padding: var(--s2) var(--s4);
  border-radius: var(--pill); background: oklch(1 0 0 / 0.14);
}
.toast__action:hover { background: oklch(1 0 0 / 0.24); }
.toast svg { width: 16px; height: 16px; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---- Sheet / dialog -------------------------------------------------------*/
.scrim {
  position: fixed; inset: 0; z-index: 70; background: oklch(0.2 0.01 75 / 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 200ms var(--ease); backdrop-filter: blur(2px);
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s5) var(--s5) calc(var(--s6) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheet-up 280ms var(--ease);
  max-height: 92dvh; overflow-y: auto;
}
.sheet__grab { width: 36px; height: 4px; border-radius: var(--pill); background: var(--line-2);
  margin: 0 auto var(--s4); }
.sheet__title { font-size: var(--fs-lg); font-weight: 600; }
.sheet__sub { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 640px) {
  .scrim { align-items: center; }
  .sheet { border-radius: var(--r-xl); animation: dialog-in 200ms var(--ease); }
  .sheet__grab { display: none; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
}

/* choice list (nav chooser etc.) */
.choice {
  display: flex; align-items: center; gap: var(--s4); width: 100%;
  padding: var(--s4); border-radius: var(--r); text-align: left;
  border: 1px solid var(--line); background: var(--surface);
  transition: background var(--dur), border-color var(--dur);
}
.choice:hover { background: var(--surface-2); border-color: var(--line-2); }
.choice__icon { width: 40px; height: 40px; border-radius: var(--r); flex: none;
  display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.choice__icon svg { width: 22px; height: 22px; }
.choice__body { flex: 1; }
.choice__title { font-weight: 600; }
.choice__sub { font-size: var(--fs-sm); color: var(--ink-2); }

/* ---- Lightbox -------------------------------------------------------------*/
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: oklch(0.15 0.008 75 / 0.92);
  display: flex; align-items: center; justify-content: center; padding: var(--s5);
  animation: fade 200ms var(--ease);
}
.lightbox img { max-width: 100%; max-height: 90dvh; border-radius: var(--r);
  box-shadow: var(--shadow-lg); }
.lightbox__close { position: absolute; top: calc(var(--s4) + env(safe-area-inset-top)); right: var(--s4);
  width: 44px; height: 44px; border-radius: var(--pill); background: oklch(1 0 0 / 0.14); color: #fff;
  display: flex; align-items: center; justify-content: center; }

/* ---- Tabs / bottom nav ----------------------------------------------------*/
.tabbar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; background: color-mix(in oklch, var(--paper) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--s3) 0 var(--s2); color: var(--ink-3); font-size: 0.6875rem; font-weight: 500;
  transition: color var(--dur);
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--ink); }

/* ---- Misc -----------------------------------------------------------------*/
.divider { height: 1px; background: var(--line); border: none; }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv__k { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-3); }
.kv__v { font-size: var(--fs-base); }
.grid-kv { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5) var(--s4); }

.copyable { cursor: copy; -webkit-user-select: none; user-select: none; border-radius: var(--r-sm);
  transition: background 120ms; -webkit-touch-callout: none; }
.copyable:active { background: var(--accent-bg); }

.empty { text-align: center; padding: var(--s9) var(--s5); color: var(--ink-2); }
.empty svg { width: 40px; height: 40px; color: var(--ink-3); margin: 0 auto var(--s4); }
.empty h3 { font-size: var(--fs-md); color: var(--ink); margin-bottom: var(--s2); }
.empty p { font-size: var(--fs-sm); max-width: 40ch; margin: 0 auto var(--s5); }

.qr { background: #fff; padding: var(--s4); border-radius: var(--r); border: 1px solid var(--line);
  width: fit-content; margin-inline: auto; }
.qr svg, .qr canvas { display: block; width: 200px; height: 200px; image-rendering: pixelated; }

/* skeleton */
.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 200% 100%; border-radius: var(--r); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-line { height: 12px; margin: 6px 0; }

.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  background: var(--warn-bg); color: var(--warn-strong);
  font-size: var(--fs-sm); font-weight: 500; padding: var(--s3);
  border-bottom: 1px solid var(--warn);
}
.offline-banner svg { width: 16px; height: 16px; }

.fab-space { height: 88px; }
.sticky-cta {
  position: sticky; bottom: 0; z-index: 20;
  margin: 0 calc(-1 * var(--s5)); padding: var(--s4) var(--s5) calc(var(--s4) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, transparent);
}

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