/* ================================================================
   LEDGER — Midnight. Flat, minimal, fast.
   No blur, no gradients, no shadows. Hairlines and type do the work.
   ================================================================ */

:root {
  --r-xl: 16px;
  --r-lg: 12px;
  --r-md: 10px;
  --r-pill: 999px;

  --pad-card: 16px;

  /* surfaces */
  --bg: #000000;
  --surface: #0d0d0f;          /* cards, dock, sheets */
  --surface-2: #16161a;        /* inputs, nested elements */
  --press: #1d1d22;            /* active states */
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #f5f5f7;
  --text-dim: rgba(235, 235, 245, 0.60);
  --text-faint: rgba(235, 235, 245, 0.30);

  /* Apple dark palette */
  --accent: #0a84ff;
  --good: #30d158;
  --bad: #ff453a;
  --warn: #ffd60a;

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --dock-h: 98px;
  --bar-h: 64px;
  --sidebar-w: 240px;
  color-scheme: dark;

  /* floating chrome + overlays (light values below) */
  --chrome-solid: rgba(0, 0, 0, 0.92);   /* dock/sidebar without backdrop-filter */
  --chrome-glass: rgba(0, 0, 0, 0.2);    /* dock/sidebar over a blurred backdrop */
  --sheet-solid: rgba(0, 0, 0, 0.85);
  --sheet-glass: rgba(0, 0, 0, 0.1);
  --chrome-shadow: rgba(0, 0, 0, 0.35);
  --sheet-shadow: rgba(0, 0, 0, 0.4);
  --on-inverse: #000;                    /* text on a --text-colored fill */
  --gauge-track: rgba(255, 255, 255, 0.2);
  --tooltip-bg: rgba(18, 22, 36, 0.92);
  --tooltip-border: rgba(255, 255, 255, 0.14);
  --select-bg: #16161a;
  --field-glass: rgba(0, 0, 0, 0.38);    /* form fields on a glass sheet */

  /* legacy aliases still referenced by JS chart theming */
  --glass: var(--surface);
  --glass-strong: var(--surface-2);
  --glass-press: var(--press);
  --stroke: var(--hairline);
  --highlight: transparent;
}

/* Light mode, following the system setting. Apple's light palette on
   grouped grey: white cards lift off the page the way #0d0d0f cards lift
   off black at night. Same token names, so every rule above just works;
   the only extra work is the floating chrome, which becomes white glass
   instead of black glass. */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #eeeef3;
    --press: #e5e5ea;
    --hairline: rgba(0, 0, 0, 0.08);

    --text: #1d1d1f;
    --text-dim: rgba(60, 60, 67, 0.62);
    --text-faint: rgba(60, 60, 67, 0.32);

    --accent: #007aff;
    --good: #34c759;
    --bad: #ff3b30;
    --warn: #d99a00;

    --chrome-solid: rgba(255, 255, 255, 0.94);
    --chrome-glass: rgba(255, 255, 255, 0.6);
    --sheet-solid: rgba(255, 255, 255, 0.92);
    --sheet-glass: rgba(255, 255, 255, 0.55);
    --chrome-shadow: rgba(0, 0, 0, 0.12);
    --sheet-shadow: rgba(0, 0, 0, 0.14);
    --on-inverse: #fff;
    --gauge-track: rgba(0, 0, 0, 0.12);
    --tooltip-bg: rgba(255, 255, 255, 0.96);
    --tooltip-border: rgba(0, 0, 0, 0.1);
    --select-bg: #ffffff;
    --field-glass: rgba(0, 0, 0, 0.045);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
}

/* set on <body> while a sheet (openModal) is open, so the page behind the
   backdrop can't be scrolled — the sheet itself still scrolls internally.
   `position: fixed` (with `top` pinned in JS to the negative scroll offset)
   is the part that matters on iOS: without it, focusing an input inside the
   fixed sheet makes Safari auto-scroll the page to "reveal" it, which just
   shoves the sheet — and whatever's near its top, like Amount — off-screen,
   since the sheet doesn't actually move with that scroll. */
body.modal-open { overflow: hidden; position: fixed; left: 0; right: 0; width: 100%; }

/* the old .glass hook now just means "a surface" */
.glass {
  background: var(--surface);
}

/* ---------- layout ---------- */
#app {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px
           calc(var(--dock-h) + env(safe-area-inset-bottom)) 16px;
}

.view { animation: view-in 0.18s var(--ease); }
.view.leaving { animation: view-out 0.1s var(--ease) forwards; }
@keyframes view-in  { from { opacity: 0; } }
@keyframes view-out { to   { opacity: 0; } }

h1.screen-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  margin: 10px 4px 16px;
}

/* ---------- cards ---------- */
.card {
  border-radius: var(--r-xl);
  padding: var(--pad-card);
  margin-bottom: 12px;
}
.card .inner-radius { border-radius: calc(var(--r-xl) - 6px); }

.card-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px;
}

.grid { display: grid; gap: 12px; }
@media (min-width: 760px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid .card { margin-bottom: 0; }
  .grid { margin-bottom: 12px; }
}

/* a row of cards too narrow to sit side by side (e.g. paired category
   donuts) — swipe horizontally instead of stacking them vertically. */
.hscroll {
  display: flex; gap: 12px; overflow-x: auto;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > .card { flex: 0 0 86%; scroll-snap-align: start; margin-bottom: 0; }
@media (min-width: 420px) { .hscroll > .card { flex-basis: 320px; } }

/* ---------- money type ---------- */
.money, .amount, .big-number, .shelf-amount, .run-bal {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.big-number {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05;
}
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---------- dock: shelf + tab bar ---------- */
#dock {
  position: fixed; left: 0; right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px;
  z-index: 50; pointer-events: none;
  padding: 0 10px;
  /* iOS Safari can visually "detach" position:fixed elements mid-scroll,
     especially ones with backdrop-filter descendants — promoting the dock
     to its own GPU compositing layer keeps it pinned during the scroll. */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}
#dock > * { pointer-events: auto; }

/* ---------- glassmorphism: dock, sidebar, modal sheet ----------
   Translucent surface + backdrop blur — scoped to just the floating nav
   chrome and the modal, not cards, per the original design brief (blanket
   blur-everything was the actual source of the old Apps Script jank).
   Always both prefixes: Safari doesn't recognize the unprefixed property
   on every version still in use, only -webkit-backdrop-filter is safe
   everywhere. @supports gates it so unsupported browsers still get a
   reasonable (slightly more opaque, no blur) fallback instead of nothing.

   Nav chrome (dock + sidebar) and the modal sheet are both true black,
   fairly transparent (~80%) with blur doing the work of keeping content
   legible underneath. The non-backdrop-filter fallback stays more opaque
   on purpose — there's no blur to soften raw unblurred content behind it. */
.tabbar, #sidebar { background: var(--chrome-solid); }
.sheet { background: var(--sheet-solid); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabbar, #sidebar {
    background: var(--chrome-glass);
    -webkit-backdrop-filter: blur(8px) saturate(1.3);
    backdrop-filter: blur(8px) saturate(1.3);
  }
  .sheet {
    background: var(--sheet-glass);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    backdrop-filter: blur(20px) saturate(1.6);
  }
}
.shelf-fab, .tabbar { box-shadow: 0 8px 24px var(--chrome-shadow); }
/* The desktop sidebar is a full-height pane of glass on the window's edge, made the same as the
   Dashboard's cards (the Net worth card): the page surface at 60% over a
   10px blur with the same saturation lift, and the same hairline rim. Page
   content (the Net worth graph, the Budget ring) runs underneath it. */
