:root {
  --bg: #e9edf2; --panel: #f7f9fb; --paper: #fffef9; --ink: #11161d; --muted: #4a5666;
  --rule: #d5dce5; --line: #e8e3d2; --accent: #0a6a62; --accent-ink: #ffffff; --accent-soft: #d6eeea;
  --key: #ffffff; --key-edge: #b9c3d0; --key-ink: #11161d; --neg: #b3261e; --focus: #1a56db;
  --shadow: 0 1px 2px rgba(17, 22, 29, .12), 0 6px 18px rgba(17, 22, 29, .08);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
  /* the four desk surfaces (Settings, Desk): CSS gradients only. Walnut is the Classic desk exactly as it was before the choice existed. */
  --desk-walnut: radial-gradient(ellipse at 50% 30%, rgba(255, 220, 170, .10), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 2px, rgba(255, 255, 255, .012) 2px 7px, rgba(0, 0, 0, .04) 7px 9px),
    linear-gradient(180deg, #4a3829, #3a2b1f);
  --desk-oak: radial-gradient(ellipse at 50% 30%, rgba(255, 244, 218, .30), transparent 70%),
    repeating-linear-gradient(90deg, rgba(110, 70, 30, .11) 0 2px, rgba(255, 240, 200, .07) 2px 8px, rgba(110, 70, 30, .06) 8px 11px),
    linear-gradient(180deg, #dcb47c, #c9a066);
  --desk-blotter: radial-gradient(ellipse at 50% 35%, rgba(130, 180, 140, .16), transparent 72%),
    repeating-radial-gradient(circle at 30% 40%, rgba(255, 255, 255, .04) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 72% 62%, rgba(0, 0, 0, .12) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #264b38, #1b3a2a);
  --desk-slate: radial-gradient(ellipse at 50% 25%, rgba(255, 255, 255, .10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, rgba(0, 0, 0, .035) 1px 3px),
    linear-gradient(180deg, #59636d, #49525b);
}
:root[data-theme="dark"] {
  --bg: #0e1217; --panel: #171d25; --paper: #1b222c; --ink: #edf1f6; --muted: #aab6c5;
  --rule: #2c3643; --line: #2a3340; --accent: #4fd1c1; --accent-ink: #06201c; --accent-soft: #173a36;
  --key: #232c38; --key-edge: #3a4656; --key-ink: #edf1f6; --neg: #ff8f86; --focus: #8ab4ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); }

/* top bar: logo, tape name, and two menu buttons (Tapes, Settings). Nothing else. */
.bar { display: flex; align-items: center; gap: 6px 10px; padding: 5px 12px; background: var(--panel); border-bottom: 1px solid var(--rule); position: relative; z-index: 30; }
.logo { margin: 0; font-size: 20px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; flex: none; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: 700 22px/1 var(--mono); }
.namebtn { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; font-size: 18px; font-weight: 600; max-width: 32ch; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.namebtn:hover { border-color: var(--rule); }
.save-state { color: var(--muted); font-size: 13px; min-width: 5ch; }
.save-state:empty { display: none; }
.row.tax .note { color: var(--accent); font-weight: 600; }
.bar-menus { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu { position: relative; }
.menu-btn, .menu-pop button, .pbtn { background: var(--key); border: 1px solid var(--key-edge); border-radius: 8px; cursor: pointer; color: var(--key-ink); }
.menu-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 4px 12px; font-size: 16px; font-weight: 700; white-space: nowrap; border-bottom-width: 3px; }
.menu-btn .chev { transition: transform .12s; }
.menu-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.menu-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 310px; max-height: calc(100dvh - 70px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--panel); border: 1px solid var(--key-edge); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.menu-pop[hidden] { display: none; }
.menu-pop button { display: block; width: 100%; text-align: left; min-height: 44px; padding: 8px 12px; font-size: 16px; font-weight: 500; background: transparent; border-color: transparent; border-radius: 8px; }
.menu-pop button:hover { background: var(--accent-soft); border-color: var(--accent); }
.menu-pop .taxset { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; min-height: 44px; font-size: 16px; color: var(--ink); }
.taxset input { width: 8ch; min-height: 38px; text-align: right; border: 1px solid var(--key-edge); border-radius: 8px; background: var(--paper); padding: 2px 8px; font: 16px var(--mono); }
.theme-set { display: flex; align-items: center; gap: 0; padding: 6px 12px; flex-wrap: wrap; }
.theme-name { font-size: 16px; margin-right: 12px; }
.tpos { position: relative; display: block; }
.tpos input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tpos > span { display: block; padding: 6px 10px; min-height: 38px; line-height: 24px; font-size: 15px; font-weight: 600; background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge); border-left-width: 0; cursor: pointer; }
.tpos:first-of-type > span { border-left-width: 1px; border-radius: 8px 0 0 8px; }
.tpos:last-of-type > span { border-radius: 0 8px 8px 0; }
.tpos input:checked + span { background: var(--accent); color: var(--accent-ink); }
.tpos input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; position: relative; z-index: 1; }
.bar button:hover, dialog button:hover, .pbtn:hover:not(:disabled) { border-color: var(--accent); }
dialog button { background: var(--key); border: 1px solid var(--key-edge); border-radius: 8px; padding: 9px 10px; min-height: 44px; cursor: pointer; color: var(--key-ink); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* buttons on the paper: Undo and Redo pinned at the top, Print tape, Copy and Save as CSV at the foot */
.pbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 4px 14px; font-size: 16px; font-weight: 700; white-space: nowrap; border-bottom-width: 3px; }
.pbtn .ico { flex: none; }
.pbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pbtn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.tape-top { display: flex; gap: 8px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); flex: none; position: relative; z-index: 2; }
.tape-top .pbtn { min-height: 36px; padding: 2px 12px; }
.more { display: inline; }

/* layout */
.app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); gap: 16px; padding: 14px 16px; }
.tape-panel { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.app > .side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding: 2px; }
.bridge { display: none; }

/* tape */
.tape { --tape-pt: 8px; flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; font: 22px/1.25 var(--mono); font-variant-numeric: tabular-nums; overscroll-behavior: contain;
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 36px; background-position: 0 35px; background-attachment: local; }
.tape:not(:has(.row))::before { content: "Type a number, then press + or Enter."; display: block; padding: 24px; color: var(--muted); font: 18px var(--sans); }
.row { display: grid; grid-template-columns: 5ch 2ch minmax(8ch, 1fr) minmax(10ch, 1.1fr) minmax(0, 1.2fr); column-gap: 14px; align-items: center; min-height: 36px; padding: 0 16px; cursor: pointer;
  content-visibility: auto; contain-intrinsic-size: auto 36px; }
.row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .n { color: var(--muted); font-size: 15px; text-align: right; }
.row .op { text-align: center; color: var(--accent); font-weight: 700; }
.row .amt, .row .run { text-align: right; }
.row .run { color: var(--muted); }
.row .note { font: 16px var(--sans); color: var(--muted); align-self: stretch; min-height: 36px; line-height: 36px; }
.row.editing .note { line-height: normal; min-height: 0; align-self: center; }
.row.side { background: color-mix(in srgb, var(--accent) 6%, transparent); border-left: 4px solid var(--accent); padding-left: 12px; }
.row.side .amt { color: var(--ink); }
.row.ref { color: var(--muted); font-style: italic; }
.row.ref .op { color: var(--muted); }
.row.result { font-weight: 700; border-top: 1px solid var(--ink); }
.row.marker { font-weight: 700; border-top: 2px solid var(--ink); content-visibility: visible; }
.row.marker .run { color: var(--ink); }
.row.marker .amt { font-size: 15px; letter-spacing: 1px; color: var(--muted); }
.neg { color: var(--neg) !important; }
.row.err .run::after { content: " ?"; color: var(--neg); }
.row.editing { grid-template-columns: 5ch 12ch minmax(10ch, 1fr) minmax(10ch, 1fr) minmax(0, 1.2fr); background: var(--accent-soft); cursor: default; padding-top: 6px; padding-bottom: 6px; content-visibility: visible; }
.row.editing input, .row.editing select { color: var(--ink); width: 100%; min-height: 40px; background: var(--paper); border: 2px solid var(--key-edge); border-radius: 6px; padding: 2px 8px; font: inherit; }
.row.editing .note input { font: 16px var(--sans); }
.row.editing .e-amt { text-align: right; }
.row.editing input[aria-invalid="true"] { border-color: var(--neg); }
.row .acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.row .acts button { background: var(--key); border: 1px solid var(--key-edge); border-radius: 8px; min-height: 40px; padding: 4px 10px; cursor: pointer; font: 14px var(--sans); } /* five buttons since Tick and Circle: the Classic paper is 450px and the editor row is already wider than it */
.row .acts button:hover { border-color: var(--accent); }
.tape-foot { display: flex; flex-direction: column; gap: 10px; padding: 10px 16px 12px; border-top: 3px double var(--ink); background: var(--paper); flex: none; }
.foot-info { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.foot-actions { display: flex; gap: 8px; position: relative; }
.print-pop { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 40; min-width: 250px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--panel); border: 1px solid var(--key-edge); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.print-pop[hidden] { display: none; }
.print-pop button { display: block; width: 100%; text-align: left; min-height: 44px; padding: 8px 12px; font-size: 16px; font-weight: 500; background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; color: var(--ink); }
.print-pop button:hover { background: var(--accent-soft); border-color: var(--accent); }
.print-sel-note { display: none; }
.foot-actions .pbtn { flex: 1 1 auto; min-width: 0; padding: 4px 10px; gap: 6px; }
.foot-actions .pbtn.primary { flex-grow: 1.3; font-size: 17px; }
.count { color: var(--muted); font-size: 18px; min-width: 0; }
.total-wrap { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.total-label { color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: 1px; }
.total { font: 700 38px/1.1 var(--mono); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.print-head { display: none; }

.row.marker { align-content: center; }
/* a line whose typed amount differs from the rounded amount it carries: a small approximately-equal mark before the figure */
.row.rnd .amt::before { content: "\2248"; font-size: .62em; margin-right: .35em; color: var(--muted); vertical-align: .15em; }
/* a break ends the sum: a dashed line across the paper, no running total */
.row { user-select: none; -webkit-user-select: none; }
.row.editing { user-select: auto; -webkit-user-select: auto; }
/* selected lines (click, Shift+click, Ctrl or Cmd+click) */
.row.sel:not(.editing) { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
.sel-info { display: block; width: fit-content; max-width: 100%; margin-top: 4px; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--ink); font-weight: 600; line-height: 1.3; text-wrap: balance; }
.sel-info[hidden] { display: none; }
:root[data-theme="classic"] .sel-info { font-size: 14px; }
.row.brk { border-top: 2px dashed var(--ink); border-bottom: 2px dashed transparent; min-height: 22px; font-weight: 400; }
.row.brk .amt { grid-column: 2 / -1; order: 2; text-align: center; font-size: 12px; letter-spacing: 6px; color: var(--muted); }
.row.brk .op, .row.brk .run, .row.brk .note { display: none; }
/* a feed line is blank paper: an empty row of normal height (the line number stays, as on a break), no text */
.row.feed:not(.editing) .op, .row.feed:not(.editing) .amt, .row.feed:not(.editing) .run, .row.feed:not(.editing) .note { visibility: hidden; }

/* the machine body: plain in Modern and Dark, a desk machine in Classic */
.machine { display: flex; flex-direction: column; gap: 8px; }
.housing, .well, .disp-total { display: none; }
.indicators { display: none; }
.badge { font: 700 13px var(--sans); }
/* the machine switches: plain segmented controls here, slide switches in Classic */
.switches { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 6px 4px; }
.sw { display: flex; flex-wrap: wrap; align-items: center; position: relative; }
.sw-name { font: 600 12px var(--sans); color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .5px; }
.sw .pos { position: relative; display: block; }
.sw .pos input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw .pos > span { display: block; padding: 4px 9px; min-height: 32px; line-height: 24px; font: 600 14px var(--sans); background: var(--key); color: var(--key-ink); border: 1px solid var(--key-edge); border-left-width: 0; cursor: pointer; }
.sw .pos:first-of-type > span { border-left-width: 1px; border-radius: 8px 0 0 8px; }
.sw .pos:last-of-type > span { border-radius: 0 8px 8px 0; }
.sw .pos:first-of-type:last-of-type > span { border-radius: 8px; }
.sw .pos input:checked + span { background: var(--accent); color: var(--accent-ink); }
.sw .pos input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; position: relative; z-index: 1; }
.sw-track { display: none; }
/* entry */
.entry-box { position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 6px 16px 8px; box-shadow: var(--shadow); }
.note-line { position: absolute; left: 16px; right: 16px; top: 8px; min-height: 26px; padding: 2px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font: 600 16px/22px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-line[hidden] { display: none; }
.hint { min-height: 18px; font-size: 15px; color: var(--neg); font-weight: 600; }
.entry { min-height: 52px; display: flex; align-items: center; justify-content: flex-end; font: 600 40px/1.1 var(--mono); font-variant-numeric: tabular-nums; overflow: hidden; border-radius: 8px; }
.entry::after { content: ""; width: 3px; height: 1em; margin-left: 3px; background: var(--accent); animation: blink 1.1s steps(2, start) infinite; }
.entry-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-text:empty::before { content: "0"; color: var(--muted); }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .entry::after { animation: none; } }

/* keypad: a desk ten-key arrangement, six columns: function columns, digits, right column; memory keys in their own row */
.keypad { display: grid; grid-template-columns: repeat(6, 1fr); grid-template-areas:
  "nt rf m1 m2 m3 m4"
  "tp tm n7 n8 n9 bs"
  "pc dv n4 n5 n6 ce"
  "ml eq n1 n2 n3 mn"
  "gt sb n0 n00 dt ad"
  "tt tt fd fd fd ad";
  grid-auto-rows: clamp(38px, 5.9vh, 62px); gap: 6px; }
.keypad [data-digit="7"] { grid-area: n7; } .keypad [data-digit="8"] { grid-area: n8; } .keypad [data-digit="9"] { grid-area: n9; }
.keypad [data-digit="4"] { grid-area: n4; } .keypad [data-digit="5"] { grid-area: n5; } .keypad [data-digit="6"] { grid-area: n6; }
.keypad [data-digit="1"] { grid-area: n1; } .keypad [data-digit="2"] { grid-area: n2; } .keypad [data-digit="3"] { grid-area: n3; }
.keypad [data-digit="0"] { grid-area: n0; } .keypad [data-act="00"] { grid-area: n00; } .keypad [data-act="dot"] { grid-area: dt; }
.keypad [data-act="eq"] { grid-area: eq; }
.keypad [data-act="note"] { grid-area: nt; } .keypad [data-act="pct"] { grid-area: pc; }
.keypad [data-act="gt"] { grid-area: gt; } .keypad [data-act="ref"] { grid-area: rf; }
.keypad [data-act="tax+"] { grid-area: tp; } .keypad [data-act="tax-"] { grid-area: tm; }
.keypad [data-act="S"] { grid-area: sb; } .keypad [data-act="T"] { grid-area: tt; } .keypad [data-act="feed"] { grid-area: fd; }
.keypad [data-act="mem+"] { grid-area: m1; } .keypad [data-act="mem-"] { grid-area: m2; } .keypad [data-act="memsub"] { grid-area: m3; } .keypad [data-act="memtot"] { grid-area: m4; }
.keypad [data-act="clearEntry"] { grid-area: ce; } .keypad [data-act="backspace"] { grid-area: bs; }
.keypad [data-act="/"] { grid-area: dv; } .keypad [data-act="*"] { grid-area: ml; } .keypad [data-act="-"] { grid-area: mn; }
.keypad [data-act="+"] { grid-area: ad; }
.key { min-height: 30px; min-width: 40px; border-radius: 10px; border: 1px solid var(--key-edge); border-bottom-width: 4px; background: var(--key); color: var(--key-ink); font: 600 24px var(--mono); cursor: pointer; user-select: none; touch-action: manipulation; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.key small { font: 600 10px var(--sans); color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.key:active, .key.down { transform: translateY(2px); border-bottom-width: 2px; }
.key.fn { background: var(--panel); font-size: 17px; }
.key .sym { font-size: 20px; line-height: 1; }
.key.op { color: var(--accent); }
.key.add, .key.tot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.key.add small, .key.tot small { color: inherit; }
.key.add { font-size: 30px; }
.etag { display: none; }
[data-enter="add"] .key.add .etag, [data-enter="total"] .key.tot .etag { display: block; } /* AUTO sits the legend on the plus key too */

/* dialogs and toast */
dialog { border: 1px solid var(--rule); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 20px 22px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
dialog::backdrop { background: rgba(8, 12, 18, .55); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog label { display: block; font-weight: 600; margin: 8px 0 4px; }
dialog input[type="text"], dialog textarea { width: 100%; padding: 10px; border: 2px solid var(--key-edge); border-radius: 8px; background: var(--paper); font: 18px var(--mono); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.tape-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; display: grid; gap: 8px; }
.tape-list li { display: flex; gap: 8px; align-items: stretch; }
.tape-list .open { flex: 1; text-align: left; display: flex; flex-direction: column; }
.tape-list .open small { color: var(--muted); }
.tape-list li.current .open { border-color: var(--accent); border-width: 2px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 60; max-width: calc(100vw - 24px); }


.keys-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.keys-dialog dl { margin: 6px 0 4px; display: grid; gap: 6px; }
.keys-dialog dl > div { display: grid; grid-template-columns: 13ch 1fr; gap: 10px; font-size: 15px; }
.keys-dialog dt { font: 600 14px var(--mono); }
.keys-dialog dd { margin: 0; color: var(--muted); }




/* Tick and tie: marks in the margin of the tape, and the dialog's extras */
.row { position: relative; }
/* 16px marks, 2px stroke, inset 6px from the paper edge, centred on the amount line (the first 36px, or the 32px rows of Classic and the phone). A marked row moves its line number 6px right into the column gap, so the two never touch. */
.tie-mark { position: absolute; left: 6px; top: 0; width: 16px; height: 36px; display: flex; align-items: center; line-height: 0; pointer-events: none; }
.tie-mark svg { display: block; width: 16px; height: 16px; }
.row.mk .n { margin-right: -6px; }
:root[data-theme="classic"] .tie-mark { height: 32px; }
@media (max-width: 700px) { .tie-mark, :root[data-theme="classic"] .tie-mark { height: 32px; } }
.tie-mark[data-k="ok"] { color: var(--accent); }
.tie-mark[data-k="extra"] { color: var(--neg); }
.tie-dialog textarea { resize: vertical; min-height: 5.5em; max-height: 40vh; font-size: 16px; }
.tie-dialog label.tie-check { display: flex; align-items: center; gap: 10px; min-height: 32px; margin: 8px 0 0; }
.tie-dialog .tie-check input { width: 22px; height: 22px; margin: 0; flex: none; }
.tie-go { margin: 6px 0 4px; }
.tie-go button { min-width: 8em; }
.tie-dialog button[hidden], .tie-dialog p[hidden], .tie-dialog dl[hidden], .tie-dialog h3[hidden] { display: none; }
.tie-ok { color: var(--accent); }
.diff-causes li.tie-more { color: var(--muted); padding: 2px 4px; }

/* Find the difference: the note under the paper (Off by 9.00 / Foots) and its dialog */
.diff-info { display: inline-block; margin-left: 8px; padding: 0 8px; min-height: 0; border: 1px solid currentColor; border-radius: 6px; background: transparent; font: 600 14px/1.4 var(--sans); cursor: pointer; vertical-align: baseline; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.diff-info[hidden] { display: none; }
.diff-info.off { color: var(--neg); }
.diff-info.ok { color: var(--accent); }
/* Balanced (the tape foots to the expected total, with at least one amount line under it): green ink and a bell drawn in SVG. The bell swings for 600 ms when the tape comes into balance (class ring) and never under prefers-reduced-motion. */
.diff-info.bal:not([hidden]) { display: inline-flex; align-items: center; gap: 5px; color: var(--ok); }
.diff-info.idle { color: var(--muted); }
.diff-info .bell { flex: none; transform-origin: 50% 3px; }
.diff-info.ring .bell { animation: bell-swing 600ms ease-in-out 1; }
@keyframes bell-swing { 0% { transform: rotate(0); } 15% { transform: rotate(22deg); } 35% { transform: rotate(-18deg); } 55% { transform: rotate(12deg); } 75% { transform: rotate(-6deg); } 100% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .diff-info.ring .bell { animation: none; } }
.diff-info:hover { background: var(--accent-soft); }
.diff-dialog { max-height: calc(100dvh - 40px); overflow-y: auto; overflow-x: hidden; }
.diff-dialog p { margin: 0 0 6px; overflow-wrap: anywhere; }
.diff-msg { min-height: 1.4em; color: var(--neg); font-weight: 600; }
.diff-msg:empty { min-height: 0; }
.diff-summary { margin: 8px 0 4px; display: grid; gap: 4px; }
.diff-summary[hidden], .diff-h[hidden], .diff-verdict[hidden] { display: none; }
.diff-summary > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; border-bottom: 1px solid var(--rule); padding: 2px 0; }
.diff-summary dt { color: var(--muted); }
.diff-summary dd { margin: 0; font: 700 18px var(--mono); text-align: right; overflow-wrap: anywhere; }
.diff-verdict { font-weight: 600; margin-top: 6px; }
.diff-h { margin: 12px 0 4px; font-size: 16px; }
.diff-causes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.diff-causes li { overflow-wrap: anywhere; }
.diff-causes li:not(:has(> button)) { color: var(--muted); padding: 2px 4px; }
.diff-cause { display: block; width: 100%; text-align: left; font: 15px/1.35 var(--sans); white-space: normal; }
.diff-dialog .dlg-actions { flex-wrap: wrap; }
@media (max-width: 700px) {
  /* a phone: the chip sits beside the item count, and drops to its own line under a long selection line instead of squeezing it */
  .count, :root[data-theme="classic"] .count { flex-wrap: wrap; row-gap: 2px; }
  .count > #count { flex: none; }
  .diff-info { margin-left: 0; padding: 0 6px; font-size: 12px; flex: 0 1 auto; min-width: 0; }
  .count > .sel-info { flex: 0 1 auto; }
  /* both chips (Off by, Tied): the item count and the Tied chip share the first line, Off by takes the second, and the lines are tight, so the paper keeps 3 full rows on a 360x740 phone */
  .count:has(> #diffInfo:not([hidden])):has(> #tieInfo:not([hidden])) { row-gap: 1px; line-height: 1.1; }
  .count:has(> #diffInfo:not([hidden])):has(> #tieInfo:not([hidden])) > .diff-info { line-height: 1.1; }
  .count:has(> #diffInfo:not([hidden])):has(> #tieInfo:not([hidden])) > #tieInfo { order: 1; }
  .count:has(> #diffInfo:not([hidden])):has(> #tieInfo:not([hidden])) > #diffInfo { order: 2; }
}

/* ================= Classic theme (the default): a desk printing adding machine on a desk, with its paper tape ================= */
:root[data-theme="classic"] {
  --bg: #3f3125; --panel: #dcd7c7; --paper: #fdfcf7; --ink: #14171a; --muted: #565a5f;
  --rule: #9c9784; --line: #e6e2d2; --accent: #1e4a8f; --accent-ink: #ffffff; --accent-soft: #dce6f4;
  --key: #e4e2d9; --key-edge: #85816f; --key-ink: #14171a; --neg: #b00020; --focus: #0b57d0;
  --shadow: none; --mono: Consolas, "Courier New", "Liberation Mono", monospace;
  --disp: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; color-scheme: light;
}
/* the desk: a flat dark wood tone with a faint grain and a soft light from above */
:root[data-theme="classic"] body {
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 220, 170, .10), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 2px, rgba(255, 255, 255, .012) 2px 7px, rgba(0, 0, 0, .04) 7px 9px),
    linear-gradient(180deg, #4a3829, #3a2b1f);
}
/* the other desks (Settings, Desk). Only Classic draws a desk; Modern and Dark keep their flat page. Text drawn straight on the desk (the footer) changes colour per desk. */
:root[data-theme="classic"][data-desk="oak"] body { background: var(--desk-oak); }
:root[data-theme="classic"][data-desk="blotter"] body { background: var(--desk-blotter); }
:root[data-theme="classic"][data-desk="slate"] body { background: var(--desk-slate); }
:root[data-theme="classic"][data-desk="oak"] .site-foot { color: #000; }
:root[data-theme="classic"][data-desk="oak"] .site-foot a:hover { color: #000; }
:root[data-theme="classic"][data-desk="blotter"] .site-foot { color: #eadfc4; }
:root[data-theme="classic"][data-desk="slate"] .site-foot { color: #f1f4f7; }
/* the blotter's tooled line: a thin gold rule inset from the edge of the page, behind everything, no clicks */
:root[data-theme="classic"][data-desk="blotter"] body::before { content: ""; position: fixed; inset: 4px; z-index: -1; pointer-events: none; border: 1px solid #c2a05f; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(0, 0, 0, .15); }
@media print { body::before { display: none !important; } }
/* Paper running low / out: a soft pink-red stripe down both edges of the paper, like the end-of-roll stripe on a real roll. A pseudo-element over the paper's edges: no row, figure or box moves; no clicks; never printed. */
html[data-paper] .tape-panel::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
  background: linear-gradient(90deg, rgba(232, 84, 110, .5) 0 7px, rgba(232, 84, 110, 0) 7px calc(100% - 7px), rgba(232, 84, 110, .5) calc(100% - 7px) 100%); }
html[data-paper="out"] .tape-panel::after { background: linear-gradient(90deg, rgba(222, 52, 84, .62) 0 8px, rgba(222, 52, 84, 0) 8px calc(100% - 8px), rgba(222, 52, 84, .62) calc(100% - 8px) 100%); }
@media print { .tape-panel::after { display: none !important; } }
.paper-info { font-size: 16px; }
.diff-info.paper-info.low { color: #8a4a00; }
.diff-info.paper-info.out { color: var(--neg); }
:root[data-theme="dark"] .diff-info.paper-info.low { color: #ffc266; }
/* a phone: the chip shows a short form (Paper low, Paper out, still 16px) so it shares the item count's line and costs the paper no row; the full sentence stays in the button's text for screen readers and in its tooltip */
@media (max-width: 700px) {
  .paper-info { font-size: 0; padding: 0 4px; }
  .paper-info::before { content: attr(data-short); font-size: 16px; line-height: 1.1; letter-spacing: -.2px; }
  .count:has(> #paperInfo:not([hidden])) { column-gap: 4px; }
}
.paper-count { font-weight: 600; margin-top: 6px; }
.paper-list { margin-bottom: 6px; }
.paper-list li { color: var(--ink); padding: 2px 4px; }
/* Settings, Desk: four swatch radios, each a real input with a 44px swatch and its word under it; the chosen one has a ring and a tick */
.desk-set { padding: 6px 12px 8px; }
.desk-set .theme-name { display: block; margin: 0 0 6px; }
.desk-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.dpos { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; min-width: 0; }
.dpos input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dsw { display: block; width: 100%; min-width: 44px; height: 44px; border-radius: 8px; border: 2px solid var(--muted); position: relative; }
.dsw-walnut { background: var(--desk-walnut); } .dsw-oak { background: var(--desk-oak); } .dsw-blotter { background: var(--desk-blotter); } .dsw-slate { background: var(--desk-slate); }
.dlab { font-size: 16px; font-weight: 600; line-height: 1.2; color: var(--ink); }
.dpos input:checked + .dsw { box-shadow: 0 0 0 2px var(--panel), 0 0 0 5px var(--ink); }
.dpos input:checked + .dsw::after { content: "\2713"; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #fff; color: #111; border: 2px solid #111; font: 800 16px/22px var(--sans); text-align: center; }
.dpos input:focus-visible + .dsw { outline: 3px solid var(--focus); outline-offset: 5px; }
/* Black only: nothing on the paper is red, the error flag and the derived tick-and-tie circle included (the minus sign and the circle's shape still say what they mean) */
:root[data-ribbon="black"] .row.err .run::after { color: inherit; }
:root[data-ribbon="black"] .tie-mark[data-k="extra"] { color: var(--ink); }
.ribbon-set .tpos > span { min-height: 44px; font-size: 16px; line-height: 30px; }
.desk-cap { display: block; margin-top: 6px; font-size: 14px; color: var(--muted); }
/* the one quiet toolbar */
:root[data-theme="classic"] .bar { background: #d9d5c6; border-bottom: 1px solid #8d8877; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
:root[data-theme="classic"] .logo { font-size: 18px; }
:root[data-theme="classic"] .logo-mark { border-radius: 4px; width: 26px; height: 26px; font-size: 19px; }
:root[data-theme="classic"] .menu-btn { background: linear-gradient(#f4f2ea, #d6d2c3); border: 1px solid #6f6b5a; border-bottom-width: 3px; border-radius: 6px; color: var(--ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset; }
:root[data-theme="classic"] .menu-btn:hover { border-color: var(--accent); }
:root[data-theme="classic"] .menu-btn[aria-expanded="true"] { background: linear-gradient(#cfd9ea, #dce6f4); border-color: var(--accent); }
:root[data-theme="classic"] .menu-pop { background: #ebe8dc; border: 1px solid #6f6b5a; border-radius: 8px; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
:root[data-theme="classic"] .print-pop { background: #ebe8dc; border: 1px solid #6f6b5a; border-radius: 8px; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
:root[data-theme="classic"] .print-pop button:hover { background: #d9e3f3; border-color: var(--accent); }
:root[data-theme="classic"] .menu-pop button:hover { background: #d9e3f3; border-color: var(--accent); }
:root[data-theme="classic"] .namebtn { border-radius: 4px; }
:root[data-theme="classic"] .taxset input { border-radius: 4px; }
:root[data-theme="classic"] .tpos > span { background: linear-gradient(#f4f2ea, #dcd8c9); }
:root[data-theme="classic"] .tpos input:checked + span { background: var(--accent); }
:root[data-theme="classic"] dialog button { border-radius: 5px; background: linear-gradient(#f1efe6, #d9d6c9); border-color: #7d7967; }
:root[data-theme="classic"] button.primary { background: var(--accent); color: var(--accent-ink); }

:root[data-theme="classic"] .app { grid-template-columns: minmax(300px, 450px) 38px clamp(530px, 70vh, 690px); justify-content: center; align-items: start; gap: 0; padding: 14px 16px 6px; }
:root[data-theme="classic"] .tape-panel, :root[data-theme="classic"] .app > .side { height: 100%; }
:root[data-theme="classic"] .app > .side { overflow: visible; padding: 0; justify-content: flex-start; }

/* the paper strip */
:root[data-theme="classic"] .tape-panel { position: relative; background: var(--paper); border: 0; border-radius: 0 0 2px 2px; margin-top: 10px; height: calc(100% - 10px);
  box-shadow: inset 10px 0 12px -10px rgba(0, 0, 0, .35), inset -10px 0 12px -10px rgba(0, 0, 0, .35), 5px 7px 14px rgba(0, 0, 0, .45); overflow: visible; }
:root[data-theme="classic"] .tape-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; background: var(--paper);
  -webkit-mask: conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) 0 0 / 14px 8px repeat-x; mask: conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) 0 0 / 14px 8px repeat-x; }
:root[data-theme="classic"] .tape { --tape-pt: 6px; font: 22px/1.3 var(--mono); letter-spacing: .01em; padding: 6px 0 8px; background-image: repeating-linear-gradient(0deg, rgba(60, 50, 20, .03) 0 1px, transparent 1px 4px); text-shadow: 0 0 .6px rgba(20, 23, 26, .55); }
:root[data-theme="classic"] .tape:not(:has(.row))::before { font-family: var(--mono); font-size: 18px; }
:root[data-theme="classic"] .row { grid-template-columns: 4ch minmax(9ch, 1.2fr) 2ch minmax(10ch, 1fr); column-gap: 8px; min-height: 32px; contain-intrinsic-size: auto 32px; padding: 0 14px 0 10px; }
:root[data-theme="classic"] .row .n { order: 1; font-size: 14px; }
:root[data-theme="classic"] .row .amt { order: 2; }
:root[data-theme="classic"] .row .op { order: 3; text-align: left; color: var(--ink); }
/* the running total is not printed on a real tape: here it is a faint pencil note in the margin */
:root[data-theme="classic"] .row .run { order: 4; font-style: italic; color: #565a5f; text-shadow: none; font-size: 17px; }
:root[data-theme="classic"] .row .note { order: 5; grid-column: 2 / -1; font-family: var(--mono); font-size: 15px; min-height: 0; line-height: 1.2; }
:root[data-theme="classic"] .row .note:empty { display: none; }
:root[data-theme="classic"] .row.editing { grid-template-columns: 5ch minmax(10ch, 1fr) 14ch minmax(10ch, 1fr); }
:root[data-theme="classic"] .row.editing .note { grid-column: 1 / -1; }
:root[data-theme="classic"] .row.marker { border-top: 2px dashed var(--ink); }
:root[data-theme="classic"] .row.side { background: none; border-left: 0; padding-left: 10px; }
:root[data-theme="classic"] .row.ref .amt, :root[data-theme="classic"] .row.ref .op { color: var(--muted); }
:root[data-theme="classic"] .tape-foot { border-top: 2px dashed var(--ink); padding: 6px 14px 10px; gap: 6px; }
:root[data-theme="classic"] .tape-top { padding: 8px 10px 6px; border-bottom: 1px dashed #b9b3a0; }
:root[data-theme="classic"] .pbtn { background: linear-gradient(#f6f4ec, #dedacb); border: 1.5px solid #4d4a3e; border-bottom-width: 3px; border-radius: 5px; color: #14171a; box-shadow: inset 0 1px 0 #fff; letter-spacing: .2px; }
:root[data-theme="classic"] .pbtn:hover:not(:disabled) { border-color: var(--accent); }
:root[data-theme="classic"] .pbtn.primary { background: linear-gradient(#2b5eab, #1e4a8f); border-color: #11295a; color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); text-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
:root[data-theme="classic"] .pbtn:active:not(:disabled) { transform: translateY(1px); border-bottom-width: 2px; }
:root[data-theme="classic"] .count { font-size: 15px; color: var(--muted); }
:root[data-theme="classic"] .total-wrap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the bridge: the strip runs from the tape into the printer housing */
:root[data-theme="classic"] .bridge { display: block; width: 40px; height: 50px; margin-top: 22px; margin-left: -1px; filter: drop-shadow(2px 3px 3px rgba(0, 0, 0, .4)); position: relative; z-index: 3; }

/* ---- the machine: molded putty body ---- */
:root[data-theme="classic"] .machine { position: relative; gap: 0; padding: 0 16px 18px; border-radius: 20px 20px 26px 26px;
  background: linear-gradient(180deg, #ebe6d6 0%, #ddd7c3 45%, #cfc8b2 100%);
  border: 1px solid #8f8873;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), inset 2px 0 0 rgba(255, 255, 255, .35), inset -2px 0 0 rgba(0, 0, 0, .08), inset 0 -5px 0 #a8a18b,
    0 2px 0 #6f6955, 0 5px 0 #4e4a3c, 0 18px 22px -4px rgba(0, 0, 0, .55), 0 30px 40px rgba(0, 0, 0, .28); }

/* printer housing: a raised, darker section with the paper channel and a tear bar */
:root[data-theme="classic"] .housing { display: block; position: relative; height: 68px; margin: 0 -16px; border-radius: 20px 20px 4px 4px;
  background: linear-gradient(180deg, #8c8672 0%, #77715e 55%, #67624f 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 3px 4px rgba(0, 0, 0, .35), 0 1px 0 #3f3b30; }
:root[data-theme="classic"] .housing .badge { position: absolute; right: 18px; top: 12px; font: 800 14px var(--sans); letter-spacing: 3px; text-transform: uppercase; color: #7a745f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 -1px 0 rgba(0, 0, 0, .45); padding: 0; background: none; border: 0; }
:root[data-theme="classic"] .channel { position: absolute; left: 0; top: 18px; width: 70%; height: 32px; background: #1b1a17; border-radius: 0 8px 8px 0; box-shadow: inset 0 3px 6px #000, 0 1px 0 rgba(255, 255, 255, .25); }
:root[data-theme="classic"] .strip { position: absolute; left: 0; top: 5px; bottom: 5px; right: 18%; background: linear-gradient(180deg, #e8e4d4, #fdfcf7 40%, #e1ddcc); border-radius: 0 2px 2px 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
:root[data-theme="classic"] .tearbar { position: absolute; left: 30px; top: -5px; bottom: -5px; width: 12px; border-radius: 2px;
  background: repeating-linear-gradient(180deg, #f4f4f2 0 4px, #b4b6b8 4px 6px), linear-gradient(90deg, #d9dbdd, #8f9396); background-blend-mode: multiply;
  box-shadow: 0 0 0 1px #4e5154, 2px 2px 3px rgba(0, 0, 0, .55); }

/* display */
:root[data-theme="classic"] .bezel { margin-top: 14px; padding: 9px; border-radius: 12px; background: linear-gradient(180deg, #55524a, #33322c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 rgba(255, 255, 255, .75), 0 -1px 0 rgba(0, 0, 0, .15); perspective: 700px; }
:root[data-theme="classic"] .entry-box { position: relative; background: linear-gradient(180deg, #02120b, #04180f 60%, #03140c); border: 0; border-radius: 6px; padding: 2px 12px 4px; transform: rotateX(7deg); transform-origin: 50% 100%;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, .9), inset 0 0 0 1px #000, 0 0 0 1px rgba(0, 0, 0, .6); overflow: hidden; }
:root[data-theme="classic"] .entry-box::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, .09) 0 28%, transparent 28.2%); }
:root[data-theme="classic"] .indicators { display: flex; gap: 12px; position: absolute; left: 12px; top: 6px; font: 700 11px var(--sans); letter-spacing: 1px; z-index: 2; }
:root[data-theme="classic"] .indicators span { color: #4f9c76; }
:root[data-theme="classic"] .indicators .lit { color: #b8ffd6; text-shadow: 0 0 6px #2fe27a; }
:root[data-theme="classic"] .hint { color: #ffd37a; text-align: right; padding-left: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 16px; font-size: 13px; position: relative; z-index: 2; }
:root[data-theme="classic"] .note-line { background: #12372a; color: #c8ffe0; top: 22px; z-index: 2; }
:root[data-theme="classic"] .entry { position: relative; color: #78f5ae; text-shadow: 0 0 8px rgba(80, 255, 150, .6); font: 700 clamp(38px, 6.4vh, 54px)/1.1 var(--disp); min-height: clamp(44px, 7vh, 62px); justify-content: flex-end; }
:root[data-theme="classic"] .entry::before { content: "888888888888"; position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: rgba(110, 255, 170, .07); text-shadow: none; z-index: 0; white-space: nowrap; }
:root[data-theme="classic"] .entry::after { display: none; }
:root[data-theme="classic"] .entry-text, :root[data-theme="classic"] .disp-total { position: relative; z-index: 1; }
:root[data-theme="classic"] .entry-text:empty::before { content: none; }
:root[data-theme="classic"] .entry-text:not(:empty) ~ .disp-total { display: none; }
:root[data-theme="classic"] .disp-total { display: block; }

/* slide switches in a recessed channel */
:root[data-theme="classic"] .switches { margin-top: 12px; padding: 7px 8px 8px; gap: 0; justify-content: space-between; flex-wrap: nowrap; border-radius: 8px;
  background: linear-gradient(180deg, #beb8a3, #c9c3af); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .35), 0 1px 0 rgba(255, 255, 255, .8); }
:root[data-theme="classic"] .sw { display: grid; grid-template-columns: repeat(var(--n), var(--cw, 26px)); grid-template-rows: auto auto auto; justify-items: center; align-items: end; position: relative; }
:root[data-theme="classic"] .sw-dec { --cw: 21px; } :root[data-theme="classic"] .sw-round { --cw: 26px; } :root[data-theme="classic"] .sw-item { --cw: 28px; } :root[data-theme="classic"] .sw-enter { --cw: 34px; } :root[data-theme="classic"] .sw-sound { --cw: 28px; } :root[data-theme="classic"] .sw-mode { --cw: 30px; }
:root[data-theme="classic"] .sw-name { grid-column: 1 / -1; grid-row: 1; margin: 0 0 1px; font: 800 9px var(--sans); letter-spacing: 1.4px; color: #25231d; text-shadow: 0 1px 0 rgba(255, 255, 255, .55); }
:root[data-theme="classic"] .sw .pos { grid-row: 2; width: 100%; }
:root[data-theme="classic"] .sw .pos > span { background: none; border: 0; border-radius: 0 !important; padding: 0 0 3px; min-height: 22px; line-height: 20px; text-align: center; font: 800 11px var(--sans); color: #1d1b16; text-shadow: 0 1px 0 rgba(255, 255, 255, .55); position: relative; }
:root[data-theme="classic"] .sw-enter .pos > span { font-size: 10px; letter-spacing: -.3px; }
:root[data-theme="classic"] .sw .pos > span::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 1px; height: 4px; background: #3a372d; }
:root[data-theme="classic"] .sw .pos input:checked + span { background: none; color: #000; }
:root[data-theme="classic"] .sw .pos input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 0; border-radius: 3px !important; }
:root[data-theme="classic"] .sw-track { display: block; grid-row: 3; grid-column: 1 / -1; position: relative; width: 100%; height: 14px; border-radius: 7px; background: linear-gradient(180deg, #14130f, #2a2923); box-shadow: inset 0 2px 3px #000, 0 1px 0 rgba(255, 255, 255, .7); }
:root[data-theme="classic"] .sw-track { cursor: pointer; touch-action: none; }
:root[data-theme="classic"] .sw-track::before { content: ""; position: absolute; inset: -8px 0; } /* a taller target than the slot */
:root[data-theme="classic"] .sw-knob { position: absolute; top: -4px; width: 16px; height: 22px; border-radius: 3px; pointer-events: none;
  left: calc(var(--i, 0) * var(--cw, 26px) + var(--cw, 26px) / 2 - 8px);
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .35) 0 1px, transparent 1px 3px), linear-gradient(180deg, #8a8d91, #4b4e53 55%, #2d2f33);
  box-shadow: 0 2px 2px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .5); transition: left .14s ease-out; }
:root[data-theme="classic"] .sw:has(input:focus-visible) .sw-knob { outline: 3px solid var(--focus); outline-offset: 2px; }
:root[data-theme="classic"] .sw.unset .sw-knob { opacity: .35; }
@media (prefers-reduced-motion: reduce) { :root[data-theme="classic"] .sw-knob { transition: none; } }

/* keyboard: recessed wells separate the groups; each key is a face on a darker skirt */
:root[data-theme="classic"] .keypad { position: relative; margin-top: 16px; gap: 7px; grid-auto-rows: var(--kh, clamp(38px, 5.9vh, 62px)); }
:root[data-theme="classic"] .well { display: block; z-index: 0; border-radius: 10px; margin: -5px; background: rgba(90, 82, 55, .13); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .22), 0 1px 0 rgba(255, 255, 255, .6); }
:root[data-theme="classic"] .w-mem { grid-area: 1 / 3 / 2 / 7; }
:root[data-theme="classic"] .w-fn { grid-area: 1 / 1 / 7 / 3; }
:root[data-theme="classic"] .w-dig { grid-area: 2 / 3 / 7 / 6; }
:root[data-theme="classic"] .w-op { grid-area: 2 / 6 / 7 / 7; }
:root[data-theme="classic"] .key { position: relative; isolation: isolate; z-index: 1; border: 0; border-radius: 9px; padding: 0 0 7px; min-width: 40px; font: 800 23px var(--sans); color: var(--key-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
  background: linear-gradient(180deg, #8e8a79, #6f6b5c); box-shadow: 0 3px 0 #4d4a3e, 0 5px 6px rgba(0, 0, 0, .4); }
:root[data-theme="classic"] .key::before { content: ""; position: absolute; z-index: -1; top: 2px; left: 3px; right: 3px; bottom: 6px; border-radius: 7px;
  background: radial-gradient(ellipse at 50% 18%, #fbfaf3 0%, #ebe8dc 55%, #d5d1c1 100%); box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .18), inset 0 1px 1px rgba(255, 255, 255, .9); }
:root[data-theme="classic"] .key:active, :root[data-theme="classic"] .key.down { transform: none; padding: 5px 0 0; box-shadow: 0 1px 0 #4d4a3e, 0 1px 2px rgba(0, 0, 0, .4); }
:root[data-theme="classic"] .key:active::before, :root[data-theme="classic"] .key.down::before { top: 5px; bottom: 2px; box-shadow: inset 0 3px 5px rgba(0, 0, 0, .35); }
:root[data-theme="classic"] .key small { font: 800 9px var(--sans); color: inherit; letter-spacing: .6px; text-shadow: none; }
:root[data-theme="classic"] .key .sym { font-size: 22px; }
:root[data-theme="classic"] .key.fn, :root[data-theme="classic"] .key.op { font-size: 17px; }
:root[data-theme="classic"] .key.op { font-size: 24px; }
:root[data-theme="classic"] .key.fn::before, :root[data-theme="classic"] .key.op::before { background: radial-gradient(ellipse at 50% 18%, #d7d7d1 0%, #bdbdb6 60%, #a4a49d 100%); }
:root[data-theme="classic"] .key.mem { color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); background: linear-gradient(180deg, #3a3d42, #25272b); }
:root[data-theme="classic"] .key.mem::before { background: radial-gradient(ellipse at 50% 18%, #6b7078 0%, #565a61 60%, #474b51 100%); }
:root[data-theme="classic"] .key.minus { color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); background: linear-gradient(180deg, #7e1e18, #5a120e); font-size: 30px; }
:root[data-theme="classic"] .key.minus::before { background: radial-gradient(ellipse at 50% 18%, #c93f33 0%, #b72f25 60%, #a32820 100%); }
:root[data-theme="classic"] .key.add, :root[data-theme="classic"] .key.tot { color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); background: linear-gradient(180deg, #11295a, #0b1b3e); }
:root[data-theme="classic"] .key.add::before, :root[data-theme="classic"] .key.tot::before { background: radial-gradient(ellipse at 50% 18%, #3b6cb9 0%, #2f5aa8 60%, #244b93 100%); }
:root[data-theme="classic"] .key.add { font-size: 40px; }
:root[data-theme="classic"] .key.add .sym { font-size: 44px; }
:root[data-theme="classic"] .key.tot { flex-direction: row; gap: 8px; }
:root[data-theme="classic"] .key.tot small { font-size: 10px; }
:root[data-theme="classic"] .key.feed { flex-direction: row; gap: 8px; }
:root[data-theme="classic"] .key.sub small, :root[data-theme="classic"] .key.ref small { margin-top: -1px; }
:root[data-theme="classic"] .key:disabled { opacity: .55; }

/* phone: paper above, machine below at full width */
@media (max-width: 820px) {
  body { display: block; height: auto; }
  html, body { height: auto; }
  .app { display: flex; flex-direction: column; padding: 10px; gap: 12px; }
  .tape-panel { height: 46vh; min-height: 260px; }
  .tape { font-size: 22px; }
  .row { grid-template-columns: 4ch 2ch 1fr 1fr; }
  .row .note { display: none; }
  .row.editing .note { display: block; grid-column: 1 / -1; }
  .total { font-size: 30px; }
  .total-label { display: none; }
  .count { white-space: nowrap; }
  .row.editing { grid-template-columns: 4ch 11ch 1fr; }
  .row.editing .run { display: none; }
  .keypad { grid-auto-rows: minmax(52px, auto); gap: 6px; }
  .key { min-height: 52px; }
  .namebtn { max-width: 100%; }
  .keys-dialog dl > div { grid-template-columns: 1fr; gap: 0; }
  :root[data-theme="classic"] .app { display: flex; align-items: stretch; padding: 14px 10px 12px; }
  :root[data-theme="classic"] .tape-panel { height: 46vh; margin-top: 10px; }
  :root[data-theme="classic"] .bridge { display: none; }
  :root[data-theme="classic"] .row { grid-template-columns: 4ch 1fr 2ch 1fr; column-gap: 8px; }
  :root[data-theme="classic"] .row .note { display: block; }
  :root[data-theme="classic"] .row .note:empty { display: none; }
  :root[data-theme="classic"] .row.editing { grid-template-columns: 4ch 1fr 11ch; }
  :root[data-theme="classic"] .app > .side { height: auto; }
  :root[data-theme="classic"] .machine { padding: 0 10px 16px; }
  :root[data-theme="classic"] .housing { margin: 0 -10px; }
  :root[data-theme="classic"] .channel { width: 80%; }
  :root[data-theme="classic"] .switches { flex-wrap: wrap; gap: 8px 10px; justify-content: space-around; }
  :root[data-theme="classic"] .sw .pos > span { min-height: 44px; line-height: 40px; }
  :root[data-theme="classic"] .keypad { gap: 6px; }
  .sw .pos > span { min-height: 44px; }
}

/* narrow (phone) width: the machine goes compact. The toolbar is the logo, the tape name and one Menu button; the tape is a short
   window above the machine; the display is slim; the slide switches stay in one compact row; the whole keypad is on screen. */
@media (max-width: 700px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; height: 100dvh; }
  .bar { flex-wrap: nowrap; padding: 3px 8px; gap: 6px; }
  .logo { font-size: 17px; }
  .logo-mark { width: 26px; height: 26px; font-size: 19px; }
  .namebtn { flex: 1; min-width: 0; font-size: 15px; padding: 4px 6px; max-width: none; text-align: left; }
  .save-state { display: none; }
  .bar-menus { gap: 6px; margin-left: 0; }
  .menu { position: static; }
  .menu-btn { min-height: 38px; padding: 2px 9px; font-size: 14px; gap: 5px; }
  .menu-btn .ico { width: 20px; height: 20px; }
  .menu-btn .chev { display: none; }
  .menu-pop { left: 6px; right: 6px; top: 100%; min-width: 0; max-height: calc(100dvh - 54px); border-radius: 0 0 12px 12px; margin-top: 0; }
  .menu-pop .menu-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; padding: 8px 12px 2px; border-top: 1px solid var(--rule); margin-top: 6px; }
  .menu-pop .menu-links a { min-height: 36px; display: inline-flex; align-items: center; }
  .menu-pop .menu-about { display: block; font-size: 13px; color: var(--muted); padding: 2px 12px 6px; }

  .app, :root[data-theme="classic"] .app { flex: 1 1 0; min-height: 0; padding: 4px 6px 4px; gap: 4px; display: flex; flex-direction: column; align-items: stretch; }
  .tape-panel, :root[data-theme="classic"] .tape-panel { flex: 1 1 0; height: auto; min-height: 142px; margin-top: 6px; }
  .tape { font-size: 22px; padding: 2px 0 2px; --tape-pt: 2px; }
  .row { grid-template-columns: 3ch 2ch minmax(0, 1.7fr) minmax(0, 1fr); }
  :root[data-theme="classic"] .row { grid-template-columns: 3ch minmax(0, 1.7fr) 2ch minmax(0, 1fr); }
  .row, :root[data-theme="classic"] .row { min-height: 32px; contain-intrinsic-size: auto 32px; padding: 0 6px; column-gap: 6px; }
  .row .run, :root[data-theme="classic"] .row .run { font-size: 15px; }
  /* the paper on a phone is a grid: Undo and Redo with the item count (and the total in Modern and Dark) on the top line, the short tape window, the three buttons at the foot */
  .tape-panel, :root[data-theme="classic"] .tape-panel { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .tape-top, :root[data-theme="classic"] .tape-top { grid-area: 1 / 1; border-bottom: 0; padding: 2px 8px; }
  .tape { grid-area: 2 / 1 / 3 / 3; }
  .tape-foot, :root[data-theme="classic"] .tape-foot { display: contents; }
  .foot-info { grid-area: 1 / 2; flex-direction: column; align-items: flex-end; justify-content: center; gap: 0; padding: 0 8px 0 0; min-width: 0; }
  .total-wrap { gap: 6px; }
  .total { font-size: 24px; line-height: 1.1; }
  .foot-actions { grid-area: 3 / 1 / 4 / 3; padding: 3px 8px 3px; border-top: 3px double var(--ink); background: var(--paper); }
  :root[data-theme="classic"] .foot-actions { border-top: 2px dashed var(--ink); }
  .tape-top .pbtn { min-height: 30px; padding: 0 10px; font-size: 15px; border-bottom-width: 2px; }
  .pbtn { min-height: 34px; padding: 2px 8px; font-size: 15px; gap: 5px; border-bottom-width: 2px; }
  .foot-actions .pbtn.primary { font-size: 15px; }
  .pbtn .ico { width: 18px; height: 18px; }
  .more { display: none; }
  .foot-actions { gap: 6px; }
  .count, :root[data-theme="classic"] .count { font-size: 14px; }
  .app > .side, :root[data-theme="classic"] .app > .side { flex: none; height: auto; overflow: visible; padding: 0; }

  .machine, :root[data-theme="classic"] .machine { gap: 4px; padding: 0 6px 5px; }
  :root[data-theme="classic"] .machine { border-radius: 14px 14px 18px 18px; }
  :root[data-theme="classic"] .housing { height: 20px; margin: 0 -6px; border-radius: 14px 14px 3px 3px; }
  :root[data-theme="classic"] .housing .badge { top: 2px; right: 12px; font-size: 12px; }
  :root[data-theme="classic"] .channel { top: 3px; height: 14px; width: 62%; }
  :root[data-theme="classic"] .strip { top: 2px; bottom: 2px; }
  :root[data-theme="classic"] .tearbar { left: 22px; top: -3px; bottom: -3px; width: 8px; }
  :root[data-theme="classic"] .bezel { margin-top: 4px; padding: 4px; border-radius: 9px; }
  :root[data-theme="classic"] .entry-box { padding: 0 8px 2px; transform: none; }
  :root[data-theme="classic"] .indicators { top: 3px; left: 8px; font-size: 10px; gap: 9px; }
  :root[data-theme="classic"] .hint { padding-left: 90px; min-height: 13px; font-size: 11px; }
  :root[data-theme="classic"] .entry { font-size: 32px; min-height: 38px; }
  .entry-box { padding: 2px 10px 4px; }
  .hint { min-height: 14px; font-size: 13px; }
  .entry { font-size: 30px; min-height: 40px; }

  /* the six slide switches: two rows of three on a phone (six in one row would need type too small to read) */
  .switches { flex-wrap: wrap; justify-content: flex-start; gap: 4px 10px; padding: 2px 2px; margin-top: 0; }
  :root[data-theme="classic"] .switches { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 3px 4px; padding: 3px 8px 3px; margin-top: 4px; overflow: visible; }
  .sw { flex: none; }
  .sw .pos > span { min-height: 28px; padding: 1px 5px; font-size: 12.5px; line-height: 24px; }
  .sw-name { font-size: 10px; margin-right: 3px; }
  .switches { row-gap: 2px; column-gap: 8px; }
  .sw { display: grid; grid-template-columns: repeat(var(--n), auto); justify-content: start; }
  .sw-name { grid-column: 1 / -1; grid-row: 1; margin: 0; line-height: 1.1; }
  .sw .pos { grid-row: 2; }
  :root[data-theme="classic"] .sw .pos > span { min-height: 18px; line-height: 16px; font-size: 10px; padding: 0 0 2px; }
  :root[data-theme="classic"] .sw-name { font-size: 9px; letter-spacing: .8px; }
  :root[data-theme="classic"] .sw-dec { --cw: 20px; } :root[data-theme="classic"] .sw-round { --cw: 28px; } :root[data-theme="classic"] .sw-item { --cw: 30px; }
  :root[data-theme="classic"] .sw-enter { --cw: 36px; } :root[data-theme="classic"] .sw-sound { --cw: 30px; } :root[data-theme="classic"] .sw-mode { --cw: 32px; }
  :root[data-theme="classic"] .sw-enter .pos > span { font-size: 9px; letter-spacing: -.2px; }
  :root[data-theme="classic"] .sw-track { height: 12px; }
  :root[data-theme="classic"] .sw-knob { width: 14px; height: 18px; top: -3px; left: calc(var(--i, 0) * var(--cw, 26px) + var(--cw, 26px) / 2 - 7px); }

  .keypad, :root[data-theme="classic"] .keypad { --kh: 44px; grid-auto-rows: 44px; gap: 5px; margin-top: 5px; }
  .key, :root[data-theme="classic"] .key { min-height: 44px; min-width: 48px; font-size: 20px; }
  :root[data-theme="classic"] .key.fn { font-size: 15px; }
  :root[data-theme="classic"] .key.op { font-size: 22px; }
  :root[data-theme="classic"] .key.add { font-size: 34px; }
  :root[data-theme="classic"] .key.add .sym { font-size: 36px; }
  :root[data-theme="classic"] .well { margin: -3px; }
  .keys-dialog dl > div { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 700px) and (min-height: 800px) {
  .keypad, :root[data-theme="classic"] .keypad { --kh: 48px; grid-auto-rows: 48px; }
  .key, :root[data-theme="classic"] .key { min-height: 48px; }
}

/* a phone: the selection line takes the count's place while lines are selected, and it shows only "N lines, sum X" (the rest is in its tooltip and the live region) */
@media (max-width: 700px) {
  .count, :root[data-theme="classic"] .count { display: flex; align-items: center; justify-content: flex-end; gap: 6px; max-width: 100%; }
  .count:has(> .sel-info:not([hidden])) > #count { display: none; } /* the selection line takes the place of the item count while lines are selected */
  .sel-info { margin-top: 0; min-width: 0; font-size: 12px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  :root[data-theme="classic"] .sel-info { font-size: 12px; }
  .sel-pre, .sel-sep, .sel-more { display: none; }
}
@media (max-width: 380px) { .sel-info { white-space: normal; overflow-wrap: anywhere; line-height: 1.15; } } /* the smallest phones: a long sum wraps rather than runs off the paper */

@media (max-width: 480px) {
  :root[data-theme] .logo { font-size: 0; gap: 0; } /* the AddTape word steps aside for the tape name; the + mark stays, and the h1 text is still read aloud */
}

/* ---- the power switch: a rocker on the machine, 44px to tap. Classic puts it on the printer housing (top right, the badge moves left); Modern and Dark show it as a flex item after Item ---- */
.power { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-width: 44px; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 8px; cursor: pointer; flex: none; align-self: center; }
.power .rocker { position: relative; display: block; width: 28px; height: 36px; border-radius: 6px; border: 2px solid var(--ink); background: linear-gradient(180deg, #a6adb4 0 48%, #1f2327 52% 100%); box-shadow: 0 2px 0 rgba(0, 0, 0, .35); transition: transform .12s; transform: perspective(70px) rotateX(16deg); }
.power[aria-checked="false"] .rocker { transform: perspective(70px) rotateX(-16deg); background: linear-gradient(180deg, #1f2327 0 48%, #a6adb4 52% 100%); }
.power .rk-i { position: absolute; left: 50%; top: 6px; width: 3px; height: 11px; margin-left: -1.5px; border-radius: 1px; background: #101214; }
.power .rk-o { position: absolute; left: 50%; bottom: 6px; width: 10px; height: 10px; margin-left: -5px; border: 3px solid #b8bec4; border-radius: 50%; box-sizing: border-box; }
.power[aria-checked="false"] .rk-i { background: #b8bec4; }
.power[aria-checked="false"] .rk-o { border-color: #101214; }
.power:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
.power:hover .rocker { border-color: var(--accent); }
/* off: the display is dark, no digits, the caption says how to wake it. Nothing else changes. */
.power-caption { display: none; }
.power-caption:not([hidden]) { display: flex; position: absolute; left: 12px; right: 12px; bottom: 4px; min-height: 40px; align-items: center; justify-content: flex-end; z-index: 3; font: 600 16px/1.25 var(--sans); text-align: right; color: var(--muted); }
html[data-power="off"] .entry-text, html[data-power="off"] .disp-total { visibility: hidden; }
html[data-power="off"] .entry::before { opacity: 0; }
html[data-power="off"] .indicators .lit { color: #2f5a46; text-shadow: none; }
html[data-power="off"]:not([data-theme="classic"]) .entry-box { background: #20262d; border-color: #20262d; }
html[data-power="off"]:not([data-theme="classic"]) .power-caption { color: #dfe6ee; }
:root[data-theme="classic"] .power-caption:not([hidden]) { color: #9be8bf; }
.hum-set { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; font-size: 16px; cursor: pointer; color: var(--ink); }
.hum-set input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); cursor: pointer; }
:root[data-theme="classic"] .power { position: absolute; top: 12px; right: 12px; z-index: 3; }
:root[data-theme="classic"] .power .rocker { border-color: #15130e; box-shadow: 0 2px 0 #4d4a3e, 0 3px 5px rgba(0, 0, 0, .4); }
:root[data-theme="classic"] .housing .badge { right: 70px; letter-spacing: 2px; }
@media (max-width: 700px) {
  /* a phone: the rocker takes a fourth column beside the two rows of slide switches (Classic) or sits at the end of the first row (Modern and Dark), so the machine is no taller */
  :root[data-theme="classic"] .switches { grid-template-columns: repeat(3, auto) 44px; }
  :root[data-theme="classic"] .power { position: static; grid-column: 4; grid-row: 1 / span 2; align-self: center; justify-self: end; }
  :root[data-theme="classic"] .housing .badge { right: 12px; letter-spacing: 3px; }
  :root:not([data-theme="classic"]) .sw-enter, :root:not([data-theme="classic"]) .sw-sound, :root:not([data-theme="classic"]) .sw-mode { order: 1; } /* the rocker (last in the page order, so the keyboard reaches it after the switches) is shown at the end of the first row */
  :root:not([data-theme="classic"]) .power { margin: -3px 0 -2px; } /* still 44px to tap, but the row is as tall as the labelled switches beside it, so the paper keeps its 3 rows */
}

/* ---- the spike file (Classic only): a receipt spike on a small base with a slip for each saved tape. A real button, position: fixed in the free desk right of the machine; ui.js sets
   its left edge and hides it where there is no room. Not printed. The slips are CSS boxes, the spike a steel rod: no image. ---- */
.spike { display: none; position: fixed; bottom: 44px; width: 88px; height: 124px; z-index: 4; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 10px; }
:root[data-theme="classic"] .spike:not([hidden]) { display: block; }
.spike:focus-visible { outline: 3px solid #0b57d0; outline-offset: 2px; box-shadow: 0 0 0 6px #fff; }
.spike-base { position: absolute; left: 2px; right: 2px; bottom: 0; height: 16px; border-radius: 7px 7px 9px 9px; background: linear-gradient(180deg, #7a6850, #3d3023 70%, #2b2118); box-shadow: 0 4px 6px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .3); }
.spike-pin { position: absolute; left: calc(50% - 2px); bottom: 12px; width: 4px; height: 108px; background: linear-gradient(90deg, #8b939b, #f4f6f8 45%, #6f777f); clip-path: polygon(50% 0, 100% 7%, 100% 100%, 0 100%, 0 7%); }
.slips { position: absolute; inset: 0; pointer-events: none; }
.slip { position: absolute; left: 50%; bottom: calc(14px + var(--i) * 5px); width: 58px; height: 32px; margin-left: -29px; border-radius: 1px; border: 1px solid #c9c1a6;
  background: repeating-linear-gradient(180deg, transparent 0 6px, rgba(60, 50, 30, .16) 6px 7px), linear-gradient(180deg, #fbf7ea, #efe9d6);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .35); transform: rotate(var(--r, 0deg)) skewX(var(--k, 0deg)); }
.slip.settle { animation: spike-settle 300ms ease-out; }
@keyframes spike-settle { from { transform: translateY(-16px) rotate(var(--r, 0deg)) skewX(var(--k, 0deg)); opacity: .4; } to { transform: rotate(var(--r, 0deg)) skewX(var(--k, 0deg)); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .slip.settle { animation: none; } }
.spike-count { position: absolute; right: -2px; bottom: 20px; z-index: 2; min-width: 28px; height: 28px; padding: 0 5px; box-sizing: border-box; border-radius: 14px; border: 2px solid #14171a; background: #fff7dc; color: #14171a; font: 700 16px/24px var(--sans); text-align: center; }
.spike-count[hidden] { display: none; }
@media print { .spike { display: none !important; } }
@media (max-width: 820px) { .spike { display: none !important; } }

/* the tagline and the link row under the machine (small, off the machine; behind Menu on a phone) */
.site-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; padding: 3px 16px 5px; font-size: 12.5px; color: var(--muted); }
.site-foot p, .menu-about { margin: 0; }
.site-foot nav, .menu-links { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.site-foot a, .menu-links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-foot a:hover, .menu-links a:hover { color: var(--ink); }
:root[data-theme="classic"] .site-foot { color: #d8cdb8; }
:root[data-theme="classic"] .site-foot a:hover { color: #fff; }
.menu-links, .menu-about { display: none; }
.menu-pop .menu-links, .menu-pop .menu-about { color: var(--ink); }
@media (max-width: 700px) {
  .site-foot { display: none; }
}

/* Tear-off: a handle along the paper's top edge (a real button), a tear opening that follows the pointer, the ghost of the torn paper that slides away, and the toast with Put it back */
.tape-panel { position: relative; }
.tear-edge { position: absolute; left: 0; right: 0; top: 0; height: 8px; z-index: 3; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.tear-edge::before { content: ""; position: absolute; left: 10px; right: 10px; top: 3px; border-top: 2px dashed var(--muted); opacity: .55; pointer-events: none; }
.tear-edge:hover::before, .tear-edge:focus-visible::before { opacity: 1; border-top-color: var(--accent); }
.tear-edge:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tear-edge:active { cursor: grabbing; }
:root[data-theme="classic"] .tear-edge { top: -10px; height: 18px; }
:root[data-theme="classic"] .tear-edge::before { top: 11px; left: 6px; right: 6px; border-top: 2px dotted rgba(60, 50, 20, .45); opacity: 1; }
:root[data-theme="classic"] .tear-edge:hover::before, :root[data-theme="classic"] .tear-edge:focus-visible::before { border-top-color: #1d4f9e; }
.tear-open { position: absolute; top: 0; height: 10px; z-index: 4; pointer-events: none; background: color-mix(in srgb, var(--ink) 60%, transparent);
  -webkit-mask: conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) 0 0 / 12px 10px repeat-x; mask: conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) 0 0 / 12px 10px repeat-x; }
.tear-open[hidden] { display: none; }
.tear-open.ready { background: var(--accent); }
:root[data-theme="classic"] .tear-open { top: -6px; height: 14px; background: rgba(35, 22, 12, .8); -webkit-mask-size: 12px 14px; mask-size: 12px 14px; }
:root[data-theme="classic"] .tear-open.ready { background: #1d4f9e; }
.tear-ghost { position: fixed; z-index: 55; margin: 0; pointer-events: none; will-change: transform, opacity; }
.tear-ghost > .tape-panel { position: absolute !important; left: 0; top: 0; width: 100% !important; height: 100% !important; min-height: 0 !important; margin: 0 !important; flex: none !important; } /* the same box as the real paper, whatever the theme or width says about the real one's margins and height */
/* never over the keypad or the tape's buttons: ui.js puts it in the toolbar's free middle, or (narrow windows) over the top of the new, blank tape window, and sets --tear-left and --tear-top */
:root[data-theme="classic"] .toast { color: #f6f3e8; } /* Classic's --bg is the dark brown desk: brown text on the near-black pill read poorly at rest (rgb 63,49,37 on rgb 20,23,26), so the pill's text is cream there (measured: about 1.4:1 before, about 16:1 after) */
.tear-toast { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; white-space: nowrap; left: var(--tear-left, 12px); top: var(--tear-top, 8px); bottom: auto; transform: none; padding: 4px 10px; font-size: 15px; }
.tear-toast[hidden] { display: none; }
.tear-toast button { font: inherit; font-weight: 700; color: inherit; background: transparent; border: 2px solid currentColor; border-radius: 8px; min-height: 32px; padding: 0 12px; cursor: pointer; }
.tear-toast button:hover { background: color-mix(in srgb, var(--bg) 22%, transparent); }
.tear-toast button:focus-visible { outline: 3px solid var(--bg); outline-offset: 2px; }
@media (max-width: 700px) {
  .tear-edge, .tear-open { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tear-ghost { display: none; } }

/* print: the tape only, with name, date, item count and total */
@media print {
  :root:root:root { --paper: #fff; --ink: #000; --muted: #333; --neg: #b00020; --line: #ddd; color-scheme: light; } /* a credit prints red on the two-colour ribbon (it printed black before the Ribbon setting); with Black only no figure has the .neg class */
  body { display: block; background: #fff !important; height: auto; }
  .bar, .app > .side, .bridge, .skip, .toast, .tape-foot, .tape-top, .pbtn, .menu-pop, dialog, .site-foot, .tear-edge, .tear-open, .tear-ghost { display: none !important; }
  .app { display: block !important; padding: 0; }
  .tape-panel { border: 0; box-shadow: none !important; overflow: visible; display: block; height: auto !important; margin: 0 !important; }
  .print-head { display: block; padding: 0 0 10px; border-bottom: 2px solid #000; margin-bottom: 6px; font: 14px var(--sans); }
  .print-head h2 { margin: 0 0 4px; font-size: 22px; }
  .print-head .pt { font: 700 20px var(--mono); }
  .tape { overflow: visible; background: none; padding: 0; font-size: 14px; }
  .row { content-visibility: visible; min-height: 22px; break-inside: avoid; padding: 0 4px; }
  .row:hover { background: none; }
  :root:root:root .tape-panel { background: #fff; box-shadow: none; padding-top: 0; }
  :root:root:root .tape-panel::before { display: none; }
  :root:root:root .tape { background: none; text-shadow: none; }
  :root:root:root .row .run { color: #333; }
  .neg::before { content: ""; }
  .tape:not(:has(.row))::before { content: ""; }
  .row.sel { background: none !important; box-shadow: none !important; }
  .sel-info, .print-pop, .diff-info { display: none !important; }
  .tie-mark { left: 1px; top: 0; width: 14px; height: 22px; }
  .tie-mark svg { width: 14px; height: 14px; }
  :root:root:root .tie-mark { color: #000; }
  /* Print selected lines: only the lines marked .sel, in tape order, then a line saying it is a selection */
  /* Print columns 2 (Settings): the tape flows down the left column, then the right; a row never splits; the type size is unchanged */
  :root[data-print-cols="2"] .tape { column-count: 2; column-gap: 28px; column-rule: 1px solid #888; }
  :root[data-print-cols="2"] .row { break-inside: avoid; padding: 0 2px; column-gap: 6px; }
  :root[data-print-cols="2"] .row.marker .amt { letter-spacing: 0; } /* a half-width column still has room for SUBTOTAL 057 */
  body.print-sel .tape .row:not(.sel) { display: none !important; }
  body.print-sel .print-sel-note { display: block; margin-top: 8px; padding-top: 6px; border-top: 2px solid #000; font: 700 14px var(--sans); }
}

/* keypad shortcuts: the small secondary legend on TOTAL (*) and SUB (/), and the Settings note */
.key.tot, .key.sub { position: relative; }
.key .kleg { position: absolute; top: 2px; right: 5px; font: 800 14px var(--sans); font-style: normal; line-height: 1; opacity: .95; pointer-events: none; }
html[data-kpshort="off"] .key .kleg { display: none; }
.menu-note { margin: 4px 12px 6px; font-size: 12px; line-height: 1.35; color: var(--muted); max-width: 30em; }

/* ================= Labels on lines =================
   A label (vendor, check number, account) is kept in its own span, made only for a line that has one (paintLabel in ui.js), and the note cell of
   that line carries it as data-label. The tape gets class .has-labels only while at least one line has a label, and every rule below hangs on that
   class (or on .hl, a labelled row), so a tape with no labels is laid out exactly as before. The amount type stays 22px and keeps room for
   -1,234,567.89 and the approximately-equal mark (14ch): the label column is the one that shrinks.
   Screen, 1200px and wider: a label column. Narrower (down to the phone): no column, the label is printed bold on the small line before the note,
   because beside the amount, the running total and the note there is no room left for a column worth reading. Print: always a column. */
.row .lbl { font: 15px var(--sans); color: var(--ink); text-align: left; }
:root[data-theme="classic"] .row .lbl { font-family: var(--mono); }
.row.editing .lbl { display: none; }
.row.editing .note { display: flex; gap: 6px; }
.row.editing .note input { flex: 1 1 0; min-width: 0; }
.row.editing .note input.e-label { flex: 0 0 40%; }
.row.editing .note::before { content: none !important; }
@media screen and (min-width: 1200px) {
  /* 4px on top of the column gap (8px in Classic) so the label text starts about 12px after the line number; the amount's width is not touched */
  .tape.has-labels .row:not(.editing) > .lbl { margin-left: 4px; }
  /* Modern and Dark: line number, op, label, amount, running total, note */
  .tape.has-labels .row:not(.editing) { grid-template-columns: 5ch 2ch minmax(0, 2fr) minmax(14ch, 1fr) minmax(13ch, .9fr) minmax(0, 1fr); }
  .tape.has-labels .row:not(.editing) > .n { grid-column: 1; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .op { grid-column: 2; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .lbl { grid-column: 3; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .amt { grid-column: 4; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .run { grid-column: 5; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .note { grid-column: 6; grid-row: 1; }
  .tape.has-labels .row.brk:not(.editing) > .amt { grid-column: 2 / -1; }
  /* Classic: line number, label, amount, op, running total; the note keeps its own small line. The paper column grows while a label column shows. */
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) { grid-template-columns: 4ch minmax(0, 1.1fr) minmax(14ch, 1.2fr) 2ch minmax(11ch, 1fr); }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .n { grid-column: 1; grid-row: 1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .lbl { grid-column: 2; grid-row: 1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .amt { grid-column: 3; grid-row: 1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .op { grid-column: 4; grid-row: 1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .run { grid-column: 5; grid-row: 1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .note { grid-column: 2 / -1; grid-row: 2; }
  :root[data-theme="classic"] .tape.has-labels .row.brk:not(.editing) > .amt { grid-column: 2 / -1; }
  :root[data-theme="classic"] .app:has(.tape.has-labels) { grid-template-columns: minmax(300px, 620px) 38px clamp(530px, 70vh, 690px); }
}
@media screen and (max-width: 1199px) {
  .row .lbl { display: none; }
  .tape.has-labels .row.hl:not(.editing) .tie-mark { height: 28px; }
  :root .tape.has-labels .row:not(.editing) .note[data-label] { display: block; grid-column: 1 / -1; align-self: start; min-height: 0; line-height: 1.25; font-size: 14px; color: var(--muted); }
  :root .tape.has-labels .row:not(.editing) .note[data-label]::before { content: attr(data-label); font-weight: 700; color: var(--ink); }
  :root .tape.has-labels .row:not(.editing) .note[data-label]:not(:empty)::before { margin-right: .6em; }
}
@media screen and (max-width: 700px) {
  /* a phone keeps its row widths. The amount line and the small line together are 34px, so three labelled rows still fit the 106px Classic paper
     window of a 360x740 phone; the mark sits on the amount line */
  :root .tape.has-labels .row.hl:not(.editing) { row-gap: 0; line-height: 22px; }
  :root .tape.has-labels .row.hl:not(.editing) .tie-mark { height: 22px; }
  :root .tape.has-labels .row:not(.editing) .note[data-label] { line-height: 12px; font-size: 12px; }
  /* a line number of 4 digits has to clear the 16px mark: smaller type and a few more px into the column gap (5 digits are not handled) */
  .row.mk.n4 .n { font-size: 12px; margin-right: -10px; }
}
@media print {
  /* Print: a label column in one-column and two-column print, black on white. The note moves to a small line under the label so the column has room. */
  :root:root:root .row .lbl { color: #000; font-size: 13px; }
  .tape.has-labels .row:not(.editing) { grid-template-columns: 4ch 2ch minmax(0, 1fr) 14ch 12ch; column-gap: 6px; }
  .tape.has-labels .row:not(.editing) > .n { grid-column: 1; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .op { grid-column: 2; grid-row: 1; order: 0; }
  .tape.has-labels .row:not(.editing) > .lbl { grid-column: 3; grid-row: 1; }
  .tape.has-labels .row:not(.editing) > .amt { grid-column: 4; grid-row: 1; order: 0; }
  .tape.has-labels .row:not(.editing) > .run { grid-column: 5; grid-row: 1; order: 0; }
  .tape.has-labels .row:not(.editing) > .note { grid-column: 3 / -1; grid-row: 2; min-height: 0; line-height: 1.2; }
  .tape.has-labels .row:not(.editing) > .note:empty { display: none; }
  .tape.has-labels .row.brk:not(.editing) > .amt { grid-column: 2 / -1; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) { grid-template-columns: 4ch minmax(0, 1fr) 14ch 2ch 12ch; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .lbl { grid-column: 2; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .amt { grid-column: 3; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .op { grid-column: 4; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .run { grid-column: 5; }
  :root[data-theme="classic"] .tape.has-labels .row:not(.editing) > .note { grid-column: 2 / -1; }
  .tape.has-labels .row.hl .tie-mark { height: 20px; }
  /* Classic prints in its 22px type, so half a page cannot hold a label column beside the amount and the running total: with two print columns the label
     goes on the small line before the note, as on a phone */
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) { grid-template-columns: 4ch minmax(9ch, 1.2fr) 2ch minmax(10ch, 1fr); }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .n,
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .amt,
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .op,
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .run { grid-column: auto; grid-row: auto; }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .lbl { display: none; }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .note { grid-column: 2 / -1; grid-row: auto; }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .note[data-label] { display: block; }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .note[data-label]::before { content: attr(data-label); font-weight: 700; color: #000; }
  :root[data-theme="classic"][data-print-cols="2"] .tape.has-labels .row:not(.editing) > .note[data-label]:not(:empty)::before { margin-right: .6em; }
}

/* ---------- Rubber stamps and pencil marks (DESIGN.md: Rubber stamps, Pencil marks) ---------- */
:root {
  --ok: #1b6e3a; --stamp-paid: #1b6e3a; --stamp-reviewed: #1f4f9e; --stamp-void: #b3261e; --stamp-draft: #5f6670; --pencil: #555;
}
:root[data-theme="dark"] { --ok: #4fd18a; --stamp-paid: #4fd18a; --stamp-reviewed: #7fb0ff; --stamp-void: #ff8f86; --stamp-draft: #b4bdc9; --pencil: #aeb6c2; }
[data-kind="PAID"], [data-stamp="PAID"] { --stamp-ink: var(--stamp-paid); }
[data-kind="REVIEWED"], [data-stamp="REVIEWED"] { --stamp-ink: var(--stamp-reviewed); }
[data-kind="VOID"], [data-stamp="VOID"] { --stamp-ink: var(--stamp-void); }
[data-kind="DRAFT"], [data-stamp="DRAFT"] { --stamp-ink: var(--stamp-draft); }

/* the impression on the tape: a zero-height sticky wrapper at the top of the scrolling window, so it takes no space and stays in the upper right while the tape scrolls */
.stamp-wrap { position: sticky; top: var(--tape-pt, 8px); height: 0; z-index: 2; pointer-events: none; }
/* The ink is see-through (the figures under it stay readable) but is NOT one opacity on the whole element: the border and the word are about half ink, the date line is nearly full ink on a thin paper-coloured halo, so the date reads where it crosses printed figures. */
.stamp { --ink-word: color-mix(in srgb, var(--stamp-ink, var(--ink)) 52%, transparent); --ink-date: color-mix(in srgb, var(--stamp-ink, var(--ink)) 94%, transparent);
  position: absolute; top: 34px; right: 16px; display: flex; flex-direction: column; align-items: center; padding: 4px 14px 5px; color: var(--stamp-ink, var(--ink));
  border: 7px double var(--ink-word); border-radius: 14px; transform: rotate(-12deg); pointer-events: none; white-space: nowrap; text-shadow: none; text-transform: none; letter-spacing: 0; font-style: normal;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
  /* a slightly uneven ink: fine diagonal streaks of a little less ink, CSS only */
  -webkit-mask-image: repeating-linear-gradient(112deg, #000 0 7px, rgba(0, 0, 0, .78) 7px 8px, #000 8px 17px, rgba(0, 0, 0, .9) 17px 18px); mask-image: repeating-linear-gradient(112deg, #000 0 7px, rgba(0, 0, 0, .78) 7px 8px, #000 8px 17px, rgba(0, 0, 0, .9) 17px 18px); }
:root[data-theme="classic"] .stamp { right: 64px; }
:root[data-theme="classic"] .stamp[data-kind="REVIEWED"] { right: 30px; } /* the wide word: over the amount column as little as possible */ /* Classic's narrow paper: the date sits over the gap between the amount and the running total, not on the italic totals */
.stamp-word { font: 900 clamp(34px, 3vw, 40px)/1.05 var(--sans); letter-spacing: 2px; color: var(--ink-word); }
[data-kind="REVIEWED"] > .stamp-word { font-size: clamp(26px, 2.3vw, 31px); letter-spacing: 1px; } /* nine letters: scaled so the stamp stays under about 300px wide */
.stamp-date { font: 800 16px/1.2 var(--sans); letter-spacing: .8px; margin-top: 3px; color: var(--ink-date); text-shadow: 0 0 2px var(--paper), 0 0 3px var(--paper); }
@media (max-width: 700px) {
  .stamp { top: 12px; right: 8px; padding: 1px 8px 2px; border-width: 4px; border-radius: 9px; }
  .stamp-word { font-size: 17px; letter-spacing: 1px; }
  :root[data-theme="modern"] .stamp, :root[data-theme="dark"] .stamp { top: 28px; left: 6px; right: auto; } /* clear of the Undo and Redo row above the tape: the rotated box rises about 18px above its top */
  :root[data-theme="classic"] .stamp, :root[data-theme="classic"] .stamp[data-kind="REVIEWED"] { top: 10px; left: 6px; right: auto; } /* Classic: over the line numbers and the blank left of the amounts, so no figure is under it */
  .stamp-date { font-size: 12px; margin-top: 1px; text-shadow: 0 0 1px var(--paper); }
}

/* the dialog: four buttons that look like their stamp */
.stamp-dialog { max-width: min(92vw, 460px); }
.stamp-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; margin: 14px 0 12px; }
:root:root dialog button.stamp-btn { display: flex; align-items: center; justify-content: center; min-height: 68px; padding: 6px 8px; background: var(--paper); color: var(--stamp-ink, var(--ink)); border: 6px double currentColor; border-radius: 12px; transform: rotate(-3deg); box-shadow: none; }
:root:root dialog button.stamp-btn:nth-child(even) { transform: rotate(2deg); }
:root:root dialog button.stamp-btn:hover { background: var(--accent-soft); border-color: currentColor; }
dialog button.stamp-btn .stamp-word { color: inherit; font-size: clamp(20px, 1.9vw, 26px); letter-spacing: 2px; }
dialog button.stamp-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
dialog button.stamp-btn[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent); }

/* the odometer dialog: three mechanical counters (dark wheel cells, light digits, tabular figures, fixed digit counts with leading zeros) */
.odo-dialog { max-width: min(92vw, 520px); max-height: calc(100dvh - 40px); overflow-y: auto; overflow-x: hidden; }
.odo-rows { display: grid; gap: 14px; margin: 12px 0 10px; }
.odo-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 14px; }
.odo-label { font: 700 18px/1.3 var(--sans); }
.odo-wheels { display: inline-flex; max-width: 100%; gap: 2px; padding: 4px; background: #0b0b0b; border-radius: 6px; box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .4); }
.odo-cell { display: inline-block; width: 24px; height: 36px; text-align: center; font: 700 24px/36px var(--mono); font-variant-numeric: tabular-nums; color: #f6f2e4; background-color: #1c1c1c; background-image: linear-gradient(#000 0, rgba(0, 0, 0, 0) 24%, rgba(0, 0, 0, 0) 76%, #000 100%); border-radius: 3px; }
.odo-feet { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 12px; min-width: 0; }
@media (max-width: 700px) { .odo-feet { justify-content: flex-start; } }
.odo-text { font: 700 18px/1.3 var(--sans); overflow-wrap: anywhere; }
.odo-note { margin: 0 0 6px; font-size: 16px; color: var(--muted); }
.odo-ask { margin: 8px 0 0; padding: 10px 12px; border: 2px solid var(--neg); border-radius: 10px; }
.odo-ask[hidden], #odoReset[hidden] { display: none; }
.odo-ask p { margin: 0 0 8px; font: 700 18px/1.3 var(--sans); }
.odo-ask-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.odo-dialog .dlg-actions { flex-wrap: wrap; }
@media print { .odo-dialog { display: none !important; } }

/* the tape as a picture: a preview of the PNG that scrolls inside the dialog; text 16px and up, buttons 44px, nothing wider than the phone */
.pic-dialog { max-width: min(94vw, 680px); width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; overflow-x: hidden; display: none; }
.pic-dialog[open] { display: flex; flex-direction: column; }
.pic-dialog p { margin: 6px 0; font-size: 16px; line-height: 1.4; }
.pic-note { font-weight: 700; padding: 8px 10px; border: 2px solid var(--key-edge); border-radius: 8px; background: var(--paper); }
.pic-wrap { flex: 1 1 auto; min-height: 120px; max-height: min(58dvh, 560px); overflow: auto; border: 1px solid var(--rule); border-radius: 8px; background: #cfcbc1; padding: 8px; }
.pic-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pic-wrap img { display: block; width: 100%; height: auto; border-radius: 2px; }
.pic-wrap:has(img[hidden]) { display: none; }
.pic-msg { min-height: 1.4em; font-weight: 600; }
.pic-dialog .dlg-actions { flex-wrap: wrap; }
.pic-dialog .dlg-actions button[hidden], .pic-dialog p[hidden] { display: none; }
.pic-dialog button:disabled { opacity: .55; cursor: default; }
@media (max-width: 700px) { .pic-dialog .dlg-actions button { flex: 1 1 100%; } }
@media print { .pic-dialog { display: none !important; } }

/* pencil marks: graphite, hand drawn, an SVG only on a marked row. The tick is in the operator cell (right of the symbol), the circle in the amount cell (round the figure) */
.row.pt .op, .row.pc .amt { overflow: visible; position: relative; }
.pm { position: absolute; display: block; overflow: visible; pointer-events: none; }
.pm path { fill: none; stroke: var(--pencil); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pm-tick { left: 100%; top: 50%; width: 15px; height: 15px; margin: -9px 0 0 1px; }
.pm-circle { right: -9px; top: 50%; height: 1.5em; transform: translateY(-50%); max-width: calc(100% + 10px); } /* never wider than the cell plus its overhang: a seven-figure amount that fills the cell must not push the ellipse over the line number */
.pm-circle path { vector-effect: non-scaling-stroke; stroke-width: 1.6; }
@media (max-width: 700px) { .pm-tick { left: auto; right: 0; width: 9px; height: 9px; margin: -5px 0 0 0; } .pm-tick path { stroke-width: 2.6; } .pm-circle { right: -6px; max-width: calc(100% + 6px); } } /* on a phone the tick sits inside the operator cell, so it never reaches into a full-width amount */

/* pencil mode, the button and the selection buttons */
.pencil-btn { margin-left: auto; }
.pencil-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
:root[data-theme="classic"] .pencil-btn[aria-pressed="true"] { background: linear-gradient(#cfd9ea, #dce6f4); border-color: var(--accent); }
.tape-panel.pencil-on .tape, .tape-panel.pencil-on .row { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z' fill='%23fff' stroke='%23222' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") 3 21, crosshair; }
.sel-marks { display: flex; gap: 6px; margin-top: 4px; }
.sel-marks[hidden] { display: none; }
.sel-mark { min-height: 30px; padding: 2px 12px; border: 1px solid var(--key-edge); border-radius: 6px; background: var(--key); color: var(--key-ink); font: 600 14px var(--sans); cursor: pointer; }
.sel-mark:hover { border-color: var(--accent); }
.sel-mark[aria-pressed="true"], .row .acts button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (max-width: 700px) {
  .row .acts { gap: 4px; }
  .row .acts button { padding: 4px 6px; font-size: 14px; } /* five buttons now (Tick and Circle): they must stay inside a 360px paper */
  .sel-marks { display: none; }
  .tape-top { gap: 4px; }
  .pencil-btn { margin-left: 0; padding: 0 7px; min-width: 0; } /* icon only on a phone: the word stays for screen readers */
  .pencil-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* 380px and narrower (a 360px phone in Classic with both chips under the paper): there is no room left for it without costing the paper a row, so it is hidden; the line editor's Tick and Circle remain */
@media (max-width: 380px) { .pencil-btn { display: none; } }
@media print {
  .sel-marks, .pencil-btn, .stamp-dialog { display: none !important; }
  :root:root:root { --stamp-paid: #14572c; --stamp-reviewed: #173f82; --stamp-void: #9b1c14; --stamp-draft: #444a52; --pencil: #222; }
  .tape { position: relative; }
  .stamp-wrap { position: absolute; top: 0; right: 0; left: auto; width: 100%; height: 0; }
  .stamp { top: 22px; right: 10px; }
}
