:root {
  --bg: #0a0610;
  --bg-2: #0f0818;
  --panel: #150d21;
  --panel-2: #1b1129;
  --panel-3: #221635;
  --line: #2e2042;
  --line-soft: #241a36;
  --text: #efe9fb;
  --text-dim: #b8a9d1;
  --text-faint: #8b7ba6;
  --violet: #a855f7;
  --violet-bright: #c084fc;
  --violet-deep: #7c3aed;
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #fb7185;
  --bad-soft: rgba(251, 113, 133, 0.12);
  --info: #7dd3fc;
  --info-soft: rgba(125, 211, 252, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --mono: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(168, 85, 247, 0.16), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-dim); }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75em; }
small { font-size: 0.78rem; }
a { color: var(--violet-bright); }

:focus-visible {
  outline: 2px solid var(--violet-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--violet-deep);
  color: #fff;
  z-index: 100;
  border-radius: 0 0 10px 0;
}
.skip:focus { left: 0; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 6, 16, 0.72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: 0.01em; }
.brand small { display: block; color: var(--text-faint); font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 6px 16px rgba(168, 85, 247, 0.45)); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  background: rgba(34, 22, 53, 0.7);
  white-space: nowrap;
}
.chip-good { color: var(--good); border-color: rgba(74, 222, 128, 0.35); background: var(--good-soft); }
.chip-warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: var(--warn-soft); }
.chip-bad { color: var(--bad); border-color: rgba(251, 113, 133, 0.35); background: var(--bad-soft); }

/* ------------------------------------------------------------------ layout */
.layout {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 28px);
  display: grid;
  grid-template-columns: minmax(300px, 366px) minmax(0, 1fr);
  gap: clamp(14px, 1.8vw, 22px);
  align-items: start;
}

.panel {
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.queue { padding: 18px; position: sticky; top: 92px; }
.detail { padding: 22px; min-height: 420px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { margin: 0; }
.count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--violet-bright);
  background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 2px 9px;
  border-radius: 999px;
}

.queue-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 12px; }

.queue-stats {
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-faint);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}
.queue-stats strong { color: var(--text); font-family: var(--mono); font-weight: 600; }

.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: min(58vh, 620px); overflow-y: auto; }
.queue-list::-webkit-scrollbar { width: 8px; }
.queue-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.queue-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.queue-item:hover { background: var(--panel-3); border-color: var(--line); }
.queue-item.is-selected {
  background: linear-gradient(100deg, rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0.06));
  border-color: rgba(192, 132, 252, 0.55);
}
.queue-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.queue-title { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-meta { font-size: 0.74rem; color: var(--text-faint); }

.mini-bar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 2px 4px 6px; }
.mini-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--violet-bright)); transition: width 0.4s ease; }

.empty-note { color: var(--text-faint); font-size: 0.85rem; padding: 14px 4px; }
.queue-foot { margin: 14px 0 0; font-size: 0.72rem; color: var(--text-faint); border-top: 1px solid var(--line-soft); padding-top: 12px; }

/* ------------------------------------------------------------------- pills */
.pill {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
  flex: none;
}
.pill-good { color: var(--good); border-color: rgba(74, 222, 128, 0.4); background: var(--good-soft); }
.pill-warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); background: var(--warn-soft); }
.pill-bad { color: var(--bad); border-color: rgba(251, 113, 133, 0.4); background: var(--bad-soft); }
.pill-info { color: var(--info); border-color: rgba(125, 211, 252, 0.4); background: var(--info-soft); }
.pill-muted { color: var(--text-faint); }

/* ------------------------------------------------------------------ buttons */
.btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: #2a1c40; }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--violet-deep));
  border-color: rgba(192, 132, 252, 0.6);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #b467fa, var(--violet-deep)); }