#sidebar {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  box-shadow: inset -1px 0 0 var(--hairline);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  #sidebar {
    -webkit-backdrop-filter: blur(10px) saturate(1.7);
    backdrop-filter: blur(10px) saturate(1.7);
  }
}
.sheet { box-shadow: 0 -8px 32px var(--sheet-shadow); }

.tabbar { border: 1px solid var(--hairline); }

/* quick-add FAB — sits as its own floating circle beside the tab-bar pill,
   the same "detached control" pattern iOS 26 uses to split Apple Music's
   search field off from its tab bar: two separate glass capsules in one
   row instead of one wide bar. Tinted blue (not black-glass like the tab
   bar) so it reads as the primary action, matching iOS's filled-tint
   button treatment. */
.shelf-fab {
  display: grid; place-items: center;
  /* fixed to the same --bar-h as .tabbar (below) rather than derived via
     align-items:stretch + aspect-ratio — that combination turned out not
     to reliably resolve to a square in practice (a flex item's main-axis
     size wins over the ratio here), leaving the button visibly oval.
     Both being set from the one shared variable keeps them in lockstep
     without that fragility. */
  width: var(--bar-h); height: var(--bar-h);
  border-radius: var(--r-pill); flex-shrink: 0;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff; font: inherit; cursor: pointer;
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.35);
  transition: opacity 0.15s var(--ease);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .shelf-fab {
    background: rgba(10, 132, 255, 0.82);
    -webkit-backdrop-filter: blur(8px) saturate(1.3);
    backdrop-filter: blur(8px) saturate(1.3);
  }
}
.shelf-fab:active { opacity: 0.7; }
.shelf-label { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.shelf-amount { font-size: 15px; font-weight: 600; margin-left: auto; }
.shelf-amount.pos { color: var(--good); }
.shelf-amount.neg { color: var(--bad); }

.tabbar {
  display: flex; align-items: center; gap: 2px;
  height: var(--bar-h);
  /* fills the row alongside the fixed-size "+" FAB instead of shrinking
     to fit its own content, so the whole bar spans the screen (minus
     #dock's small side buffer) the way a native iOS tab bar does. */
  flex: 1;
  border-radius: var(--r-pill);
  /* 8.5px matches the active pill's own top/bottom gap to the bar edge
     (bar-h 64px minus the pill's 47px height, halved — see .tab-pill
     below) so the bar's own edge padding reads the same on every side. */
  padding: 0 8.5px;
}
/* icon-only, permanently — no label text, so the bar (and the "+" FAB,
   both fixed to the same --bar-h, see above) stay compact and circular
   without a separate scroll-triggered "compact" state to toggle between. */
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center;
  color: var(--text-faint);
  height: 100%; flex: 1;
  font: inherit;
  transition: color 0.15s var(--ease);
}
/* the active-state highlight lives on this inner pill, not .tab itself —
   .tab is the full-height, full-width (flex:1) tap target, which would
   make a background painted directly on it a tall rectangle spanning the
   whole cell; sized wider than tall on purpose (20px horizontal vs 10px
   vertical padding around the 27px icon — 67x47px) to read as a rounded
   capsule rather than a tight circle, and just centers inside .tab via
   place-items. */
.tab-pill { display: grid; place-items: center; padding: 10px 20px; border-radius: var(--r-pill); transition: background 0.15s var(--ease); }
.tab svg { width: 27px; height: 27px; }
.tab:active { opacity: 0.7; }
.tab.active { color: var(--text); }
.tab.active .tab-pill { background: var(--surface-2); }
.tab.active svg { color: var(--accent); }

/* The dock must never be wider than the screen. A <button> keeps its default
   side padding and a flex item won't shrink below its content width, so on
   a 390pt phone (iPhone 13/14/15/16, 17) the four 79px cells added up to a
   341px bar in a 296px slot — it spilled off the left edge and shoved the
   "+" off the right. Zero the buttons' own padding and let both the bar and
   its cells shrink (min-width: 0) so flex fits them beside the "+". The
   active capsule is then narrowed (67 -> 55px) to stay inside its cell,
   which is ~68px wide at 390pt and ~64px at 375pt. */
@media (max-width: 480px) {
  .tabbar { min-width: 0; }
  .tab { min-width: 0; padding: 0; }
  .tab-pill { padding: 10px 14px; }
}
/* 320-360pt-class phones (SE, mini) leave ~48-58px per cell. */
@media (max-width: 360px) { .tab-pill { padding: 10px 8px; } }

/* ---------- sidebar (desktop nav) ----------
   Replaces the dock above the desktop breakpoint; below it, #sidebar stays
   hidden and the dock is untouched. Nav buttons reuse .tab (same class the
   dock uses), so click handling and active-state sync in app.js work for
   both without any JS changes — see setView(). */
#sidebar { display: none; }
#sidebar-edit { display: none; }

@media (min-width: 900px) {
  /* the tab bar gives way to the sidebar; the + stays, bottom right */
  #tabbar { display: none; }
  #dock { left: auto; right: max(28px, calc(env(safe-area-inset-right) + 16px)); padding: 0; }

  #app {
    margin: 0 auto 0 calc(var(--sidebar-w) + env(safe-area-inset-left));
    max-width: 1200px;
    padding: 28px 32px 32px;
  }

  #sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    /* flush to the window's edge and full height, past the notch if there is one */
    width: calc(var(--sidebar-w) + env(safe-area-inset-left));
    padding: max(20px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
    border-radius: 0;
    z-index: 40;
  }

  .sidebar-brand { display: flex; align-items: center; gap: 6px; padding: 6px 10px 22px; }
  .sidebar-mark { width: 34px; height: 34px; border-radius: var(--r-md); font-size: 16px; background: none; }
  .sidebar-wordmark {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  }

  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar-nav .tab {
    /* explicitly opt out of the mobile dock's .tab { flex: 1 } — the
       sidebar's own vertical list of nav buttons should keep its normal
       content-driven height regardless of what the dock's bar does. */
    display: flex; flex-direction: row; justify-content: flex-start;
    flex: none; height: auto;
    gap: 12px; width: 100%;
    padding: 10px 12px;
    border-radius: var(--r-md);
    font-size: 14px;
  }
  .sidebar-nav .tab svg { width: 20px; height: 20px; }
  /* sidebar rows highlight themselves directly (full-width row background,
     not the mobile dock's small centered pill) — restated explicitly here
     since .tab.active no longer paints a background on .tab itself. */
  .sidebar-nav .tab.active { background: color-mix(in srgb, var(--text) 11%, transparent); }

  .sidebar-version { font-size: 11.5px; color: var(--text-faint); padding: 0 10px 8px; }
  .dash-version { display: none; }

  /* compact transaction edit panel, docked above the version number */
  #sidebar-edit.active {
    display: block; margin-bottom: 10px;
    max-height: 60vh; overflow-y: auto;
  }
  #sidebar-edit .sheet {
    position: relative;
    padding: 14px 12px; border-radius: var(--r-lg);
    animation: none;
  }
  #sidebar-edit .sheet h2 { font-size: 14px; margin: 0 26px 10px 0; }
  #sidebar-edit .sheet .field { margin-bottom: 8px; }
  #sidebar-edit .sheet .field span { font-size: 10.5px; }
  #sidebar-edit .sheet .field-2col { grid-template-columns: 1fr; gap: 0; }
  #sidebar-edit .sheet input, #sidebar-edit .sheet select { font-size: 13px; padding: 8px 10px; }
  #sidebar-edit .sheet .amount-input { font-size: 20px; padding: 10px; }
  #sidebar-edit .sheet .segment { margin-bottom: 8px; }
  #sidebar-edit .sheet .segment button { padding: 6px 4px; font-size: 11px; }
  #sidebar-edit .sheet .toggle-row { padding: 3px 0 8px; font-size: 13px; }
  #sidebar-edit .sheet .switch { width: 38px; height: 22px; }
  #sidebar-edit .sheet .switch .knob::after { width: 16px; height: 16px; }
  #sidebar-edit .sheet .switch input:checked + .knob::after { transform: translateX(16px); }
  #sidebar-edit .sheet .actions { flex-direction: column; gap: 6px; margin-top: 4px; }
  #sidebar-edit .sheet .actions .btn { width: 100%; }
  .sidebar-edit-close {
    position: absolute; top: 10px; right: 10px;
    width: 24px; height: 24px;
  }

}

