/* Theme: every colour is a token. light-dark(LIGHT, DARK) picks by the inherited color-scheme: the OS by
   default, or <html data-theme="light|dark"> (set by the header toggle, before first paint, in index.html).
   The video stage sets color-scheme: dark, so it stays dark in both themes. */
:root {
  color-scheme: light dark;

  /* surfaces */
  --bg: light-dark(#f5f6f8, #0b0c0f);
  --panel: light-dark(#ffffff, #131419);
  --panel2: light-dark(#f8f9fb, #181a20);
  --raised: light-dark(#eef0f3, #20232b);
  --raised2: light-dark(#e4e7ec, #272a34);
  --field: light-dark(#ffffff, #0e0f13);
  --tile: light-dark(#ffffff, #0f1014);
  --active-bg: light-dark(#f1f4fd, #1a1d26);
  --card-bg: light-dark(#ffffff, #181a20);
  --viewer-bg: light-dark(#ffffff, #0e0f12);
  --stage-well: light-dark(#1b1c21, #0e0f12);
  --track-bg: light-dark(#e6e9ee, #1b1d24);
  --timeline-bg: light-dark(#eef0f3, #0e0f12);
  --timeline-drag: light-dark(#e9edf9, #10131b);
  --timeline-drop: light-dark(#e2e8fa, #11151f);
  --menu-bg: light-dark(#ffffff, #1a1c23);
  --toast-bg: light-dark(#ffffff, #20232b);
  --dialog-bg: light-dark(#ffffff, #181a20);
  --scrim: light-dark(rgba(22, 24, 29, 0.36), rgba(5, 6, 9, 0.62));

  /* lines */
  --line: light-dark(#e3e6eb, #23262e);
  --line2: light-dark(#d5d9e0, #2f333d);
  --line-hover: light-dark(#c9ced7, #353a46);
  --line3: light-dark(#bfc5cf, #3b404c);
  --line-strong: light-dark(#aeb5c1, #434957);
  --scroll-thumb: light-dark(#cdd1d8, #2a2d36);
  --scroll-thumb-hover: light-dark(#b3b9c3, #3a3e4a);
  --hover-wash: light-dark(rgba(0, 0, 0, 0.035), rgba(255, 255, 255, 0.03));
  --tick: light-dark(rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0.22));
  --swatch-edge: light-dark(rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.18));

  /* text */
  --text: light-dark(#16181d, #e4e6eb);
  --text2: light-dark(#353a44, #c4c8d0);
  --dialog-text: light-dark(#2b2f37, #cdd1d8);
  --dim: light-dark(#5b616e, #9ba1ad);
  --mute: light-dark(#757b87, #686e7a);

  /* accent */
  --accent: light-dark(#3a5bd9, #7c9cff);
  --accent-hover: light-dark(#2f4fc4, #93adff);
  --on-accent: light-dark(#ffffff, #0b0e18);
  --accent-busy: light-dark(#4a67d6, #5a74c8);
  --on-accent-busy: #ffffff;
  --export-fill: light-dark(rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.32));
  --accent-weak: light-dark(rgba(58, 91, 217, 0.16), rgba(124, 156, 255, 0.18));
  --accent-wash: light-dark(rgba(58, 91, 217, 0.1), rgba(124, 156, 255, 0.15));
  --accent-line: light-dark(rgba(58, 91, 217, 0.5), rgba(124, 156, 255, 0.55));
  --accent-line-strong: light-dark(rgba(58, 91, 217, 0.62), rgba(124, 156, 255, 0.7));
  --accent-line-soft: light-dark(rgba(58, 91, 217, 0.35), rgba(124, 156, 255, 0.35));
  --accent-glow: light-dark(rgba(58, 91, 217, 0.4), rgba(124, 156, 255, 0.6));

  /* In/Out marks, playhead, states */
  --in: light-dark(#a86a00, #ffc24b);
  --in-text: light-dark(#8a5600, #ffc24b);
  --in-weak: light-dark(rgba(214, 140, 0, 0.16), rgba(255, 194, 75, 0.2));
  --in-line: light-dark(rgba(168, 106, 0, 0.6), rgba(255, 194, 75, 0.6));
  --in-wash: light-dark(rgba(214, 140, 0, 0.13), rgba(255, 194, 75, 0.15));
  --head: light-dark(#d92d2d, #ff5c5c);
  --head-text: light-dark(#b42323, #ff8a8a);
  --head-ink: light-dark(#a51d1d, #ffd3d3);
  --head-wash: light-dark(rgba(217, 45, 45, 0.1), rgba(255, 92, 92, 0.18));
  --head-wash2: light-dark(rgba(217, 45, 45, 0.08), rgba(255, 92, 92, 0.16));
  --head-line: light-dark(rgba(217, 45, 45, 0.5), rgba(255, 92, 92, 0.6));
  --ok: light-dark(#178a57, #4ad295);
  --warn: light-dark(#b86e00, #f5a524);
  --warn-text: light-dark(#7a4a00, #f7b955);
  --warn-wash: light-dark(rgba(214, 138, 0, 0.12), rgba(245, 165, 36, 0.14));
  --warn-line: light-dark(rgba(184, 110, 0, 0.4), rgba(245, 165, 36, 0.35));
  --err: light-dark(#c92a2a, #ff6b6b);
  --del-hover: light-dark(#c92a2a, #e5484d);
  --seg-on-text: light-dark(#16181d, #ffffff);

  /* stars (pinned templates and shots) */
  --star: light-dark(#b07300, #ffc24b);
  --star-text: light-dark(#8a5600, #ffc24b);
  --star-wash: light-dark(rgba(214, 140, 0, 0.11), rgba(255, 194, 75, 0.13));
  --star-line: light-dark(rgba(176, 115, 0, 0.42), rgba(255, 194, 75, 0.42));
  --star-media: #ffc24b;   /* on the dark overlay over thumbnails, so one value for both themes */

  /* render flags and branded renders */
  --flag: light-dark(#c2410c, #ff8a4c);
  --flag-media: #ff8a4c;
  --branded: light-dark(#0f7b6c, #3fd0b4);
  --branded-media: #3fd0b4;
  --branded-wash: light-dark(rgba(15, 123, 108, 0.1), rgba(63, 208, 180, 0.13));

  /* the library's Templates | Shots switch */
  --switch-track: light-dark(#eef0f3, #0e0f13);
  --switch-on: light-dark(#ffffff, #272a34);
  --shadow-switch: light-dark(rgba(16, 24, 40, 0.12), rgba(0, 0, 0, 0.45));
  --veil: light-dark(rgba(255, 255, 255, 0.56), rgba(11, 12, 15, 0.56));   /* dims preview-only shots */
  --ov-bg-hover: rgba(0, 0, 0, 0.9);

  /* media: placeholders behind thumbnails, and labels drawn on top of them */
  --media-bg: light-dark(#dfe2e7, #000000);
  --media-edge: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.06));
  --stripe-a: light-dark(rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.75));
  --stripe-b: light-dark(rgba(0, 0, 0, 0.09), rgba(30, 30, 30, 0.75));
  --ov-bg: rgba(0, 0, 0, 0.72);
  --ov-bg-soft: rgba(0, 0, 0, 0.66);
  --ov-text: #ffffff;
  --stage-bg: #000000;
  --tip-bg: light-dark(#1d2026, #000000);
  --tip-text: #ffffff;
  --logo-bg: #20232b;
  --logo-screen: #e4e6eb;
  --logo-a: #7c9cff;
  --logo-b: #ffc24b;

  /* shadows */
  --shadow-menu: light-dark(rgba(16, 24, 40, 0.16), rgba(0, 0, 0, 0.55));
  --shadow-toast: light-dark(rgba(16, 24, 40, 0.16), rgba(0, 0, 0, 0.5));
  --shadow-dialog: light-dark(rgba(16, 24, 40, 0.22), rgba(0, 0, 0, 0.6));
  --shadow-card: light-dark(rgba(16, 24, 40, 0.14), rgba(0, 0, 0, 0.45));
  --shadow-stage: light-dark(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.35));

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.theme-switching, .theme-switching * { transition: none !important; }

/* Kind colours come from JS as --k (pastels tuned for dark). On light, --kc (dots, borders, tints) and --kt
   (text) cap their OKLCH lightness, keeping hue and chroma, so every kind holds up on white (kc ≥ 3:1,
   kt ≥ 4.5:1 on its tint). On dark --kc is --k, and --kt only lifts the few dark kinds (the grey fallback). */
.chip, .seg, .mini-shot i {
  --kc: light-dark(oklch(from var(--k, var(--mute)) min(l, 0.6) c h), var(--k, var(--mute)));
  --kt: light-dark(oklch(from var(--k, var(--mute)) min(l, 0.45) c h), oklch(from var(--k, var(--mute)) max(l, 0.68) c h));
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.35 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--dim); }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* ------------------------------------------------------------------ layout */
/* Column and row sizes are variables: the inspector and the boards drawer collapse (classes on <html>, set by
   js/layout.js and before first paint by index.html), and the drawer's height is dragged (--drawer-h, inline). */
:root { --lib-w: 312px; --insp-w: 272px; --insp-rail: 32px; --drawer-h: 222px; --drawer-bar: 38px; }
:root.insp-collapsed { --insp-w: var(--insp-rail); }
#app {
  display: grid;
  height: 100vh;
  grid-template-columns: var(--lib-w) minmax(0, 1fr) var(--insp-w);
  grid-template-rows: 44px minmax(0, 1fr) clamp(120px, var(--drawer-h), 60vh);
  grid-template-areas: "hdr hdr hdr" "lib view insp" "board board board";
  gap: 1px;
  background: var(--line);
}
:root.drawer-collapsed #app { grid-template-rows: 44px minmax(0, 1fr) var(--drawer-bar); }
:root.resizing-drawer, :root.resizing-drawer * { cursor: ns-resize !important; user-select: none; }
#hdr { grid-area: hdr; }
#library { grid-area: lib; }
#viewer { grid-area: view; }
#inspector { grid-area: insp; }
#board { grid-area: board; }
.panel { background: var(--panel); min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.panel-head {
  height: 36px; flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 8px 0 12px; border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.count { color: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ controls */
.btn {
  height: 28px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 1px solid var(--line2); background: var(--raised); border-radius: 6px; font-weight: 550;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--raised2); border-color: var(--line3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { height: 24px; padding: 0 9px; font-size: 11.5px; }
.btn.on { color: var(--accent); border-color: var(--accent-line); }
.btn svg { flex: none; }

.icon-btn {
  width: 28px; height: 28px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 6px; text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger:hover:not(:disabled) { color: var(--err); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

input[type="text"], input[type="search"], input:not([type]), select, textarea, .inp {
  background: var(--field); border: 1px solid var(--line2); border-radius: 6px; height: 28px; padding: 0 8px;
  outline: none; min-width: 0; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.inp { height: auto; padding: 6px 8px; line-height: 1.45; resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
input::placeholder, textarea::placeholder { color: var(--mute); }
select { padding-right: 4px; cursor: pointer; }
input.bad, .inp.bad { border-color: var(--err) !important; animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
input[type="range"] { accent-color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: 4px;
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.badge.warn { background: var(--warn-wash); color: var(--warn-text); box-shadow: inset 0 0 0 1px var(--warn-line); }
.badge.block { display: flex; height: 22px; justify-content: center; }

.chip {
  height: 22px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; border-radius: 11px;
  border: 1px solid var(--line2); background: transparent; color: var(--dim); font-size: 11px; white-space: nowrap;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--kc); flex: none; }
.chip .n { color: var(--mute); font-size: 10px; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--text); border-color: var(--line3); }
.chip.on { color: var(--text); border-color: var(--kc); background: color-mix(in srgb, var(--kc) 20%, transparent); }
.chip.on .n { color: var(--dim); }
.chip.all { padding: 0 9px; }
.chip.static { cursor: default; }

kbd {
  font-family: var(--mono); font-size: 10.5px; background: var(--raised); border: 1px solid var(--line2);
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--text); text-align: center; white-space: nowrap;
}

/* ------------------------------------------------------------------ header */
#hdr {
  background: var(--panel); display: flex; align-items: center; gap: 10px; padding: 0 12px; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { width: 20px; height: 20px; border-radius: 5px; background: var(--logo-bg); position: relative; flex: none; }
.logo i { position: absolute; bottom: 4px; height: 5px; border-radius: 1.5px; }
.logo i:nth-child(1) { left: 3px; width: 4px; background: var(--logo-a); }
.logo i:nth-child(2) { left: 8px; width: 6px; background: var(--logo-b); }
.logo i:nth-child(3) { left: 15px; width: 2px; background: var(--logo-a); }
.logo::before { content: ""; position: absolute; left: 3px; right: 3px; top: 3px; height: 7px; border-radius: 2px; background: var(--logo-screen); }
.brand-name { font-weight: 700; letter-spacing: 0.01em; }
.brand-sep { color: var(--mute); }
.proj-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the project menu: the name itself is the button (projects.js) */
.proj-pick {
  position: relative; display: inline-flex; align-items: center; min-width: 0; max-width: 260px; height: 26px;
  padding: 0 24px 0 8px; margin-left: -4px; border: 1px solid transparent; border-radius: 6px; background: none;
  font-size: inherit; cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.proj-pick .pick-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-pick::after {
  content: ""; position: absolute; right: 9px; top: 50%; width: 5px; height: 5px; pointer-events: none;
  border-right: 1.6px solid var(--dim); border-bottom: 1.6px solid var(--dim); transform: translateY(-70%) rotate(45deg);
}
.proj-pick:hover, .proj-pick.open { background: var(--raised); border-color: var(--line2); }
.proj-pick.open::after { transform: translateY(-25%) rotate(-135deg); border-color: var(--accent); }
.new-proj { width: 100%; margin-top: 4px; }
/* the cloud's user menu, at the right end (projects.js) */
.user-pick { margin-left: 0; max-width: 160px; color: var(--text2); font-weight: 550; }
.hdr-stats { display: flex; gap: 6px; color: var(--dim); white-space: nowrap; margin-left: 6px; }
.hdr-stats .dot { color: var(--mute); }
.hdr-div { width: 1px; height: 20px; background: var(--line2); flex: none; }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11px; white-space: nowrap; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.save-state[data-state="unsaved"] i { background: var(--warn); }
.save-state[data-state="saving"] i { background: var(--accent); animation: pulse 0.8s ease-in-out infinite alternate; }
.save-state[data-state="error"], .save-state[data-state="blocked"] { color: var(--err); }
.save-state[data-state="error"] i, .save-state[data-state="blocked"] i { background: var(--err); }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }
.caret { color: var(--mute); font-size: 10px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 320px; max-height: 60vh; overflow: auto;
  background: var(--menu-bg); border: 1px solid var(--line2); border-radius: 9px; padding: 4px; z-index: 60;
  box-shadow: 0 14px 40px var(--shadow-menu);
}
.menu-head { color: var(--mute); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 8px 4px; }
.menu-item {
  display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: baseline; width: 100%;
  text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 6px;
}
.menu-item:hover:not(:disabled) { background: var(--raised); }
.mi-name { font-family: var(--mono); font-weight: 600; }
.mi-meta { color: var(--dim); font-variant-numeric: tabular-nums; }
.mi-when { color: var(--mute); font-size: 11px; }

.export-btn { position: relative; overflow: hidden; min-width: 132px; justify-content: center; }
.export-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--export-fill); transition: width 0.3s; }
.export-label { position: relative; }
.export-btn.running { background: var(--accent-busy); border-color: var(--accent-busy); color: var(--on-accent-busy); cursor: progress; }

/* ------------------------------------------------------------------ library */
.lib-head { padding-left: 8px; }
.lib-views {
  display: inline-flex; flex: none; gap: 2px; padding: 2px; border-radius: 7px;
  background: var(--switch-track); box-shadow: inset 0 0 0 1px var(--line);
}
.lib-views button {
  height: 22px; padding: 0 9px; border: 0; border-radius: 5px; background: transparent; color: var(--dim);
  font-size: 11.5px; font-weight: 600; transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.lib-views button:hover:not(.on) { color: var(--text); }
.lib-views button.on { background: var(--switch-on); color: var(--text); box-shadow: 0 0 0 1px var(--line2), 0 1px 2px var(--shadow-switch); }
/* Starred (a filter), Archived and Hidden (lists of what was put away) */
.lib-lens {
  flex: none; display: flex; flex-wrap: nowrap; gap: 3px; padding: 0 10px 7px; min-width: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
}
.lib-lens::-webkit-scrollbar { display: none; }
.lens-btn {
  height: 24px; flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 0 7px;
  border: 1px solid var(--line2); border-radius: 12px; background: transparent; color: var(--dim);
  font-size: 10.5px; font-weight: 600; white-space: nowrap; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.lens-btn .n { color: var(--mute); font-size: 10.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.lens-btn:hover { color: var(--text); border-color: var(--line3); }
.lens-btn.on { color: var(--text); background: var(--accent-wash); border-color: var(--accent-line); }
.lens-btn.on .n { color: var(--dim); }
.star-toggle.on { background: var(--star-wash); border-color: var(--star-line); }
/* in the Archived / Hidden lists, Starred and the kind chips do not apply */
#library.lens-on .star-toggle, #library.lens-on .chips { opacity: 0.4; }
#library.lens-on .chips { pointer-events: none; }

/* small buttons on a poster or a shot thumbnail (star, archive, hide ×): shown on hover; a set star stays */
.tc-acts { position: absolute; top: 4px; right: 4px; z-index: 3; display: flex; gap: 3px; }
.tc-poster .tc-acts { top: 3px; right: 3px; }
.star-btn {
  width: 20px; height: 20px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 4px;
  background: var(--ov-bg); color: var(--ov-text); opacity: 0; transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.star-btn svg { width: 12px; height: 12px; }
.tc-main:hover .star-btn, .shot:hover .star-btn, .star-btn.on, .star-btn:focus-visible { opacity: 1; }
.star-btn:hover, .star-btn.on { color: var(--star-media); }
.arch-btn:hover { color: var(--ov-text); background: var(--ov-bg-hover); }
.flag-btn:hover, .flag-btn.on { color: var(--flag-media); }
/* "Render" mark: a small text pill instead of an icon (Marc: no ambiguous glyphs) */
.render-pill { width: auto !important; padding: 0 6px !important; font-size: 10px; font-weight: 600; letter-spacing: 0.02em; line-height: 20px; }
.render-pill.on { background: var(--flag-media) !important; color: #1a0f08 !important; }
.v-flag.render-pill { height: 24px; line-height: 22px; border: 1px solid var(--line2); border-radius: 5px; background: transparent; color: var(--dim); }
.v-flag.render-pill.on { border-color: var(--flag); background: var(--flag) !important; color: #fff !important; }
.hide-btn svg { stroke-width: 2.6; }
.hide-btn:hover { color: var(--ov-text); background: var(--del-hover); }
body.dragging-clip .star-btn:not(.on), body.dragging-slice .star-btn:not(.on) { opacity: 0; }
.lib-filters { display: flex; gap: 6px; padding: 8px 10px 6px; }
.lib-filters .search { flex: 1 1 auto; min-width: 0; }
.lib-filters input { width: 100%; -webkit-appearance: none; appearance: none; }
/* the collection filter: a picker (ui.js), the same box as the search field */
.lib-col { flex: 0 1 auto; max-width: 48%; }
.lib-col[hidden] { display: none; }
/* kind chips: one row that scrolls sideways (JS sets fade-l/-r, see .side-scroll) */
.chips {
  flex: none; display: flex; flex-wrap: nowrap; gap: 4px; padding: 0 10px 8px;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex: none; }
/* rows that scroll sideways (the kind chips, the lists row): the edge with more behind it fades */
.side-scroll.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.side-scroll.fade-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px); mask-image: linear-gradient(to right, transparent, #000 28px); }
.side-scroll.fade-l.fade-r {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 40px), transparent);
}
.lib-list { flex: 1 1 auto; overflow-y: auto; padding: 2px 8px 14px; }
.lib-msg { color: var(--dim); padding: 14px 6px; text-align: center; }
.lib-msg.error { color: var(--err); text-align: left; }

.tcard {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  transition: border-color 0.12s, background 0.12s;
}
.tcard:hover { border-color: var(--line-hover); }
.tcard.active { border-color: var(--accent-line-strong); background: var(--active-bg); }
.tc-main { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 8px; cursor: pointer; }
.tc-poster {
  width: 112px; height: 63px; border-radius: 5px; background: var(--media-bg) center / cover no-repeat; position: relative;
  box-shadow: inset 0 0 0 1px var(--media-edge);
}
.tc-len {
  position: absolute; right: 3px; bottom: 3px; font: 600 10px/15px var(--mono); padding: 0 4px;
  background: var(--ov-bg); border-radius: 3px; color: var(--ov-text);
}
.tc-nopreview {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; color: var(--warn-text); border-radius: inherit;
  background: repeating-linear-gradient(135deg, var(--stripe-a) 0 8px, var(--stripe-b) 8px 16px);
}
.tc-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-title {
  font-size: 12.5px; font-weight: 620; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tc-author { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; color: var(--dim); font-size: 11px; margin-top: auto; }
.m-res { color: var(--text); background: var(--raised); padding: 0 5px; border-radius: 3px; font-size: 10.5px; font-weight: 650; line-height: 17px; }
.tc-bar { display: flex; align-items: center; border-top: 1px solid var(--line); min-width: 0; }
.tc-shots {
  display: flex; flex: 1 1 auto; min-width: 0; justify-content: space-between; align-items: center; height: 24px; padding: 0 10px;
  border: 0; background: transparent; color: var(--mute); font-size: 11px; border-radius: 0 0 8px 8px;
}
.tc-shots.static { justify-content: flex-start; }
.tc-bar .link { flex: none; padding: 0 10px; height: 24px; }
.tc-bar .btn.small { flex: none; margin: 4px 6px 4px 0; height: 22px; }
.tcard.archived .tc-poster { filter: saturate(0.4); opacity: 0.8; }
/* Hidden list: the hidden shots of each template, each with Restore */
.hgroup { margin-bottom: 10px; }
.hg-head { display: flex; align-items: baseline; gap: 6px; padding: 4px 2px 6px; min-width: 0; }
.hg-title { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.shot.is-hidden .sh-thumb { filter: saturate(0.5); }
/* branded renders (master/branded.json): the tile shows them by default */
.sh-tc.branded { color: var(--branded-media); font-family: inherit; font-weight: 650; }
.shot.branded { border-color: color-mix(in srgb, var(--branded) 45%, var(--line)); }
.mini-switch { display: inline-flex; gap: 1px; padding: 1px; border-radius: 5px; background: var(--switch-track); box-shadow: inset 0 0 0 1px var(--line); }
.mini-switch button {
  height: 18px; padding: 0 6px; border: 0; border-radius: 4px; background: transparent; color: var(--dim);
  font-size: 10px; font-weight: 600; white-space: nowrap;
}
.mini-switch button:hover:not(.on) { color: var(--text); }
.mini-switch button.on { background: var(--switch-on); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }
.mini-switch button[data-v="branded"].on, .mini-switch button[data-variant="branded"].on { color: var(--branded); }
.mini-switch.wide { display: flex; }
.mini-switch.wide button { flex: 1; height: 22px; font-size: 11px; }
.sh-var { margin: 0 6px 5px; }
.sh-est { flex: none; margin-left: auto; font-size: 10px; color: var(--flag); font-variant-numeric: tabular-nums; white-space: nowrap; }
.render-sum { display: flex; justify-content: space-between; gap: 8px; padding: 2px 2px 8px; color: var(--dim); font-size: 11.5px; }
.render-sum .mono { color: var(--flag); }
.tc-shots.has { color: var(--dim); }
.tc-shots:hover:not(:disabled) { color: var(--text); background: var(--hover-wash); }
.tc-shots .chev { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; color: var(--dim); transition: transform 0.15s, color 0.12s, background 0.12s; }
.tc-shots .chev svg { width: 14px; height: 14px; stroke-width: 2.2; }
.tc-shots .chev.open { transform: rotate(90deg); }
.tc-shots:hover:not(:disabled) .chev { color: var(--text); background: var(--raised); }
.tc-sl { display: inline-flex; align-items: center; gap: 8px; }
.tc-starn { display: inline-flex; align-items: center; gap: 3px; color: var(--star-text); font-variant-numeric: tabular-nums; }
.tc-starn span:first-child { display: grid; color: var(--star); }
.tc-starn svg { width: 10px; height: 10px; }
.tcard.open .tc-shots { border-radius: 0; }

.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 2px 8px 8px; }
.shots .lib-msg { grid-column: 1 / -1; padding: 6px; }
.shot {
  background: var(--tile); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: pointer;
  transition: border-color 0.12s;
}
.shot:hover { border-color: var(--accent); }
.sh-thumb { aspect-ratio: 16 / 9; background: var(--media-bg) center / cover no-repeat; position: relative; overflow: hidden; }
.hover-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.08s; }
.hover-video.ready { opacity: 1; }
.sh-tc {
  position: absolute; left: 4px; bottom: 5px; z-index: 2; font: 9.5px/14px var(--mono); padding: 0 4px;
  background: var(--ov-bg); border-radius: 3px; color: var(--ov-text); white-space: nowrap;
}
.sh-prog { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--accent); z-index: 2; }
.sh-line { padding: 5px 6px 5px; display: flex; gap: 5px; align-items: baseline; font-size: 11px; min-width: 0; }
.sh-kind {
  position: absolute; top: 4px; left: 4px; z-index: 2; display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; font-weight: 650; line-height: 15px; color: var(--ov-text); background: var(--ov-bg);
  padding: 0 5px; border-radius: 3px; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden;
}
.sh-kind i { width: 6px; height: 6px; border-radius: 50%; background: var(--k); flex: none; }
.sh-desc {
  color: var(--dim); min-width: 0; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sh-foot { display: flex; gap: 3px; align-items: center; padding: 0 6px 6px; }
/* the Shots view: one line of description, the template's name under it */
.shots.flat { padding: 0; }
.shot.flat .sh-line { padding-bottom: 1px; }
.shot.flat .sh-desc { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2); }
.sh-sub { display: flex; align-items: center; gap: 5px; padding: 0 6px 6px; min-width: 0; }
.sh-tpl { flex: 1 1 auto; min-width: 0; font-size: 10px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* preview_only shots (the author's marketing cards): dimmed until hovered, with a small mark */
.sh-po {
  flex: none; font-size: 9.5px; line-height: 14px; padding: 0 4px; border-radius: 3px; color: var(--dim);
  box-shadow: inset 0 0 0 1px var(--line2); white-space: nowrap;
}
.sh-foot .sh-po { margin-left: 2px; }
.shot.ponly .sh-thumb::after {
  content: ""; position: absolute; inset: 0; z-index: 1; background: var(--veil); pointer-events: none; transition: opacity 0.12s;
}
.shot.ponly:hover .sh-thumb::after { opacity: 0; }
.shot.ponly .sh-desc { color: var(--mute); }
.sw { width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1px var(--swatch-edge); }
.fit { margin-left: auto; display: flex; gap: 2px; }
.fit b { width: 5px; height: 5px; border-radius: 50%; background: var(--line2); }
.fit b.on { background: var(--ok); }

/* ------------------------------------------------------------------ viewer */
#viewer { background: var(--viewer-bg); }
.viewer-head { height: 36px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.mode-pill {
  font-size: 10px; font-weight: 750; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 4px;
  background: var(--raised); color: var(--dim); white-space: nowrap; flex: none;
}
.mode-pill.source { background: var(--accent-wash); color: var(--accent); }
.mode-pill.slice { background: var(--in-wash); color: var(--in-text); }
.mode-pill.board { background: var(--head-wash); color: var(--head-text); }
.v-title { font-size: 13px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.v-sub { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; }
.v-star {
  flex: none; height: 24px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px 0 6px; margin-right: -6px;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--dim); font-size: 11px; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.v-star .vs-ico { display: grid; }
.v-star svg { width: 13px; height: 13px; }
.v-star:hover { background: var(--raised); color: var(--text); }
.v-star.on { color: var(--text); }
.v-star.on .vs-ico { color: var(--star); }
.v-flag { padding: 0; justify-content: center; margin-right: 0; }
.v-flag.on { color: var(--flag); }
.v-variant { flex: none; }

.stage-wrap {
  flex: 1 1 auto; min-height: 0; container-type: size; display: grid; place-items: center;
  margin: 8px 10px 4px; padding: 4px; border-radius: 8px; background: var(--stage-well);
}
.stage {
  width: min(100cqw, 177.78cqh); height: min(100cqh, 56.25cqw); position: relative; background: var(--stage-bg);
  border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 10px 30px var(--shadow-stage);
  color-scheme: dark; color: var(--text);
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; background: var(--stage-bg); cursor: pointer; }
.stage video.front { opacity: 1; }
.stage.is-empty video, .stage.is-missing video { visibility: hidden; }
.stage-msg { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--dim); text-align: center; padding: 20px; }
.stage-msg .big { font-size: 15px; font-weight: 620; color: var(--text); }
.stage.is-empty .empty-msg { display: flex; }
.stage.is-missing:not(.is-empty) .missing-msg { display: flex; }
.missing-poster { position: absolute; inset: 0; background: var(--stage-bg) center / cover no-repeat; filter: blur(3px) brightness(0.32); transform: scale(1.04); }
.missing-text { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.missing-text .big::before { content: ""; display: block; width: 34px; height: 34px; margin: 0 auto 10px; border-radius: 50%; border: 2px dashed var(--warn); opacity: 0.8; }
.stage-badge {
  position: absolute; top: 10px; left: 10px; z-index: 3; background: var(--ov-bg-soft); color: var(--ov-text); font-size: 11px;
  padding: 4px 9px; border-radius: 5px; border-left: 3px solid var(--head); pointer-events: none; backdrop-filter: blur(4px);
}

.scrub { flex: none; padding: 2px 14px 0; user-select: none; }
.shots-lane { position: relative; height: 18px; margin-bottom: 2px; }
.seg {
  position: absolute; top: 0; bottom: 0; border-radius: 3px; cursor: pointer; overflow: hidden;
  background: color-mix(in srgb, var(--kc) 22%, transparent); box-shadow: inset 2px 0 0 var(--kc), inset -1px 0 0 var(--viewer-bg);
  color: var(--kt); font-size: 9.5px; font-weight: 650; line-height: 18px; padding: 0 5px; white-space: nowrap;
  transition: background 0.12s;
}
.seg span { pointer-events: none; }
/* × on a strip segment: hides that shot (library.json → hidden_shots), restorable */
.seg-x { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; padding: 0; border: 0; border-radius: 3px; display: grid; place-items: center;
  background: var(--ov-bg); color: var(--ov-text); opacity: 0; cursor: pointer; transition: opacity 0.12s, background 0.12s; }
.seg-x svg { width: 9px; height: 9px; stroke-width: 2.8; }
.seg:hover .seg-x { opacity: 1; }
.seg-x:hover { background: var(--del-hover); }
.seg:hover { background: color-mix(in srgb, var(--kc) 38%, transparent); }
.seg.on { background: color-mix(in srgb, var(--kc) 44%, transparent); color: var(--seg-on-text); }
.lane-empty { color: var(--mute); font-size: 10.5px; line-height: 18px; font-style: italic; }
.track { position: relative; height: 34px; cursor: pointer; touch-action: none; }
.track-bg { position: absolute; left: 0; right: 0; top: 9px; height: 16px; background: var(--track-bg); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line2); }
.shot-ticks i { position: absolute; top: 6px; height: 22px; width: 1px; background: var(--tick); pointer-events: none; }
.range { position: absolute; top: 9px; height: 16px; background: var(--in-weak); box-shadow: inset 0 0 0 1px var(--in-line); border-radius: 2px; pointer-events: none; }
.mark { position: absolute; top: 4px; height: 26px; width: 7px; cursor: ew-resize; z-index: 2; border: 2.5px solid var(--in); }
.mark::before { content: ""; position: absolute; inset: -3px -7px; }
.mark-in { border-right: 0; border-radius: 3px 0 0 3px; }
.mark-out { border-left: 0; border-radius: 0 3px 3px 0; transform: translateX(-100%); }
.mark:hover, .track.dragging .mark { filter: brightness(1.25); }
.playhead { position: absolute; top: 1px; bottom: 1px; width: 2px; margin-left: -1px; background: var(--head); pointer-events: none; z-index: 3; border-radius: 1px; }
.playhead::before { content: ""; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top: 6px solid var(--head); }
.hover-tc {
  position: absolute; bottom: calc(100% + 2px); transform: translateX(-50%); background: var(--tip-bg); color: var(--tip-text); z-index: 6;
  font: 10.5px/16px var(--mono); padding: 0 5px; border-radius: 3px; pointer-events: none; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line2);
}
.track.off { cursor: default; }
.track.off .range, .track.off .mark, .track.off .playhead, .track.off .hover-tc { display: none; }

.transport { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px 14px 10px; min-width: 0; }
.tc-box { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; min-width: 150px; }
.tc { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 550; }
.tc.dim { font-size: 11.5px; color: var(--dim); font-weight: 400; }
.tbtns { display: flex; gap: 2px; }
.icon-btn.play { background: var(--raised); color: var(--text); }
.icon-btn.play.on { color: var(--accent); }
.io { display: flex; align-items: center; gap: 4px; min-width: 0; }
.io-btn {
  width: 26px; height: 26px; border-radius: 5px; border: 1px solid var(--line2); background: var(--raised);
  color: var(--in-text); font: 700 12px var(--mono); padding: 0;
}
.io-btn:hover:not(:disabled) { background: var(--raised2); }
.tc-field { width: 78px; height: 26px !important; font-family: var(--mono); font-size: 11.5px; text-align: center; padding: 0 4px !important; }
.io-arrow { color: var(--mute); }
.range-dur { color: var(--dim); font-size: 11px; min-width: 46px; margin-left: 4px; }
.drag-range {
  width: 26px; height: 28px; display: grid; place-items: center; color: var(--dim); border: 1px dashed var(--line2);
  border-radius: 6px; cursor: grab; flex: none;
}
.drag-range:hover { color: var(--text); border-color: var(--accent); }
.drag-range.off { opacity: 0.3; cursor: not-allowed; }

/* ------------------------------------------------------------------ inspector */
#inspector { overflow: hidden; }
.insp-root { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.insp-toggle { margin-left: auto; }
.insp-toggle svg { width: 14px; height: 14px; }
/* collapsed: a slim rail on the right; the whole rail reopens it */
.insp-rail { display: none; }
:root.insp-collapsed .insp-root { display: none; }
:root.insp-collapsed .insp-rail {
  display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1 1 auto; width: 100%; padding: 6px 0;
  border: 0; border-radius: 0; background: transparent; color: var(--dim); cursor: pointer; transition: background 0.12s, color 0.12s;
}
.insp-rail:hover { background: var(--hover-wash); color: var(--text); }
.rail-ico { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; }
.rail-ico svg { width: 14px; height: 14px; transform: rotate(180deg); }
.rail-label { writing-mode: vertical-rl; font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.insp-body { padding: 10px 12px 18px; display: flex; flex-direction: column; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f-label { font-size: 10px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--mute); }
.field .inp { width: 100%; }
.tc-inp { font-family: var(--mono); font-size: 11.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.facts { display: grid; gap: 3px; }
.fact { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; }
.fact .k { color: var(--dim); flex: none; }
.fact .v { text-align: right; min-width: 0; overflow-wrap: anywhere; font-size: 11px; }
.sep { height: 1px; background: var(--line); margin: 2px 0; flex: none; }
.tmini { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 9px; align-items: center; }
.tm-poster { width: 72px; height: 40px; border-radius: 4px; background: var(--media-bg) center / cover no-repeat; }
.tm-title { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-sub { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 11px; }
.link:hover { text-decoration: underline; }
.insp-shots { display: flex; flex-direction: column; gap: 3px; }
.insp-note { color: var(--dim); font-size: 11.5px; }
.flag-block { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 6px; background: var(--raised); }
.flag-block .f-label { color: var(--flag); }
.flag-note { min-height: 44px !important; }
/* Move to… / Copy to…: side by side, stacked when the inspector is too narrow for both labels */
.send-row { display: flex !important; flex-wrap: wrap; gap: 6px; }
.send-row .pick-btn { flex: 1 1 104px; height: 28px; padding-right: 26px; }
.mini-shot { display: grid; grid-template-columns: 8px 24px auto minmax(0, 1fr); gap: 6px; align-items: center; font-size: 11px; }
.mini-shot i { width: 8px; height: 8px; border-radius: 2px; background: var(--kc); }
.mini-shot .mono { color: var(--mute); font-size: 10.5px; }
.ms-kind { color: var(--dim); white-space: nowrap; }
.ms-desc { color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-poster { aspect-ratio: 16 / 9; border-radius: 6px; background: var(--media-bg) center / cover no-repeat; position: relative; box-shadow: inset 0 0 0 1px var(--media-edge); }
.insp-title { font-size: 14px; font-weight: 650; line-height: 1.25; }
.insp-author { color: var(--dim); margin-top: -5px; }
.kind-sum { display: flex; flex-wrap: wrap; gap: 4px; }
.desc { color: var(--text2); font-size: 11.5px; line-height: 1.5; cursor: pointer; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--raised); color: var(--dim); }
.keys { display: grid; gap: 6px; }
.key-row { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 8px; align-items: center; font-size: 11.5px; color: var(--dim); }
.key-row kbd { justify-self: start; }

/* ------------------------------------------------------------------ board */
#board { background: var(--panel); position: relative; }
.board-bar { height: var(--drawer-bar); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 6px; border-bottom: 1px solid var(--line); min-width: 0; }
.drawer-toggle svg { width: 14px; height: 14px; transform: rotate(90deg); transition: transform 0.16s; }
:root.drawer-collapsed .drawer-toggle svg { transform: rotate(-90deg); }
/* collapsed: a slim bar with the active board's name, duration and Play; the viewer takes the room */
.mini-only { display: none !important; }
:root.drawer-collapsed .mini-only { display: inline-flex !important; }
:root.drawer-collapsed .full-only, :root.drawer-collapsed .boards-list, :root.drawer-collapsed .drawer-grip { display: none !important; }
:root.drawer-collapsed .board-bar { border-bottom: 0; }
.drawer-mini { align-items: center; gap: 8px; min-width: 0; }
.mini-name { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.mini-dur { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
/* the drawer's top edge: drag to resize (min 120 px, max 60 % of the window) */
.drawer-grip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 20; touch-action: none; }
.drawer-grip::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: transparent; transition: background 0.12s; }
.drawer-grip:hover::after, :root.resizing-drawer .drawer-grip::after { background: var(--accent); }
.bmenu { position: fixed; top: auto; right: auto; min-width: 180px; }
.bmenu .menu-item { display: flex; align-items: center; }
.menu-item.danger { color: var(--err); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.play-board { justify-content: center; }
.play-board svg { width: 11px; height: 11px; }
.play-board.on { background: var(--head-wash2); border-color: var(--head-line); color: var(--head-ink); }
.hint { color: var(--mute); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.zoom { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11px; }
.zoom input { width: 110px; }

/* every board stacked: a header over a strip of cards; the active one has the accent bar */
.boards-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative;
  background: var(--timeline-bg); padding: 2px 0 4px; overscroll-behavior: contain;
}
.brow { position: relative; }
.brow + .brow { border-top: 1px solid var(--line); }
.brow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; z-index: 2; }
.brow.on::before { background: var(--accent); }
.brow-head {
  height: 28px; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 9px; min-width: 0;
  color: var(--dim); cursor: grab; user-select: none;
}
.brow-grip { display: grid; color: var(--mute); opacity: 0; transition: opacity 0.12s; margin-right: -4px; }
.brow-grip svg { width: 12px; height: 12px; }
.brow-head:hover .brow-grip { opacity: 1; }
.brow-name { font-weight: 620; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 40%; }
.brow.on .brow-name { color: var(--text); }
.brow-meta { font-size: 11px; color: var(--mute); white-space: nowrap; }
.brow-tc { font-size: 11px; color: var(--dim); white-space: nowrap; }
.brow-head .btn.small { height: 22px; padding: 0 8px; font-size: 11px; }
.brow:not(.on) .play-board, .brow:not(.on) .bt-more { opacity: 0.55; }
.brow:not(.on):hover .play-board, .brow:not(.on):hover .bt-more { opacity: 1; }
.brow.dragging { opacity: 0.4; }
.brow.drop-before::after, .brow.drop-after::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 2px; z-index: 6;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak);
}
.brow.drop-before::after { top: -2px; }
.brow.drop-after::after { bottom: -2px; }
.bt-more {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--dim);
  font-size: 13px; line-height: 1; display: grid; place-items: center;
}
.bt-more:hover, .bt-more.on { background: var(--raised2); color: var(--text); }
.bt-input { height: 22px !important; padding: 0 6px !important; font-size: 12px; font-weight: 600; }
.brow .timeline { height: 122px; overflow-x: auto; overflow-y: hidden; position: relative; transition: background 0.12s; }
.brow .tl-track { position: relative; display: flex; gap: 6px; padding: 2px 10px 10px; min-width: 100%; width: max-content; height: 100%; align-items: stretch; }
.brow.drop-target .timeline { background: var(--timeline-drop); }
.brow-add {
  display: block; width: calc(100% - 20px); height: 30px; margin: 8px 10px 4px; border: 1px dashed var(--line2); border-radius: 7px;
  background: transparent; color: var(--dim); font-size: 11.5px; font-weight: 600;
}
.brow-add:hover { color: var(--text); border-color: var(--line3); background: var(--raised); }

.card {
  flex: none; display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--line2);
  border-radius: 7px; overflow: hidden; cursor: pointer; position: relative; user-select: none;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.card:hover { border-color: var(--line-strong); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 6px 18px var(--shadow-card); }
body.board-playing .card.selected { border-color: var(--head); box-shadow: 0 0 0 1px var(--head), 0 6px 18px var(--shadow-card); }
.card.dragging { opacity: 0.32; }
.card.flash { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.c-thumb { flex: 1 1 auto; min-height: 0; background: var(--media-bg) center / cover no-repeat; position: relative; }
.c-num {
  position: absolute; top: 5px; left: 5px; font: 700 10px/16px var(--mono); background: var(--ov-bg);
  padding: 0 5px; border-radius: 3px; color: var(--ov-text);
}
.c-dur {
  position: absolute; right: 5px; bottom: 5px; font: 10px/16px var(--mono); background: var(--ov-bg);
  padding: 0 5px; border-radius: 3px; color: var(--ov-text); white-space: nowrap;
}
.c-kind { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--k); }
.c-warn {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; color: var(--warn-text);
  background: repeating-linear-gradient(135deg, var(--stripe-a) 0 8px, var(--stripe-b) 8px 16px);
}
.c-meta { flex: none; padding: 5px 7px 6px; border-top: 1px solid var(--line); min-width: 0; }
.c-label { font-size: 12px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-label.ph { color: var(--mute); font-weight: 400; font-style: italic; }
.c-sub { font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-branded { color: var(--branded); font-weight: 650; margin-right: 5px; }
.c-label-input { width: 100%; height: 20px !important; font-size: 12px; padding: 0 4px !important; }
.card.narrow .c-meta { padding: 4px 5px 5px; }
.card.narrow .c-dur { right: 3px; bottom: 3px; padding: 0 3px; }
.card.narrow .c-num { top: 4px; left: 3px; padding: 0 3px; }
.c-del {
  position: absolute; top: 5px; right: 5px; z-index: 3; width: 18px; height: 18px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 4px; background: var(--ov-bg); color: var(--ov-text); opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.c-del svg { width: 12px; height: 12px; stroke-width: 2.6; }
.card:hover .c-del, .card.selected .c-del, .c-del:focus-visible { opacity: 1; }
.c-del:hover { background: var(--del-hover); }
body.dragging-slice .c-del, body.dragging-clip .c-del { opacity: 0; pointer-events: none; }
.card.narrow .c-del { top: 4px; right: 3px; width: 16px; height: 16px; }
.card.narrow .c-del svg { width: 11px; height: 11px; }

.insert-ind {
  position: absolute; left: 0; top: 2px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak), 0 0 14px var(--accent-glow); opacity: 0; pointer-events: none; z-index: 5;
}
.insert-ind.on { opacity: 1; }
.tl-playhead { position: absolute; left: 0; top: 0; bottom: 8px; width: 2px; margin-left: -1px; background: var(--head); opacity: 0; pointer-events: none; z-index: 4; }
.tl-playhead::before { content: ""; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top: 6px solid var(--head); }
.tl-playhead.on { opacity: 1; }
.tl-empty {
  position: absolute; inset: 2px 10px 10px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line2); border-radius: 8px; color: var(--dim); font-size: 11.5px; pointer-events: none;
}

/* ------------------------------------------------------------------ toasts + dialogs */
.toasts { position: fixed; right: 16px; bottom: calc(clamp(120px, var(--drawer-h), 60vh) + 14px); display: flex; flex-direction: column; gap: 6px; z-index: 100; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 520px; background: var(--toast-bg);
  border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: 7px; padding: 7px 8px 7px 11px;
  box-shadow: 0 10px 30px var(--shadow-toast); animation: toast-in 0.16s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateY(4px); transition: opacity 0.18s, transform 0.18s; }
.toast-msg { min-width: 0; }
.toast-btn { background: var(--raised2); border: 1px solid var(--line3); border-radius: 4px; padding: 2px 8px; font-size: 11.5px; white-space: nowrap; }
.toast-btn:hover { background: var(--raised); border-color: var(--line-strong); }
.toast-x { background: none; border: 0; color: var(--mute); font-size: 16px; line-height: 1; padding: 0 2px; }
.toast-x:hover { color: var(--text); }
:root.drawer-collapsed .toasts { bottom: calc(var(--drawer-bar) + 14px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.overlay { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 200; }
.dialog {
  width: min(470px, 92vw); background: var(--dialog-bg); border: 1px solid var(--line2); border-radius: 11px; padding: 16px 18px;
  box-shadow: 0 24px 70px var(--shadow-dialog); animation: toast-in 0.14s ease-out;
}
.dialog.wide { width: min(980px, 92vw); }
.dialog-title { font-size: 14px; font-weight: 650; margin-bottom: 10px; }
.dialog-body { color: var(--dialog-text); line-height: 1.5; }
.dialog-body p { margin: 0 0 8px; }
.dialog-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.modal-video { width: 100%; max-height: 68vh; background: var(--stage-bg); border-radius: 6px; display: block; }
.dialog-sub { color: var(--dim); font-size: 11px; margin-top: 8px; word-break: break-all; }

/* ------------------------------------------------------------------ narrower windows */
@media (max-width: 1380px) {
  :root { --lib-w: 290px; --insp-w: 252px; }
  .hint { display: none; }
  .tc-box { min-width: 132px; }
  .tc { font-size: 14px; }
}
@media (max-width: 1300px) {
  .tc-field { width: 72px; }
  .range-dur { display: none; }
  .brand-name, .brand-sep { display: none; }
  .zoom span { display: none; }
}
@media (max-width: 1120px) {
  :root { --lib-w: 250px; --insp-w: 220px; }
  .tc-main { grid-template-columns: 88px minmax(0, 1fr); }
  .tc-poster { width: 88px; height: 50px; }
  .tc-box { min-width: 0; }
  .zoom input { width: 80px; }
}
@media (max-height: 820px) {
  :root { --drawer-h: 196px; }
}

/* ------------------------------------------------------------------ import (importer.js) */
.import-btn { min-width: 0; }
.import-btn.attn { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-wash); }
.badge.uncat { background: var(--raised); color: var(--dim); box-shadow: inset 0 0 0 1px var(--line2); }
.badge.uncat.busy { background: var(--accent-wash); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line-soft); }
.imp-dialog { display: flex; flex-direction: column; max-height: 86vh; width: min(760px, 92vw); }
.imp { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.imp-links { width: 100%; font-family: var(--mono); font-size: 11.5px; min-height: 150px; }
.imp-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.imp-col { flex: 1; }
.imp-found { color: var(--dim); font-size: 11.5px; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.imp-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.imp-optrow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.imp-opt { height: 26px; padding: 0 10px 0 8px; font-size: 11.5px; min-width: 150px; gap: 7px; }
.imp-tick { width: 12px; height: 12px; flex: none; border-radius: 3px; border: 1px solid var(--line3); display: inline-grid; place-items: center; }
.imp-opt.on .imp-tick { background: var(--accent); border-color: var(--accent); }
.imp-opt.on .imp-tick::after { content: ''; width: 6px; height: 3px; border: solid var(--on-accent); border-width: 0 0 1.6px 1.6px; transform: translateY(-1px) rotate(-45deg); }
.imp-opt:disabled { opacity: 0.45; cursor: not-allowed; }
.imp-note { color: var(--dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.imp-title { display: flex; align-items: baseline; gap: 10px; }
.imp-sum { color: var(--dim); font-size: 12px; font-weight: 500; }
.imp-banner {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 10px; border-radius: 8px;
  background: var(--warn-wash); box-shadow: inset 0 0 0 1px var(--warn-line); color: var(--warn-text); font-size: 12px; line-height: 1.4;
}
.imp-banner[hidden] { display: none; }
.imp-banner.quiet { background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line); color: var(--dim); }
.imp-list { overflow: auto; min-height: 90px; max-height: 58vh; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.imp-item { display: flex; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.imp-thumb { width: 96px; aspect-ratio: 16 / 9; flex: none; border-radius: 5px; background: var(--media-bg) center / cover no-repeat; }
.imp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.imp-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.imp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-colname { color: var(--mute); font-size: 11px; white-space: nowrap; }
.imp-head .btn.small { height: 22px; }
.imp-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.imp-step {
  height: 20px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--line2); color: var(--mute); font-variant-numeric: tabular-nums;
}
.imp-step.s-running { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }
.imp-step.s-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.imp-step.s-waiting { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-wash); }
.imp-step.s-error { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, transparent); }
.imp-step.s-skipped { opacity: 0.55; }
.imp-spin { width: 9px; height: 9px; border-radius: 50%; border: 1.6px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.imp-msg { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--dim); min-width: 0; }
.imp-msg > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-msg-k { color: var(--mute); font-weight: 600; flex: none; width: 66px; }
.imp-msg.s-error { color: var(--err); }
.imp-msg.s-error > span:nth-child(2) { white-space: normal; }
.imp-msg.s-waiting { color: var(--warn-text); }
.imp-bar { flex: 1; max-width: 220px; min-width: 60px; height: 4px; border-radius: 2px; background: var(--track-bg); overflow: hidden; }
.imp-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }

/* ------------------------------------------------------------------ notes (prefs.js, inspector.js) */
.tc-note, .sh-note {
  color: var(--accent); font-size: 11px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; min-width: 0;
}
.tc-note { margin-top: 2px; }
.sh-note { padding: 0 8px 6px; margin-top: -2px; }
.shot.flat .sh-note { padding: 0 8px 4px; }
.notes-block { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------------ Claude's status (status.js) */
.st-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 10.5px;
  font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: var(--accent); color: var(--on-accent);
}
.st-badge[hidden] { display: none; }
.st-badge[data-tone="busy"] { background: var(--accent); color: var(--on-accent); }
.st-badge[data-tone="done"] { background: var(--ok); color: #fff; }
.st-badge[data-tone="error"] { background: var(--err); color: #fff; }
.st-badge[data-tone="info"] { background: var(--raised2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line3); }
/* on thumbnails and posters: a corner badge */
.sh-thumb > .st-badge, .tc-poster > .st-badge, .c-thumb > .st-badge { position: absolute; left: 6px; bottom: 6px; z-index: 3; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.c-thumb > .st-badge { left: 4px; bottom: 4px; height: 16px; font-size: 10px; padding: 0 5px; }
.st-badge.row { margin-left: 8px; }
.claude-pill {
  height: 28px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: 14px; max-width: 420px;
  border: 1px solid var(--accent-line); background: var(--accent-wash); color: var(--accent); font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.claude-pill[hidden] { display: none; }
.claude-pill[data-tone="done"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.claude-pill[data-tone="error"] { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, transparent); background: color-mix(in srgb, var(--err) 10%, transparent); }
.claude-pill .cp-who { font-weight: 750; }
.claude-pill .cp-msg { color: var(--dim); font-weight: 500; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.st-dialog { width: min(640px, 92vw); }
.st-intro { margin: 0 0 10px; font-size: 12px; }
.st-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.st-main { flex: 1; min-width: 0; }
.st-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-msg { color: var(--dim); font-size: 11.5px; }
.st-since { color: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Export for Claude (handoff.js) */
.hand-dialog { width: min(700px, 92vw); }
.hand-intro { font-size: 12.5px; color: var(--dim); }
.hand-msg { width: 100%; min-height: 96px; }
.hand-label { margin: 12px 0 6px; }
.hand-boards { display: flex; flex-wrap: wrap; gap: 6px; }
.hand-boards .imp-opt { min-width: 0; }
.hand-last { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--dim); font-size: 12px; }
.hand-row { display: flex; gap: 8px; margin-top: 4px; }
.hand-line { flex: 1; font-size: 12px; }

/* ------------------------------------------------------------------ picker (ui.js): our own dropdown, no <select> */
.pick-btn {
  position: relative; display: inline-flex; align-items: center; min-width: 0; height: 28px; padding: 0 28px 0 10px;
  background: var(--field); border: 1px solid var(--line2); border-radius: 6px; color: var(--text); font-size: 12px;
  text-align: left; cursor: pointer; transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.pick-btn .pick-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pick-btn::after {
  content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1.6px solid var(--dim); border-bottom: 1.6px solid var(--dim); transform: translateY(-70%) rotate(45deg);
  transition: transform 0.15s;
}
.pick-btn:hover { background: var(--raised); border-color: var(--line3); }
.pick-btn.open { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.pick-btn.open::after { transform: translateY(-25%) rotate(-135deg); border-color: var(--accent); }
.pick-btn.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }
.pick-btn.send { color: var(--text2); font-weight: 550; }
.pick-menu { z-index: 300; max-height: min(60vh, 420px); }
.pick-menu .pk-item { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.pk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-meta { color: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.pk-item.on { color: var(--accent); font-weight: 650; background: var(--accent-wash); }
.pk-item.on .pk-meta { color: var(--accent); }
.pk-item.pk-info:disabled { opacity: 1; color: var(--dim); cursor: default; }

/* ------------------------------------------------------------------ the Script panel (script.js) */
#btn-script.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }
.sc-overlay { place-items: stretch center; padding: 28px 24px; }
.sc-panel {
  width: min(1080px, 100%); height: 100%; display: flex; flex-direction: column; min-height: 0;
  background: var(--dialog-bg); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 24px 70px var(--shadow-dialog);
  animation: toast-in 0.14s ease-out; overflow: hidden;
}
.sc-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sc-title { font-weight: 700; font-size: 14px; margin-right: 4px; }
.sc-ver { height: 28px; max-width: 260px; }
.sc-state { color: var(--mute); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sc-state[data-state="unsaved"], .sc-state[data-state="saving"] { color: var(--warn-text); }
.sc-mode button { height: 24px; padding: 0 12px; font-size: 12px; }
.sc-banner {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--warn-wash);
  border-bottom: 1px solid var(--warn-line); color: var(--warn-text); font-size: 12px;
}
.sc-banner[hidden] { display: none; }
.sc-body { flex: 1; min-height: 0; display: flex; }
.sc-text {
  flex: 1; min-height: 0; resize: none; border: 0; border-radius: 0; height: auto; padding: 22px 28px; background: var(--dialog-bg);
  font-family: var(--mono); font-size: 13px; line-height: 1.65; color: var(--text); tab-size: 2;
}
.sc-text:focus { box-shadow: none; }
.sc-text[hidden], .sc-view[hidden] { display: none; }
.sc-view { flex: 1; min-height: 0; overflow: auto; padding: 22px 32px 40px; }
/* markdown preview */
.md { color: var(--text); font-size: 14px; line-height: 1.6; }
.md h1 { font-size: 22px; margin: 0 0 14px; letter-spacing: -0.01em; }
.md h2 { font-size: 17px; margin: 26px 0 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.md h3 { font-size: 14.5px; margin: 18px 0 8px; }
.md p { margin: 0 0 10px; color: var(--text2); }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; color: var(--text2); }
.md li { margin: 2px 0; }
.md li.sub { margin-left: 18px; }
.md strong { color: var(--text); }
.md code { font-family: var(--mono); font-size: 12px; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--raised); padding: 10px 12px; border-radius: 8px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid var(--accent-line); color: var(--dim); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md a { color: var(--accent); }
.md-table { overflow-x: auto; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 8px; }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; line-height: 1.45; }
.md th { text-align: left; font-weight: 650; background: var(--panel2); color: var(--dim); font-size: 11.5px; }
.md th, .md td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.md tr:last-child td { border-bottom: 0; }
.md td:first-child, .md th:first-child { white-space: nowrap; }

/* the Script document: every block and table cell is edited in place (script.js) */
.md-block { position: relative; margin: 0 -8px 2px; padding: 3px 8px; border-radius: 7px; outline: none; transition: background 0.1s; }
.md-block:not(.md-hr):not(.md-tablewrap):hover { background: var(--hover-wash); cursor: text; }
.md-block > :last-child { margin-bottom: 0; }
.md-block > h2:first-child { margin-top: 18px; }
.md-block.editing, .md-table td.editing, .md-table th.editing {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; color: var(--text);
  background: var(--raised); box-shadow: 0 0 0 2px var(--accent-line-soft); cursor: text;
}
.md-table td, .md-table th { outline: none; cursor: text; transition: background 0.1s; }
.md-table td:hover, .md-table th:hover { background: var(--hover-wash); }
.md-table td:empty::before, .md-table th:empty::before { content: "—"; color: var(--mute); }
.md-table td.editing:empty::before, .md-table th.editing:empty::before { content: ""; }
.md-tablewrap { padding: 0; margin: 4px 0 14px; }
.md-tablewrap .md-table { margin: 0; }
.md-addrow { margin-top: 6px; background: none; border: 0; padding: 2px 4px; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.md-addrow:hover { text-decoration: underline; }
.md-tail { min-height: 34px; margin-top: 10px; color: var(--text2); }
.md-tail:empty::before { content: attr(data-placeholder); color: var(--mute); }
.md-tail.editing:empty::before { content: ""; }

/* ------------------------------------------------------------------ login (auth.js): the cloud board only */
.login { position: fixed; inset: 0; z-index: 500; display: flex; overflow: auto; padding: 24px 16px; background: var(--bg); }
.login-box { margin: auto; width: min(340px, 100%); display: flex; flex-direction: column; gap: 14px; padding-bottom: 6vh; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--dim); font-size: 13px; font-weight: 650; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; padding: 20px; background: var(--dialog-bg);
  border: 1px solid var(--line2); border-radius: 11px; box-shadow: 0 10px 30px var(--shadow-toast);
}
.login-title { font-size: 14px; font-weight: 650; }
.login-sub { margin-top: -4px; color: var(--dim); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field .inp { width: 100%; height: 32px; font-size: 13px; }
.login-policy { color: var(--mute); font-size: 11.5px; line-height: 1.4; }
.login-msg { color: var(--err); font-size: 12px; line-height: 1.4; }
.login-msg.ok { color: var(--ok); }
.login-msg:empty { display: none; }
.login-go { width: 100%; height: 32px; justify-content: center; margin-top: 2px; }
.login-link { align-self: center; padding: 2px 4px; border: 0; background: none; color: var(--dim); font-size: 12px; }
.login-link:hover { color: var(--accent); }
:root.login-on .toasts { z-index: 600; bottom: 16px; }
@media (max-width: 600px) {   /* 16px fields: phones don't zoom in on focus */
  .login-field .inp { height: 40px; font-size: 16px; }
  .login-go { height: 40px; font-size: 14px; }
}
