/* Arca: navy and brass after dark, ink on paper by day. Matches the 08 ink logo. */
:root {
  color-scheme: dark;
  --page: #0d1525;
  --panel: #131d30;
  --raised: #1b2840;
  --line: rgba(200, 214, 240, 0.10);
  --line-strong: rgba(200, 214, 240, 0.20);
  --ink: #e9edf5;
  --ink-2: #afb9cc;
  --muted: #7f8aa2;
  --brass: #d6b06a;
  --brass-ink: #18130a;
  --brass-wash: rgba(214, 176, 106, 0.14);
  --logo: #e9e4d8;
  --up: #4cc98f;
  --down: #f2806f;
  --warn: #fab219;
  --grid: #1f2c44;
  --axis: #33425e;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --other: #6b7690;
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --r-sm: 6px; --r-md: 10px;
  --shadow: 0 12px 40px rgba(2, 6, 16, 0.45);
}
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --page: #f5f3ee; --panel: #fffefb; --raised: #edeae2;
    --line: rgba(20, 23, 28, 0.10); --line-strong: rgba(20, 23, 28, 0.22);
    --ink: #14171c; --ink-2: #464b55; --muted: #6e727b;
    --brass: #22407a; --brass-ink: #fffefb; --brass-wash: rgba(34, 64, 122, 0.10);
    --logo: #14171c;
    --up: #0e7a45; --down: #b33a2e;
    --grid: #e6e2d9; --axis: #c9c3b6;
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
    --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
    --other: #a7a39a;
    --shadow: 0 12px 40px rgba(20, 23, 28, 0.14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f5f3ee; --panel: #fffefb; --raised: #edeae2;
  --line: rgba(20, 23, 28, 0.10); --line-strong: rgba(20, 23, 28, 0.22);
  --ink: #14171c; --ink-2: #464b55; --muted: #6e727b;
  --brass: #22407a; --brass-ink: #fffefb; --brass-wash: rgba(34, 64, 122, 0.10);
  --logo: #14171c;
  --up: #0e7a45; --down: #b33a2e;
  --grid: #e6e2d9; --axis: #c9c3b6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --other: #a7a39a;
  --shadow: 0 12px 40px rgba(20, 23, 28, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brass); color: var(--brass-ink); padding: 8px 12px; z-index: 50; border-radius: var(--r-sm); }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.error { color: var(--down); min-height: 1.2em; margin: 0; }

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 22px;
  margin: 0;
}

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "rail tape" "rail main";
  min-height: 100vh;
}
.tape {
  grid-area: tape;
  border-bottom: 1px solid var(--line);
  background: var(--page);
  position: sticky; top: 0; z-index: 5;
  overflow-x: auto;
  scrollbar-width: none;
}
.tape::-webkit-scrollbar { display: none; }
.tape-track { display: flex; gap: 28px; padding: 10px 28px; white-space: nowrap; font-size: 13px; }
.tape-item { display: flex; gap: 8px; align-items: baseline; }
.tape-item .label { color: var(--muted); }
.tape-item .price { font-variant-numeric: tabular-nums; }
.tape-item .chg { font-variant-numeric: tabular-nums; font-size: 12px; }

