*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0d10;
  --surface: #15171c;
  --elevated: #1c1f26;
  --fg: #f0ebe3;
  --muted: #8b8a84;
  --subtle: #5e5d58;
  --line: #2a2d34;
  --accent: #b8c0cc;
  --accent-fg: #0c0d10;
  --good: #6f9e7a;
  --bad: #c17a72;
  --radius: 20px;
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Outfit", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: 88px;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; padding: 24px 20px 0; }
.kicker { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
h1 { font-family: var(--font-display); font-size: 28px; font-weight: 500; letter-spacing: -0.03em; line-height: 1; }
.balance-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 8px 12px; text-align: right; }
.balance-chip small { display: block; font-size: 10px; color: var(--muted); }
.balance-chip strong { font-size: 14px; font-weight: 500; }

.card { margin: 20px; border: 1px solid var(--line); background: var(--surface); border-radius: 28px; padding: 20px; }
.idx-row { display: flex; justify-content: space-between; align-items: center; }
.idx-val { font-family: var(--font-mono); font-size: 24px; }
.pill { font-size: 11px; border-radius: 999px; padding: 4px 8px; }
.pill.up { background: color-mix(in oklab, var(--good) 15%, transparent); color: var(--good); }
.pill.down { background: color-mix(in oklab, var(--bad) 15%, transparent); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: var(--elevated); border-radius: 12px; padding: 8px; }
.stat span { display: block; font-size: 10px; color: var(--muted); }
.stat b { font-size: 13px; font-weight: 500; }
.xp { height: 4px; background: var(--line); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.xp > i { display: block; height: 100%; background: var(--accent); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 20px; }
.quick button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: 12px 4px; font-size: 11px; color: var(--muted);
}
.quick svg { display: block; margin: 0 auto 6px; }

.section { padding: 24px 20px 0; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-h h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.link { font-size: 12px; color: var(--accent); }

.vault { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 12px; margin-bottom: 8px; }
.vault .meta { flex: 1; min-width: 0; }
.vault .row { display: flex; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); font-size: 11px; }
.empty { border: 1px dashed var(--line); border-radius: 20px; padding: 32px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.note { padding: 16px 20px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.note a { color: var(--accent); }

.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 94%, transparent);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.nav button { color: var(--muted); font-size: 10px; }
.nav button.active { color: var(--fg); }
.nav svg { display: block; margin: 0 auto 2px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.panel {
  width: 100%; max-width: 430px; background: var(--bg); border-radius: 28px 28px 0 0;
  border-top: 1px solid var(--line); max-height: 88vh; overflow-y: auto; padding: 12px 20px 32px;
}
.handle { width: 40px; height: 4px; background: var(--line); border-radius: 99px; margin: 4px auto 16px; }
.panel-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-h h3 { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.close { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); color: var(--muted); }

.pkg { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 16px; margin-bottom: 8px; }
.pkg.on { border-color: var(--accent); background: var(--elevated); }
.pkg .row { display: flex; justify-content: space-between; }
.good { color: var(--good); }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chips button, .method { height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; font-size: 12px; }
.chips button.on { border-color: var(--accent); background: var(--elevated); }
.field {
  width: 100%; height: 48px; margin-top: 12px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 12px; padding: 0 12px; outline: none;
}
.field:focus { border-color: var(--accent); }
.btn {
  width: 100%; height: 56px; margin-top: 20px; border-radius: 12px;
  background: var(--accent); color: var(--accent-fg); font-weight: 500; font-size: 16px;
}
.btn.good { background: var(--good); color: var(--bg); }
.btn.ghost { background: transparent; color: var(--bad); height: 44px; font-size: 14px; }

.board, .hist { display: flex; flex-direction: column; gap: 8px; }
.row-card { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px 16px; }
.row-card.me { border-color: var(--accent); background: var(--elevated); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 16px 0; }
.day { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; font-size: 11px; color: var(--subtle); }
.day.on { border-color: color-mix(in oklab, var(--good) 40%, transparent); background: color-mix(in oklab, var(--good) 10%, transparent); color: var(--good); }
.center-card { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 40px 16px; text-align: center; }
.spin-face { font-family: var(--font-mono); font-size: 32px; }

.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  z-index: 50; background: var(--elevated); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; font-size: 14px; white-space: nowrap;
}

.landing { min-height: 100dvh; padding: 48px 24px 80px; }
.landing h1 { font-size: 40px; max-width: 12ch; }
.landing p { margin-top: 16px; color: var(--muted); line-height: 1.5; max-width: 36ch; }
.landing .btn { max-width: 280px; }

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