:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1020;
  color: #e8edf9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
main { max-width: 1080px; margin: 0 auto; padding: 48px 24px 72px; }
header { margin-bottom: 24px; }
h1 { margin: 4px 0 8px; font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { margin: 0; font-size: 1.15rem; }
.eyebrow { margin: 0; color: #74d7ff; letter-spacing: .14em; font-size: .74rem; font-weight: 700; }
.subtle { color: #a8b3ca; margin: 8px 0 0; line-height: 1.5; }

.card { background: #141c31; border: 1px solid #253250; border-radius: 12px; padding: 20px; margin-top: 16px; }
.controls, .history-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
label { display: grid; gap: 6px; color: #bfcae2; font-size: .85rem; }
input { min-height: 40px; background: #0c1324; border: 1px solid #3a4b70; border-radius: 7px; color: #f3f7ff; padding: 8px 10px; font: inherit; }
#stream-path { min-width: 240px; }
#recording-start { min-width: min(100%, 290px); }
#recording-duration { width: 135px; }
button { min-height: 40px; border: 0; border-radius: 7px; background: #2c8cc3; color: #fff; padding: 0 14px; font: inherit; font-weight: 650; cursor: pointer; }
button:hover { background: #41a6de; }
button.secondary { background: #33415f; }
button.secondary:hover { background: #475a81; }

.status { border-radius: 999px; padding: 7px 10px; font-size: .85rem; font-weight: 700; }
.status-idle { background: #33415f; color: #d9e3fa; }
.status-connecting { background: #725e21; color: #ffeb99; }
.status-live { background: #155d49; color: #aaf5d6; }
.status-error { background: #702d3a; color: #ffbec9; }

.player-card { padding: 12px; }
#video { background: #03050a; display: block; width: 100%; height: 100%; object-fit: contain; }
.player-shell { position: relative; isolation: isolate; aspect-ratio: 16 / 9; background: #03050a; overflow: hidden; border-radius: 8px; }
/* Never taller than the visible screen (e.g. a phone in landscape), so the
   bottom-anchored controls stay on screen. dvh tracks mobile browser bars;
   the vh line is the fallback for browsers without it. */
.player-shell { max-width: calc((100vh - 24px) * 16 / 9); max-width: calc((100dvh - 24px) * 16 / 9); margin-inline: auto; }
.player-shell:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.player-overlay { position: absolute; inset: auto 0 0; padding: 48px 16px 8px; background: linear-gradient(transparent, #000b); opacity: 0; transition: opacity .16s ease; pointer-events: none; }
.player-shell:hover .player-overlay, .player-shell:focus-within .player-overlay,
.player-shell.is-paused .player-overlay, .player-shell.show-controls .player-overlay { opacity: 1; pointer-events: auto; }
.player-shell.controls-hidden .player-overlay { display: none; }
.timeline-wrap { position: relative; height: 22px; display: flex; align-items: center; }
.timeline { --progress: 100%; appearance: none; -webkit-appearance: none; width: 100%; min-height: 0; height: 22px; margin: 0; padding: 0; border: 0; border-radius: 0; cursor: pointer; background: transparent; touch-action: pan-y; }
.timeline::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(to right, #ff2744 0 var(--progress), #ffffff60 var(--progress) 100%); }
.timeline::-moz-range-track { height: 4px; background: linear-gradient(to right, #ff2744 0 var(--progress), #ffffff60 var(--progress) 100%); }
.timeline::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 13px; height: 13px; margin-top: -4.5px; border-radius: 50%; background: #ff2744; }
.timeline::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #ff2744; }
.timeline:disabled { opacity: .4; cursor: default; }
.transport { display: flex; align-items: center; gap: 8px; min-height: 40px; color: #fff; }
.transport button { background: transparent; border-radius: 4px; padding: 0 8px; min-width: 40px; color: #fff; }
.transport button:hover { background: #ffffff24; }
.transport button:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.icon-button { display: grid; place-items: center; }
.icon-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#toggle-mute svg path:first-child { fill: currentColor; stroke: none; }
.play-icon { display: block; width: 0; height: 0; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 14px solid white; }
.play-icon.is-playing { width: 14px; height: 18px; border: 0; border-left: 5px solid white; border-right: 5px solid white; }
.transport .live-button { display: flex; align-items: center; gap: 7px; font-size: 13px; letter-spacing: .04em; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.live-button.is-live .live-dot { background: #ff2744; }
.time-behind { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transport-spacer { flex: 1; }
/* A PredictWind mark on every stream, embeds included. It is not a link, so
   a tap inside the app's embed cannot navigate the page away. */
.player-top { position: absolute; top: 14px; left: 16px; right: 16px; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.player-brand { width: clamp(84px, 18%, 145px); height: auto; filter: drop-shadow(0 1px 1px #0009) drop-shadow(0 2px 8px #0006); user-select: none; }
.player-message { max-width: 100%; padding: 7px 12px; border-radius: 5px; background: #0009; color: white; font-size: 13px; }
.play-feedback { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; color: white; background: #0007; font-size: 28px; opacity: 0; pointer-events: none; }
.play-feedback.visible { animation: feedback .55s ease-out; }
@keyframes feedback { 0%, 35% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); } }
.timeline-preview { position: absolute; bottom: 30px; width: 180px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px; color: white; pointer-events: none; text-shadow: 0 1px 3px #000; font-size: 13px; }
#preview-video { width: 180px; height: 101px; object-fit: cover; background: #111; border: 2px solid white; border-radius: 7px; }
#preview-note { padding: 6px 9px; border-radius: 5px; background: #000b; font-size: 11px; }
#preview-time { padding: 2px 6px; border-radius: 3px; background: #0008; font-variant-numeric: tabular-nums; }
.player-shell:fullscreen { width: 100%; height: 100%; border-radius: 0; }
@media (hover: none) { .player-overlay { padding: 32px 10px 5px; } }
@media (prefers-reduced-motion: reduce) { .player-overlay { transition: none; } .play-feedback.visible { animation: none; } }
.telemetry { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; }
.telemetry div { background: #0d1527; border-radius: 7px; padding: 10px; min-width: 0; }
dt { color: #8d9bb9; font-size: .72rem; }
dd { margin: 3px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.history { display: grid; gap: 16px; }
pre { margin: 0; min-height: 54px; max-height: 260px; overflow: auto; white-space: pre-wrap; background: #0b1120; border-radius: 7px; color: #b9dcff; padding: 12px; font-size: .78rem; }
code { color: #b9dcff; }

@media (max-width: 700px) {
  main { padding: 28px 14px 48px; }
  .telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* /embed is designed to be placed in a fixed-ratio iframe. */
body.embed-mode { background: #03050a; overflow: hidden; }
/* Pinned to the viewport rather than sized in document flow: mobile Safari
   scrolls the page despite overflow: hidden, and after a rotation it can keep
   a stale scroll offset or toolbar height, which pushed the player and its
   bottom controls partly off screen. */
/* Height is the small viewport (browser bars shown), not the full screen:
   iOS 26 Safari draws its floating toolbar over page content, which hid the
   bottom controls when the embed filled the whole screen. */
body.embed-mode main { position: fixed; top: 0; right: 0; left: 0; height: 100vh; height: 100svh; max-width: none; padding: 0; }
body.embed-mode .player-overlay { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.embed-mode header,
body.embed-mode .controls,
body.embed-mode .telemetry,
body.embed-mode .history { display: none; }
body.embed-mode .player-card {
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #03050a;
}
body.embed-mode .player-shell {
  height: 100%;
  max-width: none;
  border-radius: 0;
  aspect-ratio: auto;
}

/* ?debug=layout: on-screen viewport diagnostics for mobile layout bugs. */
.layout-debug { position: fixed; top: 4px; left: 4px; z-index: 10; max-width: calc(100% - 8px); margin: 0; padding: 6px 8px;
  border-radius: 4px; background: #000c; color: #9ff; font: 11px/1.35 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }
