/* GrumpyBooks — a desk tool, calm and dense enough to be useful (DESIGN.md §8). A humanist sans
   for the interface with tabular figures everywhere a number appears; one serif, large, for the
   Quick Entry box and page titles. Nothing under 14 px; the daily targets 40 px tall. One accent,
   moss green, for the primary action; amounts in ink, never red or green. Light and dark follow
   the system. The layout rules (rail + page, the top bar on an iPad upright, two faces on a phone)
   are DESIGN.md §6 and §9. The Newsreader face and the token pattern are copied from
   62. List/public/style.css (26 Oct 2026). */

@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/Newsreader.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #FAFAF7;
  --panel: #F1F3EC;
  --rule: #DADDD4;
  --ink: #1C1F1D;
  --ink-soft: #5B625C;
  --moss: #2F5D3A;
  --moss-soft: #E3EDE5;
  --on-moss: #FFFFFF;
  --warn: #9A3B2E;
  --shadow: 0 8px 24px rgba(28, 31, 29, .12);

  --serif: 'Newsreader', ui-serif, 'New York', Georgia, serif;
  --sans: -apple-system, system-ui, 'Helvetica Neue', 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --rail-w: 248px;
  --gutter: 32px;
  --t-body: 15px;
  --t-small: 14px;
  --t-title: 30px;
  --t-quick: 22px;
  --target: 40px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16181A; --panel: #1F2321; --rule: #30352F; --ink: #E8E9E4; --ink-soft: #A3AAA2;
    --moss: #7FB58A; --moss-soft: #24342A; --on-moss: #10251A; --warn: #E08A7A;
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16181A; --panel: #1F2321; --rule: #30352F; --ink: #E8E9E4; --ink-soft: #A3AAA2;
  --moss: #7FB58A; --moss-soft: #24342A; --on-moss: #10251A; --warn: #E08A7A;
  --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; font-variant-numeric: tabular-nums; }
button { cursor: pointer; }
a { color: var(--moss); }
:focus-visible { outline: 3px solid var(--moss); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.soft { color: var(--ink-soft); }
.small { font-size: var(--t-small); }

/* ---- the frame: rail + page ---- */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: 1fr auto; }
.page-quick { display: none; margin: 8px 0 20px; }
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 8px;
  padding: calc(16px + env(safe-area-inset-top)) 16px 16px max(16px, env(safe-area-inset-left));
  background: var(--panel); border-right: 1px solid var(--rule);
}
.wordmark {
  font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: var(--target); padding: 0 8px;
}
.rail-quick { padding: 4px 0 8px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: 10px; min-height: var(--target); padding: 0 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: var(--t-body);
}
.rail-link:hover { background: var(--moss-soft); }
.rail-link[aria-current="page"] { background: var(--moss); color: var(--on-moss); }
.rail-link .count { margin-left: auto; color: inherit; opacity: .8; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: var(--t-small); color: var(--ink-soft); }
.rail-foot a, .rail-foot button { color: var(--ink-soft); }
.rail-foot .text-btn { padding: 0; min-height: 32px; font-size: var(--t-small); }

.page-wrap { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: 0 var(--gutter) 64px; outline: none; max-width: 1240px; width: 100%; }

/* The status line: one plain sentence at the top of the page (DESIGN.md §7). */
.status {
  margin: 0; min-height: 28px; padding: 4px var(--gutter) 0; font-size: var(--t-small); color: var(--ink-soft);
  transition: opacity 300ms var(--ease); opacity: 0;
}
.status.on { opacity: 1; }
.status.warn { color: var(--warn); }

