:root {
  color-scheme: light dark;
  --bg: oklch(96.5% .006 220);
  --bg-2: oklch(92.5% .010 215);
  --surface: oklch(99% .002 220);
  --surface-2: oklch(95.2% .006 215);
  --surface-3: oklch(89.8% .012 215);
  --card: var(--surface);
  --card2: var(--surface-2);
  --card3: var(--surface-3);
  --ink: oklch(20% .018 220);
  --text: oklch(23% .016 220);
  --sub: oklch(43% .020 220);
  --hint: oklch(57% .018 220);
  --line: oklch(84% .014 220);
  --line2: oklch(77% .020 220);
  --line-strong: oklch(63% .028 220);
  --brand: oklch(43% .090 185);
  --brand-2: oklch(49% .085 178);
  --brand-soft: oklch(91.5% .030 185);
  --brand-dim: oklch(43% .090 185 / .12);
  --brand-ring: oklch(43% .090 185 / .32);
  --gold: var(--brand);
  --gold-dim: var(--brand-dim);
  --gold-soft: var(--brand-soft);
  --gold-ring: var(--brand-ring);
  --credit: oklch(48% .095 152);
  --credit-dim: oklch(92.5% .030 152);
  --debit: oklch(49% .125 28);
  --debit-dim: oklch(93.5% .035 28);
  --warning: oklch(61% .110 72);
  --blue: oklch(49% .075 235);
  --blue-dim: oklch(92% .025 235);
  --purple: oklch(48% .075 305);
  --amber: oklch(60% .095 78);
  --teal: oklch(48% .085 188);
  --shadow-sm: 0 1px 1px oklch(20% .020 220 / .06);
  --shadow-md: 0 6px 16px oklch(28% .035 220 / .09);
  --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(15% .014 220);
  --bg-2: oklch(11.5% .012 220);
  --surface: oklch(20% .016 220);
  --surface-2: oklch(24% .018 220);
  --surface-3: oklch(30% .022 220);
  --card: var(--surface);
  --card2: var(--surface-2);
  --card3: var(--surface-3);
  --ink: oklch(96% .004 220);
  --text: oklch(91% .006 220);
  --sub: oklch(74% .012 220);
  --hint: oklch(62% .014 220);
  --line: oklch(33% .020 220);
  --line2: oklch(42% .024 220);
  --line-strong: oklch(57% .030 220);
  --brand: oklch(70% .090 185);
  --brand-2: oklch(76% .085 178);
  --brand-soft: oklch(31% .040 185);
  --brand-dim: oklch(70% .090 185 / .16);
  --brand-ring: oklch(70% .090 185 / .34);
  --credit: oklch(72% .090 152);
  --credit-dim: oklch(31% .038 152);
  --debit: oklch(69% .120 28);
  --debit-dim: oklch(32% .044 28);
  --warning: oklch(76% .105 78);
  --blue: oklch(72% .080 235);
  --blue-dim: oklch(31% .036 235);
  --purple: oklch(73% .080 305);
  --amber: oklch(76% .100 78);
  --teal: oklch(72% .085 188);
  --shadow-sm: none;
  --shadow-md: 0 10px 24px oklch(5% .010 220 / .32);
}

