    :root {
      --bg-app:        #D8D0C4;
      --bg-field:      #EDE7DA;
      --bg-panel:      #FAFAF8;
      --bg-toolbar:    #FFFFFF;
      --border-lo:     rgba(120, 95, 70, 0.12);
      --border-mid:    rgba(120, 95, 70, 0.22);
      --border-hi:     rgba(120, 95, 70, 0.45);
      --text-dark:     #1A1410;
      --text-body:     #3C2E24;
      --text-muted:    #7D6A58;   /* 5.15:1 on white — WCAG AA */
      --text-faint:    #7F7468;   /* 4.56:1 on white — WCAG AA */
      --accent:        #7A5230;
      --accent-med:    #A67B5B;
      --accent-light:  rgba(122, 82, 48, 0.1);
      --accent-xlight: rgba(122, 82, 48, 0.05);
      --gold:          #C8960C;
      --gold-light:    rgba(200, 150, 12, 0.15);
      --danger:        #A83232;
      --line-gray:     #888888;
      --danger-light:  rgba(168, 50, 50, 0.08);
      --green:         #2E7D52;
      --shadow-xs:     0 1px 3px rgba(0,0,0,0.05);
      --shadow-sm:     0 2px 8px rgba(0,0,0,0.08);
      --shadow-md:     0 6px 20px rgba(0,0,0,0.12);
      --shadow-lg:     0 12px 40px rgba(0,0,0,0.16);
      --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
      --r-pill: 999px;   /* fully rounded — replaces scattered 20/22/24px literals */
      --empty-msg-color: rgba(60, 46, 36, 0.18);
      /* The field background is SVG, but its colours are theme values like any
         other. Exposing them here means applyTheme() sets variables instead of
         poking attributes through selectors like rect:last-of-type. */
      --field-grad-inner: #F2EDE3;
      --field-grad-outer: #E6DDD0;
      --field-dot:        #B8AD9E;
      --field-border:     #B8AD9E;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold, #C8960C); outline-offset: 2px; border-radius: 3px; }
    html { font-size: 16px; transition: font-size 0.15s; }
    body {
      font-family: 'IBM Plex Sans Arabic', 'Calibri', 'Segoe UI', Tahoma, Arial, sans-serif;
      background: var(--bg-app);
      height: 100vh; height: 100dvh; /* dvh tracks mobile browser chrome */
      display: flex; flex-direction: column;
      overflow: hidden; user-select: none;
      color: var(--text-body);
    }

    /* ══════════════════════════════════
       TOOLBAR
    ══════════════════════════════════ */
    #toolbar {
      height: 54px;
      background: var(--bg-toolbar);
      border-bottom: 1px solid var(--border-lo);
      box-shadow: var(--shadow-xs);
      display: flex; justify-content: space-between; align-items: center;
      padding: 0 20px; z-index: 10; gap: 16px;
      position: relative;
    }
    #toolbar::before {
      content: '';
      position: absolute; top: 0; inset-inline-start: 0; inset-inline-end: 0;
      height: 3px;
      background: linear-gradient(90deg, var(--accent) 0%, var(--accent-med) 100%);
    }
    #toolbar .brand {
      font-size: 1.3rem; font-weight: 700;
      font-family: 'IBM Plex Sans Arabic', 'Calibri', 'Segoe UI', Tahoma, Arial, sans-serif;
      color: var(--accent); letter-spacing: 2px;
      white-space: nowrap; min-width: 60px;
    }
    #toolbar .center { display: flex; gap: 6px; flex-wrap: nowrap; }
    #toolbar .left {
      font-size: 0.8rem; color: var(--text-muted);
      display: flex; align-items: center; gap: 8px;
      white-space: nowrap; min-width: 120px; justify-content: flex-end;
    }

    /* ══════════════════════════════════
       BUTTONS — base
    ══════════════════════════════════ */
    button {
      background: transparent;
      border: 1px solid var(--border-mid);
      border-radius: var(--r-sm);
      padding: 7px 12px;
      cursor: pointer;
      color: var(--text-body);
      font-size: 0.92rem;
      font-weight: 400;
      font-family: inherit;
      line-height: 1;
      transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.1s;
      display: flex; align-items: center; justify-content: center; gap: 5px;
      white-space: nowrap;
    }
    button:hover {
      background: var(--accent-light);
      border-color: var(--accent-med);
      color: var(--accent);
      box-shadow: var(--shadow-xs);
    }
    button:active { transform: scale(0.95); }
    button.active {
      background: var(--accent-light);
      border-color: var(--accent);
      color: var(--accent);
      box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
    }
    button.danger { color: var(--danger); border-color: rgba(168,50,50,0.22); }
    button.danger:hover { background: var(--danger-light); border-color: rgba(168,50,50,0.5); color: var(--danger); }

    /* toolbar buttons slightly larger */
    #toolbar button { padding: 7px 13px; font-size: 0.88rem; }

    #btn-lang {
      font-size: 0.88rem; font-weight: 700;
      min-width: 38px; padding: 6px 8px;
      color: var(--accent); border-color: var(--border-hi);
      border-radius: var(--r-sm);
    }
    #btn-lang:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

    #btn-fontsize {
      font-size: 0.8rem; font-weight: 700;
      padding: 6px 8px; min-width: 34px;
      color: var(--text-muted); border-color: var(--border-mid);
    }
    #btn-fontsize:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent-med); }

    .home-copyright {
      font-size: 0.65rem; color: var(--text-faint);
      text-align: center; letter-spacing: 0.5px;
      margin-top: 4px; opacity: 0.7;
    }

    #home-stats {
      display: flex; gap: 0; align-items: stretch;
      border: 1px solid var(--border-lo);
      border-radius: var(--r-md);
      overflow: hidden;
      width: 100%;
      background: var(--accent-xlight);
      min-height: 52px;
    }
    #home-stats:empty { display: none; }
    .stat-item {
      flex: 1; display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      padding: 8px 6px; gap: 2px;
    }
    .stat-item + .stat-item { border-inline-start: 1px solid var(--border-lo); }
    .stat-num {
      font-size: 1.3rem; font-weight: 700;
      color: var(--accent); line-height: 1;
      font-family: 'Courier New', monospace;
    }
    .stat-lbl {
      font-size: 0.62rem; color: var(--text-faint);
      font-weight: 700; letter-spacing: 0.8px;
      text-transform: uppercase;
    }

    /* ══════════════════════════════════
       LAYOUT
    ══════════════════════════════════ */
    #app-layout { display: flex; flex: 1; overflow: hidden; }

    .side-panel {
      background: var(--bg-panel);
      border-inline-end: 1px solid var(--border-lo);
      display: flex; flex-direction: column;
      padding: 0; z-index: 5; overflow-y: auto;
    }
    .side-panel:last-child { border-inline-end: none; border-inline-start: 1px solid var(--border-lo); }
    #palette-panel { width: 136px; }
    #props-panel   { width: 174px; }

    /* scrollbar */
    .side-panel::-webkit-scrollbar { width: 4px; }
    .side-panel::-webkit-scrollbar-track { background: transparent; }
    .side-panel::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }

    /* ══════════════════════════════════
       PANEL SECTIONS
    ══════════════════════════════════ */
    .panel-section {
      padding: 10px 10px 8px;
      border-bottom: 1px solid var(--border-lo);
    }
    .panel-section:last-child { border-bottom: none; }

    .panel-title {
      font-size: 0.68rem; font-weight: 700; letter-spacing: 1.2px;
      text-transform: uppercase; margin-bottom: 10px;
      color: var(--text-faint);
      display: flex; align-items: center; gap: 5px;
    }
    .panel-title::before {
      content: '';
      display: inline-block; width: 3px; height: 10px;
      background: var(--accent-med); border-radius: 2px; flex-shrink: 0;
    }

    /* ══════════════════════════════════
       CANVAS
    ══════════════════════════════════ */
    #field-canvas {
      flex: 1; position: relative; overflow: hidden; touch-action: none;
      background: var(--bg-field);
    }
    #field-bg { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; }
    #field-grad-in  { stop-color: var(--field-grad-inner); }
    #field-grad-out { stop-color: var(--field-grad-outer); }
    #dotGrid circle { fill: var(--field-dot); }
    #field-border   { stroke: var(--field-border); }

    #empty-msg {
      position: absolute; top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      color: var(--empty-msg-color, rgba(60,46,36,0.18));
      font-size: 1.3rem;
      pointer-events: none; letter-spacing: 3px;
      text-align: center; line-height: 2;
      font-weight: 400;
      display: flex; flex-direction: column; gap: 10px; /* title + hint stacked */
    }

    /* ══════════════════════════════════
       LINES LAYER
    ══════════════════════════════════ */
    /* pan/zoom transform layer holding lines, figures and cone handles */
    #canvas-content {
      position: absolute; inset: 0;
      transform-origin: 0 0;
      will-change: transform;
    }
    /* overflow:visible so vision cones / lines are not clipped at the SVG's own
       edge (e.g. a cone pointing up from a figure near the top, or after panning);
       #field-canvas still clips everything at the real board edge. */
    #lines-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }

    /* zoom controls: compact horizontal row tucked BELOW the dashed field
       frame (the frame's bottom margin is deepened to make room), so the
       board interior stays clear. bottom-start avoids the mobile FAB. */
    #zoom-controls {
      position: absolute; bottom: calc(5px + env(safe-area-inset-bottom, 0px)); inset-inline-start: 12px;
      display: flex; flex-direction: row; gap: 5px; z-index: 40;
    }
    #zoom-controls button {
      width: 28px; height: 28px; padding: 0;
      border-radius: var(--r-sm);
      background: var(--bg-toolbar); border: 1px solid var(--border-mid);
      color: var(--text-body); font-size: 0.9rem; line-height: 1;
      box-shadow: var(--shadow-xs); cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      opacity: 0.85;
      transition: background 0.14s, border-color 0.14s, color 0.14s, opacity 0.14s;
    }
    #zoom-controls button:hover { background: var(--accent-light); border-color: var(--accent-med); color: var(--accent); opacity: 1; }
    /* live zoom % readout — tabular digits so 84% / 300% don't jiggle */
    #zoom-controls #btn-zoom-reset {
      font-size: 0.58rem; font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: var(--text-muted); letter-spacing: -0.2px;
      min-width: 34px; width: auto; padding: 0 4px;
    }
    .relation-line { pointer-events: stroke; cursor: pointer; transition: stroke-width 0.15s, opacity 0.15s; }
    .relation-line:hover { stroke-width: 7 !important; opacity: 0.7; }

    /* ══════════════════════════════════
       FIGURES
    ══════════════════════════════════ */
    .fig-wrapper {
      position: absolute; cursor: grab;
      display: flex; flex-direction: column; align-items: center;
      touch-action: none; z-index: 2;
      filter: drop-shadow(0 3px 6px rgba(0,0,0,0.18));
      transition: filter 0.2s;
    }
    .fig-wrapper:hover { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.25)); }
    .fig-wrapper:active { cursor: grabbing; }
    /* Focus is not the same thing as selection here: you can tab onto a figure
       and read it before deciding to act. The ring has to be visible against
       both the light field and a dark figure, hence the paired outline. */
    .fig-wrapper:focus { outline: none; }
    .fig-wrapper:focus-visible {
      outline: 2px solid var(--accent2, #E8A020);
      outline-offset: 6px;
      border-radius: 6px;
      box-shadow: 0 0 0 4px rgba(255,255,255,0.55);
    }
    #field-canvas:focus { outline: none; }
    #field-canvas:focus-visible {
      outline: 2px solid var(--accent2, #E8A020);
      outline-offset: -4px;
    }
    /* Available to assistive technology, invisible on screen. */
    .sr-only {
      position: absolute; width: 1px; height: 1px;
      margin: -1px; padding: 0; border: 0;
      clip: rect(0 0 0 0); clip-path: inset(50%);
      overflow: hidden; white-space: nowrap;
    }
    .fig-svg-container { position: relative; }
    .fig-label {
      /* absolutely centered UNDER the figure so a long name never widens the
         wrapper (which would shift the figure away from its cone). */
      position: absolute; top: 100%; left: 50%;
      transform: translateX(-50%); margin-top: 6px;
      font-size: 0.75rem; font-weight: 600; color: #fff;
      background: linear-gradient(135deg, rgba(28,20,16,0.78), rgba(60,46,36,0.72));
      padding: 3px 8px; border-radius: var(--r-pill);
      white-space: nowrap; pointer-events: none;
      backdrop-filter: blur(6px);
      letter-spacing: 0;
      box-shadow: 0 1px 4px rgba(0,0,0,0.25);
      max-width: 150px; overflow: hidden; text-overflow: ellipsis; /* long names */
    }

    /* size slider: tick at the default size (scale 1 = 33.3% of the 0.5–2 range) */
    .scale-wrap { position: relative; }
    .scale-wrap::after {
      content: '';
      position: absolute;
      inset-inline-start: calc(33.333% + 2px); /* thumb-width compensation */
      top: 50%; transform: translateY(-50%);
      width: 2px; height: 12px;
      background: var(--accent-med);
      border-radius: 1px;
      opacity: 0.55;
      pointer-events: none;
    }
    .scale-wrap input[type="range"] { width: 100%; position: relative; z-index: 1; }

    /* entrance: a soft "drop" when a figure is placed (reduced-motion zeroes it) */
    @keyframes fig-enter {
      0%   { transform: scale(1.25); opacity: 0; }
      60%  { transform: scale(0.96); opacity: 1; }
      100% { transform: scale(1); }
    }
    .fig-wrapper.fig-enter { animation: fig-enter 0.28s ease-out; }

    /* ══════════════════════════════════
       PALETTE
    ══════════════════════════════════ */
    .grid-2x3 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 0; }
    .add-fig-btn {
      height: 54px;
      border: 1.5px dashed var(--border-mid);
      border-radius: var(--r-sm); cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      background: transparent;
      transition: background 0.14s, border-color 0.14s, box-shadow 0.14s;
    }
    .add-fig-btn:hover {
      background: var(--accent-xlight);
      border-color: var(--accent-med); border-style: solid;
      box-shadow: var(--shadow-xs);
    }
    .add-fig-btn.active {
      background: var(--accent-light);
      border-color: var(--accent); border-style: solid;
      box-shadow: inset 0 1px 4px rgba(0,0,0,0.08);
    }
    .add-fig-btn svg { pointer-events: none; }

    #add-hint {
      background: linear-gradient(135deg, #E8F4FD, #D6ECF8);
      color: #1558A0;
      font-size: 0.75rem; font-weight: 500;
      padding: 7px 8px; border-radius: var(--r-sm);
      text-align: center; margin-bottom: 10px; display: none;
      border: 1px solid rgba(21,88,160,0.18);
    }

    /* ══════════════════════════════════
       PROPS PANEL
    ══════════════════════════════════ */
    .prop-group { margin-bottom: 9px; }
    .prop-group:last-child { margin-bottom: 0; }
    .prop-group label {
      display: block; font-size: 0.75rem; font-weight: 700;
      color: var(--text-muted); margin-bottom: 5px;
      letter-spacing: 0.5px; text-transform: uppercase;
    }
    .prop-input {
      width: 100%;
      border: 1px solid var(--border-mid);
      border-radius: var(--r-sm);
      padding: 6px 8px;
      font-size: 0.84rem;
      font-family: inherit;
      background: var(--bg-panel);
      color: var(--text-dark);
      transition: border-color 0.14s, box-shadow 0.14s;
    }
    .prop-input:focus {
      outline: none;
      border-color: var(--accent-med);
      box-shadow: 0 0 0 3px var(--accent-light);
    }
    /* fate + age side by side; select inherits the input skin */
    .fate-age-row { display: flex; gap: 6px; }
    .fate-age-row > div { flex: 1; min-width: 0; }
    .fate-age-row label { display: block; margin-bottom: 3px; }
    select.prop-input { cursor: pointer; }

    /* ══════════════════════════════════
       CURTAIN MODE (IDEA-0036) — the audience sees only the field.
       Interaction stays live; Esc or the chip raises the curtain.
    ══════════════════════════════════ */
    body.curtain #toolbar,
    body.curtain #palette-panel,
    body.curtain #props-panel,
    body.curtain #zoom-controls,
    body.curtain #m-btn-palette,
    body.curtain #session-bar,
    body.curtain #empty-msg,
    body.curtain #add-hint { display: none !important; }
    #btn-curtain-exit {
      display: none;
      position: fixed;
      top: calc(10px + env(safe-area-inset-top, 0px));
      inset-inline-end: 12px;
      z-index: 60;
      font-size: 0.72rem;
      padding: 5px 10px;
      background: var(--bg-toolbar);
      opacity: 0.35;
      border-radius: var(--r-pill);
    }
    #btn-curtain-exit:hover, #btn-curtain-exit:focus-visible { opacity: 1; }
    body.curtain #btn-curtain-exit { display: flex; }
    body.curtain #trial-bar { display: none !important; } /* only the field remains */

    /* ══════════════════════════════════
       LIVE-SESSION GESTURES (IDEA-0030/0032/0040)
    ══════════════════════════════════ */
    /* «أفضل أم أسوأ؟» floating bar — quiet, centered under the toolbar */
    #trial-bar {
      position: fixed;
      /* below toolbar (54px) + session bar (38px) so it never covers the
         presence chips or the 🤲 signal — the exact context it serves */
      top: calc(96px + env(safe-area-inset-top, 0px));
      inset-inline-start: 50%;
      transform: translateX(50%);
      max-width: calc(100vw - 24px);
      flex-wrap: wrap; justify-content: center;
      z-index: 40;
      display: flex; align-items: center; gap: 8px;
      background: var(--bg-toolbar);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-pill);
      padding: 6px 14px;
      box-shadow: var(--shadow-sm);
      font-size: 0.82rem;
    }
    html[dir="ltr"] #trial-bar { transform: translateX(-50%); }
    #trial-title { font-weight: 700; color: var(--accent); }
    #trial-hint  { color: var(--text-faint); font-size: 0.74rem; }
    #trial-bar button { padding: 5px 10px; font-size: 0.78rem; }

    /* soft spotlight: a 4s breathing halo — never a blink */
    .fig-spot-halo { animation: spot-breathe 4s ease-in-out infinite; }
    @keyframes spot-breathe { 0%, 100% { opacity: 0.10; } 50% { opacity: 0.32; } }

    /* quiet hand signal: the client chip warms amber, nothing else moves */
    .presence-user {
      padding: 2px 8px;
      border-radius: var(--r-pill);
      background: transparent;
      box-shadow: none;
      transition: background 1.2s ease, box-shadow 1.2s ease;
    }
    .presence-user.signal-on {
      background: var(--gold-light);
      box-shadow: 0 0 0 1px rgba(200, 150, 12, 0.35);
    }
    #btn-hand-signal { font-size: 1rem; padding: 5px 9px; }
    #btn-hand-signal.sent { background: var(--gold-light); border-color: var(--gold); }

    input[type="range"] {
      accent-color: var(--accent);
      cursor: pointer; width: 100%;
    }

    .colors-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
    /* These are <button>s so the keyboard can reach them; padding:0 and the
       inherited font undo what the UA stylesheet would otherwise impose. */
    .color-dot {
      width: 100%; aspect-ratio: 1; border-radius: 50%; cursor: pointer;
      border: 2.5px solid transparent;
      padding: 0; font: inherit; -webkit-appearance: none; appearance: none;
      box-shadow: 0 1px 4px rgba(0,0,0,0.22);
      transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
    }
    .color-dot:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 3px;
    }
    .color-dot-light { border-color: var(--border-mid); }

    /* Line colours come from the theme tokens, not from a hex repeated in the
       markup — the red and green here ARE --danger and --green. */
    .btn-line-color { color: #fff; }
    .btn-line-color[data-val="#888888"] { background: var(--line-gray); border-color: var(--line-gray); }
    .btn-line-color[data-val="#A83232"] { background: var(--danger);    border-color: var(--danger); }
    .btn-line-color[data-val="#2E7D52"] { background: var(--green);     border-color: var(--green); }
    .color-dot:hover { transform: scale(1.14); box-shadow: 0 2px 8px rgba(0,0,0,0.28); }
    .color-dot.selected {
      border-color: var(--text-dark);
      box-shadow: 0 0 0 1px var(--text-dark), 0 2px 6px rgba(0,0,0,0.22);
      transform: scale(1.08);
    }

    .fig-info-card {
      background: linear-gradient(135deg, var(--accent-light), var(--accent-xlight));
      border: 1px solid var(--border-mid);
      border-radius: var(--r-md);
      padding: 9px 10px;
      text-align: center;
      font-size: 0.84rem; font-weight: 700;
      color: var(--accent);
      letter-spacing: 0.3px;
    }


    /* ══════════════════════════════════
       COMPASS
    ══════════════════════════════════ */
    .compass-wrap {
      background: var(--accent-xlight);
      border: 1px solid var(--border-lo);
      border-radius: var(--r-md);
      padding: 8px;
    }
    .compass-grid {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
      margin-bottom: 5px;
    }
    .compass-btn {
      height: 26px; font-size: 0.85rem; border-radius: var(--r-sm); padding: 0;
      border: 1px solid var(--border-lo); background: var(--bg-panel);
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      transition: background 0.12s, border-color 0.12s, color 0.12s;
      color: var(--text-muted);
    }
    .compass-btn:hover { background: var(--accent-light); border-color: var(--accent-med); color: var(--accent); }
    .compass-btn.active {
      background: var(--accent); border-color: var(--accent);
      color: #fff; box-shadow: var(--shadow-xs);
    }
    .compass-center {
      height: 26px; display: flex; align-items: center; justify-content: center;
      font-size: 0.7rem; font-weight: 700; color: var(--accent);
      background: linear-gradient(135deg, var(--accent-light), var(--accent-xlight));
      border-radius: var(--r-sm);
      border: 1px solid var(--border-mid);
      letter-spacing: 0.5px;
    }
    .compass-tip {
      font-size: 0.68rem; color: var(--text-faint);
      text-align: center; line-height: 1.4;
    }

    /* cone visibility toggle */
    .direction-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
    .direction-header label { margin-bottom: 0; }
    #btn-toggle-fig-cone {
      padding: 2px 7px; font-size: 0.8rem; border-radius: var(--r-pill);
      line-height: 1.4; min-width: unset;
    }
    #btn-toggle-fig-cone.hidden-cone { color: var(--text-faint); border-color: var(--border-lo); }
    #btn-toggle-cones.cones-off { opacity: 0.55; }

    /* ══════════════════════════════════
       TIMELINE / STAGES PANEL
    ══════════════════════════════════ */
    #timeline-panel {
      position: absolute; top: 54px; right: 0;
      width: 280px; max-height: 360px;
      background: var(--bg-panel);
      border: 1px solid var(--border-mid); border-top: none;
      box-shadow: var(--shadow-md);
      z-index: 20; display: none; flex-direction: column;
      border-end-start-radius: var(--r-md); overflow: hidden;
    }
    #timeline-panel.has-session-bar { top: 92px; }
    #timeline-header {
      height: 34px; background: var(--accent-xlight);
      border-bottom: 1px solid var(--border-lo);
      display: flex; align-items: center; padding: 0 12px;
      font-size: 0.8rem; font-weight: 700; color: var(--accent);
      letter-spacing: 0.5px; flex-shrink: 0;
    }
    #timeline-header::before { content: '🎬'; margin-inline-end: 6px; }
    #timeline-capture-wrap { padding: 10px 12px; border-bottom: 1px solid var(--border-lo); flex-shrink: 0; }
    #btn-capture { width: 100%; background: var(--accent); color: #fff; border: none; padding: 9px; font-weight: 700; border-radius: var(--r-sm); }
    #btn-capture:hover { filter: brightness(0.9); background: var(--accent); color: #fff; }
    #timeline-list { overflow-y: auto; padding: 6px; min-height: 60px; }
    .timeline-empty { text-align: center; color: var(--text-faint); font-size: 0.78rem; padding: 22px 10px; line-height: 1.6; }
    .timeline-item {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 10px; margin-bottom: 5px; cursor: pointer;
      border: 1px solid var(--border-lo); border-radius: var(--r-sm);
      background: var(--accent-xlight); transition: background 0.12s, border-color 0.12s;
    }
    .timeline-item:hover { background: var(--accent-light); border-color: var(--border-mid); }
    .timeline-num {
      flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
      background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      font-family: 'Courier New', monospace;
    }
    .timeline-meta { flex: 1; font-size: 0.76rem; color: var(--text-body); }
    .timeline-del {
      background: none; border: none; cursor: pointer; color: var(--text-faint);
      font-size: 0.85rem; padding: 2px 5px; border-radius: var(--r-sm); line-height: 1; font-family: inherit;
    }
    .timeline-del:hover { color: var(--danger); background: var(--danger-light); }
    @media (max-width: 768px) {
      #timeline-panel { left: 0 !important; right: 0 !important; width: 100% !important; border-radius: 0 0 var(--r-md) var(--r-md); }
    }

    /* ══════════════════════════════════
       NOTES PANEL
    ══════════════════════════════════ */
    #notes-panel {
      position: absolute; top: 54px; right: 0;
      width: 300px; height: 320px;
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-top: none;
      box-shadow: var(--shadow-md);
      z-index: 20; display: none; flex-direction: column;
      border-radius: 0 0 0 var(--r-md);
      overflow: hidden;
    }
    #notes-panel.has-session-bar { top: 92px; }
    #notes-header {
      height: 34px; background: var(--accent-xlight);
      border-bottom: 1px solid var(--border-lo);
      display: flex; align-items: center; padding: 0 12px;
      font-size: 0.8rem; font-weight: 700; color: var(--accent);
      letter-spacing: 0.5px; flex-shrink: 0;
    }
    .notes-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
    .notes-section + .notes-section { border-top: 1px solid var(--border-lo); }
    .notes-sec-label {
      font-size: 0.68rem; font-weight: 700; color: var(--text-faint);
      letter-spacing: 1px; text-transform: uppercase;
      padding: 5px 12px 3px; background: var(--accent-xlight);
      flex-shrink: 0;
    }
    #notes-panel textarea {
      flex: 1; border: none; resize: none;
      padding: 10px 14px; font-size: 0.88rem; outline: none;
      background: transparent; color: var(--text-dark);
      line-height: 1.7; font-family: inherit;
    }

    /* ══════════════════════════════════
       LINE PROPS
    ══════════════════════════════════ */
    .line-style-btns { display: flex; gap: 4px; margin-bottom: 0; }
    .line-style-btns button { flex: 1; font-size: 0.78rem; padding: 6px 4px; }

    /* ══════════════════════════════════
       EMPTY STATE
    ══════════════════════════════════ */
    #props-empty-inner {
      text-align: center; color: var(--text-faint);
      font-size: 0.8rem; padding: 28px 12px; line-height: 1.8;
    }
    #props-empty-inner .empty-icon {
      width: 36px; height: 36px; margin: 0 auto 10px;
      opacity: 0.4;
    }


    /* ══════════════════════════════════
       MISC
    ══════════════════════════════════ */
    .crosshair-cursor { cursor: crosshair !important; }
    .spacer { flex: 1; }

    /* ══════════════════════════════════
       HOME SCREEN
    ══════════════════════════════════ */
    #home-screen {
      position: fixed; inset: 0; z-index: 200;
      background: var(--bg-app);
      display: flex; flex-direction: column; align-items: center;
      overflow-y: auto;
      padding: 24px 0;
    }
    .home-card {
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-lg);
      padding: 40px 36px;
      width: 380px; max-width: 94vw;
      display: flex; flex-direction: column; align-items: center; gap: 14px;
    }
    .home-brand {
      font-size: 3.25rem; font-weight: 700;
      font-family: 'IBM Plex Sans Arabic', 'Calibri', 'Segoe UI', Tahoma, Arial, sans-serif;
      color: var(--accent); letter-spacing: 4px;
      line-height: 1;
    }
    .home-subtitle {
      font-size: 0.88rem; color: var(--text-muted); letter-spacing: 0.5px;
      margin-bottom: 4px;
    }
    .home-btn-primary {
      width: 100%; padding: 13px 16px;
      background: var(--accent); color: #fff;
      border: none; border-radius: var(--r-md);
      font-size: 0.95rem; font-weight: 700;
      cursor: pointer; font-family: inherit;
      transition: background 0.15s, transform 0.1s;
      display: flex; align-items: center; justify-content: center; gap: 8px;
    }
    .home-btn-primary:hover { filter: brightness(0.85); }
    .home-btn-primary:active { transform: scale(0.97); filter: none; }
    .home-btn-primary .sub { font-size: 0.8rem; opacity: 0.75; font-weight: 500; }
    .home-divider {
      display: flex; align-items: center; gap: 10px; width: 100%;
      color: var(--text-faint); font-size: 0.8rem;
    }
    .home-divider::before, .home-divider::after {
      content: ''; flex: 1; height: 1px; background: var(--border-lo);
    }
    .home-join-row { display: flex; gap: 8px; width: 100%; }
    .home-join-input {
      flex: 1; padding: 10px 12px;
      border: 1px solid var(--border-mid); border-radius: var(--r-sm);
      font-size: 1rem; font-family: 'Courier New', monospace;
      text-align: center; letter-spacing: 4px; text-transform: uppercase;
      color: var(--text-dark); background: var(--bg-panel);
      transition: border-color 0.14s, box-shadow 0.14s;
    }
    .home-join-input:focus { outline: none; border-color: var(--accent-med); box-shadow: 0 0 0 3px var(--accent-light); }
    .home-join-input::placeholder { letter-spacing: 2px; color: var(--text-faint); font-size: 0.92rem; font-family: inherit; }
    .home-btn-join {
      padding: 10px 16px; white-space: nowrap;
      background: transparent; border: 1px solid var(--border-mid);
      border-radius: var(--r-sm); font-size: 0.92rem; font-weight: 600;
      cursor: pointer; font-family: inherit; color: var(--text-body);
      transition: background 0.14s, border-color 0.14s, color 0.14s;
    }
    .home-btn-join:hover { background: var(--accent-light); border-color: var(--accent-med); color: var(--accent); }
    .home-btn-local {
      font-size: 0.8rem; color: var(--text-faint); background: none;
      border: none; cursor: pointer; font-family: inherit;
      padding: 7px 10px; min-height: 26px;   /* WCAG 2.2 target size, with room for sub-pixel rounding */
    }
    .home-btn-local:hover { color: var(--text-muted); text-decoration: underline; }
    #home-help-link {
      font-size: 0.82rem; color: var(--text-muted); text-decoration: none;
      margin-top: 2px; padding: 4px 8px; min-height: 24px;   /* WCAG 2.2 target size */
      display: inline-flex; align-items: center; gap: 4px;
    }
    #home-help-link:hover { text-decoration: underline; }

    .home-author {
      display: inline-flex; align-items: center; gap: 9px;
      margin-top: 12px; text-decoration: none;
      background: var(--accent-light);
      border: 1px solid var(--accent-med);
      border-radius: var(--r-pill);
      padding: 7px 18px;
    }
    .home-author-name { font-weight: 700; color: var(--accent); font-size: 0.92rem; }
    .home-author-sub  { color: var(--text-muted); font-size: 0.8rem; }

    .home-sessions-wrap { width: 100%; }
    #home-sessions-list { max-height: 200px; overflow-y: auto; }
    .home-sessions-title {
      font-size: 0.68rem; color: var(--text-faint); font-weight: 700;
      letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 8px;
    }
    .home-session-item {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 10px; border: 1px solid var(--border-lo);
      border-radius: var(--r-sm); cursor: pointer; margin-bottom: 5px;
      background: var(--accent-xlight);
      transition: background 0.12s, border-color 0.12s;
    }
    .home-session-item:hover { background: var(--accent-light); border-color: var(--border-mid); }
    .home-session-code { font-size: 0.92rem; font-weight: 700; color: var(--accent); letter-spacing: 2px; font-family: 'Courier New', monospace; }
    .home-session-meta { font-size: 0.75rem; color: var(--text-faint); }
    .home-session-role { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

    /* ══════════════════════════════════
       SESSION BAR
    ══════════════════════════════════ */
    #session-bar {
      height: 38px;
      background: linear-gradient(90deg, #1C1208, #2C1A0E);
      color: #E8D5B8;
      display: none; align-items: center;
      padding: 0 14px; gap: 10px;
      font-size: 0.8rem; z-index: 9; flex-shrink: 0;
      border-bottom: 1px solid rgba(0,0,0,0.25);
      position: relative;
    }
    .conn-dot {
      width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
      background: #66BB6A; box-shadow: 0 0 5px rgba(102,187,106,0.6);
      transition: background 0.3s;
    }
    .conn-dot.connecting { background: #FFA726; box-shadow: 0 0 5px rgba(255,167,38,0.6); animation: blink 1s infinite; }
    .conn-dot.offline    { background: #EF5350; box-shadow: none; animation: none; }
    @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

    #session-code-badge {
      display: flex; align-items: center; gap: 6px;
      background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.18);
      border-radius: var(--r-pill); padding: 3px 12px;
      cursor: pointer; transition: background 0.14s;
      font-weight: 700; letter-spacing: 3px; font-size: 0.92rem;
      font-family: 'Courier New', monospace;
    }
    #session-code-badge:hover { background: rgba(255,255,255,0.16); }
    #code-copied-msg { font-size: 0.68rem; color: #A5D6A7; font-weight: 400; letter-spacing: 0; display: none; }

    #session-role-badge {
      border-radius: var(--r-pill); padding: 3px 10px;
      font-size: 0.75rem; font-weight: 700;
      background: rgba(200,150,12,0.25); border: 1px solid rgba(200,150,12,0.4); color: #F0C040;
    }
    #session-role-badge.client { background: rgba(74,127,165,0.25); border-color: rgba(74,127,165,0.4); color: #7ABFEF; }

    .sbar-spacer { flex: 1; }

    #session-perms-btn {
      background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
      color: #E8D5B8; border-radius: var(--r-sm);
      padding: 4px 10px; font-size: 0.75rem; cursor: pointer;
      font-family: inherit; transition: background 0.14s; display: none;
    }
    #session-perms-btn:hover { background: rgba(255,255,255,0.16); }

    #session-perms-panel {
      position: absolute; top: calc(100% + 6px);
      background: var(--bg-panel); border: 1px solid var(--border-mid);
      border-radius: var(--r-md); box-shadow: var(--shadow-md);
      padding: 10px 14px; z-index: 50; min-width: 220px; display: none;
    }
    [dir="rtl"] #session-perms-panel { right: auto; left: 60px; }
    [dir="ltr"] #session-perms-panel { left: auto; right: 60px; }
    .perms-panel-title {
      font-size: 0.68rem; color: var(--text-faint); font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;
    }
    .perm-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 7px 0; border-bottom: 1px solid var(--border-lo);
      font-size: 0.84rem; color: var(--text-body); gap: 12px;
    }
    .perm-row:last-child { border-bottom: none; }
    /* toggle switch */
    .tog { position: relative; width: 34px; height: 20px; flex-shrink: 0; }
    .tog input { opacity: 0; width: 0; height: 0; position: absolute; }
    .tog-track {
      position: absolute; inset: 0; border-radius: 10px;
      background: var(--border-mid); cursor: pointer; transition: background 0.2s;
    }
    .tog-track::after {
      content: ''; position: absolute;
      width: 16px; height: 16px; border-radius: 50%;
      background: #fff; top: 2px; left: 2px;
      transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    }
    .tog input:checked ~ .tog-track { background: var(--green); }
    .tog input:checked ~ .tog-track::after { transform: translateX(14px); }

    #btn-end-session {
      background: rgba(168,50,50,0.18); border: 1px solid rgba(168,50,50,0.35);
      color: #FFAB91; border-radius: var(--r-sm);
      padding: 4px 11px; font-size: 0.75rem; cursor: pointer;
      font-family: inherit; transition: background 0.14s; white-space: nowrap;
    }
    #btn-end-session:hover { background: rgba(168,50,50,0.32); }

    /* name input on home screen */
    .home-name-wrap { width: 100%; }
    .home-name-label { font-size: 0.75rem; color: var(--text-faint); font-weight: 700; letter-spacing: 0.5px; margin-bottom: 5px; display: block; }
    .home-name-input {
      width: 100%; padding: 9px 12px;
      border: 1px solid var(--border-mid); border-radius: var(--r-sm);
      font-size: 0.92rem; font-family: inherit;
      color: var(--text-dark); background: var(--bg-panel);
      transition: border-color 0.14s, box-shadow 0.14s;
    }
    .home-name-input:focus { outline: none; border-color: var(--accent-med); box-shadow: 0 0 0 3px var(--accent-light); }

    /* home screen lang toggle */
    .home-card { position: relative; }
    #btn-home-lang {
      position: absolute; top: 12px; inset-inline-end: 14px;
      font-size: 0.88rem; font-weight: 700;
      padding: 4px 9px; min-width: 36px;
      color: var(--accent); border: 1.5px solid var(--border-hi);
      border-radius: var(--r-sm); background: transparent;
      cursor: pointer; font-family: inherit;
      transition: background 0.14s, color 0.14s;
    }
    #btn-home-lang:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

    /* presence in session bar */
    #session-presence {
      display: flex; align-items: center; gap: 10px;
      font-size: 0.78rem; color: rgba(232,213,184,0.75);
    }
    .presence-user { display: flex; align-items: center; gap: 5px; }
    .presence-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: #66BB6A; box-shadow: 0 0 4px rgba(102,187,106,0.5); }
    .presence-dot.offline { background: #888; box-shadow: none; }
    .presence-dot.waiting { background: #FFA726; box-shadow: 0 0 4px rgba(255,167,38,0.5); animation: blink 1.5s infinite; }
    .presence-sep { color: rgba(232,213,184,0.25); }

    /* delete button on recent session items */
    .home-session-del {
      background: none; border: none; cursor: pointer;
      color: var(--text-faint); font-size: 0.92rem; padding: 2px 4px;
      border-radius: var(--r-sm); transition: color 0.14s, background 0.14s;
      font-family: inherit; line-height: 1;
    }
    .home-session-del:hover { color: var(--danger); background: var(--danger-light); }

    /* ══════════════════════════════════
       THEME PICKER
    ══════════════════════════════════ */
    .more-btn-wrap { position: relative; display: flex; align-items: center; }

    #btn-more { padding: 7px 12px; font-size: 1rem; line-height: 1; font-weight: 700; }

    /* «⋯» overflow menu: secondary toolbar actions (export, font size, themes) */
    #more-menu {
      display: none;
      position: absolute;
      top: calc(100% + 8px);
      left: 50%;
      transform: translateX(-50%);
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-md);
      box-shadow: var(--shadow-md);
      padding: 8px;
      z-index: 200;
      flex-direction: column;
      gap: 2px;
      white-space: nowrap;
      min-width: 200px;
    }
    #more-menu.open { display: flex; }
    #toolbar #more-menu button {
      display: block; width: 100%; text-align: start;
      background: none; border: none; box-shadow: none;
      color: var(--text-body); font-size: 0.85rem;
      padding: 8px 10px; border-radius: var(--r-sm);
    }
    #toolbar #more-menu button:hover { background: var(--accent-light); color: var(--accent); }
    .more-menu-sep { height: 1px; background: var(--border-lo); margin: 6px 2px; }

    #theme-picker-title {
      font-size: 0.68rem; font-weight: 700; letter-spacing: 1px;
      text-transform: uppercase; color: var(--text-faint);
      width: 100%; text-align: start; padding: 4px 10px 2px;
    }

    .theme-swatches-row { display: flex; gap: 7px; padding: 2px 10px 6px; }

    .theme-swatch {
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      cursor: pointer;
      background: none; border: none; padding: 2px; font: inherit;
      -webkit-appearance: none; appearance: none;
    }
    .theme-swatch:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
      border-radius: var(--r-sm);
    }
    .theme-swatch-dot {
      width: 26px; height: 26px;
      border-radius: var(--r-sm);
      border: 2px solid var(--border-mid);
      transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
      position: relative; overflow: hidden;
    }
    .theme-swatch:hover .theme-swatch-dot { transform: scale(1.12); border-color: var(--border-hi); }
    .theme-swatch.active .theme-swatch-dot { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
    .theme-swatch-lbl {
      font-size: 0.68rem; color: var(--text-faint);
      letter-spacing: 0.3px; line-height: 1;
    }
    .theme-swatch.active .theme-swatch-lbl { color: var(--accent); font-weight: 700; }

    /* ══════════════════════════════════
       ABOUT BUTTON & MODAL
    ══════════════════════════════════ */
    #btn-about {
      position: absolute; top: 12px; inset-inline-start: 14px;
      font-size: 0.75rem; font-weight: 700;
      padding: 6px 9px; min-width: 32px; min-height: 26px;   /* WCAG 2.2 target size, with room for sub-pixel rounding */
      color: var(--text-faint); border: 1.5px solid var(--border-mid);
      border-radius: var(--r-sm); background: transparent;
      cursor: pointer; font-family: inherit;
      transition: background 0.14s, color 0.14s, border-color 0.14s;
    }
    #btn-about:hover { color: var(--accent); border-color: var(--accent-med); background: var(--accent-xlight); }

    #about-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.45); z-index: 400;
      align-items: center; justify-content: center;
      backdrop-filter: blur(4px);
    }
    #about-overlay.open { display: flex; }

    #about-modal {
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-lg);
      padding: 32px 36px 28px;
      width: 440px; max-width: 94vw; max-height: 88vh;
      overflow-y: auto;
      position: relative;
    }
    #about-modal-title {
      font-size: 1.5rem; font-weight: 700;
      color: var(--accent); letter-spacing: 1px;
      margin-bottom: 4px;
    }
    #about-modal-sub {
      font-size: 0.8rem; color: var(--text-faint);
      margin-bottom: 20px; letter-spacing: 0.3px;
    }
    .about-section { margin-bottom: 18px; }
    .about-section-title {
      font-size: 0.75rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 1px;
      color: var(--accent-med); margin-bottom: 7px;
      padding-bottom: 5px;
      border-bottom: 1px solid var(--border-lo);
    }
    .about-section p {
      font-size: 0.88rem; color: var(--text-body);
      line-height: 1.85; margin-bottom: 8px;
    }
    .about-section p:last-child { margin-bottom: 0; }
    .about-contact {
      background: var(--accent-xlight);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-md);
      padding: 12px 16px;
      font-size: 0.84rem; color: var(--text-muted);
      line-height: 1.7;
    }
    .about-contact a {
      color: var(--accent); font-weight: 600;
      text-decoration: none;
    }
    .about-contact a:hover { text-decoration: underline; }
    #btn-close-about {
      position: absolute; top: 14px; inset-inline-end: 16px;
      background: none; border: none; cursor: pointer;
      font-size: 1.1rem; color: var(--text-faint); padding: 4px 8px;
      border-radius: var(--r-sm); font-family: inherit; line-height: 1;
      transition: color 0.14s, background 0.14s;
    }
    #btn-close-about:hover { color: var(--text-dark); background: var(--border-lo); }

    /* ══════════════════════════════════
       MOBILE FLOAT BUTTON & DIM
       (hidden on desktop, shown via @media)
    ══════════════════════════════════ */
    #m-btn-palette {
      display: none;
      position: fixed;
      bottom: calc(22px + env(safe-area-inset-bottom, 0px));
      inset-inline-end: 22px;
      width: 52px; height: 52px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      font-size: 1.6rem; font-weight: 300;
      border: none;
      box-shadow: 0 4px 18px rgba(0,0,0,0.28);
      z-index: 60;
      cursor: pointer;
      transition: transform 0.2s, filter 0.15s;
      padding: 0;
      line-height: 1;
    }
    #m-btn-palette:active { filter: brightness(0.88); }
    #m-btn-palette.open { transform: rotate(45deg); }

    #m-dim {
      display: none;
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.38);
      z-index: 45;
    }
    #m-dim.active { display: block; }

    /* ══════════════════════════════════
       RESPONSIVE — MOBILE ≤ 768px
    ══════════════════════════════════ */
    @media (max-width: 768px) {
      /* ── Toolbar ── */
      #toolbar {
        height: 48px;
        padding: 0 8px;
        gap: 4px;
        flex-shrink: 0;
      }
      #toolbar .brand { display: none; }
      #toolbar .center {
        flex: 1;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 4px;
        padding: 0 2px;
        justify-content: flex-start;
      }
      #toolbar .center::-webkit-scrollbar { display: none; }
      #toolbar button { padding: 6px 9px; font-size: 0.78rem; flex-shrink: 0; }
      #toolbar .left { min-width: unset; gap: 5px; }
      #counter { display: none; }
      #btn-exit-local { font-size: 0.75rem; padding: 5px 8px; }

      /* ── Session bar ── */
      #session-bar { height: 34px; padding: 0 10px; gap: 7px; font-size: 0.72rem; }
      #session-presence { display: none; }
      #session-code-badge { padding: 2px 9px; font-size: 0.8rem; letter-spacing: 2px; }

      /* ── App layout: canvas fills full width ── */
      #app-layout { position: relative; }

      /* ── Side panels → bottom drawers ── */
      #palette-panel,
      #props-panel {
        position: fixed !important;
        bottom: 0; left: 0; right: 0;
        width: 100% !important;
        height: auto;
        max-height: 60vh;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        border: 1px solid var(--border-mid);
        border-bottom: none;
        border-inline-end: none;
        border-inline-start: none;
        box-shadow: 0 -4px 28px rgba(0,0,0,0.22);
        transform: translateY(110%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 50;
        overflow-y: auto;
        overflow-x: hidden;
        flex-direction: column;
        padding-bottom: env(safe-area-inset-bottom, 0px); /* clear the iOS home indicator */
      }
      #palette-panel.m-open,
      #props-panel.m-open { transform: translateY(0); }

      /* drag-handle pill */
      #palette-panel::before,
      #props-panel::before {
        content: '';
        display: block;
        width: 36px; height: 4px;
        background: var(--border-mid);
        border-radius: 2px;
        margin: 10px auto 4px;
        flex-shrink: 0;
      }

      /* spread palette figures into a single row that wraps */
      .grid-2x3 { grid-template-columns: repeat(6, 1fr); }
      .panel-section { padding: 8px 14px 10px; }

      /* ── Notes panel full-width ── */
      #notes-panel {
        left: 0 !important; right: 0 !important;
        width: 100% !important;
        border-left: none; border-right: none;
        border-radius: 0 0 var(--r-md) var(--r-md);
      }

      /* ── Home card ── */
      .home-card { padding: 28px 18px 24px; gap: 12px; }
      .home-brand { font-size: 2.6rem; }

      /* Show FAB */
      #m-btn-palette { display: flex; align-items: center; justify-content: center; }

      /* New modals full-width-ish on mobile */
      .modal-box { width: 92vw !important; }
      #btn-share-session { padding: 4px 8px; font-size: 0.72rem; }
    }

    /* ══════════════════════════════════
       EMPTY STATE HINT
    ══════════════════════════════════ */
    .empty-msg-hint {
      font-size: 0.82rem; letter-spacing: 0.5px;
      opacity: 0.7; font-weight: 400;
    }

    /* ══════════════════════════════════
       TOAST
    ══════════════════════════════════ */
    #toast-container {
      position: fixed; bottom: 24px; left: 50%;
      transform: translateX(-50%);
      z-index: 600; display: flex; flex-direction: column;
      gap: 8px; align-items: center; pointer-events: none;
      width: max-content; max-width: 90vw;
    }
    .toast {
      background: var(--text-dark); color: #fff;
      padding: 11px 18px; border-radius: var(--r-md);
      font-size: 0.88rem; font-family: inherit;
      box-shadow: var(--shadow-md);
      display: flex; align-items: center; gap: 8px;
      opacity: 0; transform: translateY(12px);
      transition: opacity 0.25s, transform 0.25s;
      max-width: 100%; line-height: 1.5;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.error   { background: var(--danger); }
    .toast.success { background: var(--green); }

    /* ══════════════════════════════════
       GENERIC MODAL (confirm / share)
    ══════════════════════════════════ */
    .modal-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.45); z-index: 500;
      align-items: center; justify-content: center;
      backdrop-filter: blur(4px);
    }
    .modal-overlay.open { display: flex; }
    .modal-box {
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-lg);
      padding: 26px 28px 22px;
      width: 360px; max-width: 94vw;
      position: relative;
      display: flex; flex-direction: column;
    }
    .modal-close {
      position: absolute; top: 12px; inset-inline-end: 14px;
      background: none; border: none; cursor: pointer;
      font-size: 1rem; color: var(--text-faint); padding: 4px 8px;
      border-radius: var(--r-sm); font-family: inherit; line-height: 1;
      transition: color 0.14s, background 0.14s;
    }
    .modal-close:hover { color: var(--text-dark); background: var(--border-lo); }
    .modal-btn-primary {
      padding: 10px 16px; background: var(--accent); color: #fff;
      border: none; border-radius: var(--r-md);
      font-size: 0.9rem; font-weight: 700; cursor: pointer;
      font-family: inherit; transition: filter 0.14s, transform 0.1s;
      white-space: nowrap;
    }
    .modal-btn-primary:hover { filter: brightness(0.9); }
    .modal-btn-primary:active { transform: scale(0.97); }
    .modal-btn-secondary {
      padding: 10px 16px; background: transparent;
      border: 1px solid var(--border-mid); border-radius: var(--r-md);
      font-size: 0.9rem; font-weight: 600; cursor: pointer;
      color: var(--text-body); font-family: inherit;
      transition: background 0.14s, border-color 0.14s;
    }
    .modal-btn-secondary:hover { background: var(--accent-light); border-color: var(--accent-med); }
    .modal-btn-danger {
      padding: 10px 16px; background: var(--danger); color: #fff;
      border: none; border-radius: var(--r-md);
      font-size: 0.9rem; font-weight: 700; cursor: pointer;
      font-family: inherit; transition: filter 0.14s, transform 0.1s;
    }
    .modal-btn-danger:hover { filter: brightness(0.9); }
    .modal-btn-danger:active { transform: scale(0.97); }

    /* confirm */
    .confirm-msg {
      font-size: 0.95rem; color: var(--text-body);
      line-height: 1.7; text-align: center; margin-bottom: 20px;
    }
    .confirm-actions { display: flex; gap: 10px; justify-content: center; }
    .confirm-actions button { flex: 1; }

    /* share */
    .share-box { align-items: center; text-align: center; }
    .share-title { font-size: 1.2rem; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
    .share-sub { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }
    #share-qr {
      width: 160px; height: 160px; padding: 10px;
      background: #fff; border-radius: var(--r-md);
      border: 1px solid var(--border-lo);
      display: flex; align-items: center; justify-content: center;
      margin-bottom: 14px;
    }
    #share-qr img, #share-qr canvas { display: block; }
    .share-code-big {
      font-size: 1.6rem; font-weight: 700; letter-spacing: 6px;
      color: var(--accent); font-family: 'Courier New', monospace;
      margin-bottom: 16px;
    }
    .share-link-row { display: flex; gap: 8px; width: 100%; }
    .share-link-input {
      flex: 1; padding: 9px 12px; min-width: 0;
      border: 1px solid var(--border-mid); border-radius: var(--r-sm);
      font-size: 0.78rem; font-family: 'Courier New', monospace;
      color: var(--text-muted); background: var(--accent-xlight);
      text-overflow: ellipsis;
    }
    .share-copied {
      display: none; font-size: 0.78rem; color: var(--green);
      font-weight: 700; margin-top: 10px;
    }
    .share-copied.show { display: block; }

    /* share button in session bar */
    #btn-share-session {
      background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
      color: #E8D5B8; border-radius: var(--r-sm);
      padding: 4px 11px; font-size: 0.75rem; cursor: pointer;
      font-family: inherit; transition: background 0.14s; white-space: nowrap;
      display: none;
    }
    #btn-share-session:hover { background: rgba(255,255,255,0.16); }

    /* lock button + badge */
    #btn-toggle-lock.locked {
      background: var(--gold-light); border-color: var(--gold); color: var(--accent);
    }

    /* watch-intro button on the home card */
    .home-watch-btn {
      background: transparent; border: 1px solid var(--border-mid);
      color: var(--accent); border-radius: var(--r-pill);
      padding: 6px 16px; font-size: 0.82rem; font-weight: 600;
      cursor: pointer; font-family: inherit; margin-top: -4px;
      transition: background 0.14s, border-color 0.14s, color 0.14s;
    }
    .home-watch-btn:hover { background: var(--accent-light); border-color: var(--accent-med); color: var(--accent); }

    /* intro overlay (animated explainer in an iframe) */
    .intro-box {
      position: relative; width: min(94vw, 900px);
      background: #000; border-radius: var(--r-lg);
      box-shadow: var(--shadow-lg); overflow: hidden;
    }
    .intro-box .modal-close {
      z-index: 2; background: rgba(255,255,255,0.9);
      width: 30px; height: 30px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
    }
    .intro-frame-wrap { width: 100%; aspect-ratio: 16 / 9; }
    #intro-frame { width: 100%; height: 100%; border: none; display: block; }

    /* ══════════════════════════════════════
       HOME — quiet editorial / SEO section
    ══════════════════════════════════════ */
    .home-seo {
      width: min(560px, calc(100% - 40px));
      margin: 18px auto 40px;
      color: var(--text-body);
      font-size: 0.92rem;
      line-height: 1.9;
    }
    /* the whole section folds behind one quiet line */
    .home-seo-fold > summary {
      list-style: none;
      cursor: pointer;
      text-align: center;
      color: var(--text-muted);
      font-size: 0.86rem;
      font-weight: 700;
      padding: 8px 0;
      user-select: none;
    }
    .home-seo-fold > summary::-webkit-details-marker { display: none; }
    .home-seo-fold > summary::after { content: ' ▾'; color: var(--text-faint); font-size: 0.8em; }
    .home-seo-fold[open] > summary::after { content: ' ▴'; }
    .home-seo-fold > summary:hover { color: var(--accent); }
    .home-seo h2 {
      font-size: 1.02rem; font-weight: 700; color: var(--accent);
      margin: 26px 0 8px;
    }
    .home-seo-fold > h2:first-of-type { margin-top: 14px; }
    .home-seo-fold > p { color: var(--text-muted); }
    .home-seo-bands {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
      margin-top: 14px;
    }
    .home-seo-band {
      background: var(--bg-panel);
      border: 1px solid var(--border-lo);
      border-radius: var(--r-md);
      padding: 12px 14px;
    }
    .home-seo-band h3 { font-size: 0.85rem; font-weight: 700; color: var(--text-dark); margin-bottom: 4px; }
    .home-seo-band p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.7; }
    .home-faq details {
      background: var(--bg-panel);
      border: 1px solid var(--border-lo);
      border-radius: var(--r-md);
      padding: 10px 14px;
      margin-bottom: 8px;
    }
    .home-faq summary { cursor: pointer; font-weight: 700; font-size: 0.88rem; color: var(--text-dark); }
    .home-faq p { margin-top: 8px; color: var(--text-muted); font-size: 0.86rem; }
    .home-seo-links { text-align: center; margin-top: 22px; font-size: 0.88rem; }
    .home-seo-links a { color: var(--accent); text-decoration: none; font-weight: 700; }
    .home-seo-links a:hover { text-decoration: underline; }
    @media (max-width: 768px) {
      .home-seo-bands { grid-template-columns: 1fr; }
    }

    /* ══════════════════════════════════════
       GUIDED TOUR + HELP MENU
    ══════════════════════════════════════ */
    #tour-spot {
      position: fixed;
      z-index: 300;
      border-radius: var(--r-md);
      border: 2px solid var(--gold);
      box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
      pointer-events: none;
      transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
    }
    #tour-bubble {
      position: fixed;
      z-index: 301;
      background: var(--bg-panel);
      color: var(--text-body);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-lg);
      padding: 14px 16px;
      transition: left 0.25s ease, top 0.25s ease;
    }
    .tour-step-count { font-size: 0.68rem; color: var(--text-faint); margin-bottom: 4px; }
    .tour-title { font-weight: 700; color: var(--text-dark); font-size: 1rem; margin-bottom: 5px; }
    .tour-body  { font-size: 0.86rem; line-height: 1.55; margin-bottom: 12px; }
    .tour-actions { display: flex; align-items: center; gap: 8px; }
    .tour-spacer { flex: 1; }
    .tour-actions button {
      border: 1px solid var(--border-mid); background: var(--bg-panel);
      color: var(--text-body); border-radius: var(--r-sm);
      padding: 6px 12px; font-size: 0.8rem; cursor: pointer;
    }
    .tour-actions .tour-next { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
    .tour-actions .tour-skip { border: none; background: none; color: var(--text-faint); padding-inline: 4px; }

    .help-btn-wrap { position: relative; }
    #help-menu {
      display: none;
      position: absolute;
      top: calc(100% + 8px);
      inset-inline-end: 0;
      background: var(--bg-panel);
      border: 1px solid var(--border-mid);
      border-radius: var(--r-md);
      box-shadow: var(--shadow-md);
      padding: 8px;
      min-width: 190px;
      z-index: 120;
    }
    #help-menu.open { display: flex; flex-direction: column; gap: 2px; }
    .help-menu-title {
      font-size: 0.68rem; font-weight: 700; color: var(--text-faint);
      text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 8px 6px;
    }
    #help-menu button, #help-menu a {
      display: block; width: 100%; text-align: start;
      background: none; border: none; cursor: pointer;
      color: var(--text-body); text-decoration: none;
      font-size: 0.85rem; padding: 8px 10px; border-radius: var(--r-sm);
    }
    #help-menu button:hover, #help-menu a:hover { background: var(--accent-light); color: var(--accent); }

    /* Respect the OS "reduce motion" preference: near-instant transitions and
       no looping animations (e.g. the blinking presence / connection dots). */
    @media (prefers-reduced-motion: reduce) {
      .fig-spot-halo { animation: none; opacity: 0.25; }
      *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
      }
    }