/* ---------- buttons, chips, inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--hairline); cursor: pointer;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 18px;
  transition: background 0.15s var(--ease), opacity 0.15s var(--ease);
}
.btn:active { background: var(--press); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:active { opacity: 0.8; }
.btn.danger { color: var(--bad); }
.btn.small { font-size: 13px; padding: 6px 13px; }
.btn.block { width: 100%; }
/* Save button while a request is in flight (transaction sheet): spinner +
   "Saving…", no further clicks on any of the sheet's action buttons. */
.btn.saving { opacity: 0.85; cursor: default; }
.sheet.is-saving .actions .btn { pointer-events: none; }
.sheet.is-saving .actions .btn:not(.saving) { opacity: 0.5; }
.spinner {
  display: inline-block; width: 0.9em; height: 0.9em; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.12em;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; appearance: none; cursor: pointer;
  border-radius: var(--r-pill); border: 1px solid var(--hairline);
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.chip:active { background: var(--press); }
.chip.active { background: var(--text); border-color: transparent; color: var(--on-inverse); }


label.field, div.field { display: block; margin-bottom: 12px; }
label.field > span, div.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 0 4px 6px; }

/* custom category picker (transaction modal) — a styled trigger button
   standing in for the real (hidden) <select id="f-cat">, which stays the
   source of truth for every existing bit of wiring (payee autofill, the
   __new__ sentinel, the save-time read) so none of that had to change. */
.cat-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 16px; color: var(--text); text-align: left;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 10px 14px; cursor: pointer;
}
.cat-btn:focus { border-color: var(--accent); }
.cat-btn-icon { display: grid; place-items: center; width: 20px; height: 20px; flex: none; color: var(--text-dim); }
.cat-btn-icon svg { display: block; }
.cat-btn-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-btn-chev { color: var(--text-faint); flex: none; transition: transform 0.15s var(--ease); }
.cat-btn[aria-expanded="true"] .cat-btn-chev { transform: rotate(180deg); }
.cat-options {
  margin-top: 6px; max-height: 240px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--r-md);
}
.cat-search-wrap {
  position: sticky; top: 0; z-index: 1; padding: 8px;
  background: var(--surface-2); border-bottom: 1px solid var(--hairline);
}
.cat-search {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg, transparent); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 8px 12px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.cat-search:focus { border-color: var(--accent); }
.cat-empty { padding: 12px; font-size: 14px; color: var(--text-faint); text-align: center; }
.cat-option-group { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); padding: 8px 12px 4px; }
.cat-option {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 14px; color: var(--text); text-align: left;
  background: transparent; border: 0; padding: 9px 12px; cursor: pointer;
}
.cat-option-icon { display: grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--text-dim); }
.cat-option.active { background: rgba(10, 132, 255, 0.14); color: var(--accent); }
.cat-option.active .cat-option-icon { color: var(--accent); }

/* transaction modal's account picker — card art you swipe through one at a
   time (scroll-snap, side padding lets the first/last card reach center
   too), name labeled above each card per its own peek. */
.acct-picker-track {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 2px 19% 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  /* cancels out .sheet's own 20px side padding so peeking neighbor cards
     reach the modal's true edge instead of stopping short of it. */
  margin: 0 -20px;
}
.acct-picker-track::-webkit-scrollbar { display: none; }
/* min-width:0 overrides a flex item's default min-width:auto, which
   otherwise won't let it shrink below its content's min-content size —
   flex-shrink is 0 here (the basis is a deliberate fixed size, not a
   suggestion), so without this a long account name (e.g. "AMEX (Grocery,
   Amazon)") forces that one card wider than same-sized siblings instead of
   actually eliding via acct-picker-name's own text-overflow:ellipsis. */
