:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --accent: #3d9cf0;
  --accent-2: #2ecc71;
  --warn: #f0a030;
  --danger: #e74c3c;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent); }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
}
header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 650;
}
header .tag {
  color: var(--muted);
  font-size: 0.9rem;
}

.latency {
  background: #243044;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.25rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea,
input[type="file"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}
input[type="file"] { padding: 0.4rem; }
textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.4;
}

.toggle-row {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.toggle-row input { width: auto; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  align-items: center;
}

button {
  background: var(--accent);
  color: #041018;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger { background: var(--danger); color: #fff; }

.hls-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.hls-box[hidden] { display: none; }
.hls-box label { flex: 1 1 16rem; }
.hls-box input { font-family: var(--mono); font-size: 0.8rem; }

#status {
  font-size: 0.9rem;
  color: var(--muted);
}
#status.running { color: var(--accent-2); }
#status.error { color: var(--danger); }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 340px 1fr; }
}

video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  border: 1px solid var(--border);
}

.cards { display: flex; flex-direction: column; gap: 0.85rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.card.active { border-color: var(--accent); }
.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.card .time {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline dotted;
}
.card .scene { margin: 0.4rem 0; color: var(--text); }
.card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}
.card ul.lines {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}
.card ul.lines li { margin: 0.2rem 0; }
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #2a3a52;
  color: var(--muted);
  vertical-align: middle;
}
.badge.dry { background: #3a3420; color: var(--warn); }

pre.export {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow: auto;
  max-height: 220px;
  font-size: 0.75rem;
  display: none;
}
footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.live-panel { margin-bottom: 1.25rem; }
.live-title {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  font-weight: 650;
}
.live-feed {
  max-height: 220px;
  overflow-y: auto;
  background: #121a26;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  color: var(--text);
}
.live-feed .empty { color: var(--muted); }
.live-feed .beat {
  padding: 0.35rem 0;
  border-bottom: 1px solid #243044;
}
.live-feed .beat:last-child { border-bottom: 0; }
.live-feed .beat .when {
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.8rem;
  margin-right: 0.5rem;
}
.card .lines-label {
  margin: 0.55rem 0 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-2);
}
.card .lines li {
  color: #f2f6fb;
  font-size: 1rem;
}

.audio-box { margin-top: 0.65rem; }
.audio-box audio { width: 100%; height: 32px; }

.match-summary {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: #121821;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  max-height: 160px;
  overflow: auto;
}
