/* t1ld3's look (bone and ink, monospace, square corners, one accent
   colour), taken from t1ld3's phone/style.css. Day and night follow the
   device. The accent is t1ld3's default orange. */
:root {
  --background: #E7E7DD;
  --ink: #111210;
  --ink-soft: #3B3C37;
  --muted: #6B6C63;
  --faint: #A6A79B;
  --rule: #CBCBBF;
  --hover: #D8D8CD;
  --field: #F0F0E8;
  --accent: #E8642C;
  --accent-text: #B44718;
  --warning: #B44718;
  --mono: ui-monospace, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="day"]) {
    --background: #121311;
    --ink: #E7E7DD;
    --ink-soft: #C6C6BA;
    --muted: #8F9086;
    --faint: #4D4E47;
    --rule: #33342F;
    --hover: #262722;
    --field: #1B1C19;
    --warning: #F08A5D;
    --accent-text: #F08A5D;
    color-scheme: dark;
  }
}

:root[data-theme="night"] {
  --background: #121311;
  --ink: #E7E7DD;
  --ink-soft: #C6C6BA;
  --muted: #8F9086;
  --faint: #4D4E47;
  --rule: #33342F;
  --hover: #262722;
  --field: #1B1C19;
  --warning: #F08A5D;
  --accent-text: #F08A5D;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  /* Below a short page the browser shows html's background, not body's.
     index.html sets it from the system theme so the first paint isn't
     white; this follows the app's own day/night choice once it loads, or
     a day app on a dark phone shows black between the page and the tabs. */
  background: var(--background);
  -webkit-text-size-adjust: 100%;
  /* No double-tap zoom, and no rubber-band bounce past the ends: an app's
     pages stay put (pull-to-sync is the app's own, in gestures.js). */
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--ink-soft);
  font: 15px/1.5 var(--mono);
  /* Room for the tab bar, which reaches down past the home indicator. */
  padding-bottom: calc(52px + env(safe-area-inset-bottom) / 2);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* Buttons and labels aren't text to select, and long-pressing a link
     shouldn't pop up a preview. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: padding-bottom 200ms;
}

/* What you'd want to copy stays selectable. */
input, textarea, .raw {
  -webkit-user-select: text;
  user-select: text;
}

a { color: inherit; }

header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--background);
  padding-top: env(safe-area-inset-top);
}

.noise {
  margin: 0;
  height: 2.2em;
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.1;
  white-space: pre;
  user-select: none;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--ink);
}

.trail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 17px;
  color: var(--ink-soft);
}

.trail a { text-decoration: none; color: var(--muted); }
.trail .home { color: var(--ink); font-weight: 700; }
.trail .home .one { color: var(--accent-text); }
.trail .slash { color: var(--muted); margin: 0 0.4em; }

.status { color: var(--warning); font-weight: 700; min-width: 1ch; }

main { padding: 16px 16px 24px; }

h1 { color: var(--ink); font-size: 22px; line-height: 1.25; margin: 0; }
h2 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 26px 0 8px;
}
h3 { color: var(--ink); font-size: 14px; margin: 16px 0 6px; }
h3.now::after { content: "  ●"; color: var(--accent); }
p { margin: 8px 0; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.faded { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; font-style: italic; }
.label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.center { text-align: center; }
.error { color: var(--warning); }
.flash { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--ink); }
.art { color: var(--muted); margin: 16px 0; font: inherit; }
.art.center { display: table; margin: 40px auto 8px; }
code { font: inherit; color: var(--ink); }

.today { color: var(--ink); font-size: 17px; margin-top: 4px; }
.briefing { color: var(--ink-soft); }

/* Buttons: outlined, or solid ink for the main action. */
.button, .chip {
  appearance: none;
  font: inherit;
  border-radius: 0;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  padding: 9px 16px;
  min-height: 42px;
}
.button.solid { background: var(--ink); color: var(--background); }
.button.small { border: 0; color: var(--muted); font-weight: 400; min-height: 0; padding: 4px 0; }
.button.wide { width: 100%; margin-top: 8px; }
.button:active, .chip:active { background: var(--hover); }
.button.solid:active { background: var(--ink-soft); }
.button:disabled { opacity: 0.6; }