.acct-picker-item {
  flex: 0 0 62%; min-width: 0; scroll-snap-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  opacity: 0.45; transform: scale(0.94); transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.acct-picker-item.active { opacity: 1; transform: scale(1); }
.acct-picker-name {
  align-self: stretch; text-align: left;
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acct-picker-media {
  width: 100%; aspect-ratio: 1.586 / 1; border-radius: var(--r-lg); overflow: hidden;
  background: linear-gradient(135deg in oklch, var(--surface), var(--surface-2));
  display: flex; align-items: center; justify-content: center; color: var(--text-faint);
  box-shadow: 0 0 0 1.5px transparent; transition: box-shadow 0.2s var(--ease);
}
.acct-picker-item.active .acct-picker-media { box-shadow: 0 0 0 2px var(--accent); }
.acct-picker-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acct-picker-media .acct-card-fallback { background: none; }
.acct-picker-media .acct-card-fallback svg { width: 30px; height: 30px; }

/* Register's account filter reuses the .acct-picker-* carousel above —
   full-width-ish cards on mobile since this is the page's main filter, not
   a form field, settling down to a smaller peek-a-boo carousel at
   tablet/desktop widths where a near-full-width card would be excessive.
   margin:-16px cancels out #app's own side padding so peripheral cards'
   peeking edges reach the true screen edge instead of stopping short of it. */
.reg-acct-picker { margin: 0 -16px; padding: 2px 8% 10px; }
/* Every card is full-size by default. Only while "All accounts" is the
   selection (the track carries .compact — see acctChipsHtml) do cards sit
   small instead; picking any real account drops .compact and every card
   expands and stays that way, even while swiping between other real
   accounts afterward (flex-basis is what actually resizes each card;
   transitioning it animates the swap). */
.reg-acct-picker .acct-picker-item {
  flex-basis: 84%;
  transition: flex-basis 0.35s var(--ease), opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.reg-acct-picker.compact .acct-picker-item { flex-basis: 30%; }
/* the "All accounts" card has no real card art to show, so at any size
   it's just its own label — no icon. */
.acct-picker-all {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-dim);
  background: linear-gradient(135deg in oklch, var(--surface), var(--surface-2));
}
.reg-acct-picker .acct-picker-item.active .acct-picker-all { color: var(--text); }
@media (min-width: 600px) {
  .reg-acct-picker { margin: 0; padding: 2px 24% 10px; }
  .reg-acct-picker .acct-picker-item { flex-basis: 52%; }
  .reg-acct-picker.compact .acct-picker-item { flex-basis: 18%; }
}

input, select, textarea {
  width: 100%; appearance: none;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
select option { background: var(--select-bg); color: var(--text); }
input[type="checkbox"] { width: auto; }
input[type="color"] { width: 64px; height: 44px; padding: 4px; cursor: pointer; }

.amount-input {
  font-family: -apple-system, "SF Pro Display", sans-serif;
  font-size: 38px !important; font-weight: 700; letter-spacing: -0.02em;
  text-align: center; border-radius: var(--r-lg);
  font-variant-numeric: tabular-nums;
}

/* segmented control */
.segment { display: flex; padding: 3px; gap: 3px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--hairline); margin-bottom: 14px; }
.segment button {
  flex: 1; appearance: none; border: 0; cursor: pointer;
  border-radius: calc(var(--r-md) - 3px); background: transparent; color: var(--text-dim);
  font: inherit; font-size: 14px; font-weight: 600; padding: 8px 0;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.segment button.active.expense { background: var(--bad); color: #fff; }
.segment button.active.income  { background: var(--good); color: #04130a; }
.segment button.active.transfer { background: var(--accent); color: #fff; }

/* toggle row */
.toggle-row { display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 14px; font-size: 15px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch .knob { position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--hairline); transition: background 0.15s var(--ease);
  /* the knob paints on top of the checkbox (later in DOM order, same
     stacking area) and would otherwise swallow every click before it
     reaches the actual input — pass clicks through to it. */
  pointer-events: none; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch input:checked + .knob { background: var(--good); border-color: transparent; }
.switch input:checked + .knob::after { transform: translateX(20px); }

/* ---------- rows & lists ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; cursor: pointer;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--press); }
.row.editing { background: rgba(10, 132, 255, 0.14); border-radius: var(--r-md); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amount { font-size: 15px; font-weight: 600; }
.row .run-bal { font-size: 11.5px; color: var(--text-faint); text-align: right; }
.row[draggable="true"] { cursor: grab; }
.row.dragging { opacity: 0.4; }
.row.drop-target, .date-header.drop-target {
  outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: var(--r-md);
}

.date-header { font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint); margin: 18px 6px 4px; }

/* register row's category icon — no separate status dot anymore, since the
   icon itself is already tinted by that same status (see txStatusColor);
   no background box either, so the icon can run bigger without looking
   like it's crammed into a tile. Compound selector (not a plain .tx-icon)
   so its specificity beats the base .icon-bubble rule regardless of which
   one comes first in the file. */
.icon-bubble.tx-icon { flex: none; width: 40px; height: 40px; font-size: 18px; background: transparent; }

.icon-bubble {
  width: 38px; height: 38px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center; font-size: 16px; font-weight: 600;
  background: var(--surface-2);
}

.icon-btn {
  appearance: none; border: none; background: transparent; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--press); color: var(--text); }
.icon-btn.accent, .icon-btn.accent:hover, .icon-btn.accent:active { color: var(--accent); }

/* progress bars */
.bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill);
  background: var(--accent); transition: width 0.3s var(--ease); }
.bar > i.good { background: var(--good); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.flag { display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--bad);
  padding: 3px 0; }
.flag.ok { color: var(--good); }
.flag.muted { color: var(--text-faint); }

/* budget rows */
.brow { padding: 11px 4px; border-bottom: 1px solid var(--hairline); }
.brow:last-child { border-bottom: 0; }
.brow .line1 { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.brow .name { font-size: 15px; font-weight: 500; flex: 1; }
.brow .nums { font-size: 13px; color: var(--text-dim); }
.brow .nums b { color: var(--text); font-weight: 600; }
/* ---------- budget page ----------
   Title row with a settings (sliders) button, a month switcher, a hero
   ring for how much of the month's income has a job, then one card per
   category, grouped. Cards tap to see transactions and press-and-hold to
   edit the plan (wireBudgetCardPress in app.js). A little colour does the
   cheering here: each card glows in its own state (green on track, yellow
   close, red over). */
.card-title svg { vertical-align: -2px; margin-right: 6px; }

.bud-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bud-top .screen-title { margin-right: 0; }
.bud-top-actions { display: flex; align-items: center; gap: 8px; }
.bud-top-actions .bud-gear { margin: 4px 0 6px; }
.bud-gear { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--hairline); color: var(--text); margin: 4px 4px 6px 0; }
.bud-gear[aria-expanded="true"] { background: var(--text); color: var(--on-inverse); }

.bud-month { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 0 12px; }
.bud-month .icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--text); background: var(--surface-2); border: 1px solid var(--hairline); padding-bottom: 3px; }
.bud-month-label {
  appearance: none; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer;
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r-pill);
}
.bud-month-label:disabled { cursor: default; }
.bud-month-label span {
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 3px 8px; border-radius: var(--r-pill);
}

/* The hero card is see-through glass. Behind it (.bud-under) a big copy
   of its ring is its own layer, centred just past the card's right edge so
   it shows both around the card (crisp) and through it (softened by the
   glass). It fills with the share of income assigned, starts at 3 o'clock
   so its gap falls off-screen, and trails the scroll (nwParallax). */
.bud-hero-wrap, .bud-hero { --tone: var(--accent); }
.bud-hero-wrap.is-zero,  .bud-hero.is-zero  { --tone: var(--good); }
.bud-hero-wrap.is-over,  .bud-hero.is-over  { --tone: var(--bad); }
.bud-hero-wrap.is-empty, .bud-hero.is-empty { --tone: var(--text-faint); }
.bud-hero-wrap { --app-side: 16px; position: relative; isolation: isolate; margin-bottom: 12px; }
@media (min-width: 900px) { .bud-hero-wrap { --app-side: 32px; } }
.bud-top, .bud-month { position: relative; z-index: 1; }   /* above the ring layer */
.bud-hero { position: relative; margin: 0; background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--hairline); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .bud-hero { background: color-mix(in srgb, var(--surface) 52%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(1.7); backdrop-filter: blur(10px) saturate(1.7); }
}
.bud-under-clip { position: absolute; z-index: -1; top: -130px; bottom: 0; pointer-events: none; overflow: hidden;
  left: calc(-1 * var(--bleed-l, var(--app-side))); right: calc(-1 * var(--bleed-r, var(--app-side))); }
.bud-under { position: absolute; top: 70px; right: calc(var(--bleed-r, var(--app-side)) - 130px); width: 240px; height: 240px; will-change: transform; }
.bud-under svg { width: 100%; height: 100%; display: block; }
.bud-under-track { fill: none; stroke: color-mix(in srgb, var(--tone) 16%, transparent); stroke-width: 11; }
.bud-under-fill { fill: none; stroke: var(--tone); opacity: 0.85; stroke-width: 11; stroke-linecap: round;
  animation: bud-ring-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) backwards 0.1s; }