@media (prefers-color-scheme: dark) {
  body[data-theme='system'] {
    --bg: oklch(15% .014 220);
    --bg-2: oklch(11.5% .012 220);
    --surface: oklch(20% .016 220);
    --surface-2: oklch(24% .018 220);
    --surface-3: oklch(30% .022 220);
    --card: var(--surface);
    --card2: var(--surface-2);
    --card3: var(--surface-3);
    --ink: oklch(96% .004 220);
    --text: oklch(91% .006 220);
    --sub: oklch(74% .012 220);
    --hint: oklch(62% .014 220);
    --line: oklch(33% .020 220);
    --line2: oklch(42% .024 220);
    --line-strong: oklch(57% .030 220);
    --brand: oklch(70% .090 185);
    --brand-2: oklch(76% .085 178);
    --brand-soft: oklch(31% .040 185);
    --brand-dim: oklch(70% .090 185 / .16);
    --brand-ring: oklch(70% .090 185 / .34);
    --credit: oklch(72% .090 152);
    --credit-dim: oklch(31% .038 152);
    --debit: oklch(69% .120 28);
    --debit-dim: oklch(32% .044 28);
    --warning: oklch(76% .105 78);
    --blue: oklch(72% .080 235);
    --blue-dim: oklch(31% .036 235);
    --purple: oklch(73% .080 305);
    --amber: oklch(76% .100 78);
    --teal: oklch(72% .085 188);
    --shadow-sm: none;
    --shadow-md: 0 10px 24px oklch(5% .010 220 / .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-definition {
  max-width: 620px;
  margin-top: 14px;
  padding-left: 14px;
  border-left: 3px solid var(--brand);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
}
.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 color-mix(in oklch, var(--line) 68%, var(--surface));
  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 color-mix(in oklch, var(--line) 58%, var(--surface));
  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-statement-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: 160px;
  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: 14px 0 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}
.auth-week-events {
  display: grid;
  gap: 6px;
}
.auth-week-event {
  min-height: 30px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--sub) !important;
  line-height: 1.25;
}
.auth-week-event.imported-event {
  border-color: var(--brand-ring);
  background: color-mix(in oklch, var(--brand-soft) 64%, var(--surface));
}
.auth-week-event b {
  display: inline-block;
  min-width: 35px;
  margin-right: 6px;
  color: var(--ink);
  font-weight: 700;
}
.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-habit-example {
  display: grid;
  gap: 12px;
  width: min(100%, 720px);
  margin: 14px auto 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.auth-habit-example-copy strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}
.auth-habit-example-copy span {
  display: block;
  margin-top: 4px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.auth-habit-mini-sheet {
  display: grid;
  grid-template-columns: minmax(58px, 78px) repeat(3, minmax(38px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: color-mix(in oklch, var(--line) 70%, var(--surface));
}
.auth-habit-mini-sheet span,
.auth-habit-mini-sheet i {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.auth-habit-mini-sheet span {
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
}
.auth-habit-mini-sheet .corner,
.auth-habit-mini-sheet .head {
  background: var(--surface-2);
  color: var(--ink);
}
.auth-habit-mini-sheet .head {
  min-height: 48px;
  align-items: flex-end;
  padding: 7px 4px;
}
.auth-habit-mini-sheet .date {
  justify-content: flex-start;
  padding: 0 8px;
  font-family: var(--mono);
}
.auth-habit-mini-sheet i {
  position: relative;
  color: var(--brand);
  font-family: var(--mono);
  font-size: 16px;
  font-style: normal;
  font-weight: 700;
}
.auth-habit-mini-sheet i.checked::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid color-mix(in oklch, var(--brand) 48%, var(--line));
  border-radius: 44% 56% 50% 47%;
  background: var(--surface);
  transform: rotate(-2deg);
  z-index: -1;
}
.auth-habit-mini-sheet i.streak::before {
  content: '';
  position: absolute;
  inset: -6px 8px;
  border-radius: 48% 52% 46% 54% / 16% 18% 14% 20%;
  background:
    linear-gradient(180deg,
      color-mix(in oklch, var(--brand) 12%, transparent),
      color-mix(in oklch, var(--brand) 20%, transparent) 48%,
      color-mix(in oklch, var(--brand) 13%, transparent));
  box-shadow:
    inset 1px 0 0 color-mix(in oklch, var(--brand) 34%, transparent),
    inset -1px 0 0 color-mix(in oklch, var(--brand) 24%, transparent);
  clip-path: polygon(44% 0, 59% 2%, 54% 15%, 62% 31%, 55% 49%, 61% 67%, 54% 84%, 58% 100%, 39% 100%, 45% 83%, 37% 66%, 44% 50%, 36% 32%, 43% 15%);
  z-index: -2;
}
.auth-habit-mini-sheet i.checked {
  z-index: 1;
  isolation: isolate;
  text-shadow: 0 1px 0 var(--surface);
}
.auth-habit-mini-sheet i.checked::after,
.auth-habit-mini-sheet i.checked::before {
  pointer-events: none;
}
.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-faq-section {
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 64px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.auth-faq-list {
  display: grid;
  gap: 10px;
  width: min(100%, 720px);
}
.auth-faq-item {
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  overflow: hidden;
}
.auth-faq-item summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  list-style: none;
}
.auth-faq-item summary::-webkit-details-marker { display: none; }
.auth-faq-item summary::after {
  content: "+";
  flex: none;
  color: var(--brand);
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  transition: transform .18s ease;
}
.auth-faq-item[open] summary::after { content: "\2212"; }
.auth-faq-item summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.auth-faq-item p {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.6;
}
.auth-faq-item a {
  color: var(--brand);
  text-decoration: underline;
}
.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-tagline {
  display: block;
  margin-top: 6px;
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--hint);
}
.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;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  overflow-y: auto;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.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(100dvh - 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;
}
.legal-cross {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin-top: 18px;
  padding: 0 4px;
}
.legal-cross span {
  color: var(--hint);
  font-size: 12px;
}
.legal-cross a {
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.legal-cross a:hover { text-decoration: underline; }
.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 {
  position: relative;
  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-control {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.sync-control:hover,
.sync-control.open {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.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; }
.sync-popover {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 41px;
  width: min(260px, calc(100vw - 28px));
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.sync-popover strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}
.sync-popover span {
  display: block;
  margin-top: 4px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.4;
}
@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;
  color: var(--sub);
  font-size: 12px;
}
.balance-meta-item + .balance-meta-item { border-left: 1px solid var(--line); padding-left: 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; }
.app-page-loading {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  color: var(--sub);
  font-size: 13px;
  text-align: center;
}
.app-page-loading strong {
  color: var(--ink);
  font-size: 15px;
}
.tab-page { display: none; padding-bottom: calc(var(--safe-b) + 26px); }
.tab-page.active { display: block; }

/* 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 */
.timer-banner, .timer-big, .hm-outer, .donut-outer, .assistant-gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.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;
}

.ledger-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  padding: 14px 16px 0;
}
.ledger-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.ledger-action:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.ledger-action.primary {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}
.ledger-action strong {
  margin-top: 0;
  overflow: hidden;
  max-width: 100%;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-action small {
  margin-top: 5px;
  overflow: hidden;
  max-width: 100%;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-statement {
  margin: 18px 16px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.ledger-statement-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 13px;
  border: 1px solid color-mix(in oklch, var(--line) 68%, var(--surface));
  border-radius: var(--r2);
  background: color-mix(in oklch, var(--surface) 82%, var(--surface-2));
}
.ledger-statement-kicker {
  color: var(--sub);
  font-size: 11px;
  font-weight: 700;
}
.ledger-statement h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}
.ledger-statement-meta {
  color: var(--sub);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}
.ledger-column-head {
  display: none;
  align-items: center;
  grid-template-columns: 48px 38px minmax(0, 1fr) 76px 30px;
  gap: 9px;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid color-mix(in oklch, var(--line) 68%, var(--surface));
  border-radius: var(--r);
  background: var(--surface);
  color: var(--hint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.ledger-column-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-column-head .lch-name { text-align: left; }
.ledger-column-head span:not(.lch-time):not(.lch-icon):not(.lch-name):not(.lch-action) { text-align: right; }
.txn-list { padding: 4px 0 0; }
.txn-list--bank-register {
  --statement-pad: 10px;
  --statement-row: 52px;
  --statement-radius: 10px;
  --statement-border: color-mix(in oklch, var(--line) 68%, var(--surface));
  --statement-divider: color-mix(in oklch, var(--line) 58%, var(--surface));
  --statement-header-divider: color-mix(in oklch, var(--line2) 48%, var(--surface));
}
.txn-list--bank-register .txn-ledger-section-head {
  min-height: 22px;
  padding: 14px 2px 6px;
  color: var(--sub);
}
.txn-list--bank-register .txn-ledger-section-head span,
.txn-list--bank-register .txn-ledger-section-head small {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.txn-list--bank-register .txn-day-block {
  margin: 4px 0 16px;
  overflow: hidden;
  border: 1px solid var(--statement-border);
  border-radius: var(--statement-radius);
  background: var(--surface);
}
.txn-list--bank-register .txn-day-header {
  min-height: 48px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--statement-header-divider);
  border-radius: 0;
  background: color-mix(in oklch, var(--surface-2) 86%, var(--surface));
}
.txn-list--bank-register .txn-day-summary {
  justify-content: flex-start;
  gap: 5px;
  color: var(--sub);
  font-weight: 600;
}
.txn-list--bank-register .txn-day-summary span + span::before {
  content: '·';
  margin-right: 5px;
  color: var(--line-strong);
}
.txn-list--bank-register .txn-day-title,
.txn-list--bank-register .txn-day-date,
.txn-list--bank-register .txn-day-summary span {
  font-family: var(--mono);
}
.txn-list--bank-register .txn-day-summary span {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 10px;
}
.txn-list--bank-register .txn-card {
  margin: 0;
  border: 0;
  border-top: 0;
  border-bottom: 1px solid var(--statement-divider);
  border-radius: 0;
  background: transparent;
}
.txn-list--bank-register .txn-card + .txn-card {
  border-top: 0;
}
.txn-list--bank-register .txn-card:last-child {
  border-bottom: 0;
}
.txn-list--bank-register .txn-row {
  min-height: var(--statement-row);
  padding: var(--statement-pad) 14px;
}
.txn-list--bank-register .txn-icon {
  width: 28px !important;
  height: 28px !important;
  border-radius: 3px !important;
  font-size: 9px !important;
}
.txn-list--bank-register .txn-name,
.txn-list--bank-register .txn-amount {
  font-size: 13px;
}
.txn-list--bank-register .txn-meta,
.txn-list--bank-register .txn-duration,
.txn-list--bank-register .txn-balance {
  font-size: 11px;
}
.txn-list--bank-register .txn-ledger-history {
  margin-top: 20px;
  padding: 0;
  border-top: 0;
  background: transparent;
}
.txn-list--bank-register .txn-ledger-history .txn-ledger-section-head {
  padding-top: 0;
}
.txn-list--bank-register .txn-ledger-history .txn-day-block {
  margin-right: 0;
  margin-left: 0;
}
.txn-ledger-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 2px;
}
.txn-ledger-history {
  margin-top: 26px;
  padding: 18px 0 1px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.txn-ledger-history .txn-ledger-section-head {
  padding-top: 0;
}
.txn-ledger-section-head span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.txn-ledger-section-head small {
  color: var(--hint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.txn-day-block {
  margin: 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.txn-day-block:first-child { margin-top: 12px; }
.txn-day-block:last-child { margin-bottom: 12px; }
.txn-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: color-mix(in oklch, var(--surface-2) 80%, var(--surface));
}
.txn-day-title {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.txn-day-date {
  display: block;
  margin-top: 2px;
  color: var(--hint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
}
.txn-day-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  color: var(--sub);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.txn-day-summary span {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.txn-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 1px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--line);
}
.txn-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 9px 11px;
  background: var(--surface);
}
.txn-metric-label { color: var(--hint); font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.txn-metric-value { color: var(--ink); font-family: var(--mono); font-size: 15px; font-weight: 600; }
.txn-metric-sub { min-width: 0; overflow: hidden; color: var(--sub); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.txn-card {
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: none;
  cursor: pointer;
}
.txn-card.deposit,
.txn-card.reset,
.txn-card.live { cursor: default; }
.txn-card + .txn-card { border-top: 1px solid var(--line); }
.txn-row {
  display: grid;
  grid-template-columns: 48px 38px minmax(0, 1fr) 76px 30px;
  align-items: center;
  gap: 9px;
  min-height: 62px;
  padding: 10px 11px;
  transition: transform .18s ease;
}
.txn-posted {
  color: var(--sub);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
}
.txn-posted span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !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 {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 4px;
  color: var(--sub);
  font-size: 12px;
}
.txn-ref,
.txn-period {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txn-period { color: var(--hint); font-family: var(--mono); font-size: 11px; }
.txn-duration,
.txn-balance {
  display: none;
  color: var(--sub);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.txn-amount {
  justify-self: end;
  width: 76px;
  text-align: right;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.txn-amount.debit { color: var(--debit); }
.txn-amount.invested { color: var(--ink); }
.txn-amount.credit { color: var(--credit); }
.txn-del {
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.txn-edit {
  display: none;
  align-items: center;
  justify-content: center;
  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 { 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.inline {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}
.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;
}

.category-parent {
  color: var(--sub);
  font-weight: 600;
}
.category-sep {
  margin: 0 4px;
  color: var(--hint);
  font-family: var(--mono);
  font-weight: 600;
}
.category-leaf {
  color: var(--ink);
  font-weight: 700;
}

/* Invest */
.invest-wrap, .stats-wrap, .settings-wrap, .habits-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); }

/* Habits */
.habits-wrap {
  min-width: 0;
}
.habits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.habits-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.habits-kicker {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.habits-head h2 {
  margin-top: 3px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}
.habits-month-nav {
  display: grid;
  grid-template-columns: 34px minmax(104px, auto) 34px;
  align-items: center;
  gap: 6px;
}
.habit-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.habit-icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); }
.habit-edit-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.habit-edit-toggle:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); transform: translateY(-1px); }
.habit-edit-toggle.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.habit-icon-btn:focus-visible,
.habit-edit-toggle:focus-visible,
.habit-check-btn:focus-visible,
.habit-link-select:focus-visible,
.habit-title-input:focus-visible,
.habit-threshold-control input:focus-visible,
.habit-archive-btn:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}
.habits-month-label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.habits-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid color-mix(in oklch, var(--line) 72%, var(--surface));
  border-radius: var(--r2);
  background: color-mix(in oklch, var(--surface) 78%, var(--surface-2));
}
.habits-toolbar[hidden] { display: none; }
.habit-add-control {
  display: flex;
  min-width: min(100%, 320px);
  flex: 1;
  gap: 8px;
}
.habit-title-input,
.habit-threshold-control input {
  min-height: 36px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.habit-title-input {
  min-width: 0;
  flex: 1;
  padding: 0 10px;
}
.habit-title-input::placeholder { color: var(--sub); opacity: 1; }
.habit-threshold-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.habit-threshold-control input {
  width: 58px;
  padding: 0 8px;
  font-family: var(--mono);
  font-weight: 600;
}
.habits-sheet-frame {
  border: 1px solid color-mix(in oklch, var(--line) 72%, var(--surface));
  border-radius: var(--r2);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.habits-sheet-scroll {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.habits-sheet {
  display: grid;
  min-width: max-content;
  align-items: stretch;
  background: color-mix(in oklch, var(--line) 70%, var(--surface));
  gap: 1px;
}
.habit-cell {
  position: relative;
  min-width: 0;
  min-height: 42px;
  background: var(--surface);
}
.habit-corner,
.habit-date-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  border-right: 1px solid color-mix(in oklch, var(--line2) 64%, var(--surface));
}
.habit-corner {
  top: 0;
  z-index: 6;
  min-height: 122px;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  background: var(--surface-2);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.habit-head {
  z-index: 2;
  min-height: 122px;
  display: grid;
  grid-template-rows: 1fr;
  align-items: flex-end;
  justify-items: stretch;
  padding: 10px 8px;
  background: var(--surface-2);
  overflow: visible;
}
.habit-head.editing {
  min-height: 158px;
  grid-template-rows: minmax(102px, 1fr) 34px;
  align-items: flex-end;
  gap: 8px;
}
.habit-head.linked:not(.editing) {
  grid-template-rows: 1fr auto;
  gap: 4px;
}
.habit-head.archived { opacity: .68; }
.habit-link-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.habit-link-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 999px;
  background: var(--link-color, var(--brand));
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--link-color, var(--brand)) 22%, transparent);
}
.habit-head-title {
  width: 100%;
  min-height: 78px;
  position: relative;
  overflow: visible;
}
.habit-head-title span {
  --habit-title-inline: 82px;
  --habit-title-thickness: 16px;
  position: absolute;
  left: calc(50% - var(--habit-title-inline) - (var(--habit-title-thickness) / 2));
  bottom: 0;
  display: block;
  width: var(--habit-title-inline);
  max-width: var(--habit-title-inline);
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: var(--habit-title-thickness);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: rotate(90deg);
  transform-origin: 100% 100%;
}
.habit-head.editing .habit-head-title { min-height: 98px; }
.habit-link-select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
}
.habit-archive-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.habit-archive-btn:hover { background: var(--debit-dim); color: var(--debit); }
.habit-date-cell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  background: var(--surface);
}
.habit-date-cell strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.habit-date-cell span {
  overflow: hidden;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-date-cell.today,
.habit-check-cell.today,
.habit-empty-cell.today {
  background: color-mix(in oklch, var(--brand-soft) 42%, var(--surface));
}
.habit-check-cell,
.habit-empty-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}
.habit-check-cell.archived { background: var(--surface-2); }
.habit-check-btn {
  width: 100%;
  height: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brand);
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.habit-check-btn:hover,
.habit-check-btn.checked {
  background: transparent;
}
.habit-check-btn:hover { background: var(--surface-2); }
.habit-check-btn.checked {
  color: var(--brand);
  box-shadow: none;
}
.habit-check-btn.auto {
  box-shadow: inset 0 0 0 1.5px color-mix(in oklch, var(--link-color, var(--brand)) 60%, transparent);
}
.habit-check-btn.manual-off {
  background: transparent;
  color: var(--debit);
  box-shadow: none;
}
.habit-check-btn:active { transform: translateY(1px); }
.habit-check-cell.streak-run {
  isolation: isolate;
  overflow: visible;
  /* Highlighter ink, two layers: fiber streaks along the stroke and ink
     pooling at the edges. Both run parallel to the stroke and are constant
     down its length, so segments join invisibly across cells. */
  --streak-ink:
    repeating-linear-gradient(90deg,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-fill, 16%) * .32), transparent) 0 1.1px,
      transparent 1.1px 2.5px,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-fill, 16%) * .18), transparent) 2.5px 3.4px,
      transparent 3.4px 4.7px),
    linear-gradient(90deg,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-stroke, 40%) * .8), transparent) 0%,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-fill, 16%) * .95), transparent) 16%,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-fill, 16%) * .68), transparent) 42%,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-fill, 16%) * .8), transparent) 70%,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-edge, 34%) * .75), transparent) 100%);
}
.habit-check-cell.streak-run::before {
  content: '';
  position: absolute;
  /* Bridge exactly half the sheet's 1px grid gap on each side: neighboring
     segments meet without overlapping, so the multiply blend never doubles. */
  top: -0.5px;
  bottom: -0.5px;
  left: 50%;
  /* Ink sits over the checkmark and multiplies into it, like a real swipe
     over pen; the cell's isolation keeps the blend from reaching the page. */
  z-index: 2;
  width: 16px;
  background: var(--streak-ink);
  mix-blend-mode: multiply;
  /* Left and right edges waver in parallel (same offset at every step), so
     the stroke wanders slightly but its thickness never changes; both edges
     return to the shared joint positions at 0%/100% so cells line up. */
  clip-path: polygon(5% 0, 95.5% 0, 96.5% 12%, 94.7% 26%, 96.9% 40%, 94.3% 55%, 96.3% 70%, 94.5% 85%, 95.5% 100%, 5% 100%, 4% 85%, 5.8% 70%, 3.8% 55%, 6.4% 40%, 4.2% 26%, 6% 12%);
  transform: translateX(-50%);
  pointer-events: none;
}
.habit-check-cell.streak-run .habit-check-btn.checked {
  background: transparent;
}
.habit-check-cell.streak-run::after {
  content: none;
}
.habit-check-cell.streak-start::before {
  top: 8px;
  /* Chisel-tip press-in: angled cap plus a pooled blot where the tip lands. */
  background:
    radial-gradient(90% 9px at 50% 4px,
      color-mix(in oklch, var(--streak-color, var(--line-strong)) calc(var(--streak-stroke, 40%) * .9), transparent),
      transparent 74%),
    var(--streak-ink);
  clip-path: polygon(6% 4.5%, 30% 1%, 80% 0, 95% 3%, 96.5% 12%, 94.7% 26%, 96.9% 40%, 94.3% 55%, 96.3% 70%, 94.5% 85%, 95.5% 100%, 5% 100%, 4% 85%, 5.8% 70%, 3.8% 55%, 6.4% 40%, 4.2% 26%, 6% 12%);
}
.habit-check-cell.streak-start::after {
  content: none;
}
.habit-check-cell.streak-end::before {
  bottom: 8px;
  /* Dry taper: the stroke lifts off, losing ink over the last few pixels. */
  clip-path: polygon(5% 0, 95.5% 0, 96.5% 12%, 94.7% 26%, 96.9% 40%, 94.3% 55%, 96.3% 70%, 94.5% 82%, 93.5% 92%, 78% 98.5%, 38% 100%, 13% 97.5%, 5.5% 92%, 4% 85%, 5.8% 70%, 3.8% 55%, 6.4% 40%, 4.2% 26%, 6% 12%);
  mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 9px), rgb(0 0 0 / .55) calc(100% - 3px), rgb(0 0 0 / .3) 100%);
}
.habit-check-cell.streak-end::after {
  content: none;
}
.habit-check-cell.streak-start.streak-end::before {
  top: 8px;
  bottom: 8px;
  clip-path: polygon(6% 4.5%, 30% 1%, 80% 0, 95% 3%, 96.5% 12%, 94.7% 26%, 96.9% 40%, 94.3% 55%, 96.3% 70%, 94.5% 82%, 93.5% 92%, 78% 98.5%, 38% 100%, 13% 97.5%, 5.5% 92%, 4% 85%, 5.8% 70%, 3.8% 55%, 6.4% 40%, 4.2% 26%, 6% 12%);
}
.habit-check-cell.streak-start.streak-end::after {
  content: none;
}
.habit-check-cell > * {
  position: relative;
  z-index: 1;
}
.habit-empty-head,
.habit-empty-cell {
  color: var(--hint);
  font-family: var(--mono);
  font-size: 11px;
}
.habit-empty-head {
  min-height: 122px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px 6px;
  background: var(--surface-2);
}
body[data-density='compact'] .habit-cell { min-height: 34px; }
body[data-density='compact'] .habit-check-cell,
body[data-density='compact'] .habit-empty-cell { min-height: 34px; }
body[data-density='compact'] .habit-check-btn { min-height: 34px; font-size: 14px; }
body[data-density='compact'] .habit-head,
body[data-density='compact'] .habit-corner,
body[data-density='compact'] .habit-empty-head { min-height: 104px; }
body[data-density='compact'] .habit-head.editing {
  min-height: 138px;
  grid-template-rows: minmax(86px, 1fr) 30px;
}
body[data-density='compact'] .habit-head-title { min-height: 66px; }
body[data-density='compact'] .habit-head.editing .habit-head-title { min-height: 84px; }
body[data-density='compact'] .habit-head-title span {
  --habit-title-inline: 72px;
  --habit-title-thickness: 15px;
  font-size: 12px;
}
body[data-contrast='high'] .habits-sheet { background: var(--line-strong); }
body[data-contrast='high'] .habit-check-btn { border-width: 2px; color: var(--ink); }
body[data-contrast='high'] .habit-check-btn.checked { background: var(--brand); color: var(--surface); }
body[data-contrast='high'] .habit-check-cell.streak-run::before {
  background: color-mix(in oklch, var(--streak-color, var(--brand)) 42%, var(--surface));
  mix-blend-mode: normal;
  z-index: 0;
  mask-image: none;
}
body[data-motion='reduced'] .habit-check-btn,
body[data-motion='reduced'] .habit-edit-toggle { transition: none; }

