:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #112238;
  --muted: #5b6b80;
  --accent: #0f766e;
  --border: #d9e1ed;
  --shadow: 0 10px 30px rgba(21, 42, 74, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% -10%, #d6f5f2 0%, transparent 36%),
    radial-gradient(circle at 85% 120%, #d7e8ff 0%, transparent 42%),
    var(--bg);
  min-height: 100vh;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar, .stats, .pane {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 14px;
}

.topbar {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

h1 { margin: 0; font-size: 1.35rem; }
.sub { margin: 6px 0 0; color: var(--muted); }

.controls { display: flex; gap: 10px; }
button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

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

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.card h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.card p { margin: 0; font-size: 1.15rem; font-weight: 700; }

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pane {
  padding: 14px;
}

.pane h3 { margin: 0 0 10px; }
.pane label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.key-input {
  width: 100%;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.key-row .key-input {
  margin-bottom: 10px;
}

.row-btn {
  white-space: nowrap;
  margin-bottom: 10px;
}

.radio-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.radio-row label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}


.mini-status {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.mini-proto {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
}

.mini-debug {
  margin: 6px 0 0;
  font-size: 0.74rem;
  color: #7a8798;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

video, canvas {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 10px;
  background: #0b1626;
  border: 1px solid #1f3552;
}

/* Playback: fixed 16:9 viewport with letterboxing instead of stretch */
#watch {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b1626;
  overflow: hidden;
  border-radius: 10px;
}

#watch canvas,
#watch video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0b1626;
}

.media-shell {
  position: relative;
}

.metric-overlay {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 9999;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #e6edf7;
  background: rgba(11, 22, 38, 0.72);
  border: 1px solid rgba(230, 237, 247, 0.22);
  border-radius: 6px;
  padding: 3px 6px;
  pointer-events: none;
}

.metric-overlay.right-bottom {
  left: auto;
  right: 10px;
}

.metric-overlay.top-right {
  left: auto;
  right: 10px;
  top: 10px;
  bottom: auto;
}

.metric-overlay.top-left {
  left: 10px;
  right: auto;
  top: 10px;
  bottom: auto;
}

.cap-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.cap-list li {
  font-size: 0.96rem;
  display: flex;
  align-items: center;
}

.cap-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.cap-yes { background: #16a34a; }
.cap-no { background: #dc2626; }
.cap-unknown { background: #facc15; }

@media (max-width: 900px) {
  .video-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
