/* The default look is White colorful ("Fresh garden"). No data-theme = follow the device: White colorful on a
   light device, Dark on a dark one. Signed-in people can pick another theme in Settings > Appearance. */
:root {
  --bg: #fbfdfc;
  --surface: #ffffff;
  --surface-2: #f2f6f5;
  --border: #e3e9e8;
  --text: #13201d;
  --muted: #5b6b68;
  --accent: #0a8567;
  --accent-ink: #ffffff;
  --pos: #0a7a5c;
  --neg: #c8391f;
  --warn: #b26a00;
  --bar-in: #12b886;
  --bar-out: #f97362;
  --track: #ecf1f0;
  --shadow: 0 1px 2px rgba(16, 40, 34, .05), 0 10px 28px -10px rgba(16, 40, 34, .12);
  --radius: 18px;
  --radius-sm: 11px;
  --pop-shadow: 0 18px 48px -12px rgba(0, 0, 0, .35);
  color-scheme: light;
  /* Only White colorful changes these (below); every other theme keeps these plain values. */
  --glow-2: transparent;
  --brand-grad: linear-gradient(var(--accent), var(--accent));
  --hero-bg:
    radial-gradient(600px 260px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface) 75%);
  --hero-border: color-mix(in srgb, var(--accent) 22%, var(--border));
  --hero-ink: var(--text);
  --hero-muted: var(--muted);
  --hero-pos: var(--pos);
  --hero-neg: var(--neg);
  --tile-in: transparent;
  --tile-out: transparent;
  --tile-net: transparent;
  --stat-gap: 0px;
  --stat-rule: color-mix(in srgb, var(--border) 80%, transparent);
  --stat-pad: 4px 22px;
  --stat-pad-phone: 0 0 0 14px;
  --stat-first-left: 0px;
  --stat3-pad: 14px 0 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --surface: #171a1f;
    --surface-2: #1f232a;
    --border: #2a2f37;
    --text: #e8eaee;
    --muted: #9198a4;
    --accent: #5bb497;
    --accent-ink: #0c1512;
    --pos: #5bc28d;
    --neg: #f08a76;
    --warn: #e6b05a;
    --bar-in: #4fae86;
    --bar-out: #e0806b;
    --track: #262b33;
    --shadow: none;
    color-scheme: dark;
  }
}

