/* =====================================================================
   Puzzle Desk — a detective's desk.
   Wood desktop under a desk lamp, a ruled ledger book, a manila case folder
   for the pinned clue, typewriter type, red rubber stamps, steel paperclips.

   Mobile-first like admin.css: base rules are a phone; wider layouts are
   added with min-width queries only (700px tablet, 1000px desk).
   Marks never rely on colour alone (spec §16): crossed = strike line + ✕,
   held = paperclip + dotted underline, the tool = icon + label + page border.
   ===================================================================== */

:root {
    --wood-1: #5b3a20;
    --wood-2: #6d4626;
    --wood-3: #43291a;
    --wood-dark: #2a190e;
    --leather: #3b2414;
    --brass: #c9a25f;
    --brass-dark: #8a6a35;
    --paper: #f5eedb;
    --paper-2: #ece2c6;
    --rule: #b9cde0;
    --margin: #c8553d;
    --manila: #e3c98f;
    --manila-2: #d4b473;
    --manila-edge: #a8874a;
    --ink: #1e1914;
    --ink-soft: #51463a;
    --red-ink: #a32a1d;
    --stamp: #b3261e;
    --steel: #59656f;
    --ok: #2f6b3a;
    --focus: #1d5fd1;

    --type: 'Special Elite', 'Courier Prime', 'Courier New', monospace;
    --mono: 'Courier Prime', 'Courier New', monospace;

    --ts: 1;              /* text size step (Settings): 1 / 1.15 / 1.3 / 1.5 */
    --row-base: 44px;     /* a ledger line; tap targets ≥ 44 px on touch */
    --nm-base: 15px;
    --row: calc(var(--row-base) * var(--ts));
    --nm-size: calc(var(--nm-base) * var(--ts));
    --col: 96px;          /* narrowest ledger column (desk.js widens it to fit the names) */
    --radius: 6px;
    --shadow: 0 2px 0 rgba(0,0,0,.18), 0 8px 22px rgba(0,0,0,.35);
}
@media (pointer: fine) {
    :root { --row-base: 34px; }
}
@media (min-width: 700px) {
    :root { --nm-base: 16px; }
}
html.ts-1 { --ts: 1.15; }
html.ts-2 { --ts: 1.3; }
html.ts-3 { --ts: 1.5; }
/* Panels and bars scale with the text size too. */
html.ts-1 .cluebar, html.ts-1 .sheet__card, html.ts-1 .dlg__card, html.ts-1 .banner, html.ts-1 .toast,
html.ts-1 .nudge, html.ts-1 .coach { zoom: 1.15; }
html.ts-2 .cluebar, html.ts-2 .sheet__card, html.ts-2 .dlg__card, html.ts-2 .banner, html.ts-2 .toast,
html.ts-2 .nudge, html.ts-2 .coach { zoom: 1.3; }
html.ts-3 .cluebar, html.ts-3 .sheet__card, html.ts-3 .dlg__card, html.ts-3 .banner, html.ts-3 .toast,
html.ts-3 .nudge, html.ts-3 .coach { zoom: 1.5; }

