/*
  Ledger & Lane: personal banking dashboard (Screenery template "ledger")
  1. Tokens, base and browser surfaces   2. Masthead and account tabs
  3. The bound sheet: balance band, register, side page   4. Transfer slip (dialog)
  5. Components: pick list (select), calendar, tooltip, notices, confirmation dialog, radio, switch
  6. Responsive (1100px, 720px) and the print stylesheet for the register
*/

/* ---------- 1. Tokens ---------- */
:root {
  /* paper and ink */
  --paper: #f6f1e4;        /* ledger cream, the ground */
  --paper-deep: #ece5d2;   /* resting tabs, wells */
  --sheet: #fcf9f0;        /* the bound page */
  --ink: #173a2f;          /* deep green ink */
  --ink-soft: #4b6258;     /* secondary text, 6:1 on sheet */
  --ink-press: #0f2a22;
  --debit: #7a1f2b;        /* burgundy, money out and errors */
  --debit-wash: #f3e3df;
  --gilt: #c8ab62;         /* foil on the card and masthead */
  --cream-soft: #cfd3c2;   /* secondary text on green */
  --safety: #e2e8d5;       /* cheque safety paper, behind the engraving */
  --field: #fffdf7;        /* inputs and popups, a shade brighter than the sheet */

  /* rules */
  --rule: #173a2f24;
  --rule-mid: #173a2f47;
  --rule-strong: #173a2f;
  --rule-red: #7a1f2b59;

  /* category inks */
  --cat-housing: #173a2f;
  --cat-bills: #3f5d78;
  --cat-groceries: #71894a;
  --cat-dining: #b78a2a;
  --cat-transport: #8f5a3c;
  --cat-leisure: #a4596a;
  --cat-income: #2c6b52;
  --cat-transfers: #8a9189;

  /* type */
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;

  /* space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --gutter: clamp(16px, 2.6vw, 40px);
  --pad: clamp(20px, 2.8vw, 44px);

  /* shape */
  --r-sm: 3px;
  --r-md: 6px;
  --r-card: 12px;

  --pop-shadow: 0 22px 32px -20px #0f2a2299, 0 5px 12px -5px #0f2a2247;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  color-scheme: light;
  scrollbar-color: #173a2f66 var(--paper);
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  accent-color: var(--ink);
  caret-color: var(--debit);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--ink); color: var(--paper); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: #173a2f59; border: 2px solid var(--paper); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #173a2f99; }

h1, h2, h3, p, dl, dd, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; text-wrap: balance; letter-spacing: -.01em; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: inherit; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
.masthead :focus-visible, .card :focus-visible { outline-color: var(--paper); }

/* Numerals: Newsreader, old-style and tabular, wherever money or dates are set */
.num, td.c-date, td.c-out, td.c-in, td.c-bal, time {
  font-family: var(--serif);
  font-variant-numeric: oldstyle-nums tabular-nums;
}

.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.sprite { position: absolute; width: 0; height: 0; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.wrap { max-width: 1400px; margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: var(--r-sm);
}
.skip:focus { top: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px; letter-spacing: .005em; white-space: nowrap;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-cream { background: var(--paper); color: var(--ink); }
.btn-cream:hover { background: #fffdf6; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: var(--ink-press); }
.btn-outline { border-color: var(--rule-strong); background: transparent; }
.btn-outline:hover { background: var(--ink); color: var(--paper); }
.btn-quiet { background: transparent; padding-inline: 12px; }
.btn-quiet:hover { background: #173a2f14; }
.btn[disabled] { opacity: .55; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: transparent; border: 0; border-radius: var(--r-sm);
  transition: background-color .2s var(--ease);
}
.icon-btn:hover:not([disabled]) { background: #173a2f14; }
.icon-btn[disabled] { opacity: .3; cursor: default; }

/* ---------- 2. Masthead ---------- */
.masthead {
  background: var(--ink);
  color: var(--paper);
  /* a faint engraved line under the bar, like the head of a statement */
  box-shadow: inset 0 -1px 0 #f6f1e426;
}
.masthead-row {
  display: flex; align-items: center; gap: var(--s6);
  padding-block: 18px 22px;
}
.wordmark { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; flex: none; }
.seal { width: 40px; height: 40px; fill: none; stroke: var(--gilt); stroke-width: .55; }
.seal-l { stroke: var(--paper); stroke-width: 2; stroke-linecap: square; }
.seal:has(g:empty) { background: url("assets/seal.svg") center / contain no-repeat; }
.wordmark-name { font: 500 25px/1 var(--serif); letter-spacing: -.015em; }
.wordmark-name i { font-weight: 400; color: var(--gilt); padding-inline: 1px; }

.primary { display: flex; gap: 2px; margin-right: auto; }
.primary a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 13px;
  color: var(--cream-soft); text-decoration: none; font-weight: 500; font-size: 14px;
  border-radius: var(--r-sm);
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.primary a:hover { color: var(--paper); background: #f6f1e414; }
.primary a[aria-current] { color: var(--paper); text-decoration: underline; text-decoration-color: var(--gilt); text-underline-offset: .5em; }

.masthead-end { display: flex; align-items: center; gap: var(--s5); }
.who { text-align: right; font-size: 13px; line-height: 1.35; color: var(--cream-soft); }
.who-name { display: block; color: var(--paper); font-weight: 600; font-size: 14px; }
.who time { font-size: 14px; }

/* Account tabs: the index tabs of a bound ledger, sitting on the sheet's top edge */
.tabs { display: flex; gap: 6px; align-items: flex-end; }
.tab {
  display: grid; gap: 1px; text-align: left;
  min-width: 190px; padding: 11px 20px 12px;
  background: #f6f1e41a; color: var(--cream-soft);
  border: 1px solid #f6f1e433; border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  transition: background-color .25s var(--ease), color .25s var(--ease), padding .25s var(--ease);
}
.tab:hover { background: #f6f1e42b; color: var(--paper); }
.tab-name { font-weight: 600; font-size: 14px; }
.tab-bal { font-size: 16px; line-height: 1.2; }
.tab[aria-selected="true"] {
  background: var(--sheet); color: var(--ink); border-color: var(--sheet);
  padding-top: 15px;
}

/* ---------- 3. The bound sheet ---------- */
main.wrap { padding-bottom: var(--s7); }
.sheet {
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 29vw, 400px);
  background: var(--sheet);
  border: 1px solid var(--rule-mid); border-top: 0;
  /* the edges of the pages underneath */
  box-shadow:
    0 3px 0 -1px var(--sheet), 0 3px 0 0 var(--rule-mid),
    0 6px 0 -2px var(--sheet), 0 6px 0 -1px var(--rule-mid),
    0 28px 40px -28px #173a2f40;
  outline-offset: 4px;
}
.page-main { display: flex; flex-direction: column; padding: var(--pad) var(--pad) var(--s7); min-width: 0; }
.page-side {
  padding: var(--pad) clamp(20px, 2.2vw, 32px) var(--s7);
  border-left: 3px double var(--rule-mid);   /* the binding */
  background: linear-gradient(90deg, #173a2f0d, #173a2f00 18px);
  min-width: 0;
}

/* Balance */
.balance-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.balance-head h1 { font-size: 36px; line-height: 1.1; letter-spacing: -.015em; }
.acct-id { display: flex; gap: var(--s4); font-size: 17px; color: var(--ink-soft); }
.acct-id span + span { padding-left: var(--s4); border-left: 1px solid var(--rule-mid); }

.band {
  position: relative; display: flex; align-items: center;
  height: clamp(150px, 15vw, 208px);
  margin: var(--s4) calc(var(--pad) * -1) 0; padding-inline: var(--pad);
  background: var(--safety);
  border-block: 1px solid var(--rule-strong);
  box-shadow: inset 0 3px 0 var(--safety), inset 0 4px 0 var(--rule-mid), inset 0 -3px 0 var(--safety), inset 0 -4px 0 var(--rule-mid);
  overflow: hidden;
}
.band-art {
  position: absolute; inset: 0; width: 100%; height: 100%;
  fill: none; stroke: var(--ink); stroke-width: .6;
}
.band-art:empty { background: url("assets/band.svg") right center / cover no-repeat; }
.band-art path { vector-effect: non-scaling-stroke; }
.band-art .g-wave { opacity: .7; }
.band-art .g-fine { stroke: var(--debit); opacity: .7; }
.band-art .g-chain { stroke-width: .5; }
.band-art .g-border { fill: url(#g-chain); stroke: none; opacity: .6; }
.band-art .g-rule { opacity: .4; }
/* The figure sits in a cartouche: a clear window cut into the engraving, as on a banknote */
.figure {
  position: relative; display: flex; align-items: flex-start;
  padding: .13em .3em .03em .24em;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4px var(--rule-strong);
  font-family: var(--serif); font-weight: 400; line-height: 1;
  font-size: clamp(3.4rem, 6.4vw, 6rem); letter-spacing: -.02em;
  font-variant-numeric: oldstyle-nums tabular-nums;
}
.figure-cur { font-size: .5em; margin: .22em .12em 0 0; color: var(--ink-soft); }
.figure-num { display: inline-flex; white-space: nowrap; }
.figure.is-neg { color: var(--debit); }

/* Rolling numerals: each digit is a strip 0 to 9, moved with a transform */
.roll { display: inline-block; height: 1.18em; line-height: 1.18em; overflow: hidden; }
.roll-strip {
  display: flex; flex-direction: column;
  transform: translateY(calc(var(--d, 0) * -10%));
  transition: transform 1.1s var(--ease);
  transition-delay: calc(var(--i, 0) * 45ms);
}
.roll-strip span { height: 1.18em; }
.no-roll .roll-strip { transition: none; }
.roll-sep { display: inline-block; height: 1.18em; line-height: 1.18em; }

.balance-note { margin-top: var(--s3); color: var(--ink-soft); max-width: 68ch; text-wrap: pretty; }
.balance-note b { color: var(--ink); font-weight: 600; }
.balance-note .num { font-size: 1.1em; }

/* Register */
.register-block { display: flex; flex-direction: column; flex: 1; margin-top: var(--s7); --money: 118px; --lead: 98px; }
.print-head { display: none; }
.register-head { display: flex; align-items: center; gap: var(--s4); }
.register-head h2 { font-size: 28px; line-height: 1.15; margin-right: auto; }
.month { display: flex; align-items: center; border: 1px solid var(--rule-mid); border-radius: var(--r-sm); }
.month-label {
  min-width: 152px; text-align: center; font: 500 17px/1 var(--serif);
  font-variant-numeric: oldstyle-nums;
}

.summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin-top: var(--s4);
  border-block: 1px solid var(--rule-mid);
}
.summary > div { padding: 12px var(--s4) 11px; }
.summary > div + div { border-left: 1px solid var(--rule); }
.summary > div:first-child { padding-left: 0; }
.summary dt { font: 500 13px/1.3 var(--sans); color: var(--ink-soft); }
.summary dd { font-size: 22px; line-height: 1.25; }
.debit { color: var(--debit); }

.filters { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); }
.field-inline .pick-btn { min-width: 156px; }
.field-inline { display: flex; min-width: 0; align-items: center; gap: var(--s2); font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.search:hover, .slip input:hover { border-color: var(--ink); }
.search {
  flex: 1; max-width: 360px; display: flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 10px 0 12px;
  border: 1px solid var(--rule-mid); border-radius: var(--r-sm); background: var(--sheet);
  transition: border-color .2s var(--ease);
}
.search:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.search .icon { color: var(--ink-soft); }
.search input {
  flex: 1; min-width: 0; height: 42px; padding: 0; border: 0; border-radius: 0; background: none; outline: 0; font-size: 14px;
  appearance: none; -webkit-appearance: none;
}
.search input::-webkit-search-decoration { -webkit-appearance: none; }
.search input::placeholder, .slip input::placeholder { color: var(--ink-soft); opacity: 1; }
.search input::-webkit-search-cancel-button {
  -webkit-appearance: none; width: 18px; height: 18px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23173a2f' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='m5 5 10 10M15 5 5 15'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.search kbd {
  display: grid; place-items: center; width: 22px; height: 22px;
  border: 1px solid var(--rule-mid); border-radius: var(--r-sm);
  font: 500 12px/1 var(--sans); color: var(--ink-soft);
}
.search:focus-within kbd { display: none; }
.count { margin-left: auto; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }

/* The table, ruled like accounting paper: hairlines across, red money rules down */
.register-scroll { margin-top: var(--s4); }
.register { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; }
.register th {
  padding: 9px 12px 8px; text-align: left; vertical-align: bottom;
  font: 600 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft);
  border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.register th button {
  display: inline-flex; align-items: center; gap: 2px;
  margin: -12px -8px; padding: 8px; min-height: 44px;
  background: none; border: 0; border-radius: var(--r-sm);
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--ink);
}
.register th button:hover { background: #173a2f14; }
.register th .icon { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.register th[aria-sort="ascending"] .icon { transform: rotate(180deg); }
.register td { padding: 0 12px; height: 48px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.register .c-date { width: 86px; padding-left: 4px; white-space: nowrap; }
.register .c-cat { width: 148px; }
.register .c-out, .register .c-in, .register .c-bal { width: 118px; text-align: right; white-space: nowrap; }
.register td.c-date, .register td.c-out, .register td.c-in, .register td.c-bal { font-size: 17px; }
.register td.c-date { color: var(--ink-soft); }
.register .c-out { border-left: 3px double var(--rule-red); color: var(--debit); }
.register .c-in, .register .c-bal { border-left: 1px solid var(--rule-red); }
.register th.c-out { color: var(--debit); }
.register td.c-bal { font-weight: 500; }
.register td.c-bal.is-neg { color: var(--debit); }

.entry { transition: background-color .15s var(--ease); cursor: pointer; }
.entry:hover, .entry.is-open { background: #173a2f0b; }
.entry.is-new { animation: inked 2.4s var(--ease) 1; }
@keyframes inked { from { background: #c8ab6259; } to { background: #c8ab6200; } }
.entry-toggle {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 47px;
  padding: 0; background: none; border: 0; text-align: left;
}
.entry-toggle .names { display: grid; min-width: 0; }
.payee { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 13px; line-height: 1.25; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub .sub-cat { display: none; }
.entry-toggle .icon { margin-left: auto; width: 18px; height: 18px; color: var(--ink-soft); opacity: 0; transition: transform .3s var(--ease), opacity .2s; }
.entry:hover .entry-toggle .icon, .entry-toggle:focus-visible .icon, .entry.is-open .entry-toggle .icon { opacity: 1; }
.entry.is-open .entry-toggle .icon { transform: rotate(180deg); }
.cat { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.cat i, .legend i { width: 9px; height: 9px; flex: none; border-radius: 1px; background: var(--c); transform: rotate(45deg); }

.entry-detail td { height: auto; padding: 0; background: #173a2f0b; border-bottom: 1px solid var(--rule-mid); }
.detail {
  display: grid; grid-template-columns: 1fr auto; gap: var(--s4) var(--s5); align-items: end;
  padding: 6px 12px 18px 98px;
}
.detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3) var(--s5); }
.detail dt, .review dt { font-size: 13px; color: var(--ink-soft); }
.detail dd { font-size: 14px; font-weight: 500; }
.detail dd.num { font-size: 16px; font-weight: 400; white-space: nowrap; }
.detail .btn { min-height: 44px; }

.carry td { height: 44px; font-style: italic; font-family: var(--serif); font-size: 17px; color: var(--ink-soft); }
.carry td.c-bal { font-style: normal; color: var(--ink); }
.carry:last-child td { border-bottom: 2px solid var(--rule-strong); }

.empty { padding: var(--s7) var(--s4) var(--s6); text-align: center; border-bottom: 2px solid var(--rule-strong); }
.empty-art { width: 104px; height: 104px; fill: none; stroke: var(--ink); stroke-width: .5; opacity: .6; }
.empty h3 { margin-top: var(--s3); font-size: 22px; }
.empty p { margin: var(--s2) auto var(--s5); max-width: 46ch; color: var(--ink-soft); text-wrap: pretty; }

/* A short month: the unused lines are ruled off with one diagonal stroke,
   as a bookkeeper closes a page. It takes whatever height the facing page leaves over. */
.ruled-off {
  position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; container-type: size;
  box-shadow: inset 0 -1px 0 var(--rule-mid);
  background:
    linear-gradient(var(--rule-red), var(--rule-red)) right calc(var(--money) - 1px) top / 1px 100% no-repeat,
    linear-gradient(var(--rule-red), var(--rule-red)) right calc(var(--money) * 2 - 1px) top / 1px 100% no-repeat,
    linear-gradient(var(--rule-red), var(--rule-red)) right calc(var(--money) * 3 - 1px) top / 1px 100% no-repeat,
    linear-gradient(var(--rule-red), var(--rule-red)) right calc(var(--money) * 3 - 3px) top / 1px 100% no-repeat,
    repeating-linear-gradient(#0000 0 47px, var(--rule) 47px 48px);
}
.ruled-off p {
  position: absolute; left: var(--lead); top: 0;
  font: italic 400 17px/47px var(--serif); color: var(--ink-soft); white-space: nowrap;
}
.ruled-off svg {
  position: absolute; left: 0; top: 60px; width: calc(100% - var(--money) * 3 - 15px); height: calc(100% - 72px);
  fill: none; stroke: var(--rule-mid); stroke-width: 1;
}
.ruled-off line { vector-effect: non-scaling-stroke; }
@container (max-height: 190px) { .ruled-off p, .ruled-off svg { display: none; } }

/* Side page */
.side-block + .side-block { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--rule-mid); }
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.side-head h2 { font-size: 20px; line-height: 1.2; }
.side-total { font-size: 20px; line-height: 1.2; }
.fine { margin-top: var(--s3); font-size: 13px; line-height: 1.45; color: var(--ink-soft); text-wrap: pretty; }
.side-empty { margin-top: var(--s3); padding: var(--s4); border: 1px dashed var(--rule-mid); border-radius: var(--r-sm); font-size: 14px; color: var(--ink-soft); text-wrap: pretty; }

.spendbar { display: flex; gap: 2px; height: 28px; margin-top: var(--s4); }
.spendbar span { background: var(--c); min-width: 3px; transition: flex-basis .7s var(--ease), opacity .2s; }
.spendbar.has-pick span:not(.is-pick) { opacity: .28; }
.legend { margin-top: var(--s3); }
.legend button {
  display: grid; grid-template-columns: 9px 1fr auto 44px; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 0 8px 0 5px; margin-inline: -5px; width: calc(100% + 10px);
  background: none; border: 0; border-bottom: 1px solid var(--rule); text-align: left; font-size: 14px;
  transition: background-color .15s var(--ease);
}
.legend li:last-child button { border-bottom: 0; }
.legend button:hover { background: #173a2f0b; }
.legend button[aria-pressed="true"] { background: #173a2f14; font-weight: 600; }
.legend .num { font-size: 16px; text-align: right; }
.legend .pct { color: var(--ink-soft); }

.bills { margin-top: var(--s3); }
.bills li {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: var(--s3);
  min-height: 54px; border-bottom: 1px solid var(--rule);
}
.bills li:last-child { border-bottom: 0; }
.bills time { font-size: 15px; color: var(--ink-soft); white-space: nowrap; }
.bills time b { font-weight: 500; font-size: 20px; color: var(--ink); }
.bill-name { display: block; font-weight: 500; font-size: 14px; line-height: 1.3; }
.bill-meta { display: block; font-size: 13px; color: var(--ink-soft); line-height: 1.3; }
.bill-amt { font-size: 17px; }
.bills li.is-new { animation: inked 2.4s var(--ease) 1; }
.bills li.is-mine { grid-template-columns: 58px 1fr auto 36px; }
.bill-cancel {
  display: grid; place-items: center; width: 36px; height: 44px; margin-right: -8px; padding: 0;
  background: none; border: 0; border-radius: var(--r-sm); color: var(--debit);
  transition: background-color .2s var(--ease);
}
.bill-cancel:hover { background: var(--debit-wash); }
.bill-cancel .icon { width: 18px; height: 18px; }

/* Savings goals as measured rules: a scale with ticks, inked up to the amount saved */
.goals { margin-top: var(--s2); }
.goal { padding-block: var(--s4) 2px; }
.goal-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.goal-name { font-weight: 500; font-size: 14px; }
.goal-sum { font-size: 16px; white-space: nowrap; }
.goal-sum i { color: var(--ink-soft); }
.measure {
  position: relative; height: 30px; margin-top: 2px;
  border-bottom: 1px solid var(--rule-strong);
  background:
    /* major ticks at each third, minor ticks every thirtieth */
    repeating-linear-gradient(90deg, var(--ink) 0 1px, #0000 1px calc((100% - 1px) / 3)) bottom left / 100% 11px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 1px, #0000 1px calc((100% - 1px) / 30)) bottom left / 100% 6px no-repeat;
}
.measure::before {            /* the inked length */
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p); background: var(--ink);
  transition: width 1s var(--ease);
}
.measure::after {             /* the pointer */
  content: ""; position: absolute; left: var(--p); bottom: 4px; width: 1px; height: 14px; background: var(--debit);
}
.measure-mark {
  position: absolute; left: var(--p); bottom: 15px; transform: translateX(-100%);
  padding-right: 5px; font-size: 14px; line-height: 1; color: var(--debit);
  display: inline-flex; align-items: center; gap: 2px; white-space: nowrap;
}
.goal.is-met .measure-mark { font: 600 12px/1 var(--sans); color: var(--ink); }
.goal.is-met .measure::after { background: var(--ink); }
.measure-mark .icon { width: 15px; height: 15px; }
.goal-scale { display: flex; justify-content: space-between; margin-top: 3px; font-size: 13px; color: var(--ink-soft); }

/* Debit card */
.card-state { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.card-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cat-income); }
.card-state.is-frozen { color: var(--debit); }
.card-state.is-frozen::before { background: var(--debit); }
.card {
  position: relative; aspect-ratio: 1.586; margin-top: var(--s4); container-type: inline-size;
  border-radius: var(--r-card); overflow: hidden; isolation: isolate;
  background: var(--ink); color: var(--paper);
  box-shadow: 0 1px 0 #ffffff26 inset, 0 14px 22px -14px #0f2a2299, 0 3px 6px -2px #0f2a2259;
  transition: filter .6s var(--ease);
}
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; fill: none; stroke: var(--gilt); stroke-width: .45; opacity: .8; }
.card-art .g-b { stroke: var(--paper); opacity: .32; }
.card-art:has(g:empty) { background: url("assets/card.svg") center / cover no-repeat; }
.card > p { position: absolute; }
.card-bank { left: 7%; top: 9%; font: 500 20px/1 var(--serif); letter-spacing: -.01em; }
.card-bank i { color: var(--gilt); font-weight: 400; }
.card-debit { right: 7%; top: 10%; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--cream-soft); }
.card-chip { position: absolute; left: 7%; top: 35%; width: 13%; fill: #c8ab6226; stroke: var(--gilt); stroke-width: 1.2; }
.card-number { left: 7%; bottom: 25%; display: flex; gap: .7em; font-size: 21px; line-height: 1; letter-spacing: .04em; }
.card-holder { left: 7%; bottom: 9%; font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.card-exp { right: 7%; bottom: 8.5%; font-size: 16px; line-height: 1.1; }
.card-exp span { font: 500 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--cream-soft); margin-right: 6px; }
@container (max-width: 310px) { .card-exp span { display: none; } .card-number { font-size: 19px; } }
.card-stamp {
  left: 50%; top: 50%; padding: 5px 16px 4px;
  transform: translate(-50%, -50%) rotate(-9deg) scale(1.5); opacity: 0;
  border: 2px solid var(--paper); border-radius: var(--r-sm);
  font: 600 22px/1 var(--serif); letter-spacing: .16em; text-transform: uppercase;
  background: #173a2fd9;
  transition: opacity .25s var(--ease), transform .45s var(--ease);
}
.card.is-frozen { filter: saturate(.25) brightness(1.08); }
.card.is-frozen .card-stamp { opacity: 1; transform: translate(-50%, -50%) rotate(-9deg) scale(1); }

.freeze { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-top: var(--s4); }
.freeze-label { font-weight: 600; font-size: 14px; }
.freeze .fine { margin-top: 2px; }
.banker-name { margin-top: var(--s3); font: 500 24px/1.15 var(--serif); letter-spacing: -.01em; }
.banker .fine { margin-top: var(--s1); }
.banker .fine a { display: inline-block; padding-block: 3px; color: var(--ink); font-size: 15px; white-space: nowrap; }
.banker .btn { margin-top: var(--s4); width: 100%; }
.banker .btn[disabled] { opacity: 1; cursor: default; border-color: var(--rule-mid); color: var(--ink-soft); background: none; }

.colophon {
  display: flex; justify-content: space-between; gap: var(--s5); flex-wrap: wrap;
  margin-top: var(--s6); font-size: 13px; color: var(--ink-soft);
}
.colophon p:last-child { display: flex; flex-wrap: wrap; column-gap: var(--s5); }
.colophon a { display: inline-flex; align-items: center; min-height: 44px; }
.colophon p:first-child { max-width: 60ch; align-self: center; }

/* ---------- 4. Transfer slip ---------- */
.slip {
  width: min(480px, 100vw); max-width: none; height: 100dvh; max-height: none;
  margin: 0 0 0 auto; padding: 0; border: 0;
  background: var(--sheet); color: var(--ink);
  border-left: 3px double var(--rule-mid);
  box-shadow: -30px 0 60px -30px #0f2a2280;
  transition: transform .5s var(--ease), opacity .3s var(--ease), overlay .5s allow-discrete, display .5s allow-discrete;
  transform: translateX(40px); opacity: 0;
}
.slip[open] { transform: none; opacity: 1; }
@starting-style { .slip[open] { transform: translateX(40px); opacity: 0; } }

.slip-inner { min-height: 100%; padding: var(--s5) clamp(20px, 6vw, 36px) var(--s6); display: flex; flex-direction: column; }
.slip-head { display: flex; align-items: center; justify-content: space-between; }
.slip-head h2 { font-size: 28px; }
.slip-head .icon-btn { margin-right: -10px; }

.steps { display: flex; gap: var(--s2); margin-top: var(--s3); padding-bottom: var(--s4); border-bottom: 1px solid var(--rule-strong); font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.steps li { display: flex; align-items: center; gap: var(--s2); }
.steps li + li::before { content: ""; width: 22px; height: 1px; background: var(--rule-mid); }
.steps li[aria-current] { color: var(--ink); font-weight: 700; }
.steps li.is-done { color: var(--ink); }

.slip-step { display: flex; flex-direction: column; flex: 1; padding-top: var(--s5); }
.field { margin: 0 0 var(--s5); padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 14px; }
.opt { font-weight: 400; color: var(--ink-soft); font-size: 13px; margin-left: 4px; }
.slip input[type="text"] {
  width: 100%; min-height: 48px; padding: 0 12px;
  background-color: var(--field); border: 1px solid var(--rule-mid); border-radius: var(--r-sm);
  font-size: 15px; transition: border-color .2s var(--ease);
}
.slip input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: inset 0 0 0 100px var(--field); }
.slip .pick-btn { min-height: 48px; background-color: var(--field); font-size: 15px; }
.slip .pick-list { width: 100%; }
.date-btn .pick-value { font: 400 18px/1 var(--serif); font-variant-numeric: oldstyle-nums; }
.date-btn .pick-value .pick-meta.is-text { font-size: 13px; }
#filter-cat-list { --meta: 56px; }
#t-to-list { --meta: 104px; }
.pick-value.is-placeholder { font: 400 15px/1 var(--sans); }
.money { position: relative; }
.money span { position: absolute; left: 14px; top: 50%; transform: translateY(-52%); font: 400 24px/1 var(--serif); color: var(--ink-soft); pointer-events: none; }
.slip .money input { min-height: 64px; padding-left: 36px; font-size: 32px; }
.slip [aria-invalid="true"] { border-color: var(--debit); background-color: var(--debit-wash); }
.hint { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
.hint .num { font-size: 15px; }
.err {
  display: flex; gap: 6px; margin-top: 6px; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--debit);
}
.err::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%237a1f2b' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='M10 6.5v4.25M10 13.4v.1'/%3E%3C/svg%3E") center / contain no-repeat;
}
.when-date { margin-top: var(--s2); }
.slip-actions { display: flex; gap: var(--s2); margin-top: auto; padding-top: var(--s5); }
.slip-actions .btn-ink { flex: 1; min-height: 52px; font-size: 15px; }
.slip-actions .btn-quiet { min-height: 52px; }

/* Review: the transfer written out like a cheque */
.cheque {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--s3) var(--s4);
  padding: var(--s5) var(--s5) var(--s4);
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: var(--field);
  box-shadow: inset 0 0 0 3px var(--field), inset 0 0 0 4px var(--rule-mid);
}
.cheque-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; fill: none; stroke: var(--ink); stroke-width: .5; opacity: .2; }
.cheque-line { grid-column: 1 / -1; display: flex; align-items: baseline; gap: var(--s3); border-bottom: 1px solid var(--rule-mid); padding-bottom: 6px; }
.cheque-line span { font: italic 400 16px/1 var(--serif); color: var(--ink-soft); }
.cheque-line b { font: 500 22px/1.2 var(--serif); }
.cheque-words { font: italic 400 17px/1.35 var(--serif); text-wrap: pretty; min-height: 2.7em; }
.cheque-amount {
  padding: 4px 10px 3px; border: 1px solid var(--rule-strong); background: var(--field);
  font-size: 22px; line-height: 1.2;
}
.review { margin-top: var(--s4); }
.review > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 11px 0 10px; border-bottom: 1px solid var(--rule); }
.review dd { text-align: right; font-weight: 500; font-size: 14px; }
.review dd.num { font-size: 17px; font-weight: 400; }
#confirm { position: relative; }
.spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #f6f1e466; border-top-color: var(--paper); animation: spin .8s linear infinite; }
#confirm.is-busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(1turn); } }

.receipt { text-align: center; }
.receipt-seal { width: 116px; height: 116px; margin: var(--s2) auto 0; fill: none; stroke: var(--ink); stroke-width: .5; }
.receipt-seal .seal-tick { stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 0; }
.receipt h3 { margin-top: var(--s3); font-size: 32px; line-height: 1.1; }
.receipt-lede { margin: var(--s2) auto 0; max-width: 34ch; color: var(--ink-soft); text-wrap: balance; }
.receipt-lede b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.receipt .review { margin-top: var(--s5); border-top: 1px solid var(--rule-strong); text-align: left; }

/* ---------- 5. Components ----------
   The themed kit. Nothing here is drawn by the browser: every control is ruled, inked
   and set from the tokens at the top of this file, so it can be lifted out as a set.
   A. Pick list (replaces <select>)   B. Calendar (replaces the date input)
   C. Tooltip   D. Notices (toast and inline)   E. Confirmation dialog
   F. Radio   G. Switch
*/

/* A. Pick list: a button that opens a short ruled register. Options sit on hairlines,
   the chosen one is ticked in the margin, figures line up in a money column. */
.pick { position: relative; min-width: 0; }
.pick-btn {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; min-height: 44px; padding: 0 10px 0 12px;
  background: var(--sheet); border: 1px solid var(--rule-mid); border-radius: var(--r-sm);
  font-weight: 500; font-size: 14px; text-align: left; white-space: nowrap;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.pick-btn:hover, .is-open > .pick-btn { border-color: var(--ink); }
.pick-btn > .icon { color: var(--ink); transition: transform .3s var(--ease); }
.pick.is-open > .pick-btn > .icon { transform: rotate(180deg); }
.pick-value { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.pick-value .pick-label { overflow: hidden; text-overflow: ellipsis; }
.pick-value .pick-meta { color: var(--ink-soft); font-size: 16px; font-weight: 400; }
.pick-value.is-placeholder { color: var(--ink-soft); font-weight: 400; }

.pick-list, .cal {
  position: absolute; z-index: 15; left: 0; top: calc(100% + 6px);
  margin: 0; background: var(--field);
  border: 1px solid var(--rule-strong); border-top: 3px double var(--rule-strong); border-radius: 0 0 var(--r-sm) var(--r-sm);
  box-shadow: var(--pop-shadow);
  transform-origin: 50% 0;
}
.pick-list.is-up, .cal.is-up { top: auto; bottom: calc(100% + 6px); transform-origin: 50% 100%; }
.pick-list {
  min-width: max(100%, 256px); max-width: calc(100vw - 32px); max-height: 404px;
  padding: 0; overflow-y: auto; overscroll-behavior: contain;
}
.pick-list ul { margin: 0; padding: 0; }
.pick-group {
  display: block; padding: 11px 12px 5px;
  font: 600 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-strong);
}
.pick-opt {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  min-height: 44px; padding: 0 12px 0 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 14px; white-space: nowrap; cursor: pointer;
}
.pick-list > .pick-opt:last-child, .pick-list > li:last-child .pick-opt:last-child { border-bottom: 0; }
.pick-opt .icon { width: 16px; height: 16px; opacity: 0; }
.pick-opt[aria-selected="true"] { font-weight: 600; }
.pick-opt[aria-selected="true"] .icon { opacity: 1; }
.pick-opt .pick-label { display: flex; align-items: center; gap: 9px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pick-opt .pick-label i { width: 9px; height: 9px; flex: none; border-radius: 1px; background: var(--c); transform: rotate(45deg); }
.pick-opt .pick-meta {
  align-self: stretch; display: flex; align-items: center; justify-content: flex-end;
  width: var(--meta, 112px); padding-left: 12px; border-left: 1px solid var(--rule-red);
  font-size: 16px; font-weight: 400;
}
.pick-opt .pick-meta.is-text { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); }
/* the row under the pointer or the arrow keys is inked in */
.pick-opt.is-active { background: var(--ink); color: var(--paper); }
.pick-opt.is-active .pick-meta { border-left-color: #f6f1e459; color: var(--paper); }
.pick-opt.is-active .pick-label i { box-shadow: 0 0 0 1px var(--paper); }

/* B. Calendar: a month ruled like a diary page. Today is ringed in red, the chosen day is inked. */
.cal { width: min(340px, 100%); min-width: min(300px, calc(100vw - 40px)); padding: 10px 12px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.cal-title { font: 500 19px/1 var(--serif); font-variant-numeric: oldstyle-nums; }
.cal-grid { width: 100%; margin-top: 4px; border-collapse: collapse; table-layout: fixed; }
.cal-grid th {
  height: 28px; padding: 0; border-bottom: 1px solid var(--rule-strong);
  font: 600 11px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft);
}
.cal-grid td { padding: 0; border-bottom: 1px solid var(--rule); }
.cal-grid td:nth-child(n+6) { background: #173a2f0a; }   /* Saturday and Sunday */
.cal-day {
  display: block; width: 100%; height: 40px; padding: 0;
  background: none; border: 0; border-radius: 2px;
  font: 400 17px/1 var(--serif); font-variant-numeric: oldstyle-nums tabular-nums;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.cal-day:hover { background: #173a2f1f; }
.cal-day:focus-visible { outline-offset: -2px; }
.cal-day[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--debit); }
.cal-day[aria-disabled="true"] { color: #173a2f6b; cursor: default; }
.cal-day[aria-disabled="true"]:hover { background: none; }
.cal-day[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 500; }
.cal-day[aria-pressed="true"]:focus-visible { outline-color: var(--debit); }
.cal-foot { margin-top: 10px; font-size: 13px; line-height: 1.4; color: var(--ink-soft); text-wrap: pretty; }

/* C. Tooltip: a marginal note in the ledger hand. Shown on hover and on keyboard focus. */
.tip {
  position: fixed; z-index: 40; left: 0; top: 0; max-width: 240px;
  padding: 6px 11px 5px;
  background: var(--ink); color: var(--paper); border-radius: 2px;
  box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px #c8ab6266, 0 10px 18px -10px #0f2a22b3;
  font: italic 400 15px/1.3 var(--serif); font-variant-numeric: oldstyle-nums; white-space: nowrap;
  pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .18s var(--ease), transform .25s var(--ease);
}
.tip::after {
  content: ""; position: absolute; left: var(--ax, 50%); bottom: -4px; width: 9px; height: 9px;
  background: var(--ink); transform: translateX(-50%) rotate(45deg);
}
.tip.is-below { transform: translateY(-4px); }
.tip.is-below::after { bottom: auto; top: -4px; }
.tip.is-on { opacity: 1; transform: none; }

/* D. Notices. The toast is an advice note stamped with the seal; .notice is its inline form. */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; margin: 0;
  display: flex; align-items: center; gap: 12px;
  width: max-content; max-width: min(500px, calc(100vw - 32px)); padding: 13px 20px 13px 14px;
  background: var(--ink); color: var(--paper); border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 4px #c8ab6273, 0 16px 28px -14px #0f2a22cc;
  font-size: 14px; font-weight: 500; line-height: 1.4; text-wrap: pretty;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: transform .45s var(--ease), opacity .3s var(--ease);
}
.toast::before { content: ""; flex: none; width: 28px; height: 28px; background: url("assets/seal.svg") center / contain no-repeat; }
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.notice {
  display: flex; gap: var(--s2); margin-top: var(--s4); padding: 12px 14px;
  border: 1px solid var(--rule-red); border-radius: var(--r-sm);
  background: var(--debit-wash); color: var(--debit);
  font-size: 13px; font-weight: 500; line-height: 1.45;
}
.notice .icon { margin-top: -1px; }

/* E. Confirmation dialog: a stop notice laid over the page. What is at stake is ruled out in the middle. */
.stop {
  width: min(440px, calc(100vw - 32px)); max-width: none; padding: 0;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 3px var(--sheet), inset 0 0 0 4px var(--rule-mid), 0 34px 54px -26px #0f2a22cc;
  opacity: 0; transform: translateY(12px) scale(.97);
  transition: transform .4s var(--ease), opacity .25s var(--ease), overlay .4s allow-discrete, display .4s allow-discrete;
}
.stop[open] { opacity: 1; transform: none; }
@starting-style { .stop[open] { opacity: 0; transform: translateY(12px) scale(.97); } }
.stop-inner { padding: 30px 30px 26px; }
.stop h2 { font-size: 27px; line-height: 1.15; }
.stop-text { margin-top: var(--s2); color: var(--ink-soft); text-wrap: pretty; }
.stop-item {
  position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4);
  margin-top: var(--s4); padding: 11px 0 10px;
  border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
  font: 500 19px/1.25 var(--serif);
}
.stop-item .num { white-space: nowrap; }
.stop-item::after {            /* the entry is struck through in red, as a clerk voids a line */
  content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: 1px;
  background: var(--debit); transform: rotate(-1.2deg);
}
.stop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); }
.btn-debit { background: var(--debit); color: var(--paper); }
.btn-debit:hover { background: #631722; }

/* Backdrops for both dialogs: green ink, hatched like the shading of an engraving */
.slip::backdrop, .stop::backdrop {
  background: repeating-linear-gradient(135deg, #0f2a2226 0 1px, #0f2a2200 1px 6px) #0f2a228c;
  opacity: 0;
  transition: opacity .4s var(--ease), overlay .4s allow-discrete, display .4s allow-discrete;
}
.slip[open]::backdrop, .stop[open]::backdrop { opacity: 1; }
@starting-style { .slip[open]::backdrop, .stop[open]::backdrop { opacity: 0; } }

/* F. Radio: the real input, redrawn as an inked ring */
.radio, .field > label.radio { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-size: 15px; font-weight: 400; cursor: pointer; }
.radio:has(:checked) { font-weight: 500; }
.radio input {
  appearance: none; -webkit-appearance: none; flex: none;
  display: grid; place-content: center; width: 20px; height: 20px; margin: 0;
  background: var(--field); border: 1px solid var(--ink); border-radius: 50%;
}
.radio input:hover { background: var(--paper-deep); }
.radio input::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); transform: scale(0); transition: transform .25s var(--ease); }
.radio input:checked::before { transform: scale(1); }
.radio input:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 50%; }
.radio input:disabled { border-color: var(--rule-mid); background: var(--paper-deep); cursor: default; }
.radio input:disabled::before { background: var(--ink-soft); }

/* G. Switch: a button with role="switch" */
.switch {
  position: relative; flex: none; width: 60px; height: 44px; padding: 0; border: 0; background: none;
}
.switch::before {
  content: ""; position: absolute; inset: 7px 0; border-radius: 15px;
  background: var(--paper-deep); border: 1px solid var(--rule-strong);
  transition: background-color .3s var(--ease);
}
.switch-knob {
  position: absolute; left: 4px; top: 11px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  transition: transform .35s var(--ease), background-color .3s var(--ease);
}
.switch-knob .icon { width: 14px; height: 14px; opacity: 0; transition: opacity .2s; }
.switch[aria-checked="true"]::before { background: var(--debit); border-color: var(--debit); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(30px); background: var(--sheet); color: var(--debit); }
.switch[aria-checked="true"] .switch-knob .icon { opacity: 1; }
.switch[disabled] { opacity: .5; cursor: default; }

/* Motion: authored only where it helps, off when the reader asks */
@media (prefers-reduced-motion: no-preference) {
  .receipt:not([hidden]) .seal-tick { animation: tick .7s var(--ease) .15s backwards; }
  .receipt:not([hidden]) .receipt-seal { animation: stamp .6s var(--ease) backwards; }
  .register tbody.is-turning { animation: turn .45s var(--ease); }
  .pick-list:not([hidden]), .cal:not([hidden]) { animation: unroll .24s var(--ease); }
}
@keyframes unroll { from { opacity: 0; transform: translateY(-6px) scaleY(.94); } }
@keyframes tick { from { stroke-dashoffset: 40; } }
@keyframes stamp { from { transform: scale(1.25) rotate(-12deg); opacity: 0; } }
@keyframes turn { from { opacity: .25; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}

/* ---------- 6. Responsive ---------- */
@media screen and (max-width: 1180px) {
  .who { display: none; }
}
/* Where the main page is narrow, the category moves under the payee.
   The column is squeezed to nothing rather than removed, so colspans still add up. */
@media screen and (max-width: 960px), screen and (min-width: 1101px) and (max-width: 1180px) {
  .register th.c-cat, .register td.c-cat { width: 0; padding: 0; overflow: hidden; font-size: 0; }
  .register .c-cat .cat { display: none; }
  .sub .sub-cat { display: inline; }
  .register .c-out, .register .c-in, .register .c-bal { width: 106px; }
  .register .c-date { width: 76px; }
  .detail { padding-left: 88px; }
  .register-block { --money: 106px; --lead: 88px; }
}

@media screen and (max-width: 900px) {
  .primary { display: none; }
  .masthead-end { margin-left: auto; }
}

@media screen and (max-width: 1100px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .page-side {
    border-left: 0; border-top: 3px double var(--rule-mid); background: none;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s6) var(--pad);
    padding: var(--pad);
  }
  .side-block + .side-block { margin-top: 0; padding-top: 0; border-top: 0; }
}

@media screen and (max-width: 720px) {
  .masthead-row { padding-block: 12px 16px; gap: var(--s3); }
  .seal { width: 34px; height: 34px; }
  .wordmark-name { font-size: 21px; }
  .btn-cream { padding-inline: 14px; }
  .btn-cream span { display: none; }
  .btn-cream::after { content: "Transfer"; }

  .wrap { padding-inline: 0; }
  .masthead .wrap { padding-inline: 16px; }
  .tabs { gap: 4px; }
  .tab { flex: 1; min-width: 0; padding: 9px 12px 10px; }
  .tab[aria-selected="true"] { padding-top: 12px; }
  .tab-bal { font-size: 14px; }

  .sheet { border-inline: 0; }
  .page-main, .page-side { padding: 24px 16px 32px; }
  .page-side { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
  .side-block + .side-block { padding-top: var(--s5); border-top: 1px solid var(--rule-mid); }

  .balance-head h1 { font-size: 28px; }
  .acct-id { font-size: 15px; gap: var(--s3); }
  .acct-id span + span { padding-left: var(--s3); }
  .band { height: 148px; margin-inline: -16px; padding-inline: 16px; }
  .figure { font-size: clamp(2.7rem, 13.6vw, 4rem); padding-inline: .2em .24em; }

  .register-block { margin-top: var(--s6); }
  .register-head { flex-wrap: wrap; gap: var(--s2) var(--s3); }
  .register-head h2 { font-size: 24px; }
  #print-btn { padding: 0; width: 44px; }
  #print-btn span { display: none; }
  .month-label { min-width: 112px; font-size: 16px; }

  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div { padding: 10px 12px 9px; }
  .summary > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .summary > div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .summary dd { font-size: 20px; }

  .filters { flex-wrap: wrap; }
  .field-inline > span { display: none; }
  .field-inline, .field-inline .pick { flex: 1; min-width: 0; }
  .field-inline .pick-btn { min-width: 0; }
  .search { flex: 1 1 100%; max-width: none; order: -1; }
  .search kbd { display: none; }
  .search input { font-size: 16px; }
  .count { margin-left: 0; }

  /* The register becomes a two-line entry list; the table markup is unchanged */
  .register, .register tbody, .register tr, .register td { display: block; }
  .register thead { display: block; }
  .register thead tr { display: flex; justify-content: space-between; border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
  .register th { border: 0; padding: 4px 0; }
  .register th:not(.c-date):not(.c-bal) { display: none; }
  .register th.c-bal { width: auto; align-self: center; }
  .register th.c-bal::before { content: "Amount and "; }
  .register td { height: auto; padding: 0; border: 0; width: auto; }
  .register .c-out, .register .c-in, .register .c-bal, .register .carry:last-child td { border: 0; }
  .register tr.entry {
    display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; grid-template-rows: auto auto;
    column-gap: 8px; align-items: center; padding: 9px 16px 8px; margin-inline: -16px; border-bottom: 1px solid var(--rule);
  }
  .register .entry .c-date { grid-area: 1 / 1 / 3 / 2; width: auto; padding: 0; font-size: 15px; }
  .register .entry .c-details { grid-area: 1 / 2 / 3 / 3; min-width: 0; }
  .register .entry .c-cat { display: none; }
  .register .c-date, .register .c-out, .register .c-in, .register .c-bal { width: auto; }
  .register .entry .c-out, .register .entry .c-in { grid-area: 1 / 3; width: auto; border: 0; font-size: 18px; line-height: 1.2; }
  .register .entry .c-in { color: var(--cat-income); }
  .register .entry .c-in:not(:empty)::before { content: "+"; }
  .register .entry td:empty { display: none; }
  .register .entry .c-bal { grid-area: 2 / 3; width: auto; border: 0; font-size: 14px; font-weight: 400; color: var(--ink-soft); line-height: 1.2; }
  .entry-toggle { min-height: 44px; }
  .entry-toggle .icon { display: none; }
  .sub .sub-cat { display: inline; }
  .register tr.entry-detail { margin-inline: -16px; padding-inline: 16px; border-bottom: 1px solid var(--rule-mid); background: #173a2f0b; }
  .register .entry-detail td { background: none; border: 0; }
  .detail { grid-template-columns: 1fr; padding: 12px 0 16px 62px; }
  .detail dl { grid-template-columns: auto minmax(0, 1fr); }
  .register tr.carry { display: flex; justify-content: space-between; align-items: center; min-height: 44px; border-bottom: 1px solid var(--rule); }
  .register tr.carry:last-child { border-bottom: 2px solid var(--rule-strong); }
  .register tr.carry td { font-size: 16px; }
  .register tr.carry .c-date, .register tr.carry td:empty { display: none; }

  .colophon { padding-inline: 16px; }
  .slip { border-left: 0; }
  .slip-actions { flex-wrap: wrap; }
  .slip-actions .btn { flex: 1 1 100%; }
  .stop-inner { padding: 26px 22px 22px; }
  .stop-actions .btn { flex: 1 1 100%; min-height: 48px; }
  .toast { bottom: 16px; }
}

@media screen and (max-width: 380px) {
  .month { order: 3; flex: 1 1 100%; }
  .month-label { flex: 1; }
}

/* ---------- Print: the register as a clean statement ---------- */
@media print {
  @page { margin: 16mm 14mm; }
  html, body { background: #fff; }
  body { font-size: 10.5pt; color: #000; }
  .masthead, .page-side, .balance, .filters, .month .icon-btn, #print-btn, .colophon, .slip, .stop, .tip, .toast,
  .skip, .entry-detail, .entry-toggle .icon, .empty, .sub, .ruled-off, body > a[aria-label*="Screenery"] { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .sheet { display: block; border: 0; box-shadow: none; background: none; }
  .page-main { display: block; padding: 0; }
  .register-block { display: block; margin: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12mm; padding-bottom: 4mm; border-bottom: 2pt solid #000; margin-bottom: 5mm; }
  .print-bank { font: 500 20pt/1.1 var(--serif); }
  .print-bank span { display: block; margin-top: 1.5mm; font: 400 9pt/1.3 var(--sans); }
  .print-acct { text-align: right; font: 400 10pt/1.4 var(--serif); font-variant-numeric: oldstyle-nums; }
  .register-head h2 { font-size: 15pt; }
  .register-head h2::after { content: " of entries"; }
  .month { border: 0; }
  .month-label { min-width: 0; font-size: 13pt; }
  .summary { border-color: #000; margin-top: 3mm; }
  .summary dt { color: #000; font-size: 8.5pt; }
  .summary dd { font-size: 13pt; }
  .register { font-size: 10pt; }
  .register thead { display: table-header-group; }
  .register th { color: #000; border-color: #000; font-size: 8pt; padding: 2mm; }
  /* Chrome leaves a button out of the header it repeats on later pages, so the label is printed as text */
  .register th button { display: none; }
  .register th.c-date::after { content: "Date"; }
  .register td { height: auto; padding: 1.6mm 2mm; border-bottom: .5pt solid #999; }
  .register td.c-date, .register td.c-out, .register td.c-in, .register td.c-bal { font-size: 10.5pt; color: #000; }
  .register td.c-out { color: var(--debit); }
  .register th.c-cat, .register td.c-cat { display: table-cell; width: 30mm; padding: 1.6mm 2mm; font-size: 10pt; overflow: visible; }
  .register th.c-cat { padding: 2mm; font-size: 8pt; }
  .register .c-cat .cat { display: inline-flex; font-size: 10pt; gap: 2mm; }
  .cat i { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .register .c-out, .register .c-in, .register .c-bal { border-left: .5pt solid #999; width: 26mm; }
  .entry-toggle { min-height: 0; }
  .entry, .carry { break-inside: avoid; background: none !important; }
  .carry td { color: #000; font-size: 10.5pt; }
  .register-block::after {
    content: "Ledger & Lane is a fictional bank. This statement was produced by the Screenery ledger template.";
    display: block; margin-top: 6mm; font-size: 8pt;
  }
}