.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--panel-3); }
.btn-danger { color: var(--bad); border-color: rgba(251, 113, 133, 0.4); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn-sm { font-size: 0.78rem; padding: 6px 10px; border-radius: 8px; }
.btn-icon { padding: 6px 9px; }

/* ------------------------------------------------------------------- empty */
.detail-empty { max-width: 62ch; padding: 26px 8px; }
.detail-empty h2 { text-transform: none; letter-spacing: -0.01em; font-size: 1.5rem; color: var(--text); }
.detail-empty p { color: var(--text-dim); }
.detail-empty-list { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.detail-empty-list li { padding: 10px 14px; border-left: 2px solid var(--violet); background: rgba(168, 85, 247, 0.06); border-radius: 0 8px 8px 0; font-size: 0.9rem; color: var(--text-dim); }
.detail-empty-list strong { color: var(--text); }

/* ------------------------------------------------------------- episode view */
.ep-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.ep-title { font-size: clamp(1.25rem, 2.4vw, 1.7rem); margin: 0 0 6px; letter-spacing: -0.015em; }
.ep-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.82rem; color: var(--text-faint); }
.ep-meta .dot::before { content: "·"; margin-right: 8px; color: var(--line); }
.ep-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge-sample { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); background: var(--warn-soft); }
.badge-estimated { color: var(--info); border-color: rgba(125, 211, 252, 0.45); background: var(--info-soft); }

.grid { display: grid; gap: 16px; margin-top: 18px; }
.grid-2 { grid-template-columns: minmax(0, 1fr); }

.card {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px;
}
.card > h3 { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 12px; }
.card > h3 .step { font-family: var(--mono); font-size: 0.7rem; color: var(--violet-bright); border: 1px solid rgba(168, 85, 247, 0.35); background: rgba(168, 85, 247, 0.1); padding: 1px 6px; border-radius: 5px; }

/* ---------------------------------------------------------------- progress */
.stage-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.86rem; color: var(--text-dim); margin-bottom: 8px; }
.stage-line strong { color: var(--text); }
.progress {
  height: 9px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet-deep), var(--violet-bright));
  transition: width 0.45s ease;
}
.progress.is-failed > span { background: linear-gradient(90deg, #9f1239, var(--bad)); }
.progress.is-done > span { background: linear-gradient(90deg, #15803d, var(--good)); }

.log {
  margin: 12px 0 0;
  padding: 10px 12px;
  list-style: none;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-dim);
  max-height: 168px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
}
.log li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; }
.log time { color: var(--text-faint); }
.log li.is-error { color: var(--bad); }

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  border: 1px solid rgba(251, 113, 133, 0.4);
  background: var(--bad-soft);
  color: #ffd7de;
  margin-top: 12px;
}
.alert strong { color: #fff; }
.alert-info { border-color: rgba(125, 211, 252, 0.35); background: var(--info-soft); color: #d5f1fd; }
.alert-warn { border-color: rgba(251, 191, 36, 0.35); background: var(--warn-soft); color: #fde9b8; }

/* ------------------------------------------------------------------ upload */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  color: var(--text-dim);
  background: rgba(168, 85, 247, 0.03);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--violet); background: rgba(168, 85, 247, 0.09); }
.dropzone strong { color: var(--text); display: block; margin-bottom: 2px; }
.dropzone small { color: var(--text-faint); }
.dropzone input[type="file"] { display: none; }
.dropzone-progress { margin-top: 12px; }

.source-info { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--text-faint); margin-top: 12px; font-family: var(--mono); }
.source-info strong { color: var(--text-dim); font-weight: 500; }

/* ------------------------------------------------------------------- forms */
label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 12px; }
label .hint { display: block; font-size: 0.74rem; color: var(--text-faint); margin-top: 4px; }

input[type="text"], input[type="date"], textarea, select {
  width: 100%;
  margin-top: 5px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
textarea.transcript { min-height: 180px; font-family: var(--mono); font-size: 0.8rem; }
input:focus, textarea:focus, select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
  outline: none;
}
input[type="checkbox"] { accent-color: var(--violet); width: 16px; height: 16px; }

.check-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.check-row label { margin: 0; font-size: 0.84rem; color: var(--text-dim); }
.check-row input { margin-top: 2px; flex: none; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--bad); font-size: 0.82rem; margin: 8px 0 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* -------------------------------------------------------------- deliverables */
.deliverables { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 10px; }
.deliverable {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.deliverable:hover { border-color: rgba(192, 132, 252, 0.5); transform: translateY(-1px); }
.deliverable-kind { font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--violet-bright); }
.deliverable-name { font-family: var(--mono); font-size: 0.8rem; word-break: break-all; color: var(--text); }
.deliverable-meta { font-size: 0.72rem; color: var(--text-faint); display: flex; gap: 10px; flex-wrap: wrap; }
.deliverable-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