/* ---- Quick Entry (DESIGN.md §5.1): one serif line, the chip under it ---- */
.quick { display: flex; flex-direction: column; gap: 6px; }
.quick-input {
  width: 100%; min-height: 44px; padding: 8px 12px;
  font-family: var(--serif); font-size: var(--t-quick); line-height: 1.2;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.quick-input::placeholder { color: var(--ink-soft); opacity: .85; }
.quick-input:focus { outline: 3px solid var(--moss); outline-offset: 0; border-color: transparent; }
.quick-hint { margin: 0; font-size: var(--t-small); color: var(--ink-soft); }
.quick.large .quick-input { min-height: 56px; font-size: 28px; padding: 10px 16px; }

/* ---- pages ---- */
.page { padding-top: 8px; }
.page-title { font-family: var(--serif); font-weight: 500; font-size: var(--t-title); line-height: 1.15; letter-spacing: -.01em; margin: 8px 0 16px; }
.page-lead { margin: 0 0 24px; max-width: 64ch; color: var(--ink-soft); }
.empty { margin: 24px 0; color: var(--ink-soft); max-width: 64ch; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 0 0 24px; }
.figure { font-size: 28px; font-weight: 500; letter-spacing: -.01em; }
.figure-label { font-size: var(--t-small); color: var(--ink-soft); }

/* ---- controls ---- */
.primary {
  min-height: var(--target); padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--moss); color: var(--on-moss); font-weight: 500; font-size: var(--t-body);
}
.primary:disabled { opacity: .55; cursor: default; }
.secondary {
  min-height: var(--target); padding: 0 16px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--paper); color: var(--ink); font-size: var(--t-body);
}
.secondary:hover { border-color: var(--ink-soft); }
.text-btn {
  min-height: var(--target); padding: 0 4px; border: 0; background: none; color: var(--moss);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; font-size: var(--t-body);
}
.field, .set-input {
  width: 100%; min-height: var(--target); padding: 6px 12px; font-size: var(--t-body);
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.field:focus, .set-input:focus { outline: 3px solid var(--moss); outline-offset: 0; border-color: transparent; }
.set-row { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; max-width: 440px; }
.set-label { font-size: var(--t-small); color: var(--ink-soft); }
.set-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 16px; }
.group { padding: 8px 0 24px; border-top: 1px solid var(--rule); }
.group-title { font-weight: 600; font-size: var(--t-small); color: var(--ink-soft); letter-spacing: .02em; text-transform: uppercase; margin: 16px 0 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--target); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--moss); flex: none; }

/* ---- tables: every column lines up ---- */
.table { width: 100%; border-collapse: collapse; font-size: var(--t-body); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table th { font-size: var(--t-small); font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.table td.num, .table th.num { text-align: right; }
.table tr:hover td { background: var(--panel); }
.table .act { white-space: nowrap; text-align: right; }

/* ---- the phone's bottom bar: Today (Quick Entry) and For review ---- */
.bottom {
  position: sticky; bottom: 0; z-index: 16; grid-column: 1 / -1;
  display: none; justify-content: space-around; align-items: center;
  min-height: calc(56px + env(safe-area-inset-bottom)); padding: 0 16px env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--rule);
}
.bottom .rail-link { flex: 1; justify-content: center; min-height: 48px; }
.bottom:empty { display: none; }

/* ---- an iPad upright, or anything narrower than 900 px: the rail becomes a top bar (DESIGN.md §9) ---- */
@media (max-width: 899px), ((max-width: 1100px) and (orientation: portrait)) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .rail {
    position: sticky; height: auto; flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px; border-right: 0; border-bottom: 1px solid var(--rule); z-index: 20;
  }
  .rail-quick { display: none; }
  .rail-nav { flex-direction: row; overflow-x: auto; gap: 0; scrollbar-width: none; flex: 1; }
  .rail-nav::-webkit-scrollbar { display: none; }
  .rail-link { white-space: nowrap; padding: 0 12px; }
  .rail-foot { display: none; }
  .main { padding: 0 16px 80px; }
  .status { padding: 4px 16px 0; }
  .page-quick { display: block; }
}

