:root {
  color-scheme: dark;
  --base: #101516;
  --panel: #171e1e;
  --line: #2d3a38;
  --muted: #a9b8b2;
  --text: #eff6f2;
  --accent: #a9edbc;
  --accent-bg: #224333;
  font: 100% / 1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--base);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.masthead { border-bottom: 1px solid var(--line); background: #141a1b; }
.masthead-inner, main { max-width: 1312px; margin: 0 auto; padding-inline: clamp(1rem, 4vw, 3rem); }
.masthead-inner { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.identity { display: flex; align-items: center; gap: .78rem; font-size: 1.08rem; font-weight: 650; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--accent); background: var(--accent-bg); }
.mark svg { width: 26px; height: 26px; }
.connection-summary { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.connection-summary::before, .camera-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: .5em; border-radius: 100%; background: currentColor; vertical-align: .08em; }
.connection-summary[data-online="true"] { color: var(--accent); }

main { padding-block: clamp(1.8rem, 5vw, 3.75rem); }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.55rem; }
.heading h1 { margin: 0; font-weight: 650; font-size: clamp(2rem, 4.8vw, 3rem); letter-spacing: -.045em; line-height: 1.1; }
.heading p, .camera-header p { margin: .35rem 0 0; color: var(--muted); }
.view-controls { display: flex; padding: .25rem; gap: .2rem; border: 1px solid var(--line); border-radius: 10px; background: #161c1d; }
.view-controls button, .camera-picker button { display: flex; align-items: center; gap: .45rem; padding: .44rem .68rem; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: .9rem; }
.view-controls svg { width: 20px; height: 20px; }
.view-controls button[aria-pressed="true"], .camera-picker button[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); }
.view-controls button:not(:disabled):hover, .camera-picker button:hover { color: var(--text); }
.camera-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.camera-picker button { border-color: var(--line); }

.camera-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.camera-grid.is-focused { grid-template-columns: minmax(0, 1fr); max-width: 960px; }
.camera-card { min-width: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; }
.camera-header { min-height: 73px; padding: .85rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
.camera-header h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; font-weight: 650; }
.camera-header p { margin-top: .16rem; font-size: .88rem; }
.camera-status { flex-shrink: 0; color: var(--muted); padding: .22rem .55rem; border: 1px solid var(--line); border-radius: 999px; font-size: .87rem; }
[data-state="live"] .camera-status { color: var(--accent); border-color: #37654a; background: #1d3528; }
[data-state="offline"] .camera-status { color: #ffdba9; border-color: #5a4933; }
.screen { position: relative; overflow: hidden; display: grid; place-items: center; aspect-ratio: 16 / 9; background-color: #0f1415; }
.screen video { position: absolute; inset: 0; width: 100%; height: 100%; background: black; object-fit: contain; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem; padding: .6rem; }
.empty-state svg { width: 44px; height: 44px; color: #8aab9a; }
.empty-state p { margin: 0; color: var(--muted); font-size: .9rem; }
[data-state="live"] .empty-state { display: none; }
.retry { padding: .26rem .7rem; border: 1px solid #496454; border-radius: 6px; background: #192721; font-size: .87rem; }
.retry:hover, .select-camera:hover { color: var(--accent); }
.camera-card footer { padding: .64rem 1rem; border-top: 1px solid var(--line); }
.select-camera { padding: .15rem 0; color: var(--muted); border: 0; background: transparent; font-size: .9rem; }
.is-focused .camera-card footer { display: none; }
#page-message { color: #ffdba9; }

@media (max-width: 650px) {
  .masthead-inner { min-height: 60px; }
  .camera-grid { grid-template-columns: minmax(0, 1fr); }
  .heading { align-items: flex-start; }
  .view-controls button { gap: .28rem; padding-inline: .42rem; }
  .view-controls svg { width: 17px; height: 17px; }
}
