  :root {
    --bg: #14322A;
    --bg-deep: #0C211B;
    /* Lobby mode ("Midnight Navy") — a hue-rotation of --bg/--bg-deep at the
       same depth/mood, shifted from green to blue. Applied by toggling the
       body.lobby-mode class, which overrides --bg/--bg-deep for everything
       that already derives its color from them (page background, drawer,
       share-preview panel) without needing per-rule overrides. */
    --bg-lobby: #142133;
    --bg-lobby-deep: #0D1522;
    --card: #F1ECDC;
    --card-shadow: rgba(0,0,0,0.35);
    --ink: #1B2420;
    --ink-soft: #4B554E;
    --accent: #D8A62B;
    --accent-soft: #6E9B8C;
    --line: rgba(0,0,0,0.14);
    --cream-line: rgba(241,236,220,0.16);
    --danger: #FB655F;
    --radius: 14px;
    /* Shared by the outline-style elements around the player list and
       header — Add Player, Add Multiple, Start/Join a Lobby, the
       lobby-strip status bar's border, and the sort/log/share icon
       buttons. Translucent white rather than a fixed color since several
       of these stay visible against BOTH the green (solo) and blue
       (lobby-mode) backgrounds — a hardcoded dark-green-tuned color
       didn't have enough contrast once it showed up against blue too. */
    --btn-border: #ffffff29;
    --btn-text: #ffffff7a;
    --font-display: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    /* Dialog ("sheet") surface — inverted from the old --card (cream) to a
       dark surface, so all sheet text/ink colors below are light-on-dark
       instead of dark-on-light. */
    --sheet-bg: #1F3831;
    --sheet-ink: var(--card);
    --sheet-ink-soft: rgba(241,236,220,0.65);
  }

  * { box-sizing: border-box; }

  button, .card, .name-btn, .color-panel, .badge, .pill, .icon-btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Without this, mobile Safari/Chrome show their own translucent
       tap-highlight overlay on any tappable element — visible as an
       unwanted white flash/border, especially over colored backgrounds
       like a player row. button:active's scale-down below is already the
       intended tap feedback. */
    -webkit-tap-highlight-color: transparent;
  }

  html, body { height: 100%; background-color: var(--bg); }

  body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg) !important;
    background-image: radial-gradient(ellipse at top left, rgba(255,255,255,0.05), transparent 60%);
    color: var(--card);
    font-family: var(--font-display);
    padding: 18px 14px 60px;
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(60px, env(safe-area-inset-bottom));
    /* App-wide, not just the specific button/card classes below — those
       covered the main player list, but left every dialog's text (titles,
       notes, the lobby code display, drawer log entries, etc.) selectable,
       which is what was still triggering iOS's double-tap "Select/Copy"
       callout. Re-enabled just below for actual editable fields. */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  input, textarea {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
  }

  /* Lobby mode: overriding --bg/--bg-deep here cascades to every rule that
     already references them (this rule's own background-color, .drawer,
     .share-preview-wrap) — see the --bg-lobby comment in :root. Cream
     cards, ink text, and accent colors are deliberately untouched.
     --sheet-bg is overridden the same way, so dialogs get their own
     lobby-mode tint too — everything deriving from --sheet-bg (the sheet
     background itself, the swatch-selected ring's inner gap, and
     .sheet-btn.save's text color) picks it up automatically. */
  body.lobby-mode {
    --bg: var(--bg-lobby);
    --bg-deep: var(--bg-lobby-deep);
    --sheet-bg: #1d2e45;
  }

  .wrap { max-width: 520px; margin: 0 auto; }

  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    -webkit-user-select: none;
    user-select: none;
  }

  h1 {
    margin: 0;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .toolbar { display: flex; align-items: center; gap: 10px; }

  button { font-family: var(--font-display); cursor: pointer; border: none; background: transparent; }
  button:active { transform: scale(0.94); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--card);
    border: 1px solid var(--btn-border);
    transition: background 0.12s ease, border-color 0.12s ease;
  }
  .icon-btn:hover { background: rgba(241,236,220,0.08); }
  .icon-btn svg { width: 20px; height: 20px; }
  .icon-btn.muted {
    width: 34px;
    height: 34px;
    opacity: 0.55;
    border-color: transparent;
  }
  .icon-btn.muted:hover { opacity: 0.85; }

  .pill {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: 999px;
    width: 100%;
    text-align: center;
  }
  .pill.active-on { background: var(--accent-soft); border-color: var(--accent-soft); color: #fff; }
  /* Icon + label inline, e.g. the Share Join Link button below the QR —
     the base .pill above is plain centered text with no flex layout. */
  /* Icon + label inline, e.g. the Share Join Link button below the QR —
     the base .pill above is plain centered text with no flex layout.
     width: fit-content + align-self: center break out of .settings-row's
     default flex stretch, sized to content by default — min-width pins it
     to the QR's own rendered width (132px: cellSize 4 * moduleCount 29 +
     margin 8*2 — fixed regardless of lobby code length, since every
     possible code length here still fits the same QR version/grid size),
     so it lines up with the QR but can still grow wider if its own
     content needs more room. */
  .pill-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: fit-content;
    min-width: 132px;
    align-self: center;
  }
  .pill-icon svg { width: 16px; height: 16px; flex-shrink: 0; }
  .pill.danger-confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
  .pill:disabled { opacity: 0.7; cursor: default; }

  /* --- Lobby status strip --- */
  .lobby-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 2px 0 14px;
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--btn-border);
    color: var(--sheet-ink-soft);
  }
  .lobby-strip:hover { background: rgba(255, 255, 255, 0.11); }
  .lobby-strip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-soft);
    flex-shrink: 0;
  }
  .lobby-strip-text {
    font-family: var(--font-mono);
    font-size: 15px;
    letter-spacing: 0.03em;
  }

  /* Read-only devices: +/- hidden entirely (not shown-but-disabled) while
     scoring is host-only. Toggling body.lobby-readonly handles every
     player card at once regardless of how/when they're (re)rendered. */
  body.lobby-readonly .score-btn { display: none; }

  /* Roster management (add/rename/recolor/remove/reorder) and resets are
     host-only, always, in a lobby — independent of the scoring toggle. */
  body.lobby-roster-locked .add-card,
  body.lobby-roster-locked #resetBtn,
  body.lobby-roster-locked #resetPlayersBtn { display: none; }

  /* Non-hosts can't open the player sheet (rename/recolor/remove/reorder),
     so the name/color button should be visually inert for them too — no
     press animation, no click reaching openPlayerSheet() at all. */
  body.lobby-roster-locked .color-panel {
    pointer-events: none;
  }

  /* Live connectivity gap (debounced 2 consecutive failed polls — see
     pollOnce()). Dim + disable, NOT hide: this is transient, so the layout
     shouldn't jump around as connectivity flickers, unlike the stable
     session-long lobby-readonly treatment above. Applies to every device
     in the lobby, host included — a tap that can't reach the server during
     a gap is either lost or produces a score only this device believes,
     neither of which is acceptable for a scorekeeping app. */
  body.lobby-reconnecting .score-btn {
    opacity: 0.35;
    pointer-events: none;
  }
  body.lobby-reconnecting .lobby-strip-dot {
    background: var(--accent);
  }

  .grid { display: flex; flex-direction: column; gap: 12px; position: relative; }

  /* Shown in place of the player rows when the roster is empty (solo mode,
     or a lobby host — see isRosterLocked() gating in renderRowsNow, a
     non-host viewing an empty lobby never sees this since they can't add
     players anyway). */
  .empty-roster-message {
    text-align: center;
    padding: 40px 20px;
    color: rgb(241, 236, 220);
    font-size: 20px;
    line-height: 1.5;
  }

  .card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px var(--card-shadow);
    color: var(--ink);
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    min-height: 70px;
  }

  /* Long-press-to-drag reorder (manual sort mode only) — the dragged row
     lifts above its siblings and follows the pointer via inline transform
     set in JS; siblings shift out of the way the same way. No transition
     of its own since its position is driven directly by pointermove, not
     a CSS-animated property change. */
  .card.dragging {
    z-index: 5;
    box-shadow: 0 14px 28px rgba(0,0,0,0.45);
    transition: none;
  }

  .color-panel {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-width: 0;
    border: none;
    padding: 0 0 0 18px;
    cursor: pointer;
    text-align: left;
  }
  /* Overrides the generic button:active scale-down: .card's background is
     the cream --card color, so shrinking .color-panel away from its edges
     exposed a sliver of that cream showing through — looked like an
     unwanted white border. Dimming in place gives the same "pressed"
     feedback without revealing the parent underneath. */
  .color-panel:active { transform: none; filter: brightness(0.9); }

  .name-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 30px;
    color: var(--card);
    text-shadow: 0 1px 2px rgba(0,0,0,0.22);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
  }

  .right-zone {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px 8px 2px;
    background: var(--card);
  }

  .tally {
    text-align: center;
    flex-shrink: 0;
    min-width: 60px;
    cursor: pointer;
    padding: 0 4px;
    overflow: hidden;
    white-space: nowrap;
    transition: width 150ms ease;
  }

  .score {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 38px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
    white-space: nowrap;
  }

  .score.pending-value { font-size: 26px; font-weight: 500; color: var(--ink-soft); }
  .score.pending-value .delta { font-weight: 800; }
  .score.pending-value .delta.pos { color: #1F8F5F; }
  .score.pending-value .delta.neg { color: var(--danger); }

  .score-edit-input {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--ink);
    background: var(--card);
    border: none;
    border-radius: 6px;
    width: 76px;
    text-align: center;
    padding: 2px 0;
  }

  .btn-row { display: flex; gap: 7px; flex-shrink: 0; }

  .score-btn {
    font-family: var(--font-mono);
    font-size: 30px;
    font-weight: 700;
    width: 54px;
    height: 54px;
    border-radius: 12px;
    color: var(--card);
    /* none rather than manipulation — these are the one element on the
       page involving a sustained press (attachHoldButton's repeat), which
       is exactly what triggers iOS's native long-press text-selection
       gesture. user-select/touch-callout:none and pointerdown's own
       preventDefault() were already in place and should have covered
       this, but touch-action governs the browser's own gesture recognizer
       specifically, which can still win the race in stubborn cases. These
       are small, fixed-size buttons that don't need to support
       pinch/pan themselves, so losing that isn't a real tradeoff. */
    touch-action: none;
  }
  .score-btn.plus { background: #6E9B8C; }
  .score-btn.plus:hover { filter: brightness(1.1); }
  .score-btn.minus { background: #C1443F; }
  .score-btn.minus:hover { filter: brightness(1.1); }

  .add-card {
    border: 2px dashed var(--btn-border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 55px;
    color: var(--btn-text);
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
  }
  .add-card:hover { background: rgba(241,236,220,0.06); border-color: var(--accent); }

  /* "+ Add player" / "+ Add multiple" side by side — Add player gets the
     larger share (flex: 1 fills whatever's left), Add multiple is pinned
     to ~35% via flex-basis. Both reuse .add-card as-is, same as the
     Start/Join a Lobby row below reuses it too. */
  .add-player-row { display: flex; gap: 8px; width: 100%; }
  .add-player-row .add-card { width: auto; flex: 1; }
  .add-player-row .add-card.add-multiple-card { flex: 0 0 50%; }

  /* Start/Join a Lobby — lives in the same slot .lobby-strip occupies once
     a lobby is active (right above the grid), and is mutually exclusive
     with it via the same body.lobby-mode signal. No longer related to
     .add-card at all now that it's moved out of the Add Player row it used
     to sit under — these are their own thing, styled and sized for this
     slot specifically (about half the height .add-card buttons are). */
  .lobby-cta-row { display: flex; gap: 8px; width: 100%; margin: 2px 0 14px; }
  .lobby-cta-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--btn-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--sheet-ink-soft);
    font-size: 15px;
    font-weight: 600;
  }
  .lobby-cta-btn:hover { background: rgba(255, 255, 255, 0.11); }

  /* Hidden while in a lobby — same signal (body.lobby-mode) that hides
     startJoinLobbyRow in Settings, so both stay in sync. */
  body.lobby-mode .lobby-cta-row { display: none; }

  /* --- Add Multiple Players dialog --- */
  .multi-add-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
  #addMultipleRows .multi-add-row input[type="text"] { flex: 1; margin-bottom: 0; }
  .multi-add-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    /* visibility (not display) so the dot's column stays reserved and the
       input doesn't jump width as a row goes from blank to typed. */
    visibility: hidden;
  }

  /* --- Overlay + sheets --- */
  .overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 20;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
  }
  .overlay.open { opacity: 1; pointer-events: auto; }

  .sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--sheet-bg);
    color: var(--sheet-ink);
    border-radius: 18px 18px 0 0;
    padding: 22px 18px max(18px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 21;
    max-width: 520px;
    margin: 0 auto;
  }
  .sheet.open { transform: translateY(0); }

  .sheet h2 {
    margin: 0 0 14px;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    color: var(--sheet-ink-soft);
  }

  .sheet input[type="text"] {
    font-family: var(--font-display);
    font-size: 18px;
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    width: 100%;
    margin-bottom: 14px;
  }

  .sheet-note {
    font-size: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--sheet-ink-soft);
    line-height: 1.4;
    margin: -6px 0 22px;
  }

  .lobby-code-display {
    font-family: var(--font-mono);
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-align: center;
    color: var(--sheet-ink);
    margin-bottom: 16px;
  }

  .lobby-qr { display: flex; justify-content: center; margin-bottom: 16px; }
  .lobby-qr svg { display: block; }

  #joinLobbyCodeInput {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }

  .swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
  .swatch {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
  }
  .swatch.selected { box-shadow: 0 0 0 2px var(--sheet-bg), 0 0 0 4px var(--sheet-ink); }

  .move-row { display: flex; gap: 8px; margin-bottom: 14px; }
  .move-btn {
    flex: 1;
    background: rgba(241,236,220,0.08);
    color: var(--sheet-ink);
    border-radius: 8px;
    padding: 10px;
    font-size: 16px;
    font-weight: 600;
  }
  .move-btn:disabled { opacity: 0.35; cursor: default; }
  .move-btn:not(:disabled):hover { background: rgba(241,236,220,0.14); }

  .share-preview-wrap {
    margin: 4px 0 16px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
  }
  .share-preview-loading {
    color: rgba(241,236,220,0.55);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 24px 0;
  }
  #sharePreviewImg { width: 100%; display: block; }

  .sheet-buttons { display: flex; gap: 8px; margin-top: 10px; }
  .sheet-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
  }
  .sheet-btn.cancel { background: transparent; border: 1px solid rgba(241,236,220,0.3); color: var(--sheet-ink); }
  .sheet-btn.save { background: var(--sheet-ink); color: var(--sheet-bg); }
  .sheet-btn:disabled { opacity: 0.5; cursor: default; }
  #joinLobbyCodeInput:disabled { opacity: 0.5; }
  .sheet-btn.remove { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
  .sheet-btn.remove.confirming { background: var(--danger); color: #fff; }

  .settings-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
  /* The gap below the share button was collapsing with .sheet-note's own
     -6px top margin down to -2px (an actual overlap, not just "tight") —
     22px here collapses with that same -6px to a clean 16px, matching the
     16px gap above the button from .lobby-qr's margin-bottom. Scoped to
     just this row so it doesn't affect .settings-row's other uses
     (Settings sheet, host controls, etc). */
  .share-btn-row { margin-bottom: 22px; }
  /* Start a Lobby's scoring toggle now sits below Start Fresh/Use Current
     instead of above — this preserves the same 10px gap between them that
     .sheet-buttons' own margin-top already provided when the order was
     reversed, without affecting .settings-row elsewhere (Settings sheet,
     Lobby Manage) which don't need this. */
  #startLobbySheet .settings-row { margin-top: 10px; }

  /* Scoped to .sheet (not the base .pill rule) so this doesn't also bump
     #clearLogBtn, which reuses .pill inside the history drawer — left
     alone per "leave the history panel alone." Same reasoning applies to
     the color/border overrides here: the base .pill rule stays tuned for
     its light-background uses elsewhere, and only the dialog copies flip
     to light-on-dark to match the new --sheet-bg. */
  .sheet .pill { font-size: 15px; color: var(--sheet-ink); border-color: rgba(241,236,220,0.3); }

  .version-label {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--sheet-ink-soft);
    margin-top: 10px;
  }

  /* --- Log drawer --- */
  .drawer {
    position: fixed;
    top: 0; right: 0;
    height: 100%;
    width: min(380px, 92vw);
    background: var(--bg-deep);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 21;
    display: flex;
    flex-direction: column;
  }
  /* Only while actually open — while closed, translateX(100%) only moves
     the drawer's own box off-screen by its own width, but a box-shadow's
     blur still extends past that edge regardless of the transform, so
     leaving it on the base rule bled a persistent shadow into the last
     ~40px of the viewport even with the drawer fully hidden. */
  .drawer.open { transform: translateX(0); box-shadow: -12px 0 30px rgba(0,0,0,0.4); }

  .drawer-head {
    padding: 18px 18px 12px;
    padding-top: max(18px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--cream-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .drawer-head h2 {
    font-size: 15px;
    margin: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    color: var(--accent);
  }
  .drawer-close {
    background: transparent;
    color: var(--card);
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
  }

  .log-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 18px;
    font-family: var(--font-mono);
    font-size: 12.5px;
  }
  .log-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(241,236,220,0.08);
    flex-wrap: wrap;
  }
  .log-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .log-name { color: var(--card); }
  .log-delta { font-weight: 700; margin-left: auto; }
  .log-delta.pos { color: #8FD4B8; }
  .log-delta.neg { color: #E39A9A; }
  .log-correction { color: var(--accent); font-style: italic; margin-left: auto; }
  .log-removal, .log-final { color: var(--ink-soft); font-style: italic; margin-left: auto; }
  .log-divider { color: var(--accent); text-align: center; width: 100%; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
  .log-time { color: var(--ink-soft); font-size: 11px; margin-left: 6px; }
  .log-empty { color: var(--ink-soft); padding: 20px 0; font-size: 13px; }

  .drawer-foot { padding: 14px 18px; border-top: 1px solid var(--cream-line); }

  .log-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 18px 8px;
  }
  .log-tab {
    flex: 1;
    background: transparent;
    border: 1px solid var(--cream-line);
    color: var(--card);
    padding: 8px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .log-tab.active { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--bg-deep); }

  .trend-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 6px 18px 18px;
  }
  .trend-empty {
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 24px 0;
    text-align: center;
  }
  .trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 12px;
  }
  .trend-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--card);
  }
  .trend-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }


  /* --- Undo toast --- */
  .toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 12px);
    background: var(--ink);
    color: var(--card);
    font-family: var(--font-mono);
    font-size: 13.5px;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 22;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 92vw;
    white-space: nowrap;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
  #undoToastText {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .toast button {
    background: var(--accent);
    color: var(--bg-deep);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .status-banner {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 12px);
    background: var(--danger);
    color: #F1ECDC;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 23;
    max-width: 90vw;
    text-align: center;
  }
  .status-banner.show { opacity: 1; transform: translate(-50%, 0); }

  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
  }
