  :root {
    --bg: #0d1117;
    --panel: #151b23;
    --panel-2: #1c2430;
    --border: #2a3441;
    --text: #e6edf3;
    --muted: #8b98a8;
    --accent: #1fb6c9;
    --accent-soft: rgba(31, 182, 201, 0.16);
    --rec: #ff453a;
    --radius: 8px;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
  }
  button, select {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
  }
  button:hover:not(:disabled) { border-color: #3c4a5c; background: #222c3a; }
  button:disabled { opacity: 0.4; cursor: default; }
  button.active { background: var(--accent-soft); border-color: var(--accent); color: #fff; }

  /* Header */
  .top {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .brand { font-weight: 700; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
  .brand svg { width: 22px; height: 22px; }
  .channel { font-size: 11px; font-weight: 700; color: #1a0f00; background: #ff9f0a; border-radius: 10px; padding: 1px 7px; letter-spacing: 0.04em; }
  .channel[hidden] { display: none; }
  .version { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; letter-spacing: 0; }
  .filename { color: var(--muted); font-size: 13px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .spacer { flex: 1; }
  .top label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
  .top select { padding: 5px 6px; }

  /* Main */
  .main { flex: 1; display: flex; min-height: 0; }
  .tools {
    width: 64px; flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 10px 0; overflow-y: auto;
  }
  .tool {
    width: 44px; height: 44px; padding: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative;
  }
  .tool svg { width: 20px; height: 20px; }
  .tool .key { position: absolute; right: 3px; bottom: 1px; font-size: 9px; color: var(--muted); }
  .sep { width: 36px; height: 1px; background: var(--border); margin: 4px 0; }
  .swatch { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
  .swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--bg) inset; }
  .thick { width: 44px; height: 30px; padding: 0; display: flex; align-items: center; justify-content: center; }
  .thick span { display: block; width: 22px; background: currentColor; border-radius: 4px; }

  .stagewrap {
    flex: 1; min-width: 0; position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: 12px; background: #06080b;
  }
  canvas#stage {
    max-width: 100%; max-height: 100%;
    background: #000; border-radius: 4px;
    touch-action: none;
    cursor: crosshair;
  }
  canvas#stage.pan { cursor: grab; }
  canvas#stage.panning { cursor: grabbing; }

  .dropzone {
    position: absolute; inset: 12px;
    border: 2px dashed var(--border); border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    color: var(--muted); text-align: center; cursor: pointer;
    background: rgba(13, 17, 23, 0.85);
  }
  .dropzone strong { color: var(--text); font-size: 18px; }
  .dropzone.hidden { display: none; }
  body.dragging .dropzone { display: flex; border-color: var(--accent); color: var(--text); }

  .countdown {
    position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
    font-size: 140px; font-weight: 800; color: #fff; text-shadow: 0 4px 30px rgba(0,0,0,0.7);
    pointer-events: none;
  }
  .countdown.show { display: flex; }

  .recbadge {
    position: absolute; top: 20px; left: 20px; display: none; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.65); padding: 6px 12px; border-radius: 20px; font-weight: 600; font-variant-numeric: tabular-nums;
    pointer-events: none;
  }
  .recbadge.show { display: flex; }
  .recbadge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
  .recbadge.paused .dot { animation: none; background: #ffd60a; }
  @keyframes blink { 50% { opacity: 0.25; } }

  .toast {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #222c3a; border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px;
    opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 80%; text-align: center;
  }
  .toast.show { opacity: 1; }
  .diag {
    position: absolute; left: 20px; bottom: 20px; display: none; z-index: 5;
    background: rgba(0,0,0,0.8); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font: 12px/1.5 ui-monospace, Menlo, monospace; color: #cfe; white-space: pre;
    pointer-events: none;
  }
  .diag.show { display: block; }

  /* Controls */
  .controls {
    background: var(--panel); border-top: 1px solid var(--border);
    padding: 8px 14px 10px; display: flex; flex-direction: column; gap: 8px;
  }
  .timeline { width: 100%; accent-color: var(--accent); height: 18px; cursor: pointer; }
  .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .group { display: flex; align-items: center; gap: 4px; }
  .time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 190px; font-size: 13px; }
  .time b { color: var(--text); font-weight: 600; }
  #playBtn { width: 44px; }
  .meter { width: 70px; height: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
  .meter div { height: 100%; width: 0; background: #34c759; transition: width 0.05s; }
  #recBtn { background: #3a1a1a; border-color: #6b2a2a; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  #recBtn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); }
  #recBtn.recording { background: var(--rec); border-color: var(--rec); color: #fff; }
  #recBtn.recording .dot { background: #fff; }
  #saveBtn { font-weight: 600; }

  /* Help */
  .help {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 10;
  }
  .help.show { display: flex; }
  .help .card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; max-width: 560px; width: 92%; }
  .help h2 { margin: 0 0 12px; font-size: 18px; }
  .help table { width: 100%; border-collapse: collapse; }
  .help td { padding: 5px 0; border-bottom: 1px solid var(--border); }
  .help td:first-child { width: 150px; }
  kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font: 12px ui-monospace, Menlo, monospace; }
  .help p { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
