/* ================================================================
   CentMemo stylesheet. Mobile-first; tokens below are generated.
================================================================ */

/* ---- Design tokens ----
   The template's placeholder look. Every value below comes from
   design-tokens.json: change it there, run `node tools/design_tokens.mjs`,
   and every platform follows (see the make-it-look-like-itself skill). */
/* BEGIN design-tokens. Generated from design-tokens.json by tools/design_tokens.mjs. Do not edit by hand. */
:root {
  color-scheme: light;
  --color-primary: #4A1520;
  --color-on-primary: #FBFAF7;
  --color-background: #FBFAF7;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F1EEEA;
  --color-text: #231B1C;
  --color-text-muted: #5E5455;
  --color-border: #D9D2CF;
  --color-success: #1E7A4F;
  --color-warning: #8A5A00;
  --color-error: #B42318;
  --color-error-surface: #FDECEA;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --type-page-title-size: 1.75rem;
  --type-page-title-weight: 700;
  --type-section-header-size: 1.25rem;
  --type-section-header-weight: 700;
  --type-body-strong-size: 1rem;
  --type-body-strong-weight: 600;
  --type-body-size: 1rem;
  --type-body-weight: 400;
  --type-caption-size: 0.8125rem;
  --type-caption-weight: 400;
  --type-tabular-size: 0.875rem;
  --type-tabular-weight: 400;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-control: 8px;
  --radius-card: 12px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #F0B9BE;
  --color-on-primary: #4A1520;
  --color-background: #171615;
  --color-surface: #201E1D;
  --color-surface-alt: #2A2826;
  --color-text: #EFE9E7;
  --color-text-muted: #B8AEAC;
  --color-border: #3A3634;
  --color-success: #5CC593;
  --color-warning: #E8B04B;
  --color-error: #FF8A80;
  --color-error-surface: #3A1D1B;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --color-primary: #F0B9BE;
    --color-on-primary: #4A1520;
    --color-background: #171615;
    --color-surface: #201E1D;
    --color-surface-alt: #2A2826;
    --color-text: #EFE9E7;
    --color-text-muted: #B8AEAC;
    --color-border: #3A3634;
    --color-success: #5CC593;
    --color-warning: #E8B04B;
    --color-error: #FF8A80;
    --color-error-surface: #3A1D1B;
  }
}
/* END design-tokens */

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
/* Safari layout rule (docs/platforms/web.md): body is a 100dvh flex
   column, the main region scrolls, no position:fixed anywhere. */
body {
  height: 100dvh; display: flex; flex-direction: column;
  background: var(--color-background); color: var(--color-text);
  font-family: var(--font-body); font-size: var(--type-body-size); line-height: 1.5;
}
a { color: var(--color-primary); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: var(--space-4); top: var(--space-4); background: var(--color-background); padding: var(--space-2); z-index: 10; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wordmark { font-size: var(--type-page-title-size); font-weight: var(--type-page-title-weight); letter-spacing: -0.01em; }
.wordmark-small { font-size: var(--type-section-header-size); }

/* ---- Signed out ---- */
.auth-screen { overflow-y: auto; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-3); }
.auth-lede { font-size: var(--type-section-header-size); font-weight: var(--type-section-header-weight); }
.auth-body { color: var(--color-text-muted); margin-bottom: var(--space-3); }
.auth-actions { display: flex; flex-direction: column; gap: var(--space-3); }
/* Apple's button rules: black (white in dark), the Apple logo, "Sign in with Apple". */
.btn-apple { background: #000; border-color: #000; color: #fff; font-weight: var(--type-body-strong-weight); }
.btn-apple .apple-logo { width: 16px; height: 19px; }
html[data-theme="dark"] .btn-apple { background: #fff; border-color: #fff; color: #000; }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .btn-apple { background: #fff; border-color: #fff; color: #000; } }
.auth-foot { font-size: var(--type-caption-size); color: var(--color-text-muted); margin-top: var(--space-4); }

/* ---- Signed in ---- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border);
}
#main-content { flex: 1; min-height: 0; overflow-y: auto; outline: none; }
.view { max-width: 680px; margin: 0 auto; padding: var(--space-4) var(--space-4) var(--space-8); }
.view-heading { font-size: var(--type-page-title-size); font-weight: var(--type-page-title-weight); line-height: 1.2; margin-bottom: var(--space-4); }
.section-heading { font-size: var(--type-section-header-size); font-weight: var(--type-section-header-weight); margin: var(--space-6) 0 var(--space-3); }
.caption { font-size: var(--type-caption-size); color: var(--color-text-muted); margin: var(--space-2) 0; }

/* Tabs: a bottom bar in the flex column on phones, inline in the header
   from 768px. Never position:fixed. */
.tabs { display: flex; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--space-2) var(--space-1); text-decoration: none;
  color: var(--color-text-muted); font-size: var(--type-caption-size);
}
.tab[aria-current="page"] { color: var(--color-primary); font-weight: var(--type-body-strong-weight); }
.tabs-top { display: none; }
.tabs-bottom { border-top: 1px solid var(--color-border); background: var(--color-background); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 768px) {
  .tabs-top { display: flex; gap: var(--space-1); }
  .tabs-top .tab { flex-direction: row; gap: var(--space-2); font-size: var(--type-body-size); padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); }
  .tabs-top .tab svg { width: 18px; height: 18px; }
  .tabs-top .tab[aria-current="page"] { background: var(--color-surface); }
  .tabs-bottom { display: none; }
}

