:root {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #171b24;
  --surface-2: #202634;
  --line: #2c3444;
  --text: #f2f5fa;
  --muted: #9aa5b6;
  --accent: #ffb703;
  --accent-2: #ff7a59;
  --ok: #35d399;
  --warn: #ffb703;
  --off: #ff5d5d;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(255, 183, 3, .1), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 122, 89, .08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  font-size: 24px;
  box-shadow: 0 8px 24px rgba(255, 122, 89, .25);
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: -.02em;
}

.brand p { margin: 0; color: var(--muted); font-size: 14px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(255, 183, 3, .14);
}

.status--live .status__dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(53, 211, 153, .16);
  animation: pulse 2s ease-in-out infinite;
}

.status--offline .status__dot {
  background: var(--off);
  box-shadow: 0 0 0 4px rgba(255, 93, 93, .14);
}

/* Viewer */
.viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #05070b;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.viewer:fullscreen { aspect-ratio: auto; border: 0; border-radius: 0; }

.viewer__feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #05070b;
}

.viewer__spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  background: rgba(5, 7, 11, .55);
  transition: opacity .25s ease;
}

.viewer__spinner.is-hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, .16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.viewer__live,
.viewer__clock {
  position: absolute;
  top: 14px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.viewer__live { left: 14px; display: flex; align-items: center; gap: 8px; }
.viewer__clock { right: 14px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--off);
  animation: pulse 1.6s ease-in-out infinite;
}

.viewer__fullscreen {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.viewer__fullscreen:hover { background: rgba(0, 0, 0, .8); }

/* Controls */
.controls {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 18px;
}

.controls__form { display: flex; flex-direction: column; gap: 9px; }

.controls__form label { font-size: 13px; font-weight: 600; color: var(--muted); }

.controls__row { display: flex; gap: 10px; }

.controls__row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.controls__row input:focus-visible,
.btn:focus-visible,
.viewer__fullscreen:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #445069; }
.btn--primary { background: linear-gradient(145deg, var(--accent), var(--accent-2)); border-color: transparent; color: #1a1206; }
.btn--icon { padding: 12px 14px; font-size: 18px; }

.controls__hint { margin: 0; color: var(--muted); font-size: 12px; }

/* Footer */
.footer { color: var(--muted); font-size: 12px; }
.footer summary { cursor: pointer; }
.footer code { display: inline-block; margin-top: 8px; word-break: break-all; color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 600px) {
  .controls__row { flex-direction: column; }
  .btn { width: 100%; }
  .viewer__clock { display: none; }
}