.bud-hero-main { display: flex; align-items: center; gap: 16px; }
.bud-hero-text { min-width: 0; flex: 1; }
.bud-hero .card-title { margin-bottom: 4px; }
.bud-hero .big-number { font-size: 36px; color: var(--tone); }
.bud-hero.is-left .big-number, .bud-hero.is-empty .big-number { color: var(--text); }
.bud-hero-msg { margin: 6px 0 0; font-size: 13.5px; line-height: 1.35; color: var(--text-dim); }
.bud-ring { position: relative; width: 104px; height: 104px; flex: none; }
.bud-ring svg { transform: rotate(-90deg); display: block; }
.bud-ring-track { fill: none; stroke: var(--gauge-track); stroke-width: 9; opacity: 0.6; }
.bud-ring-fill { fill: none; stroke: var(--tone); stroke-width: 9; stroke-linecap: round;
  animation: bud-ring-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) backwards 0.05s; }
@keyframes bud-ring-in { from { stroke-dashoffset: var(--ring-c); } }
.bud-ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.bud-ring-label b { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.bud-ring-label b i { font-style: normal; font-size: 14px; margin-left: 1px; color: var(--text-dim); }
.bud-ring-label span { font-size: 10.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }
.bud-check { font-size: 38px !important; color: var(--good); animation: bud-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) backwards 0.5s; }
@keyframes bud-pop { from { transform: scale(0.2); opacity: 0; } }
.bud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.bud-stats > div { background: color-mix(in srgb, var(--surface-2) 80%, transparent); border-radius: var(--r-lg); padding: 9px 11px; min-width: 0; }
.bud-stats span { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.bud-stats b { display: inline-block; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; }
.bud-stats em { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: var(--text-faint); margin-top: 1px; }
@media (max-width: 360px) { .bud-ring { width: 84px; height: 84px; } .bud-ring svg { width: 84px; height: 84px; } .bud-hero .big-number { font-size: 30px; } }

.budget-group { margin: 18px 2px 4px; }
.bgroup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 8px; }
.bgroup-head .card-title { margin: 0; }
.bgroup-sum { font-size: 12px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.bgroup-sum span { color: var(--text-faint); font-weight: 500; }
.budget-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .budget-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .budget-grid { grid-template-columns: repeat(4, 1fr); } }

.budget-card {
  --tone: var(--good);
  --tint: 9%;               /* how strongly the state colours the card */
  position: relative; min-width: 0;
  background: color-mix(in srgb, var(--tone) var(--tint), var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone) calc(var(--tint) * 2.2), var(--hairline));
  border-radius: var(--r-xl); padding: 12px 12px 13px; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  transition: transform 0.18s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
  animation: bcard-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(min(var(--i, 0), 18) * 22ms);
}
.budget-card.tone-warn { --tone: var(--warn); }
.budget-card.tone-bad  { --tone: var(--bad); }
.budget-card.tone-idle { --tone: var(--text-faint); --tint: 0%; }
@media (prefers-color-scheme: light) { .budget-card:not(.tone-idle) { --tint: 15%; } }
.budget-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes bcard-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
/* press-and-hold: the card sinks for the whole hold, so you can feel it
   arming, then springs back as the editor opens. */
.budget-card.holding { transform: scale(0.94); transition: transform 0.45s cubic-bezier(0.3, 0, 0.6, 1); border-color: color-mix(in srgb, var(--tone) 60%, transparent); }
.budget-card.held { transform: scale(1.03); transition: transform 0.16s cubic-bezier(0.3, 1.6, 0.5, 1); }
.bcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.bcard-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-pill);
  color: var(--text-dim); background: var(--surface-2);
}
.bcard-badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.bcard-badge.good { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); font-size: 12px; padding: 2px 8px; }
.bcard-gauge { position: relative; width: 44px; height: 44px; flex: none; }
/* direct-child combinator, not descendant — the category's own icon is
   also an <svg>, nested one level deeper inside .bcard-glyph, and a plain
   descendant selector here was rotating that icon along with the ring. */
.bcard-gauge > svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--gauge-track); stroke-width: 3.5; opacity: 0.55; }
.gauge-fill { fill: none; stroke-width: 3.5; stroke-linecap: round; transition: stroke-dashoffset 0.3s var(--ease);
  animation: gauge-in 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards 0.12s; }
@keyframes gauge-in { from { stroke-dashoffset: 100.53; } }  /* 2πr, r = 16 */
.bcard-glyph { position: absolute; inset: 0; display: grid; place-items: center; }
.gauge-dot { width: 11px; height: 11px; border-radius: 50%; display: block; }
.bcard-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-top: 10px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcard-left { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcard-left span { font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--text-faint); }
.budget-card.is-over .bcard-left { color: var(--bad); }
.bcard-nums { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.bud-hint { text-align: center; font-size: 12.5px; color: var(--text-faint); margin: 14px 0 4px; }
.bud-setup { margin-top: 2px; }

/* Settings menu dropped from the sliders button. */
.bud-menu-backdrop { position: fixed; inset: 0; z-index: 120; }
.bud-menu {
  position: fixed; min-width: 260px; max-width: calc(100vw - 20px);
  padding: 6px; border-radius: var(--r-xl);
  background: var(--sheet-solid); border: 1px solid var(--hairline);
  box-shadow: 0 16px 40px var(--sheet-shadow);
  transform-origin: top right;
  animation: bud-menu-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .bud-menu { background: color-mix(in srgb, var(--surface) 70%, transparent);
    -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); }
}
@keyframes bud-menu-in { from { opacity: 0; transform: scale(0.9) translateY(-6px); } }
.bud-menu button {
  appearance: none; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--r-lg);
}
.bud-menu button:active, .bud-menu button:focus-visible { background: var(--press); outline: none; }
.bud-menu svg { flex: none; color: var(--accent); }
.bud-menu .menu-check { margin-left: auto; color: var(--accent); }
.bud-menu b { display: block; font-size: 15px; font-weight: 600; }
.bud-menu small { display: block; font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.goal-bar { height: 8px; }

/* Confetti for landing Left to budget on exactly $0.00. */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px;
  animation: confetti-fall 1.4s cubic-bezier(0.25, 0.4, 0.5, 1) forwards; }
.confetti i:nth-child(3n) { width: 10px; height: 10px; border-radius: 50%; }
@keyframes confetti-fall {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translate(var(--dx), 70vh) rotate(var(--rot)); opacity: 0; }
}

/* ---------- accounts page: card layout ----------
   Each account is a real credit-card-shaped face (name/edit above it,
   balance + usage gauge overlaid on it) — 2-up even on the smallest
   phones, growing with viewport width. */
