/* =====================================================================
   base.css — shared design system (SplitKar & Kagaz)
   Per DESIGN.md. This file is IDENTICAL across both apps EXCEPT the one
   clearly-marked "app tokens" block below (accent + app-specific semantics).
   Keep it that way so future diffs stay trivial.
   No external assets (G1): system font stack only, no @font-face, no url()
   to any remote host.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Design tokens — light (default) theme.
   Neutral scale: warm gray. Surfaces: bg / card / raised.
   --------------------------------------------------------------------- */
:root {
  /* Warm-gray neutral scale (light) */
  --gray-0:  #ffffff;
  --gray-50: #faf9f7;
  --gray-100:#f4f2ef;
  --gray-200:#e8e5e0;
  --gray-300:#d6d2ca;
  --gray-400:#b3ada2;
  --gray-500:#8a8478;
  --gray-600:#655f54;
  --gray-700:#494339;
  --gray-800:#2e2a23;
  --gray-900:#1a1712;

  /* Surfaces (light) */
  --bg:        var(--gray-50);
  --surface:   var(--gray-0);   /* card */
  --raised:    var(--gray-0);   /* raised over card (sheets/modals) */
  --overlay:   rgba(26, 23, 18, 0.44); /* backdrop scrim */

  /* Text (light) */
  --text:      var(--gray-900);
  --text-muted:var(--gray-600);
  --text-faint:var(--gray-500);
  --text-on-accent: #ffffff;

  /* Borders / dividers (light) */
  --border:      var(--gray-200);
  --border-strong:var(--gray-300);

  /* Semantic (shared across apps) */
  --success:   #16a34a;
  --success-bg:#dcfce7;
  --danger:    #dc2626;
  --danger-bg: #fee2e2;
  --warn:      #d97706;
  --warn-bg:   #fef3c7;
  /* AA text colors for use ON the matching soft -bg tint (the vivid semantic
     colors above fail 4.5:1 as small body text on their own light tints, so
     chips/reconcile/badges use these darker-in-light variants — theme-aware). */
  --on-success:#15803d;
  --on-danger: #b91c1c;
  --on-warn:   #92400e;
  /* Solid button fills that guarantee 4.5:1 white-on-fill (the accent/danger
     base tones read fine as text/rings but are a hair under AA behind white
     button labels). --accent-solid is per-app (app-tokens block); --danger-solid
     is a fixed strong red in both themes. */
  --danger-solid:#dc2626;

  /* ===== app tokens: SplitKar ===== */
  /* Accent: indigo -> violet (#6366f1 base). Swap ONLY this block per app. */
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-active: #4338ca;
  --accent-solid:  #5457e8;   /* solid-fill shade: white label hits 4.5:1 (base #6366f1 is 4.47) */
  --accent-soft:   #eef2ff;   /* tinted fill for chips/soft buttons (light) */
  --accent-soft-text:#4338ca;
  --accent-ring:   rgba(99, 102, 241, 0.45);
  --accent-grad:   linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --theme-color:   #6366f1;   /* PWA/status-bar hint */
  --toast-action:  #a5b4fc;   /* accent-tinted, legible on the fixed dark toast */
  /* App-specific money semantics: "owes" red-500 / "gets" green-600 */
  --owes:  #ef4444;
  --gets:  #16a34a;
  /* ===== end app tokens ===== */

  /* Type scale (px): 13 / 15 / 17 / 20 / 24 / 32 */
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-17: 1.0625rem;
  --fs-20: 1.25rem;
  --fs-24: 1.5rem;
  --fs-32: 2rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --lh-tight: 1.2;
  --lh: 1.5;

  /* Spacing — 4px base scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radii */
  --r-input: 10px;
  --r-card:  16px;
  --r-sheet: 24px;
  --r-pill:  999px;

  /* Shadows — soft, 2-level */
  --shadow-1: 0 1px 2px rgba(26,23,18,0.06), 0 2px 8px rgba(26,23,18,0.06);
  --shadow-2: 0 4px 12px rgba(26,23,18,0.10), 0 12px 32px rgba(26,23,18,0.12);

  /* Motion */
  --ease: cubic-bezier(.2,.8,.2,1);
  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 250ms;

  /* Layout */
  --content-max: 640px;
  --tap: 44px; /* min touch target */

  color-scheme: light;
}