/* ---- iPhone: two faces done well; the rest readable ---- */
@media (max-width: 600px) {
  :root { --t-title: 26px; }
  .rail-nav, .rail-foot { display: none; }
  .bottom { display: flex; }
  .rail { padding-bottom: 8px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .figure { font-size: 22px; }
  .table th, .table td { padding: 8px 6px; }
}

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

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- the Door (DESIGN.md §6.11): the wordmark and nothing else ---- */
body.doorway .rail, body.doorway .bottom { display: none; }
body.doorway .app { grid-template-columns: 1fr; }
.door { max-width: 420px; margin: 0 auto; padding: max(10vh, calc(24px + env(safe-area-inset-top))) 0 48px; display: flex; flex-direction: column; }
.door-mark { font-family: var(--serif); font-weight: 600; font-size: 44px; letter-spacing: -.01em; line-height: 1; text-align: center; margin: 0 0 32px; }
.door-title { font-family: var(--serif); font-weight: 500; font-size: 26px; line-height: 1.2; margin: 0 0 8px; text-align: center; }
.door-lead { text-align: center; margin: 0 0 20px; color: var(--ink-soft); }
.door-form { display: flex; flex-direction: column; gap: 12px; }
.door .field { min-height: 48px; font-size: 17px; }
.door .primary { min-height: 48px; font-size: 16px; }
.door-hint { margin: -6px 0 0 4px; font-size: var(--t-small); color: var(--ink-soft); min-height: 1.2em; }
.door-error { margin: 0; min-height: 1.4em; text-align: center; color: var(--ink); }
.door-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; margin: 20px 0 0; }
.door-links a { display: inline-flex; align-items: center; min-height: var(--target); padding: 0 6px; }
.sep { color: var(--ink-soft); }

/* ---- the top line: the accountant's "Read-only · until 15 March" ---- */
.topline { padding: 0 var(--gutter); min-height: 0; }
.topline:empty { display: none; }
.topline .ro, .rail-foot .ro { display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 999px; background: var(--moss-soft); color: var(--ink); font-size: var(--t-small); }
.rail-foot .ro { margin: 0; }
@media (max-width: 899px), ((max-width: 1100px) and (orientation: portrait)) { .topline { padding: 0 16px; } }

