:root {
  color-scheme: light dark;
  --bg: oklch(95.8% .010 250);
  --bg-2: oklch(91.8% .018 250);
  --surface: oklch(99.2% .003 250);
  --surface-2: oklch(94.8% .010 250);
  --surface-3: oklch(89.5% .017 250);
  --card: var(--surface);
  --card2: var(--surface-2);
  --card3: var(--surface-3);
  --ink: oklch(19% .028 255);
  --text: oklch(22% .024 255);
  --sub: oklch(43% .030 255);
  --hint: oklch(56% .026 255);
  --line: oklch(84% .022 255);
  --line2: oklch(78% .030 255);
  --line-strong: oklch(66% .040 255);
  --brand: oklch(43% .145 252);
  --brand-2: oklch(50% .140 238);
  --brand-soft: oklch(90.5% .042 248);
  --brand-dim: oklch(43% .145 252 / .12);
  --brand-ring: oklch(46% .160 258 / .30);
  --gold: var(--brand);
  --gold-dim: var(--brand-dim);
  --gold-soft: var(--brand-soft);
  --gold-ring: var(--brand-ring);
  --credit: oklch(52% .135 154);
  --credit-dim: oklch(92% .045 154);
  --debit: oklch(56% .185 28);
  --debit-dim: oklch(93% .055 28);
  --warning: oklch(66% .145 72);
  --blue: oklch(56% .140 250);
  --blue-dim: oklch(92% .045 250);
  --purple: oklch(55% .135 305);
  --amber: oklch(68% .140 78);
  --teal: oklch(55% .115 188);
  --shadow-sm: 0 1px 1px oklch(20% .035 255 / .07);
  --shadow-md: 0 6px 16px oklch(28% .055 255 / .10);
  --mono: 'IBM Plex Mono', 'SF Mono', 'SFMono-Regular', ui-monospace, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --r: 6px;
  --r2: 8px;
  --r3: 10px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

body[data-theme='dark'] {
  --bg: oklch(16% .020 252);
  --bg-2: oklch(12.5% .018 252);
  --surface: oklch(20.5% .024 252);
  --surface-2: oklch(24.5% .026 252);
  --surface-3: oklch(30% .030 252);
  --card: var(--surface);
  --card2: var(--surface-2);
  --card3: var(--surface-3);
  --ink: oklch(96% .006 250);
  --text: oklch(91% .009 250);
  --sub: oklch(74% .018 250);
  --hint: oklch(61% .022 250);
  --line: oklch(33% .028 252);
  --line2: oklch(42% .034 252);
  --line-strong: oklch(57% .045 252);
  --brand: oklch(68% .125 242);
  --brand-2: oklch(76% .118 232);
  --brand-soft: oklch(31% .058 245);
  --brand-dim: oklch(68% .125 242 / .16);
  --brand-ring: oklch(68% .125 242 / .34);
  --credit: oklch(72% .120 154);
  --credit-dim: oklch(31% .054 154);
  --debit: oklch(70% .155 28);
  --debit-dim: oklch(32% .060 28);
  --warning: oklch(78% .130 78);
  --blue: oklch(72% .118 250);
  --blue-dim: oklch(31% .052 250);
  --purple: oklch(74% .110 305);
  --amber: oklch(78% .130 78);
  --teal: oklch(72% .100 188);
  --shadow-sm: none;
  --shadow-md: 0 10px 24px oklch(5% .010 250 / .32);
}

@media (prefers-color-scheme: dark) {
  body[data-theme='system'] {
    --bg: oklch(16% .020 252);
    --bg-2: oklch(12.5% .018 252);
    --surface: oklch(20.5% .024 252);
    --surface-2: oklch(24.5% .026 252);
    --surface-3: oklch(30% .030 252);
    --card: var(--surface);
    --card2: var(--surface-2);
    --card3: var(--surface-3);
    --ink: oklch(96% .006 250);
    --text: oklch(91% .009 250);
    --sub: oklch(74% .018 250);
    --hint: oklch(61% .022 250);
    --line: oklch(33% .028 252);
    --line2: oklch(42% .034 252);
    --line-strong: oklch(57% .045 252);
    --brand: oklch(68% .125 242);
    --brand-2: oklch(76% .118 232);
    --brand-soft: oklch(31% .058 245);
    --brand-dim: oklch(68% .125 242 / .16);
    --brand-ring: oklch(68% .125 242 / .34);
    --credit: oklch(72% .120 154);
    --credit-dim: oklch(31% .054 154);
    --debit: oklch(70% .155 28);
    --debit-dim: oklch(32% .060 28);
    --warning: oklch(78% .130 78);
    --blue: oklch(72% .118 250);
    --blue-dim: oklch(31% .052 250);
    --purple: oklch(74% .110 305);
    --amber: oklch(78% .130 78);
    --teal: oklch(72% .100 188);
    --shadow-sm: none;
    --shadow-md: 0 10px 24px oklch(5% .010 250 / .32);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); overflow: hidden; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}
button:disabled { opacity: .56; cursor: not-allowed; }
::placeholder { color: var(--hint); opacity: 1; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.screen { display: none; }

/* Auth */
#auth-screen {
  display: block;
  height: 100vh;
  min-height: 100vh;
  overflow-y: auto;
  padding: 0;
  background: var(--bg);
}
.auth-shell {
  width: 100%;
}
.auth-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: max(10px, var(--safe-t)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.auth-nav-brand {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.035em;
  text-decoration: none;
}
.auth-nav-links {
  display: none;
  align-items: center;
  gap: 6px;
}
.auth-nav-links button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.auth-nav-links button:hover { background: var(--surface-2); color: var(--ink); }
.auth-nav-action { min-height: 34px; padding-inline: 12px; }
.auth-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  min-height: calc(100vh - 64px);
  min-width: 0;
  align-content: center;
  padding: 48px 18px max(56px, calc(var(--safe-b) + 24px));
}
.auth-hero-copy {
  min-width: 0;
}
.auth-product-mark {
  color: var(--brand);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.auth-title {
  max-width: 680px;
  margin-top: 14px;
  color: var(--ink);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.auth-sub {
  max-width: 620px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--sub);
}
.auth-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}
.auth-trust-row span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.auth-hero-product {
  min-width: 0;
}
.auth-phone-frame {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface) 92%, white), var(--surface-2));
  box-shadow: var(--shadow-md);
}
.auth-phone-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 8px 6px 14px;
}
.auth-phone-top span {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.auth-phone-top strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 38px;
  line-height: .95;
  letter-spacing: -.04em;
}
.auth-drain-preview {
  height: 8px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
  margin: 0 6px 12px;
}
.auth-drain-preview span {
  display: block;
  width: 41%;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}
