:root {
  color-scheme: dark;
  --bg: #07100f;
  --bg-elevated: #0d1717;
  --panel: rgba(15, 25, 25, 0.94);
  --panel-strong: #111d1d;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(154, 178, 172, 0.18);
  --text: #f1f7f4;
  --muted: #9db0aa;
  --subtle: #6f817c;
  --accent: #24d17e;
  --accent-strong: #18b56b;
  --accent-soft: rgba(36, 209, 126, 0.13);
  --warning: #f0a943;
  --danger: #ff6b5f;
  --danger-soft: rgba(255, 107, 95, 0.13);
  --ok: #68df8f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-height: 72px;
  --bottom-nav-height: 76px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Fira Sans", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(36, 209, 126, 0.08), transparent 28%),
    linear-gradient(180deg, #0b1414 0%, #06100f 52%, #040908 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, black, transparent 78%);
}

a,
button,
input,
select {
  font: inherit;
}

button,
a,
select,
input,
canvas {
  touch-action: manipulation;
}

button,
.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  color: #04100b;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover,
.button:hover {
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

button.secondary,
.button.secondary {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

button.ghost,
.button.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

:focus-visible {
  outline: 3px solid rgba(36, 209, 126, 0.78);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 10px 10px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
}

.topbar {
  position: static;
  z-index: 20;
  min-height: var(--topbar-height);
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: rgba(9, 18, 18, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-row,
.action-row,
.controls,
.range-readout {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-row {
  justify-content: space-between;
}

.brand {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 38px);
  line-height: 1.05;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.meta,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.desktop-nav {
  display: none;
}

.bottom-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 680px;
  margin: 0 auto;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: rgba(10, 18, 18, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.nav-link {
  min-height: 50px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  display: grid;
  place-items: center;
  font-weight: 700;
}

body[data-page="live"] .nav-live,
body[data-page="archive"] .nav-archive,
body[data-page="logins"] .nav-logins {
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid rgba(36, 209, 126, 0.28);
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.content {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.page-controls {
  padding: 10px;
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.page-controls .field {
  flex: 1 1 280px;
}

.page-controls button {
  flex: 0 0 auto;
}

.status-pill {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

.status-ok {
  color: var(--ok);
}

.status-danger {
  color: var(--danger);
}

[data-camera-status] {
  width: 156px;
  justify-content: center;
  flex: 0 0 156px;
}

.viewer {
  padding: 0;
}

.camera-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.camera-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
}

.camera-card-header,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.camera-title {
  display: grid;
  gap: 2px;
}

.camera-title .meta {
  margin: 0;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
}

.camera-video-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #010202;
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: #010202;
  object-fit: contain;
  transform-origin: center center;
  touch-action: none;
}

.live-video-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 14px;
  color: var(--text);
  background: rgba(1, 2, 2, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.live-video-state.is-visible {
  opacity: 1;
}

.live-video-state-label {
  min-width: 128px;
  border: 1px solid rgba(154, 178, 172, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  color: var(--text);
  background: rgba(7, 16, 15, 0.78);
  box-shadow: var(--shadow);
}

.live-video-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: live-spin 900ms linear infinite;
}

.live-video-state:not(.is-loading) .live-video-spinner {
  display: none;
}

.live-video-state.is-warning .live-video-state-label {
  border-color: rgba(240, 169, 67, 0.34);
  color: var(--warning);
}

.live-video-state.is-error .live-video-state-label {
  border-color: rgba(255, 107, 95, 0.38);
  color: var(--danger);
}

.live-retry-button {
  pointer-events: auto;
}

.live-theater-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 40;
  min-height: 38px;
  padding: 7px 11px;
  color: var(--text);
  background: rgba(7, 16, 15, 0.78);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
}

.live-audio-button {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 40;
  min-height: 38px;
  padding: 7px 11px;
  color: var(--text);
  background: rgba(7, 16, 15, 0.78);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
}

@keyframes live-spin {
  to {
    transform: rotate(360deg);
  }
}

.archive-layout {
  display: grid;
  gap: 10px;
}

.archive-video-panel,
.timeline-panel,
.journal {
  padding: 8px;
}

.archive-video-panel {
  overflow: hidden;
}

.archive-video-panel video {
  max-height: 62dvh;
}

.timeline-panel {
  display: grid;
  gap: 10px;
}

.timeline-controls {
  display: grid;
  gap: 8px;
}

.range-actions {
  margin-top: 2px;
}

.time-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
}

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

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.065);
}

select {
  padding-right: 34px;
}

input::placeholder {
  color: var(--subtle);
}

canvas {
  width: 100%;
  height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  cursor: crosshair;
  touch-action: none;
}

.range-readout {
  justify-content: space-between;
  color: var(--muted);
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
}

.readout-card {
  flex: 1 1 160px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

body[data-page="archive"] .timeline-panel {
  align-content: start;
}

body[data-page="archive"] .range-select-actions,
body[data-page="archive"] .range-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

body[data-page="archive"] .range-select-actions button:first-child,
body[data-page="archive"] .range-actions button:first-child {
  grid-column: 1 / -1;
}

.range-mark-button {
  width: 44px;
  flex: 0 0 44px;
  padding: 0;
}

.range-mark-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.range-mark-label {
  display: none;
}

.table-wrap {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  position: sticky;
  top: calc(var(--topbar-height) + 12px);
}

tr:last-child td {
  border-bottom: 0;
}

.event-ok {
  color: var(--ok);
  font-weight: 700;
}

.event-danger {
  color: var(--danger);
  font-weight: 700;
}

.hash-cell,
.user-agent-cell {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.hash-cell {
  font-family: "Fira Code", ui-monospace, monospace;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.mt-10 {
  margin-top: 10px;
}

.mb-10 {
  margin-bottom: 10px;
}

.login-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(2, 7, 7, 0.78);
  backdrop-filter: blur(14px);
}

.login-box {
  width: min(420px, 100%);
  padding: 18px;
}

.login-box h2 {
  font-size: 26px;
}

.login-box form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.error {
  min-height: 22px;
  color: var(--danger);
  font-weight: 700;
}

.action-row button,
.action-row .button {
  flex: 1 1 auto;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 8px 8px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 10px);
  }

  .topbar {
    position: relative;
    min-height: 0;
    gap: 8px;
    padding: 10px;
    background: #0b1515;
    box-shadow: none;
  }

  .brand-row {
    align-items: flex-start;
  }

  h1 {
    font-size: 28px;
  }

  .brand .meta {
    display: none;
  }

  .desktop-only {
    display: none !important;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .action-row .status-pill {
    grid-column: 1 / -1;
  }

  .action-row #logoutButton {
    grid-column: 2;
    grid-row: 1;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
    background: transparent;
  }

  .action-row .status-pill {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .content {
    margin-top: 8px;
    gap: 8px;
  }

  .archive-layout {
    gap: 8px;
  }

  .archive-video-panel,
  .timeline-panel,
  .journal {
    padding: 6px;
  }

  .archive-video-panel video {
    max-height: none;
  }

  .timeline-panel .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .timeline-panel .controls button:first-child {
    grid-column: 1 / -1;
  }

  .range-select-actions {
    grid-template-columns: 1fr 1fr !important;
  }

  .range-select-actions #applyRangeButton {
    grid-column: 1 / -1;
  }

  .range-select-actions #markRangeStartButton,
  .range-select-actions #markRangeEndButton {
    width: auto;
    padding-inline: 8px;
    font-size: 13px;
  }

  .range-select-actions .range-mark-button svg {
    display: none;
  }

  .range-select-actions .range-mark-label {
    display: inline;
  }

  .range-select-actions #zoomInButton,
  .range-select-actions #zoomOutButton,
  .range-select-actions #nowButton {
    display: none;
  }

  .timeline-panel {
    gap: 8px;
  }

  .time-fields {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .time-fields label {
    font-size: 12px;
  }

  .time-fields input {
    min-height: 40px;
    padding: 8px 9px;
    font-size: 13px;
  }

  .timeline-panel .section-header .meta {
    display: none;
  }

  canvas {
    height: 84px;
  }

  .readout-card {
    flex-basis: 100%;
  }

  .range-readout {
    display: block;
  }

  .range-readout .readout-card {
    display: none;
    min-height: 0;
    padding: 7px 8px;
    font-size: 12px;
  }

  .range-readout #selectedTime {
    display: block;
  }

  .range-actions {
    margin-bottom: 10px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody {
    display: grid;
    gap: 8px;
  }

  tr {
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) 1fr;
    gap: 8px;
    padding: 8px 10px;
  }

  td::before {
    content: attr(data-label);
    color: var(--subtle);
    font-weight: 700;
  }

  td.empty-state {
    display: block;
  }

  td.empty-state::before {
    content: "";
  }
}

@media (max-width: 360px) {
  .time-fields {
    grid-template-columns: 1fr;
  }
}

body[data-page="live"].live-theater {
  overflow: hidden;
  background: #010202;
}

body[data-page="live"].live-theater::before {
  display: none;
}

body[data-page="live"].live-theater .app-shell {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  padding: 0;
}

body[data-page="live"].live-theater .topbar,
body[data-page="live"].live-theater .bottom-nav {
  display: none;
}

body[data-page="live"].live-theater .content,
body[data-page="live"].live-theater .viewer,
body[data-page="live"].live-theater .camera-grid {
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 0;
}

body[data-page="live"].live-theater .camera-grid {
  display: block;
  touch-action: pan-y;
}

body[data-page="live"].live-theater .camera-card {
  display: none;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #010202;
  box-shadow: none;
}

body[data-page="live"].live-theater .camera-card.is-active {
  display: block;
}

body[data-page="live"].live-theater .camera-video-shell {
  width: 100vw;
  height: 100dvh;
  border-radius: 0;
}

body[data-page="live"].live-theater .camera-card-header {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 35;
  max-width: min(380px, calc(100vw - 20px));
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: rgba(5, 10, 10, 0.72);
  pointer-events: none;
}

body[data-page="live"].live-theater .camera-card-header .status-pill::after {
  content: "  " attr(data-camera-position);
  color: var(--muted);
}

body[data-page="live"].live-theater [data-camera-status] {
  width: 164px;
  flex-basis: 164px;
}

body[data-page="live"].live-theater .live-video-state {
  inset: auto 10px 10px auto;
  z-index: 36;
  display: flex;
  min-height: 38px;
  max-width: min(320px, 45vw);
  padding: 0;
  background: transparent;
}

body[data-page="live"].live-theater .live-video-state-label {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 7px 10px;
  font-size: 13px;
  background: rgba(5, 10, 10, 0.72);
}

body[data-page="live"].live-theater .live-video-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

body[data-page="live"].live-theater .live-theater-button {
  top: 10px;
  right: 10px;
  bottom: auto;
  z-index: 38;
}

body[data-page="live"].live-theater .live-audio-button {
  top: 10px;
  left: 10px;
  bottom: auto;
  z-index: 38;
}

body[data-page="live"].live-theater video {
  width: 100vw;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  object-fit: contain;
}

@media (hover: none) and (pointer: coarse) {
  body[data-page="live"].live-theater.live-rotate .app-shell {
    position: fixed;
    inset: 0;
    width: 100dvh;
    height: 100dvw;
    min-height: 0;
    transform: rotate(-90deg) translateX(-100%);
    transform-origin: top left;
  }

  body[data-page="live"].live-theater.live-rotate .content,
  body[data-page="live"].live-theater.live-rotate .viewer,
  body[data-page="live"].live-theater.live-rotate .camera-grid,
  body[data-page="live"].live-theater.live-rotate .camera-card,
  body[data-page="live"].live-theater.live-rotate .camera-video-shell {
    width: 100dvh;
    height: 100dvw;
  }

  body[data-page="live"].live-theater.live-rotate video {
    width: 100dvh;
    height: 100dvw;
  }

  body[data-page="live"].live-theater.live-rotate .camera-card-header {
    max-width: min(380px, calc(100dvh - 20px));
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body[data-page="live"] {
    overflow: hidden;
    background: #010202;
  }

  body[data-page="live"]:not(.live-theater)::before {
    display: none;
  }

  body[data-page="live"]:not(.live-theater) .app-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
  }

  body[data-page="live"]:not(.live-theater) .topbar,
  body[data-page="live"]:not(.live-theater) .bottom-nav {
    display: none;
  }

  body[data-page="live"]:not(.live-theater) .content,
  body[data-page="live"]:not(.live-theater) .viewer,
  body[data-page="live"]:not(.live-theater) .camera-grid {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  body[data-page="live"]:not(.live-theater) .camera-grid {
    display: block;
    touch-action: pan-y;
  }

  body[data-page="live"]:not(.live-theater) .camera-card {
    display: none;
    width: 100vw;
    height: 100dvh;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #010202;
    box-shadow: none;
  }

  body[data-page="live"]:not(.live-theater) .camera-card.is-active {
    display: block;
  }

  body[data-page="live"]:not(.live-theater) .camera-video-shell {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  body[data-page="live"]:not(.live-theater) .camera-card-header {
    position: fixed;
    left: 10px;
    bottom: 10px;
    z-index: 35;
    max-width: min(380px, calc(100vw - 20px));
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    background: rgba(5, 10, 10, 0.72);
    pointer-events: none;
  }

  body[data-page="live"]:not(.live-theater) .camera-card-header .status-pill::after {
    content: "  " attr(data-camera-position);
    color: var(--muted);
  }

  body[data-page="live"]:not(.live-theater) [data-camera-status] {
    width: 164px;
    flex-basis: 164px;
  }

  body[data-page="live"]:not(.live-theater) .live-video-state {
    inset: auto 10px 10px auto;
    z-index: 36;
    display: flex;
    min-height: 38px;
    max-width: min(320px, 45vw);
    padding: 0;
    background: transparent;
  }

  body[data-page="live"]:not(.live-theater) .live-video-state-label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 7px 10px;
    font-size: 13px;
    background: rgba(5, 10, 10, 0.72);
  }

  body[data-page="live"]:not(.live-theater) .live-video-spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
  }

  body[data-page="live"]:not(.live-theater) .live-theater-button {
    display: none;
  }

  body[data-page="live"]:not(.live-theater) video {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    object-fit: contain;
  }
}

@media (min-width: 721px) {
  .app-shell {
    padding: 12px;
  }

  .login-shell {
    place-items: center;
  }

  .login-box {
    padding: 24px;
  }

  .topbar {
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
  }

  .action-row {
    display: grid;
    grid-template-columns: minmax(220px, 420px) auto;
    align-items: center;
    justify-content: end;
    gap: 8px;
  }

  .action-row .status-pill {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .action-row .desktop-nav {
    grid-column: 1;
    grid-row: 3;
    justify-self: end;
  }

  .action-row #logoutButton {
    grid-column: 2;
    grid-row: 3;
    min-width: 112px;
  }

  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .desktop-nav .nav-link {
    min-height: 44px;
    padding: 0 14px;
  }

  .bottom-nav {
    display: none;
  }

  .camera-grid {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }

  .archive-video-panel,
  .timeline-panel,
  .journal {
    padding: 12px;
  }

  .archive-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .timeline-panel {
    position: static;
  }

  body[data-page="archive"] .timeline-panel {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  body[data-page="archive"] .timeline-panel .section-header {
    grid-column: auto;
  }

  body[data-page="archive"] .timeline-panel .meta {
    font-size: 13px;
  }

  body[data-page="archive"] canvas {
    height: 112px;
  }

  body[data-page="archive"] .timeline-controls {
    grid-column: auto;
    grid-row: auto;
    display: grid;
    grid-template-columns: minmax(360px, 1fr) auto;
    align-items: end;
    gap: 10px;
  }

  body[data-page="archive"] .time-fields {
    gap: 8px;
  }

  body[data-page="archive"] .timeline-controls,
  body[data-page="archive"] .range-select-actions,
  body[data-page="archive"] .range-actions {
    gap: 8px;
  }

  body[data-page="archive"] .range-select-actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    flex-wrap: wrap;
    max-width: none;
  }

  body[data-page="archive"] .range-select-actions button:first-child {
    grid-column: auto;
  }

  body[data-page="archive"] .range-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body[data-page="archive"] .range-actions button:first-child {
    grid-column: auto;
  }

  body[data-page="archive"] .range-actions button,
  body[data-page="archive"] .range-select-actions button {
    min-height: 40px;
    padding: 8px 12px;
  }

  body[data-page="archive"] .range-select-actions .range-mark-button {
    width: 44px;
    padding: 0;
  }

  body[data-page="archive"] .range-readout {
    grid-column: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    flex-wrap: wrap;
  }

  body[data-page="archive"] .range-actions {
    grid-column: auto;
  }

  body[data-page="archive"] .readout-card {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .time-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1180px) {
  .camera-grid {
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