/* 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;
}
.assistant-maintenance-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: auto;
}
.assistant-maintenance-card {
  width: min(100%, 460px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.assistant-maintenance-kicker {
  margin-bottom: 10px;
  color: var(--brand);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.assistant-maintenance-card h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
  text-wrap: balance;
}
.assistant-maintenance-card p {
  margin: 0;
  max-width: 58ch;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.6;
  text-wrap: pretty;
}
.assistant-maintenance-action {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
}

/* 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-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat-strip--wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-strip-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
}
.stat-strip-item + .stat-strip-item { border-left: 1px solid var(--line); }
.stat-strip--wrap .stat-strip-item:nth-child(odd) { border-left: 0; }
.stat-strip--wrap .stat-strip-item:nth-child(n+3) { border-top: 1px solid var(--line); }
.stat-strip-label { color: var(--sub); font-size: 12px; font-weight: 700; }
.stat-strip-value { color: var(--ink); font-family: var(--mono); font-size: 21px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.stat-strip-sub { overflow: hidden; color: var(--hint); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.stat-disclosure { border-top: 1px solid var(--line); padding-top: 6px; }
.stat-disclosure summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin-bottom: 0;
  padding: 10px 2px;
  border-bottom: 0;
  cursor: pointer;
  list-style: none;
}
.stat-disclosure summary::-webkit-details-marker { display: none; }
.stat-disclosure summary::after { content: '▸'; color: var(--hint); font-size: 11px; transition: transform .16s ease; }
.stat-disclosure[open] summary::after { transform: rotate(90deg); }
.stat-disclosure summary:hover { color: var(--ink); }
.stat-disclosure .stat-strip { margin-top: 4px; }
.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-row.has-split { align-items: flex-start; }
.dl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dl-main { flex: 1; min-width: 0; }
.dl-name { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--sub); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dl-split-hint { flex: none; min-width: 15px; padding: 0 4px; border-radius: 999px; background: var(--surface-3); color: var(--hint); font-family: var(--mono); font-size: 9.5px; font-weight: 700; text-align: center; }
.dl-pct { flex-shrink: 0; color: var(--ink); font-family: var(--mono); font-size: 12px; }
.dl-row { cursor: pointer; margin: -2px -4px; padding: 2px 4px; border-radius: var(--r); transition: background .15s ease; }
.dl-row.active { background: var(--surface-2); }
.dl-row.active .dl-name { color: var(--ink); }
.dl-row:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: 1px; }
.donut-slice { cursor: pointer; transition: opacity .15s ease, stroke-width .15s ease; }
.donut-tip {
  position: fixed;
  z-index: 700;
  display: none;
  transform: translate(-50%, -100%);
  min-width: 160px;
  max-width: 240px;
  padding: 8px 10px;
  border: 1px solid var(--line2);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.donut-tip-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 12px; font-weight: 700; }
.donut-tip-head span:last-child { flex: none; font-family: var(--mono); font-weight: 600; }
.donut-tip-row { display: flex; justify-content: space-between; gap: 12px; color: var(--sub); font-size: 11px; line-height: 1.65; }
.donut-tip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-tip-time { flex: none; color: var(--hint); font-family: var(--mono); }
@media (prefers-reduced-motion: reduce) { .donut-slice, .dl-row { transition: none; } }

/* Accounts overview */
.acct-table { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface); }
.acct-empty { padding: 16px; color: var(--hint); font-size: 12px; text-align: center; }
.acct-head, .acct-foot, .acct-row {
  display: grid;
  grid-template-columns: 12px minmax(64px, 1.4fr) repeat(3, minmax(46px, 1fr)) 14px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.acct-head {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--hint);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.acct-head .acct-metric { color: var(--hint); }
.acct-row {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: default;
}
.acct-row.has-kids { cursor: pointer; }
.acct-row.has-kids:hover { background: var(--surface-2); }
.acct-row:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: -2px; }
.acct-dot { width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 0 1.2px var(--brand-dim); }
.acct-dot--spacer { background: transparent; box-shadow: none; }
.acct-name { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.acct-count { flex: none; min-width: 15px; padding: 0 4px; border-radius: 999px; background: var(--surface-3); color: var(--hint); font-family: var(--mono); font-size: 9.5px; font-weight: 700; text-align: center; }
.acct-metric { color: var(--sub); font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.acct-metric.acct-invested { color: var(--ink); font-weight: 600; }
.acct-caret { color: var(--hint); font-size: 10px; text-align: center; transition: transform .15s ease; }
.acct-row[aria-expanded="true"] .acct-caret { transform: rotate(90deg); }
.acct-item:last-child .acct-row { border-bottom: 0; }
.acct-children { padding: 4px 12px 8px 30px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.acct-child { display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 12px; padding: 3px 0; color: var(--sub); font-size: 11px; }
.acct-child-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-child-fig, .acct-child-pct { font-family: var(--mono); color: var(--hint); }
.acct-child-pct { min-width: 30px; text-align: right; }
.acct-foot { background: var(--surface-2); color: var(--ink); }
.acct-foot .acct-name { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .acct-caret { transition: none; } }

/* 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; }
.fi-color {
  height: 38px;
  padding: 4px;
  cursor: pointer;
}
.fi-color::-webkit-color-swatch-wrapper { padding: 0; }
.fi-color::-webkit-color-swatch {
  border: 0;
  border-radius: calc(var(--r) - 3px);
}
.fi-color::-moz-color-swatch {
  border: 0;
  border-radius: calc(var(--r) - 3px);
}
.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-group {
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.subj-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.subj-group-head-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.sj-color--group {
  width: 26px;
  height: 22px;
  flex: 0 0 26px;
}
.subj-group-head span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.subj-group-head small {
  color: var(--hint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.subj-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 0;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}
.subj-item-row:last-child { border-bottom: 0; }
.subj-item-row--child { padding-left: 34px; position: relative; }
.subj-item-row--child .sj-name { font-weight: 600; }
.sj-connector {
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 50%;
  width: 10px;
  border-left: 1px solid var(--line2);
  border-bottom: 1px solid var(--line2);
  border-bottom-left-radius: 6px;
}
.sj-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; box-shadow: 0 0 0 1.2px var(--brand-dim); }
.sj-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.sj-name { flex: 0 1 auto; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sj-path { flex: 0 0 auto; overflow: hidden; color: var(--hint); font-family: var(--mono); font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sj-budget { margin-left: auto; flex: 0 0 auto; color: var(--sub); font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.sj-color {
  position: relative;
  width: 32px;
  height: 28px;
  flex: 0 0 32px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface-2);
  cursor: pointer;
}
.sj-color:hover { border-color: var(--line-strong); }
.sj-color span {
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ink) 18%, transparent);
  pointer-events: none;
}
.sj-color input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.sj-color input:focus-visible + span,
.sj-color:has(input:focus-visible) {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}
.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); }

/* Category folder tree (settings) */
#subj-list { display: flex; flex-direction: column; gap: 1px; }
.cat-row, .cat-folder-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 5px 8px;
  border-radius: var(--r2);
}
.cat-row:hover, .cat-folder-head:hover { background: var(--surface-2); }
.cat-dot-edit {
  position: relative;
  width: 20px;
  height: 20px;
  flex: none;
  cursor: pointer;
}
.cat-dot-edit input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.cat-dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 3px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .08);
}
.cat-dot-edit:hover .cat-dot { box-shadow: inset 0 0 0 1px oklch(0% 0 0 / .12), 0 0 0 3px var(--brand-dim); }
.cat-folder-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cat-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-name--folder { font-weight: 700; }
.cat-count {
  margin-left: auto;
  flex: none;
  color: var(--sub);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.cat-chevron {
  flex: none;
  display: inline-flex;
  color: var(--hint);
  transition: transform .18s ease;
}
.cat-folder.collapsed .cat-chevron { transform: rotate(-90deg); }
.cat-folder.collapsed .cat-folder-body { display: none; }
.cat-folder-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 24px;
}
.cat-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cat-sub { color: var(--hint); font-family: var(--mono); font-size: 11px; }
.cat-edit {
  flex: none;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.cat-edit:hover { border-color: var(--line-strong); color: var(--ink); }
.cat-del {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--hint);
  font-size: 16px;
  cursor: pointer;
}
.cat-del:hover { background: var(--debit-dim); color: var(--debit); }
@media (prefers-reduced-motion: reduce) { .cat-chevron { transition: none; } }