.auth-preview-ledger {
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.auth-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.auth-preview-row:last-child { border-bottom: 0; }
.auth-preview-row em {
  color: var(--hint);
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}
.auth-preview-row strong { color: var(--debit); font-family: var(--mono); font-weight: 600; }
.auth-preview-row.credit strong { color: var(--credit); }
.auth-preview-row.imported span,
.auth-statement-row.imported span { color: var(--brand); }
.auth-statement-row.imported strong { color: var(--brand); }
.auth-preview-row.muted { background: var(--surface-2); color: var(--sub); }
.auth-phone-frame .auth-preview-ledger { margin-top: 0; }
.auth-market-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 6px 12px;
}
.auth-market-strip div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.auth-market-strip span {
  display: block;
  color: var(--hint);
  font-size: 11px;
  font-weight: 700;
}
.auth-market-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
}
.auth-mini-plan {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.auth-mini-plan div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.auth-mini-plan span {
  display: block;
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
}
.auth-mini-plan strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
}
.auth-feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}
.auth-feature {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.auth-feature strong { display: block; color: var(--ink); font-size: 13px; font-weight: 700; }
.auth-feature span { display: block; margin-top: 5px; color: var(--sub); font-size: 12px; line-height: 1.45; }
.auth-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}
.auth-hero-actions .btn { min-width: 108px; }
.auth-ledger-section,
.auth-how-section,
.auth-plan-section,
.auth-feature-band,
.auth-security-section,
.auth-entry-section {
  display: grid;
  align-items: center;
  padding: 64px 18px;
  border-top: 1px solid var(--line);
}
.auth-ledger-section,
.auth-plan-section,
.auth-security-section {
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  background: var(--bg);
}
.auth-how-section,
.auth-feature-band {
  background: var(--bg-2);
}
.auth-section-copy {
  width: min(100%, 620px);
}
.auth-section-copy.centered {
  width: min(100%, 720px);
  margin: 0 auto;
  text-align: center;
}
.auth-section-label {
  color: var(--brand);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}