/* High contrast (Settings): black on white paper, strong borders, a plain dark desk. */
html.hc {
    --paper: #ffffff; --paper-2: #f0f0f0; --rule: #5d7f9f; --margin: #b0000d;
    --manila: #fff4d6; --manila-2: #fff4d6; --manila-edge: #000;
    --ink: #000; --ink-soft: #1a1a1a; --red-ink: #b0000d; --stamp: #a3000b; --steel: #003a66; --ok: #005a14;
}
html.hc body { background: #120b06; }
html.hc .chip, html.hc .pager__btn, html.hc .pager__num, html.hc .tool, html.hc .act { border-color: #fff; color: #fff; background: #000; }
html.hc .tool[aria-checked="true"], html.hc .chip[aria-pressed="true"], html.hc .pager__num[aria-current="page"] { background: #fff; color: #000; }
html.hc .nm.is-stamped { opacity: 1; }
html.hc .book { outline-width: 4px; }
html.hc .cluebar__folder, html.hc .sheet__card, html.hc .dlg__card { border: 2px solid #000; }

/* Reduced motion (Settings, or the device's own setting via "Auto"). */
html.rm *, html.rm *::before, html.rm *::after { animation: none !important; transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    color: var(--ink);
    font: 400 16px/1.45 var(--mono);
    /* The desktop: grain, plank seams, and a lamp's pool of light. */
    background-color: var(--wood-2);
    background-image:
        radial-gradient(ellipse 70% 55% at 50% 18%, rgba(255,214,150,.20), transparent 70%),
        radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, rgba(0,0,0,.45)),
        repeating-linear-gradient(90deg, rgba(0,0,0,.0) 0 230px, rgba(0,0,0,.22) 230px 232px),
        repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 3px, rgba(0,0,0,.035) 3px 7px, rgba(255,255,255,.02) 7px 13px),
        linear-gradient(180deg, var(--wood-1), var(--wood-2) 40%, var(--wood-3));
    background-attachment: fixed;
    -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
    position: absolute; left: 8px; top: -60px; z-index: 50;
    background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: var(--radius);
}
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
kbd {
    display: inline-block; min-width: 1.6em; padding: 0 .35em; border: 1px solid var(--ink-soft);
    border-bottom-width: 2px; border-radius: 4px; background: #fffaf0; font: 700 .85em var(--mono); text-align: center;
}
.noscript { color: #fff; text-align: center; padding: 40px 16px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    min-height: 44px; padding: 8px 16px; border-radius: var(--radius); cursor: pointer;
    border: 2px solid var(--ink); background: var(--paper); font: 400 16px var(--type); letter-spacing: .02em;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--paper { background: var(--paper); }
.btn--paper:hover:not(:disabled) { background: #fffaf0; }
.btn--stamp {
    border-color: var(--stamp); color: #fff; background: var(--stamp);
    text-transform: uppercase; letter-spacing: .08em;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.btn--stamp:hover:not(:disabled) { background: #9a1f18; }
.btn--small { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.btn--wide { width: 100%; }
.chip {
    min-height: 36px; padding: 4px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
    border: 1.5px solid rgba(255,240,210,.55); background: rgba(0,0,0,.18); color: #fbeed3; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.chip[aria-pressed="true"]::before { content: '✓ '; }
.field {
    min-height: 44px; padding: 8px 12px; border-radius: var(--radius);
    border: 2px solid var(--ink-soft); background: #fffdf6; font-size: 16px; /* ≥16px: no iOS zoom */
}
.label { display: block; font: 400 15px var(--type); margin-bottom: 6px; }
.eyebrow { margin: 0; font: 400 13px var(--type); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-soft); }

/* ── Manila folder (entry, clue bar) ─────────────────────────────── */
.folder { position: relative; }
.folder__tab {
    display: inline-block; margin-left: 18px; padding: 6px 18px 4px;
    background: var(--manila-2); border: 1px solid var(--manila-edge); border-bottom: 0;
    border-radius: 10px 10px 0 0; font: 400 13px var(--type); letter-spacing: .16em; text-transform: uppercase;
}
.folder__body {
    background: linear-gradient(180deg, var(--manila), var(--manila-2));
    border: 1px solid var(--manila-edge); border-radius: 4px 10px 10px 10px; box-shadow: var(--shadow);
    padding: 22px 18px;
}

/* ── The code box ────────────────────────────────────────────────── */
.entry { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.folder--entry { width: min(560px, 100%); }
.entry__title { margin: 4px 0 8px; font: 400 40px/1.05 var(--type); letter-spacing: .02em; }
.entry__lede { margin: 0 0 20px; }
.entry__row { display: flex; flex-direction: column; gap: 10px; }
.field--code { width: 100%; font: 700 22px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.entry__error { margin: 10px 0 0; color: var(--red-ink); font-weight: 700; }
.entry__error::before { content: '✗ '; }
.entry__cases { margin-top: 26px; border-top: 2px dashed var(--manila-edge); padding-top: 14px; }
.entry__h2 { margin: 0 0 8px; font: 400 18px var(--type); }
.entry__cases ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.entry__cases a:not(.btn) {
    display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; padding: 8px 12px;
    background: var(--paper); border: 1px solid var(--manila-edge); border-radius: var(--radius); color: var(--ink); text-decoration: none;
}
.entry__cases a:not(.btn):hover { background: #fffaf0; }
.entry__cases small { color: var(--ink-soft); }
@media (min-width: 560px) {
    .entry__row { flex-direction: row; }
    .folder__body { padding: 30px 32px; }
}

/* ── The desk layout: one screen, nothing scrolls ────────────────── */
.desk {
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    padding: 0 0 env(safe-area-inset-bottom);
}

.topbar {
    flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 8px 12px; color: #fbeed3;
    background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.12));
    border-bottom: 1px solid rgba(0,0,0,.4);
}
.topbar__brand {
    color: var(--wood-dark); text-decoration: none; font: 400 13px var(--type); letter-spacing: .14em; text-transform: uppercase;
    padding: 5px 10px; border-radius: 3px;
    background: linear-gradient(180deg, #e7c88a, var(--brass) 55%, var(--brass-dark));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 1px 2px rgba(0,0,0,.5);
}
.topbar { flex-wrap: nowrap; }
.topbar__case {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    margin: 0; font: 400 16px var(--type); white-space: nowrap; text-overflow: ellipsis;
}
.topbar__count { margin: 0 0 0 auto; font-size: 14px; text-align: right; }
.topbar__count strong { font: 700 20px var(--mono); font-variant-numeric: tabular-nums; color: #fff; }
.topbar__held { margin-left: 8px; opacity: .9; }
@media (min-width: 700px) {
    .topbar { padding: 10px 18px; }
    .topbar__case { position: static; width: auto; height: auto; clip: auto; overflow: hidden; flex: 1 1 0; min-width: 0; font-size: 19px; }
    .topbar__count { flex: none; margin: 0; font-size: 15px; }
    .topbar__count strong { font-size: 22px; }
}

/* ── The pinned clue bar: a case folder pinned at the top ────────── */
.cluebar { flex: none; position: relative; z-index: 20; padding: 6px 8px 0; }
.cluebar__folder {
    background: linear-gradient(180deg, var(--manila), var(--manila-2));
    border: 1px solid var(--manila-edge); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.cluebar__head {
    display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px;
    background: none; border: 0; cursor: pointer; text-align: left;
}
.cluebar__num {
    flex: none; font: 400 13px var(--type); letter-spacing: .12em; text-transform: uppercase;
    color: var(--red-ink); border: 2px solid var(--red-ink); border-radius: 3px; padding: 1px 6px; transform: rotate(-2deg);
}
.cluebar__title { flex: 1; min-width: 0; font: 400 17px var(--type); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cluebar__chev::after { content: '▾'; font-size: 18px; }
.cluebar__head[aria-expanded="true"] .cluebar__chev::after { content: '▴'; }
/* Collapsed on a phone: the full clue opens over the ledger, so nothing reflows. */
.cluebar__more {
    display: none; position: absolute; left: 8px; right: 8px; top: calc(100% - 2px);
    padding: 4px 14px 14px; max-height: 70vh; overflow: auto;
    background: var(--manila-2); border: 1px solid var(--manila-edge); border-top: 0;
    border-radius: 0 0 8px 8px; box-shadow: 0 10px 20px rgba(0,0,0,.4);
}
.cluebar.is-open .cluebar__more { display: block; }
.cluebar__text { margin: 4px 0 12px; font-size: 17px; }
.cluebar__actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Assistance: Check clue + Ledger check, set apart as one labelled group. */
.assist {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 100%;
    padding: 6px 8px; border: 1px dashed var(--ink-soft); border-radius: 4px;
}
.assist__note { font: 400 13px var(--type); flex: 1 1 100%; }
.assist__label {font: 700 12px var(--type); letter-spacing: .08em; text-transform: uppercase; margin-right: 2px; }
.cluebar__review {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0;
    padding: 6px 10px; background: var(--paper); border: 1px dashed var(--ink-soft); border-radius: 4px; font-weight: 700;
}
.cluestrip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cluestrip:empty { display: none; }
.cluestrip button {
    min-height: 36px; min-width: 44px; padding: 2px 10px; cursor: pointer; border-radius: 3px;
    border: 1px solid var(--manila-edge); background: var(--paper); font: 400 14px var(--type);
}
.cluestrip button.is-cleared::before { content: '✓ '; color: var(--ok); }
.cluestrip button.is-active::before { content: '● '; color: var(--red-ink); }
.cluestrip button[aria-current="true"] { background: var(--ink); color: var(--paper); }
.cluestrip button[aria-current="true"]::after { content: ' 📌'; }
/* The pin on the bar; it tilts when a cleared clue is pinned instead of the active one. */
.cluebar__pin { flex: none; font-size: 15px; line-height: 1; }
.cluebar.is-pinned-back .cluebar__pin { display: inline-block; transform: rotate(-25deg); }
.cluebar.is-pinned-back .cluebar__folder { outline: 2px dashed var(--ink-soft); outline-offset: -4px; }
/* All clues */
.clues__intro { margin: 4px 0 12px; font-size: 15px; color: var(--ink-soft); }
.clues__item { padding: 10px 12px; margin: 0 0 10px; background: #fffdf6; border: 1px solid var(--paper-2); border-radius: 4px; }
.clues__item.is-active { border: 2px solid var(--red-ink); }
.clues__item.is-pinned { box-shadow: 0 0 0 3px var(--ink) inset; }
.clues__item.is-locked { background: transparent; border-style: dashed; color: var(--ink-soft); }
.clues__h { margin: 0 0 4px; font: 400 17px var(--type); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.clues__n { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.clues__st { margin-left: auto; font-family: var(--mono); font-size: 13px; }
.clues__text { margin: 0 0 8px; font-size: 16px; }
.clues__lock { margin: 0; font-size: 15px; }
.clues__row { display: flex; flex-wrap: wrap; gap: 8px; }
.clues__row .btn { min-height: 44px; }
.cluebar.is-done .cluebar__num { color: var(--ok); border-color: var(--ok); }
@media (min-width: 1000px) and (min-height: 600px) {
    html:not(.ts-2):not(.ts-3) .cluebar { padding: 8px 18px 0; }
    /* On a desk there is room: the whole clue shows, pinned in place. */
    html:not(.ts-2):not(.ts-3) .cluebar__more { display: block; position: static; box-shadow: none; border: 0; background: none; max-height: none; padding-top: 0; }
    html:not(.ts-2):not(.ts-3) .cluebar__chev { display: none; }
    html:not(.ts-2):not(.ts-3) .cluebar__head { cursor: default; padding-bottom: 2px; }
    html:not(.ts-2):not(.ts-3) .cluebar__text { margin-bottom: 8px; }
    html:not(.ts-2):not(.ts-3) .cluebar__actions, html:not(.ts-2):not(.ts-3) .cluestrip { margin-top: 0; }
    html:not(.ts-2):not(.ts-3) .cluebar__more { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 4px 16px; align-items: start; }
    html:not(.ts-2):not(.ts-3) .cluebar__review, html:not(.ts-2):not(.ts-3) .cluebar__text { grid-column: 1; }
    html:not(.ts-2):not(.ts-3) .cluebar__actions { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; }
    html:not(.ts-2):not(.ts-3) .cluestrip { grid-column: 1 / -1; margin-top: 2px; }
}

/* ── The ledger ──────────────────────────────────────────────────── */
.ledgerwrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 8px 8px 0; }
.ledgerbar { flex: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.tabs { display: flex; flex-wrap: nowrap; gap: 3px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: none; min-width: 34px; min-height: 36px; padding: 0 6px; cursor: pointer;
    border: 1px solid rgba(0,0,0,.35); border-bottom: 0; border-radius: 6px 6px 0 0;
    background: var(--paper-2); font: 700 14px var(--mono);
}
.tab[aria-pressed="true"] { background: var(--paper); box-shadow: inset 0 3px 0 var(--red-ink); }
.tab:disabled { opacity: .38; cursor: default; }
.ledgerbar__right { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; align-items: center; }
.ledgerbar__right::-webkit-scrollbar { display: none; }
@media (min-width: 700px) { .ledgerbar__right { flex-wrap: wrap; overflow: visible; } }
.search { flex: 0 0 130px; }
@media (min-width: 700px) { .search { flex: 1 1 160px; } }
.field--search { width: 100%; min-height: 36px; padding: 4px 10px; }
@media (min-width: 1000px) {
    .ledgerwrap { padding: 8px 18px 0; }
    .search { flex: 0 1 220px; }
}

/* The ledger book: ruled paper, a red margin line, a spine shadow. */
.book {
    position: relative; flex: 1 1 auto; min-height: 0;
    padding: 6px 4px 6px 22px; border-radius: 2px 6px 6px 2px;
    background:
        linear-gradient(90deg, transparent 17px, var(--margin) 17px 19px, transparent 19px),
        linear-gradient(90deg, rgba(0,0,0,.16), transparent 14px),
        var(--paper);
    box-shadow: var(--shadow), inset 0 0 0 3px transparent;
    outline: 3px solid transparent; outline-offset: -3px;
}
.book[data-tool="cross"] { outline-color: var(--red-ink); cursor: crosshair; }
.book[data-tool="hold"]  { outline-color: var(--steel); }
.book__badge {
    position: absolute; right: 8px; top: -12px; z-index: 2; padding: 1px 10px;
    font: 400 12px var(--type); letter-spacing: .12em; text-transform: uppercase;
    background: var(--ink); color: var(--paper); border-radius: 3px;
}
.book[data-tool="cross"] .book__badge { background: var(--red-ink); }
.book[data-tool="hold"] .book__badge { background: var(--steel); }
.book__empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; font: 400 18px var(--type); color: var(--ink-soft); }

.ledger {
    height: 100%; display: grid; gap: 0 6px;
    grid-auto-flow: column;                 /* read down each column, like a ledger */
    grid-template-rows: repeat(var(--rows, 10), var(--row));
    grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
    background-image: repeating-linear-gradient(180deg, transparent 0 calc(var(--row) - 1px), var(--rule) calc(var(--row) - 1px) var(--row));
    outline: none;
}
.ledger.is-sweeping, .book[data-tool="cross"] .ledger, .book[data-tool="hold"] .ledger { touch-action: none; }

.nm {
    position: relative; display: flex; align-items: center; gap: 4px; min-width: 0; height: var(--row);
    padding: 0 2px 0 20px; margin: 0; border: 0; background: none; cursor: pointer; text-align: left;
    font: 400 var(--nm-size) var(--mono); color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.nm__t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm::before { /* the mark slot, left of the name */
    position: absolute; left: 2px; width: 18px; text-align: center; font-weight: 700;
}
.nm:hover { background: rgba(255,240,200,.7); }
.nm:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }
.nm.is-held .nm__t { text-decoration: underline dotted 2px var(--steel); text-underline-offset: 4px; }
.nm.is-held::before {
    content: ''; top: 50%; height: 22px; margin-top: -12px;
    background: no-repeat center / 14px 22px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 24'%3E%3Cpath d='M4 6v11a3 3 0 0 0 6 0V4.5a2 2 0 0 0-4 0V16a1 1 0 0 0 2 0V7' fill='none' stroke='%2359656f' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.nm.is-out { color: var(--ink-soft); }
.nm.is-out .nm__t {
    text-decoration: line-through 2px var(--red-ink);
}
.nm.is-out::before { content: '✕'; color: var(--red-ink); }
.nm.is-stamped { opacity: .55; }
.nm.is-flash { animation: flash .9s ease-out both; }
@keyframes flash {
    0% { background: rgba(179,38,30,.0); }
    30% { background: rgba(179,38,30,.22); }
    100% { background: rgba(179,38,30,0); }
}
.nm.is-sel { box-shadow: inset 0 0 0 2px var(--ink); }

/* ── Pager ───────────────────────────────────────────────────────── */
.pager {
    flex: none; display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: nowrap;
    padding: 6px 0; color: #fbeed3;
}
.pager__btn, .pager__num { white-space: nowrap;
    min-width: 44px; min-height: 40px; padding: 0 10px; cursor: pointer; border-radius: var(--radius);
    border: 1px solid rgba(255,240,210,.45); background: rgba(0,0,0,.22); color: #fbeed3;
}
.pager__btn:disabled { opacity: .4; cursor: default; }
.pager__num[aria-current="page"] { background: var(--paper); color: var(--ink); font-weight: 700; }
.pager__nums { display: none; gap: 4px; }
.pager__gap { padding: 0 4px; align-self: center; }
.pager__go { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0 4px; white-space: nowrap; }
.field--page { width: 58px; min-height: 40px; padding: 4px 6px; }
@media (min-width: 700px) { .pager__go { font-size: 14px; } .field--page { width: 74px; } }
.pager__btn--last { display: none; }
@media (min-width: 700px) {
    .pager__nums { display: flex; }
    .pager__btn--last { display: inline-block; }
}

/* ── Toolbar: a leather strip along the front edge of the desk ───── */
.toolbar {
    flex: none; display: flex; gap: 6px; justify-content: space-between; align-items: stretch;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #4a2e1a, var(--leather));
    border-top: 2px solid rgba(0,0,0,.45); box-shadow: 0 -4px 14px rgba(0,0,0,.35);
}
.toolbar__tools, .toolbar__acts { display: flex; gap: 4px; flex: 1 1 0; min-width: 0; }
.tool, .act {
    flex: 1 1 0; min-width: 0; min-height: 52px; padding: 4px 2px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border-radius: var(--radius); border: 1.5px solid rgba(255,240,210,.25);
    background: rgba(255,255,255,.06); color: #fbeed3; font: 400 12px var(--type); letter-spacing: 0;
}
.tool__icon { font: 700 18px/1 var(--mono); display: grid; place-items: center; height: 20px; }
.tool[aria-checked="true"] {
    background: var(--paper); color: var(--ink); border-color: var(--brass);
    box-shadow: 0 0 0 2px var(--brass), inset 0 -3px 0 var(--red-ink);
}
.tool--hold[aria-checked="true"] { box-shadow: 0 0 0 2px var(--brass), inset 0 -3px 0 var(--steel); }
.tool--examine[aria-checked="true"] { box-shadow: 0 0 0 2px var(--brass), inset 0 -3px 0 var(--ink); }
.act:disabled { opacity: .4; cursor: default; }
.act--stamp { background: var(--stamp); border-color: #e7a19b; color: #fff; text-transform: uppercase; letter-spacing: .1em; }
@media (min-width: 700px) {
    .toolbar { justify-content: center; gap: 28px; padding: 8px 18px calc(8px + env(safe-area-inset-bottom)); }
    .toolbar__tools, .toolbar__acts { flex: none; }
    .tool, .act { flex: none; min-width: 84px; padding: 4px 10px; flex-direction: row; gap: 8px; font-size: 15px; }
}

/* ── The Stamp panel: a sheet on a phone, a side drawer on a desk ── */
.sheet {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 78vh; max-height: 78dvh;
    display: flex; flex-direction: column;
}
.sheet__card {
    display: flex; flex-direction: column; min-height: 0; max-height: 78vh; max-height: 78dvh;   /* dvh: the screen a phone actually shows, so the ✕ never ends up off the top */
    background: var(--paper); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.5);
    border-top: 6px solid var(--stamp);
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 4px; }
.sheet__title { margin: 0; font: 400 20px var(--type); }
.sheet__close, .dlg__x {
    min-width: 44px; min-height: 44px; border: 0; background: none; cursor: pointer; font-size: 20px;
}
.sheet__body { overflow: auto; padding: 0 14px 18px; }
@media (min-width: 1000px) {
    .sheet { left: auto; top: 0; width: 400px; max-height: none; padding: 12px 12px 12px 0; }
    .sheet__card { max-height: none; height: 100%; border-radius: 10px; border-top: 0; border-left: 6px solid var(--stamp); }
    body.has-sheet .desk { margin-right: 412px; }
}
.stamp__tool { margin: 0; font: 400 18px var(--type); }
.stamp__tool::before { content: '⌖ '; color: var(--red-ink); }
.stamp__about { margin: 2px 0 12px; color: var(--ink-soft); }
.stamp__sentence {
    padding: 14px; line-height: 2.6; font-size: 17px;
    background: #fffdf6; border: 1px solid var(--paper-2); border-left: 4px solid var(--red-ink);
}
.stamp__sentence select, .stamp__sentence input {
    min-height: 40px; padding: 4px 6px; margin: 0 2px; vertical-align: middle;
    border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; background: #fff6dc; font: 700 17px var(--mono);
}
.stamp__sentence input[type="number"] { width: 4.6em; }
.stamp__sentence input.is-letter { width: 2.4em; text-align: center; text-transform: uppercase; }
.stamp__sentence input.is-word { width: 8em; }
.stamp__sentence input.is-stencil { width: 9em; letter-spacing: .12em; }
.stamp__sentence input.is-pos { width: 5.5em; }
.stamp__hint { display: block; line-height: 1.4; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.stamp__check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 6px; }
.stamp__check input { width: 22px; height: 22px; }
.stamp__problem { min-height: 1.4em; margin: 8px 0; color: var(--red-ink); font-weight: 700; }
.tray__head { margin: 14px 0 6px; font: 400 15px var(--type); letter-spacing: .1em; text-transform: uppercase; }
.tray__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.tray__list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: #fffdf6; border: 1px solid var(--paper-2); }
.tray__res { font-weight: 700; white-space: nowrap; }
.tray__res.is-clear { color: var(--red-ink); }
.tray__res.is-keep { color: var(--ok); }
.preview__text { margin: 0; }
.preview__warn { margin: 8px 0 0; padding: 8px 10px; border: 2px solid var(--red-ink); border-radius: 4px; font-weight: 700; }
.preview__warn::before { content: '⚠ '; }
#doStamp { margin-top: 16px; }
.stamplog__list { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.stamplog__list li { padding: 4px 0; }
.stamplog__list button { margin-left: 8px; }
.stamplog__list .is-undone { text-decoration: line-through; color: var(--ink-soft); }

/* ── Dialogs ─────────────────────────────────────────────────────── */
.dlg { padding: 0; border: 0; background: none; max-width: min(560px, calc(100vw - 24px)); width: 100%; }
.dlg::backdrop { background: rgba(20,10,4,.6); }
.dlg__card {
    position: relative; margin: 0; padding: 22px 18px 18px; max-height: calc(100dvh - 40px); overflow: auto;
    background: var(--paper); border-radius: 8px; box-shadow: var(--shadow);
}
.dlg__card--file { background: linear-gradient(180deg, var(--manila), var(--manila-2)); border: 1px solid var(--manila-edge); margin-top: 26px; overflow: visible; max-height: none; }
/* The file card can't scroll itself (overflow is visible so its tab shows above
   it), so it has no height cap: a tall file (My totals open on a phone) grows
   the card and the dialog around it scrolls. With the cap, the content ran on
   past the card's background. */
.dlg:has(> .dlg__card--file) { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
.dlg__tab {
    position: absolute; left: 18px; top: -27px; padding: 4px 16px; background: var(--manila);
    border: 1px solid var(--manila-edge); border-bottom: 0; border-radius: 8px 8px 0 0;
    font: 400 12px var(--type); letter-spacing: .16em; text-transform: uppercase;
}
.dlg__x { position: absolute; right: 4px; top: 4px; }
.dlg__title { margin: 0 34px 10px 0; font: 400 24px/1.2 var(--type); }
.dlg__name { margin: 0 34px 2px 0; font: 700 28px/1.15 var(--mono); word-break: break-word; }
.dlg__state { margin: 0 0 14px; font: 400 14px var(--type); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.dlg__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--manila-edge); }
.facts dt { font: 400 14px var(--type); color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 700; word-break: break-word; }
.facts__letters { display: flex; flex-wrap: wrap; gap: 4px; }
.facts__letters span { display: inline-grid; justify-items: center; min-width: 24px; padding: 2px 3px; border: 1px solid var(--paper-2); background: #fffdf6; line-height: 1.1; }
.facts__letters small { font-size: 11px; font-weight: 400; color: var(--ink-soft); }
.acclues { border: 0; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.acclues label { display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 4px 10px; background: #fffdf6; border: 1px solid var(--paper-2); cursor: pointer; }
.acclues input { width: 20px; height: 20px; }
.paper__body { font-size: 17px; }
.paper__body p:first-child { margin-top: 0; }
/* An exhibit: the impression itself is an h3 (the sanitizer keeps no style
   attributes), centred like a stamp on the page; notes under it in italics. */
.paper__body--exhibit { text-align: center; }
.paper__body--exhibit h3 { margin: 8px 0 14px; font-family: var(--mono, ui-monospace, Consolas, monospace); font-size: clamp(24px, 7vw, 38px); letter-spacing: .14em; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.paper__body--exhibit p { margin: 8px 0; }
.dlg__card--paper {
    background:
        repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px),
        var(--paper);
    background-position: 0 70px;
}
.dlg__card--help h3 { margin: 18px 0 6px; font: 400 18px var(--type); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.keys dd { margin: 0; }
.help__mail { margin-top: 18px; }

/* ── Stamp animation, banner, toast ──────────────────────────────── */
.stampfx {
    position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none; opacity: 0;
}
.stampfx span {
    font: 400 clamp(44px, 12vw, 110px) var(--type); color: var(--stamp); letter-spacing: .1em; text-transform: uppercase;
    border: 8px double var(--stamp); border-radius: 12px; padding: 4px 28px; transform: rotate(-10deg);
    mix-blend-mode: multiply; background: rgba(255,255,255,.08);
}
.stampfx.is-on { animation: stampdown .9s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes stampdown {
    0% { opacity: 0; transform: scale(1.8); }
    25% { opacity: .95; transform: scale(1); }
    75% { opacity: .9; }
    100% { opacity: 0; }
}
.banner {
    position: fixed; z-index: 55; left: 50%; top: 84px; transform: translateX(-50%); max-width: calc(100vw - 24px);
    padding: 12px 20px; background: var(--paper); border: 3px solid var(--ink); border-radius: 6px; box-shadow: var(--shadow);
    font: 400 18px var(--type); text-align: center;
}
.banner.is-pass { border-color: var(--ok); }
.banner.is-pass::before { content: '✓ '; color: var(--ok); }
.banner.is-fail { border-color: var(--red-ink); }
.banner.is-fail::before { content: '✗ '; color: var(--red-ink); }
.banner small { display: block; margin-top: 4px; font: 400 15px/1.4 var(--mono); }
.banner .btn { margin-top: 10px; }
.toast {
    position: fixed; z-index: 55; left: 50%; bottom: 128px; transform: translateX(-50%); max-width: calc(100vw - 24px);
    pointer-events: none;   /* taps go through to the names under it; only Undo takes them */
    width: max-content;     /* one line: a wrapped toast covers more of the ledger */
    display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px;
    background: var(--ink); color: var(--paper); border-radius: 999px; box-shadow: var(--shadow);
}
.toast__btn { pointer-events: auto; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--paper); background: none; color: var(--paper); cursor: pointer; }

body.is-loading .desk { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    .stampfx.is-on { animation: none; }
    .nm.is-flash { animation: none; background: rgba(179,38,30,.15); }
}

/* ── Step 3: player support ──────────────────────────────────────── */
.probe { position: absolute; visibility: hidden; height: var(--row); font-size: var(--nm-size); width: 1px; pointer-events: none; }
.topbar__gear {
    flex: none; min-width: 44px; min-height: 40px; border: 1px solid rgba(255,240,210,.35); border-radius: var(--radius);
    background: rgba(0,0,0,.2); color: #fbeed3; font-size: 20px; cursor: pointer;
}
.nm.has-note .nm__t::after { content: ' ✎'; font-size: .8em; color: var(--steel); }

/* Toolbar: on a phone the extras live in More. */
.act--extra { display: none; }
.act--more { display: flex; }
@media (min-width: 900px) {
    .act--extra { display: flex; }
    .act--extra[hidden] { display: none; }
    .act--more { display: none; }
}
.moremenu {
    position: fixed; z-index: 45; right: 8px; bottom: calc(70px + env(safe-area-inset-bottom));
    display: grid; min-width: 200px; padding: 6px; border-radius: 8px;
    background: var(--paper); box-shadow: var(--shadow); border: 1px solid var(--manila-edge);
}
.moremenu button { min-height: 44px; padding: 0 14px; text-align: left; border: 0; background: none; cursor: pointer; font: 400 16px var(--type); }
.moremenu button:hover { background: var(--paper-2); }
.chip--list { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.chip--list::after { content: '  ✕'; }

/* The Lead nudge: a pulsing ring + a dot, and a bubble that never takes focus. */
[data-lead].is-nudging { position: relative; box-shadow: 0 0 0 3px var(--brass); animation: nudgepulse 1.6s ease-in-out infinite; }
[data-lead].is-nudging::after {
    content: ''; position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--red-ink); border: 2px solid #fff;
}
@keyframes nudgepulse { 0%, 100% { box-shadow: 0 0 0 3px var(--brass); } 50% { box-shadow: 0 0 0 8px rgba(201,162,95,.25); } }
.nudge {
    position: fixed; z-index: 52; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); width: min(340px, calc(100vw - 16px));
    padding: 12px 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow);
}
.nudge__text { margin: 0 30px 10px 0; }
.nudge__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.nudge__x { position: absolute; right: 2px; top: 2px; min-width: 40px; min-height: 40px; border: 0; background: none; cursor: pointer; font-size: 18px; }

/* Leads */
.leads { display: grid; gap: 12px; margin-top: 10px; }
.lead { padding: 12px 14px; background: #fffdf6; border: 1px solid var(--paper-2); border-left: 4px solid var(--brass-dark); }
.lead__h { margin: 0; font: 400 19px var(--type); }
.lead__about { margin: 2px 0 8px; color: var(--ink-soft); font-size: 15px; }
.lead__text { font-size: 17px; margin-bottom: 6px; }
.lead__text:empty { display: none; }
.lead.is-viewed .lead__h::after { content: '  ✓ viewed'; font: 400 13px var(--mono); color: var(--ok); }

/* Reference cards */
.dlg--wide { max-width: min(760px, calc(100vw - 24px)); }
.refs { display: grid; gap: 16px; }
.ref__h { margin: 0 0 6px; font: 400 17px var(--type); letter-spacing: .06em; }
.ref__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; }
.ref__grid span { display: grid; justify-items: center; padding: 4px 0; background: #fffdf6; border: 1px solid var(--paper-2); font: 700 17px var(--mono); }
.ref__grid + .ref__grid { margin-top: 4px; }
.ref__grid small { font: 400 13px var(--mono); color: var(--ink-soft); }
.ref__grid .is-v { background: #f3e4bd; text-decoration: underline; }
.ref__note { margin: 6px 0 0; font-size: 14px; color: var(--ink-soft); }

/* The floating reference card: large screens only (desk.js REF_FLOAT_MQ).
   Above the sheets (40) so it can sit beside the Stamp panel, under the
   nudge and toasts. desk.js sets left/top/width/height. */
.reffloat { display: none; }
@media (min-width: 1024px) {
    .reffloat:not([hidden]) {
        position: fixed; z-index: 42; display: flex; flex-direction: column;
        min-width: 240px; min-height: 180px;
        background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
    }
}
.reffloat.is-moving, .reffloat.is-sizing { user-select: none; opacity: .92; }
.reffloat__bar {
    flex: none; display: flex; align-items: center; gap: 6px; padding: 0 2px 0 4px;
    background: var(--ink); color: var(--paper); cursor: move; touch-action: none;
}
.reffloat__title { flex: 1; margin: 0; font: 400 16px/1 var(--type); letter-spacing: .06em; }
.reffloat__grip, .reffloat__x {
    min-width: 40px; min-height: 40px; border: 0; background: none; color: inherit; cursor: inherit; font-size: 18px;
}
.reffloat__x { cursor: pointer; }
.reffloat__grip:focus-visible, .reffloat__x:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.reffloat__filters { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--paper-2); }
.reffloat__filters[hidden] { display: none; }
.reffloat__chip {
    min-height: 32px; padding: 2px 10px; border: 1px solid var(--ink); border-radius: 999px; cursor: pointer;
    background: #fffdf6; color: var(--ink-soft); font: 400 14px var(--type); text-decoration: line-through;
}
.reffloat__chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); text-decoration: none; }
.reffloat__body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 18px; }
.reffloat__size {
    position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none;
    background: linear-gradient(135deg, transparent 0 50%, var(--ink-soft) 50% 58%, transparent 58% 70%, var(--ink-soft) 70% 78%, transparent 78%);
}

/* Scratchpad + notes */
.padtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.padtabs button { min-height: 36px; padding: 2px 10px; cursor: pointer; border: 1px solid var(--paper-2); background: #fffdf6; border-radius: 4px 4px 0 0; font: 400 14px var(--type); }
.padtabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.padtabs button.has-text::after { content: ' ✎'; }
.pad {
    display: block; width: 100%; min-height: 220px; padding: 10px 12px; resize: vertical;
    font: 400 17px/28px var(--type); color: var(--ink); border: 1px solid var(--paper-2); border-radius: 4px;
    background: repeating-linear-gradient(180deg, #fffdf6 0 27px, var(--rule) 27px 28px); background-attachment: local;
}
.pad.is-mono { font-family: var(--mono); }
.pad--note { min-height: 64px; margin-bottom: 4px; }
.pad__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }
.ex__notelabel { margin-top: 14px; }
/* My totals (Examine): the player's own numbers, folded away until wanted. */
.extotals { margin-top: 12px; border: 1px solid var(--manila-edge); background: var(--paper); }
.extotals summary { min-height: 44px; padding: 10px 14px; cursor: pointer; font-weight: 700; }
.extotals__n { font-weight: 400; color: var(--ink-soft); }
.extotals > .tray__note { margin: 0 14px 8px; }
.extotals__grid { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 0 14px; }
.extotals__f { display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: 10px; font: 400 15px var(--type); }
.extotals__f .field { min-width: 0; width: 100%; min-height: 44px; font-size: 16px; text-align: right; }
.extotals__group { grid-column: 1 / -1; margin: 6px 0 0; font: 700 13px var(--type); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.extotals__group:first-child { margin-top: 0; }
.extotals__row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 12px; }
@media (min-width: 560px) { .extotals__grid { grid-template-columns: 1fr 1fr; gap: 8px 18px; } }
.ex__add { margin-top: 12px; }
.ex__add .field { min-width: 0; flex: 1; }

/* Lists */
.lists__new { margin-bottom: 12px; }
.lists { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.list { padding: 10px 12px; background: #fffdf6; border: 1px solid var(--paper-2); border-left: 4px solid var(--steel); }
.list__top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.list__name { margin: 0; font: 400 18px var(--type); }
.list__btns { display: flex; flex-wrap: wrap; gap: 6px; }
.list__members { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.list__members li { display: flex; align-items: center; gap: 2px; padding: 0 0 0 8px; border: 1px solid var(--paper-2); border-radius: 999px; background: var(--paper); }
.list__members button { min-width: 36px; min-height: 36px; border: 0; background: none; cursor: pointer; }
.list__note { width: 100%; margin-top: 8px; min-height: 40px; font-size: 15px; }
.tray__note { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); }
.tray__mine { display: block; font-size: 13px; color: var(--ink-soft); }

/* Statistics */
.stats h3 { margin: 16px 0 6px; font: 400 15px var(--type); letter-spacing: .1em; text-transform: uppercase; }
.stats h3:first-child { margin-top: 0; }
.stats dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; margin: 0; }
.stats dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.stats__bar { height: 12px; margin: 6px 0 2px; background: var(--paper-2); border: 1px solid var(--ink-soft); }
.stats__bar span { display: block; height: 100%; background: var(--red-ink); }

/* Settings */
.set { border: 1px solid var(--paper-2); border-radius: 6px; margin: 0 0 10px; padding: 8px 12px; }
.set legend { padding: 0 6px; font: 400 16px var(--type); }
.set label { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.set input[type="radio"], .set input[type="checkbox"] { width: 20px; height: 20px; }

/* Help */
.dlg__card--help details { border-top: 1px dashed var(--manila-edge); }
.dlg__card--help summary { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; font: 400 18px var(--type); list-style: none; }
.dlg__card--help summary::-webkit-details-marker { display: none; }
.dlg__card--help summary::before { content: '▸'; color: var(--red-ink); }
.dlg__card--help details[open] > summary::before { content: '▾'; }
.help__btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.help__btns a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.faq dt { margin-top: 10px; font-weight: 700; }
.faq dd { margin: 2px 0 0; }
.checklist { list-style: none; padding: 0; }
.checklist li { display: flex; gap: 8px; align-items: center; min-height: 32px; }
.ck { flex: none; width: 22px; height: 22px; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 700; }
.checklist li.is-done .ck::after { content: '✓'; color: var(--ok); }

/* The practice coach card */
.coach {
    position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); width: min(430px, calc(100vw - 16px));
    padding: 16px 18px 10px; background: var(--paper); border: 3px solid var(--ink); border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.coach.at-top { top: 12px; }
.coach.at-bottom { bottom: calc(82px + env(safe-area-inset-bottom)); }
.coach.at-middle { top: 50%; transform: translate(-50%, -50%); }
.coach__h { margin: 0 0 6px; font: 400 21px var(--type); }
.coach__body p { margin: 0 0 8px; }
.coach__btns { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.coach__skip { min-height: 44px; border: 0; background: none; text-decoration: underline; cursor: pointer; color: var(--ink-soft); }
.coach-hl { outline: 4px solid var(--brass) !important; outline-offset: 2px; }
body.is-practice .dlg::backdrop { background: rgba(20,10,4,.35); }

/* Print my notes */
.printsheet { display: none; }
@media print {
    body { background: #fff !important; }
    body > *:not(.printsheet) { display: none !important; }
    .printsheet { display: block; color: #000; font: 12pt/1.4 'Courier Prime', 'Courier New', monospace; }
    .printsheet h1 { font-size: 18pt; }
    .printsheet h2 { font-size: 14pt; margin-top: 18pt; border-bottom: 1px solid #000; }
    .printsheet pre { white-space: pre-wrap; font: inherit; }
}

@media (min-width: 1000px) {
    body.has-sheet .toolbar { gap: 10px; }
    body.has-sheet .toolbar__tools, body.has-sheet .toolbar__acts { gap: 3px; }
    body.has-sheet .tool, body.has-sheet .act { min-width: 0; padding: 4px 7px; gap: 5px; font-size: 14px; }
}

/* Phone header: brand, count and gear on one line. */
.topbar__brand, .topbar__count { white-space: nowrap; }
@media (max-width: 420px) {
    .topbar { gap: 6px; padding: 6px 8px; }
    .topbar__brand { font-size: 11px; letter-spacing: .08em; padding: 4px 7px; }
    .topbar__count { font-size: 13px; }
    .topbar__gear { min-width: 40px; }
}

/* ── Step 4: accounts and the dashboard ──────────────────────────── */
.home__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.home__account { display: flex; gap: 8px; flex-wrap: wrap; }
.home__rank { margin: -2px 0 14px; font: 400 17px var(--type); }
.home__rank strong { color: var(--red-ink); }
.home__guest { margin: 22px 0 0; padding-top: 14px; border-top: 2px dashed var(--manila-edge); font-size: 15px; }
.linkbtn { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; min-height: 0; }
.cases { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.case {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 56px; padding: 10px 12px;
    background: var(--paper); border: 1px solid var(--manila-edge); border-radius: var(--radius);
}
.case__title { margin: 0; font: 400 17px var(--type); }
.case__meta { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); }
.case .btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.case .btn--stamp { color: #fff; }
.tag { display: inline-block; margin-left: 6px; padding: 0 8px; border: 2px solid currentColor; border-radius: 3px; font: 400 12px var(--type); letter-spacing: .12em; text-transform: uppercase; transform: rotate(-2deg); }
.tag--closed { color: var(--ok); }
.tag--revealed { color: var(--red-ink); }
.tag--new { color: var(--stamp); }
.acct[data-view] { display: none; }
.acct.is-on { display: block; }
.acct .field { width: 100%; margin-bottom: 10px; }
.acct__err { min-height: 1.2em; margin: 6px 0 0; color: var(--red-ink); font-weight: 700; }
.acct__err:empty { display: none; }
.hint { font: 400 13px var(--mono); color: var(--ink-soft); }
.acct__ok { margin: 6px 0 12px; padding: 12px 14px; border-left: 4px solid var(--ok); background: #fffdf6; color: var(--ink); font-weight: 700; }
.topbar__acct {
    display: none; flex: none; min-height: 40px; max-width: 180px; padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border: 1px solid rgba(255,240,210,.35); border-radius: var(--radius); background: rgba(0,0,0,.2); color: #fbeed3; cursor: pointer; font: 400 14px var(--type);
}
@media (min-width: 700px) { .topbar__acct { display: inline-block; } }

/* Save status (2026-11-20): always on screen, phone included. */
.topbar__save {
    flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px;
    border: 1px solid rgba(255,240,210,.35); border-radius: var(--radius); background: rgba(0,0,0,.2);
    color: #fbeed3; cursor: pointer; font: 400 14px var(--type); white-space: nowrap;
}
.topbar__save[hidden] { display: none; }
.topbar__saveicon { display: inline-block; width: 1em; text-align: center; font-weight: 700; }
.topbar__save.is-saved .topbar__saveicon::before { content: '✓'; color: #9fe0a8; }
.topbar__save.is-saving .topbar__saveicon::before { content: '●'; color: #e7c88a; animation: savePulse 1s ease-in-out infinite; }
.topbar__save.is-failed { border-color: #ffb3a8; background: rgba(140,20,10,.55); }
.topbar__save.is-failed .topbar__saveicon::before { content: '!'; color: #fff; }
@keyframes savePulse { 50% { opacity: .35; } }
html.rm .topbar__save.is-saving .topbar__saveicon::before { animation: none; }
html.hc .topbar__save { border-color: #fff; background: #000; color: #fff; }
/* A phone shows the icon alone (✓ / pulsing dot / red !); the words stay in its label. */
@media (max-width: 420px) {
    .topbar__save { min-width: 40px; padding: 0; justify-content: center; font-size: 16px; }
    #saveStateText { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.savedlg__status { font-size: 17px; }
.savebanner {
    position: fixed; z-index: 50; left: 50%; top: 70px; transform: translateX(-50%); width: min(460px, calc(100vw - 16px));
    padding: 12px 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow);
}
.savebanner p { margin: 0 0 8px; }
.savebanner__btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Step 5: the Case Board, the report, the card ────────────────── */
/* The Case Board button sits where the Stamp button was: steel blue, so it
   reads as the way to Threads (and through them, Stamps), not as a stamp. */
.act--board { position: relative; background: #1f4468; border-color: #9fc0de; color: #fff; text-transform: uppercase; letter-spacing: .06em; }
html.hc .act--board { background: #003a66; border-color: #fff; }
.act--board.has-news::after { content: ''; position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red-ink); border: 2px solid #fff; }
.sheet--board .sheet__card {
    border-top-color: var(--red-ink);
    background:
        radial-gradient(circle at 20% 30%, rgba(0,0,0,.06) 0 2px, transparent 3px) 0 0 / 23px 19px,
        radial-gradient(circle at 70% 60%, rgba(255,255,255,.08) 0 2px, transparent 3px) 0 0 / 17px 21px,
        #b98a55;
}
html.hc .sheet--board .sheet__card { background: #fff; }
.sheet--board .sheet__title, .board__sum { color: #2a190e; }
.board__sum { margin: 0 0 8px; font: 400 15px var(--type); }
.board__tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.board__tabs button { min-height: 40px; padding: 0 14px; border: 1px solid var(--manila-edge); background: var(--paper-2); border-radius: 6px 6px 0 0; cursor: pointer; font: 400 15px var(--type); }
.board__tabs button[aria-selected="true"] { background: var(--paper); box-shadow: inset 0 3px 0 var(--red-ink); }
.board__pane { position: relative; display: grid; gap: 14px; }
.board__string { position: absolute; inset: 0; pointer-events: none; }
.pin {
    position: relative; padding: 12px 12px 10px; background: var(--paper); border: 1px solid var(--manila-edge);
    box-shadow: 0 3px 6px rgba(0,0,0,.3); transform: rotate(var(--tilt, -.6deg));
}
.pin::before { content: ''; position: absolute; top: -6px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff6b5e, #a3241b); box-shadow: 0 2px 2px rgba(0,0,0,.4); }
.pin__h { margin: 0; font: 400 18px var(--type); }
.pin__q { margin: 4px 0 6px; }
.pin__row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.pin__status { font-weight: 700; }
.pin__status.is-done { color: var(--ok); }
.need { display: inline-block; padding: 0 6px; border: 2px solid currentColor; border-radius: 3px; font: 400 12px var(--type); letter-spacing: .1em; text-transform: uppercase; }
.need--yes { color: var(--red-ink); }
.need--no { color: var(--steel); }
.need--stamp { color: var(--stamp); }
.board__grouphead h3 { margin: 4px 0 2px; font: 400 18px var(--type); }
.board__grouphead p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.board__group { position: relative; display: grid; gap: 14px; }
.board__tabs .board__ref { margin-left: auto; border-radius: 6px; background: var(--paper); }
.thread__why { margin: 6px 0 0; padding: 6px 10px; border-left: 4px solid var(--stamp); background: #fffdf6; }
.thread__foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.thread__foot .btn--stamp { color: #fff; }
.board__detail { padding: 14px; background: var(--paper); border: 1px solid var(--manila-edge); box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.board__detail h3 { margin: 0 0 6px; font: 400 20px var(--type); }
.board__back { margin-bottom: 8px; }
.steps { margin: 8px 0; padding-left: 22px; }
.steps li { margin: 4px 0; }
.steps li::marker { color: var(--ok); }
.step { margin-top: 10px; padding: 10px; background: #fffdf6; border-left: 4px solid var(--red-ink); }
.step__opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.step__opts .btn { min-height: 44px; }
.step form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.step form .field { flex: 1 1 160px; }
.msg { margin: 8px 0 0; font-weight: 700; }
.msg.is-ok { color: var(--ok); }
.msg.is-ok::before { content: '✓ '; }
.msg.is-no { color: var(--red-ink); }
.msg.is-no::before { content: '✗ '; }
.found { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.found li { padding: 2px 10px; border: 1px solid var(--paper-2); border-radius: 999px; background: #fffdf6; }
.found li::before { content: '✓ '; color: var(--ok); }
.sortrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px dashed var(--paper-2); }
.sortrow strong { min-width: 7em; }
.sortrow .is-placed { background: var(--ink); color: var(--paper); }
.oddrow { margin: 8px 0; }

.report .rep__sec { margin-top: 18px; padding-top: 12px; border-top: 2px dashed var(--manila-edge); }
.rep__h { margin: 0 0 6px; font: 400 20px var(--type); }
/* "Share your win" folds away, closed by default (owner's choice 2026-11-20). */
.rep__fold > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; list-style: none; }
.rep__fold > summary::-webkit-details-marker { display: none; }
.rep__fold > summary::before { content: '▸'; color: var(--red-ink); }
.rep__fold[open] > summary::before { content: '▾'; }
.rep__cta { text-align: center; }
.rep__cta .btn, .report a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.rep__cta .btn--stamp, .report a.btn--stamp { color: #fff; }
.repnums { grid-template-columns: 1fr auto; }
.card { display: grid; gap: 14px; }
@media (min-width: 760px) { .card { grid-template-columns: 260px 1fr; align-items: start; } }
.card__preview img { display: block; width: 100%; max-width: 300px; margin: 0 auto; border: 1px solid var(--ink); box-shadow: var(--shadow); }
.card__text { padding: 12px; background: #fffdf6; border: 1px dashed var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; border: 1px solid var(--ink-soft); border-radius: 999px; background: #fffdf6; cursor: pointer; }
.chips input { width: 18px; height: 18px; }
.stars { display: flex; gap: 2px; border: 0; padding: 0; margin: 6px 0 10px; }
.stars legend { padding: 0 0 4px; font: 400 15px var(--type); }
.stars label { cursor: pointer; font-size: 34px; line-height: 1; color: #b9ab8c; }
.stars input { position: absolute; opacity: 0; }
.stars label.is-on { color: var(--brass-dark); }
.stars input:focus-visible + span { outline: 3px solid var(--focus); }

/* Admin preview (?preview=<slug>): a plain strip above the page. */
/* Admin preview: one thin line; the note opens over the page from the Preview button. */
.desk-preview-bar { position: relative; z-index: 35;   /* under the sheets (40): it must never cover a panel's ✕ */ height: 28px; display: flex; gap: 14px; align-items: center; justify-content: center; padding: 0 12px; background: #ffe45e; color: #24112f; font: 700 .8rem/1 var(--font-body, sans-serif); }
.desk-preview-bar a { color: inherit; font-weight: 800; }
.desk-preview-bar__tag { height: 28px; padding: 0 6px; border: 0; background: none; color: inherit; font: 800 .8rem/1 var(--font-body, sans-serif); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.desk-preview-bar__note { position: absolute; top: 100%; left: 8px; right: 8px; max-width: 520px; margin: 0 auto; padding: 10px 14px; border-radius: 0 0 10px 10px; background: #ffe45e; box-shadow: 0 6px 16px rgba(0,0,0,.3); font: 600 .9rem/1.4 var(--font-body, sans-serif); text-align: center; cursor: pointer; }
.desk-preview-bar__note[hidden] { display: none; }
body.has-preview-bar .desk { height: calc(100vh - 28px); height: calc(100dvh - 28px); }