/* ---- Lists ---- */
.list { list-style: none; border-top: 1px solid var(--color-border); }
.row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border);
  color: inherit; text-decoration: none;
}
a.row:hover .row-title { text-decoration: underline; }
.row-static { align-items: center; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: var(--type-body-strong-weight); overflow-wrap: anywhere; }
.row-sub { font-size: var(--type-caption-size); color: var(--color-text-muted); }
.row-memo { font-size: var(--type-caption-size); margin-top: var(--space-1); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: var(--type-tabular-size); }
.is-credit { color: var(--color-success); }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.totals dt { font-size: var(--type-caption-size); color: var(--color-text-muted); }
.totals dd { font-weight: var(--type-body-strong-weight); font-variant-numeric: tabular-nums; }

.month-bar { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.month-title { margin: 0; flex: 1; text-align: center; }
.icon-btn, .back-btn {
  display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0;
  color: var(--color-primary); cursor: pointer; padding: var(--space-2); border-radius: var(--radius-control);
}
.icon-btn:hover, .back-btn:hover { background: var(--color-surface); }
.back-btn { margin: 0 0 var(--space-2) calc(-1 * var(--space-2)); }

/* ---- Transaction ---- */
.txn-head { margin-bottom: var(--space-3); }
.txn-head .view-heading { margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.txn-amount { font-size: var(--type-section-header-size); font-weight: var(--type-section-header-weight); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin-bottom: var(--space-6); font-size: var(--type-caption-size); }
.facts div { display: contents; }
.facts dt { color: var(--color-text-muted); }
.facts dd { overflow-wrap: anywhere; }
.memo-input { min-height: 9rem; resize: vertical; line-height: 1.5; }

/* ---- Fields and buttons ---- */
.field-label { display: block; font-size: var(--type-caption-size); font-weight: var(--type-body-strong-weight); color: var(--color-text-muted); margin: var(--space-4) 0 var(--space-2); }
.field-input {
  width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-control); background: var(--color-background); font-size: 1rem;
}
.field-inline { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-2); flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); min-height: 44px; border-radius: var(--radius-control);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  cursor: pointer; text-decoration: none; font-weight: var(--type-body-strong-weight);
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.btn-danger { color: var(--color-error); }
.btn-quiet { background: none; border-color: transparent; color: var(--color-text-muted); }
.btn-small { min-height: 36px; padding: var(--space-1) var(--space-3); font-size: var(--type-caption-size); }
.btn-full { width: 100%; }
.actions { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  border: 1px solid var(--color-border); background: var(--color-background); border-radius: 999px;
  padding: var(--space-1) var(--space-3); font-size: var(--type-caption-size); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.chips-static .chip { cursor: default; background: var(--color-surface); }

.code-line { font-family: var(--font-mono); font-size: var(--type-caption-size); background: var(--color-surface); padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); overflow-wrap: anywhere; flex: 1; min-width: 0; }

/* ---- Banners and states ---- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-control); font-size: var(--type-caption-size); margin: var(--space-2) 0; }
.banner-error { background: var(--color-error-surface); color: var(--color-error); }
.banner-info { background: var(--color-surface); }
.banner-warning { background: var(--color-surface-alt); color: var(--color-warning); border-radius: 0; margin: 0; justify-content: center; }
.state { padding: var(--space-6) 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); color: var(--color-text-muted); }

/* ---- Import ---- */
.file-drop {
  display: flex; align-items: center; justify-content: center; min-height: 96px; margin: var(--space-4) 0;
  border: 1.5px dashed var(--color-border); border-radius: var(--radius-card); cursor: pointer;
  color: var(--color-primary); font-weight: var(--type-body-strong-weight); position: relative;
}
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop:focus-within { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---- Story ---- */
.story-controls { margin-bottom: var(--space-2); }
.story-controls .field-label { margin-top: 0; }
.story-head .section-heading { margin: var(--space-4) 0 0; }
.story { list-style: none; margin-top: var(--space-4); }
.story-entry { padding: var(--space-4) 0; border-top: 1px solid var(--color-border); }
.story-meta { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--type-caption-size); color: var(--color-text-muted); text-decoration: none; }
.story-text { margin: var(--space-2) 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--type-body-size); line-height: 1.6; }

/* ---- Static pages (privacy, terms, consent) ---- */
.page { flex: 1; min-height: 0; overflow-y: auto; }
.page-inner { max-width: 680px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-8); }
.page-inner h1 { margin-bottom: var(--space-4); }
.page-inner h2 { font-size: var(--type-section-header-size); margin: var(--space-6) 0 var(--space-2); }
.page-inner p, .page-inner li { margin-bottom: var(--space-3); }
.page-inner ul { padding-left: var(--space-6); }