.auth-section-copy h2,
.auth-feature-panel h2 {
  margin-top: 10px;
  color: var(--ink);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.03em;
  text-wrap: balance;
}
.auth-section-copy p {
  margin-top: 12px;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.62;
}
.auth-statement {
  width: min(100%, 560px);
  justify-self: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.auth-statement-head,
.auth-statement-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.auth-statement-head {
  grid-template-columns: 1fr auto;
  background: var(--surface-2);
}
.auth-statement-head span,
.auth-statement-row span {
  color: var(--ink);
  font-weight: 700;
}
.auth-statement-head strong,
.auth-statement-row strong,
.auth-statement-row em {
  font-family: var(--mono);
  font-style: normal;
  font-weight: 600;
}
.auth-statement-head strong,
.auth-statement-row em { color: var(--sub); font-size: 12px; }
.auth-statement-row strong { color: var(--debit); font-size: 13px; }
.auth-statement-row.total { border-bottom: 0; background: var(--surface-2); }
.auth-statement-row.total strong { color: var(--credit); }
.auth-details-inner {
  display: grid;
  width: min(100%, 980px);
  margin: 28px auto 0;
  gap: 12px;
}
.auth-detail-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.auth-detail-block span {
  color: var(--brand);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.auth-detail-block h3 {
  margin-top: 10px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.025em;
}
.auth-detail-block p {
  margin-top: 9px;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.55;
}
.auth-plan-section {
  align-items: center;
}
.auth-week-preview {
  width: min(100%, 640px);
  justify-self: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.auth-week-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 12px;
}
.auth-week-head span {
  display: block;
  color: var(--hint);
  font-size: 11px;
  font-weight: 700;
}
.auth-week-head strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
}
.auth-week-head button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.auth-week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(116px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.auth-week-grid div {
  min-height: 126px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface-2);
}
.auth-week-grid div.imported {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}
.auth-week-grid span,
.auth-week-grid small {
  display: block;
  color: var(--hint);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.auth-week-grid strong {
  display: block;
  margin: 22px 0 6px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}
.auth-week-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}
.auth-week-foot span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
}
.auth-feature-band {
  align-items: start;
}
.auth-feature-panel {
  width: min(100%, 760px);
  margin: 0 auto;
}
.auth-feature-band .auth-feature-grid {
  width: min(100%, 1080px);
  margin: 24px auto 0;
}
.auth-security-list {
  display: grid;
  gap: 10px;
  width: min(100%, 520px);
  justify-self: center;
}
.auth-security-list div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.auth-security-list strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}
.auth-security-list span {
  display: block;
  margin-top: 5px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.auth-entry-section {
  justify-items: center;
  background: var(--bg);
}
.auth-final-copy { margin-bottom: 24px; }
.auth-final-actions { justify-content: center; }
.auth-box {
  width: min(100%, 380px);
  justify-self: center;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--shadow-md);
}
.auth-box-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px 12px 6px; }
.auth-box-title { color: var(--ink); font-size: 20px; font-weight: 700; }
.auth-box-sub { margin-top: 4px; color: var(--sub); font-size: 12px; line-height: 1.45; }
.auth-config-msg {
  margin: 10px 12px 2px;
  padding: 10px 12px;
  border: 1px solid var(--warning);
  border-radius: var(--r2);
  background: color-mix(in oklch, var(--warning) 14%, var(--surface));
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}
.oauth-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 6px; }
.oauth-btn {
  min-height: 42px;
  border: 1px solid var(--line2);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.oauth-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.auth-divider { display: flex; align-items: center; gap: 9px; padding: 5px 12px 10px; color: var(--hint); font-size: 11px; }
.auth-divider::before,
.auth-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.auth-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.asb {
  flex: 1;
  min-height: 38px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.asb.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
#f-login, #f-signup { padding: 12px; }
.auth-footnote { padding: 0 12px 12px; color: var(--hint); font-size: 11px; line-height: 1.45; }
.auth-legal-note a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}
.auth-legal-note a:hover { text-decoration: underline; }

.site-footer {
  display: grid;
  gap: 18px;
  padding: 32px 18px max(32px, calc(var(--safe-b) + 18px));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-footer p {
  max-width: 520px;
  margin-top: 8px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.55;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.site-footer a {
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.site-footer a:hover { color: var(--ink); }
.site-footer small {
  color: var(--hint);
  font-size: 12px;
}

.app-auth-screen {
  display: none;
  min-height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}
.app-auth-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: max(18px, var(--safe-t)) 18px max(28px, calc(var(--safe-b) + 20px));
}
.app-auth-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 26px;
  min-height: calc(100vh - 76px);
  padding: 32px 0;
}
.app-auth-statement {
  width: min(100%, 560px);
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.app-auth-box {
  align-self: center;
  justify-self: center;
}
.app-demo-entry {
  padding: 12px;
}

.legal-page {
  min-height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}
.legal-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: max(22px, var(--safe-t)) 18px max(40px, calc(var(--safe-b) + 24px));
}
.legal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-bottom: 24px;
}
.legal-nav a {
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.legal-doc {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.legal-doc h1 {
  color: var(--ink);
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: -.03em;
}
.legal-doc h2 {
  margin-top: 24px;
  color: var(--ink);
  font-size: 18px;
}
.legal-doc p,
.legal-doc li {
  color: var(--sub);
  font-size: 14px;
  line-height: 1.65;
}
.legal-doc p { margin-top: 12px; }
.legal-doc .legal-meta {
  color: var(--hint);
  font-size: 12px;
}
.legal-doc a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}
.legal-doc a:hover { text-decoration: underline; }
.legal-doc ul {
  margin: 10px 0 0 18px;
}
.fg { margin-bottom: 14px; }
.fg label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
}
.fi {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  appearance: none;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}
.fi:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-dim); }
.amsg { min-height: 18px; margin: 0 0 10px; color: var(--sub); font-size: 12px; text-align: center; }
.amsg.err { color: var(--debit); }
.amsg.ok { color: var(--credit); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid var(--line2);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--brand); border-color: var(--brand); color: white; box-shadow: 0 1px 2px oklch(30% .1 258 / .16); }
.btn-gold:hover { background: var(--brand-2); border-color: var(--brand-2); color: white; }
.btn-ghost { background: var(--surface); color: var(--sub); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { border-color: transparent; background: transparent; color: var(--sub); }
.btn-danger:hover { background: var(--debit-dim); color: var(--debit); }
.btn-full { width: 100%; }

/* App shell */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.topbar {
  flex-shrink: 0;
  padding: max(var(--safe-t), 12px) 14px 0;
  background: color-mix(in oklch, var(--surface) 92%, var(--bg));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 color-mix(in oklch, var(--surface) 80%, white 20%);
}
.topbar-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding-bottom: 8px;
}
.topbar-brand {
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.04em;
  text-decoration: none;
  cursor: pointer;
}
.topbar-brand:hover { color: var(--brand); }
.topbar-user { display: flex; align-items: center; gap: 9px; }
.topbar-site-link,
.setup-site-link {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.topbar-site-link:hover,
.setup-site-link:hover { border-color: var(--line-strong); color: var(--ink); }
.u-av {
  width: 32px;
  height: 32px;
  border-radius: var(--r2);
  border: 1px solid var(--line2);
  background: var(--surface-2);
  color: var(--sub);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.u-av:hover { border-color: var(--brand); color: var(--brand); }
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--credit);
  box-shadow: 0 0 0 3px var(--credit-dim);
}
.sync-dot.syncing { background: var(--warning); box-shadow: 0 0 0 3px oklch(94% .055 72); animation: pulse 1.1s ease infinite; }
.sync-dot.offline { background: var(--hint); box-shadow: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.balance-hero {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.balance-kicker {
  margin-bottom: 6px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.balance-amount {
  display: flex;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 50px;
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.045em;
  color: var(--ink);
  transition: color .2s ease;
}
.balance-amount .currency { margin-left: 8px; color: var(--sub); font-size: 18px; letter-spacing: 0; }
.balance-amount.low { color: var(--debit); }
.balance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}
.balance-meta-item {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--sub);
  font-size: 12px;
}
.balance-meta-item strong { margin-left: 4px; color: var(--ink); font-family: var(--mono); font-weight: 600; }
.balance-drain {
  position: relative;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
}
.balance-drain-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s ease;
}

