:root {
  --live-bg: #f4f1ea;
  --live-panel: #fffdf7;
  --live-ink: #1d2526;
  --live-muted: #69736f;
  --live-line: #d7d0c0;
  --live-accent: #2f6358;
  --live-rust: #8b5634;
  --live-dark: #12221f;
  --live-shadow: 0 18px 42px rgba(29, 37, 38, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

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

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

button.primary {
  background: var(--live-dark);
  border-color: var(--live-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.4fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: end;
  padding: clamp(2rem, 5vw, 4rem) 0;
}

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

h1,
h2,
p,
span,
strong,
dd {
  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: 64ch;
  margin: 1rem 0 0;
  color: var(--live-muted);
  font-size: 1.08rem;
}

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

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

.lab-note strong {
  color: var(--live-accent);
}

.lab-note span,
.status-line {
  color: var(--live-muted);
}

.live-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.4fr) 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(--live-muted);
  font-size: 0.85rem;
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0.66rem 0.75rem;
  border: 1px solid var(--live-line);
  border-radius: 8px;
  background: #fff;
  color: var(--live-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;
  font-size: 0.92rem;
}

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

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

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

.live-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(18, 34, 31, 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.75rem;
  border: 1px solid var(--live-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

dt {
  color: var(--live-muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

dd {
  margin: 0.2rem 0 0;
  font-weight: 900;
}

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

#event-log {
  display: grid;
  gap: 0.45rem;
  max-height: 240px;
  margin: 1rem 0 0;
  padding-left: 1.4rem;
  overflow: auto;
  color: var(--live-muted);
}

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

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

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

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

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

  h1 {
    max-width: 10ch;
    font-size: clamp(2.6rem, 16vw, 4.4rem);
  }

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