:root {
      /* Rich Dark Mode Palette (Zinc/Slate inspired) */
      --ink: #09090b;
      --ink-2: rgba(24, 24, 27, 0.75);
      --ink-3: rgba(39, 39, 42, 0.8);
      --bone: #f8fafc;
      --silver: #cbd5e1;
      --silver-mu: #94a3b8;
      
      --rule: rgba(255, 255, 255, 0.1);
      --rule-soft: rgba(255, 255, 255, 0.05);
      
      /* Vibrant Accents */
      --accent: #818cf8;
      --accent-hover: #6366f1;
      --tl-gutter: 64px;
      --accent-soft: rgba(129, 140, 248, 0.15);
      
      --green: #34d399;
      --green-soft: rgba(52, 211, 153, 0.15);
      --red: #fb7185;
      --red-soft: rgba(251, 113, 133, 0.15);
      --amber: #fbbf24;
      
      --display: 'Plus Jakarta Sans', system-ui, sans-serif;
      --ui: 'Inter', system-ui, sans-serif;

      color-scheme: dark;

      /* Softer Radii */
      --radius: 8px;
      --radius-lg: 12px;
      
      /* Shadows & Glows */
      --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
      --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
      --glow-accent: 0 0 12px rgba(129, 140, 248, 0.4);
      --glow-accent-sm: 0 0 6px rgba(129, 140, 248, 0.3);

      /* Theme-aware semantic surfaces */
      --body-grad:      #1a1a24;
      --surface-bar:    rgba(9, 9, 11, 0.6);
      --surface-panel:  rgba(24, 24, 27, 0.6);
      --surface-pop:    rgba(39, 39, 42, 0.95);
      --field:          var(--field);
      --field-2:        rgba(0,0,0,0.3);
      --field-3:        rgba(0,0,0,0.4);
    }

    /* ─── Light theme overrides ─── */
    :root[data-theme="light"] {
      --ink:           #f4f1ea;
      --ink-2:         rgba(255, 255, 255, 0.85);
      --ink-3:         rgba(0, 0, 0, 0.05);
      --bone:          #1a1916;
      --silver:        #44423d;
      --silver-mu:     #6a6760;
      --rule:          rgba(0, 0, 0, 0.14);
      --rule-soft:     rgba(0, 0, 0, 0.07);
      --body-grad:     #ffffff;
      --surface-bar:   rgba(255, 255, 255, 0.72);
      --surface-panel: rgba(255, 255, 255, 0.6);
      --surface-pop:   rgba(255, 255, 255, 0.98);
      --field:         rgba(0,0,0,0.04);
      --field-2:       rgba(0,0,0,0.06);
      --field-3:       rgba(0,0,0,0.08);
      --shadow-md:     0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.05);
      --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.12), 0 4px 6px -2px rgba(0,0,0,0.06);
      color-scheme: light;
    }

    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
    html, body {
      background: var(--ink);
      color: var(--bone);
      font-family: var(--ui);
      height: 100vh;
      overflow: hidden;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    body {
      display: grid;
      grid-template-rows: auto 56px 1fr clamp(140px, var(--tl-height, 200px), 70vh);
      grid-template-columns: 1fr;
      background: radial-gradient(circle at top left, var(--body-grad) 0%, var(--ink) 100%);
    }

    /* ─── Demo-mode banner (hidden until isDemoMode; auto row collapses to 0) ─── */
    .demo-banner {
      grid-row: 1;
      padding: 7px 16px;
      text-align: center;
      font-family: var(--ui);
      font-size: 12.5px;
      font-weight: 600;
      color: #1a1916;
      background: var(--amber);
      border-bottom: 1px solid rgba(0,0,0,.15);
    }

    /* ─── Toolbar ─── */
    .toolbar {
      grid-row: 2;
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      padding: 0 24px;
      background: var(--surface-bar);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-bottom: 1px solid var(--rule-soft);
      z-index: 40;
    }
    .toolbar-left {
      display: flex; align-items: center; gap: 10px;
      font-size: 13px; color: var(--silver-mu);
    }
    .toolbar-left a { color: var(--accent); text-decoration: none; font-weight: 600; transition: color 0.2s; }
    .toolbar-left a:hover { color: var(--accent-hover); }
    .toolbar-left .brand-link {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      color: var(--bone);
      font-family: var(--display);
    }
    .toolbar-left .brand-logo {
      width: 26px;
      height: 26px;
      display: block;
      border-radius: 6px;
      flex-shrink: 0;
      box-shadow: var(--shadow-sm);
    }
    .toolbar-left .sep { opacity: .3; font-weight: 400; }
    .toolbar-left .project-name { color: var(--bone); font-weight: 500; font-family: var(--display); }
    .toolbar-left .page-label { color: var(--silver-mu); font-family: var(--display); }
    .beta-badge {
      font-size: 10px; font-weight: 700; letter-spacing: .06em;
      padding: 2px 6px; border-radius: 6px;
      background: rgba(138, 99, 255, .15); color: #b794f4;
      border: 1px solid rgba(138, 99, 255, .3); margin-left: 8px;
    }

    .toolbar-preview {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px;
      background: var(--surface-panel);
      border: 1px solid var(--rule-soft);
      border-radius: var(--radius);
      backdrop-filter: blur(8px);
    }
    .preview-mode-btn {
      min-width: 72px;
      padding: 6px 12px;
      font-family: var(--ui);
      font-size: 12px;
      font-weight: 500;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: var(--silver-mu);
      cursor: pointer;
      transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .preview-mode-btn:hover { color: var(--bone); background: rgba(255,255,255,.05); }
    .preview-mode-btn.active { color: #fff; background: var(--accent); box-shadow: var(--shadow-sm); font-weight: 600; }

    .toolbar-actions { display: flex; gap: 12px; justify-content: flex-end; }
    .btn-tool {
      padding: 8px 18px;
      font-family: var(--ui); font-size: 13px; font-weight: 500;
      border: 1px solid var(--rule);
      border-radius: var(--radius);
      background: rgba(255, 255, 255, 0.02); color: var(--bone);
      cursor: pointer; transition: all 0.2s ease-out;
      display: inline-flex; align-items: center; justify-content: center;
    }
    .btn-tool:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
    :root[data-theme="light"] .btn-tool:hover { background: rgba(0, 0, 0, 0.05); }
    .btn-theme { padding: 0; width: 36px; justify-content: center; }
    .btn-theme svg { display: block; }
    .btn-theme .theme-sun { display: none; }
    :root[data-theme="light"] .btn-theme .theme-moon { display: none; }
    :root[data-theme="light"] .btn-theme .theme-sun { display: block; }
    .btn-fullscreen { padding: 0; width: 36px; justify-content: center; }
    .btn-fullscreen svg { display: block; }
    .btn-fullscreen .fs-compress { display: none; }
    .btn-fullscreen.is-fs .fs-expand { display: none; }
    .btn-fullscreen.is-fs .fs-compress { display: block; }
    .btn-tool:active { transform: translateY(0); }
    .btn-tool.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--glow-accent-sm); }
    .btn-tool.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--glow-accent); }
    .btn-tool.success { background: var(--green); border-color: var(--green); color: #fff; }
    .btn-tool.success:hover { background: #10b981; border-color: #10b981; box-shadow: 0 0 12px rgba(52, 211, 153, 0.4); }
    .btn-tool:disabled { opacity: 0.45; cursor: not-allowed; }
    .btn-tool:disabled:hover { transform: none; box-shadow: none; }
    .btn-tool.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

    .autosave-wrap { display: flex; align-items: center; gap: 6px; }
    .autosave-wrap label { font-family: var(--ui); font-size: 11px; color: var(--silver); cursor: pointer; user-select: none; white-space: nowrap; }
    .toggle-switch { position: relative; width: 32px; height: 18px; flex-shrink: 0; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-switch .slider { position: absolute; inset: 0; background: var(--rule); border-radius: 9px; cursor: pointer; transition: background .2s; }
    .toggle-switch .slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: var(--bone); border-radius: 50%; transition: transform .2s; }
    .toggle-switch input:checked + .slider { background: var(--accent); }
    .toggle-switch input:checked + .slider::before { transform: translateX(14px); }

    /* ─── Main Grid ─── */
    .editor-grid {
      grid-row: 3;
      display: grid;
      grid-template-columns: 280px 1fr 320px;
      overflow: hidden;
      position: relative; /* containing block for the drawer backdrop */
    }

    /* ─── Left Sidebar ─── */
    .sidebar {
      background: var(--ink-2);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-right: 1px solid var(--rule-soft);
      overflow-y: auto;
      padding: 0;
      display: flex;
      flex-direction: column;
    }
    .sidebar::-webkit-scrollbar { width: 6px; }
    .sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
    .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

    .sb-section { border-bottom: 1px solid var(--rule-soft); }
    .sb-section:last-child { border-bottom: none; }
    .sb-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 16px 20px;
      font-size: 11px; font-weight: 600;
      letter-spacing: .12em; text-transform: uppercase;
      color: var(--silver-mu);
      cursor: pointer; user-select: none;
      transition: color 0.2s;
    }
    .sb-header:hover { color: var(--silver); }
    .sb-body { padding: 0 16px 16px; }

    .btn-add {
      padding: 4px 12px;
      font-family: var(--ui); font-size: 11px; font-weight: 600;
      background: var(--accent-soft); color: var(--accent);
      border: none; border-radius: 6px;
      cursor: pointer; transition: all 0.2s;
    }
    .btn-add:hover { background: rgba(129, 140, 248, 0.25); transform: translateY(-1px); }
    .btn-add:active { transform: translateY(0); }
    .btn-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Scene list items */
    .scene-item {
      display: flex; align-items: center; gap: 12px;
      padding: 10px 12px;
      border-radius: var(--radius);
      cursor: pointer;
      transition: all 0.2s ease;
      margin-bottom: 4px;
      position: relative;
      border: 1px solid transparent;
    }
    .scene-item:hover { background: rgba(255,255,255,.03); border-color: var(--rule-soft); }
    .scene-item.active { background: var(--ink-3); border-color: rgba(255,255,255,0.08); box-shadow: var(--shadow-sm); }
    .scene-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .scene-item .si-num {
      width: 32px; height: 32px;
      display: flex; align-items: center; justify-content: center;
      background: var(--field); border-radius: 6px; border: 1px solid var(--rule-soft);
      font-size: 12px; font-weight: 600; color: var(--silver);
      flex-shrink: 0; transition: all 0.2s;
    }
    .scene-item.active .si-num { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--glow-accent-sm); }
    .scene-item .si-grip {
      opacity: 0; flex-shrink: 0;
      width: 16px; padding: 0; margin-left: -4px;
      background: none; border: none; color: var(--silver-mu);
      cursor: grab; font-size: 14px; line-height: 1;
      transition: opacity 0.2s, color 0.2s;
    }
    .scene-item:hover .si-grip,
    .scene-item:focus-within .si-grip { opacity: 0.5; }
    .scene-item .si-grip:hover { opacity: 1; color: var(--silver); }
    .scene-item .si-grip:active { cursor: grabbing; }
    .scene-item .si-grip:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
    .scene-item .si-info { flex: 1; min-width: 0; }
    .scene-item .si-name {
      font-size: 13px; font-weight: 500; color: var(--bone);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .scene-item .si-meta {
      font-size: 11px; color: var(--silver);
      margin-top: 2px; font-family: var(--display);
    }
    .scene-item .si-del {
      opacity: 0; padding: 4px 6px;
      background: none; border: none; color: var(--red);
      cursor: pointer; font-size: 16px; transition: all 0.2s;
      border-radius: 4px;
    }
    .scene-item:hover .si-del,
    .scene-item:focus-within .si-del { opacity: 0.6; }
    .scene-item .si-del:hover { opacity: 1; background: var(--red-soft); }
    .scene-item .si-del:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: 1px; }
    .scene-item .si-dup {
      opacity: 0; padding: 4px 6px;
      background: none; border: none; color: var(--silver-mu);
      cursor: pointer; font-size: 14px; transition: all 0.2s;
      border-radius: 4px; flex-shrink: 0;
    }
    .scene-item:hover .si-dup,
    .scene-item:focus-within .si-dup { opacity: 0.6; }
    .scene-item .si-dup:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }
    .scene-item .si-dup:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: 1px; }

    /* Timing mini bar in scene list */
    .timing-bar {
      height: 4px; background: var(--field-2); border-radius: 2px;
      margin-top: 6px; position: relative; overflow: hidden;
    }
    .timing-bar .fill {
      position: absolute; top: 0; bottom: 0;
      background: var(--accent); border-radius: 2px;
      box-shadow: 0 0 4px rgba(129, 140, 248, 0.5);
    }

    /* Global fields */
    .field {
      margin-bottom: 14px;
    }
    .field label {
      display: block; font-size: 11px; font-weight: 600;
      letter-spacing: .05em; text-transform: uppercase;
      color: var(--silver-mu); margin-bottom: 6px;
    }
    .field input[type="text"],
    .field input[type="number"],
    .field textarea,
    .field select {
      width: 100%;
      padding: 10px 12px;
      background: var(--field);
      border: 1px solid var(--rule-soft);
      border-radius: var(--radius);
      color: var(--bone);
      font-family: var(--ui); font-size: 13px;
      outline: none;
      transition: all 0.2s ease;
    }
    .field input:hover, .field textarea:hover, .field select:hover {
      border-color: rgba(255,255,255,0.15);
    }
    .field input:focus, .field textarea:focus, .field select:focus {
      border-color: var(--accent);
      background: var(--field-3);
      box-shadow: 0 0 0 2px var(--accent-soft);
    }
    .field textarea { resize: vertical; min-height: 80px; line-height: 1.4; }
    .field input[type="color"] {
      width: 36px; height: 36px; padding: 2px; border: 1px solid var(--rule-soft);
      border-radius: var(--radius); background: var(--field); cursor: pointer;
      transition: all 0.2s;
    }
    .field input[type="color"]:hover { border-color: rgba(255,255,255,0.2); }

    .color-row {
      display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
    }
    .color-row label { margin-bottom: 0; flex: 1; }
    .color-row .hex {
      font-size: 12px; color: var(--silver-mu); font-family: monospace;
      background: var(--field); padding: 4px 8px; border-radius: 4px;
    }

    /* Color swatch palette (recent + presets) */
    .swatch-palette {
      display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px;
    }
    .swatch {
      width: 20px; height: 20px; padding: 0; border-radius: 4px;
      border: 1px solid var(--rule); cursor: pointer; position: relative;
      transition: transform .12s, box-shadow .12s;
    }
    .swatch:hover { transform: scale(1.12); }
    .swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
    .swatch.swatch-recent::after {
      content: ''; position: absolute; top: -2px; right: -2px;
      width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
    }
    .contrast-note {
      font-size: 11px; margin: -6px 0 12px; color: var(--silver-mu);
      display: flex; align-items: center; gap: 6px;
    }
    .contrast-note::before {
      content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--silver-mu);
    }
    .contrast-note.ok { color: var(--green); }
    .contrast-note.ok::before { background: var(--green); }
    .contrast-note.warn { color: var(--amber); }
    .contrast-note.warn::before { background: var(--amber); }
    .contrast-note.bad { color: var(--red); }
    .contrast-note.bad::before { background: var(--red); }

    .size-row {
      display: grid;
      grid-template-columns: 1fr 66px 24px;
      align-items: center;
      gap: 10px;
      margin-bottom: 14px;
    }
    .size-row label { margin-bottom: 0; grid-column: 1 / -1; }
    .size-row input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
    .size-row input[type="number"] {
      padding: 8px 10px;
      text-align: right; font-family: monospace;
    }
    .size-row .unit {
      font-size: 12px;
      color: var(--silver-mu);
    }

    .font-row {
      display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
      padding: 10px 12px; background: var(--field); border: 1px solid var(--rule-soft);
      border-radius: var(--radius); cursor: pointer;
      transition: all 0.2s;
    }
    .font-row:hover { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,0.15); }
    .font-row .fr-label { font-size: 11px; font-weight: 600; color: var(--silver-mu); text-transform: uppercase; letter-spacing: .05em; width: 44px; flex-shrink: 0; }
    .font-row .fr-family { font-size: 14px; color: var(--bone); flex: 1; font-weight: 500; }
    .font-row .fr-change { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 4px 8px; border-radius: 4px; transition: all 0.2s; border: none; cursor: pointer; font-family: var(--ui); }
    .font-row:hover .fr-change { background: var(--accent); color: #fff; }
    .fr-change:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Segmented align buttons */
    .seg-group {
      display: flex; gap: 4px; background: var(--field);
      padding: 4px; border-radius: 8px; border: 1px solid var(--rule-soft);
    }
    .seg-group button {
      flex: 1; padding: 7px 0; font-family: var(--ui); font-size: 12px; font-weight: 500;
      background: none; border: none; border-radius: 5px; color: var(--silver-mu);
      cursor: pointer; transition: all 0.2s;
    }
    .seg-group button:hover { color: var(--silver); }
    .seg-group button.active { background: var(--accent); color: #fff; }
    .seg-group button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Mini icon button (clear highlight) */
    .btn-mini {
      width: 28px; height: 28px; flex-shrink: 0;
      background: var(--field); border: 1px solid var(--rule-soft); border-radius: 6px;
      color: var(--silver-mu); font-size: 16px; line-height: 1; cursor: pointer; transition: all 0.2s;
    }
    .btn-mini:hover { color: var(--red); border-color: var(--red-soft); }
    .btn-mini:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Preview button in Animation header */
    .prop-section-title { display: flex; align-items: center; justify-content: space-between; }
    .btn-preview {
      font-family: var(--ui); font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0;
      background: var(--accent-soft); color: var(--accent); border: none; border-radius: 6px;
      padding: 5px 10px; cursor: pointer; transition: all 0.2s;
    }
    .btn-preview:hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
    .btn-preview:active { transform: translateY(0); }
    .btn-preview:disabled { opacity: 0.5; cursor: default; transform: none; }
    .btn-preview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* ─── Canvas Area ─── */
    .canvas-wrap {
      position: relative; overflow: hidden;
      background: #000;
    }
    .canvas-wrap canvas {
      position: absolute; inset: 0; width: 100%; height: 100%; display: block;
    }
    .canvas-wrap.preview-tablet,
    .canvas-wrap.preview-mobile {
      background: radial-gradient(circle at center, #111116 0%, #050507 100%);
    }
    .canvas-wrap.preview-tablet {
      --preview-w: min(820px, calc(100% - 64px));
      --preview-h: min(1180px, calc(100% - 64px));
      --preview-shell-radius: 28px;
      --preview-content-radius: 20px;
    }
    .canvas-wrap.preview-mobile {
      --preview-w: min(390px, calc(100% - 64px));
      --preview-h: min(844px, calc(100% - 64px));
      --preview-shell-radius: 36px;
      --preview-content-radius: 28px;
    }
    .canvas-wrap.preview-tablet::before,
    .canvas-wrap.preview-mobile::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: var(--preview-w);
      height: var(--preview-h);
      transform: translate(-50%, -50%);
      border: 8px solid #1a1a24;
      border-radius: var(--preview-shell-radius);
      box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 25px 50px -12px rgba(0,0,0,0.7);
      pointer-events: none;
      z-index: 0;
      transition: all 0.3s ease;
    }
    .canvas-wrap.preview-tablet canvas,
    .canvas-wrap.preview-tablet .canvas-veil,
    .canvas-wrap.preview-tablet .overlay-container,
    .canvas-wrap.preview-mobile canvas,
    .canvas-wrap.preview-mobile .canvas-veil,
    .canvas-wrap.preview-mobile .overlay-container {
      top: 50%;
      left: 50%;
      right: auto;
      bottom: auto;
      width: var(--preview-w);
      height: var(--preview-h);
      transform: translate(-50%, -50%);
      border-radius: var(--preview-content-radius);
      overflow: hidden;
      transition: all 0.3s ease;
    }
    .canvas-wrap.preview-tablet .canvas-veil,
    .canvas-wrap.preview-mobile .canvas-veil { z-index: 1; }
    .canvas-wrap.preview-tablet .overlay-container,
    .canvas-wrap.preview-mobile .overlay-container { z-index: 5; }
    .canvas-wrap.preview-tablet .scrub-indicator,
    .canvas-wrap.preview-mobile .scrub-indicator { top: 32px; right: 32px; }
    .canvas-wrap.preview-tablet .add-here-btn,
    .canvas-wrap.preview-mobile .add-here-btn { bottom: 44px; }

    /* Panel overlays (preview) */
    .overlay-container {
      position: absolute; inset: 0;
      pointer-events: none;
      z-index: 5;
    }
    .ov-panel {
      position: absolute; top: 50%; left: 8%;
      transform: translateY(-50%);
      max-width: 480px;
      opacity: 0;
      pointer-events: none;
      will-change: transform, opacity;
      transition: none;
      filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
    }
    .ov-panel.side-right { left: auto; right: 8%; text-align: right; }
    .ov-panel.side-center { left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 560px; }
    .ov-panel .ov-scene {
      display: flex; align-items: center; gap: 12px;
      font-size: 10px; font-family: var(--display); font-weight: 600; letter-spacing: .3em; text-transform: uppercase;
      color: #cbd5e1; margin-bottom: 20px;
    }
    .ov-panel .ov-num { color: #f8fafc; background: rgba(255,255,255,0.1); padding: 4px 8px; border-radius: 4px; }
    .ov-panel .ov-bar { width: 32px; height: 1px; background: rgba(255,255,255,0.3); }
    .ov-panel .ov-content {
      font-size: var(--scene-font-size, 64px);
      font-weight: var(--scene-font-weight, 400);
      line-height: var(--scene-line-height, 1.1);
      letter-spacing: var(--scene-letter-spacing, .02em);
      text-align: var(--scene-text-align, inherit);
      opacity: var(--scene-text-opacity, 1);
      margin-bottom: 16px;
      color: var(--scene-text-color, #f8fafc);
      white-space: pre-line;
      text-shadow: var(--scene-text-shadow, 0 2px 4px rgba(0,0,0,0.5));
      background: var(--scene-bg, transparent);
      padding: var(--scene-bg-pad, 0);
      border-radius: 8px;
    }
    /* Inline canvas editing */
    .ov-panel.editing {
      opacity: 1 !important; pointer-events: auto !important;
      filter: none !important; transform: translateY(-50%) !important;
    }
    .ov-panel.side-center.editing { transform: translate(-50%, -50%) !important; }
    .ov-panel .ov-content[contenteditable="true"] {
      outline: 2px dashed var(--accent); outline-offset: 6px;
      border-radius: 8px; cursor: text;
    }
    .canvas-wrap.preview-mobile .ov-panel {
      left: 8% !important;
      right: auto !important;
      top: 50% !important;
      max-width: 84%;
      text-align: left;
    }
    .canvas-wrap.preview-mobile .ov-panel.side-right,
    .canvas-wrap.preview-mobile .ov-panel.side-center {
      left: 8% !important;
      right: auto !important;
      top: 50% !important;
      text-align: left;
      max-width: 84%;
    }
    .canvas-wrap.preview-mobile .ov-panel .ov-content {
      font-size: clamp(32px, 12vw, min(var(--scene-font-size, 64px), 56px));
      line-height: 1.1;
      letter-spacing: .01em;
      overflow-wrap: anywhere;
    }

    /* Vignette on preview */
    .canvas-veil {
      position: absolute; inset: 0;
      background: radial-gradient(circle at center, transparent 20%, rgba(0,0,0,.6) 100%);
      pointer-events: none; z-index: 1;
    }

    /* Add-here button floating over canvas */
    .add-here-btn {
      position: absolute; bottom: 24px; left: 50%;
      transform: translateX(-50%);
      padding: 10px 24px;
      background: var(--ink-2); color: var(--bone);
      font-family: var(--ui); font-size: 12px; font-weight: 600;
      border: 1px solid var(--rule); border-radius: 24px;
      cursor: pointer; z-index: 10;
      opacity: .7; transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
      backdrop-filter: blur(8px); box-shadow: var(--shadow-md);
    }
    .add-here-btn:hover { opacity: 1; background: var(--accent); color: #fff; border-color: var(--accent); transform: translate(-50%, -2px); box-shadow: var(--shadow-lg), var(--glow-accent); }

    /* Scrub progress indicator */
    .scrub-indicator {
      position: absolute; top: 16px; right: 20px;
      font-family: var(--ui); font-size: 12px; font-weight: 500;
      color: #f8fafc; z-index: 10;
      background: rgba(0,0,0,.6); padding: 6px 12px;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px; pointer-events: none;
      backdrop-filter: blur(4px); box-shadow: var(--shadow-sm);
    }

    /* ─── Right Properties ─── */
    .properties {
      background: var(--ink-2);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-left: 1px solid var(--rule-soft);
      overflow-y: auto;
      padding: 0;
    }
    .properties::-webkit-scrollbar { width: 6px; }
    .properties::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
    .properties::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

    .props-empty {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      height: 100%; color: var(--silver-mu); font-size: 14px; text-align: center; padding: 24px; gap: 12px;
    }
    .props-empty::before {
      content: ''; display: block; width: 48px; height: 48px;
      background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>') center/contain no-repeat;
      opacity: 0.5;
    }
    .props-content { display: none; }
    .props-content.show { display: block; animation: fadeIn 0.3s ease-out; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

    .prop-section {
      padding: 20px 24px;
      border-bottom: 1px solid var(--rule-soft);
    }
    .prop-section:last-child { border-bottom: none; }
    .prop-section-title {
      font-size: 11px; font-weight: 600;
      letter-spacing: .12em; text-transform: uppercase;
      color: var(--silver-mu); margin-bottom: 16px;
    }
    .prop-title-note { text-transform: none; letter-spacing: 0; opacity: .6; }
    .field-inline { display: flex; align-items: center; gap: 10px; }
    .range-hidden { visibility: hidden; width: 0; }

    /* Side radio */
    .side-radio {
      display: flex; gap: 6px; background: var(--field); padding: 4px; border-radius: 8px; border: 1px solid var(--rule-soft);
    }
    .side-radio label {
      flex: 1; text-align: center; margin-bottom: 0;
      padding: 8px 0; font-size: 12px; font-weight: 500;
      border-radius: 6px; cursor: pointer;
      color: var(--silver-mu); transition: all .2s;
      text-transform: none; letter-spacing: 0;
    }
    .side-radio input { display: none; }
    .side-radio label:hover { background: rgba(255,255,255,0.05); color: var(--bone); }
    .side-radio input:checked + label {
      background: rgba(255,255,255,0.1); color: var(--bone); box-shadow: var(--shadow-sm); font-weight: 600;
    }

    /* Actions/Meta editor */
    .list-editor { margin-top: 8px; }
    .list-row {
      display: flex; gap: 8px; align-items: center;
      margin-bottom: 8px;
    }
    .list-row input, .list-row select {
      padding: 8px 10px; font-size: 12px;
      background: var(--field); border: 1px solid var(--rule-soft);
      border-radius: var(--radius); color: var(--bone);
      font-family: var(--ui); outline: none; transition: border-color 0.2s;
    }
    .list-row input:focus, .list-row select:focus { border-color: var(--accent); }
    .list-row select { width: 70px; }
    .list-row .del-row {
      width: 28px; height: 28px;
      display: flex; align-items: center; justify-content: center;
      background: rgba(251, 113, 133, 0.1); border: none; color: var(--red); border-radius: 6px;
      cursor: pointer; font-size: 16px; flex-shrink: 0;
      opacity: .7; transition: all .2s;
    }
    .list-row .del-row:hover { opacity: 1; background: var(--red); color: #fff; }
    .btn-add-row {
      font-size: 12px; font-weight: 500; color: var(--accent);
      background: none; border: none; cursor: pointer;
      padding: 6px 0; font-family: var(--ui); display: inline-flex; align-items: center; gap: 4px;
    }
    .btn-add-row::before { content: '+'; font-size: 14px; }
    .btn-add-row:hover { color: var(--accent-hover); text-decoration: underline; }

    /* ─── Timeline ─── */
    .timeline {
      grid-row: 4;
      background: rgba(9, 9, 11, 0.8);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-top: 1px solid var(--rule-soft);
      display: flex; flex-direction: column;
      padding: 12px 24px 10px; z-index: 40;
      min-height: 0;
      position: relative;
    }
    .tl-label {
      font-size: 11px; font-weight: 600; letter-spacing: .1em;
      text-transform: uppercase; color: var(--silver-mu);
      margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
      flex: 0 0 auto;
    }
    .tl-scrub-readout {
      font-family: var(--display); font-size: 12px; font-weight: 600;
      color: var(--red); letter-spacing: 0; text-transform: none;
      background: rgba(251, 113, 133, 0.12); padding: 2px 8px; border-radius: 4px;
    }

    /* lanes area — scrolls vertically, holds the shared playhead overlay */
    .tl-lanes-wrap {
      flex: 1 1 auto; position: relative; min-height: 0;
      display: flex; flex-direction: column;
    }
    .tl-lanes {
      flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
      display: flex; flex-direction: column; gap: 4px;
      padding-right: 2px;
    }
    .tl-lane {
      display: grid; grid-template-columns: var(--tl-gutter) 1fr;
      align-items: stretch; height: 32px; flex: 0 0 auto;
    }
    .tl-lane-gutter {
      display: flex; align-items: center; padding: 0 8px 0 2px;
      font-family: var(--display); font-size: 11px; font-weight: 600;
      color: var(--silver-mu); cursor: pointer;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      border-radius: 4px; transition: color .2s, background .2s;
      user-select: none;
    }
    .tl-lane-gutter:hover { color: var(--bone); }
    .tl-lane.active .tl-lane-gutter { color: var(--accent); }
    .tl-lane-track {
      position: relative; height: 100%;
      background: rgba(255,255,255,0.03); border: 1px solid var(--rule-soft);
      border-radius: var(--radius);
      cursor: crosshair; overflow: hidden;
    }

    .tl-marker {
      position: absolute; top: 2px; bottom: 2px;
      background: rgba(129, 140, 248, 0.2); border: 1px solid rgba(129, 140, 248, 0.4);
      border-radius: 4px;
      cursor: grab; transition: background .2s, border-color .2s;
    }
    .tl-marker:hover { background: rgba(129, 140, 248, 0.3); }
    .tl-lane.active .tl-marker { background: rgba(129, 140, 248, 0.4); border-color: var(--accent); box-shadow: 0 0 8px rgba(129, 140, 248, 0.3); }
    .tl-marker:active { cursor: grabbing; }
    .tl-marker:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .tl-marker .tl-handle {
      position: absolute; top: 50%;
      transform: translate(-50%, -50%);
      cursor: ew-resize;
      z-index: 3;
      width: 12px; height: 100%;
      display: flex; align-items: center; justify-content: center;
    }
    .tl-marker .tl-handle.in,
    .tl-marker .tl-handle.out {
      opacity: .7; transition: opacity 0.2s;
    }
    .tl-marker .tl-handle.in:hover, .tl-marker .tl-handle.out:hover { opacity: 1; }
    .tl-marker .tl-handle.in::after,
    .tl-marker .tl-handle.out::after {
      content: ''; display: block; width: 4px; height: 16px; background: var(--bone); border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
    .tl-marker .tl-handle.in { left: 0; }
    .tl-marker .tl-handle.out { left: 100%; }
    .tl-marker .tl-handle.peak {
      width: 16px; height: 16px;
    }
    .tl-marker .tl-handle.peak::after {
      content: ''; display: block; width: 10px; height: 10px;
      background: var(--accent);
      border: 2px solid var(--bone);
      border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    }

    /* shared playhead — spans every lane, offset past the gutter column */
    .tl-playhead {
      position: absolute; top: 0; bottom: 0;
      left: var(--tl-gutter); right: 0;
      pointer-events: none; z-index: 6;
    }
    .tl-playhead-line {
      position: absolute; top: 0; bottom: 0;
      width: 2px; margin-left: -1px;
      background: var(--red); box-shadow: 0 0 6px rgba(251, 113, 133, 0.8);
      transition: left .05s linear;
    }
    .tl-playhead-line::before {
      content: ''; position: absolute; top: -5px; left: -5px;
      width: 12px; height: 12px;
      background: var(--red); border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    }
    .tl-ticks {
      display: flex; justify-content: space-between;
      margin-left: var(--tl-gutter);
      padding: 6px 0 0;
      font-size: 10px; font-weight: 500; color: var(--silver-mu);
      font-family: var(--display);
      flex: 0 0 auto;
    }

    /* drag handle on the timeline's top edge */
    .tl-resize {
      position: absolute; top: -3px; left: 0; right: 0; height: 6px;
      cursor: ns-resize; z-index: 5;
      background: var(--accent); opacity: 0; transition: opacity .15s;
    }
    .tl-resize:hover, body.tl-resizing .tl-resize { opacity: .5; }
    body.tl-resizing { user-select: none; cursor: ns-resize; }

    /* virtual horizontal scrollbar — appears when zoomed; the spacer's width
       (100/span %) makes the native thumb mirror the visible window */
    .tl-hscroll {
      height: 14px; flex: 0 0 auto;
      margin: 4px 0 0 var(--tl-gutter);
      overflow-x: auto; overflow-y: hidden;
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    }
    :root[data-theme="light"] .tl-hscroll { scrollbar-color: rgba(0, 0, 0, 0.3) transparent; }
    .tl-hscroll > div { height: 1px; }

    /* ─── Font Modal ─── */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.8);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      z-index: 100;
      display: flex; align-items: center; justify-content: center;
      opacity: 0; pointer-events: none; visibility: hidden;
      transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .modal-overlay.open { opacity: 1; pointer-events: auto; visibility: visible; }
    .modal {
      background: var(--ink-2);
      border: 1px solid var(--rule-soft);
      border-radius: var(--radius-lg); box-shadow: var(--shadow-lg), 0 25px 50px -12px rgba(0,0,0,0.5);
      width: 720px; max-width: 90vw; max-height: 85vh;
      display: flex; flex-direction: column;
      transform: scale(0.95) translateY(20px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .modal-overlay.open .modal { transform: scale(1) translateY(0); }
    
    .modal-header {
      display: flex; align-items: center; gap: 16px;
      padding: 20px 24px;
      border-bottom: 1px solid var(--rule-soft); background: rgba(255,255,255,0.02); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .modal-header h2 {
      font-family: var(--display); font-size: 18px; font-weight: 600;
      color: var(--bone); white-space: nowrap;
    }
    .modal-header input {
      flex: 1; padding: 10px 16px;
      background: var(--field-2); border: 1px solid var(--rule-soft);
      border-radius: var(--radius); color: var(--bone);
      font-family: var(--ui); font-size: 14px; outline: none; transition: border-color 0.2s;
    }
    .modal-header input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
    .modal-close {
      background: rgba(255,255,255,0.05); border: none; color: var(--silver-mu); border-radius: 50%; width: 36px; height: 36px;
      font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
      transition: all .2s;
    }
    .modal-close:hover { color: var(--bone); background: rgba(255,255,255,0.1); transform: rotate(90deg); }
    
    .modal-body {
      flex: 1; overflow-y: auto; padding: 24px;
    }

    /* Keyboard shortcuts cheat-sheet */
    .modal-shortcuts { width: 560px; }
    .shortcut-table { width: 100%; border-collapse: collapse; }
    .shortcut-table td { padding: 9px 10px; border-bottom: 1px solid var(--rule-soft); font-size: 13px; color: var(--silver); vertical-align: top; }
    .shortcut-table tr:last-child td { border-bottom: none; }
    .shortcut-table td:first-child { white-space: nowrap; color: var(--bone); width: 1%; padding-right: 18px; }
    .shortcut-table kbd {
      display: inline-block; padding: 2px 7px; font-family: var(--mono, monospace); font-size: 11px;
      background: var(--field); border: 1px solid var(--rule-soft); border-bottom-width: 2px;
      border-radius: 5px; color: var(--bone);
    }
    .modal-body::-webkit-scrollbar { width: 8px; }
    .modal-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; border: 2px solid var(--ink-2); }
    .modal-body::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
    
    .font-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 16px;
    }
    .font-card {
      padding: 16px 20px;
      background: var(--field);
      border: 1px solid var(--rule-soft);
      border-radius: var(--radius);
      cursor: pointer; transition: all .2s ease;
    }
    .font-card:hover { border-color: var(--accent); background: rgba(129, 140, 248, 0.05); transform: translateY(-2px); box-shadow: var(--shadow-md); }
    .font-card:active { transform: translateY(0); }
    .font-card .fc-preview {
      font-size: 26px; color: var(--bone);
      margin-bottom: 8px; line-height: 1.2;
      min-height: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .font-card .fc-name {
      font-size: 11px; font-weight: 600; color: var(--silver-mu);
      font-family: var(--ui);
      text-transform: uppercase; letter-spacing: .08em;
    }
    .font-card .fc-category {
      font-size: 10px; color: var(--silver-mu);
      font-family: var(--ui); opacity: .7; margin-top: 4px;
    }

    /* ─── Loading overlay ─── */
    .loading-overlay {
      position: absolute; inset: 0;
      background: rgba(9, 9, 11, 0.8); backdrop-filter: blur(4px);
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 20px; z-index: 20;
      opacity: 1; transition: opacity 0.3s;
    }
    .loading-overlay.hidden { opacity: 0; pointer-events: none; }
    .loading-overlay .spinner {
      width: 40px; height: 40px;
      border: 3px solid rgba(255,255,255,0.1);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loading-overlay .load-text {
      font-size: 14px; font-weight: 500; font-family: var(--display); color: var(--bone); letter-spacing: 0.05em;
    }

    /* ─── Toast (status + progress) ─── */
    #toastHost {
      position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
      z-index: 1000; pointer-events: none;
      display: flex; flex-direction: column; align-items: center; gap: 8px;
    }
    #toastHost .toast {
      position: relative; overflow: hidden;
      display: flex; align-items: center; gap: 12px;
      min-width: 240px; max-width: 380px;
      padding: 12px 16px;
      background: var(--ink-3); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--rule-soft); border-radius: var(--radius);
      box-shadow: var(--shadow-sm);
      pointer-events: auto; opacity: 1;
      animation: toastIn 0.2s ease;
    }
    @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
    #toastHost .toast.leaving { animation: toastOut 0.2s ease forwards; }
    @keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
    #toastHost .toast-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--silver-mu); }
    #toastHost .toast.success .toast-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
    #toastHost .toast.error   .toast-dot { background: var(--red);   box-shadow: 0 0 8px var(--red); }
    #toastHost .toast.loading .toast-dot {
      width: 14px; height: 14px; background: none; box-shadow: none;
      border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--accent);
      animation: spin 0.7s linear infinite;
    }
    #toastHost .toast-msg { font-size: 13px; color: var(--bone); flex: 1; }
    #toastHost .toast-action {
      font-family: var(--ui); font-size: 13px; font-weight: 600;
      background: none; border: none; color: var(--accent); flex: none;
      cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background 0.2s;
    }
    #toastHost .toast-action:hover { background: var(--accent-soft); }
    #toastHost .toast-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    /* progress bar (bottom edge of toast) */
    #toastHost .toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; overflow: hidden; }
    #toastHost .toast-bar > span {
      display: block; height: 100%; width: 100%; background: var(--accent);
      transform-origin: left; transform: scaleX(0); transition: transform 0.25s linear;
    }
    #toastHost .toast.loading .toast-bar > span {
      width: 40%; transform: none; transition: none;
      animation: toastIndet 1.1s ease-in-out infinite;
    }
    @keyframes toastIndet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
    #toastHost .toast.success .toast-bar > span { background: var(--green); }
    #toastHost .toast.error   .toast-bar > span { background: var(--red); }

    /* ─── Creative-power additions ─── */
    /* Per-scene scrim (mirrors generated #veilSide) */
    .ov-scrim {
      position: absolute; inset: 0; z-index: 2;
      pointer-events: none; opacity: 0;
      transition: opacity .15s linear, background .3s ease;
    }
    .canvas-wrap.preview-tablet .ov-scrim,
    .canvas-wrap.preview-mobile .ov-scrim {
      top: 50%; left: 50%; right: auto; bottom: auto;
      width: var(--preview-w); height: var(--preview-h);
      transform: translate(-50%, -50%);
      border-radius: var(--preview-content-radius); overflow: hidden;
    }

    /* Panel move handle — visible only on the selected panel */
    .ov-move {
      position: absolute; top: -14px; left: -14px;
      width: 28px; height: 28px; display: none;
      align-items: center; justify-content: center;
      background: var(--accent); color: #fff;
      border: 2px solid #fff; border-radius: 50%;
      font-size: 14px; line-height: 1; cursor: grab;
      pointer-events: auto; box-shadow: var(--shadow-md); z-index: 6;
    }
    .ov-move:active { cursor: grabbing; }
    .ov-panel.selected { outline: 1px dashed rgba(129,140,248,.5); outline-offset: 10px; }
    .ov-panel.selected .ov-move { display: flex; }
    .ov-panel.side-right .ov-move { left: auto; right: -14px; }
    .canvas-wrap.preview-mobile .ov-move { display: none !important; }

    /* Timeline play / loop controls */
    .tl-label-left { display: inline-flex; align-items: center; gap: 12px; }
    .tl-play {
      width: 26px; height: 26px; flex-shrink: 0;
      display: inline-flex; align-items: center; justify-content: center;
      background: var(--accent); color: #fff; border: none; border-radius: 6px;
      font-size: 11px; cursor: pointer; transition: all .2s; box-shadow: var(--glow-accent-sm);
    }
    .tl-play:hover { background: var(--accent-hover); box-shadow: var(--glow-accent); }
    .tl-play.playing { background: var(--red); box-shadow: 0 0 6px rgba(251,113,133,.4); }
    .tl-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .tl-loop {
      display: inline-flex; align-items: center; gap: 5px;
      font-size: 11px; font-weight: 500; color: var(--silver-mu);
      text-transform: none; letter-spacing: 0; cursor: pointer; user-select: none;
    }
    .tl-loop input { accent-color: var(--accent); cursor: pointer; }

    .tl-label-right { display: inline-flex; align-items: center; gap: 10px; }
    .tl-zoom { display: inline-flex; align-items: center; gap: 2px; }
    .tl-zoom button {
      min-width: 22px; height: 22px; padding: 0 6px;
      display: inline-flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,0.05); color: var(--silver-mu);
      border: 1px solid var(--rule-soft); border-radius: 5px;
      font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
      text-transform: none; letter-spacing: 0; transition: all .15s;
    }
    .tl-zoom button:hover { background: rgba(129,140,248,0.18); color: var(--bone); border-color: var(--accent); }
    .tl-zoom button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    /* Timeline filmstrip */
    .tl-filmstrip {
      margin-left: var(--tl-gutter); margin-top: 6px;
      height: 30px; flex: 0 0 auto;
      border: 1px solid var(--rule-soft); border-radius: var(--radius);
      overflow: hidden; cursor: crosshair; background: rgba(0,0,0,.3);
    }
    .tl-filmstrip canvas { display: block; width: 100%; height: 100%; }

    /* Property hint text */
    .prop-hint { font-size: 11px; color: var(--silver-mu); margin: -4px 0 4px; line-height: 1.4; }

    /* ─── Multi-element overlays ─── */
    .ov-el {
      position: absolute; top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      opacity: 0; pointer-events: none;
      will-change: transform, opacity;
      filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
    }
    .ov-el .ov-content {
      font-size: var(--scene-font-size, 56px);
      font-weight: var(--scene-font-weight, 400);
      line-height: var(--scene-line-height, 1.1);
      letter-spacing: var(--scene-letter-spacing, .02em);
      text-align: var(--scene-text-align, inherit);
      opacity: var(--scene-text-opacity, 1);
      color: var(--scene-text-color, #f8fafc);
      white-space: pre-line;
      text-shadow: var(--scene-text-shadow, 0 2px 4px rgba(0,0,0,0.5));
      background: var(--scene-bg, transparent);
      padding: var(--scene-bg-pad, 0);
      border-radius: 8px;
    }
    .ov-el .ov-img { display: block; }
    .ov-el .ov-img-empty {
      display: flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,.06); border: 1px dashed var(--rule);
      color: var(--silver-mu); font-size: 12px; border-radius: 8px;
    }
    .ov-el .ov-shape { display: block; }
    .ov-el .ov-shape-path { background: none; overflow: visible; }
    .ov-el.ov-eraser { filter: none !important; }
    .ov-el.selected { outline: 1px dashed rgba(129,140,248,.6); outline-offset: 8px; }
    .ov-el .ov-move {
      position: absolute; top: -14px; left: -14px; width: 28px; height: 28px;
      display: none; align-items: center; justify-content: center;
      background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%;
      font-size: 14px; line-height: 1; cursor: grab; pointer-events: auto; box-shadow: var(--shadow-md); z-index: 6;
    }
    .ov-el.selected .ov-move { display: flex; }
    .ov-el .ov-move:active { cursor: grabbing; }
    .ov-el.editing { opacity: 1 !important; pointer-events: auto !important; filter: none !important; }
    .ov-el .ov-content[contenteditable="true"] { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 8px; cursor: text; }
    .canvas-wrap.preview-mobile .ov-el .ov-move { display: none !important; }
    .ov-el { cursor: move; }
    .ov-el.locked { cursor: default; }
    .ov-el.locked .ov-move, .ov-el.locked .ov-resize { display: none !important; }

    /* Resize grips (selected element only) */
    .ov-el .ov-resize {
      position: absolute; width: 12px; height: 12px; padding: 0;
      display: none; background: var(--accent); border: 2px solid #fff; border-radius: 3px;
      pointer-events: auto; box-shadow: var(--shadow-md); z-index: 6;
    }
    .ov-el.selected .ov-resize { display: block; }
    .ov-el .ov-resize.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
    .ov-el .ov-resize.e { right: -7px; top: 50%; margin-top: -6px; cursor: ew-resize; }
    .ov-el .ov-resize.s { bottom: -7px; left: 50%; margin-left: -6px; cursor: ns-resize; }
    .canvas-wrap.preview-mobile .ov-el .ov-resize { display: none !important; }

    /* Custom shape drawing + vertex editing */
    .draw-capture {
      position: absolute; z-index: 30; overflow: visible;
      cursor: crosshair; touch-action: none; user-select: none;
    }
    .draw-preview {
      position: absolute; inset: 0; width: 100%; height: 100%;
      overflow: visible; pointer-events: none;
    }
    .draw-preview .draw-fill { fill: rgba(129,140,248,.22); stroke: var(--accent); stroke-width: 2; }
    .draw-preview .draw-rubber { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 5; }
    .draw-preview .draw-point { fill: var(--accent); stroke: #fff; stroke-width: 2; }
    .draw-preview .draw-point.first { fill: #fff; stroke: var(--accent); stroke-width: 3; }
    .draw-hud {
      position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
      display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px);
      padding: 8px 10px; border: 1px solid var(--rule-soft); border-radius: 8px;
      background: rgba(16,16,22,.94); color: var(--bone); box-shadow: var(--shadow-lg);
      font-family: var(--ui); font-size: 11px; cursor: default; pointer-events: auto;
    }
    .draw-hud .draw-modes { display: flex; gap: 4px; }
    .draw-hud button {
      border: 1px solid var(--rule); border-radius: 5px; padding: 5px 8px;
      background: var(--ink-3); color: var(--silver); font: inherit; cursor: pointer;
    }
    .draw-hud button.active, .draw-hud button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
    .draw-hud .draw-hint { color: var(--silver-mu); white-space: nowrap; }
    .canvas-wrap.preview-mobile .draw-hud .draw-hint { display: none; }
    .ov-el.vertex-editing {
      opacity: 1 !important; pointer-events: auto !important; filter: none !important;
      transform: translate(-50%, -50%) !important; cursor: default;
    }
    .ov-el.vertex-editing .ov-move,
    .ov-el.vertex-editing .ov-resize { display: none !important; }
    .ov-el.vertex-editing .ov-shape-path { cursor: crosshair; }
    .ov-vert {
      position: absolute; width: 12px; height: 12px; padding: 0;
      transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%;
      background: var(--accent); box-shadow: var(--shadow-md); cursor: grab;
      pointer-events: auto; z-index: 8;
    }
    .ov-vert:active { cursor: grabbing; }
    .prop-path-summary { color: var(--silver-mu); font-size: 12px; }
    .prop-path-actions { display: flex; gap: 8px; }
    .prop-path-actions .btn-mini {
      width: auto; height: auto; padding: 7px 10px;
      color: var(--accent); font-size: 11px; font-weight: 600;
    }
    .prop-path-actions .btn-mini:hover { color: #fff; border-color: var(--accent); background: var(--accent); }

    /* Snap guide lines shown while dragging an element near a snap target */
    .snap-guide {
      position: absolute; display: none; pointer-events: none; z-index: 7;
      background: var(--accent);
    }
    .snap-guide.v { top: 0; bottom: 0; width: 1px; }
    .snap-guide.h { left: 0; right: 0; height: 1px; }

    /* ─── Layers panel ─── */
    .layer-add-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
    .btn-add-layer {
      flex: 1 1 calc(50% - 3px); padding: 7px 0; font-family: var(--ui); font-size: 11px; font-weight: 600;
      background: var(--accent-soft); color: var(--accent); border: none; border-radius: 6px; cursor: pointer; transition: all .2s;
    }
    .btn-add-layer:hover { background: rgba(129,140,248,.25); transform: translateY(-1px); }
    .btn-add-layer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .btn-add-layer:disabled { opacity: 0.45; cursor: not-allowed; }
    .btn-add-layer:disabled:hover { background: var(--accent-soft); transform: none; }
    .layer-item {
      display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius);
      cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; transition: all .15s;
    }
    .layer-item:hover { background: rgba(255,255,255,.03); border-color: var(--rule-soft); }
    .layer-item.active { background: var(--ink-3); border-color: rgba(255,255,255,.08); }
    .layer-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--field); border-radius: 5px; font-size: 11px; font-weight: 700; color: var(--silver); }
    .layer-item.active .layer-icon { background: var(--accent); color: #fff; }
    .layer-name { flex: 1; min-width: 0; font-size: 12px; color: var(--bone); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .layer-kf { font-size: 10px; color: var(--accent); background: var(--accent-soft); padding: 2px 5px; border-radius: 4px; flex-shrink: 0; }
    .layer-dup, .layer-del { opacity: 0; padding: 2px 5px; background: none; border: none; cursor: pointer; border-radius: 4px; flex-shrink: 0; }
    .layer-dup { color: var(--silver-mu); font-size: 14px; }
    .layer-del { color: var(--red); font-size: 16px; }
    .layer-item:hover .layer-dup, .layer-item:hover .layer-del { opacity: .6; }
    .layer-dup:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }
    .layer-del:hover { opacity: 1; background: var(--red-soft); }
    .layer-grip {
      opacity: 0; padding: 2px 2px; background: none; border: none; cursor: grab;
      color: var(--silver-mu); font-size: 11px; border-radius: 4px; flex-shrink: 0;
    }
    .layer-item:hover .layer-grip { opacity: .5; }
    .layer-grip:active { cursor: grabbing; }
    .layer-eye, .layer-lock {
      opacity: 0; padding: 2px 4px; background: none; border: none; cursor: pointer;
      color: var(--silver-mu); border-radius: 4px; flex-shrink: 0;
      display: inline-flex; align-items: center;
    }
    .layer-item:hover .layer-eye, .layer-item:hover .layer-lock { opacity: .6; }
    .layer-item .layer-eye.on, .layer-item .layer-lock.on { opacity: .9; color: var(--accent); }
    .layer-item .layer-eye:hover, .layer-item .layer-lock:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }
    .layer-item.is-hidden .layer-name, .layer-item.is-hidden .layer-icon { opacity: .45; }

    /* ─── Keyframe editor ─── */
    .file-btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 9px 12px; background: var(--field); border: 1px solid var(--rule-soft); border-radius: var(--radius); color: var(--bone); font-size: 12px; cursor: pointer; transition: all .2s; }
    .file-btn:hover { background: rgba(255,255,255,.06); border-color: var(--accent); }
    .kf-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
    .kf-empty { font-size: 11px; color: var(--silver-mu); line-height: 1.4; padding: 4px 0; }
    .kf-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; transition: all .15s; }
    .kf-row:hover { background: rgba(255,255,255,.03); }
    .kf-row.active { background: var(--accent-soft); border-color: var(--accent); }
    .kf-dot { color: var(--accent); font-size: 11px; }
    .kf-at { font-family: monospace; font-size: 12px; color: var(--bone); width: 36px; }
    .kf-mini { flex: 1; font-size: 10px; color: var(--silver-mu); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kf-del { opacity: .5; padding: 2px 5px; background: none; border: none; color: var(--red); cursor: pointer; font-size: 15px; border-radius: 4px; }
    .kf-del:hover { opacity: 1; background: var(--red-soft); }
    .kf-editor { border-top: 1px solid var(--rule-soft); padding-top: 12px; }
    .btn-del-kf { width: 100%; padding: 8px; margin-top: 4px; background: var(--red-soft); color: var(--red); border: none; border-radius: 6px; font-family: var(--ui); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; }
    .btn-del-kf:hover { background: var(--red); color: #fff; }

    /* ─── Timeline keyframe sub-lanes ─── */
    .tl-sublane { height: 26px; }
    .tl-sub-gutter { font-size: 10px; padding-left: 14px; color: var(--silver-mu); }
    .tl-sublane.active .tl-sub-gutter { color: var(--accent); }
    .tl-kf-track { background: rgba(255,255,255,.02); }
    .tl-kf {
      position: absolute; top: 50%; width: 12px; height: 12px; margin-left: -6px;
      transform: translateY(-50%) rotate(45deg);
      background: var(--accent); border: 1px solid #fff; border-radius: 2px;
      cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.5); z-index: 3; transition: background .15s;
    }
    .tl-kf:hover { background: var(--accent-hover); }
    .tl-kf:active { cursor: grabbing; }
    .tl-kf.active { background: #fff; border-color: var(--accent); box-shadow: 0 0 6px rgba(129,140,248,.8); }

    /* ═══════════════════════════════════════════════════════════════
       Responsive — tablet (≤1024) & phone (≤768)
       Desktop (≥1025) keeps the original 3-column layout untouched.
       ═══════════════════════════════════════════════════════════════ */

    /* New mobile-only controls are hidden by default (desktop) */
    .btn-drawer, .btn-props-toggle, .btn-more, .drawer-close, .tl-collapse-btn { display: none; }
    /* Icon-button sizing to match .btn-theme / .btn-fullscreen */
    .btn-drawer, .btn-props-toggle, .btn-more { padding: 0; width: 36px; justify-content: center; font-size: 18px; }
    /* The overflow wrapper is invisible to layout on desktop — buttons stay inline */
    .toolbar-overflow { display: contents; }

    /* Backdrop behind open drawers (lives inside .editor-grid) */
    .editor-scrim {
      position: absolute; inset: 0; z-index: 44;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
      opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
    }
    .editor-scrim.show { opacity: 1; pointer-events: auto; }

    /* Allow touch-drag on the timeline resize handle without page-scrolling */
    .tl-resize { touch-action: none; }

    @media (max-width: 1024px) {
      /* Canvas takes the full width; panels overlay it as drawers */
      .editor-grid { grid-template-columns: 1fr; }

      .sidebar, .properties {
        position: absolute; top: 0; bottom: 0; z-index: 50;
        width: min(86vw, 320px);
        box-shadow: var(--shadow-lg), 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
      }
      .sidebar  { left: 0;  transform: translateX(-100%); border-right: 1px solid var(--rule); }
      .properties { right: 0; transform: translateX(100%); border-left: 1px solid var(--rule); }
      .sidebar.open, .properties.open { transform: none; }

      /* Reveal the drawer / panel toggles */
      .btn-drawer, .btn-props-toggle, .tl-collapse-btn { display: inline-flex; }

      /* In-flow close button at the top of each drawer */
      .drawer-close {
        display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
        width: 34px; height: 34px; margin: 8px 8px 0 auto;
        background: rgba(255, 255, 255, 0.05); border: 1px solid var(--rule-soft);
        border-radius: 8px; color: var(--silver-mu); font-size: 20px; line-height: 1; cursor: pointer;
        transition: all 0.2s;
      }
      .drawer-close:hover { color: var(--bone); background: rgba(255, 255, 255, 0.1); }

      /* Collapsed timeline — only its label bar remains; the row shrinks to auto */
      body.tl-collapsed { grid-template-rows: auto 56px 1fr auto; }
      body.tl-collapsed .timeline > :not(.tl-label) { display: none; }
      body.tl-collapsed .tl-label { margin-bottom: 0; }
      .tl-collapse-btn {
        align-items: center; justify-content: center;
        width: 24px; height: 22px; padding: 0;
        background: rgba(255, 255, 255, 0.05); color: var(--silver-mu);
        border: 1px solid var(--rule-soft); border-radius: 5px;
        font-size: 11px; line-height: 1; cursor: pointer; transition: all 0.15s;
      }
      .tl-collapse-btn:hover { background: rgba(129, 140, 248, 0.18); color: var(--bone); border-color: var(--accent); }
    }

    @media (max-width: 768px) {
      /* Condense the toolbar; brand only, actions on the right */
      .toolbar { grid-template-columns: auto 1fr auto; padding: 0 12px; position: relative; gap: 6px; }
      .toolbar-left { gap: 6px; }
      .toolbar-left .project-name, .toolbar-left .page-label, .toolbar-left .sep,
      .toolbar-left .brand-link span, .toolbar-left .beta-badge { display: none; }
      .toolbar-preview { display: none; }
      .toolbar-actions { gap: 8px; }

      /* Secondary actions fold into a dropdown opened by the ⋯ button */
      .btn-more { display: inline-flex; }
      .toolbar-overflow {
        display: none; position: absolute; top: calc(100% + 6px); right: 8px;
        flex-direction: column; align-items: stretch; gap: 8px; padding: 10px;
        min-width: 184px;
        background: var(--surface-pop); border: 1px solid var(--rule);
        border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60;
      }
      .toolbar-overflow.open { display: flex; }
      .toolbar-overflow .btn-tool { width: 100%; justify-content: flex-start; }
      .toolbar-overflow .autosave-wrap { justify-content: space-between; padding: 0 2px; }

      /* Slimmer timeline chrome */
      .timeline { padding: 10px 12px 8px; --tl-gutter: 44px; }
      .tl-label { flex-wrap: wrap; gap: 6px; }
    }