/* plain section (no card background/padding) so the grid gets the full
   page width to work with — slightly bigger cards than a .card wrapper
   would allow. */
/* Dashboard net worth hero. The graph sits behind the card, level with the
   number, and runs past the card to the page edges; the card is see-through
   (the web's stand-in for the native app's Liquid Glass), so the graph shows
   through it, dimmed, and crisp in the strips beside it. */
.nw2-wrap {
  --nw2-pad: 18px; --nw2-top: 30px; --nw2-band: 196px; --app-side: 16px;
  position: relative; margin-bottom: 12px;
}
@media (min-width: 760px) { .nw2-wrap { --nw2-band: 228px; } }
@media (min-width: 900px) { .nw2-wrap { --app-side: 32px; } }
.nw2 {
  position: relative; z-index: 1; margin-bottom: 0;
  padding: var(--nw2-pad) var(--nw2-pad) 16px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.nw2-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--nw2-top); }
.nw2-top .card-title { margin: 0; }

.nw2-seg {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), minmax(34px, auto));
  padding: 2px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.nw2-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px;
  width: calc((100% - 4px) / var(--n));
  border-radius: var(--r-pill); background: var(--text);
  transform: translateX(calc(100% * var(--i)));
  transition: transform 0.32s cubic-bezier(0.3, 0.8, 0.2, 1);
}
.nw2-seg button {
  position: relative; z-index: 1; appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--text-dim); padding: 5px 10px; border-radius: var(--r-pill);
  transition: color 0.2s var(--ease);
}
.nw2-seg button:hover { color: var(--text); }
.nw2-seg button[aria-pressed="true"] { color: var(--on-inverse); }
.nw2-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.nw2-value {
  margin-top: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: clamp(42px, 10vw, 58px); font-weight: 700; letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.nw2-cents { font-size: 0.5em; font-weight: 600; letter-spacing: -0.01em; color: var(--text-dim); margin-left: 1px; }
.nw2-change { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 26px; }
.nw2-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 9px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text-dim); background: color-mix(in srgb, var(--text) 7%, transparent);
}
.nw2-pill.up   { color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.nw2-pill.down { color: var(--bad);  background: color-mix(in srgb, var(--bad) 15%, transparent); }
.nw2-pct { padding-left: 6px; border-left: 1px solid currentColor; border-left-color: color-mix(in srgb, currentColor 35%, transparent); font-weight: 600; }
.nw2-when { font-size: 13px; color: var(--text-dim); transition: color 0.15s var(--ease); }
.nw2.scrubbing .nw2-when { color: var(--text); font-weight: 600; }

.nw2-band { height: var(--nw2-band); touch-action: pan-y; cursor: crosshair; outline: none; border-radius: 10px; }
.nw2-band:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.nw2-chart {
  position: absolute; z-index: 0;
  left: calc(-1 * var(--bleed-l, var(--app-side))); right: calc(-1 * var(--bleed-r, var(--app-side)));
  top: calc(var(--nw2-pad) + var(--nw2-top)); height: var(--nw2-band);
  touch-action: pan-y; cursor: crosshair;
}
.nw2-chart.reveal canvas { animation: nw2-reveal 0.75s cubic-bezier(0.3, 0.8, 0.2, 1); }
@keyframes nw2-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.nw2-axis {
  display: flex; justify-content: space-between; margin-top: 2px;
  font-size: 11px; font-weight: 500; color: var(--text-faint); font-variant-numeric: tabular-nums;
}

.nw2-mix { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.nw2-bar { display: flex; gap: 3px; height: 8px; margin-bottom: 14px; }
.nw2-bar i { display: block; min-width: 6px; border-radius: var(--r-pill); }
.nw2-c-assets { background: var(--accent); }
.nw2-c-cards  { background: var(--bad); }
.nw2-c-loans  { background: var(--warn); }
.nw2-keys { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }
.nw2-key { min-width: 0; }
.nw2-key-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 3px; }
.nw2-key-label i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.nw2-key b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw2-foot { margin-top: 12px; font-size: 12.5px; color: var(--text-dim); }
.nw2-empty { margin: 10px 0 0; font-size: 13.5px; color: var(--text-dim); }

@media (prefers-reduced-motion: reduce) {
  .nw2-thumb { transition: none; }
  .nw2-chart.reveal canvas { animation: none; }
}
.acct-section { margin-bottom: 20px; }
.accounts-grid { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 10px; row-gap: 16px; margin-top: 6px; }
@media (min-width: 600px) { .accounts-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .accounts-grid { grid-template-columns: repeat(4, 1fr); } }

/* min-width:0 overrides a grid item's default min-width:auto, which
   otherwise lets one card's content (a long account name, in particular)
   force its whole column wider than the others — the actual bug behind
   "cards aren't the same size" on mobile. align-self:start opts out of
   grid's default row-stretch too, so every card's height comes only from
   its own content (header + media, always the same two things), never
   inflated by a taller row sibling. */
.account-card { display: flex; flex-direction: column; align-self: start; min-width: 0; cursor: pointer; }
.account-card.archived { opacity: 0.55; }

/* List layout: a small card, the name and kind, the balance. */
.accounts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.account-row {
  flex-direction: row; align-items: center; gap: 12px; align-self: stretch;
  height: 64px; padding: 0 12px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--hairline);
}
.account-row .acct-card-media { width: 60px; flex: none; border-radius: 7px; border: 1px solid var(--hairline); }
.account-row .acct-card-fallback svg { width: 18px; height: 18px; }
.acct-row-text { min-width: 0; flex: 1; }
.acct-row-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-row-kind { font-size: 13px; color: var(--text-dim); }
.acct-row-balance { flex: none; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acct-row-balance.neg { color: var(--bad); }
/* long-press-to-reorder feedback (see renderAccounts' pointer gesture code):
   .armed is the hold-still cue before a drag is confirmed, .dragging kicks
   in once the finger actually moves and takes over `transform` itself, and
   .drop-target marks whichever other card the dragged one is currently
   hovering. */
.account-card.armed { transform: scale(1.04); transition: transform 0.12s var(--ease); }
.account-card.dragging { z-index: 5; opacity: 0.94; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); cursor: grabbing; }
.account-card.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: var(--r-lg); }

.acct-card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.acct-card-title { min-width: 0; flex: 1; }
.acct-card-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the card PNGs are a real card (rounded rect, ~85.6x54mm, ratio ~1.586)
   centered on a padded transparent canvas — matching that ratio here and
   scaling the <img> up (see .acct-card-img) crops away the canvas padding
   so only the card itself shows, edge to edge. */
.acct-card-media {
  position: relative; width: 100%; aspect-ratio: 1.586 / 1;
  border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2);
  transition: filter 0.15s var(--ease);
}
.account-card:active .acct-card-media { filter: brightness(0.85); }
.acct-card-img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.1); }
.acct-card-fallback {
  width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;
  color: var(--text-faint); background: linear-gradient(135deg in oklch, var(--surface), var(--surface-2));
}
.acct-card-fallback svg { width: 28px; height: 28px; }