/* ---- Settings ---- */
.settings { max-width: 760px; }
.group-sub { font-size: var(--t-body); font-weight: 600; margin: 20px 0 8px; }
.set-form { display: flex; flex-direction: column; gap: 8px; }
.set-hint { margin: 0; }
.person { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.person.closed .person-who { color: var(--ink-soft); }
.person .set-actions .secondary { min-height: 36px; padding: 0 12px; font-size: var(--t-small); }
.code-card { margin: 12px 0; max-width: 440px; }
.code { font-size: 36px; font-weight: 500; letter-spacing: .2em; margin: 8px 0; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }

/* ---- Quick Entry's chip (DESIGN.md §5.1) ---- */
.quick-row { display: flex; gap: 8px; align-items: stretch; }
.quick-row .quick-input { flex: 1; min-width: 0; }
.chip { border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.chip.ready { border-color: var(--moss); }
.chip-said { margin: 0; font-weight: 500; }
.chip-q { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-ask { font-weight: 600; margin-right: 4px; }
.chip-opt, .chip-more { min-height: 32px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); font-size: var(--t-small); }
.chip-opt:hover { border-color: var(--moss); }
.chip-note { margin: 0; }
.chip-remember { min-height: 32px; font-size: var(--t-small); }
.chip-go { display: flex; align-items: center; gap: 12px; }
.rail-quick .chip { position: absolute; z-index: 30; width: 420px; box-shadow: var(--shadow); }
.rail-quick { position: relative; }

/* ---- Today ---- */
.today { max-width: 900px; }
.today-quick { margin: 16px 0 12px; }
.today-row { display: flex; gap: 12px; margin: 0 0 20px; }
.camera { display: inline-flex; align-items: center; gap: 8px; }
.camera-wrap { display: inline-flex; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.thumb { display: inline-flex; width: 88px; height: 88px; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; align-items: center; justify-content: center; background: var(--panel); text-decoration: none; color: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-pdf { font-weight: 600; }
.setup { margin-top: 8px; }
.setup-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.drop { outline: 3px dashed var(--moss); outline-offset: 6px; }

/* ---- tabs and the chart ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin: 0 0 16px; }
.tab { display: inline-flex; align-items: center; min-height: var(--target); padding: 0 14px; color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent; }
.tab[aria-current="page"] { border-bottom-color: var(--moss); font-weight: 600; }
.acct-add { display: grid; grid-template-columns: 120px 1fr 200px auto; gap: 8px; margin: 0 0 16px; }
.acct-group { margin: 0 0 8px; }
.table tr.archived td { color: var(--ink-soft); }
.table .act .text-btn { min-height: 32px; font-size: var(--t-small); margin-left: 8px; }
@media (max-width: 600px) {
  .acct-add { grid-template-columns: 1fr 1fr; }
  .rail-quick .chip { width: auto; position: static; }
}
.chip[hidden] { display: none; }
.accounts .table { table-layout: fixed; }
.accounts .table th:nth-child(1), .accounts .table td:nth-child(1) { width: 72px; }
.accounts .table th:nth-child(3), .accounts .table td:nth-child(3) { width: 34%; }
.accounts .table th:nth-child(4), .accounts .table td:nth-child(4) { width: 170px; }
@media (max-width: 600px) { .accounts .table th:nth-child(3), .accounts .table td:nth-child(3) { display: none; } }

/* ---- the Ledger's entries and an entry's page ---- */
.ledger-tools { display: flex; gap: 12px; margin: 0 0 12px; align-items: center; }
.ledger-tools .set-input { max-width: 360px; }
.entry-title { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 8px 0 4px; }
.history { margin: 0 0 16px; padding-left: 20px; color: var(--ink-soft); }
.void-box { border-top: 1px solid var(--rule); padding-top: 16px; margin-top: 8px; max-width: 640px; }
.thumb-btn { padding: 0; border: 0; background: none; }
.attach { margin: 12px 0; }
.num-input { max-width: 160px; text-align: right; }
.entry .table { max-width: 820px; margin: 8px 0 16px; }
.table td a, .entry > p > a, .ledger-tools a, .setup-list a, .history a { display: inline-flex; align-items: center; min-height: 32px; }
.ledger-tools a.secondary { min-height: var(--target); padding: 0 16px; }
.entries-table { table-layout: fixed; }
.entries-table th:nth-child(1), .entries-table td:nth-child(1) { width: 110px; }
.entries-table th:nth-child(2), .entries-table td:nth-child(2) { width: 150px; }
.entries-table th:nth-child(4), .entries-table td:nth-child(4) { width: 130px; }
@media (max-width: 600px) { .entries-table th:nth-child(2), .entries-table td:nth-child(2) { display: none; } .entries-table th:nth-child(1), .entries-table td:nth-child(1) { width: 84px; } }

/* ---- the Bank page (DESIGN.md §6.2) ---- */
.bank-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }
.month-sel { width: auto; }
.bank-table { table-layout: fixed; }
.bank-table th:nth-child(1), .bank-table td:nth-child(1) { width: 100px; }
.bank-table th:nth-child(3), .bank-table td:nth-child(3) { width: 120px; }
.bank-table th:nth-child(4), .bank-table td:nth-child(4) { width: 44%; }
.bank-done td { color: var(--ink-soft); }
.bank-act { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.bank-act .reason { max-width: 46ch; }
.make { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bank-pick { width: auto; max-width: 260px; }
.choose { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.choose-btn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 6px 12px; height: auto; }
.small-btn { min-height: 32px; font-size: var(--t-small); padding: 0; }
.small-check { min-height: 32px; }
.deposit-pick summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--moss); }
.import-panel { border: 1px solid var(--moss); border-radius: 12px; padding: 16px 20px; margin: 0 0 20px; background: var(--panel); }
.import-panel[hidden] { display: none; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.review { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); margin: 0 0 16px; }
.review .group-title { margin: 0; }
.review-line { font-family: var(--serif); font-size: 22px; }
.review.has { border-color: var(--moss); }
@media (max-width: 600px) {
  .bank-table, .bank-table tbody, .bank-table tr, .bank-table td { display: block; width: auto !important; }
  .bank-table thead { display: none; }
  .bank-table tr { border-bottom: 1px solid var(--rule); padding: 8px 0; }
  .bank-table td { border: 0; padding: 2px 0; text-align: left; }
}
.make { width: 100%; }
.make .bank-pick { flex: 1 1 200px; }
@media (max-width: 600px) {
  .bank-table td.num { text-align: left !important; }
  .bank-table tr { display: grid !important; grid-template-columns: auto 1fr; column-gap: 12px; }
  .bank-table td:nth-child(2), .bank-table td:nth-child(4) { grid-column: 1 / -1; }
  .bank-table td:nth-child(3) { justify-self: end; grid-row: 1; grid-column: 2; }
}