.tab-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 7px 0 8px;
  border-top: 1px solid var(--line);
}
.tab-btn {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  border: 0;
  border-radius: var(--r2);
  background: transparent;
  color: var(--sub);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.tab-btn svg { opacity: .72; }
.tab-btn.active { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.tab-btn:hover { background: var(--surface-2); color: var(--ink); }

.app-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.app-body::-webkit-scrollbar { width: 0; height: 0; }
.tab-page { display: none; padding-bottom: calc(var(--safe-b) + 26px); }
.tab-page.active { display: block; }
#tab-assistant.active { display: flex; flex: 1; min-height: 0; overflow: hidden; padding-bottom: 0; flex-direction: column; }

/* Common sections */
.sec-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 9px;
}
.sec-hdr-l, .stat-section-title, .settings-section-title, .hm-title, .donut-title {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}
.sec-hdr-r { display: flex; align-items: center; gap: 7px; }
.section-action-btn {
  min-height: 32px;
  padding: 7px 12px;
  font-size: 12px;
}

/* Account */
.briefing-card, .timer-banner, .timer-big, .hm-outer, .donut-outer, .assistant-gate-card, .day-plan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.briefing-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 14px 16px 0;
  padding: 14px;
  border-radius: var(--r3);
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease;
}
.briefing-card:hover { border-color: var(--brand-ring); background: var(--surface-2); }
.briefing-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.briefing-dismiss:hover { background: var(--surface-2); color: var(--ink); }
.briefing-icon {
  min-width: 58px;
  padding: 5px 7px;
  border-radius: var(--r);
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}
.briefing-text { color: var(--sub); font-size: 13px; line-height: 1.55; }
.briefing-text strong { color: var(--ink); font-weight: 600; }
.briefing-cta { margin-top: 5px; color: var(--brand); font-size: 12px; font-weight: 600; }

