/* Self-hosted fonts (SIL Open Font License, see /fonts/LICENSE-*.txt).
   font-display: optional means no layout jump when the fonts arrive late. */
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 400; font-display: optional; src: url('/fonts/manrope-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 600; font-display: optional; src: url('/fonts/manrope-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 700; font-display: optional; src: url('/fonts/manrope-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 800; font-display: optional; src: url('/fonts/manrope-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: optional; src: url('/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: optional; src: url('/fonts/jetbrains-mono-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #111214;
  --surface: #1a1c1f;
  --surface-2: #202326;
  --line: #2a2d31;
  --line-2: #363a3f;
  --text: #f2f1ec;
  --text-2: #c8cacd;
  --muted: #9ba1a7;
  --faint: #7d8389;
  --accent: #b4d24a;
  --accent-hover: #c3de62;
  --loss: #e8865e;
  --warn: #e0a050;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar: 248px;
  --nav-h: 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-wrap: anywhere; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input { font: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
span.mono, .stat-value, .amount { white-space: nowrap; } /* keep "−$719" on one line */
.loss { color: var(--loss); }
.gain { color: var(--accent); }
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 30;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  background: var(--accent); color: var(--bg); font-weight: 700; border-radius: var(--radius-sm); text-decoration: none;
}
.skip:focus { top: 12px; color: var(--bg); }

/* ---------- Icons (custom, square caps) ---------- */
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 64px; padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { width: 33px; height: 22px; flex: none; }
.brand-word { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.topbar-wallet { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 359px) { .topbar-wallet { display: none; } }
.menu-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: transparent; color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer;
}
.menu-btn[aria-expanded="true"] { background: var(--surface-2); }
.mobile-menu { border-bottom: 1px solid var(--line); padding: 8px 12px 16px; background: var(--bg); }
.mobile-menu[hidden] { display: none; }
.mobile-menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mobile-menu a {
  display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 10px;
  border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 600;
}
.mobile-menu a[aria-current="page"] { background: var(--surface); color: var(--text); }
.mobile-menu a[aria-current="page"] .ico { stroke: var(--accent); }
.mobile-menu .menu-sep { height: 1px; background: var(--line); margin: 8px 10px; }

.view { padding: 24px 20px 32px; max-width: 760px; margin: 0 auto; outline: none; }

.site-foot {
  max-width: 760px; margin: 0 auto; padding: 20px 20px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.shell.is-home .site-foot, .shell.no-report .site-foot { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.site-foot nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; }
.site-foot a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.site-foot a:hover { color: var(--text); }
.site-foot p { margin: 6px 0 0; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 2px;
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.bottom-nav a {
  flex: 1 1 0; min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; text-align: center; overflow-wrap: normal;
}
.bottom-nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.bottom-nav a[aria-current="page"] .ico, .side-nav a[aria-current="page"] .ico { stroke: var(--accent); }
.shell.is-home .bottom-nav, .shell.no-report .bottom-nav { display: none; }
.shell.no-report [data-needs-report] { display: none !important; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .topbar, .mobile-menu, .bottom-nav { display: none !important; }
  .sidebar {
    display: flex; flex-direction: column; gap: 28px;
    position: sticky; top: 0; height: 100vh; padding: 28px 18px;
    border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0 12px; }
  .sidebar .brand-mark { width: 42px; height: 28px; }
  .sidebar .brand-word { font-size: 30px; }
  .content { min-width: 0; }
  .view { padding: 48px 48px 40px; margin: 0; max-width: 820px; }
  .site-foot { margin: 0 48px; padding: 20px 0 32px; max-width: 724px; }
  .shell.is-home .site-foot, .shell.no-report .site-foot { padding-bottom: 32px; }
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent; color: var(--text-2); text-decoration: none; font-size: 16px; font-weight: 600;
}
.side-nav a:hover { color: var(--text); background: var(--surface); }
.side-nav a[aria-current="page"] { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.side-foot { margin: auto 0 0; padding: 0 14px; font-size: 12px; color: var(--muted); }

/* ---------- Type ---------- */
.eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
h1 { margin: 6px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
.lede { margin: 8px 0 0; color: var(--muted); }
@media (min-width: 900px) { h1 { font-size: 34px; } }

/* ---------- Building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.edge { border-color: var(--accent); }
.rule { height: 1px; background: var(--line-2); border: 0; margin: 0; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-width: 0; }
.row > :last-child { text-align: right; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.note { font-size: 13px; color: var(--muted); margin: 0; }
.status {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 14px;
  border: 1px solid var(--accent); border-radius: var(--radius); color: var(--text); font-size: 14px; font-weight: 600;
}
.status::before { content: ''; width: 8px; height: 8px; flex: none; background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: transparent; color: var(--text); font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn:hover { color: var(--text); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg); }
.btn.link { border: 0; min-height: 44px; padding: 0 6px; color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn.link:hover { color: var(--text); }
.btn[disabled] { opacity: 0.7; cursor: progress; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 200px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.input {
  min-height: 52px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 16px; width: 100%; min-width: 0;
}
.input[aria-invalid="true"] { border-color: var(--loss); }
.error { color: var(--loss); font-size: 14px; font-weight: 600; margin: 0; }
.error:empty { display: none; }

/* ---------- Home ---------- */
.hero { display: flex; flex-direction: column; gap: 20px; padding-top: 4px; }
.hero-logo { display: flex; align-items: center; gap: 16px; }
.hero-logo svg { width: 72px; height: 48px; flex: none; }
.hero-logo span { font-size: 56px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.hero-tag { margin: 0; font-size: 22px; line-height: 1.35; font-weight: 600; letter-spacing: -0.02em; max-width: 30ch; }
.hero-tag em { font-style: normal; color: var(--accent); }
@media (min-width: 900px) {
  .hero { padding-top: 32px; gap: 22px; }
  .hero-logo svg { width: 132px; height: 88px; }
  .hero-logo span { font-size: 104px; }
  .hero-tag { font-size: 28px; }
}
.hero-form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.hero-points { display: grid; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; max-width: 600px; }
.hero-points li { display: flex; gap: 12px; color: var(--text-2); font-size: 15px; }
.hero-points b { font-family: var(--mono); color: var(--accent); font-weight: 600; min-width: 24px; }

/* ---------- Loading ---------- */
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.steps li.done { color: var(--text-2); }
.steps li.active { color: var(--text); }
.dot { width: 10px; height: 10px; background: var(--line-2); flex: none; }
.steps li.done .dot, .steps li.active .dot { background: var(--accent); }
.steps li.active .dot { animation: blink 1.2s steps(2, end) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* Skeleton placeholders hold the space while data loads, so nothing jumps. */
.skel { background: var(--surface-2); border-radius: var(--radius-sm); animation: fade 1.4s ease-in-out infinite; }
.skel-line { height: 14px; }
.skel-block { height: 56px; }
@keyframes fade { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .steps li.active .dot, .skel { animation: none; } }

/* ---------- Report ---------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.grade { font-size: 72px; line-height: 0.85; font-weight: 800; color: var(--accent); letter-spacing: -0.05em; white-space: nowrap; }
.grade.bad { color: var(--loss); }
.grade.na { font-size: 40px; color: var(--muted); }
.roast { margin: 0; padding: 16px; background: var(--bg); border-radius: var(--radius); font-size: 19px; line-height: 1.35; font-weight: 600; letter-spacing: -0.01em; }
.kv { display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--text-2); }
.kv .mono { color: var(--text); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
@media (min-width: 640px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 359px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .stat-value { font-size: 17px; }
.whatif { margin: 0; font-size: 17px; line-height: 1.45; font-weight: 600; }

/* ---------- Leaks ---------- */
.leak { display: flex; flex-direction: column; gap: 8px; }
.leak p { margin: 0; font-size: 15px; color: var(--text-2); }
.leak .amount { font-family: var(--mono); font-size: 15px; font-weight: 600; white-space: nowrap; }
.leak .compare { font-size: 13px; color: var(--muted); }
.leak .compare b { color: var(--text); font-weight: 700; }
.bar { display: flex; gap: 3px; }
.bar span { flex: 1; height: 6px; border-radius: 1px; background: var(--loss); }
.bar span.win { background: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); color: var(--muted); }
.badge.strong { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.badge.likely { border-color: var(--accent); color: var(--accent); }
.badge.found { border-style: dashed; color: var(--text-2); }

/* ---------- Progress ---------- */
.weeks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.week { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "label bar pnl" ". meta meta"; gap: 4px 12px; align-items: center; }
.week-label { grid-area: label; font-size: 13px; color: var(--text-2); }
.week-bar { grid-area: bar; height: 10px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.week-bar span { display: block; height: 100%; }
.week-bar .neg { background: var(--loss); }
.week-bar .pos { background: var(--accent); }
.week-pnl { grid-area: pnl; font-size: 14px; font-weight: 600; text-align: right; min-width: 60px; }
.week-meta { grid-area: meta; font-size: 12px; color: var(--muted); }
.habits { display: flex; flex-direction: column; gap: 12px; }
.habit-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.habit-name { font-size: 14px; font-weight: 600; color: var(--text-2); }
.habit-cells { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.habit-cells span {
  display: flex; align-items: center; justify-content: center; min-height: 30px;
  background: var(--surface-2); border-radius: 2px; font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.habit-cells span.zero { color: var(--faint); font-weight: 400; }
.habit-head .habit-cells span { background: transparent; min-height: 0; font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--muted); }
@media (min-width: 640px) {
  .habit-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: center; gap: 12px; }
}

/* ---------- Exits ---------- */
.exits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.exit { display: flex; flex-direction: column; gap: 4px; }
.exit .mono { font-weight: 600; }

/* ---------- Check ---------- */
.verdict { border-radius: var(--radius); padding: 18px; color: var(--bg); display: flex; flex-direction: column; gap: 4px; }
.verdict.skip { background: var(--loss); }
.verdict.caution { background: var(--warn); }
.verdict.ok { background: var(--accent); }
.verdict .big { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.verdict .eyebrow { color: var(--bg); }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.facts li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.facts .tag { font-family: var(--mono); font-size: 11px; font-weight: 600; min-width: 40px; padding-top: 3px; }
.facts .tag.flag { color: var(--loss); }
.facts .tag.ok { color: var(--accent); }
.facts .tag.na { color: var(--muted); }

/* ---------- Static pages (terms, privacy, 404) ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 24px 20px 48px; }
.page h2 { font-size: 20px; margin: 28px 0 8px; }
.page p, .page li { color: var(--text-2); }
.page ul { padding-left: 20px; }
.page-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 8px 20px; border-bottom: 1px solid var(--line); }
.page-foot { max-width: 720px; margin: 0 auto; padding: 20px 20px 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.page-foot nav { display: flex; flex-wrap: wrap; gap: 0 18px; }
.page-foot a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; color: var(--text-2); }
