@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&family=Noto+Serif+SC:wght@500;600;700&display=swap");

:root {
  --bg: #0e0d0b;
  --bg-2: #17150f;
  --surface: #1f1c16;
  --ink: #f3eee3;
  --muted: #a89e8b;
  --line: #342f24;
  --accent: #d4b24a;
  --accent-soft: rgba(212, 178, 74, 0.14);
  --accent-ink: #1a160c;
  --danger: #d46a4a;
  --ok: #7a9e6a;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --font: "Noto Serif SC", "Songti SC", Palatino, serif;
  --ui: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(920px 420px at 88% -8%, rgba(212, 178, 74, 0.09), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--ui);
}
h1, h2, h3 { font-family: var(--font); font-weight: 600; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: var(--radius-sm); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
input, textarea, select { border-radius: var(--radius-sm); }
a { color: var(--ink); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.workbench {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.wb-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 52px;
  flex: 0 0 52px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.wb-nav .brand-kicker { font-size: 12px; }
.wb-nav-title {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
}
.wb-nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.wb-nav-right a { color: var(--muted); text-decoration: none; }
.wb-nav-right a:hover { color: var(--ink); }
.wb-nav-right #user-email { color: var(--ink); }
.wb-nav-right .ghost {
  padding: 4px 10px;
  font-size: 13px;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.rail {
  border-right: 1px solid var(--line);
  padding: 16px 14px 12px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
}

.rail-label {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--mono);
  text-decoration: none;
}

.create-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
.create-card input[type="url"],
.create-card input[type="text"],
.create-card input[type="number"],
.create-card select,
.create-card button[type="submit"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.create-card input[type="url"],
.create-card input[type="text"],
.create-card input[type="number"],
.create-card select {
  appearance: none;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 11px;
}
.create-card select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23d4b24a' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.create-card input[type="checkbox"] { width: auto; }
.create-card input:focus,
.create-card select:focus {
  border-color: var(--accent);
  outline: none;
}
.lang-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
.lang-row label {
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lang-arrow {
  color: var(--muted);
  padding-bottom: 10px;
}
.create-more {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px 8px;
  background: var(--bg);
}
.create-more summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 0;
  font-size: 13px;
  color: var(--muted);
}
.create-more summary::-webkit-details-marker { display: none; }
.create-more summary::after { content: " +"; color: var(--accent); }
.create-more[open] summary::after { content: " –"; }
.create-more .check,
.create-more > label { margin-top: 6px; }

.file-drop {
  border: 1px dashed var(--line);
  padding: 16px 12px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.file-drop:hover { border-color: var(--accent); color: var(--ink); }
.file-drop input { display: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-2 label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.check { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
button[type="submit"], .editor-actions button:first-child {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 10px 14px;
  font-weight: 600;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 12px;
}
.ghost:hover { background: var(--accent-soft); }

.job-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.job-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; }
.job-list li {
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
}
.job-list li:hover { background: var(--surface); }
.job-list li.active {
  background: var(--accent-soft);
  border-color: var(--line);
}
.job-list .id { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.job-list .st { font-size: 12px; color: var(--muted); }

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr);
  gap: 0;
  flex: 1;
  min-height: 0;
}

.player-block {
  padding: 18px 22px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.player-meta, .editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.player-meta { margin-bottom: 12px; }
#job-title { margin: 0; font-size: 20px; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.player-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.toggle button { border: 0; background: transparent; padding: 8px 12px; border-radius: 0; }
.toggle button.active { background: var(--accent); color: var(--accent-ink); }

.screen {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-height: min(52vh, 560px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.screen video { width: 100%; height: 100%; object-fit: contain; color-scheme: dark; }
.progress-overlay {
  position: absolute;
  inset: auto 16px 16px;
  background: rgba(14, 13, 11, 0.9);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.progress-overlay.hidden, .hidden { display: none; }
.bar { height: 3px; background: var(--line); margin-bottom: 8px; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
#progress-text { margin: 0; font-size: 12px; font-family: var(--mono); color: var(--ink); }

.editor {
  border-left: 1px solid var(--line);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  background: var(--bg-2);
}
.editor textarea {
  width: 100%;
  min-height: 88px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 10px;
  resize: vertical;
}
.editor label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.metrics div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.metrics em { display: block; font-style: normal; font-size: 18px; font-family: var(--font); }
.metrics span { font-size: 11px; color: var(--muted); }
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}
.editor-actions button { margin: 0; }
.preview-audio { width: 100%; }
.msg { min-height: 1.2em; font-size: 13px; color: var(--accent); margin: 0; }
.msg.error { color: var(--danger); }

.timeline-wrap {
  border-top: 1px solid var(--line);
  padding: 12px 22px 14px;
  background: var(--bg-2);
  flex: 0 0 auto;
}
.timeline-wrap header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.timeline-wrap h2 { margin: 0; font-size: 14px; font-weight: 600; }
.timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 4px;
}
.cue {
  min-width: 160px;
  max-width: 220px;
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--surface);
  cursor: pointer;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
}
.cue.active { border-color: var(--accent); background: var(--accent-soft); }
.cue .t { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.cue .en, .cue .zh {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cue .zh { color: var(--muted); }

@media (max-width: 1100px) {
  body.workbench { height: auto; overflow: auto; }
  .app, .stage, .workspace { display: block; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .screen { max-height: none; }
  .wb-nav { height: auto; flex-wrap: wrap; padding: 10px 16px; }
}
