/* ───────── tokens ───────── */
:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-2: #151820;
  --panel: #1a1d26;
  --panel-2: #20242f;
  --raised: #272c39;
  --line: #2c3140;
  --line-2: #394052;
  --text: #e9ecf3;
  --text-2: #b4bacb;
  --text-3: #7d8499;
  --accent: #6c8cff;
  --accent-2: #8aa3ff;
  --accent-ink: #0b1030;
  --rec: #ff4d5e;
  --ok: #46d18a;
  --warn: #ffbf47;
  --danger: #ff5c6c;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
kbd {
  font: 11px var(--mono);
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap { gap: 12px; }
.gap-sm { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { display: inline-flex; flex: none; }

/* ───────── controls ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  user-select: none;
}
.btn:hover:not(:disabled) { background: var(--raised); border-color: #4a5268; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover:not(:disabled) { background: #ff7380; border-color: #ff7380; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; }
.btn-ghost.active { color: var(--accent-2); background: rgba(108, 140, 255, 0.12); }
.btn.danger { color: var(--danger); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-xs { height: 22px; width: 22px; padding: 0; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 15px; }
.btn-xl { height: 56px; font-size: 17px; font-weight: 600; width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-xs { width: 22px; }
.btn-rec { background: var(--rec); border-color: var(--rec); color: #fff; font-weight: 600; }
.btn-rec:hover:not(:disabled) { background: #ff6b7a; border-color: #ff6b7a; }
.btn-rec.recording { animation: pulse 1.2s ease-in-out infinite; }
.btn.busy { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 77, 94, 0.25); } }

.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18); }
.input.invalid { border-color: var(--danger); }
.input-sm { height: 28px; font-size: 12.5px; }
.input-time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
select.input { padding-right: 4px; }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; min-height: 38px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.range { width: 100%; accent-color: var(--accent); }
.range-sm { width: 80px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: var(--bg-2); border: 0; padding: 5px 11px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.bar { height: 6px; background: var(--raised); border-radius: 99px; overflow: hidden; flex: 1; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.25s; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--raised);
  color: var(--text-2);
  margin-left: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.callout {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.4;
  flex-wrap: wrap;
}
.callout .icon { margin-top: 1px; }
.callout > span:not(.icon) { flex: 1; min-width: 160px; }
.callout-warn { background: rgba(255, 191, 71, 0.1); color: #ffd58a; border: 1px solid rgba(255, 191, 71, 0.25); }
.callout-error { background: rgba(255, 92, 108, 0.1); color: #ffadb5; border: 1px solid rgba(255, 92, 108, 0.3); }
.callout-ok { background: rgba(70, 209, 138, 0.08); color: #9ce8bf; border: 1px solid rgba(70, 209, 138, 0.25); }

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 6px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #10131a;
  cursor: pointer;
  flex: none;
  padding: 0;
}
.avatar.me { box-shadow: 0 0 0 2px var(--line-2); }
.avatar.recording { box-shadow: 0 0 0 2px var(--rec); animation: pulse 1.2s infinite; }
.avatars { display: flex; flex: none; }
.avatars .avatar + .avatar { margin-left: -8px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }

/* ───────── modal / toast / menu ───────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fade 0.15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop 0.16s ease-out;
}
.modal-wide { width: min(620px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal-title { padding: 18px 20px 0; font-size: 17px; }
.modal-body { padding: 14px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }

#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: min(520px, calc(100vw - 32px));
}
.toast {
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 100%;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }

.menu {
  position: fixed;
  z-index: 150;
  min-width: 190px;
  max-height: 60vh;
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 5px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--raised); outline: none; }
.menu-item:disabled { opacity: 0.4; cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu-color { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; }
.menu-color i { width: 14px; height: 14px; border-radius: 50%; }

/* ───────── home ───────── */
.home { max-width: 1180px; margin: 0 auto; padding: 0 24px 60px; }
.home-top { display: flex; align-items: center; padding: 18px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #ff5d6e, #ff8a5c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.brand-name { font-weight: 700; font-size: 16px; }
.home-hero {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 440px);
  gap: 32px;
  align-items: start;
  padding: 30px 0 40px;
  border-bottom: 1px solid var(--line);
}
.hero-text { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.hero-text p { max-width: 560px; font-size: 15px; }
.steps { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.new-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drop {
  border: 2px dashed var(--line-2);
  border-radius: 12px;
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  word-break: break-word;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(108, 140, 255, 0.06); }
.drop.has-file { border-style: solid; border-color: rgba(108, 140, 255, 0.5); }
.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.home-list { padding-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #07080b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-state { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; }
.thumb-state.error { color: var(--danger); }
.thumb-dur, .thumb-online {
  position: absolute;
  bottom: 8px;
  font-size: 11.5px;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 7px;
  border-radius: 6px;
}
.thumb-dur { right: 8px; }
.thumb-online { left: 8px; display: flex; align-items: center; gap: 5px; }
.thumb-online i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card-more { margin: -6px -8px -6px 0; }
.card-progress { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.card-progress .bar > div { background: var(--ok); }
.empty-list { padding: 24px; text-align: center; border: 1px dashed var(--line-2); border-radius: 12px; }

/* ───────── editor layout ───────── */
.editor {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 6px var(--tl-h, 34vh);
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.editor > *, .workspace > * { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  min-width: 0;
}
.brand-mini {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #ff5d6e, #ff8a5c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.project-name {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-weight: 650;
  font-size: 15px;
  cursor: text;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-name:hover { border-color: var(--line-2); }
.conn { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); white-space: nowrap; }
.conn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(70, 209, 138, 0.18); }
.conn.down { color: var(--warn); }
.topbar .avatars { margin-right: 6px; }
.topbar > .btn { flex: none; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 420px); min-height: 0; }
.stage-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #050608; }
.stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; cursor: pointer; }
.subs {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(90%, 900px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.sub-line {
  background: rgba(0, 0, 0, 0.72);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: clamp(13px, 1.5vw, 18px);
  text-align: center;
  max-width: 100%;
}
.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8, 10, 14, 0.92);
  text-align: center;
  padding: 24px;
}
.stage-msg .bar { width: min(320px, 70%); flex: none; }
.stage-msg-error { color: var(--danger); }

.transport {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  min-width: 0;
  overflow-x: auto;
}
.btn-play { width: 40px; height: 40px; border-radius: 50%; background: var(--text); color: var(--bg); border: 0; }
.btn-play:hover:not(:disabled) { background: #fff; }
.timecode { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.mix { display: flex; align-items: center; gap: 6px; }

.overlay { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.overlay-big {
  font-size: clamp(60px, 12vw, 150px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
}
.overlay-rec {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 12px;
  border-radius: 99px;
  font-weight: 700;
  color: #fff;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.prompter {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(92%, 900px);
  background: rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  padding: 12px 18px 14px;
  border-top: 3px solid var(--c);
}
.prompter-name { color: var(--c); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.prompter-text { font-size: clamp(16px, 2.2vw, 26px); font-weight: 600; line-height: 1.3; margin-top: 4px; }
.prompter-bar { height: 5px; background: rgba(255, 255, 255, 0.15); border-radius: 9px; margin-top: 10px; overflow: hidden; }
.prompter-bar > div { height: 100%; background: var(--rec); }
.prompter-bar.over > div { background: var(--warn); }

.splitter { background: var(--line); cursor: row-resize; position: relative; }
.splitter::after { content: ''; position: absolute; left: 50%; top: 1px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line-2); }
.splitter:hover { background: var(--accent); }
.timeline-slot { min-height: 0; }

/* ───────── sidebar ───────── */
.sidebar { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; flex: none; }
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 12px 9px;
  cursor: pointer;
  color: var(--text-3);
  font-weight: 600;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.sidebar-body { flex: 1; overflow-y: auto; min-height: 0; }

.empty-panel { padding: 28px 22px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.shortcuts-mini { display: grid; gap: 6px; margin-top: 10px; text-align: left; }

.line-view { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--track); }
.line-head { display: flex; align-items: flex-end; gap: 4px; }
.line-text { min-height: 86px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.others-here { display: flex; gap: 6px; flex-wrap: wrap; }
.takes { display: flex; flex-direction: column; gap: 6px; }
.takes-empty { padding: 10px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); text-align: center; }
.take {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.take.active { border-color: color-mix(in srgb, var(--track) 60%, var(--line)); background: color-mix(in srgb, var(--track) 8%, var(--bg-2)); }
.take-pick {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  background: none;
  cursor: pointer;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.take.active .take-pick { background: var(--track); border-color: var(--track); color: #10131a; cursor: default; }
.take-info { flex: 1; min-width: 0; }
.take .btn-icon { width: 28px; height: 28px; }

/* script tab */
.script-view { display: flex; flex-direction: column; min-height: 100%; }
.script-filters { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.script-filters select { width: auto; max-width: 160px; }
.script-progress { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.script-progress .bar > div { background: var(--ok); }
.script-list { flex: 1; padding: 0 6px 8px; }
.script-row {
  display: grid;
  grid-template-columns: 52px 1fr 24px;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 3px solid var(--track);
  margin-bottom: 2px;
}
.script-row:hover { background: var(--panel-2); }
.script-row.selected { background: color-mix(in srgb, var(--track) 14%, var(--panel-2)); }
.script-row.current .script-time { color: var(--accent-2); font-weight: 700; }
.script-time { color: var(--text-3); padding-top: 1px; }
.script-name { color: var(--track); font-weight: 650; }
.script-text { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.script-status { color: var(--text-3); display: flex; justify-content: center; padding-top: 2px; }
.script-status.done { color: var(--ok); }
.trash { margin: 0 12px 10px; }
.trash summary { cursor: pointer; padding: 6px 0; }
.trash-row { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.quick-add {
  position: sticky;
  bottom: 0;
  padding: 10px 12px 12px;
  background: var(--panel-2);
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-add .section-title { margin: 0; }
.quick-grid { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr; gap: 8px; }

/* record panel */
.record-panel { padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--rec); }
.rec-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--rec); }
.rec-head { display: flex; flex-direction: column; gap: 8px; }
.rec-who { display: flex; align-items: center; gap: 8px; font-weight: 650; flex-wrap: wrap; }
.rec-who .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--track); }
.rec-text {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--track);
  background: var(--bg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.rec-body { display: flex; flex-direction: column; gap: 12px; }
.meter { position: relative; height: 10px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 70%, var(--warn) 85%, var(--rec) 100%);
  background-size: 300px 100%;
  border-radius: 99px;
}
.meter-peak { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; opacity: 0.8; }
.meter.clip { box-shadow: 0 0 0 2px var(--rec); }
.rec-settings { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; }
.rec-settings summary { cursor: pointer; padding: 9px 0; color: var(--text-2); font-weight: 600; }
.rec-settings[open] { padding-bottom: 12px; }
.rec-settings > :not(summary) + :not(summary) { margin-top: 10px; }
.rec-settings .input-sm { width: 100px; }
.rec-review { display: flex; flex-direction: column; gap: 10px; }
.rec-wave { width: 100%; height: 60px; background: var(--bg-2); border-radius: var(--radius-sm); }

/* export */
.export { display: flex; flex-direction: column; gap: 14px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.choice.active { border-color: var(--accent); background: rgba(108, 140, 255, 0.08); }
.choice input { accent-color: var(--accent); margin-top: 3px; }
.choice-title { font-weight: 650; margin-bottom: 2px; }
.chip-check { padding: 4px 10px 4px 8px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.chip-check input { accent-color: var(--c); }
.job { padding: 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.job-error { border-color: rgba(255, 92, 108, 0.4); }
.error-log { margin: 0; font: 11px/1.4 var(--mono); white-space: pre-wrap; max-height: 140px; overflow: auto; color: #ffadb5; }
.exports { display: flex; flex-direction: column; gap: 8px; }
.export-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.export-row .badge { margin: 0; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; align-items: center; }
.shortcuts kbd { justify-self: start; }

/* ───────── timeline ───────── */
.timeline { height: 100%; display: flex; flex-direction: column; background: var(--bg); min-height: 0; }
.tl-toolbar { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex: none; min-width: 0; }
.tl-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tl-zoom-label { min-width: 62px; text-align: center; }
.tl-scroll { flex: 1; overflow: auto; position: relative; min-height: 0; overscroll-behavior: contain; }
.tl-inner { position: relative; min-height: 100%; min-width: 100%; }
.tl-ruler-row { position: sticky; top: 0; z-index: 5; display: flex; height: 28px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tl-corner { position: sticky; left: 0; width: 200px; flex: none; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; align-items: center; padding: 0 12px; z-index: 2; }
.tl-ruler { position: sticky; left: 200px; display: block; cursor: col-resize; }
.tl-row { display: flex; height: 68px; border-bottom: 1px solid var(--line); }
.tl-row.inaudible .tl-lane { opacity: 0.45; }
.tl-th {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 200px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  border-left: 4px solid var(--track, transparent);
  padding: 6px 8px 6px 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.tl-add-row { height: 50px; border-bottom: 0; }
.tl-add-row .tl-th { border-left-color: transparent; align-items: flex-start; }
.tl-th-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tl-th-dot { width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; flex: none; }
.tl-th-name { flex: 1; min-width: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.tl-th-bottom { display: flex; align-items: center; gap: 4px; }
.tl-ms {
  width: 22px;
  height: 20px;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
  flex: none;
}
.tl-ms.on:first-child { background: var(--warn); color: #221a00; border-color: var(--warn); }
.tl-ms.on:nth-child(2) { background: var(--ok); color: #002211; border-color: var(--ok); }
.tl-vol { flex: 1; min-width: 0; accent-color: var(--track); height: 14px; }
.tl-vol-label { width: 44px; text-align: right; font-size: 10.5px; font-family: var(--mono); }
.tl-lane { position: relative; flex: 1; background-image: linear-gradient(90deg, transparent, transparent); }
.tl-lane:not(.tl-lane-empty):hover { background: rgba(255, 255, 255, 0.015); }

.clip {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--track) 22%, var(--bg-2));
  border: 1px dashed color-mix(in srgb, var(--track) 70%, transparent);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  min-width: 4px;
}
.clip.voiced { background: color-mix(in srgb, var(--track) 42%, var(--bg-2)); border-style: solid; }
.clip:hover { filter: brightness(1.12); }
.clip.selected { box-shadow: 0 0 0 2px var(--text); z-index: 2; }
.clip.dragging { cursor: grabbing; opacity: 0.88; z-index: 3; box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgba(0, 0, 0, 0.5); }
.clip.remote-sel { outline: 2px solid var(--remote); outline-offset: 1px; }
.clip.remote-rec { outline-color: var(--rec); animation: pulse 1.2s infinite; }
.clip-wave { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.clip-body { position: absolute; inset: 0; padding: 4px 9px; display: flex; flex-direction: column; gap: 1px; pointer-events: none; }
.clip-meta { font-size: 10px; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-text { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); overflow-wrap: anywhere; }
.clip-text.empty { color: rgba(255, 255, 255, 0.45); font-style: italic; font-weight: 400; }
.clip.narrow .clip-body { display: none; }
.clip-handle { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 1; }
.clip-handle-l { left: 0; }
.clip-handle-r { right: 0; }
.clip-handle:hover { background: rgba(255, 255, 255, 0.18); }
.clip-tag {
  position: absolute;
  right: 3px;
  top: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 4px;
  color: #10131a;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip-tag:empty { display: none; }

.tl-playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--accent); z-index: 6; pointer-events: none; will-change: transform; }
.tl-playhead-cap { position: absolute; top: 0; left: -6px; width: 14px; height: 12px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 100%, 0 50%); }
.tl-snap { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--warn); z-index: 6; pointer-events: none; display: none; }
.tl-remote-heads { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.tl-rhead { position: absolute; top: 28px; bottom: 0; width: 0; border-left: 2px dashed var(--c); opacity: 0.7; }
.tl-rhead.playing { border-left-style: solid; }
.tl-rhead-label {
  position: absolute;
  top: 0;
  left: 2px;
  font-size: 10px;
  font-weight: 700;
  background: var(--c);
  color: #10131a;
  padding: 0 4px;
  border-radius: 0 4px 4px 0;
  white-space: nowrap;
}

/* ───────── responsive ───────── */
@media (max-width: 980px) {
  .home-hero { grid-template-columns: 1fr; }
  .editor { height: auto; min-height: 100dvh; grid-template-rows: auto auto 6px 420px; overflow: visible; }
  .workspace { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 16 / 9; flex: none; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); max-height: 70vh; }
  .project-name { max-width: 40vw; }
  .tl-hint { display: none; }
  .topbar { overflow-x: auto; }
}
@media (max-width: 600px) {
  .home { padding: 0 16px 40px; }
  .brand-mini, .topbar .hide-sm { display: none; }
  .topbar .btn-primary .label { display: none; }
  .topbar .btn-primary { width: 34px; padding: 0; }
  .choices, .quick-grid { grid-template-columns: 1fr; }
  .mix .range-sm { width: 56px; }
}