/* dark scrim so the balance/gauge overlay stays legible over any card
   art, from a bright Discover photo to a near-white Apple Card face */
.acct-card-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg in oklch, rgba(0, 0, 0, 0) 66%, rgba(0, 0, 0, 0.4) 84%, rgba(0, 0, 0, 0.75) 100%);
}

.acct-card-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 6px;
  padding: 8px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.acct-card-balance { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: #fff; }
.acct-card-balance.neg { color: var(--bad); }
/* Light mode: a plain (no art, no chosen color) face is white, so the
   dark scrim meant for card art would just muddy it — drop it and set the
   balance in ordinary text color instead. Art and color faces keep both. */
@media (prefers-color-scheme: light) {
  .acct-card-media:has(.acct-card-fallback:not([style])) .acct-card-scrim { display: none; }
  .acct-card-media:has(.acct-card-fallback:not([style])) .acct-card-overlay { color: var(--text); text-shadow: none; }
  .acct-card-media:has(.acct-card-fallback:not([style])) .acct-card-balance:not(.neg) { color: var(--text); }
}

.acct-card-gauge-wrap { flex: none; }
.acct-gauge { position: relative; width: 36px; height: 36px; }
.acct-gauge > svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.agauge-track { fill: none; stroke: var(--gauge-track); stroke-width: 3; }
.agauge-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.3s var(--ease); }
.acct-gauge-glyph { position: absolute; inset: 0; display: grid; place-items: center; }

@media (hover: hover) and (pointer: fine) {
  .account-card:hover .acct-card-media { filter: brightness(1.1); }
}

/* month switcher */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 2px 14px; }
.month-nav .btn { padding: 7px 13px; }
.month-nav .label { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

/* Register calendar */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 2px 14px; }
.cal-nav .btn { padding: 7px 13px; }
.cal-nav .label { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center;
  font-size: 11px; font-weight: 600; color: var(--text-faint); margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { appearance: none; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 13px; border-radius: var(--r-md); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; }
.cal-day.outside { visibility: hidden; pointer-events: none; }
.cal-day:active { background: var(--press); }
.cal-day.today .cal-daynum { color: var(--accent); font-weight: 700; }
.cal-day.selected { background: var(--accent); }
.cal-day.selected .cal-daynum { color: #fff; font-weight: 700; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); }
.cal-dot.pos { background: var(--good); }
.cal-dot.neg { background: var(--bad); }
.cal-day.selected .cal-dot { background: #fff; }

/* ---------- modal sheet ---------- */
#modal-root .backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.6);
  animation: fade-in 0.15s var(--ease);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { #modal-root .backdrop { align-items: center; } }
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s var(--ease);
}
@media (min-width: 700px) { .sheet { border-radius: var(--r-xl); animation-name: fade-in; } }
@keyframes sheet-up { from { transform: translateY(30%); opacity: 0; } }

.sheet .grabber { width: 36px; height: 4px; border-radius: var(--r-pill);
  background: var(--text-faint); margin: 4px auto 14px; }
.sheet h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 16px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet .actions .btn { flex: 1; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* budget card modal header — the same gauge+icon the card itself shows,
   next to the name being edited. */
.bcm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bcm-head h2 { margin: 0; }
/* input and button end up different heights by default (different
   font-size/padding) — pinned to the same value so "Add to planned" and
   "Add" line up exactly instead of the button looking short/off. */
#bc-add, #bc-add-btn { height: 48px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 120; pointer-events: none; }
.toast { border-radius: var(--r-pill); padding: 10px 18px; font-size: 14px; font-weight: 500;
  animation: fade-in 0.15s var(--ease); }
.toast.out { animation: toast-out 0.2s var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; } }

/* ---------- boot ---------- */
#boot { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--bg); transition: opacity 0.25s var(--ease); }
#boot.done { opacity: 0; pointer-events: none; }
.boot-mark { width: 64px; height: 64px; border-radius: var(--r-xl); display: grid; place-items: center;
  font-family: "SF Pro Display", -apple-system, sans-serif; font-size: 30px; font-weight: 700; }
/* pulse is scoped to the boot screen itself, not the bare .boot-mark class,
   since .sidebar-mark (desktop nav) shares that class but should stay
   static — a class selector here would tie on specificity with .sidebar-mark
   and lose on source order regardless of media-query nesting. */
#boot .boot-mark { animation: breathe 1.2s var(--ease) infinite alternate; }
@keyframes breathe { to { opacity: 0.4; } }
.boot-text { font-size: 14px; color: var(--text-dim); }

/* charts */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 260px; }

/* custom HTML legend (donut) — replaces Chart.js's built-in one so each
   entry can carry the group's real icon instead of a plain color swatch. */
.chart-legend { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 12px; justify-content: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.legend-item svg { flex-shrink: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.empty { text-align: center; color: var(--text-dim); font-size: 14px; padding: 26px 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 8px; }
.section-head .card-title { margin: 0; }

/* mobile-only echo of #sidebar-version — desktop already shows it above
   "Left to budget" in the sidebar, so this is hidden there to avoid
   showing the version number twice. */
.dash-version { text-align: center; font-size: 11.5px; color: var(--text-faint); margin: 4px 0 8px; }
.dash-footer { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 0 4px; }
.dash-footer .dash-version { margin: 0; }
.dash-footer-btns { display: flex; gap: 8px; }

/* ---------- passcode lock ---------- */
#lock { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg); }
.lock-card { width: min(100%, 340px); display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 22px 22px; border-radius: var(--r-xl); text-align: center; }
.lock-card h1 { margin: 0; font-size: 22px; }
.lock-sub { margin: -6px 0 0; color: var(--text-dim); font-size: 14px; }
.lock-card input { text-align: center; font-size: 18px; letter-spacing: 0.12em; }
.lock-error { min-height: 18px; margin: -4px 0 0; font-size: 13px; color: var(--bad); }
.lock-card .btn:disabled { opacity: 0.5; cursor: default; }
.changelog { max-height: 60vh; overflow-y: auto; margin: 0 -4px 12px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.cl-entry { padding: 10px 0; border-top: 1px solid var(--border, rgba(128,128,128,.22)); }
.cl-entry:first-child { border-top: 0; padding-top: 0; }
.cl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cl-date { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }
.cl-entry ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-dim); }
.cl-entry li { margin: 2px 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- hover (mouse-capable devices only) ----------
   Gated behind (hover:hover) so touch never gets a "stuck" hover state
   after a tap — touchscreens report (hover:none). */
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--press); }
  .btn.primary:hover { opacity: 0.88; }
  .chip:hover:not(.active) { background: var(--press); }
  .row:hover { background: var(--press); }
  .tab:hover:not(.active) { color: var(--text-dim); }
  .sidebar-nav .tab:hover:not(.active) { background: var(--surface-2); }
  .sidebar-shelf:hover { border-color: var(--text-faint); }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .cal-day:hover:not(.outside):not(.selected) { background: var(--surface-2); }
  .cat-btn:hover { border-color: var(--text-faint); }
  .cat-option:hover { background: var(--press); }
  .budget-card:hover { border-color: color-mix(in srgb, var(--tone) 45%, transparent); }
  .bud-menu button:hover { background: var(--press); }
  .bud-month-label:not(:disabled):hover { background: var(--surface-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  /* a loading indicator is state, not decoration — keep it turning, slowly */
  .spinner { animation-duration: 1.6s !important; }
}


/* ---- transaction sheet: compact layout, More, recurrence ----------------
   Fields on a glass sheet are themselves see-through glass, a shade darker
   than the sheet, rather than opaque boxes. */
.sheet input, .sheet select, .sheet textarea, .sheet .cat-btn, .sheet .segment, .sheet .more-btn {
  background-color: var(--field-glass);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .sheet input, .sheet select, .sheet textarea, .sheet .cat-btn, .sheet .segment, .sheet .more-btn {
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
  }
}

/* payee and date share a row */
.field-row { display: flex; gap: 10px; align-items: flex-end; }
.field-row > .field { flex: 1; min-width: 0; }
.field-row > .field-date { flex: 0 0 150px; }

.more-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text); text-align: left;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 12px 14px; margin: 0 0 14px; cursor: pointer;
}
.more-sum { margin-left: auto; min-width: 0; color: var(--text-dim); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-btn svg { flex: none; color: var(--text-dim); transition: transform 0.2s var(--ease); }
.more-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.more-panel[hidden] { display: none; }
.recur-sum { display: block; font-size: 12.5px; color: var(--accent); margin-top: 2px; cursor: pointer; }
.recur-sum:empty { display: none; }

/* the "how often?" panel opened by Make recurring, over the sheet */
.recur-pop-backdrop {
  position: fixed; inset: 0; z-index: 120; background: rgba(0, 0, 0, 0.35);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.15s var(--ease);
}
@media (min-width: 700px) { .recur-pop-backdrop { align-items: center; } }
.recur-pop {
  width: 100%; max-width: 440px; background: var(--sheet-solid);
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: 0 -8px 32px var(--sheet-shadow);
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s var(--ease);
}
@media (min-width: 700px) { .recur-pop { border-radius: var(--r-xl); } }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .recur-pop { background: var(--sheet-glass); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); }
}
.recur-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.recur-pop .segment { background-color: var(--field-glass); }
.recur-pop .segment button.active { background: var(--text); color: var(--on-inverse); }
.recur-pop input, .recur-pop select { background-color: var(--field-glass); }
.recur-pop-sum { font-size: 13px; color: var(--text-dim); margin: 2px 2px 0; }