.player-wrap { margin-top: 4px; }
audio { width: 100%; height: 34px; filter: invert(0.92) hue-rotate(230deg); border-radius: 8px; }
video.clip-player { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #000; }

.media-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* -------------------------------------------------------------------- notes */
.notes { font-size: 0.9rem; color: var(--text-dim); }
.notes h1 { font-size: 1.3rem; color: var(--text); margin-top: 0.2em; }
.notes h2 { font-size: 0.86rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--violet-bright); margin-top: 1.5em; }
.notes h3 { font-size: 0.92rem; color: var(--text); }
.notes h4 { font-size: 0.86rem; color: var(--text); }
.notes strong { color: var(--text); }
.notes ul { padding-left: 1.1em; display: grid; gap: 5px; margin: 0 0 1em; }
.notes li::marker { color: var(--violet); }
.notes blockquote { margin: 0 0 1em; padding: 6px 0 6px 14px; border-left: 2px solid var(--violet); color: var(--text); font-style: italic; }
.notes blockquote p { margin: 0 0 2px; }
.notes code { font-family: var(--mono); font-size: 0.85em; background: var(--bg-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-soft); color: var(--violet-bright); }
.notes hr { border: none; border-top: 1px solid var(--line-soft); margin: 1.4em 0; }
.notes .table-wrap { overflow-x: auto; margin-bottom: 1em; }
.notes table { border-collapse: collapse; font-size: 0.82rem; width: 100%; }
.notes th, .notes td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.notes th { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.notes .num { color: var(--violet-bright); font-family: var(--mono); }

details.disclosure { border: 1px solid var(--line-soft); border-radius: 10px; padding: 0; background: var(--panel-2); margin-top: 12px; }
details.disclosure > summary {
  cursor: pointer;
  padding: 11px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; color: var(--violet-bright); font-family: var(--mono); }
details.disclosure[open] > summary::after { content: "–"; }
details.disclosure[open] > summary { border-bottom: 1px solid var(--line-soft); }
details.disclosure .disclosure-body { padding: 14px; }

/* ---------------------------------------------------------------- revisions */
.revision-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.revision-list li { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 12px; font-size: 0.85rem; color: var(--text-dim); }
.revision-list time { display: block; font-family: var(--mono); font-size: 0.7rem; color: var(--text-faint); margin-bottom: 4px; }

/* ------------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(90vw, 560px);
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(251, 113, 133, 0.5); }

/* ------------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 3, 12, 0.72);
  backdrop-filter: blur(3px);
  z-index: 40;
}
.modal {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 540px);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(170deg, var(--panel-3), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h2 { text-transform: none; letter-spacing: -0.01em; font-size: 1.2rem; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
[hidden] { display: none !important; }

/* -------------------------------------------------------------------- foot */
.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 14px clamp(16px, 3vw, 34px);
  border-top: 1px solid var(--line-soft);
  font-size: 0.74rem;
  color: var(--text-faint);
}
#foot-status { font-family: var(--mono); }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .queue { position: static; }
  .queue-list { max-height: 300px; }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .topbar { padding: 12px 14px; }
  .chips { width: 100%; }
  .layout { padding: 12px; }
  .detail, .queue { padding: 14px; }
  .ep-head { flex-direction: column; }
  .ep-actions { width: 100%; }
  .ep-actions .btn { flex: 1 1 auto; }
  .field-row { grid-template-columns: 1fr; }
  .queue-actions { grid-template-columns: 1fr; }
  .deliverables { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  .btn, .card, .deliverable, .panel { border: 1px solid ButtonText; }
}

/* --------------------------------------------------------------- login page */
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-brand { margin-bottom: 18px; }

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.login-card form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-card form .btn { width: 100%; justify-content: center; }

.login-error { margin: 12px 0 0; }

.login-foot {
  margin: 18px 0 0;
  color: var(--text-faint);
  font-size: 0.82rem;
}
