  @font-face { font-family: Fredoka; font-weight: 500; src: url(/web/fonts/fredoka-latin-500-normal.woff2) format('woff2'); }
  @font-face { font-family: Fredoka; font-weight: 600; src: url(/web/fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
  @font-face { font-family: Fredoka; font-weight: 700; src: url(/web/fonts/fredoka-latin-700-normal.woff2) format('woff2'); }
  /* Layout: library list, or an editor with an outline rail on the left and the selected item on the right.
     Swiss-minimal: neutral surfaces, one teal accent, hairline borders, a strict 4/8 spacing scale. */
  :root {
    --bg: #f8f5ef; --surface: #ffffff; --raised: #ffffff; --sunken: #f2eee6; --hover: #ede8df;
    --fg: #1f1a15; --fg2: #544b41; --fg3: #73695d; --line: #e8e1d5; --line2: #d7cfc1;
    --accent: #0d9488; --accent-hover: #0b7d73; --accent-soft: #e6f6f4; --on-accent: #ffffff;
    --danger: #c42b2b; --danger-soft: #fdeceb; --warn: #9a5b00; --warn-soft: #fdf3e2; --ok: #157347;
    --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    --r: 8px; --r-lg: 12px;
    /* one colour per kind of beat, shared by the script and the timeline */
    --k-line: #e6f6f4; --k-line-fg: #0b6b62; --k-move: #e3ecfb; --k-move-fg: #1e4f9a; --k-act: #fbefd6; --k-act-fg: #8a5a00;
    --k-cam: #eee7fb; --k-cam-fg: #5b3aa8; --k-snd: #e5f2e9; --k-snd-fg: #1f6b3b; --k-misc: #f1ede6; --k-misc-fg: #544b41;
    --shadow: 0 1px 2px rgb(40 30 20 / 6%), 0 4px 14px rgb(40 30 20 / 6%);
    --display: Fredoka, ui-rounded, system-ui, sans-serif;
    color-scheme: light;
  }
  /* dark: when chosen, or when the computer is dark and light wasn't chosen (Light / Dark / Auto in the top bar) */
  :root[data-theme="dark"] {
    --bg: #111113; --surface: #18181b; --raised: #1f1f23; --sunken: #141416; --hover: #27272a;
    --fg: #f4f4f5; --fg2: #c4c4cc; --fg3: #9696a0; --line: #2a2a2f; --line2: #3a3a40;
    --accent: #2dd4bf; --accent-hover: #5eead4; --accent-soft: #10302d; --on-accent: #062a26;
    --danger: #ff8a80; --danger-soft: #3a1717; --warn: #f5b84d; --warn-soft: #332611; --ok: #6ee7a8;
    --k-line: #10302d; --k-line-fg: #7ae6d6; --k-move: #1c2a44; --k-move-fg: #9cc0f5; --k-act: #33270f; --k-act-fg: #f2c66d;
    --k-cam: #2a2142; --k-cam-fg: #c4b2f5; --k-snd: #16301f; --k-snd-fg: #8fdcaa; --k-misc: #26262b; --k-misc-fg: #b8b8c0;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark; }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
    --bg: #111113; --surface: #18181b; --raised: #1f1f23; --sunken: #141416; --hover: #27272a;
    --fg: #f4f4f5; --fg2: #c4c4cc; --fg3: #9696a0; --line: #2a2a2f; --line2: #3a3a40;
    --accent: #2dd4bf; --accent-hover: #5eead4; --accent-soft: #10302d; --on-accent: #062a26;
    --danger: #ff8a80; --danger-soft: #3a1717; --warn: #f5b84d; --warn-soft: #332611; --ok: #6ee7a8;
    --k-line: #10302d; --k-line-fg: #7ae6d6; --k-move: #1c2a44; --k-move-fg: #9cc0f5; --k-act: #33270f; --k-act-fg: #f2c66d;
    --k-cam: #2a2142; --k-cam-fg: #c4b2f5; --k-snd: #16301f; --k-snd-fg: #8fdcaa; --k-misc: #26262b; --k-misc-fg: #b8b8c0;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark; } }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
  button, input, select, textarea { font: inherit; color: inherit; }
  :focus-visible { outline: none; box-shadow: var(--focus); }
  h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
  svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  [hidden] { display: none !important; }

  /* controls */
  .btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line2);
         background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; text-decoration: none; }
  .btn:hover { background: var(--hover); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn.ghost { border-color: transparent; background: transparent; color: var(--fg2); }
  .btn.ghost:hover { background: var(--hover); color: var(--fg); }
  .btn.danger { color: var(--danger); }
  .btn:disabled { opacity: .4; cursor: default; }
  .icon-btn { width: 32px; padding: 0; justify-content: center; }
  .btn.sm { height: 28px; padding: 0 10px; font-size: 13px; } .icon-btn.sm { width: 28px; padding: 0; }
  .btn.xs { height: 24px; padding: 0 8px; font-size: 12px; gap: 4px; }
  input:where(:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):not(.search input):not(.ai-input input)),
  select, textarea {
    height: 36px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 8px;
    background: var(--sunken, var(--surface)); color: var(--fg); min-width: 0; width: 100%;
    transition: border-color .15s, box-shadow .15s, background .15s;
  }
  input::placeholder, textarea::placeholder { color: var(--fg3); opacity: .85; }
  textarea { height: auto; min-height: 68px; padding: 9px 12px; resize: vertical; line-height: 1.48; }
  input:where(:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not(.search input):not(.ai-input input)):hover,
  select:hover, textarea:hover { border-color: var(--fg3); }
  input:where(:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not(.search input):not(.ai-input input)):focus,
  select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); background: var(--surface); }
  input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
  input:where([readonly]:not(.ai-input input)) { opacity: .8; background: var(--surface); }
  select { cursor: pointer; padding-right: 30px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c8c98' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; }
  input[type=number] { font-variant-numeric: tabular-nums; }
  input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
  input[type=color] { width: 36px; height: 36px; padding: 3px; border: 1px solid var(--line2); border-radius: 8px; background: var(--sunken, var(--surface)); cursor: pointer; flex: none; transition: border-color .15s; }
  input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
  input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
  input[type=file] {
    font-size: 13px; color: var(--fg2); max-width: 100%; cursor: pointer;
    border: 1px dashed var(--line2); border-radius: 8px; padding: 5px 8px; background: var(--sunken, var(--surface));
    transition: border-color .15s, background .15s;
  }
  input[type=file]:hover { border-color: var(--fg3); }
  input[type=file]::file-selector-button {
    font: inherit; font-weight: 500; font-size: 12.5px; color: var(--fg); background: var(--surface);
    border: 1px solid var(--line2); border-radius: 6px; padding: 4px 10px; margin-right: 10px;
    cursor: pointer; transition: background .15s, border-color .15s;
  }
  input[type=file]::file-selector-button:hover { background: var(--hover); border-color: var(--fg3); }
  input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; flex: none; }
  .mk-note-acts { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; vertical-align: middle; }
  .mk-notes li { margin-bottom: 6px; line-height: 1.5; }
  .check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--fg2); white-space: nowrap; }
  .seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; background: var(--surface); width: fit-content; }
  .seg button { border: 0; background: none; height: 30px; padding: 0 12px; cursor: pointer; color: var(--fg2); }
  .seg button + button { border-left: 1px solid var(--line2); }
  .seg button.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
  .field { display: grid; gap: 6px; min-width: 0; align-content: start; }
  .field > span { font-size: 12.5px; color: var(--fg3); font-weight: 500; }
  .hint { font-size: 12.5px; color: var(--fg3); font-weight: 400; }
  .row { display: flex; gap: 8px; align-items: center; min-width: 0; }
  .grow { flex: 1; min-width: 0; }
  .conflict-review { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line2); }
  .conflict-review summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
  .conflict-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .conflict-columns pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; background: var(--sunken); padding: 8px; }
  @media (max-width: 700px) { .conflict-columns { grid-template-columns: 1fr; } }

  /* app frame: collapsible workspace sidebar + slim topbar + main body */
  .app { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; overflow: hidden; }
  .app.sb-rail { grid-template-columns: 60px minmax(0, 1fr); }
  .app.auth-mode { grid-template-columns: 1fr; }
  .app.auth-mode .app-sidebar { display: none; }
  .app-shell-main { display: grid; grid-template-rows: 52px minmax(0, 1fr) auto; min-width: 0; min-height: 0; height: 100vh; }
  .queue-ribbon { position:fixed; inset:0 0 auto; height:12px; z-index:50; padding:0; border:0; background:transparent; cursor:pointer;
    animation:queue-flow 8s linear infinite; transition:filter 6s ease-in-out; }
  .queue-ribbon::before, .queue-ribbon::after { content:""; position:absolute; inset:0 0 auto; height:3px; pointer-events:none;
    background:linear-gradient(90deg,#24d6bd,#5f8bff,#d36bff,#ff8b91,#ffd36b,#24d6bd); background-size:300% 100%; background-position:inherit; }
  .queue-ribbon::after { height:6px; filter:blur(5px); opacity:.75; }
  .queue-ribbon:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
  @keyframes queue-flow { from { background-position:0% 50%; } to { background-position:300% 50%; } }
  @media (prefers-reduced-motion:reduce) { .queue-ribbon { animation:none; transition:none; } }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); min-width: 0; }
  .brand { display: flex; align-items: center; gap: 8px; font: 600 16px/1 var(--display, system-ui); letter-spacing: .005em; }
  .logo { width: 24px; height: 24px; border-radius: 7px; background: url(/web/logo.svg) center / cover no-repeat; display: inline-block; flex: none; }
  .logo svg { display: none; }
  /* the Moodaboo lockup in the top bar: the ink version on light, the cream-and-sunshine version on dark */
  .brand-lockup { height: 24px; width: auto; display: block; }
  .brand-lockup.on-dark { display: none; }
  .brand svg.moodeyes { height: 24px; width: auto; display: block !important; }  /* the live logo (web/brand/moodeyes.js) */
  .brand:has(svg.moodeyes) .brand-lockup.on-dark { display: none !important; }
  :root[data-theme="dark"] .brand-lockup.on-light { display: none; }
  :root[data-theme="dark"] .brand-lockup.on-dark { display: block; }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-lockup.on-light { display: none; }
                                        :root:not([data-theme="light"]) .brand-lockup.on-dark { display: block; } }
  .eptitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .status { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--fg3); white-space: nowrap; }
  .status svg { width: 14px; height: 14px; }
  .pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; border: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
  button.pill { cursor: pointer; }
  .pill svg { width: 14px; height: 14px; }
  .pill.ok { background: var(--accent-soft); color: var(--fg); } .pill.ok svg { color: var(--ok); }
  .pill.err { background: var(--danger-soft); color: var(--danger); }
  .pill.warn { background: var(--warn-soft); color: var(--warn); }
  .spacer { flex: 1; }
  .divider { width: 1px; height: 20px; background: var(--line); }
  .body { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 0; }
  .rail { border-right: 1px solid var(--line); background: var(--surface); overflow: auto; padding: 12px 8px 24px; display: grid; gap: 2px; align-content: start; }
  .rail h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg3); padding: 14px 10px 6px; display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
  .rail h4:first-child { padding-top: 4px; min-height: 0; }
  .nav { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--r); background: none; cursor: pointer; text-align: left; color: var(--fg2); }
  .nav:hover { background: var(--hover); color: var(--fg); }
  .nav.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
  .nav .num { width: 22px; height: 22px; border-radius: 6px; background: var(--sunken); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--fg2); flex: none; font-variant-numeric: tabular-nums; }
  .nav.on .num { background: var(--accent); color: var(--on-accent); }
  .nav .meta { display: grid; min-width: 0; line-height: 1.3; }
  .nav .meta small { color: var(--fg3); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
  .nav .end { margin-left: auto; }
  .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-left: auto; }
  .dot.err { background: var(--danger); } .dot.warn { background: var(--warn); }
  .main { overflow: auto; }
  .home-main { overflow-anchor: none; }
  .page { max-width: 980px; margin: 0 auto; padding: 28px 32px 120px; display: grid; gap: 24px; }
  .page-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .page-head h2 { font-size: 22px; }
  .page-head .sub { color: var(--fg3); margin-top: 2px; }
  .section { display: grid; gap: 10px; }
  .section > h3 { font-size: 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
  .panel.pad { padding: 16px; }
  .grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { display: grid; }
  .trow { display: grid; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); min-width: 0; }
  .trow:first-child { border-top: 0; }
  .trow.head { font-size: 12px; color: var(--fg3); font-weight: 500; padding-top: 9px; padding-bottom: 9px; }
  .stage .trow { grid-template-columns: 140px minmax(170px, 1fr) 128px 116px 112px; }
  .props .trow { grid-template-columns: 128px 110px minmax(170px, 1fr) 32px 160px 28px; }
  .who { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; cursor: pointer; }
  .who.off { color: var(--fg3); font-weight: 400; }
  .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
  .pos { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
  .pos output { font-size: 12.5px; color: var(--fg2); text-align: right; font-variant-numeric: tabular-nums; }
  .pos.spot { grid-template-columns: minmax(0, 1fr) 72px; }
  .pos.spot input[type=number] { height: 28px; padding: 0 6px; text-align: right; }
  .pos.spot.off input[type=number] { border-color: var(--warn); color: var(--warn); }

  /* beat forms (in the inspector) */
  .lineText { font-size: 15px; min-height: 40px; }
  .adder { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border: 1px dashed var(--line2); border-radius: var(--r-lg); }
  .adder > span { font-size: 12.5px; color: var(--fg3); margin-right: 4px; }
  .adder .btn svg { color: var(--fg3); }
  .insert { display: flex; justify-content: center; height: 0; position: relative; z-index: 2; }
  .insert button { position: absolute; top: -14px; opacity: 0; transition: opacity .15s; }
  .insert:hover button, .insert button:focus-visible { opacity: 1; }
  .insert::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 16px; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .chip { height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; color: var(--fg2); }
  .chip:hover { border-color: var(--fg3); }
  .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); font-weight: 600; }
  .alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); font-size: 13.5px; }
  .alert.err { background: var(--danger-soft); color: var(--danger); }
  .alert.warn { background: var(--warn-soft); color: var(--warn); }

  .character-page { height:100%; max-width:none; padding:10px 16px 12px; display:flex; flex-direction:column; gap:8px; overflow:hidden; }
  .character-page .vl-cast { flex-wrap:nowrap; overflow-x:auto; flex:none; gap:6px; padding-bottom:2px; }
  .character-page .vl-who { padding:5px 10px; min-width:132px; gap:8px; border-radius:10px; }
  .character-page .vl-who .avatar { width:28px; height:28px; border-radius:8px; font-size:12px; }
  .character-page .vl-who b { font-size:13px; line-height:1.2; display:block; }
  .character-page .vl-who small { font-size:11.5px; color:var(--fg3); line-height:1.2; display:block; }
  .character-workspace { flex:1; min-height:0; display:grid; grid-template-columns:minmax(360px, 50%) minmax(0,1fr); gap:12px; transition:grid-template-columns .18s ease; }
  .character-workspace.expanded { grid-template-columns:minmax(440px, 64%) minmax(0,1fr); }
  .character-controls { min-width:0; min-height:0; overflow:auto; display:grid; grid-auto-rows:max-content; align-content:start; gap:12px; padding-right:2px; }
  .character-controls .vl { grid-template-columns:1fr; }
  .card.lab-stage { display:grid; grid-template-rows:auto minmax(0,1fr) auto; gap:8px; padding:12px; min-width:0; min-height:0; overflow:hidden; }
  .lab-stage-head { display:flex; align-items:center; gap:8px; min-width:0; }
  .lab-stage-head h3 { font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .lab-view { position:relative; min-height:260px; height:100%; display:grid; }
  .lab-stage-play { position:absolute; left:10px; bottom:10px; z-index:4; height:32px; padding:0 13px; border-radius:99px; border:1px solid var(--accent);
    background:color-mix(in srgb, var(--accent) 92%, #000); color:#fff; font-size:13px; font-weight:600; cursor:pointer; display:inline-flex; align-items:center; gap:6px;
    box-shadow:0 4px 14px rgb(0 0 0 / 24%); }
  .lab-stage-play:hover { filter:brightness(1.08); }
  .lab-stage-play[hidden] { display:none; }
  .lab-stage-play .i { width:14px; height:14px; }
  #labSvg { min-height:240px; height:100%; width:100%; object-fit:contain; }   /* full-height live character stage */
  /* feeling, action and facing: small pills over the preview */
  .lab-pills { position:absolute; top:8px; left:8px; right:8px; display:flex; flex-wrap:wrap; justify-content:space-between; align-items:flex-start; gap:6px; pointer-events:none; z-index:4; }
  .lab-pills > *, .lab-pills-l > * { pointer-events:auto; }
  .lab-pills-l { display:flex; flex-wrap:wrap; align-items:flex-start; gap:6px; pointer-events:none; }
  .pill-menu { position:relative; }
  .pill { list-style:none; cursor:pointer; height:28px; padding:0 11px; border-radius:99px; border:1px solid var(--line2); display:inline-flex; align-items:center; gap:4px;
    background:color-mix(in srgb, var(--surface) 90%, transparent); font-size:12.5px; color:var(--fg2); box-shadow:var(--shadow); user-select:none; }
  .pill::-webkit-details-marker { display:none; }
  .pill::after { content:'▾'; font-size:10px; color:var(--fg3); }
  .pill b { color:var(--fg); font-weight:600; }
  .pill-menu[open] > .pill { border-color:var(--accent); }
  .pill-pop { position:absolute; top:calc(100% + 6px); left:0; z-index:6; width:min(340px, 72vw); max-height:280px; overflow:auto; padding:9px; background:var(--raised); border:1px solid var(--line2); border-radius:var(--r-lg); box-shadow:0 8px 24px rgb(0 0 0 / 18%); display:grid; gap:7px; }
  .lab-foot .pill-pop { top:auto; bottom:calc(100% + 6px); width:min(320px, 76vw); padding:10px 12px; }
  .pill-pop .chip { height:26px; font-size:12.5px; }
  .pill-pop .chip[aria-pressed="true"] { background:var(--accent-soft); border-color:var(--accent); color:var(--fg); font-weight:600; }
  .lab-pop-search { height:28px !important; font-size:12.5px; }
  .lab-act-group { display:grid; gap:4px; }
  .lab-act-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; color:var(--fg3); }
  .pill-seg { display:inline-flex; border:1px solid var(--line2); border-radius:99px; overflow:hidden; background:color-mix(in srgb, var(--surface) 90%, transparent); box-shadow:var(--shadow); }
  .pill-seg button { border:0; background:none; height:28px; min-width:30px; padding:0 9px; font:inherit; font-size:12px; color:var(--fg2); cursor:pointer; }
  .pill-seg button + button { border-left:1px solid var(--line2); }
  .pill-seg button[aria-pressed="true"] { background:var(--accent); color:var(--on-accent); font-weight:600; }
  .pill, .pill-seg button { white-space:nowrap; }
  .pill:focus-visible, .pill-seg button:focus-visible { outline:none; box-shadow:var(--focus); }
  .lab-row { display:flex; flex-wrap:wrap; align-items:center; gap:6px 12px; }
  .lab-turn, .lab-toward { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--fg2); }
  .lab-turn input { width:120px; }
  .lab-toward select { height:28px; width:auto; font-size:12.5px; }
  .lab-toward[hidden] { display:none; }
  /* Ask AI first (hero primary editor) */
  .ai-box { border:1.5px solid color-mix(in srgb, var(--accent) 62%, var(--line)); box-shadow:0 2px 12px color-mix(in srgb, var(--accent) 10%, transparent); background:linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 92%, var(--surface)), var(--surface) 78%); gap:9px; padding:14px; }
  .ai-top { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  .ai-top label b { font-size:15px; }
  .ai-badge { display:inline-flex; align-items:center; height:20px; padding:0 7px; border-radius:99px; background:var(--accent); color:var(--on-accent); font-size:11px; font-weight:700; letter-spacing:.02em; text-transform:uppercase; flex:none; }
  .ai-conn { display:inline-flex; align-items:center; gap:5px; font-size:12px; color:var(--fg3); flex:none; }
  .ai-conn select { height:24px; padding:0 22px 0 7px; font-size:12px; border-radius:6px; max-width:205px; width:auto; background-color:var(--surface); }
  .ai-box .ai-input { align-items:flex-end; padding:6px 6px 6px 12px; background:var(--surface); }
  .ai-input textarea { flex:1; min-width:0; border:0; background:transparent; box-shadow:none; outline:none; resize:vertical; min-height:54px; padding:4px 0; font:inherit; font-size:14px; color:var(--fg); }
  .ai-input textarea[readonly] { color:var(--fg3); }
  .ai-examples, .ai-follow { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
  .ai-examples .hint, .ai-follow .hint { font-size:12px; margin-right:2px; }
  .ai-examples .chip, .ai-follow .chip { height:26px; font-size:12.5px; }
  .ai-examples kbd { font:inherit; font-size:.85em; padding:0 4px; border:1px solid var(--line2); border-radius:4px; opacity:.85; }
  .ai-groups { display:grid; gap:7px; }
  .ai-gname { font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; color:var(--fg3); margin-bottom:4px; }
  .ai-pill-list { margin:0; padding:0; list-style:none; display:flex; flex-wrap:wrap; gap:6px; }
  .ai-pill-list > li { display:inline-flex; flex-wrap:wrap; align-items:center; gap:6px; max-width:100%; }
  .ai-pill { display:inline-flex; align-items:center; gap:5px; padding:4px 9px; border-radius:99px; border:1px solid var(--line2); background:var(--sunken); color:var(--fg2); font-size:12.5px; cursor:pointer; text-align:left; transition:border-color .15s, background .15s; max-width:100%; }
  .ai-pill:hover { border-color:var(--accent); background:var(--accent-soft); color:var(--fg); }
  .ai-pill b { color:var(--fg); font-weight:600; }
  .ai-dot { display:inline-block; flex:none; width:7px; height:7px; margin-left:6px; border-radius:50%; background:var(--accent); vertical-align:middle; }
  .ai-hl { outline:2px solid var(--accent); outline-offset:4px; border-radius:6px; }
  #aiCompare[aria-pressed="true"] { background:var(--accent-soft); border-color:var(--accent); color:var(--fg); }
  /* Manual fine-tuning divider + 4 consolidated groups */
  .lab-manual-head { display:flex; align-items:center; gap:8px; padding-top:4px; border-top:1px solid var(--line); }
  .lab-manual-head .hint { font-size:12.5px; }
  #labOnlyAll[aria-pressed="true"] { background:var(--accent-soft); border-color:var(--accent); color:var(--fg); }
  .lab-groups { display:grid; gap:8px; }
  .lab-group { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); min-width:0; }
  .lab-group > summary { list-style:none; cursor:pointer; display:flex; align-items:baseline; gap:10px; padding:11px 14px; border-radius:var(--r-lg); }
  .lab-group > summary::-webkit-details-marker { display:none; }
  .lab-group > summary::before { content:'▸'; color:var(--fg3); display:inline-block; width:10px; transition:transform .15s; }
  .lab-group[open] > summary::before { transform:rotate(90deg); }
  .lab-group > summary:hover { background:var(--hover); }
  .lab-group > summary:focus-visible { outline:none; box-shadow:var(--focus); }
  .lg-title { font-weight:600; font-size:14px; white-space:nowrap; display:inline-flex; align-items:center; }
  .lg-sum { flex:1; min-width:0; color:var(--fg3); font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-variant-numeric:tabular-nums; }
  .lg-body { padding:2px 14px 14px; display:grid; gap:12px; min-width:0; }
  .lg-none { display:none; }
  .lab-group.only-changed[data-none] .lg-none { display:block; }
  .lab-group.only-changed [data-path]:not([data-changed]), .lab-group.only-changed .tune[data-ctl]:not([data-changed]) { display:none; }
  .lab-group.only-changed .lab-sub:not([data-changed]):not(:has([data-path][data-changed], [data-ctl][data-changed])) { display:none; }
  .lab-sub { display:grid; gap:10px; }
  .lab-sub + .lab-sub, .lab-subhead { padding-top:10px; border-top:1px solid var(--line); }
  .lab-sub > h4, .lab-subhead > h4 { font-size:13px; color:var(--fg2); font-weight:600; }
  .lab-group .card { padding:12px; background:var(--bg); }
  .lab-group h3 { font-size:14px; }
  .swatch-grid { display:flex; flex-wrap:wrap; gap:8px 14px; align-items:end; }
  .swatch-grid .field { min-width:72px; flex:0 1 auto; }
  .swatch-grid input[type=color] { width:34px; height:28px; }
  .trait-checks { display:flex; flex-wrap:wrap; gap:8px 14px; align-items:center; }
  .pose-more > summary, .voice-more > summary { cursor:pointer; font-size:12.5px; font-weight:500; color:var(--fg2); padding:4px 0; user-select:none; }
  .art-sheet { display:grid; gap:10px; }
  .flabel { display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
  .flabel .reset, .tune .reset { margin-left:auto; opacity:.52; transition:opacity .12s; }
  .field:hover .reset, .field:focus-within .reset, .tune:hover .reset, .tune:focus-within .reset { opacity:1; }
  @media (hover: none) { .flabel .reset, .tune .reset { opacity:1; } }
  .tune .top1 .grow { flex:1; }
  @media (max-width: 900px) {
    .character-workspace, .character-workspace.expanded { grid-template-columns:1fr; grid-template-rows:minmax(320px, 50%) minmax(0,1fr); }
    .lab-keys { display:none; }
    .lab-view { min-height:200px; }
    #labSvg { min-height:180px; }
    .character-page { padding:8px; gap:6px; }
    .card.lab-stage { padding:8px; }
    .lab-stage-head .hint { display:none; }
  }
  @media (max-height: 550px) { .character-page .char-bar .hint, .lab-stage .hint { display:none; } }
  #labSvg { width:100%; height:100%; max-height:none; border-radius:var(--r-lg); background:var(--sunken); }
  .lab-foot { display:grid; gap:6px; min-width:0; }
  .lab-keys kbd { font:inherit; font-size:.85em; padding:0 4px; border:1px solid var(--line, currentColor); border-radius:4px; opacity:.85; }
  .lab-controls { display:flex; gap:10px; flex-wrap:wrap; align-items:end; }
  .pose-ed { display:grid; gap:10px; margin-top:12px; padding-top:12px; border-top:1px solid var(--line, rgba(0,0,0,.1)); }
  .pose-ed h4 { margin:0; }
  .field .ovr, h3 .ovr, .card-head .ovr { font-size:11px; font-weight:600; color:var(--accent); margin-left:6px; }
  .btn.xs { padding:1px 6px; font-size:11px; min-height:0; line-height:1.4; }
  .pose-ed #poseScrub { flex:1; min-width:120px; }
  .pose-ed #poseKeySel { flex:0 0 auto; width:auto; }
  .pose-arms { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(230px,100%),1fr)); gap:10px; }
  .pose-arm { min-width:0; margin:0; padding:8px 10px 10px; border:1px solid var(--arm-color); border-radius:var(--r); display:grid; gap:8px; }
  .pose-arm legend { padding:0 5px; font-size:13px; font-weight:600; }
  .pose-arm select { border-color:var(--arm-color); }
  .pose-arm input[type=range] { accent-color:var(--arm-color); }
  .pose-arm output { float:right; font-variant-numeric:tabular-nums; }
  #labSvg:has(.pose-handle) { touch-action:none; }
  .pose-handle { cursor:grab; }
  .pose-handle.dragging { cursor:grabbing; }
  .pose-handle.dragging .pose-mark { opacity:.34; }
  .lab-controls .field { min-width:120px; flex:1; }
  .pose-picker { display:flex; gap:6px; flex-wrap:wrap; margin-top:4px; }
  .pose-chip { font-size:12.5px; height:26px; padding:0 9px; }
  .face-subhead { margin-top:12px; padding-top:10px; border-top:1px solid var(--line); }
  /* cards (cast), library */
  .cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 14px; align-content: start; }
  .card-head { display: flex; align-items: center; gap: 10px; }
  .avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
  .card-head h3 { font-size: 15px; } .card-head small { color: var(--fg3); display: block; font-size: 12.5px; }
  .voice { font-size: 12.5px; color: var(--fg2); background: var(--sunken); border-radius: var(--r); padding: 8px 10px; min-height: 34px; }
  audio { width: 100%; height: 34px; }
  .library { display: grid; }
  .lib-row { display: grid; grid-template-columns: minmax(0, 1fr) 60px 140px 72px; gap: 16px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }
  .lib-row:first-child { border-top: 0; }
  .lib-row h3 { font-size: 15px; } .lib-row small { color: var(--fg3); }
  .lib-row .open { all: unset; cursor: pointer; display: grid; gap: 2px; min-width: 0; border-radius: var(--r); }
  .lib-row .open:hover h3 { color: var(--accent); } .lib-row .open:focus-visible { box-shadow: var(--focus); }
  .lib-row .acts { display: flex; gap: 2px; justify-content: flex-end; }
  .tag.live { background: var(--accent-soft); color: var(--accent); }
  .channels { display: flex; gap: 8px; flex-wrap: wrap; }
  .channel { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; min-width: 180px; padding: 10px 14px;
             border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
  .channel b { font-weight: 600; } .channel small { color: var(--fg3); font-size: 12.5px; }
  .channel:hover { border-color: var(--fg3); } .channel:focus-visible { box-shadow: var(--focus); }
  .channel.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
  .queue-dialog { width:min(760px, 94vw); max-height:80vh; border:1px solid var(--line); border-radius:var(--r-lg); padding:16px; background:var(--surface); color:var(--fg); }
  .topbar [data-act="jobs-open"] { flex:none; }
  @media (max-width:650px) { .topbar #undoBtn, .topbar #redoBtn, .topbar .divider, .topbar #valPill { display:none; } .topbar { gap:5px; padding:0 6px; } }
  .queue-dialog::backdrop { background:rgba(0,0,0,.55); }
  /* the Notes popup */
  .notes-dialog { width:min(680px, 94vw); max-height:84vh; overflow:auto; }
  .notes-dialog .nt-bar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:6px 0 10px; }
  .notes-dialog .nt-group { margin:14px 0 6px; font-size:12px; font-weight:650; letter-spacing:.04em; text-transform:uppercase; color:var(--fg3); }
  .notes-dialog .nt { border:1px solid var(--line); border-radius:var(--r); padding:10px 12px; margin-bottom:8px; background:var(--raised); }
  .notes-dialog .nt.focus { border-color:var(--warn); box-shadow:inset 0 0 0 1px var(--warn); }
  .notes-dialog .nt-title { display:flex; gap:8px; align-items:center; font-weight:600; }
  .notes-dialog .nt-title .i { color:var(--warn); }
  .notes-dialog .nt-text { margin:4px 0 0; color:var(--fg2); overflow-wrap:anywhere; }
  .notes-dialog details { margin-top:8px; }
  .notes-dialog summary { cursor:pointer; font-weight:550; color:var(--fg); border-radius:var(--r); width:fit-content; padding:2px 4px; margin-left:-4px; }
  .notes-dialog details > div { padding:6px 0 0 2px; color:var(--fg2); }
  .notes-dialog ol { margin:6px 0 0; padding-left:20px; display:grid; gap:4px; }
  .notes-dialog code { font:12px var(--mono); background:var(--sunken); border:1px solid var(--line); border-radius:4px; padding:0 4px; overflow-wrap:anywhere; }
  .notes-dialog .nt-act { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
  .nt-link { border:0; background:none; padding:0 2px; color:var(--accent); text-decoration:underline; cursor:pointer; font-size:inherit; border-radius:4px; white-space:nowrap; }
  .queue-dialog .q-row { grid-template-columns:22px minmax(0,1fr) minmax(85px,130px) auto; }
  .queue-dialog .q-actions, .queue .q-actions { display:flex; gap:6px; justify-content:flex-end; flex-wrap:wrap; }
  .queue-dialog .q-row .state { display:block; }
  @media (max-width:650px) { .queue-dialog .q-row { grid-template-columns:22px minmax(0,1fr); } .queue-dialog .q-row .state, .queue-dialog .q-row .progress, .queue-dialog .q-actions { grid-column:2; justify-content:flex-start; } }
  .queue h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--fg2); padding: 12px 16px 4px; }
  .feel-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
  .feel-pick > select { flex: 1 1 120px; min-width: 0; }
  .feel-blend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1 1 100%; }
  .feel-blend select { flex: 1 1 90px; min-width: 0; } .feel-blend input[type=range] { flex: 2 1 90px; min-width: 70px; }
  .feel-blend output { font-size: 12px; color: var(--fg3); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
  .queue h3 .q-all { margin-left: auto; display: flex; gap: 6px; }
  .q-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(80px, 200px) minmax(76px, 165px); gap: 12px; align-items: center; padding: 8px 16px; }
  .q-row:last-child { padding-bottom: 12px; }
  .q-row .n { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 600;
              background: var(--sunken); color: var(--fg3); font-variant-numeric: tabular-nums; }
  .q-row .n.run { background: var(--accent); color: var(--bg); } .q-row .n.ok { background: var(--accent-soft); color: var(--accent); }
  .q-row .n.bad { background: var(--danger); color: var(--bg); }
  .q-row .what { min-width: 0; } .q-row .what b { font-weight: 500; } .q-row .what small { display: block; color: var(--fg3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .q-row .state { color: var(--fg3); font-size: 13px; font-variant-numeric: tabular-nums; }
  .q-row.past { opacity: .72; }
  .tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--sunken); color: var(--fg3); }
  .tag.ok { background: var(--accent-soft); color: var(--fg); }
  .media { width: 100%; border-radius: var(--r-lg); background: #000; display: block; border: 0; }
  video.media.portrait { width: auto; max-width: 100%; max-height: 72vh; margin: 0 auto; }
  .watch-frame { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; }
  .watch-frame:not(.vertical) { width: 100%; }
  .safe-guide { position: absolute; inset: 8% 14% 20% 7%; border: 2px dashed #fff; box-shadow: 0 0 2px #000; pointer-events: none; }
  .safe-guide[hidden] { display: none; }
  img.media { background: var(--sunken); border: 1px solid var(--line); }
  iframe.media { aspect-ratio: 16 / 11; background: var(--sunken); }
  /* Setup: a section menu on the left, a status summary on top, each section a heading row and its settings */
  .setup { max-width: 1120px; margin: 0 auto; padding: 24px 32px 120px; display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 32px; align-items: start; }
  .setup-nav { position: sticky; top: 24px; display: grid; gap: 2px; }
  .setup-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r); color: var(--fg2); text-decoration: none; font-size: 13.5px; }
  .setup-nav a:hover { background: var(--hover); color: var(--fg); }
  .setup-nav a.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
  .setup-nav a:focus-visible { box-shadow: var(--focus); outline: none; }
  .setup-nav .led { margin-left: auto; }
  .led { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); flex: none; display: inline-block; }
  .led.ok { background: var(--ok); } .led.warn { background: var(--warn); } .led.off { background: var(--line2); }
  .setup-body { display: grid; gap: 28px; min-width: 0; }
  .setup-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; display: grid; gap: 4px; text-align: left; font: inherit; color: inherit; cursor: pointer; min-width: 0; }
  .stat:hover { border-color: var(--line2); background: var(--raised); } .stat:focus-visible { box-shadow: var(--focus); outline: none; }
  .stat small { color: var(--fg3); font-size: 12px; display: flex; align-items: center; gap: 6px; }
  .stat b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat span { color: var(--fg3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .set-sec { display: grid; gap: 12px; scroll-margin-top: 16px; }
  .set-sec > header { display: grid; gap: 2px; }
  #setVoices, #setMusic, #setSystem { display: grid; gap: 12px; }
  .narr { display: grid; gap: 14px; } .narr-head { display: flex; gap: 12px; align-items: flex-start; }
  .narr-badge { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
  .narr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
  .narr-grid input[type=range] { width: 100%; } .narr-val { font-variant-numeric: tabular-nums; margin-left: 4px; }
  .narr-ticks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; } .narr-foot { flex-wrap: wrap; gap: 10px; } .narr-foot audio { height: 34px; }
  @media (max-width: 760px) { .narr-grid { grid-template-columns: 1fr; } }
  .set-sec > header h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
  .set-sec > header p { margin: 0; color: var(--fg3); font-size: 13px; }
  .set-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
  .set-row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 16px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: start; }
  .set-row:first-child { border-top: 0; }
  .set-row > .lbl { display: grid; gap: 2px; } .set-row > .lbl b { font-size: 13.5px; } .set-row > .lbl span { color: var(--fg3); font-size: 12.5px; }
  .set-row > .val { display: grid; gap: 8px; min-width: 0; }
  .engines { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .engine { position: relative; display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
  .engine:hover:not(:disabled) { border-color: var(--line2); }
  .engine[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
  .engine:focus-visible { box-shadow: var(--focus); outline: none; }
  .engine:disabled { cursor: not-allowed; opacity: .6; }
  .engine .top { display: flex; align-items: center; gap: 8px; } .engine .top b { font-size: 14px; }
  .engine .radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line2); margin-left: auto; display: grid; place-items: center; flex: none; }
  .engine[aria-checked="true"] .radio { border-color: var(--accent); } .engine[aria-checked="true"] .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .engine small { color: var(--fg3); font-size: 12.5px; line-height: 1.4; }
  .engine .tags { display: flex; gap: 6px; flex-wrap: wrap; }
  .tag.soft { background: var(--sunken); color: var(--fg2); }
  .checks { display: grid; gap: 0; }
  .check-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 13px; }
  .check-row:first-child { border-top: 0; } .check-row .led { transform: translateY(-1px); }
  .check-row .sub { color: var(--fg3); }
  .presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; padding: 12px 16px 16px; }
  .preset { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; display: grid; gap: 2px; font-size: 12.5px; }
  .preset b { font-size: 13px; } .preset span { color: var(--fg3); }
  details.more > summary { cursor: pointer; padding: 12px 16px; color: var(--fg2); font-size: 13px; list-style: none; display: flex; align-items: center; gap: 8px; }
  details.more > summary::-webkit-details-marker { display: none; }
  details.more > summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; line-height: 1; }
  details.more[open] > summary::before { transform: rotate(90deg); }
  .meter { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; } .meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
  .meter.high i { background: var(--warn); }
  .provider-list { display: grid; gap: 6px; }
  code.cmd { background: var(--sunken); padding: 1px 6px; border-radius: 4px; font-size: 12px; user-select: all; }
  .provider { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
  .provider b { font-weight: 600; white-space: nowrap; } .provider .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .lyria { display: grid; gap: 12px; }
  .lyria textarea { min-height: 64px; resize: vertical; }
  .song { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
  .song:first-child { border-top: 0; } .song audio { width: 100%; height: 32px; grid-column: 1 / -1; }
  .song .desc { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  @media (max-width: 900px) {
    .setup { grid-template-columns: 1fr; padding: 16px 16px 96px; gap: 16px; }
    .setup-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
    .setup-nav a { white-space: nowrap; } .setup-nav .led { margin-left: 4px; }
    .setup-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .engines { grid-template-columns: 1fr; }
    .set-row { grid-template-columns: 1fr; gap: 8px; }
  }
  .line-voice { display: grid; gap: 8px; } .line-voice audio { width: 100%; height: 34px; }
  .rec-row { flex-wrap: wrap; gap: 8px; align-items: center; }
  .file-btn { cursor: pointer; position: relative; }
  .file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); } .file-btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
  .file-btn:focus-within { box-shadow: var(--focus); }
  details.rec-more > summary { cursor: pointer; color: var(--fg2); font-size: 13px; padding: 2px 0; }
  details.rec-more[open] { display: grid; gap: 8px; }
  /* Episode Maker: the steps on the left, one step at a time on the right, Back / Next at the bottom */
  .maker { max-width: 1180px; margin: 0 auto; padding: 24px 32px 0; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 32px; align-items: start; min-height: 100%; }
  .mk-nav { position: sticky; top: 24px; display: grid; gap: 16px; }
  .mk-title { display: grid; gap: 2px; } .mk-title small { color: var(--fg3); font-size: 12px; } .mk-title b { font-size: 15px; line-height: 1.3; }
  .mk-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  .mk-step { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r); border: 0; background: none; color: var(--fg2); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
  .mk-step:hover { background: var(--hover); color: var(--fg); } .mk-step:focus-visible { box-shadow: var(--focus); outline: none; }
  .mk-step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--sunken); color: var(--fg2); flex: none; }
  .mk-step .n .i { width: 13px; height: 13px; }
  .mk-step.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; } .mk-step.on .n { background: var(--accent); color: var(--on-accent); }
  .mk-step.done .n { background: var(--accent-soft); color: var(--accent); }
  .mk-step[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
  .mk-navfoot { display: grid; gap: 8px; justify-items: start; }
  .mk-body { display: grid; gap: 16px; min-width: 0; padding-bottom: 24px; }
  #mkStep { display: grid; gap: 16px; align-content: start; }
  .mk-head h2 { font-size: 22px; } .mk-head p { margin: 4px 0 0; color: var(--fg3); }
  .mk-foot { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 0 16px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
  .mk-foot .grow { flex: 1; }
  .mk-bar { flex-wrap: wrap; gap: 8px; align-items: center; }
  .mk-ideas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .mk-idea { display: grid; gap: 6px; align-content: start; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
  .mk-idea:hover { border-color: var(--accent); } .mk-idea:focus-visible { box-shadow: var(--focus); outline: none; }
  .mk-idea span { font-size: 13px; color: var(--fg2); } .mk-idea small { color: var(--fg3); font-size: 12px; }
  .mk-cards { display: grid; gap: 10px; counter-reset: card; }
  .mk-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; display: grid; gap: 10px; }
  .mk-card-head { display: flex; align-items: center; gap: 10px; } .mk-card-head input { flex: 1; font-weight: 600; }
  .mk-card .n { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }
  .mk-card .tools { display: flex; gap: 2px; }
  .mk-card textarea { resize: vertical; min-height: 52px; }
  .mk-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .mk-card-foot .grow { flex: 1; }
  .mk-final { padding: 6px 0; font-weight: 600; }
  .mk-whos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
  .mk-who { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: inherit; font: inherit; cursor: pointer; text-align: left; }
  .mk-who span:not(.avatar) { display: grid; flex: 1; } .mk-who small { color: var(--fg3); font-size: 12px; }
  .mk-who.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
  .mk-who:focus-visible { box-shadow: var(--focus); outline: none; } .mk-who .i { color: var(--accent); }
  .mk-theme { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .mk-theme input { width: 220px; flex: none; }
  .mk-who .avatar { width: 48px; height: 48px; border-radius: 12px; font-size: 18px; }
  .mk-things { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
  .mk-thing { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: 99px; background: var(--accent-soft); color: var(--fg); font-size: 13px; }
  .mk-thing button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 99px; background: transparent; color: var(--fg3); cursor: pointer; }
  .mk-thing button:hover { background: var(--sunken); color: var(--fg); } .mk-thing .i { width: 12px; height: 12px; }
  .mk-thing-add { width: auto; max-width: 220px; height: 28px; font-size: 13px; }
  .mk-arrive { flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; } .mk-needs { margin-top: 8px; flex-wrap: wrap; }
  .mk-onstage { color: var(--fg2); }
  .mk-line > .mk-flags { grid-column: 3 / -1; display: flex; flex-wrap: wrap; gap: 6px; } .mk-flags .mk-thing { height: 24px; font-size: 12.5px; }
  .mk-grip { display: grid; place-items: center; width: 22px; height: 32px; margin-left: -4px; color: var(--fg3); cursor: grab; border-radius: 6px; touch-action: none; }
  .mk-grip:hover { color: var(--fg); background: var(--sunken); } .mk-grip:active { cursor: grabbing; }
  .mk-line.dragging { opacity: .45; }
  .mk-line.drop-before { box-shadow: 0 -2px 0 var(--accent); } .mk-line.drop-after { box-shadow: 0 2px 0 var(--accent); }
  .mk-lines.drop-end { box-shadow: 0 2px 0 var(--accent); min-height: 12px; }
  .mk-scene { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; display: grid; gap: 8px; }
  .mk-scene > header { display: flex; align-items: baseline; gap: 10px; } .mk-cardtext { margin: 0; }
  .mk-lines { display: grid; gap: 6px; }
  .mk-line { display: grid; grid-template-columns: 22px 112px minmax(0, 1fr) 108px 108px auto; gap: 6px; align-items: center; }
  .mk-line select, .mk-line input { height: 32px; font-size: 13px; }
  .mk-line.narr .words { font-style: italic; grid-column: 3 / 6; }
  .mk-place { flex-wrap: wrap; gap: 8px; } .mk-place select { width: 200px; flex: none; }
  .mk-line .tools { display: flex; align-items: center; gap: 2px; } .mk-line .rw { width: 98px; }
  .mk-line > .mk-rw, .mk-line > .mk-note { grid-column: 3 / -1; }
  .mk-rw { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .mk-note { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--warn); } .mk-note.err { color: var(--danger); }
  .mk-note .i { width: 14px; height: 14px; flex: none; margin-top: 2px; }
  .mk-notes { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; color: var(--fg2); }
  .mk-sheet { width: 100%; border-radius: var(--r); border: 1px solid var(--line); display: block; }
  .mk-video { width: 100%; max-height: 360px; border-radius: var(--r); background: #000; }
  .mk-report ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; } .mk-report li { display: flex; gap: 8px; align-items: baseline; }
  .ep-make .hint { font-size: 12.5px; } .mk-lib-drafts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
  @media (max-width: 900px) {
    .maker { grid-template-columns: 1fr; padding: 16px 16px 0; gap: 16px; }
    .mk-nav { position: static; } .mk-steps { display: flex; overflow-x: auto; } .mk-step { white-space: nowrap; }
    .mk-ideas { grid-template-columns: 1fr; }
    .mk-line { grid-template-columns: 1fr 1fr; } .mk-grip { display: none; } .mk-line > .mk-rw, .mk-line > .mk-note { grid-column: 1 / -1; } .mk-line .words { grid-column: 1 / -1; order: -1; } .mk-line .tools { grid-column: 1 / -1; }
  }
  .empty { padding: 36px 24px; text-align: center; color: var(--fg3); display: grid; gap: 12px; justify-items: center; }
  .empty h3 { color: var(--fg); font-size: 15px; }
  .frame { width: 100%; border-radius: var(--r-lg); display: block; border: 1px solid var(--line); }

  /* live stage + timeline */
  .stagebox { display: grid; gap: 0; }
  #stageSvg { display: block; width: 100%; height: auto; max-height: 40vh; background: #111; touch-action: none; border-radius: var(--r-lg); }
  #stageSvg [data-who], #stageSvg [data-prop] { cursor: grab; }
  #stageSvg #grade, #stageSvg #overlay, #stageSvg #stageGuides { pointer-events: none; }   /* lighting, captions, transitions and guides sit on top; let clicks through */
  .stagebox.dragging #stageSvg, .stagebox.dragging #stageSvg * { cursor: grabbing !important; }
  .tlbar { display: flex; align-items: center; gap: 6px; padding: 10px 12px 4px; flex-wrap: wrap; }
  .tlbar .btn.on { background: var(--accent-soft, rgba(56, 189, 248, 0.16)); color: var(--accent); border-color: var(--accent); }
  .tltime { font-size: 12.5px; color: var(--fg2); font-variant-numeric: tabular-nums; min-width: 86px; }
  .tlhint { font-size: 12.5px; color: var(--fg3); margin-left: auto; text-align: right; }
  .depth-ctl { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg3); }
  .depth-ctl input { width: 68px; }
  .track { position: relative; margin: 6px 12px 12px; border-radius: var(--r); background: var(--sunken); cursor: pointer; user-select: none; max-height: 96px; overflow-y: auto; }
  .tb { position: absolute; height: 20px; border-radius: 5px; padding: 0 6px; font-size: 11.5px; line-height: 20px; white-space: nowrap; overflow: hidden;
        text-overflow: ellipsis; color: var(--fg); background: var(--line2); border: 0; cursor: pointer; text-align: left; }
  .tb:hover { filter: brightness(1.08); }
  .tb.k-line, .tb.k-narration { background: var(--k-line); color: var(--k-line-fg); }
  .tb.k-move { background: var(--k-move); color: var(--k-move-fg); }
  .tb.k-action, .tb.k-reaction, .tb.k-pose, .tb.k-hold, .tb.k-shake { background: var(--k-act); color: var(--k-act-fg); }
  .tb.k-camera { background: var(--k-cam); color: var(--k-cam-fg); } .tb.k-sound { background: var(--k-snd); color: var(--k-snd-fg); }
  .tb.k-prop, .tb.k-pause, .tb.k-group, .tb.k-other { background: var(--k-misc); color: var(--k-misc-fg); }
  .tb.on { box-shadow: 0 0 0 2px var(--fg); }
  .tb.err { box-shadow: inset 0 0 0 2px var(--danger); }
  .cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); pointer-events: none; }
  .cursor::before { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

  /* job drawer */
  .drawer { border-top: 1px solid var(--line); background: var(--surface); }
  .drawer .bar { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px 0 16px; }
  .drawer .bar b { font-weight: 600; white-space: nowrap; }
  .drawer .state { color: var(--fg3); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .progress { flex: 1; height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; min-width: 60px; }
  .progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
  .progress.busy i { width: 28%; animation: slide 1.3s ease-in-out infinite; }
  .progress.fail i { background: var(--danger); }
  @keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(380%); } }
  .log { margin: 0; max-height: 200px; overflow: auto; padding: 0 16px 12px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; color: var(--fg2); }
  .log .x { color: var(--danger); } .log .w { color: var(--warn); } .log .k { color: var(--ok); }
  .drawer.closed .log { display: none; }
  .toast { position: fixed; left: 50%; bottom: 64px; transform: translate(-50%, 8px); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: var(--r);
           font-weight: 500; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; z-index: 10; max-width: 90vw; }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  /* ---------- the workspace: outline | script | preview + inspector (the preview never scrolls away) ---------- */
  .body.ws { grid-template-columns: 220px minmax(340px, 1fr) 6px var(--stageW, 44%); }
  .split { cursor: col-resize; position: relative; background: transparent; touch-action: none; }
  .split::after { content: ""; position: absolute; inset: 0 2px; background: var(--line); transition: background .15s; }
  .split:hover::after, .split.drag::after, .split:focus-visible::after { background: var(--accent); }
  .split:focus-visible { box-shadow: none; }
  .stagecol { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
  .stagecol .stagebox { padding: 12px 12px 0; }
  .stagecol .tlbar { padding: 8px 0 2px; }
  .stagecol .track { margin: 4px 0 12px; }
  .inspector { overflow: auto; padding: 16px 16px 56px; border-top: 1px solid var(--line); display: grid; gap: 14px; align-content: start; min-height: 0; }
  .insp-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .insp-head h3 { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .insp-tools { margin-left: auto; display: flex; gap: 2px; flex: none; }
  .inspector .fields, .inline-insp .fields { display: grid; gap: 10px 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-items: end; }
  .inspector .grid, .inline-insp .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .inspector .section > h3, .inline-insp .section > h3 { font-size: 13px; }
  .inspector .panel.pad, .inline-insp .panel.pad { padding: 12px; }
  .inspector .stage .trow, .inline-insp .stage .trow { grid-template-columns: 1fr 1fr; }
  .inspector .props .trow, .inline-insp .props .trow { grid-template-columns: 1fr 1fr; }
  .inspector .trow.head, .inline-insp .trow.head { display: none; }
  .inspector .stage .trow > .who, .inspector .stage .trow > .pos, .inline-insp .stage .trow > .who, .inline-insp .stage .trow > .pos { grid-column: 1 / -1; }
  .inspector .timing, .inline-insp .timing { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--fg3); }
  .inspector .timing input[type=number], .inline-insp .timing input[type=number] { width: 68px; height: 28px; }
  .lineText { font-size: 16px; min-height: 44px; }
  .label { font-size: 12px; font-weight: 600; color: var(--fg3); text-transform: uppercase; letter-spacing: .05em; }
  .inline-insp { margin: 2px 0 10px 64px; padding: 14px; border: 1px solid var(--line2); border-radius: var(--r-lg); background: var(--surface); display: grid; gap: 14px; }
  .takes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .takes .which { font-size: 13px; color: var(--fg2); font-variant-numeric: tabular-nums; min-width: 70px; text-align: center; }

  /* the script: the scene as a readable screenplay */
  .script { max-width: 820px; margin: 0 auto; padding: 22px 28px 160px; display: grid; gap: 14px; }
  .scene-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .scene-head h2 { font-size: 20px; margin-right: 6px; }
  .scene-head .tools { margin-left: auto; display: flex; gap: 2px; }
  .scene-head .chip { height: 26px; font-size: 12.5px; }
  .rows { display: grid; gap: 2px; }
  .srow { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 9px 10px; border-radius: var(--r-lg);
          border: 1px solid transparent; cursor: pointer; position: relative; outline: none; }
  .srow:hover { background: var(--hover); }
  .srow:focus-visible { box-shadow: var(--focus); }
  .srow.on { background: var(--surface); border-color: var(--line2); box-shadow: var(--shadow); }
  .srow.err { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
  .srow.flash { box-shadow: 0 0 0 2px var(--accent); }
  .srow .tm { font: 12px/22px var(--mono); color: var(--fg3); white-space: nowrap; }
  .srow .sp { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; min-width: 0; }
  .srow .sp .how { font-weight: 450; letter-spacing: 0; text-transform: none; color: var(--fg3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .srow .words { font-size: 16px; line-height: 1.45; margin-top: 1px; overflow-wrap: anywhere; }
  .srow .words.empty { color: var(--fg3); font-style: italic; }
  .srow .act { font-size: 13.5px; color: var(--fg2); line-height: 22px; overflow-wrap: anywhere; }
  .srow .rtools { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
  .srow:hover .rtools, .srow.on .rtools, .srow:focus-within .rtools { opacity: 1; }
  .srow .msg { grid-column: 2 / -1; color: var(--danger); font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
  .srow.nested { margin-left: 40px; }
  /* reordering: a grip shows on hover; a beat that runs with the one above sits indented under it */
  .srow .tm { position: relative; }
  .srow .drag-grip { position: absolute; left: -20px; top: 1px; width: 16px; height: 20px; display: grid; place-items: center; color: var(--fg3); opacity: 0; cursor: grab; touch-action: none; transition: opacity .12s; }
  .srow .drag-grip .i { width: 14px; height: 14px; fill: currentColor; stroke: none; }
  .srow:hover .drag-grip, .srow.on .drag-grip, .srow:focus-visible .drag-grip { opacity: .8; }
  .srow.linked { margin-left: 32px; }
  .srow.linked::before { content: ''; position: absolute; left: -18px; top: -6px; width: 12px; height: 22px; border-left: 2px solid var(--line2); border-bottom: 2px solid var(--line2); border-bottom-left-radius: 8px; }
  .srow.nested.linked { margin-left: 72px; }
  .srow .with-tag { color: var(--fg3); }
  .srow.dragging, #rail .nav.dragging { opacity: .45; }
  body.reordering, body.reordering * { cursor: grabbing !important; user-select: none; }
  .drop-marker { position: fixed; z-index: 80; height: 0; border-top: 3px solid var(--accent); border-radius: 2px; pointer-events: none; }
  .drop-marker::before { content: ''; position: absolute; left: -5px; top: -6.5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
  .drop-marker span { position: absolute; right: 0; top: -22px; font: 600 11.5px/18px var(--font); color: var(--on-accent); background: var(--accent); padding: 0 8px; border-radius: 9px; white-space: nowrap; }
  .drop-marker span:empty { display: none; }
  .drop-marker.linked { border-top-style: dashed; }
  .tlbar .scene-step { white-space: nowrap; }
  .tlbar .scene-step-slot:empty { display: none; }
  .ktag { display: inline-flex; height: 20px; align-items: center; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 650; margin-right: 8px; vertical-align: 1px; white-space: nowrap; }
  .ktag.k-line { background: var(--k-line); color: var(--k-line-fg); } .ktag.k-move { background: var(--k-move); color: var(--k-move-fg); }
  .ktag.k-act { background: var(--k-act); color: var(--k-act-fg); } .ktag.k-cam { background: var(--k-cam); color: var(--k-cam-fg); }
  .ktag.k-snd { background: var(--k-snd); color: var(--k-snd-fg); } .ktag.k-misc { background: var(--k-misc); color: var(--k-misc-fg); }
  .ins { height: 0; position: relative; z-index: 2; }
  .ins > button { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); opacity: 0; transition: opacity .15s; height: 24px; border-radius: 99px; border-style: dashed; color: var(--fg3); font-size: 12px; }
  .ins:hover > button, .ins > button:focus-visible { opacity: 1; }
  .ins::before { content: ""; position: absolute; left: 0; right: 0; top: -7px; height: 14px; }
  .addmenu { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border: 1px dashed var(--line2); border-radius: var(--r-lg); align-items: center; background: var(--surface); }
  .addmenu > span { font-size: 12.5px; color: var(--fg3); margin-right: 4px; }
  .addmenu .btn svg { color: var(--fg3); }

  /* top bar: workspace views and the theme switch */
  .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
  .views { margin: 0 auto; flex: none; }
  .views button { display: inline-flex; align-items: center; gap: 6px; }
  .theme-seg button { width: 32px; padding: 0; display: grid; place-items: center; }

  /* cast & voices */
  .vl-cast { display: flex; gap: 8px; flex-wrap: wrap; }
  .vl-who { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); min-width: 170px; }
  .vl-who:hover { border-color: var(--fg3); } .vl-who:focus-visible { box-shadow: var(--focus); }
  .vl-who.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .avatar.thumb { background: var(--sunken); overflow: hidden; } .avatar.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  /* Ask AI (Character Lab): one input with its button inside, the connection underneath, a compact result card */
  .ai-ask { display: grid; gap: 6px; }
  .ai-ask > label { font-size: 12.5px; color: var(--fg3); font-weight: 500; }
  .ai-input { display: flex; align-items: center; gap: 4px; padding: 3px 3px 3px 10px; border: 1px solid var(--line2); border-radius: var(--r-lg);
    background: var(--bg); transition: border-color .15s, box-shadow .15s; }
  .ai-input:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
  .ai-input input { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; outline: none; height: 30px; padding: 0; font: inherit; color: var(--fg); }
  .ai-input .btn { flex: none; }
  .ai-input input[readonly] { color: var(--fg3); }
  .ai-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--fg3); min-height: 24px; }
  .ai-meta select { height: 24px; padding: 0 22px 0 6px; font-size: 12px; border-radius: 6px; max-width: 240px; }
  .ai-meta .btn.xs { font-size: 12px; }
  .ai-busy { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--sunken); font-size: 13px; color: var(--fg2); }
  .ai-busy .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sai { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); z-index: 40; background: var(--surface); border-left: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(0,0,0,.08); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  body.sai-open .app { padding-right: min(400px, 100vw); }
  body.sai-open .topbar .hide-sm, body.sai-open .topbar .views .lbl, body.sai-open .topbar .hide-md, body.sai-open .topbar #saveStatus .i { display: none; }
  body.sai-open .topbar { gap: 6px; } body.sai-open .topbar .eptitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } @media (max-width: 900px) { body.sai-open .app { padding-right: 0; } }
  .sai-head { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); box-sizing: border-box; }
  .sai-draft { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--fg2); border-top: 1px solid var(--line); padding-top: 6px; } .sai-draft .i { color: var(--warn); margin-top: 1px; }
  .sai-log { overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
  .sai-empty p { margin: 0 0 12px; color: var(--fg2); font-size: 13.5px; line-height: 1.5; } .sai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .sai-msg { padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; max-width: 92%; display: grid; gap: 6px; }
  .sai-msg.me { align-self: flex-end; background: var(--accent-soft); color: var(--fg); white-space: pre-wrap; }
  .sai-msg.ai { align-self: flex-start; background: var(--sunken); color: var(--fg); }
  .sai-msg.ai:has(.ai-spin) { display: flex; align-items: center; gap: 8px; color: var(--fg2); }
  .sai-msg.err { display: flex; gap: 8px; color: var(--danger); } .sai-msg .i { width: 15px; height: 15px; flex: none; }
  .sai-changes { margin: 0; padding-left: 16px; display: grid; gap: 3px; font-size: 12.5px; color: var(--fg2); } .sai-changes b { color: var(--fg); font-weight: 600; }
  .sai-changes .muted { color: var(--fg3); }
  .sai-foot { display: flex; align-items: center; gap: 8px; }
  .sai-ask { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: grid; gap: 8px; }
  .sai-ask textarea { width: 100%; resize: vertical; min-height: 64px; font: inherit; font-size: 13.5px; }
  .sai-scope { font-size: 12.5px; }
  /* the Moodaboo loader: the logo's eyes look around and blink (web/brand/moodaboo-loader.svg animates itself) */
  .ai-spin { width: 26px; height: 14px; flex: none; display: inline-block; vertical-align: middle;
             background: url(/web/brand/moodaboo-loader.svg) center / contain no-repeat; }
  :root[data-theme="dark"] .ai-spin { background-image: url(/web/brand/moodaboo-loader-dark.svg); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-spin { background-image: url(/web/brand/moodaboo-loader-dark.svg); } }
  .mb-loading { display: inline-flex; align-items: center; gap: 10px; }
  .mb-loading::before { content: ""; width: 30px; height: 16px; flex: none; background: url(/web/brand/moodaboo-loader.svg) center / contain no-repeat; }
  .mb-loading.big { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 180px; color: var(--fg2); }
  .mb-loading.big::before { width: 96px; height: 52px; }
  :root[data-theme="dark"] .mb-loading::before { background-image: url(/web/brand/moodaboo-loader-dark.svg); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mb-loading::before { background-image: url(/web/brand/moodaboo-loader-dark.svg); } }
  @keyframes ai-spin { to { transform: rotate(360deg); } }
  .ai-card { margin-top: 2px; padding: 12px 14px; display: grid; gap: 8px; animation: fadein .15s ease-out; }
  .ai-card:focus, .alert:focus { outline: none; box-shadow: var(--focus); }
  .ai-head { display: flex; align-items: baseline; gap: 10px; }
  .ai-head b { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; font-weight: 600; }
  .ai-head .hint { flex: none; font-size: 12px; white-space: nowrap; }
  .ai-changes { margin: 0; padding-left: 18px; display: grid; gap: 4px; overflow-wrap: anywhere; font-size: 13px; }
  .ai-note { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r); background: var(--sunken); font-size: 12.5px; line-height: 1.5; color: var(--fg2); }
  .ai-note svg { margin-top: 2px; color: var(--fg3); }
  .ai-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 2px; }
  .ai-foot .hint { flex: 1; min-width: 140px; font-size: 12px; }
  .ai-foot .btn svg { width: 14px; height: 14px; }
  .ai-key .field { min-width: 0; } #aiPanel progress { accent-color: var(--accent); }
  .vl-who b { font-weight: 600; } .vl-who small { display: block; color: var(--fg3); font-size: 12px; }
  .vl { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
  .tune { display: grid; gap: 6px; }
  .tune .top1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
  .tune b { font-size: 13px; font-weight: 600; } .tune output { font-size: 13px; color: var(--fg2); font-variant-numeric: tabular-nums; }
  .face-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; margin-top: 10px; }
  .face-grid input[type=range] { width: 100%; }
  .chip .n { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: var(--bg, #fff); font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; }
  #faceCompare[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
  .ticks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--fg3); }
  .sweep { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .sweep button { display: grid; gap: 2px; justify-items: center; padding: 10px 6px; border-radius: var(--r-lg); border: 1px solid var(--line2); background: var(--surface); cursor: pointer; }
  .sweep button:hover { border-color: var(--fg3); }
  .sweep button.on { border-color: var(--accent); background: var(--accent-soft); }
  .sweep b { font-size: 16px; } .sweep small { font-size: 12px; color: var(--fg3); }
  .aud { display: grid; gap: 4px; } .aud small { color: var(--fg3); font-size: 12px; }

  /* sound mix */
  .faders { display: flex; gap: 12px; flex-wrap: wrap; }
  .fader { width: 132px; display: grid; justify-items: center; gap: 8px; padding: 14px 10px; }
  .fader input[type=range] { writing-mode: vertical-lr; direction: rtl; height: 150px; width: 28px; }
  .fader b { font-size: 13px; text-align: center; } .fader output { font-size: 12.5px; color: var(--fg3); font-variant-numeric: tabular-nums; }
  .mixrow { display: grid; grid-template-columns: 150px minmax(130px, 200px) minmax(160px, 1fr); gap: 16px; align-items: center; }

  /* ---------- home: the channel's episodes ---------- */
  .home { max-width: 1240px; margin: 0 auto; padding: 24px 32px 96px; display: grid; gap: 20px; }
  .channel-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
  .channel-tabs button { border: 0; background: none; cursor: pointer; padding: 8px 14px 10px; color: var(--fg2); font-weight: 600; display: grid; justify-items: start;
                         border-bottom: 2px solid transparent; margin-bottom: -1px; text-align: left; }
  .channel-tabs button small { font-weight: 400; color: var(--fg3); font-size: 12px; }
  .channel-tabs button:hover { color: var(--fg); }
  .channel-tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
  .home-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
  .home-head h1 { font-size: 26px; letter-spacing: -0.02em; }
  .home-head .sub { margin: 4px 0 0; color: var(--fg2); }
  .home-head .stats { margin: 6px 0 0; color: var(--fg3); font-size: 13px; }
  .home-acts { margin-left: auto; display: grid; justify-items: end; gap: 4px; }
  .home-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  .search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; max-width: 420px; height: 36px; padding: 0 10px; border: 1px solid var(--line2);
            border-radius: 8px; background: var(--sunken, var(--surface)); color: var(--fg3); transition: border-color .15s, box-shadow .15s, background .15s; }
  .search:hover { border-color: var(--fg3); }
  .search:focus-within { border-color: var(--accent); box-shadow: var(--focus); background: var(--surface); }
  .search input { appearance: none; border: 0; height: 32px; padding: 0; background: transparent; box-shadow: none; outline: none; flex: 1; min-width: 0; width: auto; color: var(--fg); }
  .search input:focus, .search input:focus-visible { outline: none; box-shadow: none; border: 0; background: transparent; }
  .search .clear { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 99px; background: transparent; color: var(--fg3); cursor: pointer; flex: none; }
  .search .clear:hover { background: var(--sunken); color: var(--fg); } .search .clear .i { width: 13px; height: 13px; }
  .lib-count { font-size: 12.5px; color: var(--fg3); white-space: nowrap; }
  .home-tools .seg { margin-left: auto; }
  .home-tools .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
  .ep-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .ep-card { position: relative; display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
             overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
  .ep-card:hover { border-color: var(--line2); box-shadow: var(--shadow); }
  .ep-card:has(.ep-open:hover) { transform: translateY(-1px); }
  .ep-open { all: unset; cursor: pointer; display: grid; grid-template-rows: auto 1fr; min-width: 0; }
  .ep-open:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
  .ep-poster { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--sunken); }
  .ep-poster.tall { aspect-ratio: 16 / 9; }
  .ep-poster > svg, .ep-poster > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  .ep-poster > svg { animation: fadein .3s ease; }
  @keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
  .ep-len { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / 62%); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
  .ep-body { display: grid; gap: 4px; padding: 12px 14px 6px; min-width: 0; }
  .ep-body b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ep-body small { color: var(--fg3); font-size: 12.5px; }
  .ep-foot { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px 14px; min-width: 0; }
  .ep-foot .tags { min-width: 0; flex-wrap: wrap; gap: 4px; }
  .ep-foot .tag { height: 20px; font-size: 11.5px; white-space: nowrap; }
  .tag.warn { background: var(--warn-soft); color: var(--warn); }
  .ep-cast { display: flex; margin-left: auto; padding-left: 6px; }
  .ep-cast i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; color: var(--fg2);
               background: var(--sunken); border: 2px solid var(--surface); margin-left: -6px; }
  .ep-foot .acts { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
  .ep-card:hover .acts, .ep-card:focus-within .acts { opacity: 1; }
  .ep-new { border-style: dashed; background: transparent; }
  .ep-add { grid-template-rows: auto 1fr; transition: border-color .15s, background .15s; }
  .ep-add:hover { border-color: var(--accent); background: var(--accent-soft); }
  .ep-add-open { display: grid; grid-template-rows: auto auto; border: 0; background: none; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; border-radius: inherit; }
  .ep-add-open:focus-visible { box-shadow: var(--focus); }
  .ep-add-plus { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; transition: transform .15s; }
  .ep-add:hover .ep-add-plus { transform: scale(1.06); } .ep-add-plus svg { width: 26px !important; height: 26px !important; }
  .ep-add-drafts { padding: 0 14px 12px; } .ep-add-drafts:empty { display: none; }
  .new-ep-dialog { width: min(760px, 94vw); border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--surface); color: var(--fg); box-shadow: 0 24px 64px rgba(0,0,0,.25); }
  .new-ep-dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
  .ne-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 4px; }
  .ne-head h2 { margin: 0; font-size: 20px; } .ne-head p { margin: 4px 0 0; color: var(--fg2); font-size: 13.5px; }
  .ne-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 24px 20px; }
  .ne-choice { position: relative; display: grid; align-content: start; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); transition: border-color .15s, box-shadow .15s; }
  .ne-choice:hover, .ne-choice:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .ne-choice.ai { background: linear-gradient(160deg, var(--accent-soft), var(--bg) 60%); }
  .ne-choice h3 { margin: 4px 0 0; font-size: 16px; } .ne-choice p { margin: 0; color: var(--fg2); font-size: 13px; line-height: 1.5; }
  .ne-choice .btn { justify-self: start; margin-top: 4px; } .ne-choice textarea { resize: vertical; }
  .ne-art { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--sunken); color: var(--fg); }
  .ne-art.ne-mk { background: var(--accent); color: #fff; } .ne-art svg { width: 22px; height: 22px; }
  .ne-badge { position: absolute; top: 14px; right: 14px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--accent); }
  .ne-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; counter-reset: ne; }
  .ne-steps li { counter-increment: ne; font-size: 11.5px; padding: 2px 8px 2px 4px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--fg2); }
  .ne-steps li::before { content: counter(ne); display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 4px; border-radius: 99px; background: var(--sunken); font-size: 10px; font-weight: 700; }
  .ne-drafts { display: grid; gap: 6px; padding: 14px 24px 22px; border-top: 1px solid var(--line); }
  .ne-draft { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: inherit; font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
  .ne-draft:hover { border-color: var(--accent); }
  @media (max-width: 680px) { .ne-choices { grid-template-columns: 1fr; } }
  .search input::-webkit-search-cancel-button { display: none; }
  .ep-new .ep-poster.new { display: grid; place-items: center; background: var(--sunken); color: var(--accent); }
  .ep-new .ep-poster.new svg { width: 34px; height: 34px; position: static; }
  .ep-new .ep-body { padding-bottom: 14px; gap: 8px; } .ep-new .ep-body .btn { justify-self: start; }
  .ep-grid.list { grid-template-columns: 1fr; gap: 8px; }
  .ep-grid.list .ep-card { grid-template-columns: 160px minmax(0, 1fr) auto; grid-template-rows: auto; align-items: center; }
  .ep-grid.list .ep-open { grid-column: 1 / 3; grid-template-columns: 160px minmax(0, 1fr); grid-template-rows: auto; align-items: center; }
  .ep-grid.list .ep-foot { grid-column: 3; padding: 0 12px; }
  .ep-grid.list .ep-new { grid-template-columns: 160px minmax(0, 1fr); }
  .ep-grid.list .ep-new .ep-body { grid-template-columns: auto minmax(0, 320px) auto; align-items: center; padding: 10px 14px; }
  .ep-grid.list .ep-add { grid-template-columns: 1fr; } .ep-grid.list .ep-add .ep-add-open { grid-template-columns: 160px minmax(0, 1fr); grid-template-rows: auto; align-items: center; }
  .ep-grid.list .ep-add .ep-body { display: grid; gap: 2px; padding: 10px 14px; } .ep-grid.list .ep-add-plus { width: 40px; height: 40px; border-radius: 12px; }
  @media (max-width: 700px) { .home { padding: 16px 16px 80px; } .ep-grid.list .ep-card { grid-template-columns: 1fr; } .ep-grid.list .ep-open { grid-column: 1; grid-template-columns: 120px 1fr; } .ep-grid.list .ep-foot { grid-column: 1; padding: 0 12px 10px; } }

  @media (max-width: 1100px) {
    .body.ws { grid-template-columns: 196px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
    .body.ws .rail { grid-row: 1 / -1; }
    .body.ws .split { display: none; }
    .body.ws .stagecol { grid-column: 2; grid-row: 1; border-left: 0; border-bottom: 1px solid var(--line); grid-template-rows: auto; }
    .body.ws .main { grid-column: 2; grid-row: 2; }
    .body.ws #stageSvg { max-height: 30vh; }
    .body.ws .inspector { display: none; }
    .stagecol.mini #stageSvg, .stagecol.mini .track { display: none; }
    .script { padding: 18px 16px 120px; }
    .views .lbl, .hide-md { display: none; }
  }
  @media (min-width: 1101px) { .narrow-only { display: none !important; } }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
  @media (max-width: 900px) {
    .body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); } .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 200px; }
    .page { padding: 20px 16px 96px; } .stage .trow, .props .trow { grid-template-columns: 1fr 1fr; } .stage .trow.head, .props .trow.head { display: none; }
    .lib-row { grid-template-columns: 1fr auto; } .lib-row .len, .lib-row .tags { display: none; }
    .q-row { grid-template-columns: 22px minmax(0, 1fr) minmax(76px, 165px); } .q-row .progress, .q-row .state { display: none; } .hide-sm { display: none !important; }
    .body.ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
    .body.ws .rail { grid-row: 1; grid-column: 1; max-height: 120px; }
    .body.ws .stagecol { grid-row: 2; grid-column: 1; }
    .body.ws .main { grid-row: 3; grid-column: 1; }
    .inline-insp { margin-left: 0; } .srow { grid-template-columns: 44px minmax(0, 1fr) auto; } .srow.nested { margin-left: 16px; }
  }
  /* Props page (picture props) */
  .pp { max-width: 960px; margin: 0 auto; padding: 24px 32px 120px; display: grid; gap: 28px; }
  .pp-checker { background-color: var(--surface); background-image: linear-gradient(45deg, var(--sunken) 25%, transparent 25%, transparent 75%, var(--sunken) 75%), linear-gradient(45deg, var(--sunken) 25%, transparent 25%, transparent 75%, var(--sunken) 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
  .pp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
  .pp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; min-width: 0; }
  .pp-card .pic { height: 140px; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; border-bottom: 1px solid var(--line); min-width: 0; }
  .pp-card .pic img { max-width: 88%; max-height: 124px; width: auto; height: auto; object-fit: contain; min-width: 0; }
  .pp-card .pic .none { color: var(--fg3); font-size: 12.5px; }
  .pp-card .body { padding: 10px 12px 12px; display: grid; gap: 8px; }
  .pp-card code { font-size: 13px; overflow-wrap: anywhere; }
  .pp-names { display: flex; flex-wrap: wrap; gap: 6px; }
  .pp-add { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 16px; }
  .pp-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pp-prompt { font-size: 13px; }
  .pp-drop { border: 1.5px dashed var(--line2); border-radius: var(--r-lg); padding: 22px 16px; text-align: center; color: var(--fg2); cursor: pointer; background: var(--sunken); }
  .pp-drop:hover, .pp-drop.over, .pp-drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
  .pp-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pp-pair figure { margin: 0; display: grid; gap: 6px; }
  .pp-pair .pic { height: 220px; border: 1px solid var(--line); border-radius: var(--r); display: grid; place-items: center; overflow: hidden; }
  .pp-pair img { max-width: 100%; max-height: 210px; object-fit: contain; }
  .pp-pair figcaption { font-size: 12.5px; color: var(--fg3); }
  @media (max-width: 700px) { .pp { padding: 16px 16px 96px; } .pp-two, .pp-pair { grid-template-columns: 1fr; } }

/* Phase 3 panels: Brands, Asset Library, Custom Voices & Variants Matrix */
.p3-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 10px; }
.p3-form .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.p3-form .field input, .p3-form .field select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.p3-swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 14px; border: 1px solid rgba(0,0,0,.15); }
.p3-asset-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.p3-asset-row:last-child { border-bottom: 0; }