/* 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); font-weight: 600; }

/* Log-time modal: preview of the row about to post */
.log-post-preview {
  margin: 2px 0 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
.log-post-preview[hidden] { display: none; }
.log-post-preview:empty { display: none; }

@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;
  }
}

/* Modals */
.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;
}

/* Apple Shortcuts setup: numbered steps, because the order genuinely matters
   (copy the key before the shortcut asks for it). */
.shortcut-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}
.shortcut-step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.shortcut-step-title {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.shortcut-step-sub {
  color: var(--sub);
  font-size: 12px;
  line-height: 1.7;
}
.shortcut-step-sub strong { color: var(--text); }
.shortcut-key-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.shortcut-key {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  /* The key is one long unbroken string: wrap it rather than let it push the
     modal wider than the viewport. */
  overflow-wrap: anywhere;
  user-select: all;
}
.shortcut-key-copy { flex: none; }
.shortcut-key-note {
  margin-top: 8px;
  color: var(--sub);
  font-size: 11px;
}
.shortcut-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.shortcut-link { text-decoration: none; }
@media (max-width: 420px) {
  .shortcut-key-box { flex-direction: column; align-items: stretch; }
  .shortcut-key-copy { width: 100%; }
}
.post-plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.post-plan-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.post-plan-row:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.post-plan-row:disabled { cursor: default; opacity: .64; }
.post-plan-time {
  color: var(--sub);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.post-plan-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.post-plan-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-plan-main small {
  overflow: hidden;
  color: var(--sub);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-plan-state {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}
.post-plan-empty {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--line2);
  border-radius: var(--r2);
  background: var(--surface-2);
  color: var(--sub);
  font-size: 13px;
}
.post-plan-empty strong { color: var(--ink); }
.duration-field-row {
  display: grid;
  grid-template-columns: minmax(0, 82px) auto minmax(0, 82px) auto;
  align-items: center;
  gap: 8px;
}
.duration-number {
  width: 100%;
  min-width: 0;
}
.duration-unit {
  color: var(--sub);
  font-size: 13px;
}
.log-time-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 10px;
}
.log-duration-field { min-width: 0; }
.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; }
.fg-optional { color: var(--hint); font-weight: 400; font-size: 11px; }
.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)); }
  .auth-habit-example {
    grid-template-columns: minmax(180px, .72fr) minmax(0, 1fr);
    align-items: center;
  }
  .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; }
  .log-time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log-duration-field { grid-column: 1 / -1; }
}