/* ---------------------------------------------------------------------
   Dark theme — automatic via prefers-color-scheme, PLUS manual override
   through [data-theme] on <html>. Precedence:
     1) [data-theme="dark"]  -> always dark
     2) [data-theme="light"] -> always light (wins over the media query)
     3) no attribute         -> follow prefers-color-scheme
   Dark values are defined once (%dark-vars) and applied by all three hooks.
   --------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gray-0:  #17150f;
    --gray-50: #1c1a13;
    --gray-100:#232019;
    --gray-200:#2f2b22;
    --gray-300:#3d382d;
    --gray-400:#5a5344;
    --gray-500:#8a8272;
    --gray-600:#a8a090;
    --gray-700:#c7bfae;
    --gray-800:#e3ddce;
    --gray-900:#f5f1e8;

    --bg:        #141209;
    --surface:   #1e1b13;
    --raised:    #26221a;
    --overlay:   rgba(0, 0, 0, 0.60);

    --text:      var(--gray-900);
    --text-muted:var(--gray-600);
    --text-faint:var(--gray-500);

    --border:      #2f2b22;
    --border-strong:#3d382d;

    --success:   #4ade80;
    --success-bg:#14311f;
    --danger:    #f87171;
    --danger-bg: #3a1616;
    --warn:      #fbbf24;
    --warn-bg:   #3a2c0c;
    /* On-tint text: the -bg tints are DARK here, so the lighter semantic tones
       are the legible choice (all clear 4.5:1 on their dark tint). */
    --on-success:#4ade80;
    --on-danger: #f87171;
    --on-warn:   #fbbf24;

    /* Dark accent tints derived from --accent so this stays app-agnostic
       (the ONLY per-app values live in the app-tokens block). */
    --accent-soft:     color-mix(in srgb, var(--accent) 26%, #17150f);
    --accent-soft-text:color-mix(in srgb, var(--accent) 60%, #ffffff);

    --shadow-1: 0 1px 2px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.40);
    --shadow-2: 0 4px 12px rgba(0,0,0,0.50), 0 12px 32px rgba(0,0,0,0.55);

    color-scheme: dark;
  }
}

/* Manual override: dark — mirrors the media-query block above. */
:root[data-theme="dark"] {
  --gray-0:  #17150f;
  --gray-50: #1c1a13;
  --gray-100:#232019;
  --gray-200:#2f2b22;
  --gray-300:#3d382d;
  --gray-400:#5a5344;
  --gray-500:#8a8272;
  --gray-600:#a8a090;
  --gray-700:#c7bfae;
  --gray-800:#e3ddce;
  --gray-900:#f5f1e8;

  --bg:        #141209;
  --surface:   #1e1b13;
  --raised:    #26221a;
  --overlay:   rgba(0, 0, 0, 0.60);

  --text:      var(--gray-900);
  --text-muted:var(--gray-600);
  --text-faint:var(--gray-500);

  --border:      #2f2b22;
  --border-strong:#3d382d;

  --success:   #4ade80;
  --success-bg:#14311f;
  --danger:    #f87171;
  --danger-bg: #3a1616;
  --warn:      #fbbf24;
  --warn-bg:   #3a2c0c;
  /* On-tint text: the -bg tints are DARK here, so the lighter semantic tones
     are the legible choice (all clear 4.5:1 on their dark tint). */
  --on-success:#4ade80;
  --on-danger: #f87171;
  --on-warn:   #fbbf24;

  /* Dark accent tints derived from --accent so this stays app-agnostic
     (the ONLY per-app values live in the app-tokens block). */
  --accent-soft:     color-mix(in srgb, var(--accent) 26%, #17150f);
  --accent-soft-text:color-mix(in srgb, var(--accent) 60%, #ffffff);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.40);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.50), 0 12px 32px rgba(0,0,0,0.55);

  color-scheme: dark;
}

/* ---------------------------------------------------------------------
   Reset / base elements
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-15);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-ring); }

/* Utilities ----------------------------------------------------------- */
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
/* Money tone as TEXT (on card/bg surfaces): use the AA-safe on-tint tokens so
   17px/13px amounts clear 4.5:1. --owes/--gets stay the vivid brand tones for
   large/decorative use (e.g. avatars, fills). */
.text-owes { color: var(--on-danger, var(--owes)); }
.text-gets { color: var(--on-success, var(--gets)); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.spacer { flex: 1 1 auto; }

/* Type helpers */
.t-32 { font-size: var(--fs-32); line-height: var(--lh-tight); font-weight: 700; letter-spacing: -0.02em; }
.t-24 { font-size: var(--fs-24); line-height: var(--lh-tight); font-weight: 700; letter-spacing: -0.01em; }
.t-20 { font-size: var(--fs-20); line-height: var(--lh-tight); font-weight: 600; }
.t-17 { font-size: var(--fs-17); line-height: var(--lh); font-weight: 600; }
.t-15 { font-size: var(--fs-15); line-height: var(--lh); }
.t-13 { font-size: var(--fs-13); line-height: var(--lh); }

/* Focus ring — 2px accent, always visible (a11y) --------------------- */
:where(a, button, input, textarea, select, [tabindex], .list-row, .seg-tab):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-input);
}

/* ---------------------------------------------------------------------
   App shell / layout
   --------------------------------------------------------------------- */
.app {
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 56px;
  padding: var(--sp-2) var(--sp-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-size: var(--fs-20); font-weight: 700; letter-spacing: -0.01em; }
.content {
  flex: 1 1 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
}

/* ---------------------------------------------------------------------
   Buttons — primary / secondary / ghost / danger, sizes, loading
   --------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--accent);
  --btn-fg: var(--text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-input);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  position: relative;
  white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 36px; padding: 0 var(--sp-3); font-size: var(--fs-13); }
.btn--lg { min-height: 52px; padding: 0 var(--sp-6); font-size: var(--fs-17); }

.btn--primary { --btn-bg: var(--accent-solid, var(--accent)); --btn-fg: var(--text-on-accent); }
.btn--secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--accent);
}
.btn--ghost:hover { background: var(--accent-soft); }
.btn--danger { --btn-bg: var(--danger-solid, var(--danger)); --btn-fg: #ffffff; }

/* is-loading: hide label, show spinner. */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--btn-fg);
  opacity: 0.9;
}