.row-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.row-buttons.bottom { margin-top: 28px; }
.spacer { flex: 1; }

.section-head { display: flex; align-items: baseline; gap: 12px; }
.section-head h2 { margin-right: 0; }
.section-head .button.small { margin-left: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-color: var(--rule); color: var(--ink-soft); font-weight: 400; min-height: 36px; padding: 5px 12px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--background); }
.chip .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }

.picker { display: flex; align-items: center; gap: 4px; }
.picker .muted { margin-right: 6px; }
.picker .chip { min-width: 40px; border-color: var(--ink); }

/* Fields: 16px text, or iOS zooms in on focus. */
input, select, textarea {
  font: 16px/1.4 var(--mono);
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 10px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select { min-height: 44px; }
.select-row { display: flex; align-items: center; gap: 10px; position: relative; }
/* Fields lose their native look, so the menu draws its own arrow. */
.select-row .caret { position: absolute; right: 12px; pointer-events: none; color: var(--ink); }
.select-row .swatch { width: 28px; height: 28px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.select-row select { flex: 1; min-width: 0; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
input[type="date"], input[type="time"] { min-height: 44px; }

.search { margin: 4px 0 4px; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.add { margin: 8px 0 4px; }

.editor label { display: block; margin: 14px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.editor label .hint { display: block; text-transform: none; font-weight: 400; margin: 2px 0 4px; }
.editor label input, .editor label select, .editor label textarea { margin-top: 4px; text-transform: none; font-weight: 400; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Lists */
ul, ol { list-style: none; margin: 0; padding: 0; }

.center-row { justify-content: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* The month, with steps to the one before and after. */
.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-bar h1 { flex: 1; text-align: center; }
.step {
  appearance: none; border: 1px solid var(--ink); background: none; color: var(--ink);
  font: inherit; font-size: 20px; font-weight: 700; min-width: 44px; min-height: 44px; border-radius: 0;
}
.step:active { background: var(--hover); }
.step.off { border-color: var(--rule); color: var(--faint); display: inline-flex; align-items: center; justify-content: center; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 18px 0 0; border: 1px solid var(--ink); }
.totals div { padding: 10px 12px; }
.totals div + div { border-left: 1px solid var(--rule); }
.totals dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.totals dd { margin: 2px 0 0; color: var(--ink); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Spending by category: name, text bar, amount. */
.meters li {
  display: grid; grid-template-columns: minmax(7em, 1fr) auto minmax(6em, auto); align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--rule); cursor: pointer;
}
.meters li:active { background: var(--hover); }
.meters .name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meters .meter { letter-spacing: -0.05em; white-space: nowrap; }
.meters .amount { text-align: right; color: var(--ink); font-weight: 700; }
.bar-fill { color: var(--accent); }
.bar-empty { color: var(--faint); }

.transactions li {
  display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--rule); cursor: pointer;
}
.transactions li:active { background: var(--hover); }
.transactions .who { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transactions .amount { color: var(--ink); font-weight: 700; text-align: right; }
.transactions .amount.in, .big-amount.in { color: var(--accent-text); }
.transactions .what { color: var(--muted); font-size: 12px; }
h3 + .transactions { border-top: 1px solid var(--ink); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.filters select { font-size: 16px; }

.big-amount { color: var(--ink); font-size: 28px; font-weight: 700; margin: 6px 0 10px; }
.facts div { display: grid; grid-template-columns: 7em 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.remember { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; color: var(--ink); }
.remember input { width: 20px; height: 20px; padding: 0; accent-color: var(--ink); -webkit-appearance: checkbox; appearance: auto; }

.file { display: block; text-align: center; line-height: 22px; margin: 16px 0 8px; }
.how { list-style: decimal; padding-left: 1.6em; }
.how li { margin: 4px 0; }

nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  background: var(--background);
  border-top: 1px solid var(--ink);
}
nav[hidden] { display: none; }
nav a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  /* The tabs reach the bottom of the screen, so the selected one is a
     solid block down to the edge, as in iOS. Their text sits in the top
     part, half the home indicator's space above it: clear of the
     indicator without floating. */
  padding: 14px 0 calc(12px + env(safe-area-inset-bottom) / 2);
  font-size: 14px;
}
nav a.on { color: var(--background); background: var(--ink); font-weight: 700; position: relative; }
/* The open tab carries a bar of the accent, or the flag's stripes. */
nav a.on::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--accent-bar, var(--accent)); }

.legal-links { margin-top: 32px; color: var(--muted); font-size: 12px; }
.legal-links a { color: var(--muted); }

/* Charts (views/charts.js). Colours come from the chosen chart style
   (<html data-charts>, js/chartstyle.js) and day or night. Each pair was
   checked for colour-blind separation and contrast (dataviz validator):
   terminal ink + orange (#B44718 by day for contrast on bone), green/red
   #0A5C45 + #D84A2C by day, #5CCB8F + #F0574A at night. Text stays ink. */
:root { --series-in: var(--ink); --series-out: #B44718; --series-last: var(--muted); --good: var(--ink); --bad: #B44718; }
:root[data-charts="terminal-rg"] { --series-in: #0A5C45; --series-out: #D84A2C; --good: #0A5C45; --bad: #D84A2C; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="day"]) { --series-out: #E8642C; --bad: #E8642C; }
  :root[data-charts="terminal-rg"]:not([data-theme="day"]) { --series-in: #5CCB8F; --series-out: #F0574A; --good: #5CCB8F; --bad: #F0574A; }
}
:root[data-theme="night"] { --series-out: #E8642C; --bad: #E8642C; }
:root[data-theme="night"][data-charts="terminal-rg"] { --series-in: #5CCB8F; --series-out: #F0574A; --good: #5CCB8F; --bad: #F0574A; }

.chart-block { margin-bottom: 30px; }
.chart-block h2 { margin-top: 18px; }
.headline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; color: var(--ink); margin: 0 0 6px; }
.headline .big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.delta.good, .readout .good { color: var(--good); }
.delta.bad, .readout .bad { color: var(--bad); }
.chart { width: 100%; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.chart svg { display: block; overflow: visible; cursor: crosshair; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .grid.dotted { stroke-dasharray: 2 4; }
.chart .tick { fill: var(--muted); font: 11px var(--mono); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.thick { stroke-width: 3; }
.chart .line.partial { stroke-dasharray: 3 4; }
.chart .line.in { stroke: var(--series-in); }
.chart .line.out { stroke: var(--series-out); }
.chart .line.last { stroke: var(--series-last); }
.chart .line.spark { stroke: var(--ink); }
.chart .fill { stroke: none; }
.chart .fill.in { fill: var(--series-in); opacity: 0.12; }
.chart .fill.out { fill: var(--series-out); opacity: 0.18; }
.chart .fill.last { fill: var(--series-last); opacity: 0.1; }
.chart .fill.spark { fill: var(--ink); opacity: 0.07; }
.chart .bar.in { fill: var(--series-in); }
.chart .bar.out { fill: var(--series-out); }
.chart .dot { stroke: var(--background); stroke-width: 2; }
.chart .dot.in { fill: var(--series-in); }
.chart .dot.out { fill: var(--series-out); }
.chart .dot.last { fill: var(--series-last); }
.chart .last-level { stroke-width: 1; stroke-dasharray: 1 3; opacity: 0.7; }
.chart .last-level.in { stroke: var(--series-in); }
.chart .last-level.out { stroke: var(--series-out); }
.chart .last-level.last { stroke: var(--series-last); }
.chart .tag.in { fill: var(--series-in); }
.chart .tag.out { fill: var(--series-out); }
.chart .tag.last { fill: var(--series-last); }
.chart .tag.cursor { fill: var(--ink); }
.chart .tag-text { fill: var(--background); font: 700 11px var(--mono); }
.chart .cross line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .brush { fill: var(--good); fill-opacity: 0.14; stroke: var(--good); stroke-opacity: 0.6; stroke-dasharray: 3 3; }
:root:not([data-charts="terminal-rg"]) .chart .brush { fill: var(--series-out); stroke: var(--series-out); }
.chart .hit { fill: transparent; }
.chart .bill-day { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 2 3; }
.chart .bill-day.gone { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 1 4; }
.chart .bill-label { fill: var(--ink); font: 700 11px var(--mono); }
.chart .bill-label.gone { fill: var(--muted); font-weight: 400; }
.chart .today { stroke: var(--ink); stroke-width: 1; }
.chart .projection { fill: none; stroke: var(--series-out); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: 0.85; }
.legend .key-bill { display: inline-block; height: 12px; border-left: 2px dotted var(--ink); margin: 0 4px 0 10px; }
.legend .key-projection { display: inline-block; width: 14px; border-top: 2px dashed var(--series-out); margin: 0 4px 0 10px; vertical-align: middle; }
.legend .toggle { margin-left: auto; min-height: 28px; padding: 2px 10px; font-size: 12px; }
.legend { flex-wrap: wrap; row-gap: 2px; }
.legend .pair { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.legend .pair .key { margin-left: 0; }
.legend .pair + .pair { margin-left: 8px; }
.legend .pair .key-bill, .legend .pair .key-projection { margin-left: 0; }
.headline .ahead { color: var(--ink-soft); font-size: 13px; }
.chart-tip .tip-bill { color: var(--ink); font-weight: 700; }
.coming { margin: 12px 0 0; }
.coming h3 { margin: 10px 0 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.coming li { display: grid; grid-template-columns: 5.5em 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); color: var(--ink); }
.coming .when { color: var(--muted); }
.coming .amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.coming .sum span:nth-child(2) { font-weight: 700; }
.readout { min-height: 1.5em; margin: 6px 0 0; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.readout .hint { color: var(--muted); font-style: italic; }
.readout.on { border-left: 3px solid var(--series-out); padding-left: 8px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 12px; margin: 0 0 6px; }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.legend .key:first-child { margin-left: 0; }
.legend .key.in { background: var(--series-in); }
.legend .key.out { background: var(--series-out); }
.legend .key.last { background: var(--series-last); }
/* Soft: a raised card, like a banking app. */
:root[data-charts="soft"] .chart-block { background: var(--field); border-radius: 14px; padding: 4px 16px 14px; }
:root[data-charts="soft"] .chart-block h2 { margin-top: 14px; }
.chart-tip {
  position: fixed; z-index: 30; pointer-events: none; max-width: 240px;
  background: var(--background); border: 1px solid var(--ink); padding: 7px 10px;
  display: flex; flex-direction: column; gap: 1px; font-size: 12px; color: var(--ink-soft);
}
.chart-tip[hidden] { display: none; }
.chart-tip strong { color: var(--ink); }
.multiples { display: grid; gap: 2px; }
.multiple { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 5.5em; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.multiple .name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiple .now { text-align: right; color: var(--ink); font-weight: 700; line-height: 1.2; }
.multiple .now small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
/* The spreadsheet scrolls sideways on its own; the page never does. */
.sheet-wrap { overflow-x: auto; margin: 6px -16px 0; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.sheet { border-collapse: collapse; font-size: 12px; min-width: 100%; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 6px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.sheet thead th { color: var(--muted); font-weight: 700; text-align: left; border-bottom-color: var(--ink); }
.sheet thead small { color: var(--faint); margin-left: 2px; font-weight: 400; }
.sheet tbody th, .sheet tfoot th { color: var(--ink); font-weight: 400; text-align: left; position: sticky; left: 0; background: var(--background); }
:root[data-charts="soft"] .sheet tbody th, :root[data-charts="soft"] .sheet tfoot th { background: var(--field); }
.sheet .num { text-align: right; }
.sheet .cell { color: var(--ink); cursor: pointer; background: color-mix(in srgb, var(--series-out) calc(var(--shade, 0) * 100%), transparent); }
.sheet .cell:hover { outline: 1px solid var(--ink); outline-offset: -1px; }
.sheet .total { color: var(--ink); font-weight: 700; }
.sheet tfoot td, .sheet tfoot th { border-top: 1px solid var(--ink); font-weight: 700; color: var(--ink); }

/* The list's table on a wide screen: sortable, resizable headings. */
.tx-table th { padding: 0; }
.tx-table th .sort {
  appearance: none; border: 0; background: none; font: inherit; color: inherit; text-transform: inherit;
  width: 100%; text-align: inherit; padding: 6px 14px 6px 8px; cursor: pointer; white-space: nowrap;
}
.tx-table th.num .sort { text-align: right; }
.tx-table th .sort:hover { color: var(--ink); }
.tx-table thead th.num { color: var(--muted); font-weight: 700; }
.tx-table th.sorted, .tx-table th.sorted .sort { color: var(--ink); }
.tx-table th .arrow { color: var(--accent-text); margin-left: 4px; font-size: 9px; }
.tx-table .col-resize { position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; touch-action: none; }
.tx-table .col-resize::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 0; border-left: 1px solid var(--rule); }
.tx-table .col-resize:hover::after, .tx-table.resizing .col-resize::after { border-left: 2px solid var(--accent); top: 0; bottom: 0; }
.tx-table.sized { table-layout: fixed; }
.tx-table.sized td { overflow: hidden; text-overflow: ellipsis; }
.tx-table.sized .who { width: auto; max-width: none; }
.tx-table.resizing { cursor: col-resize; user-select: none; }

/* The balance and pay still to come (overview). */
.totals .note { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.balance { margin: 14px 0 0; border: 1px solid var(--rule); padding: 10px 12px; }
.balance > div { color: var(--ink-soft); margin: 2px 0; }
.balance .big { color: var(--ink); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance .part { color: var(--muted); font-size: 12px; margin-left: 10px; white-space: nowrap; }
.balance .hint { margin: 4px 0 0; }
.balance .overdrawn { color: var(--warning); }
.coming li.in .amount { color: var(--good); }
.coming li small { color: var(--muted); }
/* Settings: naming accounts. */
.accounts li { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.account-name { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.account-name .number { color: var(--muted); }
.account-name input { padding: 6px 8px; }
.balance-note { font-size: 12px; }

/* The budget (views/budget.js) and the overview's budget box. */
.goal .big { color: var(--ink); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal p { margin: 4px 0; }
.goal-bar { letter-spacing: -0.05em; white-space: nowrap; overflow: hidden; }
.allowance { color: var(--ink); margin: 4px 0 8px; }
.allowance b { font-size: 18px; }
.warn-flash { border-left-color: var(--warning); }
.budget-meters li { grid-template-columns: minmax(7em, 1fr) auto minmax(7em, auto); grid-template-rows: auto auto; }
.budget-meters .note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin-top: -2px; }
.budget-meters .amount small { color: var(--muted); font-weight: 400; }
.budget-meters li.warn .bar-fill { color: var(--warning); }
.budget-meters li.over .bar-fill, .budget-meters li.over .amount { color: var(--warning); }
.budget-meters li.warn .note, .budget-meters li.over .note { color: var(--warning); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 8px 0; }
.plan {
  appearance: none; text-align: left; font: inherit; color: var(--ink-soft); background: transparent;
  border: 1px solid var(--rule); border-radius: 0; padding: 12px; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.plan:hover { border-color: var(--ink); }
.plan.on { border: 2px solid var(--ink); padding: 11px; }
.plan-name { color: var(--ink); font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; }
.plan.on .plan-name::after { content: " · yours"; color: var(--accent-text); }
.plan-saving { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-saving small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.plan-goal { color: var(--ink); }
.plan-about { color: var(--muted); font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.sums .total { border-top: 1px solid var(--ink); }
.sums .total dt, .sums .total dd { font-weight: 700; }
.budget-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.budget-table th, .budget-table td { padding: 6px 4px; border-bottom: 1px solid var(--rule); text-align: left; font-weight: 400; }
.budget-table thead th { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; border-bottom-color: var(--ink); }
.budget-table tbody th { color: var(--ink); }
.budget-table .num { text-align: right; }
.budget-table small.essential { color: var(--muted); font-size: 11px; margin-left: 6px; }
.budget-amount { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.budget-amount input { width: 5.5em; padding: 4px 6px; text-align: right; }
.where li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule); color: var(--ink); }
.budget-box { margin-top: 14px; }
.budget-box h2 { margin-top: 6px; }
.budget-link span:first-child { color: var(--accent); }
main[data-view="budget"] { max-width: 820px; }

/* The ⚙ at the top right: settings. */
.cog { color: var(--muted); text-decoration: none; font-size: 22px; line-height: 1; padding: 4px 2px 4px 10px; }
.cog.on { color: var(--accent-text); }
.cog[hidden] { display: none; }

/* Subscriptions and bills (views/subs.js). */
.subs-total { color: var(--ink); font-size: 18px; margin: 4px 0 0; }
.subs-total strong { font-size: 34px; }
.section-total { margin-left: auto; color: var(--muted); font-size: 12px; }
.subs li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 0 12px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--rule); cursor: pointer;
}
.subs li:active, .subs li:hover { background: var(--hover); }
.subs .who { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subs .amount { color: var(--ink); font-weight: 700; text-align: right; }
.subs .side { min-width: 3.5em; text-align: right; }
.subs .what { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.subs.ended .who, .subs.ended .amount { color: var(--muted); font-weight: 400; }
.sub-link { color: var(--accent-text); font-weight: 700; text-decoration: none; padding: 6px 0 6px 10px; }
p > .sub-link { padding: 0; }
.add-link { color: var(--faint); font-size: 12px; }
.warn-note { color: var(--warning); }
.change.up { color: var(--warning); }
.change.down { color: var(--accent-text); }
.mini-chart { margin: 18px 0 4px; font: 12px/1.1 var(--mono); color: var(--ink); white-space: pre; overflow: hidden; }
.mini-chart b { font-weight: 400; }
.mini-chart .a { color: var(--accent); }
.hidden-subs { margin-top: 22px; color: var(--muted); }
.hidden-subs summary { cursor: pointer; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.big-amount small { font-size: 15px; font-weight: 400; }
.link-form input { margin-top: 0; }

/* The bank connection needs you: every page says so. */
.banner { margin: 12px 16px 0; padding: 9px 12px; border: 1px solid var(--accent); color: var(--ink); }
.banner[hidden] { display: none; }
.banner a { color: var(--accent-text); font-weight: 700; text-decoration: none; }

/* The river (views/river.js): one canvas of glyphs, and a tooltip. */
.river-line { color: var(--ink); margin: 14px 0 6px; }
.river-wrap { position: relative; height: 440px; margin: 8px -4px 4px; touch-action: manipulation; }
.river { display: block; }
.river-tip {
  position: absolute; z-index: 1; max-width: 260px; pointer-events: none;
  background: var(--background); border: 1px solid var(--ink); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.river-tip[hidden] { display: none; }
.river-tip strong { color: var(--ink); }
.river-card { border: 1px solid var(--ink); padding: 10px 12px; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 2px; }
.river-card[hidden] { display: none; }
.river-card strong { color: var(--ink); }
.river-card a { color: var(--accent-text); font-weight: 700; margin-top: 6px; text-decoration: none; padding: 4px 0; }

/* Your year, wrapped (views/wrapped.js): a full-screen deck of cards. */
.wrapped-link {
  appearance: none; display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 16px 0 0; padding: 12px 14px; border: 1px dashed var(--ink); border-radius: 0;
  background: none; color: var(--ink); font: inherit; font-weight: 700; text-align: left; cursor: pointer;
}
.wrapped-link span { color: var(--accent); }
.wrapped-link .go { margin-left: auto; color: var(--muted); }
.wrapped-link:active, .wrapped-link:hover { background: var(--hover); }

body.wrapped-open { overflow: hidden; }
body.wrapped-open nav { display: none; }
.wrapped {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: var(--background); overflow: hidden; cursor: pointer;
  padding: calc(env(safe-area-inset-top) + 14px) 22px calc(env(safe-area-inset-bottom) + 22px);
  -webkit-user-select: none; user-select: none;
}
.w-progress { display: flex; gap: 4px; width: 100%; max-width: 680px; margin: 0 auto; padding-right: 36px; }
.w-progress span { flex: 1; height: 3px; background: var(--rule); overflow: hidden; }
.w-progress i { display: block; height: 100%; width: 0; background: var(--ink); }
.w-progress .done i { width: 100%; }
.w-progress .now i { animation: w-fill var(--auto, 8000ms) linear forwards; }
.wrapped.last .w-progress .now i { width: 100%; animation: none; }
.wrapped.paused .w-progress .now i { animation-play-state: paused; }
@keyframes w-fill { to { width: 100%; } }
.w-close {
  position: absolute; top: calc(env(safe-area-inset-top) + 2px); right: 12px;
  appearance: none; border: 0; background: none; font: inherit; font-size: 28px; color: var(--muted);
  min-width: 44px; min-height: 44px; cursor: pointer;
}
.w-deck { flex: 1; display: flex; align-items: center; width: 100%; max-width: 680px; margin: 0 auto; }
.w-card { display: none; width: 100%; }
.w-card.on { display: block; animation: w-in 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes w-in { from { opacity: 0; transform: translateY(16px); } }
.w-kicker { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 14px; }
.w-title { color: var(--ink); font-size: 26px; line-height: 1.2; margin: 6px 0; overflow-wrap: anywhere; }
.w-big { color: var(--ink); font-size: 44px; font-weight: 700; line-height: 1.1; margin: 4px 0; }
.w-big small { color: var(--muted); font-size: 16px; font-weight: 400; }
@media (max-width: 600px) { .w-big small { display: block; margin-top: 2px; } }
.w-accent, .w-accent .count { color: var(--accent-text); }
.w-sub { color: var(--ink-soft); margin: 8px 0; }
.w-art { margin: 26px 0 0; font: 13px/1.15 var(--mono); color: var(--faint); white-space: pre; overflow: hidden; }
.w-art.small { font-size: 12px; line-height: 1.45; }
.w-art b { font-weight: 400; }
.w-art .a { color: var(--accent); }
.w-art .d { color: var(--accent-text); }
.w-art .k, .w-art .bar-ink { color: var(--ink); }
.w-art i { color: var(--muted); font-style: normal; }
/* Each row of a picture draws in from the left, one after another. */
.w-row { display: inline-block; }
.w-card.on .w-row { animation: w-row 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i) * 70ms + 250ms); }
@keyframes w-row { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.w-card.on .wave .w-row { animation: w-row 380ms both, w-drift 3s ease-in-out infinite alternate; animation-delay: calc(var(--i) * 70ms + 250ms), calc(var(--i) * -400ms); }
@keyframes w-drift { from { transform: translateX(0); } to { transform: translateX(-1.5ch); } }
.w-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule); color: var(--ink); }
.w-end { display: flex; gap: 10px; margin-top: 22px; }
@media (min-width: 900px) {
  .w-title { font-size: 32px; }
  .w-big { font-size: 64px; }
  .w-art { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .w-card.on, .w-card.on .w-row, .w-card.on .wave .w-row, .w-progress .now i { animation: none; }
  .w-progress .now i { width: 100%; }
}

/* The phone shows the first 5 of the latest; a wide screen all of them. */
.latest li:nth-child(n+6) { display: none; }

/* Laptop and desktop (js/ui.js WIDE): the header across the top, the tabs
   in a sidebar, the pages in columns, and denser controls. Capped at
   1400px and centred on very wide screens. */
@media (min-width: 900px) {
  body {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "head head" "side main";
    max-width: 1400px;
    min-height: 100vh;
    margin: 0 auto;
    padding-bottom: 0;
    font-size: 14px;
  }
  header { grid-area: head; }
  header .bar { margin: 0 24px; padding-bottom: 12px; }
  .trail { font-size: 16px; }

  nav {
    grid-area: side;
    position: sticky;
    top: var(--header-height, 66px);
    left: auto; right: auto; bottom: auto;
    align-self: start;
    flex-direction: column;
    padding: 20px 0;
    border-top: 0;
    background: none;
  }
  nav a { flex: none; text-align: left; padding: 9px 24px; font-size: 14px; }
  nav a.on::before { top: 0; bottom: 0; left: 0; right: auto; width: 4px; height: auto; background: var(--accent); }
  nav a:not(.on):hover { color: var(--ink); background: var(--hover); }

  main { grid-area: main; min-width: 0; padding: 20px 24px 48px 8px; }
  .banner { grid-area: main; align-self: start; margin: 16px 24px 0 8px; position: relative; z-index: 1; }
  body:has(.banner:not([hidden])) main { padding-top: 70px; }
  main[data-view="import"], main[data-view="me"], main[data-view="subs"], main[data-view="sub"] { max-width: 760px; }
  main[data-view="charts"] { max-width: 980px; }
  /* Signing in: no sidebar, a centred form. */
  body:has(nav[hidden]) main { grid-column: 1 / -1; width: 100%; max-width: 440px; margin: 0 auto; padding: 20px 24px; }

  h1 { font-size: 20px; }
  h2 { margin-top: 20px; }
  .button, .chip { min-height: 34px; padding: 6px 14px; }
  .chip { min-height: 30px; padding: 3px 10px; }
  .button:hover, .chip:hover, .step:hover { background: var(--hover); }
  .button.solid:hover { background: var(--ink-soft); }
  .chip.on:hover { background: var(--ink); }
  input, select, textarea { font-size: 14px; padding: 7px 10px; }
  select { min-height: 36px; }
  .step { min-width: 36px; min-height: 36px; font-size: 17px; }

  .overview-head { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 1.5fr); gap: 32px; align-items: center; }
  .totals { margin: 0; }
  .totals dd { font-size: 16px; }
  .columns { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
  .latest li:nth-child(n+6) { display: grid; }
  .meters li, .transactions li { padding: 7px 0; }
  .meters li:hover, .transactions li:hover { background: var(--hover); }

  .split { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); gap: 28px; align-items: start; }
  .split .search { margin-top: 0; }
  .split-detail {
    position: sticky; top: calc(var(--header-height, 66px) + 16px);
    max-height: calc(100vh - var(--header-height, 66px) - 36px); overflow: auto;
    border: 1px solid var(--ink); padding: 14px 18px 18px;
  }
  .split-detail h1 { font-size: 18px; }
  .split-detail .big-amount { font-size: 24px; margin: 4px 0 8px; }
  .split-detail .facts div { grid-template-columns: 6.5em 1fr; }

  .file { display: inline-block; width: auto; padding: 8px 20px; }
  .river-wrap { height: min(560px, calc(100vh - 230px)); min-height: 380px; }
  main[data-view="river"] .month-bar { max-width: 520px; }

  .tx-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
  .tx-table th {
    text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase;
    padding: 6px 8px; border-bottom: 1px solid var(--ink); position: sticky; top: var(--header-height, 66px); z-index: 1; background: var(--background);
  }
  .tx-table td { padding: 6px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
  .tx-table tr { cursor: pointer; }
  .tx-table tbody tr:hover { background: var(--hover); }
  .tx-table tbody tr.on, .tx-table tbody tr.on:hover { background: var(--ink); }
  .tx-table tr.on td, .tx-table tr.on .num.in { color: var(--background); }
  .tx-table .date { color: var(--muted); }
  .tx-table .who { color: var(--ink); max-width: 0; width: 40%; overflow: hidden; text-overflow: ellipsis; }
  .tx-table .what { color: var(--ink-soft); }
  .tx-table .num { text-align: right; font-weight: 700; color: var(--ink); }
  .tx-table .num.in { color: var(--accent-text); }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}