/* media layer: pictures and clips panel, media beat fields */
.assets-box > summary { cursor: pointer; font-weight: 650; display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.assets-drop { display: grid; gap: 8px; margin-top: 8px; } .assets-drop.over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.asset-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .asset-row b { overflow-wrap: anywhere; } .asset-row .grow { flex: 1 1 140px; overflow-wrap: anywhere; }
.media-block { display: grid; gap: 6px; grid-column: 1 / -1; }
.media-cells { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; } .media-cells .mini { display: grid; gap: 2px; width: 86px; } .media-cells .mini span { font-size: 11.5px; color: var(--fg3); }
.media-row { display: flex; gap: 8px; align-items: center; } .media-row input[type=text] { flex: 1 1 auto; min-width: 0; } .media-row input[type=number] { width: 90px; }
.ktag .i { width: 13px; height: 13px; margin-right: 4px; }

/* Phase 1.8: Publish & Schedule + Calendar */
.pub-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
.pub-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.p3-form .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); font: inherit; resize: vertical; }
.pub-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pub-sched-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.pub-sched-row input, .pub-sched-row select { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg); }
.pub-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); margin: 8px 0 12px; background: var(--sunken); }
.pub-thumb-empty { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r); border: 1px dashed var(--line2); display: grid; place-items: center; color: var(--fg3); margin: 8px 0 12px; background: var(--sunken); font-size: 13px; }
.pub-checks { display: grid; gap: 8px; }
.pub-check { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.pub-mini-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 12.5px; }
.pub-mini-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pub-tag { display: inline-flex; align-items: center; justify-content: center; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--sunken); color: var(--fg2); }
.pub-tag-youtube { background: #fee2e2; color: #b91c1c; }
.pub-tag-tiktok { background: #e0f2fe; color: #0369a1; }
.pub-tag-instagram { background: #fce7f3; color: #be185d; }
.pub-tag-facebook { background: #dbeafe; color: #1d4ed8; }
.pub-st { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: var(--sunken); color: var(--fg2); text-transform: capitalize; }
.pub-st-published, .pub-st-ok { background: #dcfce7; color: #15803d; }
.pub-st-missed, .pub-st-failed { background: var(--danger-soft); color: var(--danger); }
.pub-st-scheduled { background: var(--accent-soft); color: var(--accent); }
.pub-missed-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 4px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
.pub-missed-box { border-color: var(--warn); background: var(--warn-soft); margin-bottom: 14px; }
.pub-missed-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pub-cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; flex-wrap: wrap; }
.pub-cal-title { font-size: 15px; margin-left: 6px; }
.pub-cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; font-size: 12px; color: var(--fg3); font-weight: 600; padding: 4px 2px; }
.pub-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.pub-day { min-height: 98px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pub-cal-grid.week .pub-day { min-height: 220px; }
.pub-day.out { opacity: .48; background: var(--sunken); }
.pub-day.today { border-color: var(--accent); }
.pub-day.over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.pub-day-num { font-size: 12px; font-weight: 600; color: var(--fg2); }
.pub-day-items { display: grid; gap: 4px; }
.pub-chip { display: flex; align-items: center; gap: 4px; padding: 3px 5px; border-radius: 5px; font-size: 11.5px; background: var(--sunken); border: 1px solid var(--line); cursor: grab; overflow: hidden; }
.pub-chip-missed { border-color: var(--danger); background: var(--danger-soft); }
.pub-chip-published { opacity: .75; cursor: default; }
.pub-chip-t { color: var(--fg3); font-variant-numeric: tabular-nums; flex: none; }
.pub-chip-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-acc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.pub-acc-card { display: flex; flex-direction: column; gap: 6px; }
.pub-connected { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--sunken); border-radius: var(--r); }
.pub-uri { padding: 6px 8px; border-radius: 6px; background: var(--sunken); border: 1px solid var(--line); overflow-x: auto; font-size: 12px; }
.pub-setup-tip { margin: 10px 0; border-color: var(--accent); }
@media (max-width: 820px) { .pub-layout, .pub-two { grid-template-columns: 1fr; } .pub-day { min-height: 70px; } }
.pub-chip { cursor: pointer; }
.pub-chip.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.pub-selected-bar { margin: 10px 0; border-color: var(--accent); }
.pub-quick-sched { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pub-quick-sched select, .pub-quick-sched input { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg); font: inherit; }

/* Authentication & Users */
.auth-shell { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 32px 16px;
              background: linear-gradient(180deg, #cfe9f6 0%, #e9f6fb 45%, var(--bg) 100%); }
:root[data-theme="dark"] .auth-shell { background: var(--bg); }
.auth-split { width: min(920px, 100%); display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface);
              border: 2px solid #221c15; border-radius: 24px; box-shadow: 6px 6px 0 #221c15; overflow: hidden; }
.auth-art { position: relative; background: #cfe9f6; min-height: 100%; border-right: 2px solid #221c15; }
.auth-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-art-line { position: absolute; left: 20px; bottom: 20px; margin: 0; padding: 12px 16px; background: #fbf6ec; color: #221c15;
                 border: 2px solid #221c15; border-radius: 16px; box-shadow: 3px 3px 0 #221c15; font: 700 22px/1.15 var(--display, system-ui); }
.auth-art-line span { background: linear-gradient(transparent 58%, #f8bd3a 58%, #f8bd3a 92%, transparent 92%); }
.auth-card { display: grid; gap: 14px; padding: 32px 30px; align-content: center; }
.auth-head { display: flex; gap: 12px; align-items: flex-start; }
.auth-head .logo { width: 40px; height: 40px; border-radius: 11px; }
.auth-head .auth-logo, .auth-head svg.moodeyes { width: 48px; height: 48px; flex: none; display: block; }
.auth-head h1 { margin: 0 0 6px; font: 700 26px/1.15 var(--display, system-ui); }
.auth-head .sub { margin: 0; color: var(--fg2); font-size: 14px; }
.auth-card .btn.primary.auth-submit { height: 44px; border-radius: 999px; font: 600 16px/1 var(--display, system-ui); background: #f8bd3a; color: #221c15;
                                      border: 2px solid #221c15; box-shadow: 3px 3px 0 #221c15; }
.auth-card .btn.primary.auth-submit:hover { background: #ffc94f; }
.auth-card .btn.auth-submit:not(.primary) { height: 44px; border-radius: 999px; border: 2px solid #221c15; }
@media (max-width: 760px) { .auth-split { grid-template-columns: 1fr; } .auth-art { border-right: 0; border-bottom: 2px solid #221c15; aspect-ratio: 16 / 9; }
                            .auth-card { padding: 24px 20px; } }
.auth-form { display: grid; gap: 10px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }
.auth-foot { border-top: 1px solid var(--line); padding-top: 12px; margin: 4px 0 0; font-size: 13px; text-align: center; }
.auth-foot a { color: var(--fg2); }
.auth-user-chip { font-size: 12.5px; color: var(--fg2); padding: 0 6px; white-space: nowrap; }
.users-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
.auth-edit-row { margin: 8px 0; display: grid; gap: 10px; border-color: var(--accent); }
@media (max-width: 820px) { .users-grid { grid-template-columns: 1fr; } .auth-user-chip { display: none; } }



/* Global top progress bar for any in-flight Studio API call (>120ms) */
.api-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999; pointer-events: none; overflow: hidden; background: rgba(13, 148, 136, .15); }
.api-bar::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 40%; background: linear-gradient(90deg, var(--sun, #f8bd3a), var(--accent, #0d9488), var(--sun, #f8bd3a)); animation: apiBarSlide 1.1s ease-in-out infinite; }
@keyframes apiBarSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ------------------------------------------------------------------ Workspace Sidebar & Slim Topbar */
.app-sidebar { display: flex; flex-direction: column; min-height: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); z-index: 30; user-select: none; }
.sb-head { height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--line); }
.sb-brand { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; min-width: 0; border-radius: var(--r); padding: 4px 2px; }
.sb-brand:focus-visible { box-shadow: var(--focus); }
.sb-logo-mark { display: none; width: 26px; height: 26px; flex: none; }
.sb-close-mobile { display: none; }
.sb-menu-btn { display: none; }
.sb-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 14px; }
.sb-group { display: grid; gap: 2px; }
.sb-group-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--fg3); padding: 2px 10px 5px; }
.sb-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r); background: transparent; color: var(--fg2); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; white-space: nowrap; transition: background .14s, color .14s; }
.sb-item:hover { background: var(--hover); color: var(--fg); }
.sb-item.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.sb-item.on .i { color: var(--accent); }
.sb-item .i { width: 16px; height: 16px; flex: none; opacity: .88; }
.sb-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.sb-count { font-size: 12px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; margin-left: auto; }
.sb-badge { margin-left: auto; }
.sb-foot { flex: none; border-top: 1px solid var(--line); padding: 10px 8px 12px; display: grid; gap: 8px; }
.sb-theme { display: flex; justify-content: center; }
.sb-theme .theme-seg { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
.sb-theme .theme-seg button { width: auto; height: 28px; }
.sb-user { display: grid; gap: 6px; padding: 8px; border-radius: var(--r); background: var(--sunken); border: 1px solid var(--line); }
.sb-user-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sb-avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.sb-user-meta { min-width: 0; display: grid; line-height: 1.2; }
.sb-user-meta b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-meta small { font-size: 11px; color: var(--fg3); }
.sb-user-acts { display: flex; gap: 4px; }
.sb-user-acts .btn { flex: 1; justify-content: center; }

/* Icon-rail collapsed state */
.app.sb-rail .sb-head { padding: 0; flex-direction: column; justify-content: center; height: auto; padding: 8px 0; gap: 4px; }
.app.sb-rail .sb-logo-full { display: none !important; }
.app.sb-rail .sb-logo-mark { display: block; }
.app.sb-rail .sb-group-lbl,
.app.sb-rail .sb-lbl,
.app.sb-rail .sb-user-meta,
.app.sb-rail .sb-theme { display: none; }
.app.sb-rail .sb-nav { padding: 8px 6px; gap: 10px; }
.app.sb-rail .sb-item { justify-content: center; padding: 0; width: 44px; height: 36px; margin: 0 auto; position: relative; }
.app.sb-rail .sb-badge,
.app.sb-rail .sb-count { position: absolute; top: 2px; right: 2px; font-size: 10px; min-width: 14px; height: 14px; padding: 0 3px; }
.app.sb-rail .sb-foot { padding: 8px 6px; }
.app.sb-rail .sb-user { padding: 6px 4px; justify-items: center; }
.app.sb-rail .sb-user-acts { flex-direction: column; width: 100%; }
.app.sb-rail .sb-user-acts .btn { padding: 0; width: 100%; height: 26px; }

/* Slim Topbar helpers & overflow dropdown */
.tb-sep { color: var(--fg3); opacity: .55; }
.tb-channel { font-size: 12px; font-weight: 500; color: var(--fg3); padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--sunken); white-space: nowrap; }
.tb-actions { display: inline-flex; align-items: center; gap: 6px; flex: none; }

/* Full-bleed embedded 2.5D Diorama workspace */
.diorama-main { padding: 0; overflow: hidden; display: flex; background: #0c0d11; }
.diorama-frame { width: 100%; height: 100%; border: 0; display: block; background: #0c0d11; }

/* Responsive Mobile Drawer */
.sidebar-backdrop { position: fixed; inset: 0; z-index: 38; background: rgba(0, 0, 0, .42); backdrop-filter: blur(2px); }
@media (max-width: 960px) {
  .app, .app.sb-rail { grid-template-columns: 1fr; }
  .sb-menu-btn { display: inline-flex; }
  .app-sidebar { position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 42; transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 12px 36px rgb(0 0 0 / 28%); }
  .app.sb-mobile-open .app-sidebar { transform: translateX(0); }
  .app.sb-rail .sb-head { flex-direction: row; height: 52px; padding: 0 10px 0 14px; justify-content: space-between; }
  .app.sb-rail .sb-logo-full { display: block !important; }
  :root[data-theme="dark"] .app.sb-rail .sb-logo-full.on-light { display: none !important; }
  :root:not([data-theme="dark"]) .app.sb-rail .sb-logo-full.on-dark { display: none !important; }
  .app.sb-rail .sb-logo-mark { display: none; }
  .app.sb-rail .sb-group-lbl, .app.sb-rail .sb-lbl, .app.sb-rail .sb-user-meta, .app.sb-rail .sb-theme { display: revert; }
  .app.sb-rail .sb-item { width: 100%; justify-content: flex-start; padding: 0 10px; }
  .app.sb-rail .sb-badge, .app.sb-rail .sb-count { position: static; margin-left: auto; }
  .app.sb-rail .sb-user { padding: 8px; justify-items: stretch; }
  .app.sb-rail .sb-user-acts { flex-direction: row; }
  .sb-toggle { display: none; }
  .sb-close-mobile { display: inline-flex; }
}

/* ------------------------------------------------------------------ Character Lab Compact Bar & In-Pane Creator */
.char-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; flex: none; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.char-bar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.char-bar-title h2 { font-size: 18px; line-height: 1.2; }
.char-bar-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vl-who-add { border-style: dashed; border-color: var(--line2); background: transparent; }
.vl-who-add:hover { background: var(--surface); border-color: var(--accent); }
.vl-add-ic { background: var(--sunken); color: var(--fg2); border: 1px solid var(--line); }
.vl-who-add.on .vl-add-ic { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.creator-card { display: grid; gap: 14px; padding: 18px; }
.creator-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.creator-head h3 { font-size: 16px; margin-bottom: 2px; }
.creator-head p { margin: 0; }
.species-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.species-btn { display: grid; gap: 2px; padding: 10px 11px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--sunken); color: var(--fg); cursor: pointer; text-align: left; transition: border-color .14s, background .14s; }
.species-btn:hover { border-color: var(--fg3); background: var(--hover); }
.species-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.species-btn b { font-size: 13.5px; font-weight: 600; }
.species-btn small { font-size: 11.5px; color: var(--fg3); line-height: 1.25; }
.creator-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.photo-ref-box { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
.photo-ref-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-lg); border: 1px solid var(--line2); display: block; background: var(--sunken); }
.photo-ref-empty { width: 96px; height: 96px; border-radius: var(--r-lg); border: 1.5px dashed var(--line2); background: var(--sunken); color: var(--fg3); display: grid; place-content: center; align-content: center; gap: 4px; text-align: center; font-size: 11px; padding: 6px; }
.photo-ref-fields { display: grid; gap: 10px; min-width: 0; }
.photo-consent { white-space: normal; align-items: flex-start; line-height: 1.4; font-size: 13px; }
.photo-consent input { margin-top: 2px; }
@media (max-width: 560px) { .photo-ref-box { grid-template-columns: 1fr; } .photo-ref-thumb, .photo-ref-empty { width: 72px; height: 72px; } }