/* ---------------------------------------------------------------------
   Inputs — labeled, error state, ₹-prefixed amount
   --------------------------------------------------------------------- */
.field { display: block; }
.field > .label {
  display: block;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}
.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-17);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-input);
  appearance: none;
}
.textarea { min-height: 88px; resize: vertical; line-height: var(--lh); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select { border-color: var(--danger); }
.field.has-error .input:focus,
.field.has-error .textarea:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.field > .error {
  display: none;
  margin-top: var(--sp-1);
  font-size: var(--fs-13);
  color: var(--danger);
}
.field.has-error > .error { display: block; }
.field > .hint {
  margin-top: var(--sp-1);
  font-size: var(--fs-13);
  color: var(--text-faint);
}

/* Amount input with ₹ prefix */
.input-amount {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-input);
  background: var(--surface);
  overflow: hidden;
}
.input-amount:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field.has-error .input-amount { border-color: var(--danger); }
.input-amount > .prefix {
  padding: 0 var(--sp-1) 0 var(--sp-3);
  font-size: var(--fs-20);
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.input-amount > input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-1);
  font-size: var(--fs-20);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.input-amount > input:focus { outline: none; }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
}
.card--flush { padding: 0; overflow: hidden; }
.card__header { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.card__title { font-size: var(--fs-17); font-weight: 600; }

/* ---------------------------------------------------------------------
   List rows — leading icon/avatar, title+meta, trailing slot
   --------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list--card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.list-row[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.list-row .lead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-input);
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: var(--fs-20);
}
.list-row .body { flex: 1 1 auto; min-width: 0; }
.list-row .row-title {
  font-size: var(--fs-15);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .row-meta {
  font-size: var(--fs-13);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .trail {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.list-row .chevron { color: var(--text-faint); font-size: var(--fs-20); }

/* ---------------------------------------------------------------------
   Segmented tabs
   --------------------------------------------------------------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--gray-100);
  border-radius: var(--r-input);
  border: 1px solid var(--border);
}
.seg-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  min-height: 36px;
  border-radius: 7px;
  cursor: pointer;
}
.seg-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* ---------------------------------------------------------------------
   Avatar chip — initial + stable color (hue set via inline --avatar-h)
   --------------------------------------------------------------------- */
.avatar {
  --avatar-h: 240;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--fs-15);
  color: hsl(var(--avatar-h) 65% 32%);
  background: hsl(var(--avatar-h) 70% 90%);
}
.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-13); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-20); }
:root[data-theme="dark"] .avatar,
.avatar {
  /* dark tuning applied via media + attr below */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar {
    color: hsl(var(--avatar-h) 70% 82%);
    background: hsl(var(--avatar-h) 40% 24%);
  }
}
:root[data-theme="dark"] .avatar {
  color: hsl(var(--avatar-h) 70% 82%);
  background: hsl(var(--avatar-h) 40% 24%);
}

