    :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;
      --text-faint:    #B0A090;
      --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;
      --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;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    html { font-size: 16px; transition: font-size 0.15s; }
    body {
      font-family: 'Calibri', 'Segoe UI', Tahoma, Arial, sans-serif;
      background: var(--bg-app);
      height: 100vh; 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: '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: 196px; }

    /* 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: 12px 12px 10px;
      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%; }

    #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; font-family: 'Calibri', 'Segoe UI', Tahoma, Arial, sans-serif;
      pointer-events: none; letter-spacing: 3px;
      text-align: center; line-height: 2;
      font-weight: 400;
    }

    /* ══════════════════════════════════
       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;
    }
    #lines-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

    /* zoom controls (bottom-start so they don't collide with the mobile FAB) */
    #zoom-controls {
      position: absolute; bottom: 16px; inset-inline-start: 16px;
      display: flex; flex-direction: column; gap: 6px; z-index: 40;
    }
    #zoom-controls button {
      width: 36px; height: 36px; padding: 0;
      border-radius: var(--r-md);
      background: var(--bg-toolbar); border: 1px solid var(--border-mid);
      color: var(--text-body); font-size: 1.1rem; line-height: 1;
      box-shadow: var(--shadow-sm); cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.14s, border-color 0.14s, color 0.14s;
    }
    #zoom-controls button:hover { background: var(--accent-light); border-color: var(--accent-med); color: var(--accent); }
    #zoom-controls #btn-zoom-reset { font-size: 0.95rem; }
    .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; }
    .fig-svg-container { position: relative; }
    .fig-label {
      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: 20px;
      margin-top: 6px; white-space: nowrap; pointer-events: none;
      backdrop-filter: blur(6px);
      letter-spacing: 0;
      box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    }

    /* ══════════════════════════════════
       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: 0; display: none;
      border: 1px solid rgba(21,88,160,0.18);
    }

    /* ══════════════════════════════════
       PROPS PANEL
    ══════════════════════════════════ */
    .prop-group { margin-bottom: 12px; }
    .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);
    }

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

    .colors-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 7px; }
    .color-dot {
      width: 100%; aspect-ratio: 1; border-radius: 50%; cursor: pointer;
      border: 2.5px solid transparent;
      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-light { border-color: var(--border-mid); }
    .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;
    }

    .divider { height: 1px; background: var(--border-lo); margin: 2px 0 10px; }

    /* ══════════════════════════════════
       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: 30px; font-size: 0.95rem; 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: 30px; display: flex; align-items: center; justify-content: center;
      font-size: 0.75rem; 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: 20px;
      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-radius: 0 0 0 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;
    }

    .drag-hint {
      font-size: 0.72rem; color: var(--text-faint);
      text-align: center; padding: 8px 0 4px;
      letter-spacing: 0.3px;
    }

    /* ══════════════════════════════════
       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; align-items: flex-start; justify-content: 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: '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: 4px;
    }
    .home-btn-local:hover { color: var(--text-muted); text-decoration: underline; }
    .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: 20px; 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: 20px; 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
    ══════════════════════════════════ */
    .theme-btn-wrap { position: relative; display: flex; align-items: center; }

    #btn-theme { padding: 7px 10px; font-size: 0.95rem; line-height: 1; }

    #theme-picker {
      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: 10px 10px 8px;
      z-index: 200;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
    }
    #theme-picker.open { display: flex; }

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

    .theme-swatches-row { display: flex; gap: 7px; }

    .theme-swatch {
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      cursor: pointer;
    }
    .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: 4px 9px; min-width: 32px;
      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: 22px;
      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;
      }
      #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 { display: flex; flex-direction: column; gap: 10px; }
    .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: 22px;
      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; }
