:root {
  --bg: #0a0e13;
  --panel: #111821;
  --panel-2: #0d141b;
  --line: #202b38;
  --line-strong: #2c3a4a;
  --text: #e6edf3;
  --dim: #8997a6;
  --accent: #f5a524;
  --accent-soft: rgba(245, 165, 36, 0.14);
  --green: #3ddc97;
  --danger: #ff6b6b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 70% -10%, #16202c 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--dim);
  background: #0b1118;
  white-space: nowrap;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: #0b1118;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}

.dim { color: var(--dim); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 19, 0.86);
}

.brand h1 {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand .sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
}

.badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.badge.live {
  color: var(--text);
  border-color: var(--line-strong);
}

.badge.vfr {
  color: var(--accent);
  border-color: rgba(245, 165, 36, 0.45);
  background: var(--accent-soft);
}

.badge.warn {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

/* ---------- main ---------- */

main {
  width: 100%;
  max-width: 1460px;
  margin: 0 auto;
  padding: 14px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #131c26;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}

.btn:hover:not(:disabled) { background: #182430; border-color: #3a4b5e; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: #1c2a3a;
  border-color: #33506e;
}

.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1205;
  font-weight: 600;
}

.btn.accent kbd {
  color: #4a3208;
  border-color: rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.25);
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover:not(:disabled) { background: #141d27; }

.btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.1); }

.btn.small { font-size: 12px; padding: 5px 9px; }

.btn.play { min-width: 104px; justify-content: center; font-weight: 600; }
.btn.play.playing { border-color: var(--green); color: var(--green); }

/* ---------- source ---------- */

.source {
  padding: 10px 12px;
}

.source-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.url-group {
  display: flex;
  gap: 6px;
  flex: 1 1 320px;
  min-width: 220px;
}

.url-group input {
  font: inherit;
  font-size: 13px;
  font-family: var(--mono);
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #0b1118;
  color: var(--text);
}

.url-group input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.source-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--dim);
}

.source-name {
  font-family: var(--mono);
  color: #b9c6d3;
  overflow-wrap: anywhere;
}

.source-detail { font-family: var(--mono); }

.manual-fps {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.manual-fps input {
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  width: 76px;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: #0b1118;
  color: var(--text);
}

.manual-fps input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.status {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--dim);
  min-height: 16px;
}

.status.ok { color: var(--green); }
.status.warn { color: var(--accent); }
.status.error { color: var(--danger); }

/* ---------- playlist ---------- */

.playlist {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.playlist-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.playlist-head h2 {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c8d4e0;
  white-space: nowrap;
}

.playlist-head .hint { font-size: 11.5px; }

.playlist-items {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.playlist-item {
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #101820;
  color: #b9c6d3;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.playlist-item:hover {
  background: #16212c;
  border-color: #3a4b5e;
  color: var(--text);
}

.playlist-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.playlist-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.playlist-item.active::before {
  content: '●';
  font-size: 8px;
  margin-right: 6px;
  vertical-align: 2px;
}

/* ---------- stage ---------- */

.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-height: clamp(240px, 52vh, 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #000;
}

.stage.empty video { visibility: hidden; }

.stage.dragover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(245, 165, 36, 0.55);
}

.stage:not(.empty) .stage-empty { display: none; }

.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
}

.stage.empty .stage-overlay { display: none; }

.frame-readout {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(5, 9, 13, 0.72);
  border: 1px solid rgba(120, 145, 170, 0.22);
  border-radius: 8px;
  padding: 5px 12px 7px;
  backdrop-filter: blur(4px);
}

.frame-readout .cap,
.readout .cap {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.frame-number {
  font-family: var(--mono);
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(245, 165, 36, 0.25);
}

.stage-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.time-readout {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: #dbe6f0;
  background: rgba(5, 9, 13, 0.72);
  border: 1px solid rgba(120, 145, 170, 0.22);
  border-radius: 7px;
  padding: 4px 10px;
  backdrop-filter: blur(4px);
}

.elapsed-readout {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  background: rgba(5, 9, 13, 0.72);
  border: 1px solid rgba(61, 220, 151, 0.3);
  border-radius: 7px;
  padding: 3px 9px;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.014) 0 12px, transparent 12px 24px),
    #060a0e;
  text-align: center;
}

.drop-card h2 { font-size: 17px; margin-bottom: 6px; }
.drop-card p { margin: 4px 0; font-size: 13px; max-width: 46ch; }
.drop-card .dim { font-size: 12px; }