.rail {
  grid-area: rail;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.brand { padding: 2px 8px 18px; display: flex; align-items: center; gap: 10px; }
.brand .wordmark { color: var(--ink); }
.logo { color: var(--logo); display: block; flex: none; }
.brand .logo { width: 34px; height: 34px; }
.login-card .logo { width: 64px; height: 64px; margin-bottom: 4px; }
.theme-toggle { margin: 0 8px 8px; }
.search { position: relative; margin-bottom: 18px; }
.search input {
  width: 100%;
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 14px;
}
.search input::placeholder { color: var(--muted); }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow); z-index: 20; max-height: 320px; overflow: auto;
}
.search-results li { padding: 7px 8px; border-radius: 4px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--brass-wash); }
.search-results .sym { font-weight: 600; min-width: 56px; }
.search-results .nm { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: block; padding: 8px 10px; border-radius: var(--r-sm);
  text-decoration: none; color: var(--ink-2);
}
.nav a:hover { background: var(--raised); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brass-wash); color: var(--ink); box-shadow: inset 3px 0 0 var(--brass); }
.nav-end { margin-top: auto; }
.nav-more-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none;
  color: var(--ink-2); cursor: pointer; text-align: left; font-size: inherit;
}
.nav-more-btn:hover { background: var(--raised); color: var(--ink); }
.nav-more-btn::after {
  content: ""; width: 6px; height: 6px; margin-right: 4px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform 160ms ease;
}
.nav-more-btn[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.nav-more-btn.has-current { color: var(--ink); }
.nav-sub { list-style: none; margin: 2px 0 0; padding: 0 0 0 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-sub a { font-size: 14px; }
.rail-foot { font-size: 12px; padding: 10px; margin: 0; }

.main { grid-area: main; padding: 28px 32px 64px; min-width: 0; outline: none; }
.demo-banner {
  border: 1px dashed var(--brass); color: var(--ink-2); background: var(--brass-wash);
  padding: 8px 14px; border-radius: var(--r-sm); margin-bottom: 20px; font-size: 14px;
}

/* ---------- page furniture ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 0; }
.page-head .sub { color: var(--ink-2); margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
h2.section { font-size: 15px; font-weight: 600; margin: 0 0 12px; color: var(--ink); }
.section-note { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  min-width: 0;
}
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 7px 13px; cursor: pointer; color: var(--ink);
  font-size: 14px; text-decoration: none;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.quiet { border-color: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 11px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--brass-wash); color: var(--ink); }

input.field, select.field, textarea.field {
  background: var(--page); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 7px 9px; min-width: 0;
}
textarea.field { resize: vertical; }

/* ---------- the ledger line: Arca's one loud element ---------- */
.ledger {
  display: grid; grid-template-columns: minmax(0, auto) 1fr; gap: 8px 36px; align-items: end;
  padding-bottom: 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.ledger::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 120px; height: 2px; background: var(--brass);
}
.ledger .worth {
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: lining-nums;
  letter-spacing: -0.01em;
  margin: 0;
}
.ledger .worth .cents { font-size: 0.45em; color: var(--ink-2); vertical-align: 0.95em; margin-left: 2px; }
.ledger .caption { color: var(--ink-2); margin: 0 0 10px; }
.ledger-facts { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 0; }
.ledger-facts div { min-width: 0; }
.ledger-facts dt { color: var(--muted); font-size: 13px; }
.ledger-facts dd { margin: 2px 0 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.incomplete { color: var(--warn); font-size: 13px; margin: 8px 0 0; grid-column: 1 / -1; }

/* ---------- accounts ---------- */
.accounts { margin-bottom: 18px; }
.account-switch { margin-bottom: 18px; }
.account-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.account-card {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; cursor: pointer; color: var(--ink);
}
.account-card:hover { border-color: var(--line-strong); }
.account-card[aria-pressed="true"] { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.acct-name { font-weight: 600; font-size: 14px; }
.acct-total { font-family: var(--serif); font-size: 26px; line-height: 1.15; margin: 2px 0; }
.acct-line { font-size: 13px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 13px;
  padding: 6px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th.num, table.data td.num { text-align: right; }
table.data tbody tr.link { cursor: pointer; }
table.data tbody tr.link:hover { background: var(--raised); }
table.data .sym { font-weight: 600; }
table.data .nm { color: var(--muted); font-size: 13px; display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.data tfoot td { border-bottom: 0; color: var(--ink-2); font-weight: 600; }
.stale { color: var(--warn); font-size: 12px; margin-left: 4px; }

/* ---------- allocation ---------- */
.alloc-bar { display: flex; height: 14px; gap: 2px; border-radius: 4px; overflow: hidden; margin: 6px 0 14px; }
.alloc-bar span { display: block; min-width: 3px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .pct { color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.legend .val { font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; }

/* ---------- watchlist ---------- */
.watch-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
table.data th button.sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
table.data th button.sort:hover { color: var(--ink); }
table.data.watch td { vertical-align: middle; }
.spark-cell { display: inline-flex; align-items: center; gap: 8px; }
.spark { display: block; }
.spark-line { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.spark-line.up { stroke: var(--up); } .spark-line.down { stroke: var(--down); }
.spark-dot.up { fill: var(--up); } .spark-dot.down { fill: var(--down); }
.own { font-size: 11px; font-weight: 500; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.badge.zone { background: var(--brass-wash); color: var(--ink); border: 1px solid var(--brass); }
.badge.target { background: rgba(76, 201, 143, 0.14); color: var(--up); border: 1px solid var(--up); }
.badge.below { color: var(--muted); border: 1px solid var(--line-strong); }
tr.hit td:first-child { box-shadow: inset 3px 0 0 var(--brass); }
.hit-notice { margin-bottom: 14px; border-color: var(--brass); }
.row-actions { display: flex; gap: 2px; margin: 4px 0 0 -9px; white-space: nowrap; }
table.data.watch td.plan-cell { white-space: normal; min-width: 160px; max-width: 220px; }
.plan-line { display: block; font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
table.data.watch td, table.data.watch th { padding-left: 8px; padding-right: 8px; }

/* ---------- 52-week range ---------- */
.range { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.range-track { position: relative; width: 90px; height: 4px; background: var(--grid); border-radius: 2px; }
.range-dot { position: absolute; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); transform: translateX(-50%); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { stroke: var(--panel); stroke-width: 2; }
.chart .direct-label { font-size: 12px; fill: var(--ink-2); }
.chart .bar-derived { opacity: 0.55; }
.chart-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-head h2.section { margin: 0; }
.chart-empty { color: var(--muted); font-size: 14px; padding: 28px 0; text-align: center; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 7px 10px; font-size: 13px; box-shadow: var(--shadow); max-width: 260px;
}
.tooltip .t-head { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.tooltip .t-row { display: flex; gap: 12px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tooltip .t-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }

/* ---------- company ---------- */
.company-head { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.company-head h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; margin: 0; line-height: 1.1; }
.company-head .ticker { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.company-price { font-family: var(--serif); font-size: 36px; line-height: 1; margin: 0; font-variant-numeric: lining-nums; }
.company-price .chg { font-family: var(--sans); font-size: 16px; margin-left: 10px; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 18px; }
.facts div { background: var(--panel); padding: 12px 14px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 4px 0 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.facts dd small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.notice { border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 14px 16px; color: var(--ink-2); background: var(--panel); }
.notice strong { color: var(--ink); }

/* ---------- lists: news, notes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.news-title { color: var(--ink); text-decoration: none; font-size: 15px; }
.news-title:hover { text-decoration: underline; text-decoration-color: var(--brass); }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 12px; color: var(--ink-2); background: none; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brass-wash); border-color: var(--brass); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.note-link { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--ink); font-size: 15px; }
.note-link:hover { text-decoration: underline; text-decoration-color: var(--brass); }
.snippet { color: var(--ink-2); font-size: 13px; margin: 3px 0 0; overflow-wrap: anywhere; }

.notes-layout { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 18px; align-items: start; }
.notes-layout .panel.list-panel { position: sticky; top: 64px; max-height: calc(100vh - 96px); overflow: auto; }
.list-panel li.active .note-link { color: var(--brass); }

/* rendered markdown */
.md { max-width: 920px; overflow-wrap: break-word; }
.md p, .md ul, .md ol, .md blockquote { max-width: 72ch; }
.md h1 { font-family: var(--serif); font-size: 28px; font-weight: 600; margin: 0 0 14px; line-height: 1.2; }
.md h2 { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 26px 0 8px; }
.md h3, .md h4, .md h5, .md h6 { font-size: 16px; margin: 20px 0 6px; }
.md p, .md ul, .md ol { margin: 0 0 12px; line-height: 1.65; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 3px 0; }
.md li.md-task { list-style: none; margin-left: -20px; }
.md code { background: var(--raised); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.md pre { background: var(--raised); padding: 12px 14px; border-radius: var(--r-sm); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 12px; padding-left: 14px; border-left: 2px solid var(--line-strong); color: var(--ink-2); }
.md .md-callout { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--brass-wash); border-left: 3px solid var(--brass); }
.md .md-callout > strong { display: block; margin-bottom: 4px; }
.md .md-callout p:last-child { margin-bottom: 0; }
.md a { color: var(--brass); }
.md .md-wikilink { text-decoration: none; border-bottom: 1px dashed var(--brass); }
.md .md-tag { color: var(--ink-2); background: var(--raised); padding: 0 6px; border-radius: 999px; font-size: 0.88em; }
.md .md-embed { color: var(--muted); font-style: italic; }
.md mark { background: var(--brass-wash); color: inherit; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
/* Note tables: scroll sideways instead of squeezing, numbers never wrap. */
.md-table { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.md table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.md th, .md td { padding: 7px 12px; text-align: left; white-space: nowrap; overflow-wrap: normal; border-bottom: 1px solid var(--line); }
.md th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--raised); position: sticky; top: 0; }
.md tbody tr:last-child td { border-bottom: 0; }
.md tbody tr:hover td { background: var(--brass-wash); }
.md th.num, .md td.num { text-align: right; font-variant-numeric: tabular-nums; }
.md th.center, .md td.center { text-align: center; }
.md td:first-child { font-weight: 500; }
/* Charts drawn from ```chart blocks */
.md .md-chart { margin: 4px 0 16px; padding: 14px 16px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.md .md-chart figcaption { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.md .md-chart .chart-legend { margin: 0 0 6px; }
/* Callouts by kind, like Obsidian */
.md .md-callout { --c: var(--brass); background: color-mix(in srgb, var(--c) 10%, transparent); border-left-color: var(--c); }
.md .md-callout-info, .md .md-callout-note, .md .md-callout-tip { --c: var(--s1); }
.md .md-callout-example, .md .md-callout-success { --c: var(--s3); }
.md .md-callout-abstract, .md .md-callout-summary { --c: var(--brass); }
.md .md-callout-warning, .md .md-callout-caution, .md .md-callout-danger { --c: var(--warn); }
.md details.md-callout > summary { cursor: pointer; font-weight: 600; }
.md details.md-callout[open] > summary { margin-bottom: 4px; }
.md .md-callout ul { margin-bottom: 0; }
.md .md-callout p, .md .md-callout ul { max-width: none; }
.reader-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.notes-tabs { margin-bottom: 10px; display: flex; }
.notes-tabs button { flex: 1; }
.list.sources li { padding: 6px 0; font-size: 14px; }
.note-preview { max-height: 46vh; overflow: auto; background: var(--raised); padding: 12px 14px; border-radius: var(--r-sm); font-size: 12px; white-space: pre-wrap; margin: 0; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

/* ---------- expenditures ---------- */
.month-picker { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; }
.month-picker select { min-width: 180px; }
.donut-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px 28px; align-items: center; }
.donut .slice { cursor: pointer; transition: opacity 150ms; }
.donut .slice.dim { opacity: 0.3; }
.donut .slice:focus-visible { outline: none; stroke: var(--brass); stroke-width: 3; }
.donut-top, .donut-bottom { pointer-events: none; }
.donut-top { font-family: var(--serif); font-size: 22px; fill: var(--ink); font-variant-numeric: lining-nums; }
.donut-bottom { font-size: 12px; fill: var(--muted); }
.fold-parts { display: block; font-size: 12px; color: var(--muted); }
.panel.needs { border-color: var(--brass); margin-bottom: 18px; }
.panel.needs table.data td { vertical-align: middle; }
.panel.needs .merchant { font-weight: 600; display: block; }
.legend-pick { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: 0 -4px; }
.legend-pick:hover, .legend-pick[aria-pressed="true"] { background: var(--raised); }
.legend-pick.dim { opacity: 0.45; }
table.data.tx td { vertical-align: middle; }
table.data.tx .merchant { font-weight: 600; display: block; }
table.data.tx .nm { max-width: 340px; }
table.data.tx td .swatch { vertical-align: middle; }
.cat-select { padding: 3px 6px; font-size: 13px; }
tr.excluded td { color: var(--muted); }
@media (max-width: 820px) { table.data.tx .nm, table.data.tx td:last-child, table.data.tx th:last-child { display: none; } table.data.tx .merchant { max-width: 150px; overflow: hidden; text-overflow: ellipsis; } .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; } .donut-wrap .legend { width: 100%; } }

/* ---------- home ---------- */
.home-head h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; margin: 0; }
.home-head .sub { color: var(--ink-2); margin: 4px 0 22px; }
.home-worth { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; text-decoration: none; color: inherit; padding-bottom: 20px; margin-bottom: 22px; border-bottom: 1px solid var(--line); position: relative; }
.home-worth::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 120px; height: 2px; background: var(--brass); }
.home-worth .caption { color: var(--ink-2); width: 100%; }
.home-worth .worth { font-family: var(--serif); font-size: clamp(34px, 5vw, 52px); line-height: 1; }
.home-worth .worth .cents { font-size: 0.45em; color: var(--ink-2); vertical-align: 0.95em; }
.home-worth .incomplete { width: 100%; margin: 0; }
.list.attention li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.list.attention a { color: var(--ink); font-weight: 600; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
ol.steps li a { font-weight: 600; color: var(--ink); display: block; }
ol.steps li span { display: block; font-size: 14px; }
.home-spend { font-family: var(--serif); font-size: 30px; margin: 0 0 8px; }
.home-spend .muted { font-family: var(--sans); font-size: 15px; }
.meter { height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brass); border-radius: 4px; }
.ok-text { color: var(--up); margin: 0; min-height: 1.2em; }
pre.code { background: var(--page); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 0; }
.chips a.chip[aria-selected="true"] { background: var(--brass-wash); border-color: var(--brass); color: var(--ink); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.msg { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel); }
.msg.user { background: var(--raised); align-self: flex-end; max-width: 85%; white-space: pre-wrap; }
.msg.assistant .md { max-width: none; }
.msg .trace { color: var(--muted); font-size: 12px; margin-top: 8px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; position: sticky; bottom: 0; padding: 12px 0; background: var(--page); }
.chat-form textarea { flex: 1; min-height: 46px; max-height: 200px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.thinking { color: var(--muted); font-size: 14px; }

/* ---------- setup ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.mark { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.mark.ok { background: var(--up); color: var(--panel); }
.mark.off { border: 1.5px solid var(--muted); color: var(--muted); }
.checks code { background: var(--raised); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---------- dialog ---------- */
.dialog {
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--panel); color: var(--ink);
  padding: 0; width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(4, 8, 18, 0.6); }
.dialog-body { padding: 22px 24px; overflow: auto; max-height: calc(100vh - 140px); }
.dialog-body h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog-foot .error { margin-right: auto; align-self: center; }
.edit-table input.field, .edit-table select.field { width: 100%; }
.edit-table td { padding: 5px 6px; }
.edit-table .w-sym { width: 110px; }
.edit-table .w-num { width: 130px; }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); padding: 22px; text-align: center; color: var(--ink-2);
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 16px; box-shadow: var(--shadow);
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 10px; background: var(--panel); padding: 28px; border-radius: var(--r-md); border: 1px solid var(--line); }
.login-card .wordmark { color: var(--ink); font-size: 30px; }
.login-card input { background: var(--page); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1440px) {
  .hide-md { display: none; }
}
@media (max-width: 1100px) {
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tape" "main"; }
  .rail {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 10;
    flex-direction: row; align-items: center; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand, .rail-foot, .search { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  .nav-end { margin-top: 0; }
  .nav-more-btn { white-space: nowrap; gap: 8px; font-size: 14px; }
  .nav-more-btn::after { transform: translateY(1px) rotate(-135deg); }
  .nav-more-btn[aria-expanded="true"]::after { transform: translateY(-2px) rotate(45deg); }
  .nav-more-btn.has-current { background: var(--brass-wash); box-shadow: inset 0 -2px 0 var(--brass); }
  .nav-sub {
    position: fixed; right: 8px; bottom: calc(var(--rail-h, 52px) + 6px); z-index: 30;
    min-width: 180px; padding: 6px; margin: 0;
    background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow);
  }
  .nav-sub a { padding: 10px 12px; font-size: 15px; }
  .main { padding: 20px 16px 96px; }
  .grid.halves, .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .notes-layout .panel.list-panel { position: static; max-height: none; }
  .ledger { grid-template-columns: minmax(0, 1fr); }
  .mobile-search { display: block !important; }
  .hide-sm { display: none; }
}
.mobile-search { display: none; margin-bottom: 16px; }
@media (prefers-reduced-motion: no-preference) {
  .ledger .worth { animation: settle 600ms cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (forced-colors: active) {
  .alloc-bar span, .swatch { forced-color-adjust: none; }
}

/* ---------- welcome ----------
   One orchestrated moment: the ring draws, the mark fills, the verse settles,
   then the logo glides into the side rail as the site appears. */
.welcome {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--page);
  transition: opacity 600ms ease;
}
.welcome.leaving { opacity: 0; pointer-events: none; }
.welcome-inner { display: grid; justify-items: center; text-align: center; padding: 24px; max-width: 34rem; }
.welcome-logo { width: 148px; height: 148px; color: var(--logo); overflow: visible; }
.welcome-logo .w-ring { stroke-dasharray: 1; stroke-dashoffset: 1; animation: w-draw 1300ms cubic-bezier(.6, 0, .2, 1) forwards; }
.welcome-logo .w-ring-2 { animation-delay: 250ms; }
.welcome-logo .w-mark path { fill: currentColor; fill-opacity: 0; stroke-dasharray: 1; stroke-dashoffset: 1; animation: w-draw 1100ms ease forwards 500ms, w-fill 700ms ease forwards 1300ms; }
.welcome-logo .w-mark path:nth-child(2) { animation-delay: 650ms, 1400ms; }
.welcome-logo .w-mark path:nth-child(n+3) { animation-delay: 800ms, 1500ms; }
.welcome-word {
  font-family: var(--serif); font-weight: 600; font-size: 40px; letter-spacing: 0.02em;
  margin: 18px 0 26px; opacity: 0; animation: w-rise 700ms ease forwards 1500ms;
}
.welcome-verse { margin: 0; }
.welcome-verse p { margin: 0; font-family: var(--serif); }
.w-latin { font-style: italic; font-size: 20px; color: var(--ink); opacity: 0; animation: w-rise 800ms ease forwards 2000ms; }
.w-arcam { color: var(--brass); }
.w-english { font-size: 16px; color: var(--ink-2); margin-top: 10px !important; line-height: 1.55; opacity: 0; animation: w-rise 800ms ease forwards 2500ms; }
.w-cite { font-size: 13px; color: var(--muted); margin-top: 10px; opacity: 0; animation: w-rise 700ms ease forwards 2900ms; }
.welcome-skip { position: absolute; right: 20px; bottom: 20px; }
.welcome-logo.flying, .welcome-word.flying { transition: transform 750ms cubic-bezier(.6, 0, .2, 1); transform-origin: center; }
@keyframes w-draw { to { stroke-dashoffset: 0; } }
@keyframes w-fill { to { fill-opacity: 1; stroke-opacity: 0; } }
@keyframes w-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .welcome-logo .w-ring, .welcome-logo .w-mark path, .welcome-word, .w-latin, .w-english, .w-cite { animation: none; opacity: 1; stroke-dashoffset: 0; fill-opacity: 1; }
  .welcome-logo.flying, .welcome-word.flying { transition: none; }
}
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
form.panel label > span.muted { display: block; margin-bottom: 4px; }
form.panel select.field { width: 100%; }

/* ---------- learn ----------
   A full-height feed: one card per screen, snapping as you scroll. */
.main.learn-mode { padding-bottom: 0; }
.learn-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; max-width: 640px; margin: 0 auto 6px; }
.learn-head > div:first-child { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.learn-head h1 { font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.15; margin: 0; }
.learn-head .sub { color: var(--muted); margin: 0; font-size: 13px; }
.learn-streak { cursor: default; }
.feed {
  overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none; outline: none;
}
.feed::-webkit-scrollbar { display: none; }
.lcard { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; justify-content: center; padding: 6px 0 14px; }
.lcard-inner {
  width: 100%; max-width: 640px; height: 100%; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 26px; display: flex; flex-direction: column; gap: 12px;
}
.lcard-inner > * { flex: none; }
.feed { overflow-anchor: none; }
.lcard-loading { scroll-snap-align: none; }
.lcard-loading .lcard-inner { justify-content: center; align-items: center; text-align: center; }
.k-concept .lcard-inner { border-top: 3px solid var(--brass); }
.k-quiz .lcard-inner { background: linear-gradient(var(--brass-wash), var(--brass-wash)), var(--panel); }
.lcard-eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass); font-weight: 600; }
.lcard-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lcard-title h2 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 0; }
.lcard-title h2.quiz-q { font-size: 23px; line-height: 1.3; }
.lcard-lede { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink); }
.lcard-price { font-size: 15px; }
.lcard-price strong { font-size: 24px; font-weight: 600; margin-right: 4px; }
.learn-spark { width: 100%; height: 48px; display: block; }
.learn-spark .spark-line { stroke-width: 2; }
.lstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.lstat { background: var(--panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lstat-label { font-size: 12px; color: var(--muted); }
.lstat strong { font-size: 18px; font-weight: 600; }
.lstat-hint { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.lcard-note { background: var(--brass-wash); border-radius: var(--r-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.lcard-note p { margin: 0; line-height: 1.5; }
.lcard-note a { color: var(--ink); }
.lcard-why strong { display: block; font-size: 13px; margin-bottom: 4px; }
.lcard-why p { margin: 0 0 6px; color: var(--ink-2); line-height: 1.55; }
.lcard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.lcard-source { margin: 0; font-size: 12px; color: var(--muted); }
.lcard-chart { min-height: 130px; }
.lfigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 0; }
.lfigs dt { font-size: 12px; color: var(--muted); }
.lfigs dd { margin: 0; font-size: 17px; font-weight: 600; }
.kept-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.kept-bar .kept { background: var(--s1); }
.kept-bar .spent { background: var(--other); opacity: 0.45; }
.kept-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.kept-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.kept-legend .sw.kept { background: var(--s1); }
.kept-legend .sw.spent { background: var(--other); opacity: 0.45; }
.range-track { position: relative; height: 6px; border-radius: 3px; background: var(--line-strong); margin: 10px 0 6px; }
.range-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--brass); border: 2px solid var(--panel); }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--panel); cursor: pointer; font-size: 15px; line-height: 1.4;
}
.quiz-opt:hover:not([disabled]) { border-color: var(--brass); }
.quiz-opt[disabled] { cursor: default; }
.quiz-letter { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--ink-2); }
.quiz-opt.correct { border-color: var(--up); box-shadow: inset 3px 0 0 var(--up); }
.quiz-opt.correct .quiz-letter { background: var(--up); color: var(--panel); }
.quiz-opt.wrong { border-color: var(--down); box-shadow: inset 3px 0 0 var(--down); }
.quiz-opt.wrong .quiz-letter { background: var(--down); color: var(--panel); }
.quiz-val { margin-left: auto; font-weight: 600; }
.breadth { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; }
.breadth .b-up { background: var(--up); }
.breadth .b-down { background: var(--down); }
.movers-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.lsub { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--ink-2); }
.movers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.movers a { display: grid; grid-template-columns: 52px minmax(0, 1fr) 62px; align-items: center; gap: 8px; text-decoration: none; padding: 4px 6px; border-radius: 4px; font-size: 13px; }
.movers a:hover { background: var(--raised); }
.movers .msym { font-weight: 600; }
.movers .mtrack { height: 8px; }
.movers .mbar { display: block; height: 100%; border-radius: 2px; background: var(--muted); }
.movers .mbar.up { background: var(--up); }
.movers .mbar.down { background: var(--down); }
.movers a > span:last-child { text-align: right; }
@media (max-width: 820px) {
  .lcard-inner { padding: 18px 16px; border-radius: 12px; }
  .lcard-title h2 { font-size: 25px; }
  .lstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .movers-cols { grid-template-columns: minmax(0, 1fr); }
  .learn-head .sub { display: none; }
  .lstat-hint { display: none; }
  .lcard-lede { font-size: 15px; }
  .learn-spark { height: 36px; }
}
@media (prefers-reduced-motion: no-preference) {
  .lcard-inner { animation: settle 420ms cubic-bezier(.2, .7, .2, 1) both; }
}

/* accounts */
.linklike { background: none; border: 0; padding: 0; color: var(--brass); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.rail-foot a { color: var(--ink-2); }
.share-people { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.login-card input[type="text"] { width: 100%; }
