/* Payday Ledger, design B: black and white + one highlighter colour.
   Only the tokens below may be used for colour (checked by tools/check-tokens.mjs). */
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("fonts/dmsans.woff2") format("woff2"); font-weight: 100 1000; font-display: swap; }

:root {
  --bg: #FFFFFF;
  --ink: #111111;
  --sub: #6B6B6B;
  --hl: #D9F45B;
  --on-hl: #111111;
  --warn: #B3381F;
  --line: #E4E4E4;
  --field: #767676;
  --btn-bg: #111111;
  --btn-ink: #FFFFFF;
  --card: #F5F5F5;
  --focus: #111111;
  --big-ink: #111111;
  --band-from: 48%;
  --band-to: 94%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --ink: #F2F2F2; --sub: #A8A8A8; --hl: #D9F45B; --on-hl: #111111; --warn: #FF8F73;
    --line: #333333; --field: #8C8C8C; --btn-bg: #F2F2F2; --btn-ink: #111111; --card: #1E1E1E; --focus: #D9F45B; --big-ink: #111111; --band-from: 14%; --band-to: 96%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --ink: #F2F2F2; --sub: #A8A8A8; --hl: #D9F45B; --on-hl: #111111; --warn: #FF8F73;
  --line: #333333; --field: #8C8C8C; --btn-bg: #F2F2F2; --btn-ink: #111111; --card: #1E1E1E; --focus: #D9F45B; --big-ink: #111111; --band-from: 14%; --band-to: 96%;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.45; font-feature-settings: "tnum" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; padding: 0 24px calc(112px + env(safe-area-inset-bottom)); }
@media (max-width: 359px) { #app { padding-left: 16px; padding-right: 16px; } }

/* ---------- header bar ---------- */
.bar { min-height: 56px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; gap: 12px; }
.bar .date { flex: 1; color: var(--sub); }
.bar .title { flex: 1; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; flex: none; }
.icon-btn:hover { background: var(--card); }
.bar .back { margin-left: -12px; }
.bar .end { margin-right: -10px; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.steps { flex: 1; display: flex; gap: 6px; }
.steps i { flex: 1; height: 6px; background: var(--line); }
.steps i.on { background: var(--ink); }
.meta { font-size: 14px; color: var(--sub); }
.demo-tag { font-size: 14px; color: var(--sub); }

/* ---------- type ---------- */
h1 { font-family: "DM Sans", "Inter", sans-serif; font-weight: 800; font-variation-settings: "opsz" 40; letter-spacing: -0.03em; font-size: 28px; line-height: 1.15; margin-top: 12px; }
h2 { font-size: 16px; font-weight: 600; }
.lead { margin-top: 8px; color: var(--sub); }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* ---------- today ---------- */
.today { margin-top: 16px; }
.label { color: var(--sub); }
.big { font-family: "DM Sans", "Inter", sans-serif; font-weight: 800; font-variation-settings: "opsz" 40; letter-spacing: -0.05em; line-height: 1; margin-top: 6px; font-size: 96px; overflow-wrap: anywhere; }
.big.len-m { font-size: 72px; }
.big.len-l { font-size: 56px; }
.big.len-xl { font-size: 44px; }
@media (max-width: 359px) { .big { font-size: 80px; } .big.len-m { font-size: 60px; } .big.len-l { font-size: 46px; } .big.len-xl { font-size: 36px; } }
.big .hl { background: linear-gradient(transparent var(--band-from), var(--hl) var(--band-from), var(--hl) var(--band-to), transparent var(--band-to)); color: var(--big-ink); padding: 0 8px; margin-left: -8px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.payday { margin-top: 12px; }
.alert { margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-weight: 600; }
.alert svg.i { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.alert-hint { margin-top: 4px; color: var(--sub); }

/* ---------- the math ---------- */
.math { margin-top: 24px; border: 1.5px solid var(--ink); border-radius: 18px; padding: 12px 16px 0; }
.math .row { min-height: 36px; align-items: center; }
.math .sum { border-top: 1px solid var(--ink); }
.math .res { border-top: 3px double var(--ink); font-weight: 600; min-height: 44px; }
.math .note { font-size: 14px; color: var(--sub); padding: 4px 0 8px; }
.hl2 { background: var(--hl); color: var(--on-hl); padding: 2px 6px; border-radius: 4px; }
.toggle, .link { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.toggle svg.i { width: 16px; height: 16px; stroke-width: 2.2; }
.math-closed { margin-top: 16px; }

/* ---------- lists ---------- */
.section { margin-top: 28px; }
.section .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.list { list-style: none; margin-top: 8px; }
.item { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); text-align: left; padding: 6px 0; }
.item .d { min-width: 64px; flex: none; color: var(--sub); white-space: nowrap; }
.item .n { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .n small { display: block; font-size: 14px; color: var(--sub); }
.item.skipped .n, .item.skipped .amt { text-decoration: line-through; color: var(--sub); }
.item.skipped .tag { font-size: 14px; color: var(--sub); text-decoration: none; }
.empty { color: var(--sub); padding: 12px 0; }
.total { display: flex; justify-content: space-between; align-items: center; min-height: 48px; background: var(--hl); color: var(--on-hl); font-weight: 600; padding: 0 12px; margin: 8px -12px 0; border-radius: 8px; }
.add { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 4px; }
.add span { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.add svg.i { width: 18px; height: 18px; stroke-width: 2.2; }

/* ---------- setup ---------- */
.answered { list-style: none; margin-top: 20px; border-top: 1.5px solid var(--ink); }
.answered li button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); text-align: left; padding: 6px 0; }
.answered .ok svg.i { width: 18px; height: 18px; stroke-width: 2.2; }
.answered .q { color: var(--sub); flex: none; }
.answered .a { margin-left: auto; font-weight: 600; text-align: right; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.current { margin-top: 24px; }
.current h2 { display: flex; gap: 10px; align-items: flex-start; }
.num { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 14px; background: var(--ink); color: var(--bg); flex: none; margin-top: -1px; }
.hint { margin-top: 4px; color: var(--sub); }
.current .hint { padding-left: 34px; }

/* ---------- forms ---------- */
.field { margin-top: 16px; display: block; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.input, select.input { width: 100%; min-height: 48px; border: 1.5px solid var(--field); border-radius: 12px; padding: 10px 14px; background: var(--bg); font-size: 18px; }
select.input { font-size: 16px; appearance: auto; }
.input.money { font-size: 24px; font-weight: 600; }
.input:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
.input[aria-invalid="true"] { border-color: var(--warn); }
.err { color: var(--warn); font-weight: 600; margin-top: 6px; min-height: 0; }
.two { display: flex; gap: 12px; }
.two > * { flex: 1; min-width: 0; }
.seg { display: flex; border: 1.5px solid var(--field); border-radius: 999px; padding: 3px; gap: 3px; margin-top: 16px; }
.seg button { flex: 1; min-height: 44px; border-radius: 999px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.computed { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card); }

/* ---------- buttons ---------- */
.primary-wrap { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 24px calc(20px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 28%); }
.primary-wrap .inner { max-width: 432px; margin: 0 auto; }
@media (max-width: 359px) { .primary-wrap { padding-left: 16px; padding-right: 16px; } }
.btn { min-height: 52px; width: 100%; border-radius: 999px; background: var(--btn-bg); color: var(--btn-ink); font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; }
.btn svg.i { width: 20px; height: 20px; stroke-width: 2.2; }
.btn.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.danger { background: transparent; color: var(--warn); border: 1.5px solid var(--warn); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

/* ---------- notices ---------- */
.notice { margin-top: 12px; border-radius: 16px; background: var(--card); padding: 14px 16px; }
.notice.strong { border: 1.5px solid var(--ink); background: var(--bg); }
.notice p + p { margin-top: 6px; }
.notice .title { font-weight: 600; }
.notice .actions { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- settings ---------- */
.group { margin-top: 24px; }
.group h2 { font-size: 14px; color: var(--sub); font-weight: 600; text-transform: none; }
.cell { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); text-align: left; padding: 8px 0; }
.cell .v { color: var(--sub); text-align: right; overflow-wrap: anywhere; }
.cell.danger { color: var(--warn); font-weight: 600; }
.prose p { margin-top: 12px; }
.prose ol, .prose ul { margin: 12px 0 0 20px; }
.prose li + li { margin-top: 6px; }

/* ---------- dialogs ---------- */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; background: var(--bg); color: var(--ink); }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog.sheet::backdrop { background: rgba(17, 17, 17, 0.55); }
.sheet-body { padding: 20px 24px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: inherit; }
@media (max-width: 359px) { .sheet-body { padding-left: 16px; padding-right: 16px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-family: "DM Sans", "Inter", sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sheet-head .icon-btn { margin-right: -10px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; max-width: calc(100% - 32px); z-index: 10; display: flex; gap: 14px; align-items: center; }
.toast button { color: inherit; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; font-weight: 700; }
.today h1.label { font-family: "Inter", system-ui, sans-serif; font-size: 18px; font-weight: 400; letter-spacing: 0; margin-top: 0; color: var(--sub); font-variation-settings: normal; }
.bar h1.title { font-family: "Inter", system-ui, sans-serif; font-size: 17px; font-weight: 600; letter-spacing: 0; margin: 0; font-variation-settings: normal; }
.display { font-family: "DM Sans", "Inter", sans-serif; font-weight: 800; font-variation-settings: "opsz" 40; letter-spacing: -0.03em; font-size: 28px; line-height: 1.15; margin-top: 12px; }
.prose h2 { margin-top: 24px; }
.next-left { min-height: 48px; align-items: center; font-weight: 600; border-top: 3px double var(--ink); margin-top: -1px; }
.section > .meta { margin-top: 4px; }
