:root {
  --gun-bg: #f5f2ea;
  --gun-ink: #1e2528;
  --gun-muted: #687178;
  --gun-panel: #fffdf7;
  --gun-line: #d7cfbf;
  --gun-blue: #315f7e;
  --gun-green: #50735b;
  --gun-rust: #985c35;
  --gun-dark: #142027;
  --gun-shadow: 0 18px 42px rgba(30, 37, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body.gun-video-page {
  margin: 0;
  background: var(--gun-bg);
  color: var(--gun-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

.lab-header,
.lab-shell,
.lab-footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.lab-nav {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem 0;
}

.lab-nav a,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--gun-line);
  border-radius: 8px;
  background: var(--gun-panel);
  color: var(--gun-ink);
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

button.primary {
  background: var(--gun-dark);
  border-color: var(--gun-dark);
  color: #fffaf0;
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.hero-grid {
  min-height: 42vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: end;
  padding: clamp(2rem, 5vw, 4rem) 0;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--gun-rust);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
span,
strong {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(3rem, 8vw, 6.2rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero-grid p {
  max-width: 62ch;
  margin: 1rem 0 0;
  color: var(--gun-muted);
  font-size: 1.08rem;
}

.lab-note,
.room-panel,
.controls-panel,
.metrics-panel,
.debug-panel {
  border: 1px solid var(--gun-line);
  border-radius: 8px;
  background: var(--gun-panel);
  box-shadow: var(--gun-shadow);
}

.lab-note {
  display: grid;
  gap: 0.4rem;
  padding: 1rem;
}

.lab-note strong {
  color: var(--gun-blue);
}

.lab-note span {
  color: var(--gun-muted);
}

.lab-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: 4rem;
}

.room-panel,
.controls-panel,
.metrics-panel,
.debug-panel {
  padding: 1rem;
}

.room-form,
.controls-panel {
  display: grid;
  gap: 0.7rem;
}

.room-form {
  margin-top: 1rem;
}

label {
  color: var(--gun-muted);
  font-size: 0.85rem;
  font-weight: 850;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0.66rem 0.75rem;
  border: 1px solid var(--gun-line);
  border-radius: 8px;
  background: #fff;
  color: var(--gun-ink);
  font: inherit;
}

.room-row,
.button-row,
.settings-grid {
  display: grid;
  gap: 0.5rem;
}

.room-row,
.button-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.settings-grid {
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
}

.status-line {
  margin: 0.4rem 0 0;
  color: var(--gun-muted);
  font-size: 0.92rem;
}

.stream-grid {
  grid-row: span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-content: start;
}

.stream-tile {
  min-height: 300px;
  position: relative;
  border: 1px solid var(--gun-line);
  border-radius: 8px;
  background: #111a20;
  overflow: hidden;
  box-shadow: var(--gun-shadow);
}

.stream-tile video,
.stream-tile img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: block;
  object-fit: cover;
  background: #111a20;
}

.stream-tile img:not([src]) {
  opacity: 0;
}

.tile-label {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(20, 32, 39, 0.78);
  color: #fffaf0;
  backdrop-filter: blur(10px);
}

.tile-label span {
  color: rgba(255, 250, 240, 0.72);
}

.metrics-panel dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.metrics-panel div {
  padding: 0.7rem;
  border: 1px solid var(--gun-line);
  border-radius: 8px;
  background: #fbfaf7;
}

.metrics-panel dt {
  color: var(--gun-muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.metrics-panel dd {
  margin: 0.15rem 0 0;
  color: var(--gun-blue);
  font-size: 1.2rem;
  font-weight: 950;
}

.debug-panel {
  grid-column: 1 / -1;
}

#event-log {
  display: grid;
  gap: 0.45rem;
  max-height: 260px;
  overflow: auto;
  padding-left: 1.3rem;
  color: var(--gun-muted);
}

.lab-footer {
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--gun-line);
  color: var(--gun-muted);
}

@media (max-width: 900px) {
  .hero-grid,
  .lab-shell {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    min-height: auto;
  }

  .stream-grid {
    grid-row: auto;
  }
}

@media (max-width: 620px) {
  .lab-header,
  .lab-shell,
  .lab-footer {
    width: min(100% - 1rem, 1180px);
  }

  .lab-nav,
  .button-row,
  .room-row,
  .settings-grid,
  .stream-grid,
  .metrics-panel dl {
    grid-template-columns: 1fr;
  }
}