/* ---------------------------------------------------------------------
   FAB — bottom-anchored primary action
   --------------------------------------------------------------------- */
.fab {
  position: fixed;
  z-index: 30;
  right: max(var(--sp-4), calc((100vw - var(--content-max)) / 2 + var(--sp-4)));
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-6);
  border: none;
  border-radius: var(--r-pill);
  background: var(--accent-solid, var(--accent));
  color: var(--text-on-accent);
  font-size: var(--fs-15);
  font-weight: 700;
  box-shadow: var(--shadow-2);
  cursor: pointer;
}
.fab .plus { font-size: var(--fs-24); line-height: 1; margin-top: -2px; }

/* ---------------------------------------------------------------------
   Empty state — SVG doodle slot + one-liner + CTA
   --------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-muted);
}
.empty .art { width: 96px; height: 96px; color: var(--accent); opacity: 0.9; }
.empty .empty-title { font-size: var(--fs-17); font-weight: 700; color: var(--text); }
.empty .empty-sub { font-size: var(--fs-15); max-width: 34ch; }

/* ---------------------------------------------------------------------
   Skeleton shimmer
   --------------------------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--gray-200);
  border-radius: var(--r-input);
}
.skeleton--text { height: 12px; margin: 6px 0; }
.skeleton--title { height: 18px; width: 60%; }
.skeleton--thumb { width: 100%; aspect-ratio: 3 / 4; border-radius: var(--r-input); }
.skeleton--circle { width: 40px; height: 40px; border-radius: 50%; }

/* ---------------------------------------------------------------------
   Overlays: backdrop, bottom sheet, modal, toast
   Base (static) styles here; transitions live in the motion guard below.
   --------------------------------------------------------------------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  z-index: 50;
  width: 100%;
  max-width: var(--content-max);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--raised);
  border-top-left-radius: var(--r-sheet);
  border-top-right-radius: var(--r-sheet);
  box-shadow: var(--shadow-2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet.is-open { transform: translateX(-50%) translateY(0); }
.sheet .drag-handle {
  align-self: center;
  width: 40px; height: 4px;
  margin: var(--sp-3) 0 var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--border-strong);
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}
.sheet .sheet-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-4) var(--sp-2);
}
.sheet .sheet-title { font-size: var(--fs-17); font-weight: 700; }
.sheet .sheet-body { padding: 0 var(--sp-4) var(--sp-4); overflow-y: auto; }

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  z-index: 50;
  width: calc(100% - var(--sp-8));
  max-width: 440px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--raised);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6);
  opacity: 0;
  pointer-events: none;
}
.modal.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.modal .modal-title { font-size: var(--fs-20); font-weight: 700; margin-bottom: var(--sp-2); }
.modal .modal-message { color: var(--text-muted); }
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
}

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: calc(100% - var(--sp-8));
  max-width: 420px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  /* Fixed dark surface in BOTH themes (a toast reads as an overlay, not a
     theme surface), so the action tint stays legible either way. */
  background: #232019;
  color: #faf9f7;
  border-radius: var(--r-input);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-15);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px);
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast .toast-msg { flex: 1 1 auto; }
.toast .toast-action {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--toast-action);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: 6px;
}

/* ---------------------------------------------------------------------
   Motion — ALL animation gated behind prefers-reduced-motion:no-preference
   (DESIGN.md detector: no animation without the media-query guard).
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color var(--dur-fast) var(--ease),
                     transform var(--dur-fast) var(--ease),
                     box-shadow var(--dur-fast) var(--ease); }
  .btn:hover:not(:disabled) { background: var(--accent-hover); }
  .btn--secondary:hover:not(:disabled) { background: var(--gray-100); }
  .btn--danger:hover:not(:disabled) { background: #b91c1c; }
  .btn:active:not(:disabled) { transform: scale(0.97); }
  .btn.is-loading::after { animation: spin 0.7s linear infinite; }

  .list-row { transition: background-color var(--dur-fast) var(--ease); }
  .seg-tab { transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
  .fab { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
  .fab:active { transform: scale(0.96); }

  .input, .textarea, .select, .input-amount {
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }

  .backdrop { transition: opacity var(--dur) var(--ease); }
  .sheet { transition: transform var(--dur-slow) var(--ease); }
  .modal { transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); }
  .toast { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }

  .skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
      transparent,
      color-mix(in srgb, var(--gray-0) 55%, transparent),
      transparent);
    animation: shimmer 1.4s ease-in-out infinite;
  }

  .list-row.enter { animation: fade-in var(--dur) var(--ease) both; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
