:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background: #101419;
  color: #eef2f4;
  --panel: #181e25;
  --line: #303943;
  --muted: #a8b4bf;
  --green: #aef8b7;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--green); }
header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem max(1.25rem, calc((100% - 1060px)/2)); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-weight: 800; white-space: nowrap; }
.mark { display: flex; align-items: center; gap: 2px; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: var(--green); }
.mark i { display: block; width: 3px; height: 10px; border-radius: 3px; background: #15251b; }
.mark i:nth-child(2) { height: 18px; }
nav { display: flex; flex-wrap: wrap; gap: .25rem; }
nav a { text-decoration: none; color: var(--muted); padding: .55rem .65rem; border-radius: 6px; font-size: .87rem; }
nav a[aria-current], nav a:hover { color: white; background: var(--panel); }
main { max-width: 1100px; margin: auto; padding: clamp(1.25rem, 4vw, 2.75rem); }
h1 { margin: 0 0 .6rem; font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.055em; }
h2 { font-size: 1.12rem; margin: 0 0 .65rem; }
p { color: var(--muted); line-height: 1.5; margin: .45rem 0 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 1rem; margin: 1.4rem 0; }
.card { padding: 1.25rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.login { max-width: 440px; margin-top: 1.5rem; }
label { display: grid; gap: .4rem; margin-bottom: .75rem; font-weight: 650; }
input, select, button, .button { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .85rem; min-height: 44px; }
input, select { background: #11161c; color: inherit; max-width: 100%; }
button, .button { cursor: pointer; color: #132019; background: var(--green); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
button.secondary, .button.secondary { color: inherit; background: #242c35; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.actions label { margin: 0; }
.error { color: #ffabab; white-space: pre-line; }
.error:empty { display: none; }
.status { color: var(--muted); font-size: .9rem; font-weight: 650; }
.status[data-live="true"] { color: var(--green); }
.status::before { content: ''; display: inline-block; width: .55rem; height: .55rem; margin-right: .55rem; border-radius: 50%; background: currentColor; }
code { display: block; overflow-wrap: anywhere; color: var(--green); margin: .75rem 0; }
video { display: block; background: #090c0f; width: 100%; max-height: 62dvh; aspect-ratio: 16 / 9; object-fit: contain; border-radius: 12px; margin: 1rem 0; }
.chat-page { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
.chat-page header { padding-block: .3rem; }
.chat-page main {
  display: grid;
  grid-template-rows: auto minmax(4.75rem, 15dvh) minmax(0, 1fr);
  gap: .5rem;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: .5rem clamp(.5rem, 3vw, 1.25rem);
}
.chat-status { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem .65rem; min-width: 0; }
.chat-status .status { font-size: .76rem; overflow-wrap: anywhere; }
.chat-status #logout { margin-left: auto; min-height: 32px; padding: .25rem .5rem; font-size: .78rem; }
.chat-status #twitch-warnings { flex-basis: 100%; margin: 0; max-height: 3rem; overflow: auto; font-size: .8rem; }
.chat-status #twitch-warnings:empty { display: none; }
.chat-panel { display: grid; min-height: 0; gap: .35rem; padding: .55rem; }
.chat-panel h2 { font-size: .92rem; margin: 0; }
.activity-panel { grid-template-rows: auto minmax(0, 1fr); }
.messages-panel { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.feed { display: grid; align-content: start; gap: .35rem; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.activity-panel .entry { padding: .35rem .6rem; font-size: .86rem; }
.activity-panel .entry p { display: inline; margin: 0 0 0 .4rem; }
.chat-panel .error { margin: 0; max-height: 3rem; overflow: auto; font-size: .85rem; }
.messages-panel .compose { grid-row: 4; }
@media (max-width: 540px) {
  .chat-page header { padding-inline: .5rem; }
  .chat-page .brand { display: none; }
}
.entry { padding: .6rem .75rem; border-radius: 8px; background: #11161c; overflow-wrap: anywhere; }
.entry.alert { border-left: 3px solid var(--green); }
.entry strong { color: var(--green); }
.entry time { float: right; margin-left: .5rem; color: var(--muted); font-size: .78rem; }
.entry p { color: inherit; margin: .2rem 0 0; white-space: pre-wrap; }
.compose { display: flex; gap: .6rem; }
.compose input { flex: 1; min-width: 0; }
.overlay { background: transparent; }
.overlay header { display: none; }
.overlay main { padding: 1rem; max-width: 720px; }
.overlay .entry { font-size: clamp(1.1rem, 4vw, 2rem); padding: 1rem 1.35rem; background: #181e25; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

[hidden] { display: none !important; }
.camera-stage { position: relative; }
.camera-stage video { margin-top: 0; touch-action: none; }
.camera-tools { display: none; }
.camera-settings { align-items: end; }
.camera-settings details { flex-basis: 100%; }
.camera-settings summary { cursor: pointer; }
#tuning { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .5rem; margin-top: .6rem; }
#tuning input, #zoom { width: 100%; padding-inline: 0; }
.camera-bottom { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-top: .65rem; }
.camera-readout { flex: 1 1 15rem; }
.camera-readout p { margin: 0; }
.camera-zoom { position: relative; }
#zoom-options { position: absolute; bottom: calc(100% + .55rem); left: 0; width: min(224px, 75vw); padding: .65rem; z-index: 3; background: #181e25f5; border-radius: .7rem; }
.camera-full { overflow: hidden; background: #000; }
.camera-stage.mobile-full { position: fixed; inset: 0; z-index: 20; display: grid; padding: 0; border: 0; border-radius: 0; background: #000; }
.mobile-full video { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; margin: 0; border-radius: 0; background: #000; }
.mobile-full .camera-tools {
  position: absolute; z-index: 4; display: flex; gap: .12rem;
  top: max(.4rem, env(safe-area-inset-top)); right: max(.4rem, env(safe-area-inset-right));
}
.mobile-full .camera-tools button {
  width: 44px; height: 44px; min-height: 44px; padding: 0; color: #fff; background: transparent; border: 0;
  filter: drop-shadow(0 1px 3px #000) drop-shadow(0 0 2px #000);
}
.mobile-full #torch[aria-pressed="true"] { color: #ffe68f; }
.mobile-full .camera-settings { display: none; }
.mobile-full.settings-open .camera-settings {
  position: absolute; display: flex; z-index: 3; top: calc(max(.4rem, env(safe-area-inset-top)) + 46px);
  right: max(.55rem, env(safe-area-inset-right)); width: min(370px, calc(100% - 1.1rem));
  max-height: 60dvh; overflow: auto; overscroll-behavior: contain;
  border: 1px solid #ffffff32; border-radius: .8rem; padding: .75rem; background: #111820f2;
}
.mobile-full .camera-facing { display: none; }
.mobile-full .camera-bottom {
  position: absolute; bottom: 0; inset-inline: 0; flex-wrap: nowrap; margin: 0;
  padding: .65rem max(.6rem, env(safe-area-inset-right)) max(.65rem, env(safe-area-inset-bottom)) max(.6rem, env(safe-area-inset-left));
  background: linear-gradient(transparent, #000b);
}
.mobile-full .camera-readout { min-width: 0; font-size: .78rem; overflow-wrap: anywhere; }
.mobile-full .camera-readout p { color: #fff; }
.mobile-full .camera-readout .error { color: #ffb5b5; }
.mobile-full #start { display: none; }
.mobile-full #stop, .mobile-full #zoom-button { padding-inline: .55rem; color: #fff; background: #101419a8; border-color: #ffffff45; }
.camera-stage:not(.mobile-full) { display: flex; flex-direction: column; }
.camera-stage:not(.mobile-full) .camera-settings { order: -2; }
.camera-stage:not(.mobile-full) video { margin-top: 1rem; }
.mic-meter { width: 8rem; height: .75rem; accent-color: #aef8b7; margin-top: .6rem; }
.mobile-full .mic-meter {
  position: absolute; z-index: 2; width: 5.5rem; height: .55rem; margin: 0; left: max(.65rem, env(safe-area-inset-left));
  top: 50%; transform-origin: left center; transform: translateY(2.75rem) rotate(-90deg);
}
#mic-mute[aria-pressed="true"] { color: #ff8f8f; }
#mic-mute[aria-pressed="true"] svg { opacity: .65; }
#gain-label input { padding-inline: 0; width: 100%; }
#gain-value { font-size: .8em; }
#tuning-note { margin: .3rem 0; font-size: .8em; }
#zoom-close { padding: .25rem .5rem; min-height: 34px; }
.watch-feed main { max-width: none; padding: 0; }
.watch-feed video { width: 100vw; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
.watch-feed p, .watch-feed button { position: fixed; z-index: 1; left: 1rem; bottom: 1rem; margin: 0; }
.watch-feed button { bottom: 3rem; }

#camera-feed-panel { display: none; }
.mobile-full #camera-feed-panel {
  position: absolute;
  z-index: 2;
  display: block;
  left: max(.45rem, env(safe-area-inset-left));
  right: max(.45rem, env(safe-area-inset-right));
  bottom: calc(4.85rem + env(safe-area-inset-bottom));
  height: clamp(7rem, 33dvh, 22rem);
  padding: .4rem;
  border: 1px solid #ffffff32;
  border-radius: .65rem;
  background: #101419e8;
  overflow: auto;
}
.mobile-full.feed-open video { height: calc(100% - clamp(7rem, 33dvh, 22rem) - 4.85rem - env(safe-area-inset-bottom)); }
#camera-feeds { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 2fr); gap: .4rem; height: 100%; }
#camera-feeds section { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
#camera-feeds h2 { font-size: .8rem; margin: 0 0 .2rem; }
#camera-feeds .entry { padding: .25rem .4rem; font-size: .82rem; background: #0b1017; }
#camera-feeds .entry p { display: inline; margin-inline-start: .35rem; }
#camera-feeds time { font-size: .72rem; }
#camera-feed-login { max-width: 20rem; margin: .2rem auto; }
#camera-feed-login input { min-width: 0; width: 100%; }
@media (orientation: landscape) {
  .mobile-full #camera-feed-panel {
    left: auto;
    width: clamp(12rem, 36vw, 24rem);
    top: calc(max(.4rem, env(safe-area-inset-top)) + 46px);
    height: auto;
    bottom: calc(4rem + env(safe-area-inset-bottom));
  }
  .mobile-full.feed-open video {
    height: 100%;
    width: calc(100% - clamp(12rem, 36vw, 24rem) - max(.45rem, env(safe-area-inset-right)));
  }
}
