:root {
  color-scheme: dark;
  font-family: "Fira Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070b13;
  color: #ecf4ff;
  --border: #25364b;
  --panel: #101827;
  --panel-muted: #162235;
  --panel-hot: #1b1020;
  --text-muted: #99aac0;
  --text-soft: #c8d5e6;
  --accent: #00d4ff;
  --accent-strong: #7c3aed;
  --hot: #ff2e63;
  --coin: #ffca3a;
  --danger: #ff6b6b;
  --success: #36d399;
  --field-height: 34px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
}

.viewer-workbench {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(300px, 360px);
  grid-template-rows: minmax(0, 1fr) 180px;
  gap: 12px;
  padding: 12px;
}

.config-pane,
.video-pane,
.diagnostics-pane,
.log-pane {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.04), 0 18px 44px rgba(0, 0, 0, 0.28);
}

.config-pane,
.diagnostics-pane {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.video-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.log-pane {
  grid-column: 1 / -1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.pane-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.pane-heading.compact {
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--coin);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: #f8fbff;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
}

.config-form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field span,
dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  min-width: 0;
  min-height: var(--field-height);
  border-radius: 6px;
  border: 1px solid #2b4058;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: #0a111d;
  color: #ecf4ff;
}

input,
select {
  padding: 0 10px;
}

textarea {
  min-height: 118px;
  padding: 9px 10px;
  resize: vertical;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--coin);
  outline-offset: 2px;
}

.action-row,
.diagnostic-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.audio-control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

button {
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.primary-action {
  border-color: var(--accent);
  background: #0b4a64;
  color: #ecfbff;
}

.primary-action:hover {
  background: #0d5d7e;
  border-color: #66e7ff;
}

.secondary-action {
  border-color: #39516d;
  background: #17243a;
  color: #d7e6f8;
}

.secondary-action:hover {
  border-color: var(--hot);
  background: #24162d;
  color: #ffffff;
}

.video-pane {
  position: relative;
}

.viewer-status-toast {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  width: min(760px, calc(100% - 24px));
  margin: 0 auto;
  padding: 7px 12px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  color: #e6eef8;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(7, 12, 22, 0.82);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(10px);
}

.viewer-status-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

#errorText {
  color: var(--danger);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-shell {
  position: relative;
  min-height: 320px;
  background: #05070c;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #05070c;
  object-fit: contain;
}

body[data-display-scale="medium"] video {
  width: 82%;
  height: 82%;
  margin: auto;
}

body[data-display-scale="low"] video {
  width: 66%;
  height: 66%;
  margin: auto;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8da2ba;
  pointer-events: none;
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.video-shell.has-video .video-placeholder {
  display: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.metric-grid div {
  min-width: 0;
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px;
  background: var(--panel-muted);
  border: 1px solid #26384f;
  border-radius: 6px;
}

dd {
  min-width: 0;
  margin: 0;
  color: #ecf4ff;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.log-heading {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: #0b1220;
}

.log-heading span {
  color: var(--text-muted);
  font-size: 12px;
}

.event-log {
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  background: #080d16;
  color: #cfe1f5;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

body[data-presentation-mode="video-only"] .config-pane,
body[data-presentation-mode="video-only"] .diagnostics-pane,
body[data-presentation-mode="video-only"] .log-pane,
body[data-presentation-mode="video-only"] .audio-control-row {
  display: none;
}

body[data-presentation-mode="video-only"] .viewer-workbench {
  display: block;
  padding: 0;
}

body[data-presentation-mode="video-only"] .video-pane {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

@media (max-width: 1120px) {
  .viewer-workbench {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    grid-template-rows: minmax(420px, 1fr) auto 180px;
  }

  .diagnostics-pane {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .viewer-workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(360px, 48vh) auto 180px;
    padding: 8px;
  }

  .metric-grid,
  .action-row,
  .diagnostic-actions {
    grid-template-columns: 1fr;
  }

  .viewer-status-toast {
    grid-template-columns: 1fr;
    gap: 2px;
    width: calc(100% - 16px);
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 7px 10px;
  }

  #errorText {
    text-align: left;
  }
}

.codec-info-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.codec-info-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