/* category transactions sheet header — same as the app's category page */
.cattx-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.cattx-head .grow { flex: 1; min-width: 0; }
.cattx-head h2 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cattx-head .card-title { margin: 2px 0 0; }
.cattx-nums { font-size: 14px; color: var(--text-dim); margin: 0 2px 14px; }
.cattx-nums b { color: var(--text); }

/* ---------- tip calculator ---------- */
/* (the standalone % button is gone; the calculator lives in the transaction sheet) */

/* the % beside the transaction sheet's amount */
.amount-wrap { position: relative; }
.tip-toggle {
  position: absolute; right: 8px; top: 8px; width: 36px; height: 36px;
  border-radius: var(--r-pill); display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--hairline);
  color: var(--accent); font: 700 16px/1 -apple-system, "SF Pro Display", sans-serif;
}
.tip-toggle.active { background: var(--accent); border-color: transparent; color: #fff; }
.tip-toggle[hidden] { display: none; }
.tip-panel { margin: 0 0 12px; padding: 12px 12px 0; border-radius: var(--r-lg);
  border: 1px solid var(--hairline); background: var(--field-glass); }
.tip-panel[hidden] { display: none; }
.tip-panel .amount-input { font-size: 26px !important; }
.tip-panel .actions { padding-bottom: 12px; }

.tip-calc .tip-results { border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--hairline); }
.tip-line { display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.tip-line span { color: var(--text-dim); }
.tip-line.big { font-size: 24px; border-top: 1px solid var(--hairline); margin-top: 6px; padding-top: 9px; }
.tip-line[hidden] { display: none; }
.tip-step { display: flex; align-items: center; justify-content: space-between;
  min-height: 44px; padding: 0 6px; border-radius: var(--r-lg); background: var(--field-glass);
  font-size: 17px; font-variant-numeric: tabular-nums; }
.tip-step .icon-btn { width: 40px; height: 40px; font-size: 22px; color: var(--text); }
.tip-calc .toggle-row small { display: block; font-size: 12px; color: var(--text-faint); }


/* ---------- expanded Sankey page ---------- */
.sankey-card { cursor: pointer; transition: background 0.15s var(--ease); }
.sankey-card:active { background: var(--press); }
.sankey-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sankey-card canvas { pointer-events: none; }
.sankey-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sankey-expand {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2);
}

#sankey-page {
  position: fixed; inset: 0; z-index: 95;
  background: var(--bg);
  animation: sankey-in 0.28s var(--ease);
}
@keyframes sankey-in { from { opacity: 0; transform: scale(0.97); } }
/* the diagram fills the whole page; the bar floats on top of it as glass */
.sankey-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  padding: max(12px, env(safe-area-inset-top)) 0 10px;
  background: var(--sheet-glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
  border-bottom: 1px solid var(--hairline);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sankey-top { background: var(--sheet-solid); }
}
.sankey-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 0 16px 10px;
}
.sankey-back { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px 7px 8px; }
.sankey-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sankey-nav .btn { padding: 6px 12px; }
.sankey-nav .label { font-size: 15px; font-weight: 600; min-width: 112px; text-align: center; }
.sankey-sums { display: flex; gap: 10px; padding: 0 16px; }
.sankey-sums > div {
  flex: 1; background: var(--surface); border-radius: var(--r-lg); padding: 8px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.sankey-sums span { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.sankey-sums b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sankey-scroll {
  position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
.sankey-stage { min-width: 100%; padding: var(--sankey-top, 120px) 0 max(24px, env(safe-area-inset-bottom)); }
@media (max-width: 520px) {
  .sankey-sums b { font-size: 15px; }
  .sankey-nav { width: 100%; justify-content: space-between; margin-left: 0; }
}

/* Landscape phone: the keyboard leaves little height, so the transaction
   form runs in two balanced columns (amount and payee on the left, account,
   category and switches on the right) in a wider sheet, instead of one long
   scroll. Only the centered modal — not the docked sidebar editor. */
@media (orientation: landscape) and (max-height: 520px) {
  #modal-root .sheet.txn-sheet {
    max-width: 800px; max-height: 96vh;
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  #modal-root .sheet.txn-sheet .grabber { margin-bottom: 6px; }
  #modal-root .sheet.txn-sheet h2 { margin-bottom: 10px; }
  .txn-sheet .txn-cols { column-count: 2; column-gap: 20px; }
  .txn-sheet .txn-cols > *, .txn-sheet #f-fields > * { break-inside: avoid; }
  .txn-sheet #f-fields { display: contents; }
  /* smaller account cards, so the whole form and Save fit the short screen */
  .txn-sheet .acct-picker-item { flex-basis: 40%; }
  .txn-sheet .acct-picker-track { padding-left: 30%; padding-right: 30%; }
}
