:root {
  --bg: #F2F5F3;
  --surface: #FFFFFF;
  --ink: #15211C;
  --ink-2: #4E5E57;
  --ink-3: #7E8C86;
  --line: #DCE4E0;
  --tea: #22564A;
  --tea-soft: #D7E6E0;
  --mist: #E7EEEA;
  --ok: #2E7A4F;
  --warn: #A86A12;
  --warn-soft: #F6E8CF;
  --bad: #B03A32;
  --bad-soft: #F5DCD9;
  --empty: #E1E8E4;
  --radius-lg: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  --display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --text: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101915; --surface: #18241F; --ink: #E7EFEA; --ink-2: #A9B9B1; --ink-3: #7A8C84;
    --line: #26352E; --tea: #7DC3AE; --tea-soft: #1F3A32; --mist: #1C2A24;
    --ok: #6CC895; --warn: #E2A84B; --warn-soft: #3A2E18; --bad: #EE8077; --bad-soft: #3D2220; --empty: #24332C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101915; --surface: #18241F; --ink: #E7EFEA; --ink-2: #A9B9B1; --ink-3: #7A8C84;
  --line: #26352E; --tea: #7DC3AE; --tea-soft: #1F3A32; --mist: #1C2A24;
  --ok: #6CC895; --warn: #E2A84B; --warn-soft: #3A2E18; --bad: #EE8077; --bad-soft: #3D2220; --empty: #24332C;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--text); -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--tea); outline-offset: 2px; }
.num, .big, h1, h2 { font-family: var(--display); font-variant-numeric: tabular-nums; }

#view { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(96px + var(--safe-b)); }

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 16px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 28px 0 10px; letter-spacing: -0.01em; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.8rem; color: var(--ink-3); }

/* Top bar on home */
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price .num { font-size: 1rem; font-weight: 600; }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
}
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.iconbtn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Runway hero */
.hero { margin: 0 0 8px; }
.hero .big { font-size: 4.25rem; line-height: 1; font-weight: 700; letter-spacing: -0.04em; }
.hero .big small { font-size: 1.25rem; font-weight: 600; letter-spacing: 0; margin-left: 6px; color: var(--ink-2); }
.hero p { margin-top: 8px; color: var(--ink-2); }

.strip { margin: 18px 0 6px; }
.strip-row { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px; position: relative; }
.cell { height: 34px; border-radius: 4px; background: var(--empty); position: relative; overflow: hidden; }
.cell i { position: absolute; inset: 0 auto 0 0; background: var(--fill, var(--tea)); }
.cell.mark-target { box-shadow: inset -2px 0 0 var(--ink); }
.cell.mark-trigger { box-shadow: inset -2px 0 0 var(--bad); }
.strip-labels { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px; margin-top: 6px; }
.strip-labels span { font-size: 0.7rem; color: var(--ink-3); white-space: nowrap; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 0.8rem; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 2px; height: 12px; margin-right: 6px; vertical-align: -1px; background: var(--ink); }
.legend .lt::before { background: var(--warn); width: 10px; height: 10px; border-radius: 2px; vertical-align: 0; }

/* Status list */
.status { margin-top: 22px; border-top: 1px solid var(--line); }
.status-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pill {
  flex: none; font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--tea-soft); color: var(--ok); min-width: 82px; text-align: center; margin-top: 2px;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.status-row strong { font-weight: 600; display: block; }
.status-row .muted { font-size: 0.9rem; }

/* Panels */
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-top: 12px; border: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--ink-2); }
.kv .num { font-weight: 600; text-align: right; }
.callout { background: var(--mist); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; }
.callout strong { font-family: var(--display); }

/* Bars */
.bar-row { padding: 10px 0; }
.bar-row + .bar-row { border-top: 1px solid var(--line); }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.95rem; }
.bar-head .num { font-size: 0.9rem; }
.bar { height: 8px; border-radius: 999px; background: var(--empty); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--tea); border-radius: 999px; }
.bar.over i { background: var(--bad); }
.bar.near i { background: var(--warn); }
.bar-foot { font-size: 0.8rem; color: var(--ink-3); margin-top: 4px; }

.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.monthnav h1 { margin: 0; }

/* Log */
.day { margin-top: 20px; }
.day-head { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--ink-2); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.entry { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; gap: 12px; }
.entry .note { display: block; font-size: 0.85rem; color: var(--ink-3); }
.entry .num { font-weight: 600; white-space: nowrap; }
.empty { text-align: center; padding: 48px 12px; color: var(--ink-2); }

/* More menu */
.menu { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 15px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.menu li + li button { border-top: 1px solid var(--line); }
.menu .tiny { text-align: right; }
.back { background: none; border: 0; padding: 6px 0; color: var(--tea); font-weight: 600; }

/* Forms */
label.field { display: block; margin-top: 14px; }
label.field > span { display: block; font-size: 0.875rem; color: var(--ink-2); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px; min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--tea); outline-offset: -1px; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: block; width: 100%; border: 0; border-radius: 999px; padding: 14px 18px; min-height: 52px;
  background: var(--tea); color: var(--bg); font-weight: 600; font-size: 1rem; margin-top: 20px;
}
.btn.ghost { background: transparent; color: var(--tea); border: 1px solid var(--line); margin-top: 10px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); margin-top: 10px; }
.btn:disabled { opacity: 0.5; }

/* Add sheet */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 24px 24px 0 0;
  background: var(--bg); color: var(--ink); max-height: 92dvh;
}
.sheet::backdrop { background: rgb(10 20 16 / 0.45); }
.sheet form { padding: 12px 16px calc(20px + var(--safe-b)); overflow-y: auto; max-height: 92dvh; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; }
.sheet-top h2 { margin: 0; }
.amount { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--tea); margin: 18px 0 4px; padding-bottom: 4px; }
.amount span { font-family: var(--display); color: var(--ink-2); font-size: 1.1rem; }
.amount input { border: 0; background: transparent; padding: 0; font-family: var(--display); font-size: 2.6rem; font-weight: 700; min-height: 0; letter-spacing: -0.02em; }
.amount input:focus { outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; font-size: 0.9rem; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--tea); border-color: var(--tea); color: var(--bg); }
.chips-label { font-size: 0.8rem; color: var(--ink-3); margin-top: 16px; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login .big { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; }
.error { color: var(--bad); font-size: 0.9rem; margin-top: 10px; }

/* Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b));
}
.tabs[hidden] { display: none; }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 0.72rem; color: var(--ink-3); }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[data-tab="more"] svg { fill: currentColor; stroke: none; }
.tab[aria-current="page"] { color: var(--tea); }
.tab.add { justify-self: center; width: 54px; height: 54px; border-radius: 50%; background: var(--tea); color: var(--bg); margin-top: -18px; box-shadow: 0 4px 14px rgb(20 50 40 / 0.25); padding: 0; justify-content: center; }
.tab.add svg { width: 26px; height: 26px; stroke-width: 2.4; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 500;
  max-width: calc(100% - 32px);
}
.sync { font-size: 0.75rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync.pending::before { background: var(--warn); }
.sync.offline::before { background: var(--ink-3); }

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