:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #21252e;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a7;
  --accent: #6aa6ff;
  --accent-2: #8ad2ff;
  --danger: #ff6b6b;
  --success: #5fd39f;
  --warn: #f5c451;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 2px 0 14px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.sidebar-actions button { flex: 1; }

.progress {
  color: var(--muted);
  font-size: 12px;
}

.render-status {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
}

.render-status.hidden { display: none; }
.render-status .row { display: flex; align-items: center; gap: 8px; }
.render-status a { color: var(--accent); text-decoration: none; }
.render-status a:hover { text-decoration: underline; }
.render-status.error { border-color: var(--danger); color: var(--danger); white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }

.scene-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.scene-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
  cursor: pointer;
  border-left: 3px solid transparent;
  font: inherit;
}

.scene-item:hover { background: var(--panel-2); }

.scene-item.active {
  background: var(--panel-2);
  border-left-color: var(--accent);
}

.scene-item .num {
  color: var(--muted);
  min-width: 24px;
  font-variant-numeric: tabular-nums;
}

.scene-item .title {
  flex: 1;
  font-size: 13.5px;
}

.scene-item .status {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.scene-item.recorded .status { color: var(--success); }
.scene-item .status.missing { color: var(--muted); }

.stage {
  overflow-y: auto;
  padding: 28px 36px;
  position: relative;
}

.stage-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
}

.stage-content.hidden, .overlay.hidden, .stage-empty.hidden { display: none; }

.stage-top {
  margin-bottom: 18px;
}

.scene-meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.scene-number {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
  font-size: 14px;
}

.scene-meta h2 {
  margin: 0;
  font-size: 22px;
}

.scene-duration {
  color: var(--muted);
  font-size: 13px;
}

.stage-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  margin-bottom: 20px;
}

.scene-image-wrap {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  align-self: start;
}

.scene-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.scene-script {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.scene-script h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#scene-text {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.65;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-row, .nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-row {
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
}

button:hover:not(:disabled) { background: #2a2f3a; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary { background: var(--accent); color: #0b1220; border-color: transparent; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-2); }
button.secondary { background: transparent; border-color: var(--accent); color: var(--accent); }
button.record { background: var(--danger); color: #1b0000; border-color: transparent; font-weight: 600; }
button.record.recording { background: #a82323; color: #fff; animation: pulse 1.2s infinite; }
button.stop { background: #3a3f4d; }
button.playback { }
button.danger { color: var(--danger); background: transparent; border-color: var(--danger); }
button.ghost { background: transparent; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255, 107, 107, 0); }
}

.rec-status {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

audio {
  width: 100%;
  filter: invert(0.88) hue-rotate(180deg);
}

.overlay {
  position: fixed;
  inset: 0;
  background: #000d;
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 10;
}

.overlay-inner {
  width: min(90vw, 1100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.overlay-inner img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.overlay-caption {
  color: var(--text);
  text-align: center;
}

#overlay-title { font-size: 20px; font-weight: 600; }
#overlay-progress { color: var(--muted); font-size: 13px; margin-top: 4px; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stage-body { grid-template-columns: 1fr; }
}