/* ---------- transport ---------- */

.transport {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 9px 12px;
}

.readouts {
  display: flex;
  align-items: baseline;
  gap: 22px;
  flex-wrap: wrap;
  min-width: 0;
}

.readout {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  color: var(--text);
  line-height: 1.1;
}

.num.small { font-size: 15px; }

.readout.elapsed .num { color: var(--green); }

.buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.btn.icon {
  padding: 7px 9px;
  color: var(--text);
}

.btn.icon svg { display: block; }

.sound-cross { display: none; }
.btn.icon.muted .sound-waves { display: none; }
.btn.icon.muted .sound-cross { display: block; }
.btn.icon.muted { color: var(--dim); }

.audio-control {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 9px;
  margin-left: 3px;
  border-left: 1px solid var(--line);
}

.audio-control input[type="range"] {
  width: 76px;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.audio-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #263544;
}

.audio-control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #263544;
}

.audio-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid #12181f;
}

.audio-control input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid #12181f;
}

.audio-control input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.audio-control.unavailable { opacity: 0.45; }

.audio-control.unavailable input[type="range"] { cursor: default; }

/* ---------- scrub ---------- */

.scrub { padding: 9px 14px 6px; }

.scrub input[type="range"] {
  width: 100%;
  margin: 0;
  height: 18px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.scrub input[type="range"]:disabled { cursor: default; opacity: 0.4; }

.scrub input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: #1c2733;
}

.scrub input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: #1c2733;
}

.scrub input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #12181f;
  box-shadow: 0 0 0 1px var(--accent);
}

.scrub input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #12181f;
}

.scrub input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.scrub-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  margin-top: 1px;
}

/* ---------- log ---------- */

.log {
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.log-title h2 { font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; color: #c8d4e0; }
.hint { font-size: 12px; color: var(--dim); }

.log-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.log-scroll {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.log table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.log thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0f1720;
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.log tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid #17212c;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log tbody tr:last-child td { border-bottom: 0; }
.log tbody tr.start td { background: var(--accent-soft); }

.log .col-index { width: 34px; }
.log .col-num { text-align: right; }
.log thead th.col-num { text-align: right; }
.log td.col-index, .log td.col-mark { color: var(--dim); }
.log td.col-num { text-align: right; }
.log td.mark-start { color: var(--accent); }
.log td.mark-point { color: #b9c6d3; }

.log .col-x { width: 26px; }

.row-del {
  font: inherit;
  font-family: var(--sans);
  background: none;
  border: 0;
  color: #5c6b7a;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.2;
}

.row-del:hover { color: var(--danger); background: rgba(255, 107, 107, 0.1); }

.log-empty {
  margin: 0;
  padding: 14px;
  font-size: 12.5px;
  color: var(--dim);
  text-align: center;
}

.log-foot { font-size: 11px; margin: 0; }

/* ---------- footer ---------- */

.foot {
  max-width: 1460px;
  margin: 0 auto;
  padding: 4px 18px 14px;
  font-size: 11px;
  width: 100%;
}

/* ---------- guide modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 7, 10, 0.74);
  backdrop-filter: blur(3px);
  padding: 24px 16px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 18px 20px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  margin: auto;
}

.modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.modal-head h2 { font-size: 17px; }

.steps {
  margin: 14px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.steps li::marker {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}

.steps h3 { font-size: 13px; margin-bottom: 3px; }
.steps p { margin: 0 0 4px; color: #c2cfdb; }

.keys {
  width: 100%;
  margin: 16px 0 0;
  border-collapse: collapse;
  font-size: 12.5px;
}

.keys td {
  padding: 4px 8px;
  border-top: 1px solid var(--line);
  color: #c2cfdb;
}

.keys td:first-child { width: 120px; white-space: nowrap; }

.modal-note { margin: 14px 0 0; font-size: 11.5px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .buttons { width: 100%; margin-left: 0; }
  .audio-control { border-left: 0; padding-left: 0; margin-left: 0; }
  .manual-fps { margin-left: 0; }
  .stage { min-height: 240px; }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .badges { justify-content: flex-start; }
  .btn kbd { display: none; }
  .readout .cap { display: none; }
  .log-actions .btn { flex: 1 1 auto; justify-content: center; }
  .stage-overlay { padding: 8px; }
  .frame-number { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