.timer-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 16px 0;
  padding: 12px 13px;
  border-radius: var(--r3);
}
.timer-banner-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--debit); box-shadow: 0 0 0 4px var(--debit-dim); animation: pulse 1.2s ease infinite; }
.timer-banner-time { font-family: var(--mono); font-size: 21px; font-weight: 600; color: var(--ink); }
.timer-banner-sub { margin-top: 2px; color: var(--sub); font-size: 12px; }
.timer-banner-btn {
  margin-left: auto;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--debit);
  border-radius: var(--r);
  background: var(--debit-dim);
  color: var(--debit);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.day-plan-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 14px 16px 0;
}
.day-plan-card {
  min-height: 112px;
  padding: 12px;
  border-radius: var(--r3);
}
.day-plan-card.primary {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}
.day-plan-label {
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
}
.day-plan-value {
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-plan-sub {
  min-height: 30px;
  margin-top: 5px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.3;
}
.day-plan-action,
.day-plan-link {
  min-height: 30px;
  margin-top: 9px;
  padding: 6px 10px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.day-plan-action {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
}
.day-plan-link {
  border: 1px solid var(--line2);
  background: var(--surface);
  color: var(--sub);
}
.day-plan-link:hover { color: var(--ink); border-color: var(--line-strong); }
.day-plan-card.meter { min-height: 86px; }
.day-plan-meter {
  height: 7px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
}
.day-plan-meter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .3s ease;
}
.day-plan-meter.danger span { background: var(--debit); }

.budget-scroll { overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.budget-scroll::-webkit-scrollbar { display: none; }
.budget-row { display: flex; gap: 10px; width: max-content; }
.budget-card {
  position: relative;
  min-width: 148px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.budget-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.budget-card.editing { border-color: var(--brand); background: var(--brand-soft); }
.bc-cat {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.bc-cat-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.bc-spent { color: var(--ink); font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1; letter-spacing: -.035em; }
.bc-of { margin-top: 4px; color: var(--hint); font-size: 12px; }
.bc-bar { height: 7px; margin-top: 11px; overflow: hidden; border-radius: 2px; background: var(--surface-3); }
.bc-bar-fill { height: 100%; border-radius: inherit; transform: scaleX(0); transform-origin: left center; transition: transform .35s ease; }
.bc-over { color: var(--debit) !important; }
.bc-edit {
  min-height: 26px;
  margin-top: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.bc-edit:hover { border-color: var(--line-strong); color: var(--ink); }
.budget-empty {
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  padding: 18px;
  border: 1px dashed var(--line2);
  border-radius: var(--r3);
  background: var(--surface);
  color: var(--sub);
}
.budget-empty strong { color: var(--ink); font-size: 14px; }
.budget-empty span { font-size: 12px; line-height: 1.45; }

.schedule-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0 16px;
}
.schedule-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.schedule-row:hover { border-color: var(--line-strong); }
.schedule-row.posted { background: var(--surface-2); }
.schedule-time {
  width: 62px;
  flex-shrink: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}
.schedule-time span { display: block; margin-top: 3px; color: var(--hint); font-weight: 500; }
.schedule-main { flex: 1; min-width: 0; }
.schedule-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schedule-meta { margin-top: 3px; color: var(--sub); font-size: 12px; }
.schedule-post-btn {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--brand);
  border-radius: var(--r);
  background: var(--brand);
  color: white;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.schedule-edit-btn {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.schedule-edit-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.schedule-post-btn:disabled {
  border-color: var(--line2);
  background: var(--surface-3);
  color: var(--hint);
  cursor: default;
}
.schedule-remove-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.schedule-remove-btn:hover { background: var(--debit-dim); color: var(--debit); }
.schedule-empty {
  display: grid;
  gap: 7px;
  padding: 18px;
  border: 1px dashed var(--line2);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--sub);
  font-size: 13px;
  text-align: center;
}
.schedule-empty strong { color: var(--ink); font-size: 14px; }
.schedule-empty span { color: var(--sub); line-height: 1.45; }
.schedule-inline-btn {
  display: block;
  margin: 10px auto 0;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.txn-list { padding: 0 16px; }
.txn-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 8px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.txn-day-total { color: var(--debit); font-family: var(--mono); font-size: 12px; }
.txn-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
  cursor: pointer;
}
.txn-card.deposit,
.txn-card.reset,
.txn-card.live { cursor: default; }
.txn-card.first-in-day,
.txn-day-header + .txn-card {
  border-radius: var(--r2) var(--r2) 0 0;
}
.txn-card + .txn-card {
  border-top: 0;
}
.txn-card.last-in-day,
.txn-card:last-child {
  border-radius: 0 0 var(--r2) var(--r2);
}
.txn-card.first-in-day.last-in-day { border-radius: var(--r2); }
.txn-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 10px 12px;
  transition: transform .18s ease;
}
.txn-icon {
  width: 40px !important;
  height: 40px !important;
  border-radius: var(--r) !important;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px !important;
  font-weight: 700;
}
.txn-body { flex: 1; min-width: 0; }
.txn-name { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.txn-meta { margin-top: 3px; color: var(--sub); font-size: 12px; }
.txn-amount {
  flex-shrink: 0;
  min-width: 66px;
  text-align: right;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.txn-amount.debit { color: var(--debit); }
.txn-amount.credit { color: var(--credit); }
.txn-del {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.txn-edit {
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.txn-edit:hover { border-color: var(--line-strong); color: var(--ink); }
.txn-del:hover { background: var(--debit-dim); color: var(--debit); }
.txn-assistant-note {
  margin: -2px 12px 12px 63px;
  padding: 9px 11px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.txn-assistant-note::before { content: 'Memo: '; color: var(--hint); font-weight: 600; }
.txn-card.live { border-color: var(--brand-ring); background: var(--brand-soft); }
.txn-card.live .txn-amount { color: var(--brand); }
.txn-card.deposit { border-color: oklch(80% .070 154); background: var(--credit-dim); }
.txn-swipe-hint {
  position: absolute;
  inset: 0 0 0 auto;
  width: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--debit);
  color: white;
  font-size: 12px;
  font-weight: 700;
  transform: translateX(100%);
  transition: transform .18s ease;
  pointer-events: none;
}
.txn-card.swiped .txn-swipe-hint { transform: translateX(0); }
.txn-card.swiped .txn-row { transform: translateX(-78px); }
.txn-empty {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 38px 22px;
  border: 1px dashed var(--line2);
  border-radius: var(--r3);
  background: var(--surface);
  color: var(--sub);
  text-align: center;
  font-size: 14px;
}
.txn-empty strong { color: var(--ink); font-size: 15px; }
.txn-empty .txn-empty-sub { margin-top: 6px; color: var(--hint); font-size: 12px; }
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

/* Invest */
.invest-wrap, .stats-wrap, .settings-wrap { padding: 16px; }
.weekly-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.weekly-plan-kicker {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.weekly-plan-title {
  margin-top: 3px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.week-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.week-summary-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.week-summary-card span {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}
.week-summary-card small {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--sub);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.week-planner {
  display: grid;
  grid-auto-columns: minmax(158px, 1fr);
  grid-auto-flow: column;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.week-planner::-webkit-scrollbar { display: none; }
.week-day-col {
  min-width: 158px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  overflow: hidden;
}
.week-day-col.today { border-color: var(--brand-ring); background: var(--brand-soft); }
.week-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.week-day-head strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.week-day-blocks {
  display: flex;
  min-height: 138px;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.week-block,
.week-empty {
  width: 100%;
  min-height: 46px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.week-block:hover,
.week-empty:hover { border-color: var(--line-strong); }
.week-block.week-only { border-color: var(--brand-ring); background: var(--surface); }
.week-block span {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.week-block small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--sub);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.week-empty {
  border-style: dashed;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.week-actions { margin: 10px 0 2px; }
.template-panel {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.template-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.template-panel-copy {
  margin-top: 3px;
  color: var(--sub);
  font-size: 12px;
}
.template-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}
.template-row {
  width: 100%;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.template-row:hover { border-color: var(--line-strong); }
.template-row span {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-row small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--sub);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-row.empty {
  border-style: dashed;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.plan-cal-hdr { padding: 18px 0 9px; }
.plan-calendar-panel {
  padding: 0 0 8px;
}
.subject-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.subj-btn, .subj-add-btn {
  min-height: 92px;
  padding: 13px;
  border-radius: var(--r3);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}
.subj-btn:hover, .subj-add-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.subj-btn.active { border-color: var(--brand); background: var(--brand-soft); }
.subj-btn-dot { width: 9px; height: 9px; margin-bottom: 10px; border-radius: 2px; }
.subj-btn-name { color: var(--ink); font-size: 14px; font-weight: 700; }
.subj-btn-today { margin-top: 5px; color: var(--sub); font-family: var(--mono); font-size: 12px; }
.subj-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: var(--sub);
  font-weight: 700;
  text-align: center;
}
.timer-big {
  padding: 22px;
  border-radius: var(--r3);
  text-align: center;
}
.timer-big-label { margin-bottom: 12px; color: var(--sub); font-size: 13px; font-weight: 700; }
.timer-big-time {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 48px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.05em;
}
.timer-big-ms { margin-top: 3px; color: var(--hint); font-family: var(--mono); font-size: 14px; }
.timer-big-cost { margin: 16px 0 18px; color: var(--brand); font-family: var(--mono); font-size: 18px; font-weight: 600; }
.timer-start-btn {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: var(--r2);
  background: var(--brand);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .16s ease, transform .16s ease;
}
.timer-start-btn:hover { background: var(--brand-2); }
.timer-start-btn:active { transform: translateY(1px); }
.timer-start-btn.running { border: 1px solid var(--debit); background: var(--debit-dim); color: var(--debit); }

/* Henry */
.assistant-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.assistant-scroll::-webkit-scrollbar { display: none; }
.msg-j, .msg-u { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.msg-u { align-self: flex-end; align-items: flex-end; }
.msg-name { color: var(--brand); font-family: var(--mono); font-size: 10px; font-weight: 600; }
.bubble-j, .bubble-u {
  padding: 11px 14px;
  border-radius: var(--r3);
  font-size: 13px;
  line-height: 1.6;
}
.bubble-j { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-top-left-radius: 5px; }
.bubble-u { background: var(--brand); color: white; border-top-right-radius: 5px; }
.bubble-thinking { color: var(--hint); font-family: var(--mono); font-size: 12px; }
.assistant-input-bar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px max(10px, calc(10px + var(--safe-b)));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.assistant-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line2);
  border-radius: var(--r2);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.assistant-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-dim); }
.assistant-send {
  width: 46px;
  border: 0;
  border-radius: var(--r2);
  background: var(--brand);
  color: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
.assistant-input-bar-v3 {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
  margin: 0 12px max(10px, calc(10px + var(--safe-b)));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.assistant-input-bar-v3 .assistant-compose-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  max-width: 104px;
  padding: 0 10px;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assistant-input-bar-v3 .assistant-input {
  min-height: 40px;
  border-color: transparent;
  background: var(--surface-2);
}
.assistant-gate-card { margin: 24px 16px; padding: 22px; border-radius: var(--r3); text-align: center; }
.assistant-gate-title { color: var(--brand); font-family: var(--mono); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.assistant-gate-body { max-width: 320px; margin: 0 auto 18px; color: var(--sub); font-size: 13px; line-height: 1.6; }
.assistant-gate-action {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}
.assistant-gate-secondary {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  font-size: 13px;
}

/* Stats */
.stat-section { margin-bottom: 20px; }
.stat-section-title, .settings-section-title {
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-card {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat-card.gold, .stat-card.blue, .stat-card.credit, .stat-card.debit, .stat-card.purple, .stat-card.amber { background: var(--surface); }
.stat-label { margin-bottom: 8px; color: var(--sub); font-size: 12px; font-weight: 700; }
.stat-value { color: var(--ink); font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1; letter-spacing: -.04em; }
.stat-value.gold { color: var(--brand); }
.stat-value.credit { color: var(--credit); }
.stat-value.blue { color: var(--blue); }
.stat-value.debit { color: var(--debit); }
.stat-value.purple { color: var(--purple); }
.stat-value.amber { color: var(--amber); }
.stat-sub { margin-top: 5px; color: var(--hint); font-size: 12px; }
.stats-wrap-v1 {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}
.investment-summary {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stats-empty-state {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px dashed var(--line2);
  border-radius: var(--r3);
  background: var(--surface);
  color: var(--sub);
}
.stats-empty-state strong { color: var(--ink); font-size: 15px; }
.stats-empty-state span { font-size: 13px; line-height: 1.45; }
.stats-empty-state .btn { justify-self: start; }
.investment-summary-copy {
  margin-top: 5px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.45;
}
.investment-balance {
  min-width: 132px;
  padding: 12px;
  border-radius: var(--r2);
  background: var(--brand-soft);
  color: var(--brand);
  text-align: left;
}
.investment-balance span {
  display: block;
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}
.investment-balance small { color: var(--sub); font-size: 11px; }
.stats-ledger-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}
.hm-outer, .donut-outer {
  min-width: 0;
  max-width: 100%;
  padding: 14px;
  overflow: hidden;
  border-radius: var(--r3);
  margin-bottom: 10px;
}
.hm-title, .donut-title { margin-bottom: 12px; }
.hm-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.hm-scroll::-webkit-scrollbar { display: none; }
.hm-grid-wrap { display: flex; gap: 3px; }
.hm-week-col { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.hm-cell, .hm-leg-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); }
.hm-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.hm-leg-lbl { color: var(--hint); font-size: 10px; }
.hm-leg-cells { display: flex; gap: 4px; }
.donut-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.donut-body svg {
  width: 82px;
  height: 82px;
  max-width: 28vw;
}
.donut-legend-list { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 7px; }
.dl-row { display: flex; min-width: 0; align-items: center; gap: 7px; }
.dl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dl-name { flex: 1; min-width: 0; overflow: hidden; color: var(--sub); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dl-pct { flex-shrink: 0; color: var(--ink); font-family: var(--mono); font-size: 12px; }

/* Settings */
.settings-section { margin-bottom: 22px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.setting-row-label { color: var(--ink); font-size: 14px; font-weight: 700; }
.setting-row-sub { margin-top: 4px; color: var(--sub); font-size: 12px; }
.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 30px;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--surface-3);
  transition: background-color .16s ease, border-color .16s ease;
}
.switch span::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease;
}
.switch input:checked + span { border-color: var(--brand); background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.setting-select {
  min-width: 112px;
  min-height: 36px;
  padding: 7px 34px 7px 11px;
  appearance: none;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background:
    linear-gradient(45deg, transparent 50%, var(--sub) 50%) calc(100% - 16px) 15px / 5px 5px no-repeat,
    linear-gradient(135deg, var(--sub) 50%, transparent 50%) calc(100% - 11px) 15px / 5px 5px no-repeat,
    var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.setting-select:hover { border-color: var(--line-strong); }
.setting-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-dim); outline: none; }
.setting-inline-input {
  width: 120px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.setting-inline-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-dim); }
.setting-inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.setting-legal-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.setting-legal-link:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}
.setting-short-input { width: 90px; text-align: center; }
.setting-action-btn {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}
.setting-full-action { margin-top: 6px; }
.setting-dev-btn {
  width: 100%;
  min-height: 32px;
  font-size: 11px;
}
.setting-add-btn {
  width: 100%;
  margin-top: 6px;
}
.settings-footnote {
  margin-top: 8px;
  color: var(--hint);
  font-size: 11px;
  text-align: center;
}
.subj-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.sj-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.sj-main { flex: 1; min-width: 0; }
.sj-name { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sj-budget { color: var(--sub); font-family: var(--mono); font-size: 12px; }
.sj-edit {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sj-edit:hover { border-color: var(--line-strong); color: var(--ink); }
.sj-del { width: 28px; height: 28px; border: 0; border-radius: var(--r); background: transparent; color: var(--hint); font-size: 18px; cursor: pointer; }
.sj-del:hover { background: var(--debit-dim); color: var(--debit); }

/* Calendar */
.cal-event {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.cal-event:last-child { border-bottom: 0; }
.cal-event-time { min-width: 82px; color: var(--sub); font-family: var(--mono); font-size: 11px; }
.cal-event-title { min-width: 0; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cal-event-src { flex-shrink: 0; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--hint); font-size: 10px; font-weight: 700; }
.cal-disconnect { border: 0; background: none; color: var(--hint); font-size: 11px; cursor: pointer; }
.cal-disconnect:hover { color: var(--debit); }
.cal-import-btn {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--brand);
  border-radius: var(--r);
  background: var(--brand);
  color: white;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.cal-import-btn:disabled {
  border-color: var(--line2);
  background: var(--surface-3);
  color: var(--hint);
  cursor: default;
}
.calendar-connect-card {
  margin-bottom: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  text-align: center;
}
.calendar-connect-copy {
  margin-bottom: 12px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.6;
}
.calendar-connect-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calendar-status {
  display: none;
  padding: 12px 0;
  color: var(--hint);
  font-size: 12px;
}
.calendar-connect-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}
.calendar-disclaimer {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
  color: var(--hint);
  font-size: 10px;
}
.calendar-disclaimer span { font-family: var(--mono); }

@media (max-width: 430px) {
  .cal-event {
    grid-template-columns: 76px minmax(0, 1fr) auto;
  }
  .cal-event-src {
    display: none;
  }
  .cal-import-btn {
    padding: 5px 8px;
  }
  .donut-body {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .donut-body svg {
    max-width: 90px;
  }
}

/* Pricing and modals */
.pricing-card {
  margin-bottom: 9px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.pricing-card.featured { border-color: var(--brand); background: var(--brand-soft); }
.pricing-tier { color: var(--sub); font-family: var(--mono); font-size: 11px; font-weight: 600; margin-bottom: 7px; }
.pricing-price { color: var(--ink); font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; }
.pricing-price span { color: var(--sub); font-size: 13px; font-weight: 400; }
.pricing-features { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.pricing-feat { display: flex; gap: 7px; color: var(--sub); font-size: 12px; line-height: 1.45; }
.pricing-feat::before { content: ''; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }
.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: oklch(16% .030 255 / .55);
}
.overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 20px;
  padding-bottom: max(20px, calc(16px + var(--safe-b)));
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px oklch(20% .035 255 / .16);
}
.modal-handle { width: 40px; height: 4px; margin: 0 auto 18px; border-radius: 999px; background: var(--line2); }
.modal-title { margin-bottom: 15px; color: var(--ink); font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.modal-btns { display: flex; gap: 8px; margin-top: 16px; }
.modal-btns .btn { flex: 1; }
.modal-copy {
  margin-bottom: 16px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.7;
}
.modal-copy strong,
.modal-help-block strong { color: var(--text); }
.modal-help-block {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--card2);
  color: var(--sub);
  font-size: 12px;
  line-height: 1.8;
}
.modal-status {
  min-height: 18px;
  margin-bottom: 4px;
  color: var(--sub);
  font-size: 12px;
}
.duration-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.duration-number { width: 70px; }
.duration-unit {
  color: var(--sub);
  font-size: 13px;
}
.pricing-primary-btn {
  margin-top: 4px;
  padding: 14px;
  font-size: 15px;
}
.pricing-footnote {
  margin-top: 8px;
  color: var(--hint);
  font-size: 12px;
  text-align: center;
}
.onboarding-modal {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  max-height: none;
  border-radius: 0;
  padding: max(24px, calc(var(--safe-t) + 22px)) max(18px, calc((100vw - 900px) / 2)) max(24px, calc(var(--safe-b) + 22px));
}
.onboarding-copy {
  margin: -4px 0 16px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.55;
}
.onboarding-step-title {
  margin: 18px 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.onboarding-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.inline-field span {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.time-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 4px 0 14px;
}
.weekday-row label {
  min-width: 0;
  cursor: pointer;
}
.weekday-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.weekday-row span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.weekday-row input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.weekday-row input:focus-visible + span { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.textarea-fi {
  min-height: 86px;
  resize: vertical;
  line-height: 1.45;
}
.hm-tooltip {
  position: fixed;
  z-index: 700;
  display: none;
  transform: translate(-50%, -120%);
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-family: var(--mono);
  font-size: 11px;
}

@media (min-width: 760px) {
  .auth-nav {
    grid-template-columns: 1fr auto auto;
    padding-right: max(24px, calc((100vw - 1120px) / 2));
    padding-left: max(24px, calc((100vw - 1120px) / 2));
  }
  .auth-nav-links { display: flex; }
  .auth-welcome {
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, .8fr);
    align-items: center;
    padding-right: max(48px, calc((100vw - 1120px) / 2));
    padding-left: max(48px, calc((100vw - 1120px) / 2));
  }
  .auth-title { font-size: 58px; }
  .auth-feature-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .auth-ledger-section,
  .auth-plan-section,
  .auth-security-section {
    grid-template-columns: minmax(0, .9fr) minmax(360px, 1fr);
    padding-right: max(48px, calc((100vw - 1120px) / 2));
    padding-left: max(48px, calc((100vw - 1120px) / 2));
  }
  .auth-how-section,
  .auth-feature-band,
  .auth-entry-section {
    padding-right: max(48px, calc((100vw - 1120px) / 2));
    padding-left: max(48px, calc((100vw - 1120px) / 2));
  }
  .auth-preview-ledger { max-width: none; }
  .auth-details-inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-auth-hero { grid-template-columns: minmax(0, .95fr) minmax(340px, .72fr); }
  .site-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    padding-right: max(48px, calc((100vw - 1120px) / 2));
    padding-left: max(48px, calc((100vw - 1120px) / 2));
  }
  .site-footer small { grid-column: 1 / -1; }
  .setup-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .setup-progress-step small { display: block; }
  .setup-pref-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

@media (min-width: 980px) {
  #app,
  #app[style*='display: flex'] {
    display: grid !important;
    grid-template-columns: 320px minmax(0, 1fr);
    height: 100vh;
    background: var(--bg-2);
  }
  .topbar {
    height: 100vh;
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 22px 18px;
  }
  .topbar-row1 { padding-bottom: 20px; }
  .topbar-brand { font-size: 25px; }
  .balance-hero {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r3);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .balance-amount { font-size: 58px; }
  .balance-meta { display: grid; grid-template-columns: 1fr; }
  .balance-meta-item { justify-content: space-between; border-radius: var(--r); }
  .tab-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 18px;
    border-top: 0;
  }
  .tab-btn {
    min-height: 46px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 12px;
    gap: 10px;
    font-size: 13px;
  }
  .app-body { padding: 22px; }
  .tab-page.active {
    max-width: 1180px;
    margin: 0 auto;
    padding-bottom: 22px;
  }
  #tab-account.active {
    display: block;
    max-width: 960px;
  }
  .briefing-card, .timer-banner { margin: 0; }
  .day-plan-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 14px 0 0; }
  .sec-hdr { padding: 18px 0 9px; }
  .budget-scroll { padding: 0 0 4px; overflow: visible; }
  .budget-row { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .budget-card { min-width: 0; }
  .schedule-panel { padding: 0; }
  .schedule-empty { margin: 0; }
  .txn-list { padding: 0; }
  .calendar-panel { padding: 0 0 8px !important; }
  .invest-wrap, .stats-wrap, .settings-wrap { max-width: 960px; margin: 0 auto; padding: 0; }
  .week-planner {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: initial;
    overflow: visible;
  }
  .week-day-col { min-width: 0; }
  .template-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .timer-big { max-width: 680px; margin: 0 auto; }
  .timer-big-time { font-size: 64px; }
  .investment-summary {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .investment-balance { text-align: right; }
  .stats-ledger-grid { grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #tab-assistant.active { max-width: 900px; height: calc(100vh - 44px); }
  .modal { margin-bottom: 24px; border-radius: var(--r3); }
  .onboarding-modal { margin-bottom: 0; border-radius: 0; }
  .overlay { align-items: center; padding: 24px; }
  .onboarding-overlay { align-items: stretch; padding: 0; }
  .onboarding-grid { grid-template-columns: 160px minmax(0, 1fr); gap: 12px; }
  .setup-shell {
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }
  .setup-rail {
    align-content: start;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 24px 18px;
  }
  .setup-rail h1 { font-size: 34px; }
  .setup-progress { grid-template-columns: 1fr; }
  .setup-main { padding: 34px; }
  .setup-week-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
  .setup-week-preview {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: initial;
    overflow: visible;
  }
  .setup-week-day { min-width: 0; }
}

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

body[data-contrast='high'] {
  --bg: oklch(97.5% .004 250);
  --bg-2: oklch(92% .006 250);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(94% .006 250);
  --surface-3: oklch(88% .012 250);
  --text: oklch(13% .025 255);
  --ink: oklch(10% .030 255);
  --sub: oklch(29% .030 255);
  --hint: oklch(39% .030 255);
  --line: oklch(72% .020 255);
  --line2: oklch(61% .030 255);
  --line-strong: oklch(45% .045 255);
}

body[data-theme='dark'][data-contrast='high'] {
  --bg: oklch(9% .012 252);
  --bg-2: oklch(6% .010 252);
  --surface: oklch(15% .018 252);
  --surface-2: oklch(21% .022 252);
  --surface-3: oklch(28% .028 252);
  --text: oklch(97% .004 250);
  --ink: oklch(99% .003 250);
  --sub: oklch(84% .010 250);
  --hint: oklch(72% .014 250);
  --line: oklch(44% .026 252);
  --line2: oklch(55% .032 252);
  --line-strong: oklch(70% .040 252);
}

@media (prefers-color-scheme: dark) {
  body[data-theme='system'][data-contrast='high'] {
    --bg: oklch(9% .012 252);
    --bg-2: oklch(6% .010 252);
    --surface: oklch(15% .018 252);
    --surface-2: oklch(21% .022 252);
    --surface-3: oklch(28% .028 252);
    --text: oklch(97% .004 250);
    --ink: oklch(99% .003 250);
    --sub: oklch(84% .010 250);
    --hint: oklch(72% .014 250);
    --line: oklch(44% .026 252);
    --line2: oklch(55% .032 252);
    --line-strong: oklch(70% .040 252);
  }
}

body[data-density='compact'] .txn-row { min-height: 54px; padding: 8px 10px; }
body[data-density='compact'] .txn-icon { width: 34px !important; height: 34px !important; border-radius: 10px !important; }
body[data-density='compact'] .budget-card,
body[data-density='compact'] .stat-card,
body[data-density='compact'] .setting-row { padding: 10px; }
body[data-density='compact'] .briefing-card,
body[data-density='compact'] .timer-banner,
body[data-density='compact'] .day-plan-card { padding: 11px; }

body[data-motion='reduced'] *,
body[data-motion='reduced'] *::before,
body[data-motion='reduced'] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