@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; }
  .balance-meta-item + .balance-meta-item { border-left: 0; padding-left: 0; }
  .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;
  }
  .timer-banner { margin: 0; }
  .ledger-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 0 0; }
  .ledger-column-head {
    display: grid;
    grid-template-columns: 72px 38px minmax(0, 1fr) 88px 96px 82px 42px 30px;
    gap: 11px;
    padding: 9px 14px;
  }
  .sec-hdr { padding: 18px 0 9px; }
  .txn-list { padding: 0; }
  .txn-row {
    grid-template-columns: 72px 38px minmax(0, 1fr) 88px 96px 82px 42px 30px;
    gap: 11px;
    padding: 11px 14px;
  }
  .txn-duration,
  .txn-balance,
  .txn-edit { display: block; }
  .txn-balance { color: var(--hint); }
  .txn-posted { font-size: 12px; }
  .calendar-panel { padding: 0 0 8px !important; }
  .invest-wrap, .stats-wrap, .settings-wrap, .habits-wrap { max-width: 960px; margin: 0 auto; padding: 0; }
  .habits-wrap { max-width: 1120px; }
  .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-strip--wrap { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-strip--wrap .stat-strip-item:nth-child(n+3) { border-top: 0; }
  .stat-strip--wrap .stat-strip-item + .stat-strip-item { border-left: 1px solid var(--line); }
  .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; }
  .log-time-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .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'] .stat-strip-item,
body[data-density='compact'] .setting-row { padding: 10px; }
body[data-density='compact'] .timer-banner { 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;
}