/* ---- The person's color: a mark, never a ground (docs/DESIGN.md C3-C5) ----
   Values from design-tokens.json `grounds`; tools/test_grounds.mjs fails if
   these drift from the JSON or from apple/Core/Ground.swift. */
:root { --color-yours: #2FD4EC; --color-on-yours: #231B1C; }
html[data-ground="sky"]       { --color-yours: #9AC0F8; }
html[data-ground="salmon"]    { --color-yours: #FDA19B; }
html[data-ground="apricot"]   { --color-yours: #FEA669; }
html[data-ground="citron"]    { --color-yours: #C7C43F; }
html[data-ground="pistachio"] { --color-yours: #B4C875; }

/* C3.1 What still needs you: the Unexamined count sits on the person's color;
   in the Ledger a purchase without a memo carries a highlighter stroke. */
.yours-count { background: var(--color-yours); color: var(--color-on-yours); border-radius: 999px; padding: 0 .4em; }
.row.is-unexamined .row-amount {
  background: linear-gradient(transparent 12%, var(--color-yours) 12%, var(--color-yours) 88%, transparent 88%);
  color: var(--color-on-yours); padding: 0 .3em; border-radius: 3px;
}
/* C3.2 What you value: value chips wear the person's color. */
.chip[aria-pressed="true"], .chips-static .chip { background: var(--color-yours); border-color: var(--color-yours); color: var(--color-on-yours); }
.chip[aria-pressed="false"] { background: transparent; border-color: var(--color-border); color: var(--color-text); }

/* ---- Editorial type: Newsreader for headings and the person's memos ---- */
:root { --font-display: "Newsreader", Georgia, "Times New Roman", serif; }
.wordmark, .view-heading, .section-heading, .txn-head .view-heading, .page-inner h1, .page-inner h2 { font-family: var(--font-display); letter-spacing: -0.005em; color: var(--color-primary); }
.memo-input, .story-text, .row-memo { font-family: var(--font-display); }


/* ---- Pencil marks: drawn, never a handwriting font (memory no-handwriting-fonts) ---- */
.row { border-bottom: 0; position: relative; }
.row::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 6px;
  background: var(--color-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 6' preserveAspectRatio='none'%3E%3Cpath d='M1 3.2 C 20 1.9, 38 4.3, 60 3.0 S 101 1.8, 121 3.4 S 160 4.4, 182 2.7 S 222 2.2, 239 3.3' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 6' preserveAspectRatio='none'%3E%3Cpath d='M1 3.2 C 20 1.9, 38 4.3, 60 3.0 S 101 1.8, 121 3.4 S 160 4.4, 182 2.7 S 222 2.2, 239 3.3' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  opacity: .55;
}
.list { border-top: 0; }
.pencil-circle { position: relative; display: inline-block; padding: 0 .35em; }
.pencil-circle::before {
  content: ""; position: absolute; inset: -.18em -.12em -.12em -.12em; background: var(--color-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60' preserveAspectRatio='none'%3E%3Cpath d='M58 4 C 26 2, 4 14, 5 31 C 6 49, 34 57, 58 55 C 84 53, 97 42, 95 27 C 93 12, 72 3, 44 6' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60' preserveAspectRatio='none'%3E%3Cpath d='M58 4 C 26 2, 4 14, 5 31 C 6 49, 34 57, 58 55 C 84 53, 97 42, 95 27 C 93 12, 72 3, 44 6' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* ---- Ground picker (Settings) ---- */
.grounds { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.ground-swatch {
  width: 64px; display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--color-text); font-size: var(--type-caption-size);
}
.ground-swatch i { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--color-border); display: block; }
.ground-swatch[aria-pressed="true"] i { border: 3px solid var(--color-primary); box-shadow: 0 0 0 3px var(--color-surface); }
.ground-swatch[aria-pressed="true"] span { font-weight: var(--type-body-strong-weight); }

/* Paper for long reading and writing: the memo field and the story sit on surface. */
.memo-input { background: var(--color-surface); }
.story-entry { background: var(--color-surface); border-top: 0; border-radius: var(--radius-card); padding: var(--space-4); margin-bottom: var(--space-3); }
.story-meta { color: var(--color-text-muted); }

/* /connect/: the tool table and the connector address (wraps at 375px). */
.page code { font-family: var(--font-mono); font-size: 0.85rem; overflow-wrap: anywhere; }
.doc-table { width: 100%; border-collapse: collapse; margin: var(--space-3, 12px) 0; }
.doc-table th, .doc-table td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--color-border, rgba(0,0,0,.12)); }
.doc-table th { font-weight: 700; }
.doc-table td:first-child { white-space: nowrap; font-weight: 600; }
.page ol { padding-left: 1.6em; }

/* Consent page: the reviewer sign-in stays one quiet line until opened (Decision 063). */
.reviewer { margin-top: var(--space-6); }
.reviewer summary { color: var(--color-text-muted); cursor: pointer; }
.reviewer form { display: grid; gap: var(--space-2); margin-top: var(--space-3); max-width: 360px; }