/* White colorful's extras: on a light device following the system, and when picked in Settings (kept twice,
   because a media query and a theme can't share one rule). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --glow-2: rgba(249, 115, 98, .10);
    --brand-grad: linear-gradient(120deg, #0a8567, #0f7fa0);
    --hero-bg: linear-gradient(120deg, #0a8567, #0f7fa0);
    --hero-border: transparent; --hero-ink: #ffffff; --hero-muted: rgba(255, 255, 255, .86); --hero-pos: #ffffff; --hero-neg: #ffffff;
    --tile-in: #e6f8f1; --tile-out: #fff0eb; --tile-net: #eef2ff;
    --stat-gap: 8px; --stat-rule: transparent; --stat-pad: 10px 14px; --stat-pad-phone: 10px 12px; --stat-first-left: 12px; --stat3-pad: 10px 12px;
  }
}

/* ---------- themes picked in Settings (no attribute = follow the system light/dark setting) */
:root[data-theme="light"] {
  --bg: #fbfdfc; --surface: #ffffff; --surface-2: #f2f6f5; --border: #e3e9e8; --text: #13201d; --muted: #5b6b68;
  --accent: #0a8567; --accent-ink: #ffffff; --pos: #0a7a5c; --neg: #c8391f; --warn: #b26a00;
  --bar-in: #12b886; --bar-out: #f97362; --track: #ecf1f0;
  --shadow: 0 1px 2px rgba(16, 40, 34, .05), 0 10px 28px -10px rgba(16, 40, 34, .12); color-scheme: light;
  --glow-2: rgba(249, 115, 98, .10);
  --brand-grad: linear-gradient(120deg, #0a8567, #0f7fa0);
  --hero-bg: linear-gradient(120deg, #0a8567, #0f7fa0);
  --hero-border: transparent; --hero-ink: #ffffff; --hero-muted: rgba(255, 255, 255, .86); --hero-pos: #ffffff; --hero-neg: #ffffff;
  --tile-in: #e6f8f1; --tile-out: #fff0eb; --tile-net: #eef2ff;
  --stat-gap: 8px; --stat-rule: transparent; --stat-pad: 10px 14px; --stat-pad-phone: 10px 12px; --stat-first-left: 12px; --stat3-pad: 10px 12px;
}
:root[data-theme="dark"] {
  --bg: #0f1114; --surface: #171a1f; --surface-2: #1f232a; --border: #2a2f37; --text: #e8eaee; --muted: #9198a4;
  --accent: #5bb497; --accent-ink: #0c1512; --pos: #5bc28d; --neg: #f08a76; --warn: #e6b05a;
  --bar-in: #4fae86; --bar-out: #e0806b; --track: #262b33; --shadow: none; color-scheme: dark;
}
:root[data-theme="midnight"] {
  --bg: #0b1220; --surface: #111a2e; --surface-2: #18233b; --border: #24324f; --text: #e6ecf7; --muted: #8d9bb5;
  --accent: #4c8dff; --accent-ink: #ffffff; --pos: #3ecf8e; --neg: #ff6b6b; --warn: #f5b94a;
  --bar-in: #3ecf8e; --bar-out: #ff8a65; --track: #1d2942; --shadow: none; color-scheme: dark;
}
:root[data-theme="nord"] {
  --bg: #2e3440; --surface: #3b4252; --surface-2: #434c5e; --border: #4c566a; --text: #eceff4; --muted: #b4bccb;
  --accent: #88c0d0; --accent-ink: #2e3440; --pos: #a3be8c; --neg: #e5838c; --warn: #ebcb8b;
  --bar-in: #a3be8c; --bar-out: #d08770; --track: #4c566a; --shadow: none; color-scheme: dark;
}
:root[data-theme="dracula"] {
  --bg: #21222c; --surface: #282a36; --surface-2: #343746; --border: #44475a; --text: #f8f8f2; --muted: #a4a8c4;
  --accent: #bd93f9; --accent-ink: #21222c; --pos: #50fa7b; --neg: #ff5555; --warn: #f1fa8c;
  --bar-in: #50fa7b; --bar-out: #ff79c6; --track: #383a4a; --shadow: none; color-scheme: dark;
}
:root[data-theme="solarized"] {
  --bg: #fdf6e3; --surface: #fffbef; --surface-2: #eee8d5; --border: #e0d8bf; --text: #073642; --muted: #5f747c;
  --accent: #268bd2; --accent-ink: #ffffff; --pos: #6c7d00; --neg: #dc322f; --warn: #b58900;
  --bar-in: #859900; --bar-out: #cb4b16; --track: #eee8d5;
  --shadow: 0 1px 2px rgba(7, 54, 66, .06); color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f4ecd8; --surface: #fbf6ea; --surface-2: #efe5cf; --border: #e2d5b8; --text: #3b2f22; --muted: #7a6a55;
  --accent: #9a5b2e; --accent-ink: #ffffff; --pos: #4f7a3a; --neg: #b23b2b; --warn: #a86b12;
  --bar-in: #6d9a52; --bar-out: #c46a45; --track: #eadfc6;
  --shadow: 0 1px 2px rgba(59, 47, 34, .08); color-scheme: light;
}
:root[data-theme="contrast"] {
  --bg: #000000; --surface: #000000; --surface-2: #1a1a1a; --border: #ffffff; --text: #ffffff; --muted: #e0e0e0;
  --accent: #ffd400; --accent-ink: #000000; --pos: #00ff7f; --neg: #ff6b6b; --warn: #ffd400;
  --bar-in: #00e676; --bar-out: #ff6e40; --track: #333333; --shadow: none; color-scheme: dark;
}

/* ---------- text settings (Settings > Appearance). Everything is sized in rem, so the root size scales the app. */
:root { --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
:root[data-font-size="small"] { font-size: 87.5%; }
:root[data-font-size="large"] { font-size: 112.5%; }
:root[data-font-size="xlarge"] { font-size: 125%; }
:root[data-font="serif"] { --font-ui: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif; }
:root[data-font="rounded"] { --font-ui: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif; }
:root[data-font="mono"] { --font-ui: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace; }
:root[data-font="readable"] { --font-ui: "Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", sans-serif; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  /* a faint glow of the theme's accent at the top of the page */
  background:
    radial-gradient(1100px 520px at 12% -12%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 62%),
    radial-gradient(900px 460px at 96% -10%, var(--glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: .9375rem/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

h2 { font-size: 1rem; margin: 0 0 14px; font-weight: 650; letter-spacing: -.012em; }
h3 { font-size: .9rem; margin: 0 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }
.error { color: var(--neg); font-size: .85rem; min-height: 1.2em; margin: 6px 0; }
.error:empty { min-height: 0; margin: 0; }
/* a form's button never sits glued to the small note above it */
form .hint ~ button[type="submit"] { margin-top: 14px; }

/* ---------- controls */
input, select, button, textarea { font: inherit; color: inherit; }
/* filled fields: quiet until hovered or focused */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--border); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
textarea { display: block; resize: vertical; min-height: 120px; line-height: 1.5; }
label { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); margin-bottom: 14px; }
label > input, label > select, label > textarea { margin-top: 6px; color: var(--text); }

button {
  cursor: pointer; border-radius: var(--radius-sm); border: 1px solid transparent; padding: 10px 16px; font-weight: 550;
  transition: background-color .15s, border-color .15s, transform .12s, box-shadow .15s, filter .15s;
}
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .6; cursor: progress; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary {
  background: var(--brand-grad); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.primary:hover { filter: brightness(1.07); }
.ghost { background: color-mix(in srgb, var(--surface) 60%, transparent); border-color: var(--border); }
.ghost:hover { background: var(--surface-2); }
.danger-btn { background: var(--neg); color: #fff; }
.small { padding: 6px 12px; font-size: .84rem; border-radius: 9px; }
.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; background: transparent; border: 1px solid var(--border);
  width: 34px; height: 34px; padding: 0; font-size: 1.2rem; line-height: 1; border-radius: 50%; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
/* drawn ×, ‹ and › (see glyph() in app.js): always dead centre */
.glyph { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .glyph { width: 16px; height: 16px; }
.icon-btn.sm .glyph { width: 12px; height: 12px; }

/* ---------- brand */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem; }
/* the logo: a "P" (a stem + a ring) with a small gold coin, drawn in CSS so it follows the theme colour.
   Same shape as favicon.svg (64 units wide there; here everything is a share of --s). */
.logo {
  --s: 22px; flex: none; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .32); position: relative;
  background:
    radial-gradient(circle at 68.75% 71.9%, #f2c14e calc(var(--s) * .0625), transparent calc(var(--s) * .0625 + .5px)),
    linear-gradient(135deg, var(--accent), var(--bar-in));
}
.logo::before { content: ""; position: absolute; left: 28.9%; top: 22.7%; width: 10.9%; height: 57.8%; border-radius: 99px; background: var(--surface); }
.logo::after { content: ""; position: absolute; left: 30.5%; top: 22.7%; width: 42.2%; height: 42.2%; box-sizing: border-box; border: calc(var(--s) * .109) solid var(--surface); border-radius: 50%; }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
/* intro on the left, form on the right; stacked on narrow screens */
.auth-shell { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 56px; align-items: center; width: min(960px, 100%); }
.auth-intro { display: grid; gap: 14px; max-width: 460px; }
.auth-intro .brand { font-size: 1.15rem; }
/* the maker's tag beside the name: tiny and quiet, but readable */
.brand-by { margin-left: -4px; align-self: flex-end; padding-bottom: .18em; font-size: .6rem; font-weight: 500; letter-spacing: .06em; color: var(--muted); opacity: .75; white-space: nowrap; }
.footer-bottom .brand-by { margin: 0; padding: 0; font-size: .78rem; }
.auth-headline { margin: 8px 0 0; font-size: clamp(1.8rem, 3.6vw, 2.5rem); line-height: 1.15; letter-spacing: -.03em; font-weight: 750; }
.auth-lead { margin: 0; color: var(--muted); font-size: 1rem; }
.auth-points { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; }
.auth-points li > span:last-child { display: grid; gap: 1px; }
.auth-points strong { font-size: .95rem; }
.auth-points li > span:last-child > span { color: var(--muted); font-size: .88rem; }
.auth-icon {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; font-size: 1.05rem;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 24px; padding: 32px; box-shadow: var(--shadow), var(--pop-shadow);
}
.auth-card-title { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; }
.auth-card .muted { font-size: .9rem; margin: 6px 0 22px; }
@media (max-width: 860px) {
  .auth { place-items: start center; }
  .auth-shell { grid-template-columns: 1fr; gap: 22px; max-width: 420px; }
  .auth-intro { gap: 10px; }
  .auth-headline { font-size: 1.6rem; margin-top: 4px; }
  .auth-lead { font-size: .92rem; }
  /* phones: the four points as a compact 2 x 2 grid of short titles */
  .auth-points { grid-template-columns: 1fr 1fr; gap: 10px; }
  .auth-points li { align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; background: var(--surface-2); }
  .auth-points li > span:last-child > span { display: none; }
  .auth-points strong { font-size: .82rem; line-height: 1.25; }
  .auth-icon { width: 28px; height: 28px; font-size: .9rem; border-radius: 8px; }
  .auth-card { padding: 24px 20px; }
}
@media (max-width: 480px) {
  /* small phones: keep the headline and the four points, so the form starts higher up */
  .auth { padding-top: 16px; }
  .auth-lead { display: none; }
  .auth-headline { font-size: 1.45rem; }
  .auth-shell { gap: 16px; }
}
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tab { background: transparent; padding: 8px; font-size: .9rem; color: var(--muted); border-radius: 9px; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 650; }

/* ---------- layout */
/* glassy bar: the page shows softly through it while scrolling */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ledger-select { width: auto; max-width: 240px; padding: 7px 12px; font-weight: 650; border-radius: 99px; }
/* month switcher: one soft pill */
.month-nav { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 99px; background: var(--surface-2); }
.month-nav .icon-btn { border: 0; width: 32px; height: 32px; }
.month-nav .icon-btn:hover:not(:disabled) { background: var(--surface); }
.month-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.month-nav #this-month { border-radius: 99px; padding: 5px 12px; margin-left: 2px; }
.month-label { min-width: 136px; text-align: center; font-weight: 650; letter-spacing: -.01em; }
.user { display: flex; align-items: center; gap: 8px; }
.user-name { color: var(--muted); font-size: .9rem; margin-right: 4px; }

.container { max-width: 1180px; margin: 0 auto; padding: 26px 28px 56px; display: grid; gap: 20px; }
.card {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); min-width: 0;
  transition: box-shadow .2s, border-color .2s;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { margin: 0; }
.card-head.wrap { flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- hero: this month's net, big, on a soft accent wash */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr); gap: 28px; align-items: center;
  padding: 28px 30px; border-radius: calc(var(--radius) + 6px);
  border: 1px solid var(--hero-border);
  background: var(--hero-bg);
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
}
.hero-main { display: grid; gap: 4px; min-width: 0; color: var(--hero-ink); }
.hero-main .pos { color: var(--hero-pos); }
.hero-main .neg { color: var(--hero-neg); }
.hero-label, .stat-label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.hero-label { color: var(--hero-muted); }
.hero-value { font-size: clamp(2rem, 4.4vw, 2.9rem); font-weight: 750; letter-spacing: -.035em; line-height: 1.1; }
.hero-sub { font-size: .88rem; color: var(--hero-muted); min-height: 1.3em; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--stat-gap); }
.stat { display: grid; gap: 4px; padding: var(--stat-pad); min-width: 0; border-radius: 14px; transition: transform .2s; }
.stat:nth-child(1) { background: var(--tile-in); }
.stat:nth-child(2) { background: var(--tile-out); }
.stat:nth-child(3) { background: var(--tile-net); }
.stat + .stat { border-left: 1px solid var(--stat-rule); }
.stat .sw { margin: 0; width: 8px; height: 8px; border-radius: 50%; }
.stat-value { font-size: clamp(1.05rem, 1.9vw, 1.35rem); }
.stat-sub { font-size: .78rem; color: var(--muted); }
.kpi-value { white-space: nowrap; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* Wide screens: the add form has its own left column and stays in view while scrolling; on the right,
   Spending + Budgets, then the chart, then the transactions fill the space, so there are no gaps. */
.grid {
  display: grid; grid-template-columns: 340px 1fr 1fr; gap: 20px; align-items: start;
  grid-template-areas: "add spend budget" "add trend trend" "add activity activity";
  grid-template-rows: auto auto 1fr;
}
.add-card { grid-area: add; }
#spend-card { grid-area: spend; align-self: stretch; }
#budgets-card { grid-area: budget; align-self: stretch; }
.grid > .trend-card { grid-area: trend; }
.grid > #activity { grid-area: activity; align-self: stretch; }
@media (min-width: 1001px) {
  /* sticks below the top bar; scrolls inside itself if the window is short */
  .add-card {
    position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* ---------- forms */
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; text-align: center; padding: 8px; border-radius: 9px; color: var(--muted); cursor: pointer; font-size: .9rem; transition: background-color .15s, color .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 650; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- bars */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 5px; }
.bar-top { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 10px; font-size: .88rem; }
.bar-top .amt { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: auto; text-align: right; min-width: 0; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.track { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; background: var(--bar-out); border-radius: 99px; }
.fill.ok { background: var(--bar-in); }
.fill.warn { background: var(--warn); }
.fill.over { background: var(--neg); }
.empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 18px 0; margin: 0; }

/* ---------- trend chart */
.trend { width: 100%; height: auto; display: block; }
.trend .axis { stroke: var(--border); }
.trend .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.trend text { fill: var(--muted); font-size: 11px; }
.trend .in { fill: var(--bar-in); }
.trend .out { fill: var(--bar-out); }
.trend .current { fill: var(--text); font-weight: 600; }
.legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.sw-in { background: var(--bar-in); }
.sw-out { background: var(--bar-out); }

/* ---------- table */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { width: 220px; padding: 6px 10px; }
.filters select { width: auto; padding: 6px 10px; }
.table-wrap { overflow-x: auto; }
.tx-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tx-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.tx-table td { padding: 11px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); vertical-align: middle; }
.tx-table .num { font-weight: 600; }
.tx-table tr:last-child td { border-bottom: 0; }
.tx-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-table .date { white-space: nowrap; color: var(--muted); }
.tx-table .note { color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-table .row-actions { text-align: right; white-space: nowrap; }
.row-actions button { background: transparent; border: 0; color: var(--muted); padding: 4px 8px; font-size: .82rem; }
.row-actions button:hover { color: var(--text); background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; white-space: nowrap; }

/* ---------- category badges (color + icon are set per category from JS) */
.cat-badge {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px; border: 0; padding: 0;
  font-size: .85rem; font-weight: 700; line-height: 1;
  background: var(--surface-2); color: var(--muted);
}
.cat-badge.sm { width: 20px; height: 20px; border-radius: 6px; font-size: .7rem; }
.cat-badge.big { width: 42px; height: 42px; border-radius: 11px; font-size: 1.3rem; cursor: default; }

/* ---------- category manager */
.wide-dialog { width: min(520px, calc(100vw - 32px)); }
.cat-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow-y: auto; }
.cat-item { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; }
.cat-item + .cat-item { border-top: 1px solid var(--border); }
.cat-item.editing { background: var(--surface-2); }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cat-count { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.cat-fields { display: grid; grid-template-columns: auto 1fr 42px; gap: 10px; align-items: center; margin-bottom: 12px; }
.color-input { padding: 3px; height: 42px; cursor: pointer; }
.picker-label { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); margin: 4px 0 6px; }
.icon-input { width: 130px; padding: 4px 8px; font-size: .85rem; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, 26px); gap: 8px; margin-bottom: 10px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.swatch.selected { outline: 2px solid var(--text); outline-offset: 2px; }
.icon-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; margin-bottom: 6px; }
.icon-choice { padding: 5px 0; font-size: 1.1rem; background: transparent; border: 1px solid transparent; }
.icon-choice:hover { background: var(--surface-2); }
.icon-choice.selected { border-color: var(--accent); background: var(--surface-2); }
#categories-dialog .segmented { margin: 4px 0 8px; }

/* ---------- dialogs */
dialog {
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); border-radius: 22px; padding: 24px; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--pop-shadow);
}
dialog::backdrop { background: rgba(10, 12, 16, .42); backdrop-filter: blur(3px); }
dialog[open] { animation: pop-in .18s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.budget-rows { display: grid; gap: 8px; margin: 12px 0; }
.budget-row { display: grid; grid-template-columns: 1fr 120px 34px; gap: 8px; }
.settings-block { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.settings-block.danger h3 { color: var(--neg); }
.settings-block .muted { font-size: .85rem; margin: 0 0 12px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-text { color: var(--neg); }

/* ---------- theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-option {
  display: grid; gap: 6px; padding: 6px; background: transparent; border: 1px solid var(--border);
  border-radius: 10px; text-align: center;
}
.theme-option:hover { background: var(--surface-2); }
.theme-option[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-preview { display: block; height: 44px; border-radius: 7px; padding: 8px; border: 1px solid rgba(128, 128, 128, .25); }
.tp-surface { display: flex; align-items: center; gap: 6px; height: 100%; border-radius: 5px; padding: 0 6px; }
.tp-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.tp-line { height: 5px; flex: 1; border-radius: 3px; }
.theme-label { font-size: .8rem; }
.inline select { flex: 1; }

/* ---------- username field with availability check + suggestions dropdown */
.field { margin-bottom: 12px; }
.field-label { margin-bottom: 5px; }
.combo { position: relative; }
.field-status { min-height: 1.1em; margin: 5px 0 0; font-size: .8rem; color: var(--muted); }
.field-status:empty { min-height: 0; margin: 0; }
span.field-status { display: block; font-weight: 400; }
.field-status.ok { color: var(--pos); }
.field-status.bad { color: var(--neg); }
.suggest-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}
.suggest-head { padding: 6px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.suggest-option { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: .92rem; }
.suggest-option:hover, .suggest-option[aria-selected="true"] { background: var(--surface-2); }
.suggest-check { color: var(--pos); font-size: .8rem; }

/* ---------- clickable category rows */
.bar-row.clickable { cursor: pointer; margin: -5px -8px; padding: 5px 8px; border-radius: 8px; }
.bar-row.clickable:hover { background: var(--surface-2); }
.bar-row.clickable:focus { outline: none; }
.bar-row.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.chev { color: var(--muted); opacity: 0; transition: opacity .15s; margin-left: 2px; display: inline-grid; place-items: center; }
.chev .glyph { width: 13px; height: 13px; }
.bar-row.clickable:hover .chev, .bar-row.clickable:focus-visible .chev { opacity: 1; }

/* ---------- category detail pop-up */
dialog.cat-detail { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; display: none; }
dialog.cat-detail[open] { display: flex; flex-direction: column; }
.cd-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cd-title { flex: 1; min-width: 0; }
.cd-title h2 { margin: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-month-nav { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.icon-btn.sm { width: 24px; height: 24px; font-size: .95rem; }
.cd-top { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; padding: 18px 20px; }
.cd-chart { display: grid; justify-items: center; gap: 6px; }
.cd-figure { position: relative; width: 220px; max-width: 100%; }
.donut { display: block; width: 100%; height: auto; overflow: visible; }
.donut-seg {
  fill: color-mix(in srgb, var(--muted) 38%, var(--surface)); stroke: var(--surface); stroke-width: 2;
  cursor: pointer; transition: fill .15s;
}
.donut-seg:hover, .donut-seg:focus-visible { fill: color-mix(in srgb, var(--muted) 65%, var(--surface)); outline: none; }
.donut-seg.lit:hover, .donut-seg.lit:focus-visible { filter: brightness(1.08); }
.donut-empty { fill: none; stroke: var(--track); }
.cd-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.cd-pct { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cd-of { font-size: .78rem; color: var(--muted); }
.cd-total { margin: 0; font-size: .82rem; color: var(--muted); text-align: center; }
.cd-total strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: .78rem; padding: 5px 9px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.cd-budget { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; align-self: center; }
.cd-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cd-budget-line { font-size: .9rem; color: var(--muted); }
.cd-budget-line strong { color: var(--text); }
.cd-budget .setting-desc { margin: 0; }
.cd-budget .ghost { justify-self: start; }
.cd-status { font-size: .85rem; font-weight: 600; }
.cd-status.ok { color: var(--pos); }
.cd-status.warn { color: var(--warn); }
.cd-status.over { color: var(--neg); }
.cd-list-head { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 20px 6px; border-top: 1px solid var(--border); }
.cd-list-head h3 { margin: 10px 0 0; }
.cd-list { padding: 0 20px 16px; overflow-y: auto; min-height: 80px; }
.cd-when { width: 100%; max-width: 0; } /* max-width:0 lets the note ellipsize instead of widening the table */
.cd-right { text-align: right; white-space: nowrap; }
.cd-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.cd-right .row-actions { margin-right: -8px; }
.cd-right .row-actions button { padding: 2px 8px; font-size: .78rem; }
.cd-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-date { font-size: .78rem; color: var(--muted); }

/* ---------- admin panel */
.admin-note { margin: 16px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: .82rem; color: var(--muted); }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.admin-stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.admin-stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.admin-stat-label { font-size: .82rem; font-weight: 600; }
.admin-stat-sub { font-size: .75rem; color: var(--muted); }
.admin-users-head { display: flex; align-items: center; justify-content: space-between; }
.admin-users { display: grid; }
.admin-user { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.admin-user + .admin-user { border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); }
.admin-user-main { flex: 1; min-width: 0; }
.admin-user-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.admin-user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
/* site stats & errors (Settings > Admin) */
#site-stats { margin-top: 10px; }
.stats-chart { position: relative; margin-top: 16px; }
.stats-chart-title { font-size: .78rem; font-weight: 650; color: var(--muted); margin-bottom: 8px; }
.stats-bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-bottom: 1px; border-bottom: 1px solid var(--border); }
.stats-bar { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; background: transparent; border: 0; border-radius: 0; padding: 0; cursor: default; }
.stats-bar span { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; transition: opacity .12s; }
.stats-bar:hover span, .stats-bar:focus-visible span { opacity: 1; }
.stats-bar.zero span { background: var(--track); }
.stats-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.stats-pages { margin-top: 16px; }
.stats-page-list, .error-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stats-page-list li { display: grid; grid-template-columns: minmax(90px, max-content) 1fr 56px; gap: 10px; align-items: center; font-size: .85rem; }
.stats-page-list .meter { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.stats-page-list .meter span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.stats-page-list b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.error-list { margin-top: 10px; }
.error-list li { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .84rem; display: grid; gap: 2px; overflow-wrap: anywhere; }
.error-list li.new { box-shadow: inset 3px 0 0 var(--neg); }
.error-list .err-msg { font-weight: 600; }
.error-list .err-meta { color: var(--muted); font-size: .76rem; }
.error-list .empty { background: transparent; padding: 4px 0; color: var(--muted); }
/* inbox (Settings > Admin): messages from the Contact page */
.inbox-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-link { display: inline-flex; align-items: center; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 550; white-space: nowrap; }
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--neg); color: #fff; font-size: .7rem; font-weight: 700; vertical-align: 1px; }
.nav-item .nav-badge { margin-left: auto; }
.policy-links { white-space: nowrap; font-size: .88rem; }
.policy-links a { color: var(--accent); }

/* ---------- start-up screen, sign-in extras, recovery code */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; z-index: 5; }
.boot .logo { --s: 44px; }
.boot-bar { width: 120px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; position: relative; }
.boot-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: 2px; background: var(--accent); animation: boot-slide 1s ease-in-out infinite; }
@keyframes boot-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a.brand { color: var(--text); text-decoration: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .85rem; border-radius: 4px; }
.link-btn:hover { text-decoration: underline; }
.forgot-row { margin: -6px 0 14px; text-align: right; }
.back-link { margin-bottom: 14px; }
/* new account waiting for an admin's approval */
.pending-box { text-align: center; }
.pending-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 10px; }
.pending-box .muted { margin: 10px 0 0; }
.pending-user { display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 2px; }
.pending-box .primary { margin-top: 18px; }
.pending-links { display: flex; justify-content: center; gap: 18px; margin-top: 14px; font-size: .92rem; }
.auth-card .hint a { color: var(--accent); }
.code-input { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
.code-input::placeholder { text-transform: none; letter-spacing: .04em; }
.auth { grid-template-rows: 1fr auto; }
.auth-footer { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px; padding: 24px 0 4px; font-size: .85rem; }
.auth-footer a { color: var(--muted); text-decoration: none; }
.auth-footer a:hover { color: var(--text); text-decoration: underline; }
.lang-mini { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); }
.lang-mini button { padding: 3px 8px; font-size: .74rem; font-weight: 650; border-radius: 6px; background: transparent; color: var(--muted); border: 0; }
.lang-mini button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
dialog.recovery-dialog { width: min(480px, calc(100vw - 32px)); }
.recovery-dialog h2 { font-size: 1.15rem; }
.recovery-code {
  display: block; margin: 16px 0 12px; padding: 16px; border-radius: 14px; text-align: center; user-select: all;
  font: 600 clamp(.95rem, 4vw, 1.3rem)/1.4 ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .05em;
  background: var(--surface-2); border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--border));
  overflow-wrap: normal; word-break: normal; /* if it must wrap, only at a dash, never inside a group */
}
.recovery-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.recovery-actions button { flex: 1; }
.recovery-dialog .check { margin-bottom: 14px; }
.notice-banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 12px 14px; border-radius: 14px; font-size: .9rem;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.notice-icon { font-size: 1.2rem; flex: none; }
.notice-text { flex: 1; min-width: 0; }
.notice-banner .primary { flex: none; }
@media (max-width: 560px) {
  .notice-banner { flex-wrap: wrap; }
  .notice-text { flex-basis: calc(100% - 80px); }
  .notice-banner .primary { margin-left: 32px; }
}
/* the money quote: small and faint at the very end of the ledger page */
.quote-foot {
  margin: 8px auto 0; padding-top: 18px; max-width: 560px; text-align: center; color: var(--muted);
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.quote-foot blockquote { margin: 0; font-style: italic; font-size: .8rem; line-height: 1.5; }
.quote-foot figcaption { margin-top: 3px; font-size: .72rem; opacity: .8; }
/* Settings > Contact us */
#app-contact-form > .setting-desc { margin-bottom: 14px; }
#app-contact-form .hint, #notice-form .hint { margin: -8px 0 6px; text-align: right; }
#notice-form > .setting-desc { margin-bottom: 14px; }
#notice-form textarea { min-height: 300px; }
/* the red number for unread Inbox messages, on the Settings buttons */
.bn-item { position: relative; }
.bn-item .nav-badge { position: absolute; top: 2px; left: calc(50% + 4px); margin: 0; }
.contact-done { text-align: center; }
.contact-done-icon {
  width: 44px; height: 44px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; font-weight: 700;
  font-size: 1.3rem; color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, var(--surface));
}
.contact-done .setting-desc { margin: 4px 0 14px; overflow-wrap: anywhere; }
.avatar.sm { width: 34px; height: 34px; font-size: .95rem; }
.tag { font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag-accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.tag-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* ---------- compact density */
:root[data-density="compact"] .container { gap: 12px; padding-top: 14px; }
:root[data-density="compact"] .grid { gap: 12px; }
:root[data-density="compact"] .card { padding: 12px 14px; }
:root[data-density="compact"] .hero { padding: 16px 18px; gap: 16px; }
:root[data-density="compact"] .card-head { margin-bottom: 8px; }
:root[data-density="compact"] .tx-table td { padding: 6px 10px; }
:root[data-density="compact"] .bars { gap: 8px; }
:root[data-density="compact"] label { margin-bottom: 8px; }
:root[data-density="compact"] input, :root[data-density="compact"] select { padding: 6px 10px; }

/* ---------- settings: sidebar + panels */
dialog.settings-dialog {
  padding: 0; width: min(880px, calc(100vw - 32px)); height: min(640px, calc(100vh - 48px)); overflow: hidden;
}
.settings-shell { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.settings-nav {
  background: var(--surface-2); border-right: 1px solid var(--border); padding: 18px 10px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.settings-nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 12px; }
.settings-nav-head h2 { margin: 0; font-size: 1.1rem; }
.nav-close { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.nav-item[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); }
.nav-item:focus { outline: none; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-item[aria-current="page"] .nav-label { color: var(--accent); }
.nav-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface); font-size: 1rem; flex: none; }
.nav-label { display: block; font-weight: 600; font-size: .9rem; }
.nav-desc { display: block; font-size: .75rem; color: var(--muted); }
/* the Admin part of the Settings list */
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-group[hidden] { display: none; }
.nav-heading { padding: 0 10px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
/* Settings > Inbox: subject rows like an email inbox, and the opened message */
.mail-list { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--border); }
.mail-list .empty { padding: 14px 4px; color: var(--muted); font-size: .88rem; }
.mail-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; text-align: left; background: transparent;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0; color: var(--muted); font-size: .9rem;
}
.mail-row:hover { background: var(--surface-2); }
.mail-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.mail-row.unread { color: var(--text); font-weight: 700; }
.mail-row.unread .mail-dot { background: var(--accent); }
.mail-row.plain { color: var(--text); }
.mail-row .tag { flex: none; font-weight: 600; }
.mail-from { flex: none; max-width: 30%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }
.mail-subject { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.send-tabs { margin-top: 16px; }
.send-tabs ~ .group { border-bottom: 0; }
@media (max-width: 560px) { .mail-row .tag.mail-topic { display: none; } }
.mail-date { flex: none; font-size: .78rem; font-weight: 500; color: var(--muted); }
.reader-subject { margin: 12px 0 6px; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.reader-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.reader-text { margin: 16px 0; white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; font-size: .9rem; }
.reader-meta > span:empty { display: none; }

.settings-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.settings-head { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.settings-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.settings-back { display: none; }
.saved-note { font-size: .8rem; color: var(--pos); white-space: nowrap; }
.saved-note.error-note { color: var(--neg); white-space: normal; }
.settings-body { padding: 8px 22px 24px; overflow-y: auto; flex: 1; }

.group { padding: 16px 0; border-bottom: 1px solid var(--border); }
.group:last-child { border-bottom: 0; }
.group-title { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; }
.setting-row + .setting-row { border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); }
.setting-row.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.setting-label { font-weight: 600; font-size: .9rem; }
.setting-desc { font-size: .8rem; color: var(--muted); margin: 2px 0 0; }
.setting-value { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.badge-ok { color: var(--pos); font-weight: 600; }
.badge-warn { color: var(--warn); font-weight: 600; }
.danger-zone .group-title { color: var(--neg); }
.danger-zone { border: 1px solid color-mix(in srgb, var(--neg) 40%, var(--border)); border-radius: 10px; padding: 14px 16px; margin-top: 16px; }
.danger-zone .setting-row { padding: 0; }

.profile { display: flex; align-items: center; gap: 14px; padding: 16px 0 6px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: 1.4rem; font-weight: 700;
}
.profile-name { font-size: 1.15rem; font-weight: 700; }

/* segmented and card choices */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; flex: none; }
.seg button { background: transparent; border: 0; padding: 5px 11px; border-radius: 7px; font-size: .85rem; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.choice-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.font-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.choice {
  display: grid; justify-items: center; gap: 4px; padding: 10px 6px; background: transparent;
  border: 1px solid var(--border); border-radius: 10px; font-size: .8rem; color: var(--text);
}
.choice:hover { background: var(--surface-2); }
.choice[aria-checked="true"], .theme-option[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.fs-sample { font-weight: 700; line-height: 1; height: 26px; display: grid; place-items: end center; }
.fs-s { font-size: 14px; } .fs-m { font-size: 17px; } .fs-l { font-size: 21px; } .fs-xl { font-size: 25px; }
.font-sample { font-size: 1.05rem; }
.ff-system { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.ff-serif { font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif; }
.ff-rounded { font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif; }
.ff-mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace; }
.ff-readable { font-family: "Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", sans-serif; }
.pref-select { width: auto; min-width: 190px; }

.format-preview {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 14px 16px;
  border-radius: 10px; background: var(--surface-2);
}
.format-amount { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- responsive */
/* ---------- interactive touches: chips, quick dates, toast, motion */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.amount-input { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 10rem; overflow-y: auto; padding: 2px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: .84rem; font-weight: 500;
  transition: transform .12s, background-color .15s, border-color .15s;
}
.cat-chip:hover { background: var(--surface-2); }
.cat-chip:active { transform: scale(.94); }
.cat-chip.on { background: var(--surface-2); font-weight: 650; border-width: 2px; padding: 3px 9px 3px 3px; }
.cat-chip.add { padding: 4px 11px; color: var(--muted); border-style: dashed; }
.cat-chip:focus-visible, .pill:focus-visible, .chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.date-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date-row input { flex: 1 1 9rem; width: auto; }
.quick-dates { display: flex; gap: 6px; }
.pill {
  padding: 5px 11px; border-radius: 99px; border: 1px solid var(--border); background: transparent;
  font-size: .82rem; color: var(--muted); transition: background-color .15s, color .15s;
}
.pill:hover { background: var(--surface-2); color: var(--text); }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filter-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--text); padding: 3px 10px 3px 3px; }
.filter-pill .x { color: var(--muted); display: inline-grid; place-items: center; }
.filter-pill .x .glyph { width: 12px; height: 12px; }

.shortcut-hint { margin: 10px 0 0; font-size: .75rem; color: var(--muted); text-align: center; }
kbd { font: inherit; font-size: .72rem; padding: 0 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
@media (hover: none) { .shortcut-hint { display: none; } }

/* month label slides in when the month changes */
@keyframes tick { from { opacity: 0; transform: translateY(5px); } }
.month-label.tick { animation: tick .25s ease-out; display: inline-block; }

/* bars grow from the left / from the floor */
@keyframes grow { from { transform: scaleX(0); } }
.fill { transform-origin: left center; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { transform: scaleY(0); } }
.trend rect.in, .trend rect.out { transform-box: fill-box; transform-origin: bottom; animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }

/* trend chart: each month is one big clickable area */
.trend-card { position: relative; }
.head-hint { font-weight: 400; font-size: .8rem; }
.trend .slot { fill: transparent; cursor: pointer; outline: none; }
.trend .slot:focus-visible { stroke: var(--accent); stroke-width: 2; }
.trend .slot-bg { fill: transparent; transition: fill .15s; }
.trend .slot-bg.sel { fill: color-mix(in srgb, var(--accent) 11%, transparent); }
.trend .slot-bg.hover { fill: color-mix(in srgb, var(--text) 7%, transparent); }
.trend-tip { display: grid; gap: 1px; line-height: 1.35; }
/* time-range picker and the 1D day view */
.range-picker button { padding: 5px 10px; font-variant-numeric: tabular-nums; }
.trend-legend { margin: -6px 0 6px; }
.trend-day { display: grid; gap: 14px; min-height: 220px; align-content: start; }
.trend-day-totals {
  display: grid; gap: 12px; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 10px 12px; margin: 0 -12px; width: calc(100% + 24px); border-radius: 12px; color: inherit; font-weight: 400;
}
.trend-day-totals:hover { background: var(--surface-2); }
.trend-day-totals .bar-name { gap: 8px; }
.trend-day-totals .sw { margin: 0; }
.trend-day-head { margin: 6px 0 0; font-size: .85rem; color: var(--muted); font-weight: 600; }

/* transaction list: day headers, clickable rows, a flash on new or changed rows */
.tx-table .day-row td { padding: 14px 10px 6px; font-size: .78rem; font-weight: 650; color: var(--muted); }
.tx-table tr.day-row:first-child td { padding-top: 6px; }
.day-cell { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.tx-row { cursor: pointer; transition: background-color .15s; }
.tx-row:hover { background: var(--surface-2); }
.tx-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chip-btn { background: transparent; border: 0; padding: 3px 9px 3px 3px; margin: -3px 0 -3px -3px; border-radius: 99px; font-weight: 500; }
.chip-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
@keyframes flash { from { background-color: color-mix(in srgb, var(--accent) 30%, transparent); } }
.tx-row.flash { animation: flash 1.8s ease-out; }
/* press and hold to move a row within its day */
.tx-row { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tx-row.lifted {
  position: relative; z-index: 1; cursor: grabbing; background: var(--surface-2);
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, .45), inset 3px 0 0 var(--accent);
}
#tx-body.dragging { cursor: grabbing; }
#tx-body.dragging .tx-row:not(.lifted) { opacity: .7; }
/* the date filter's From – To boxes */
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.filters .date-range input { width: auto; padding: 6px 8px; }

/* toast: a popover, so it also shows above open windows */
.toast {
  inset: auto 0 24px; margin: 0 auto; width: max-content; max-width: calc(100vw - 32px);
  border: 0; padding: 8px 8px 8px 18px; border-radius: 14px; background: var(--text); color: var(--bg);
  box-shadow: var(--pop-shadow); font-size: .9rem; align-items: center; gap: 12px;
}
.toast:popover-open { display: flex; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade-in { from { opacity: 0; } }
.toast-undo {
  background: transparent; color: inherit; border: 0; padding: 6px 10px; font-weight: 700;
  font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
}
.toast-undo:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }

/* guidebook: top-bar buttons and the pop-up (same frame as Settings) */
.guide-btn { display: inline-flex; align-items: center; gap: 6px; }
/* medium screens: just the 📖, so the top bar stays on one line */
@media (max-width: 1100px) { .guide-btn .guide-label { display: none; } .guide-btn { padding-left: 12px; padding-right: 12px; } }
.month-label { white-space: nowrap; }
.guide-phone-btn { display: none; flex: none; width: 32px; height: 32px; font-weight: 700; font-size: 1rem; }
@media (max-width: 720px) { .guide-phone-btn { display: inline-grid; } }
.guide-topics { display: grid; gap: 2px; }
.guide-topics .nav-item { align-items: center; }
.guide-body { line-height: 1.6; overflow-x: hidden; }
.guide-body > * { max-width: 70ch; }
.guide-body p { margin: 12px 0; }
.guide-body h3 { margin: 22px 0 6px; font-size: .95rem; }
.guide-intro { color: var(--muted); }
.guide-steps, .guide-list { margin: 10px 0; padding-left: 1.4em; }
.guide-steps li, .guide-list li { margin: 5px 0; }
.guide-steps li::marker { color: var(--accent); font-weight: 700; }
.guide-chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.guide-chips li { margin: 0; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-size: .85rem; }
.guide-chips.guide-plain { display: grid; gap: 4px; }
.guide-chips.guide-plain li { border-radius: 9px; padding: 6px 10px; }
.guide-tip { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); }
.guide-example {
  display: grid; gap: 2px; margin: 12px 0; padding: 10px 12px; border-radius: 10px;
  border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.guide-example-label { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.guide-faq { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.guide-faq summary { cursor: pointer; font-weight: 600; }
.guide-faq p { margin: 8px 0 0; }

/* amount box tip and the import window */
.amount-label { margin-bottom: 4px; }
.amount-hint { margin: 0 0 14px; }
.import-dialog { width: min(720px, calc(100vw - 32px)); }
.import-summary { margin: -6px 0 14px; font-size: .88rem; }
.import-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
.import-grid .span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.import-preview .tx-table th { position: sticky; top: 0; background: var(--surface); }
@media (max-width: 560px) { .import-grid { grid-template-columns: 1fr; } }

/* pointing at things: a small, quick answer (only on devices with a pointer, so nothing sticks on a phone) */
@media (hover: hover) {
  .primary:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 10px 22px -8px color-mix(in srgb, var(--accent) 80%, transparent); }
  .ghost:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
  .card:hover { border-color: color-mix(in srgb, var(--accent) 28%, var(--border)); }
  .hero:hover { box-shadow: var(--shadow), 0 16px 34px -18px color-mix(in srgb, var(--accent) 70%, transparent); }
  .stat:hover { transform: translateY(-2px); }
  .cat-chip:hover, .theme-option:hover { transform: translateY(-1px); }
  .swatch { transition: transform .12s; }
  .swatch:hover { transform: scale(1.15); }
  .tx-row:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
  .mail-row:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
  .nav-item:hover .nav-icon { transform: scale(1.08); }
  .nav-icon { transition: transform .15s; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- phones only: bottom bar and the Add sheet (hidden on bigger screens) */
.bottom-nav, .sheet-handle, .sheet-close, .sheet-backdrop { display: none; }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 1000px) {
  .user-name { display: none; }
  /* tablets: the chart joins the right column beside the add form; the list goes full width below */
  .grid { grid-template-columns: 1fr 1fr; grid-template-areas: "add spend" "add budget" "add trend" "activity activity"; grid-template-rows: auto auto 1fr auto; }
  #spend-card, #budgets-card { align-self: start; }
  .grid > .trend-card { align-self: stretch; display: flex; flex-direction: column; }
  .grid > .trend-card .trend { margin: auto 0; } /* chart centred in the taller card */
  .head-hint { display: none; }
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .stat:first-child { padding-left: var(--stat-first-left); }
}
@media (max-width: 720px) {
  /* one slim row: ledger on the left, month on the right. Settings and Log out live in the bottom bar. */
  .topbar { padding: 8px 12px; flex-wrap: nowrap; gap: 8px; }
  .topbar .brand, .topbar .user { display: none; }
  .topbar-left { flex: 1 1 auto; min-width: 0; }
  .ledger-select { max-width: 100%; min-width: 0; font-size: .88rem; padding: 7px 10px; text-overflow: ellipsis; }
  .month-label { min-width: 0; font-size: .9rem; }
  .month-nav .icon-btn { width: 30px; height: 30px; }
  .month-nav { flex: none; }

  .container { padding: 14px 14px calc(104px + env(safe-area-inset-bottom)); gap: 14px; }
  .card { padding: 18px; border-radius: 20px; }
  .grid { grid-template-columns: 1fr; gap: 14px; grid-template-areas: none; grid-template-rows: none; }
  .grid > .add-card, .grid > #spend-card, .grid > #budgets-card, .grid > .trend-card, .grid > #activity { grid-area: auto; }

  /* hero: big net on top, income | expenses side by side, balance underneath */
  .hero { padding: 22px 20px 18px; gap: 18px; border-radius: 24px; }
  .hero-value { font-size: clamp(1.9rem, 9vw, 2.4rem); }
  .hero-stats { grid-template-columns: 1fr 1fr; row-gap: max(var(--stat-gap), 14px); }
  .stat { padding: var(--stat-pad-phone); }
  .stat:first-child { padding-left: var(--stat-first-left); }
  .stat:nth-child(3) {
    grid-column: 1 / -1; padding: var(--stat3-pad); border-left: 0;
    border-top: 1px solid var(--stat-rule);
    grid-template-columns: 1fr auto; align-items: baseline;
  }
  .stat:nth-child(3) .stat-sub { grid-column: 1 / -1; margin-top: -2px; }
  .stat-value { font-size: 1.08rem; }

  /* Add transaction becomes a sheet that slides up from the bottom */
  .add-card {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 26px 26px 0 0; border-bottom: 0;
    padding: 0 18px calc(20px + env(safe-area-inset-bottom));
    box-shadow: var(--pop-shadow);
    transform: translateY(110%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  }
  body.sheet-open .add-card { transform: none; }
  body.sheet-open { overflow: hidden; }
  .sheet-handle { display: grid; place-items: center; height: 26px; margin: 0 -18px 4px; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 99px; background: var(--border); }
  .sheet-close { display: inline-grid; }
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(10, 12, 16, .45); backdrop-filter: blur(2px); animation: fade-in .2s ease-out;
  }
  .sheet-backdrop[hidden] { display: none; }
  .cat-chips { max-height: none; }
  .amount-input { font-size: 1.6rem; padding: 12px 14px; }

  /* bottom bar, within thumb reach */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  }
  .bn-item {
    display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; border: 0; background: transparent;
    color: var(--muted); font-size: .68rem; font-weight: 600; border-radius: 12px;
  }
  .bn-item[aria-current="page"] { color: var(--accent); }
  .bn-add {
    justify-self: center; width: 54px; height: 54px; transform: translateY(-14px); padding: 0; border-radius: 50%;
    display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 0 0 5px var(--bg), 0 10px 22px -6px color-mix(in srgb, var(--accent) 80%, transparent);
  }
  .bn-add:active:not(:disabled) { transform: translateY(-14px) scale(.94); }
  .bn-add svg { width: 26px; height: 26px; stroke-width: 2.2; }
  .bottom-nav { height: calc(60px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }

  #tx-body .row-actions button:first-child { display: none; } /* tapping the row edits it */
  .filters, .filters input { width: 100%; }
  .filters select { flex: 1; }
  .date-range { width: 100%; }
  .filters .date-range input { flex: 1; min-width: 0; }
  .tx-table .note { display: none; }
  /* room for the Date column on a narrow screen */
  #activity .tx-table th, #activity .tx-table td { padding-left: 5px; padding-right: 5px; }
  #activity .tx-table .date { font-size: .78rem; }
  #tx-body .row-actions button { padding: 4px 4px; }
  #activity .tx-table th:nth-child(3), .import-preview .tx-table th:nth-child(3) { display: none; }
  .head-hint { display: none; }
  .month-label { min-width: 0; }
  .cat-count { display: none; }

  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-user { flex-wrap: wrap; }
  .admin-user-actions { width: 100%; justify-content: flex-start; padding-left: 46px; }

  /* Category detail on phones: full screen, chart above the budget. */
  dialog.cat-detail { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .cd-top { grid-template-columns: 1fr; gap: 14px; padding: 14px 16px; }
  .cd-head, .cd-list-head { padding-left: 16px; padding-right: 16px; }
  .cd-list { padding: 0 16px 16px; }

  /* Settings on phones: the section list first, then one panel with a back button. */
  dialog.settings-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { border-right: 0; padding: 14px 12px; }
  .nav-close { display: grid; }
  .nav-item { padding: 12px 10px; }
  .settings-shell.show-panel .settings-nav { display: none; }
  .settings-shell:not(.show-panel) .settings-main { display: none; }
  .settings-back { display: grid; }
  .settings-head, .settings-body { padding-left: 16px; padding-right: 16px; }
  .setting-row:not(.stack) { flex-wrap: wrap; }
  .choice-row { grid-template-columns: repeat(2, 1fr); }
  .font-grid, .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .pref-select { width: 100%; }
  .cat-item { grid-template-columns: auto 1fr auto; }
}
