    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg: #0a0a0a;
      --surface: #161616;
      --surface2: #202020;
      --border: #2c2c2c;
      --accent: #ec4899;
      --accent-hover: #f472b6;
      --cast: #ec4899;
      --cast-hover: #f472b6;
      /* hold-type colours */
      --start: #22c55e;
      --int: #3b82f6;
      --finish: #ef4444;
      --feet: #f59e0b;
      --gold: #fbbf24;
      --text: #f5f5f5;
      --text-muted: #9a9a9a;
      --radius: 12px;
      --shadow: 0 4px 24px rgba(0,0,0,0.4);
      --nav-h: 60px;
    }

    html, body { height: 100%; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100dvh;
      -webkit-tap-highlight-color: transparent;
    }

    /* ── Splash / boot overlay ───────────────────────────────────────────
       Matches the native PWA launch screen (same bg + mark) so the two read
       as one continuous splash, then fades out shortly after boot. */
    #splash {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 22px;
      background: var(--bg);
      transition: opacity 0.45s ease;
    }
    #splash.hide { opacity: 0; pointer-events: none; }
    #splash img { width: 96px; height: 96px; border-radius: 22px; }
    #splash .splash-name {
      font-size: 22px;
      font-weight: 700;
      letter-spacing: 0.5px;
      color: var(--text);
    }
    #splash .splash-name span { color: var(--accent); }

    /* ── View switching ──────────────────────────────────────────────── */
    .view { display: none; }
    .view.active { display: block; animation: fade 0.18s ease; }
    @keyframes fade { from { opacity: 0; } to { opacity: 1; } }

    /* ── Top bar (per view) ──────────────────────────────────────────── */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 100;
      background: rgba(10,10,10,0.92);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border-bottom: 1px solid var(--border);
      /* Reserve the iOS status-bar / notch area (viewport-fit=cover +
         black-translucent draw the page under it). The header background fills
         the inset so the clock/battery sit on dark, not over the content. */
      padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
               10px calc(16px + env(safe-area-inset-left));
    }

    .header-title {
      font-size: 1.1rem;
      font-weight: 700;
      letter-spacing: 0.02em;
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 10px;
    }

    .header-title .dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      background: var(--cast);
      box-shadow: 0 0 8px var(--cast);
      animation: pulse 2s infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }

    .search-row { display: flex; gap: 8px; align-items: center; }
    .search-wrap { position: relative; flex: 1; }

    .search-icon {
      position: absolute;
      left: 10px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
      pointer-events: none;
      font-size: 15px;
    }

    input[type="search"] {
      width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-size: 15px;
      padding: 9px 12px;
      outline: none;
      transition: border-color 0.15s;
      -webkit-appearance: none;
    }

    input[type="search"]:focus { border-color: var(--accent); }
    input[type="search"]::placeholder { color: var(--text-muted); }

    /* Hide the native (focus-only) clear control — we use a custom one that
       stays put whenever the field has text. Reserve room for it on the right. */
    .search-wrap input[type="search"] { padding-right: 36px; }
    .search-wrap input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

    .search-clear {
      position: absolute;
      right: 6px;
      top: 50%;
      transform: translateY(-50%);
      width: 26px;
      height: 26px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      border: none;
      border-radius: 50%;
      background: var(--border);
      color: var(--text);
      font-size: 18px;
      line-height: 1;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    .search-clear[hidden] { display: none; }
    .search-clear:active { background: var(--accent); }

    .count-badge {
      font-size: 12px;
      color: var(--text-muted);
      white-space: nowrap;
      padding: 0 2px;
    }

    /* "+" create button in the list search row */
    .add-btn {
      width: 40px;
      height: 40px;
      color: var(--accent);
      border-color: var(--accent);
    }
    .add-btn:active { background: rgba(236,72,153,0.12); }
    .add-btn svg { width: 22px; height: 22px; }

    /* ── Grade filter tabs ───────────────────────────────────────────── */
    .grade-tabs {
      display: flex;
      gap: 6px;
      margin-top: 10px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      padding-bottom: 2px;
    }
    .grade-tabs::-webkit-scrollbar { display: none; }

    .grade-tab {
      flex: 0 0 auto;
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      border-radius: 999px;
      padding: 6px 13px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
      touch-action: manipulation;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
    }
    .grade-tab:active { transform: scale(0.95); }
    .grade-tab.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }

    /* ── Filter pills (under the grade tabs) — 3 equal-width toggles ──── */
    .filter-pills { display: flex; gap: 6px; margin-top: 8px; }
    .filter-pill {
      flex: 1 1 0;
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      border-radius: 999px;
      padding: 7px 6px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    .filter-pill:active { transform: scale(0.96); }
    .filter-pill.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    /* Auth-only pills for a guest: muted but still tappable (taps fire a sign-in toast). */
    .filter-pill.disabled { opacity: 0.4; }

    /* ── Main content ────────────────────────────────────────────────── */
    main {
      padding: 12px 12px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
      max-width: 680px;
      margin: 0 auto;
    }
    main.centered {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 100dvh;
      text-align: center;
      /* Keep the card clear of the notch / status bar (auth has no top bar). */
      padding-top: calc(20px + env(safe-area-inset-top));
      padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    /* ── Problem cards (list) ────────────────────────────────────────── */
    .problem-list { display: flex; flex-direction: column; gap: 8px; }

    .problem-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 14px 14px 16px;
      display: flex;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
    }
    .problem-card:active { background: var(--surface2); }

    .problem-info { flex: 1; min-width: 0; }

    .problem-name {
      font-size: 15px;
      font-weight: 600;
      line-height: 1.3;
      word-break: break-word;
    }

    .problem-meta {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-top: 6px;
      font-size: 12px;
      color: var(--text-muted);
    }
    .meta-setter { color: var(--text-muted); }

    /* ── Grade badge ─────────────────────────────────────────────────── */
    .grade-badge {
      display: inline-block;
      background: rgba(236,72,153,0.16);
      border: 1px solid rgba(236,72,153,0.5);
      color: #f9a8d4;
      border-radius: 6px;
      padding: 2px 8px;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.02em;
    }

    /* ── Stars ───────────────────────────────────────────────────────── */
    .stars { letter-spacing: 1px; font-size: 13px; line-height: 1; }
    .star-on { color: var(--gold); }
    .star-off { color: #44445a; }

    /* Subtle "sent" tick on a list card, sits next to the stars */
    .tick-flag { color: var(--start); font-size: 13px; font-weight: 800; line-height: 1; opacity: 0.85; }

    /* ── Favourite heart (list cards) ────────────────────────────────── */
    .card-fave {
      flex-shrink: 0;
      background: transparent;
      border: none;
      color: var(--text-muted);
      width: 42px; height: 42px;
      display: flex; align-items: center; justify-content: center;
      border-radius: 10px;
      cursor: pointer;
      transition: color 0.15s, transform 0.1s;
      touch-action: manipulation;
    }
    .card-fave svg { width: 22px; height: 22px; }
    .card-fave:active { transform: scale(0.85); }
    .card-fave.faved { color: #f43f5e; }
    .card-fave.faved svg { fill: currentColor; }

    /* ── Cast button (card) ──────────────────────────────────────────── */
    .cast-btn {
      flex-shrink: 0;
      background: var(--cast);
      color: #fff;
      border: none;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 700;
      padding: 10px 15px;
      cursor: pointer;
      transition: background 0.15s, transform 0.1s, opacity 0.2s;
      white-space: nowrap;
      letter-spacing: 0.02em;
      touch-action: manipulation;
    }
    .cast-btn:hover { background: var(--cast-hover); }
    .cast-btn:active { transform: scale(0.95); }
    .cast-btn.casting { opacity: 0.6; pointer-events: none; }
    .cast-btn.sent { background: var(--accent); animation: flash 0.4s ease; }

    @keyframes flash {
      0%   { transform: scale(1.08); }
      100% { transform: scale(1); }
    }

    /* ── Detail view ─────────────────────────────────────────────────── */
    .detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

    .icon-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      width: 38px; height: 38px;
      border-radius: 9px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      touch-action: manipulation;
      transition: background 0.15s, transform 0.1s;
    }
    .icon-btn:active { background: var(--surface2); transform: scale(0.95); }
    .icon-btn svg { width: 20px; height: 20px; }

    .detail-bar-title {
      flex: 1;
      min-width: 0;
      font-size: 1rem;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Title block (name + meta), sits between header and board */
    .detail-head-info {
      min-width: 0;
      padding: 12px 14px 10px;
      flex-shrink: 0;
    }
    .detail-name {
      font-size: 1.35rem;
      font-weight: 800;
      line-height: 1.2;
      margin-bottom: 7px;
      word-break: break-word;
    }
    .detail-meta {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      color: var(--text-muted);
    }

    /* Tick · Mirror · Cast — boxed icon buttons (same style as the "i" button) */
    .detail-actions {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .icon-btn.casting { opacity: 0.55; pointer-events: none; }
    .icon-btn.sent { border-color: var(--accent); color: var(--accent-hover); animation: flash 0.4s ease; }
    /* Ticked (sent) — the detail tick button turns green */
    #detail-tick.ticked { color: var(--start); border-color: var(--start); background: rgba(34,197,94,0.14); }
    /* Favourited — detail-header hearts turn red/filled */
    #detail-fave.faved, #circuit-detail-fave.faved {
      color: #f43f5e; border-color: #f43f5e; background: rgba(244,63,94,0.14);
    }
    #detail-fave.faved svg, #circuit-detail-fave.faved svg { fill: currentColor; }
    /* .icon-btn sets display:flex, which beats the bare [hidden] UA rule — guard each. */
    #circuit-detail-fave[hidden] { display: none; }
    /* Mirror toggle lit — the board overlay is showing the mirrored problem */
    #detail-mirror.active { color: #60a5fa; border-color: #3b82f6; background: rgba(59,130,246,0.16); }

    .bench-badge {
      background: rgba(245,158,11,0.16);
      border: 1px solid rgba(245,158,11,0.5);
      color: var(--gold);
      border-radius: 6px;
      padding: 2px 8px;
      font-size: 12px;
      font-weight: 700;
    }

    /* "Sent in both orientations" — earns the mirror bonus */
    .both-badge {
      background: rgba(96,165,250,0.16);
      border: 1px solid rgba(59,130,246,0.5);
      color: #60a5fa;
      border-radius: 6px;
      padding: 2px 8px;
      font-size: 12px;
      font-weight: 700;
    }

    /* ── Leaderboard ─────────────────────────────────────────────────── */
    .leaderboard-row {
      display: flex;
      align-items: center;
      gap: 12px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 12px 14px;
    }
    .leaderboard-row.me {
      border-color: var(--accent);
      background: var(--surface2);
    }
    .lb-rank {
      flex: 0 0 auto;
      min-width: 28px;
      text-align: center;
      font-size: 16px;
      font-weight: 800;
      color: var(--text-muted);
    }
    .lb-name {
      flex: 1; min-width: 0;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .lb-you {
      font-size: 11px;
      font-weight: 700;
      color: var(--accent);
      border: 1px solid var(--accent);
      border-radius: 5px;
      padding: 0 5px;
      margin-left: 6px;
    }
    .lb-stat {
      flex: 0 0 auto;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      line-height: 1.25;
    }
    .lb-points { font-weight: 800; }
    .lb-sends { font-size: 12px; color: var(--text-muted); }

    .detail-comment {
      background: var(--surface);
      border: 1px solid var(--border);
      border-left: 3px solid var(--accent);
      border-radius: 8px;
      padding: 11px 13px;
      font-size: 14px;
      line-height: 1.5;
      color: #c8c8da;
      margin-bottom: 18px;
    }

    /* ── Info modal (bottom sheet) ───────────────────────────────────── */
    .modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 300;
      display: none;
      align-items: flex-end;
      justify-content: center;
      background: rgba(0,0,0,0.6);
      -webkit-backdrop-filter: blur(2px);
      backdrop-filter: blur(2px);
    }
    .modal-overlay.show { display: flex; animation: fade 0.18s ease; }
    .modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-top-left-radius: 18px;
      border-top-right-radius: 18px;
      width: 100%;
      max-width: 680px;
      padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
      box-shadow: var(--shadow);
      animation: sheetUp 0.22s cubic-bezier(.2,.8,.2,1);
    }
    @keyframes sheetUp { from { transform: translateY(50px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }
    .modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
    .modal-title { font-size: 1.2rem; font-weight: 800; }
    .modal-close {
      background: var(--surface2);
      border: 1px solid var(--border);
      color: var(--text);
      width: 32px; height: 32px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 17px;
      line-height: 1;
      display: flex; align-items: center; justify-content: center;
      touch-action: manipulation;
    }
    .info-row { margin-bottom: 18px; }
    .info-row:last-child { margin-bottom: 0; }
    .info-label {
      font-size: 11px; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.08em;
      color: var(--text-muted); margin-bottom: 7px;
    }
    .info-value { font-size: 15px; line-height: 1.5; color: var(--text); }

    /* ── Auth ─────────────────────────────────────────────────────────── */
    .btn-google {
      display: flex; align-items: center; justify-content: center; gap: 10px;
      background: #fff; color: #1f1f1f; font-weight: 700; border: none;
    }
    .btn-google svg { width: 18px; height: 18px; flex: none; }
    .auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
    .auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.12); }
    .auth-toggle { font-size: 13px; color: var(--text-muted); margin: 14px 0 2px; }
    .auth-toggle a { color: var(--accent-hover); font-weight: 700; text-decoration: none; cursor: pointer; }
    .auth-error { color: #f87171; font-size: 13px; min-height: 18px; margin: 6px 0 2px; }
    #name-modal .name-body { padding: 4px 18px 20px; }

    /* ── Board graphic ───────────────────────────────────────────────── */
    .board-graphic { width: 100%; display: block; }

    /* Detail view is pinned to the viewport — no page scrolling.
       Fixed positioning takes it out of body flow so nothing can scroll. */
    #view-detail.active {
      position: fixed;
      inset: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    /* main = everything between the sticky header and the bottom nav */
    #view-detail main {
      flex: 1;
      min-height: 0;
      padding: 0;
      position: relative;
      display: flex;
      flex-direction: column;
      margin-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    }

    /* Create-view hint, overlaid at the bottom of the board */
    .board-hint {
      position: absolute;
      left: 0; right: 0; bottom: 0;
      padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
      text-align: center;
      font-size: 13px;
      color: var(--text);
      background: linear-gradient(to top, rgba(10,10,10,0.85), rgba(10,10,10,0));
      pointer-events: none;
    }
    .board-hint span { color: var(--accent-hover); font-weight: 700; }
    #detail-content {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;   /* centre the natural-aspect board in the pinned area */
    }
    /* Board shown at its TRUE aspect ratio (no stretch) so a wide board reads as
       wide. The overlay is %-positioned and the board-wrap matches the image box,
       so dots still land on every hold. */
    #view-detail .board-graphic {
      width: 100%;
      height: auto;
    }

    /* ── Create view ─────────────────────────────────────────────────── */
    /* Create scrolls normally (form below the board). The board keeps its
       natural aspect ratio so hold_map.json percentages land on each hold. */
    #view-create .board-graphic { width: 100%; height: auto; display: block; border-radius: 10px; }
    #create-board { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    #create-hold-layer { pointer-events: none; }
    /* Only assigned holds get a dot, reusing the shared .start/.int/.finish colours. */

    /* Create form: trim the shared nav-reserve padding so a form that nearly
       fits doesn't leave a band of empty scroll below it. */
    #view-create main {
      padding-bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom));
    }
    /* Circuit-create form is taller (it scrolls), so keep a small breathing gap
       between the last field and the bottom nav. */
    #view-circuit-create main {
      padding-bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
    }
    .create-panel { padding: 12px 2px 6px; }

    .create-tip { font-size: 13px; line-height: 1.5; color: var(--text-muted); margin: 0 0 12px; text-align: center; }
    .create-tip b { font-weight: 700; }
    .c-start { color: #4ade80; }
    .c-int { color: #60a5fa; }
    .c-finish { color: #f87171; }

    .create-counts { display: flex; gap: 8px; margin-bottom: 4px; }
    .create-counts span {
      flex: 1;
      text-align: center;
      font-size: 13px;
      font-weight: 700;
      padding: 8px 6px;
      border-radius: 9px;
      background: var(--surface);
      border: 1px solid var(--border);
    }
    .create-counts .c-start  { border-color: rgba(34,197,94,0.4); }
    .create-counts .c-int    { border-color: rgba(59,130,246,0.4); }
    .create-counts .c-finish { border-color: rgba(239,68,68,0.4); }
    .create-grade-label {
      font-size: 12px; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--text-muted); margin: 14px 0 8px;
    }
    .create-grades { margin-top: 0; flex-wrap: wrap; }

    /* Save action lives in the header (furthest right) as an accent-coloured icon. */
    .save-icon-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
    .save-icon-btn:active { background: var(--accent-hover); }
    .save-icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

    /* ── Calibrate view (admin: re-map holds onto a new board image) ─── */
    #view-calibrate main { padding-bottom: 40px; }
    .cal-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 2px; flex-wrap: wrap; }
    .cal-chip {
      background: var(--surface2); border: 1px solid var(--border); color: var(--text);
      border-radius: 9px; padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    }
    .cal-chip.ghost { background: transparent; color: var(--text-muted); }
    .cal-mode { display: flex; margin-left: auto; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
    .cal-seg { background: var(--surface); color: var(--text-muted); border: none; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
    .cal-seg.active { background: var(--accent); color: #fff; }
    .cal-status { font-size: 13px; color: var(--accent-hover); min-height: 18px; margin: 0 0 10px; text-align: center; font-weight: 600; }
    .cal-board { border-radius: 10px; overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: crosshair; }
    .cal-board.nudging { touch-action: none; }
    #cal-img { width: 100%; height: auto; display: block; }
    .cal-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
    .cal-dot {
      position: absolute; width: 2.6%; aspect-ratio: 1; transform: translate(-50%, -50%);
      border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.85);
      background: rgba(236,72,153,0.45); box-sizing: border-box;
      box-shadow: 0 0 0 1px rgba(0,0,0,0.45);
    }
    .cal-dot.sel { background: rgba(250,204,21,0.92); border-color: #fff; width: 4%; z-index: 3; }
    .cal-dot.anchored { background: rgba(34,197,94,0.75); border-color: #bbf7d0; }
    /* Mirror mode: the selected hold's current partner, and holds with no mirror. */
    .cal-dot.partner { background: rgba(59,130,246,0.9); border-color: #bfdbfe; width: 4%; z-index: 2; }
    .cal-dot.selfmirror { background: rgba(245,158,11,0.7); border-color: #fde68a; }
    .cal-anchor {
      position: absolute; width: 3%; aspect-ratio: 1; transform: translate(-50%, -50%);
      border-radius: 50%; border: 2px solid #4ade80; box-sizing: border-box; z-index: 2;
    }
    .cal-anchor::before, .cal-anchor::after { content: ''; position: absolute; background: #4ade80; }
    .cal-anchor::before { left: 50%; top: -30%; width: 2px; height: 160%; transform: translateX(-50%); }
    .cal-anchor::after { top: 50%; left: -30%; height: 2px; width: 160%; transform: translateY(-50%); }
    .cal-panel { padding: 14px 2px 8px; }
    .cal-anchors-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 13px; color: var(--text-muted); font-weight: 600; }
    /* Fit is a secondary action — soft pink. Save is the primary, solid accent. */
    #cal-fit {
      background: rgba(236,72,153,0.16);
      color: var(--accent-hover);
      border: 1px solid rgba(236,72,153,0.45);
    }
    #cal-fit:disabled { opacity: 0.45; cursor: not-allowed; }
    #cal-save { margin-top: 12px; }
    .cal-help { font-size: 12px; line-height: 1.6; color: var(--text-muted); margin: 14px 0 0; }
    .cal-help b { color: var(--text); font-weight: 700; }

    /* ── Problem hold overlay (detail view) ──────────────────────────── */
    /* The board-wrap matches the image box (natural aspect), so percentage
       positions from hold_map.json land correctly on each hold. */
    .board-wrap { position: relative; }
    #view-detail .board-wrap { width: 100%; }
    #view-detail .board-wrap .board-graphic { height: auto; }
    .hold-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
    .hold-dot {
      position: absolute;
      width: 4.6%;
      aspect-ratio: 1;
      transform: translate(-50%, -50%);
      border-radius: 50%;
      border: clamp(2px, 0.7vw, 4px) solid;
      box-sizing: border-box;
      box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 0 9px rgba(0,0,0,0.4);
    }
    .hold-dot.start  { border-color: #22c55e; background: rgba(34,197,94,0.28); }
    .hold-dot.int    { border-color: #3b82f6; background: rgba(59,130,246,0.24); }
    .hold-dot.finish { border-color: #ef4444; background: rgba(239,68,68,0.30); }

    /* Hold-shape overlay (problems only): real traced outlines + dim-the-rest.
       viewBox is 0..100 in both axes with preserveAspectRatio:none, so points map
       to the board exactly like the % dots; non-scaling-stroke keeps outline width
       constant despite the non-uniform stretch. The dim mask and the outlines are
       two stacked svgs so the halo below can be a CSS filter on the OUTERMOST svg
       (resolved in CSS px). On an svg *child* the same 1px would resolve in the
       stretched viewBox units — 1% of the board, and different in x and y. */
    .hold-shape-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
    .hs-lines { filter: drop-shadow(0 0 1px rgba(0,0,0,0.85)); }
    .hs { fill: none; stroke-width: 2.4px; vector-effect: non-scaling-stroke; }
    .hs.start  { stroke: #22c55e; }
    .hs.int    { stroke: #3b82f6; }
    .hs.finish { stroke: #ef4444; }

    /* Create/edit has no dim to supply contrast, so an assigned hold gets the same
       translucent fill and chunky edge the .hold-dot used to give it — a thin
       hairline is not enough tap feedback on a bright board photo in a gym. */
    #view-create .hs        { stroke-width: 2.4px; }
    #view-create .hs.start  { fill: rgba(34,197,94,0.28); }
    #view-create .hs.int    { fill: rgba(59,130,246,0.24); }
    #view-create .hs.finish { fill: rgba(239,68,68,0.30); }

    /* ── Fullscreen board mode ───────────────────────────────────────────
       Expand button enters a rotated landscape fullscreen on any board; a touch
       device turned to landscape auto-enters a natural (un-rotated) fullscreen on
       the read-only detail views. The board-wrap is positioned fixed and sized in
       JS via --fs-bw (so the %-positioned overlay, which scales with the wrap,
       stays aligned). A full-viewport black backdrop sits behind it. */
    .board-expand-btn {
      position: absolute; top: 8px; right: 8px; z-index: 5;
      width: 36px; height: 36px; border-radius: 9px;
      display: flex; align-items: center; justify-content: center;
      background: rgba(10,10,10,0.55); border: 1px solid rgba(255,255,255,0.25);
      color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
      -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    }
    .board-expand-btn svg { width: 18px; height: 18px; }
    .board-expand-btn:active { background: rgba(10,10,10,0.8); }

    #board-fs-close {
      position: fixed; z-index: 201;
      top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
      width: 44px; height: 44px; border-radius: 11px;
      display: none; align-items: center; justify-content: center;
      background: rgba(10,10,10,0.65); border: 1px solid rgba(255,255,255,0.3);
      color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    body.board-fs #board-fs-close { display: flex; }
    /* Rotated FS keeps the OS portrait; you turn the phone anticlockwise to read
       the board, which moves the portrait top-right corner to your top-LEFT. So
       anchor the close button at the portrait bottom-right — that lands at your
       top-right once turned. (Natural FS lets the OS rotate, so top-right is right.) */
    body.board-fs-rotated #board-fs-close {
      top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    }

    /* Hide chrome + the expand button while fullscreen (!important beats the inline
       display:flex setView puts on #bottom-nav). */
    body.board-fs { overflow: hidden; }
    body.board-fs #bottom-nav { display: none !important; }
    body.board-fs .view.active .topbar { display: none !important; }
    body.board-fs .board-expand-btn { display: none; }

    /* The board-wrap is lifted above the rest of the view (z-index) and carries its
       own viewport-filling black surround as a box-shadow — painted as part of the
       wrap itself, so it covers the page without the cross-stacking-context trap a
       separate backdrop would hit (the active view is position:fixed = its own
       stacking context). The shadow rides the rotate transform and isn't clipped
       (the wrap is fixed, so ancestor overflow:hidden doesn't apply). */
    body.board-fs .view.active .board-wrap {
      position: fixed; z-index: 200; height: auto;
      /* !important beats the ID-specificity sizing the detail views set on
         .board-wrap (#view-detail / #view-circuit-detail width:100% + max-width),
         which would otherwise pin the wrap to the viewport width in both
         orientations so the board never grows in landscape. */
      width: var(--fs-bw, 100vw) !important;
      max-width: none !important; margin: 0 !important;
      background: #000; border-radius: 0; overflow: visible;
      box-shadow: 0 0 0 100vmax #000;
    }
    body.board-fs .view.active .board-graphic { width: 100%; height: auto; border-radius: 0; }
    /* natural: centre in the viewport */
    body.board-fs:not(.board-fs-rotated) .view.active .board-wrap {
      top: 50%; left: 50%; transform: translate(-50%, -50%);
    }
    /* rotated: centre + 90° turn (the wide board's long edge runs down the phone) */
    body.board-fs-rotated .view.active .board-wrap {
      top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(90deg);
    }

    .detail-section { margin-bottom: 22px; }

    .section-label {
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      margin-bottom: 10px;
    }
    .section-label .muted { color: #55556a; font-weight: 600; }

    .legend {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      margin-bottom: 14px;
      font-size: 12px;
      color: var(--text-muted);
    }
    .legend span { display: flex; align-items: center; gap: 6px; }
    .legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
    .dot-start { background: var(--start); }
    .dot-int { background: var(--int); }
    .dot-finish { background: var(--finish); }

    .hold-group { margin-bottom: 14px; }
    .hg-label {
      display: block;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 7px;
    }
    .hg-label.start { color: #4ade80; }
    .hg-label.int { color: #60a5fa; }
    .hg-label.finish { color: #f87171; }

    .chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
    .chip {
      font-size: 13px;
      font-weight: 600;
      padding: 6px 11px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface2);
      min-width: 42px;
      text-align: center;
    }
    .chip.start  { background: rgba(34,197,94,0.14);  border-color: rgba(34,197,94,0.45);  color: #4ade80; }
    .chip.int    { background: rgba(59,130,246,0.14); border-color: rgba(59,130,246,0.45); color: #60a5fa; }
    .chip.finish { background: rgba(239,68,68,0.14);  border-color: rgba(239,68,68,0.45);  color: #f87171; }
    .chip.feet   { background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.45); color: var(--gold); text-transform: capitalize; }

    /* ── Auth + Profile shells ───────────────────────────────────────── */
    .shell-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 28px 24px;
      max-width: 340px;
      width: 100%;
    }
    .shell-icon {
      width: 54px; height: 54px;
      border-radius: 14px;
      background: var(--surface2);
      display: flex; align-items: center; justify-content: center;
      margin: 0 auto 16px;
    }
    .shell-icon svg { width: 26px; height: 26px; color: var(--accent); }
    .shell-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 6px; }
    .shell-sub { font-size: 14px; color: var(--text-muted); line-height: 1.5; margin-bottom: 20px; }
    .pill {
      display: inline-block;
      background: rgba(236,72,153,0.16);
      border: 1px solid rgba(236,72,153,0.4);
      color: #f9a8d4;
      border-radius: 999px;
      padding: 4px 12px;
      font-size: 12px;
      font-weight: 700;
      margin-bottom: 18px;
    }
    .fld {
      width: 100%;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 9px;
      color: var(--text);
      font-size: 15px;
      padding: 12px;
      margin-bottom: 10px;
      -webkit-appearance: none;
    }
    .fld:disabled { opacity: 0.55; }
    .btn-block {
      width: 100%;
      border: none;
      border-radius: 10px;
      padding: 14px;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      touch-action: manipulation;
      transition: transform 0.1s, opacity 0.2s, background 0.15s;
    }
    .btn-block:active { transform: scale(0.98); }
    .btn-primary { background: var(--accent); color: #fff; }
    .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
    .btn-danger { background: #dc2626; color: #fff; }
    .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

    /* Admin-only header buttons hide via the hidden attribute (overrides icon-btn's flex) */
    .admin-only[hidden] { display: none; }

    /* ── Overflow (⋮) menu — detail headers (Edit / Delete / Information) ── */
    .menu-wrap { position: relative; flex-shrink: 0; display: flex; }
    #circuit-menu-wrap[hidden] { display: none; }
    .overflow-menu {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      min-width: 188px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 14px 34px rgba(0,0,0,0.55);
      padding: 6px;
      z-index: 200;
      display: flex;
      flex-direction: column;
      gap: 2px;
      animation: fade 0.14s ease;
    }
    .overflow-menu[hidden] { display: none; }
    .menu-item {
      display: flex;
      align-items: center;
      gap: 12px;
      width: 100%;
      background: transparent;
      border: none;
      color: var(--text);
      font-size: 15px;
      font-weight: 600;
      text-align: left;
      padding: 12px;
      border-radius: 8px;
      cursor: pointer;
      touch-action: manipulation;
    }
    .menu-item:active { background: var(--surface2); }
    .menu-item[hidden] { display: none; }
    .menu-item svg { width: 19px; height: 19px; flex-shrink: 0; }
    .menu-item.danger { color: #f87171; }

    /* Grade chips inside the edit-grade modal */
    .grade-edit-options { flex-wrap: wrap; margin: 0 0 6px; }

    /* Side-by-side modal buttons (cancel / confirm) */
    .modal-actions { display: flex; gap: 10px; }
    .modal-actions .btn-block { flex: 1; margin-top: 0; }
    /* Edit-choice chooser: two stacked full-width options (grade vs holds). */
    .edit-choice-actions { display: flex; flex-direction: column; gap: 10px; }
    .edit-choice-actions .btn-block { margin-top: 0; }
    .btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); margin-top: 10px; }
    .link { color: var(--accent-hover); text-decoration: none; font-weight: 600; }

    /* ── Profile ─────────────────────────────────────────────────────── */
    .profile-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 14px 16px;
      margin-bottom: 8px;
    }
    .profile-row .k { color: var(--text-muted); font-size: 14px; }
    .profile-row .v { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
    .profile-row .v .hardest-name {
      font-weight: 600; color: var(--text-muted); font-size: 13px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
    }

    /* Display-name row with inline edit button */
    .profile-name-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
    .profile-edit { width: 32px; height: 32px; color: var(--text-muted); }
    .profile-edit svg { width: 16px; height: 16px; }
    .profile-edit:active { color: var(--text); }

    /* ── Admin hub (#admin) ──────────────────────────────────────────── */
    #admin-content { padding: 12px 16px 24px; max-width: 520px; margin: 0 auto; }

    /* Tappable card linking to a sub-tool (e.g. Recalibrate board) */
    .admin-card {
      display: flex;
      align-items: center;
      gap: 14px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
      text-decoration: none;
      color: var(--text);
    }
    .admin-card:active { background: var(--surface2); }
    .admin-card-icon { flex: none; width: 26px; height: 26px; color: var(--accent-hover); }
    .admin-card-icon svg { width: 26px; height: 26px; }
    .admin-card-text { flex: 1; min-width: 0; }
    .admin-card-title { font-weight: 700; font-size: 15px; }
    .admin-card-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
    .admin-card-chev { flex: none; width: 18px; height: 18px; color: var(--text-muted); }
    .admin-card-chev svg { width: 18px; height: 18px; }

    /* Cards stack with a small gap (hub + user-list rows) */
    .admin-card + .admin-card { margin-top: 8px; }

    /* Hub cards: grid so every card matches the tallest (equal heights) */
    .admin-hub { display: grid; gap: 8px; grid-auto-rows: 1fr; }
    .admin-hub .admin-card + .admin-card { margin-top: 0; }
    #admin-refresh[hidden] { display: none; }

    /* User-list rows reuse .admin-card; swap the square icon for a round avatar */
    .user-avatar {
      flex: none;
      width: 38px; height: 38px;
      border-radius: 50%;
      background: var(--surface2);
      border: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      font-weight: 700; font-size: 16px; color: var(--accent-hover);
    }
    .user-link .admin-card-title { display: flex; align-items: center; gap: 8px; }

    .user-badge {
      flex: none;
      background: rgba(236,72,153,0.16);
      border: 1px solid rgba(236,72,153,0.5);
      color: var(--accent-hover);
      border-radius: 6px;
      padding: 1px 7px;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    /* User detail (#admin/user/<id>) */
    .user-detail-head { text-align: center; padding: 14px 0 20px; }
    .user-avatar.lg { width: 64px; height: 64px; font-size: 26px; margin: 0 auto 12px; }
    .user-detail-name {
      font-size: 1.15rem; font-weight: 800;
      display: flex; align-items: center; justify-content: center; gap: 8px;
    }
    .user-detail-email { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
    .user-detail-actions { margin-top: 24px; }
    .user-detail-actions .btn-block + .btn-block { margin-top: 10px; }
    .user-detail-note { color: var(--text-muted); font-size: 13px; text-align: center; line-height: 1.5; margin-top: 12px; }

    /* ── Circuits ────────────────────────────────────────────────────── */
    /* List-card meta extras */
    .circuit-len { color: var(--text-muted); }
    .loop-badge {
      display: inline-flex; align-items: center; gap: 3px;
      background: rgba(59,130,246,0.16);
      border: 1px solid rgba(59,130,246,0.5);
      color: #93c5fd;
      border-radius: 6px;
      padding: 1px 7px;
      font-size: 11px;
      font-weight: 700;
    }

    /* Move-order numbers inside a hold dot (detail + create overlays) */
    .seq-num {
      position: absolute;
      inset: 0;
      display: flex; align-items: center; justify-content: center;
      font-size: 9px; font-weight: 800; line-height: 1;
      color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.9);
      pointer-events: none;
    }
    /* A lit hold during the Play preview — brighter, with a glow pulse */
    .hold-dot.lit {
      filter: brightness(1.5);
      box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 0 14px 3px currentColor;
      animation: litPulse 0.55s ease;
    }
    .hold-dot.lit.start  { color: #22c55e; }
    .hold-dot.lit.int    { color: #3b82f6; }
    .hold-dot.lit.finish { color: #ef4444; }
    @keyframes litPulse { from { transform: translate(-50%, -50%) scale(1.35); } to { transform: translate(-50%, -50%) scale(1); } }

    /* Circuit detail Play panel */
    #view-circuit-detail .board-wrap { width: 100%; max-width: 680px; margin: 0 auto; }
    #view-circuit-detail .board-graphic { width: 100%; height: auto; border-radius: 10px; }
    .circuit-play-panel { padding: 16px 2px 8px; }
    .cc-hint { font-size: 12px; line-height: 1.5; color: var(--text-muted); text-align: center; margin: 14px 0 0; }

    /* Preview speed stepper (0.1s steps) */
    .circuit-speed {
      display: flex; align-items: center; justify-content: center; gap: 12px;
      margin-top: 14px;
    }
    .circuit-speed-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
    .circuit-speed-btn {
      width: 38px; height: 38px; flex: none;
      border-radius: 9px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text);
      font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer;
      touch-action: manipulation;
    }
    .circuit-speed-btn:active { background: var(--surface2); transform: scale(0.95); }
    .circuit-speed-val {
      min-width: 48px; text-align: center;
      font-size: 16px; font-weight: 800; color: var(--accent-hover);
      font-variant-numeric: tabular-nums;
    }

    /* Circuit create — board + option rows */
    #view-circuit-create .board-graphic { width: 100%; height: auto; display: block; border-radius: 10px; }
    #cc-board { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    #cc-hold-layer { pointer-events: none; }
    .cc-seq-summary { display: flex; gap: 8px; margin: 0 0 14px; }
    .cc-seq-summary span {
      flex: 1; text-align: center; font-size: 13px; font-weight: 700;
      padding: 8px 6px; border-radius: 9px;
      background: var(--surface); border: 1px solid var(--border);
    }
    .cc-seq-summary .muted { flex: 1 1 100%; color: var(--text-muted); font-weight: 600; }
    .cc-seq-summary .c-start  { border-color: rgba(34,197,94,0.4); }
    .cc-seq-summary .c-int    { border-color: rgba(59,130,246,0.4); }
    .cc-seq-summary .c-finish { border-color: rgba(239,68,68,0.4); }

    .cc-option-row {
      display: flex; align-items: center; justify-content: space-between;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
    }
    .cc-option-label { font-size: 14px; font-weight: 600; }
    .cc-option-label small { color: var(--text-muted); font-weight: 500; font-size: 12px; }

    /* 1 / 2 segmented control */
    .cc-seg { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
    .cc-seg-btn {
      background: var(--surface2); color: var(--text-muted); border: none;
      padding: 8px 18px; font-size: 14px; font-weight: 700; cursor: pointer;
      touch-action: manipulation;
    }
    .cc-seg-btn.active { background: var(--accent); color: #fff; }

    /* Loop toggle switch */
    .cc-toggle {
      position: relative; width: 48px; height: 28px; flex: none;
      border-radius: 999px; border: 1px solid var(--border);
      background: var(--surface2); cursor: pointer; padding: 0;
      transition: background 0.15s, border-color 0.15s;
      touch-action: manipulation;
    }
    .cc-toggle.on { background: var(--accent); border-color: var(--accent); }
    .cc-toggle-knob {
      position: absolute; top: 2px; left: 2px;
      width: 22px; height: 22px; border-radius: 50%;
      background: #fff; transition: transform 0.15s;
    }
    .cc-toggle.on .cc-toggle-knob { transform: translateX(20px); }

    /* ── Bottom nav ──────────────────────────────────────────────────── */
    #bottom-nav {
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 150;
      height: calc(var(--nav-h) + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
      display: flex;
      background: rgba(15,15,15,0.95);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-top: 1px solid var(--border);
    }
    .nav-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      text-decoration: none;
      color: var(--text-muted);
      font-size: 11px;
      font-weight: 600;
      transition: color 0.15s;
      touch-action: manipulation;
    }
    .nav-item svg { width: 23px; height: 23px; }
    .nav-item.active { color: var(--accent-hover); }
    .nav-item:active { opacity: 0.7; }

    /* ── States ──────────────────────────────────────────────────────── */
    .state-msg {
      text-align: center;
      color: var(--text-muted);
      padding: 60px 20px;
      font-size: 15px;
      line-height: 1.6;
    }
    .state-msg .icon { font-size: 36px; margin-bottom: 10px; }

    .spinner {
      width: 32px; height: 32px;
      border: 3px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      margin: 60px auto 12px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ── Toast ───────────────────────────────────────────────────────── */
    #toast {
      position: fixed;
      bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
      left: 50%;
      transform: translateX(-50%) translateY(calc(100% + var(--nav-h) + 60px));
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px 18px;
      font-size: 14px;
      font-weight: 500;
      box-shadow: var(--shadow);
      transition: transform 0.25s cubic-bezier(.175,.885,.32,1.275);
      z-index: 200;
      max-width: 90vw;
      text-align: center;
      pointer-events: none;
    }
    #toast.show { transform: translateX(-50%) translateY(0); }
    #toast.success { border-color: var(--cast); color: var(--cast); }
    #toast.error { border-color: #f87171; color: #f87171; }

    /* ── Install (A2HS) banner ───────────────────────────────────────── */
    #install-banner {
      position: fixed;
      left: 12px; right: 12px;
      bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
      z-index: 210;
      display: none;
      align-items: center;
      gap: 12px;
      background: var(--surface);
      border: 1px solid var(--accent);
      border-radius: 14px;
      padding: 12px 14px;
      box-shadow: var(--shadow);
      max-width: 660px;
      margin: 0 auto;
    }
    #install-banner.show { display: flex; animation: fade 0.2s ease; }
    .install-msg { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.4; color: var(--text); }
    .install-msg b { color: var(--accent-hover); }
    .install-actions { display: flex; gap: 8px; flex-shrink: 0; }
    .install-btn {
      border: none;
      border-radius: 9px;
      padding: 9px 14px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      touch-action: manipulation;
      white-space: nowrap;
    }
    .install-btn.add { background: var(--accent); color: #fff; }
    .install-btn.dismiss { background: var(--surface2); color: var(--text-muted); }
