@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600&display=swap");

:root {
  --shell-bg: #f5f6fa;
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-line: rgba(135, 146, 167, 0.16);
  --ink: #18233a;
  --ink-strong: #0f172a;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-border: rgba(79, 70, 229, 0.08);
  --border-light: rgba(226, 232, 240, 0.7);
  --danger: #ef4444;
  --danger-soft: #fff1f2;
  --control-height: 32px;
  /* Theme tokens. These defaults are the light theme; the themes below override them. */
  color-scheme: light;
  --app-bg: linear-gradient(180deg, #d9d8dc 0%, #dfe2eb 100%);
  --surface-rgb: 255 255 255;
  --surface-alt-rgb: 248 250 252;
  --surface-alt2-rgb: 245 247 252;
  --track-rgb: 226 232 240;
  --edge-rgb: 255 255 255;
  --highlight-rgb: 255 255 255;
  --highlight-strength: 1;
  --noise-dot: rgba(24, 35, 58, 0.055);
  --text-secondary: #475569;
  --text-input: #334155;
  --danger-soft-hover: #ffe4e6;
  --success-soft: #f0fdf4;
  --success-text: #15803d;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --track-rgb: 51 65 85;
  --app-bg: linear-gradient(180deg, #0b1120 0%, #0f172a 100%);
  --surface-rgb: 30 41 59;
  --surface-alt-rgb: 15 23 42;
  --surface-alt2-rgb: 24 33 51;
  --edge-rgb: 71 85 105;
  --highlight-rgb: 255 255 255;
  --highlight-strength: 0.06;
  --noise-dot: rgba(255, 255, 255, 0.035);
  --ink: #e2e8f0;
  --ink-strong: #f8fafc;
  --muted: #94a3b8;
  --muted-soft: #64748b;
  --text-secondary: #cbd5e1;
  --text-input: #e2e8f0;
  --border-light: rgba(71, 85, 105, 0.55);
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.2);
  --accent-border: rgba(129, 140, 248, 0.35);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --danger-soft-hover: rgba(239, 68, 68, 0.22);
  --success-soft: rgba(34, 197, 94, 0.14);
  --success-text: #4ade80;
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --track-rgb: 30 50 92;
  --app-bg: linear-gradient(180deg, #050b1d 0%, #0a1430 100%);
  --surface-rgb: 20 33 66;
  --surface-alt-rgb: 10 19 42;
  --surface-alt2-rgb: 16 27 56;
  --edge-rgb: 45 70 120;
  --highlight-rgb: 255 255 255;
  --highlight-strength: 0.06;
  --noise-dot: rgba(125, 211, 252, 0.04);
  --ink: #dbeafe;
  --ink-strong: #f0f9ff;
  --muted: #93a4c4;
  --muted-soft: #5d6f92;
  --text-secondary: #bfd3f2;
  --text-input: #dbeafe;
  --border-light: rgba(45, 70, 120, 0.6);
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --accent-border: rgba(56, 189, 248, 0.35);
  --danger: #fb7185;
  --danger-soft: rgba(244, 63, 94, 0.15);
  --danger-soft-hover: rgba(244, 63, 94, 0.24);
  --success-soft: rgba(34, 197, 94, 0.14);
  --success-text: #4ade80;
}

:root[data-theme="graphite"] {
  color-scheme: dark;
  --track-rgb: 63 63 70;
  --app-bg: linear-gradient(180deg, #111113 0%, #18181b 100%);
  --surface-rgb: 39 39 42;
  --surface-alt-rgb: 24 24 27;
  --surface-alt2-rgb: 32 32 35;
  --edge-rgb: 63 63 70;
  --highlight-rgb: 255 255 255;
  --highlight-strength: 0.05;
  --noise-dot: rgba(255, 255, 255, 0.03);
  --ink: #e4e4e7;
  --ink-strong: #fafafa;
  --muted: #a1a1aa;
  --muted-soft: #71717a;
  --text-secondary: #d4d4d8;
  --text-input: #e4e4e7;
  --border-light: rgba(63, 63, 70, 0.7);
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: rgba(16, 185, 129, 0.16);
  --accent-border: rgba(52, 211, 153, 0.32);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --danger-soft-hover: rgba(239, 68, 68, 0.22);
  --success-soft: rgba(16, 185, 129, 0.14);
  --success-text: #34d399;
}

/* Dark themes: the few accents tuned for a light page. */
:root[data-theme="dark"] .passkey-button,
:root[data-theme="midnight"] .passkey-button,
:root[data-theme="graphite"] .passkey-button {
  background: var(--ink-strong);
  color: #0f172a;
}

:root[data-theme="dark"] .passkey-button:hover,
:root[data-theme="midnight"] .passkey-button:hover,
:root[data-theme="graphite"] .passkey-button:hover {
  background: var(--ink);
}

:root[data-theme="dark"] .rail-nav a,
:root[data-theme="midnight"] .rail-nav a,
:root[data-theme="graphite"] .rail-nav a {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .rail-nav a:hover,
:root[data-theme="dark"] .rail-nav a.active,
:root[data-theme="midnight"] .rail-nav a:hover,
:root[data-theme="midnight"] .rail-nav a.active,
:root[data-theme="graphite"] .rail-nav a:hover,
:root[data-theme="graphite"] .rail-nav a.active {
  color: var(--ink-strong);
}

:root[data-theme="dark"] .rail-nav a.active .nav-icon,
:root[data-theme="dark"] .rail-nav a:hover .nav-icon,
:root[data-theme="midnight"] .rail-nav a.active .nav-icon,
:root[data-theme="midnight"] .rail-nav a:hover .nav-icon,
:root[data-theme="graphite"] .rail-nav a.active .nav-icon,
:root[data-theme="graphite"] .rail-nav a:hover .nav-icon,
:root[data-theme="dark"] .back-link,
:root[data-theme="midnight"] .back-link,
:root[data-theme="graphite"] .back-link {
  color: color-mix(in srgb, var(--accent) 55%, white);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  min-height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
  padding: 0;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  font-size: 13px;
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 24%),
    var(--app-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button,
.button,
.viewer-actions a {
  min-height: var(--control-height);
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0.35rem 0.75rem;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 10px rgba(79, 70, 229, 0.24);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

button:hover,
.button:hover,
.viewer-actions a:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.danger {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength)));
}

.danger:hover {
  background: var(--danger-soft-hover);
  color: #be123c;
}

.glass-panel,
.app-shell,
.login-panel,
.panel,
.empty {
  background: linear-gradient(180deg, rgb(var(--surface-rgb) / 0.92), rgb(var(--surface-alt2-rgb) / 0.84));
  border: 1px solid rgb(var(--edge-rgb) / 0.75);
  box-shadow: 0 24px 80px rgba(45, 57, 87, 0.12), inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.8 * var(--highlight-strength)));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.grid-noise {
  background-image:
    radial-gradient(var(--noise-dot) 0.7px, transparent 0.7px),
    linear-gradient(180deg, rgb(var(--surface-rgb) / 0.25), rgb(var(--surface-rgb) / 0));
  background-size: 18px 18px, 100% 100%;
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.mobile-topbar {
  display: none;
}

.side-rail {
  display: flex;
  width: 232px;
  min-width: 232px;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  background: rgb(var(--surface-rgb) / 0.52);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem;
  border-bottom: 1px solid var(--border-light);
}

.brand-text {
  min-width: 0;
}

.sidebar-toggle {
  display: inline-grid;
  flex: none;
  width: 30px;
  min-height: 30px;
  height: 30px;
  margin-left: auto;
  place-items: center;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  background: rgb(var(--surface-rgb));
  color: var(--muted);
  padding: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.brand-cube {
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #a5e9ef;
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  transform: none;
}

.sidebar-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 0.18s ease;
}

/* Collapsed sidebar: icons only. Labels stay readable to screen readers. */
.side-rail {
  transition: width 0.18s ease, min-width 0.18s ease;
}

:root[data-sidebar="collapsed"] .side-rail {
  width: 68px;
  min-width: 68px;
}

:root[data-sidebar="collapsed"] .brand-block {
  flex-direction: column;
  justify-content: center;
  gap: 0.6rem;
  padding-inline: 0.5rem;
}

:root[data-sidebar="collapsed"] .brand-cube {
  display: grid;
}

:root[data-sidebar="collapsed"] .brand-text,
:root[data-sidebar="collapsed"] .rail-section-label {
  display: none;
}

:root[data-sidebar="collapsed"] .sidebar-toggle {
  margin-left: 0;
}

:root[data-sidebar="collapsed"] .sidebar-toggle svg {
  transform: rotate(180deg);
}

:root[data-sidebar="collapsed"] .rail-nav,
:root[data-sidebar="collapsed"] .rail-footer {
  padding-inline: 0.6rem;
}

:root[data-sidebar="collapsed"] .rail-nav a {
  justify-content: center;
  padding-inline: 0;
}

:root[data-sidebar="collapsed"] .nav-label,
:root[data-sidebar="collapsed"] .side-rail .user-meta,
:root[data-sidebar="collapsed"] .side-rail .user-chip-caret {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:root[data-sidebar="collapsed"] .side-rail button.user-chip {
  justify-content: center;
  padding: 0.4rem 0;
}

:root[data-sidebar="collapsed"] .side-rail .user-menu-popover {
  right: auto;
  width: 240px;
}

.brand-title {
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-kicker,
.eyebrow,
.section-eyebrow {
  color: var(--muted-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rail-nav {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem;
}

.rail-section-label {
  padding: 0 0.55rem 0.2rem;
  color: var(--muted-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav-icon {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--muted-soft);
  transition: color 0.18s ease;
}

.rail-nav a.active .nav-icon,
.rail-nav a:hover .nav-icon {
  color: var(--accent);
}

.rail-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.18s ease, color 0.18s ease;
}

/* Tools in the sidebar (buttons that look like nav items). */
.rail-tool {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 0;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  padding: 0.55rem 0.7rem;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  box-shadow: none;
}

.rail-tool:hover,
.rail-tool.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-border);
  transform: none;
}

.rail-tool.active .nav-icon,
.rail-tool:hover .nav-icon {
  color: var(--accent);
}

:root[data-theme="dark"] .rail-tool,
:root[data-theme="midnight"] .rail-tool,
:root[data-theme="graphite"] .rail-tool {
  color: var(--text-secondary);
}

:root[data-sidebar="collapsed"] .rail-tool {
  justify-content: center;
  padding-inline: 0;
}

.rail-nav a:hover,
.rail-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.rail-footer {
  margin-top: auto;
  padding: 0.9rem;
  border-top: 1px solid var(--border-light);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 12px;
  background: rgb(var(--surface-rgb) / 0.72);
  padding: 0.65rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.user-menu {
  position: relative;
}

button.user-chip {
  width: 100%;
  min-height: 0;
  border: 1px solid transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

button.user-chip:hover,
button.user-chip:focus-visible,
button.user-chip.active,
.user-menu.open button.user-chip {
  border-color: var(--accent-border);
  background: rgb(var(--surface-rgb));
  transform: none;
}

.user-chip-caret {
  width: 8px;
  height: 8px;
  margin-right: 0.2rem;
  border-top: 2px solid var(--muted-soft);
  border-right: 2px solid var(--muted-soft);
  transform: rotate(-45deg) translate(-1px, 1px);
  transition: transform 0.18s ease;
}

.user-menu.open .user-chip-caret {
  transform: rotate(135deg) translate(-1px, 1px);
}

.user-menu-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.4rem);
  left: 0;
  z-index: 50;
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb));
  padding: 0.35rem;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.user-menu-popover a,
.user-menu-popover button {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.user-menu-popover a span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.user-menu-popover a:hover,
.user-menu-popover a:focus-visible,
.user-menu-popover a.active,
.user-menu-popover button:hover,
.user-menu-popover button:focus-visible {
  outline: none;
  background: var(--accent-soft);
  transform: none;
}

.user-menu-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin: 0.15rem 0;
  padding: 0.5rem 0.65rem;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.user-menu-theme select {
  width: auto;
  min-width: 112px;
  height: 30px;
  font-weight: 700;
}

.user-menu-popover .user-menu-logout {
  color: var(--danger);
}

.user-menu-popover .user-menu-logout:hover,
.user-menu-popover .user-menu-logout:focus-visible {
  background: var(--danger-soft);
}

.user-menu-who {
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.2rem;
  padding: 0.45rem 0.65rem 0.55rem;
}

.user-menu-who strong,
.user-menu-who span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-who span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.user-menu-mobile {
  margin-left: auto;
}

.mobile-account:hover,
.user-menu.open .mobile-account {
  background: linear-gradient(135deg, #4338ca, #0ea5e9);
  transform: none;
}

.user-menu-mobile .user-menu-popover {
  top: calc(100% + 0.4rem);
  bottom: auto;
  left: auto;
  width: min(260px, calc(100vw - 1.5rem));
}

.mobile-account {
  display: grid;
  width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #38bdf8);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.avatar {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #38bdf8);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-meta strong,
.user-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 48px;
  border-bottom: 1px solid var(--border-light);
  background: rgb(var(--surface-rgb) / 0.45);
  padding: 0.5rem 0.75rem;
}

.workspace-bar-title strong {
  display: block;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 900;
}

.workspace-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  padding: 0.5rem;
}

.page-head,
.viewer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
}

h1 {
  color: var(--ink-strong);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.75rem;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.camera-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb) / 0.48);
  padding: 0.65rem 0.75rem;
}

.camera-toolbar strong {
  display: block;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 900;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions button[data-muted="true"] {
  background: #475569;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 10px rgba(71, 85, 105, 0.22);
}

.live-toolbar {
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 247, 252, 0.82));
  color: var(--ink);
  box-shadow: 0 10px 35px rgba(45, 57, 87, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.live-toolbar .section-eyebrow {
  color: var(--muted-soft);
}

.live-toolbar strong {
  color: var(--ink-strong);
}

.live-toolbar button {
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 10px rgba(79, 70, 229, 0.22);
}

.live-toolbar button:hover {
  background: var(--accent-hover);
}

.live-toolbar .toolbar-actions button[data-muted="true"] {
  background: #475569;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 10px rgba(71, 85, 105, 0.2);
}

.preset-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.preset-picker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.popover-menu {
  position: relative;
}

.icon-button {
  display: inline-grid;
  width: var(--control-height);
  min-height: var(--control-height);
  height: var(--control-height);
  place-items: center;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: rgb(var(--surface-rgb));
  color: var(--muted);
  padding: 0;
  box-shadow: none;
}

.icon-button:hover,
.icon-button:focus-visible,
.popover-menu.open .icon-button {
  background: var(--accent-soft);
  color: var(--accent);
  transform: none;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.preset-menu .user-menu-popover {
  top: calc(100% + 0.4rem);
  right: 0;
  bottom: auto;
  left: auto;
  width: 190px;
}

.preset-picker select {
  width: auto;
  min-width: 180px;
  max-width: 280px;
  border-color: var(--border-light);
  background-color: rgb(var(--surface-rgb));
}

.preset-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb));
  color: var(--ink);
  padding: 1rem;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.preset-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.preset-dialog h2 {
  margin-bottom: 0;
}

.preset-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 0.6rem;
}

.preset-camera-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preset-camera-count {
  margin-right: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.preset-camera-list {
  max-height: min(320px, 45dvh);
  overflow: auto;
}

.preset-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.preset-dialog-actions .danger {
  margin-right: auto;
}

.content-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding-right: 0.25rem;
}

.content-scroll::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.content-scroll::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(120, 134, 163, 0.3);
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 0.75rem;
}

.camera-wall-scroll {
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

.frigate-grid {
  position: relative;
  grid-template-columns: repeat(var(--camera-columns, 3), minmax(0, 1fr));
  gap: 0.65rem;
}

.frigate-tile .tile-link {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.camera-tile.is-dragging {
  z-index: 20;
  border-radius: 12px;
  box-shadow: 0 0 0 2px var(--accent), 0 22px 50px rgba(15, 23, 42, 0.38);
}

.camera-tile.is-dragging .tile-drag-hint {
  opacity: 0 !important;
}

.tile-drop-slot {
  position: absolute;
  z-index: 0;
  border: 2px dashed rgba(79, 70, 229, 0.6);
  border-radius: 12px;
  background: rgba(79, 70, 229, 0.08);
  pointer-events: none;
  transition: left 0.18s ease, top 0.18s ease;
}

body.tile-dragging,
body.tile-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.tile-fullscreen {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  z-index: 4;
  display: inline-flex;
  width: 40px;
  min-height: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  padding: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.tile-fullscreen svg {
  width: 18px;
  height: 18px;
}

.tile-fullscreen:hover,
.tile-fullscreen:focus-visible {
  background: rgba(79, 70, 229, 0.92);
}

/* Picture-in-picture button, left of the full-screen one. */
.tile-pip {
  position: absolute;
  right: calc(0.6rem + 46px);
  bottom: 0.6rem;
  z-index: 4;
  display: inline-flex;
  width: 40px;
  min-height: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  padding: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.tile-pip svg {
  width: 19px;
  height: 19px;
}

.tile-pip:hover,
.tile-pip:focus-visible {
  background: rgba(79, 70, 229, 0.92);
}

.tile-pip.active {
  background: #0284c7;
}

.camera-tile.is-dragging .tile-pip,
.camera-tile.is-dragging .tile-fullscreen {
  opacity: 0;
}

/* Mouse and trackpad: show the full-screen button only while hovering the camera.
   Touch screens have no hover, so there it stays visible. */
@media (hover: hover) and (pointer: fine) {
  .tile-fullscreen {
    opacity: 0;
    transition: opacity 0.16s ease, background 0.16s ease;
  }

  .tile-pip {
    opacity: 0;
    transition: opacity 0.16s ease, background 0.16s ease;
  }

  .camera-tile:not(.is-dragging):hover .tile-fullscreen,
  .tile-fullscreen:focus-visible,
  .camera-tile:not(.is-dragging):hover .tile-pip,
  .tile-pip:focus-visible,
  .tile-pip.active {
    opacity: 1;
  }
}

.live-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: hidden;
  background: #050505;
  outline: none;
  touch-action: none;
}

.live-fullscreen.zoomed {
  cursor: grab;
}

.live-fullscreen.panning {
  cursor: grabbing;
}

.live-fullscreen-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #050505;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
}

.live-zoom-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1;
  min-height: 0;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.live-fullscreen:hover .live-zoom-badge,
.live-zoom-badge.visible {
  opacity: 1;
}

.tile-drag-hint {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 3;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  padding: 0.25rem 0.5rem;
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.frigate-tile:hover .tile-drag-hint {
  opacity: 1;
}

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

.camera-tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb) / 0.48);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.tile-link {
  display: grid;
  position: relative;
}

.camera-tile iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #050505;
}

.frigate-tile {
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

.frigate-tile iframe {
  border-radius: 12px;
  background: #050505;
  pointer-events: none;
}

.frigate-tile .tile-link::after {
  display: none;
}

.camera-tile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 900;
}

.frigate-tile .camera-tile-meta {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  width: auto;
  max-width: calc(100% - 1.2rem);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  padding: 0.25rem 0.45rem;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.camera-tile-meta strong,
.camera-tile-meta small {
  display: block;
}

.camera-tile-meta small {
  margin-left: 0.6rem;
  color: rgba(255, 255, 255, 0.74);
  font-size: 9px;
  font-weight: 650;
}

.frigate-tile:hover .camera-tile-meta {
  opacity: 1;
}



.camera-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.6rem;
  background: #050505;
  padding: 0.75rem;
}

/* Explicit rows so the floating toolbar can share the video's cell. */
.camera-fullscreen > .fullscreen-bar {
  grid-row: 1;
}

.camera-fullscreen > .fullscreen-single-view,
.camera-fullscreen > .fullscreen-multi-view {
  grid-row: 2;
  grid-column: 1;
}

.camera-fullscreen > .fullscreen-timeline {
  grid-row: 3;
}

/* Floating playback toolbar on the right edge of the video. */
.fullscreen-toolbar {
  display: flex;
  grid-row: 2;
  grid-column: 1;
  z-index: 4;
  flex-direction: column;
  align-items: center;
  align-self: center;
  justify-self: end;
  gap: 0.3rem;
  margin-right: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  padding: 0.35rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.toolbar-button {
  display: grid;
  width: 36px;
  min-height: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  padding: 0;
  box-shadow: none;
}

.toolbar-button:hover,
.toolbar-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
}

.toolbar-button svg {
  width: 18px;
  height: 18px;
}

.toolbar-button .icon-pause,
.toolbar-button[data-playing="true"] .icon-play {
  display: none;
}

.toolbar-button[data-playing="true"] .icon-pause {
  display: block;
}

.toolbar-button[data-state="busy"] {
  opacity: 0.6;
}

.toolbar-button[data-state="ok"] {
  color: #4ade80;
}

.toolbar-button[data-state="error"] {
  color: #f87171;
}

.toolbar-speed {
  width: 40px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  padding: 0;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-align-last: center;
  box-shadow: none;
}

.toolbar-speed option {
  background: #0f172a;
  color: #fff;
}

.toolbar-divider {
  width: 22px;
  height: 1px;
  margin: 0.15rem 0;
  background: rgba(255, 255, 255, 0.16);
}

.toolbar-button {
  position: relative;
}

.toolbar-button.active {
  background: rgba(79, 70, 229, 0.55);
  color: #fff;
}

/* Motion highlights toggle: amber like the motion marks when on. */
.toolbar-button.motion-toggle.active {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.toolbar-button.motion-toggle:not(.active) {
  color: rgba(226, 232, 240, 0.55);
}

.toolbar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  background: #22c55e;
  color: #052e16;
  padding: 0 3px;
  font-size: 9.5px;
  font-weight: 900;
  line-height: 15px;
  text-align: center;
}

/* "Cameras on screen": floating, draggable by its header. */
.camera-picker {
  position: absolute;
  top: 5rem;
  right: 4.6rem;
  z-index: 6;
  display: grid;
  gap: 0.5rem;
  width: min(300px, calc(100% - 1.5rem));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  padding: 0.5rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.camera-picker.dragging {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.camera-picker-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.15rem 0.15rem 0.5rem;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.camera-picker.dragging .camera-picker-head {
  cursor: grabbing;
}

.camera-picker-head div {
  flex: 1;
  min-width: 0;
}

.camera-picker-head strong,
.camera-picker-head span {
  display: block;
}

.camera-picker-head strong {
  color: #fff;
  font-size: 12.5px;
  font-weight: 800;
}

.camera-picker-head span {
  color: rgba(203, 213, 225, 0.72);
  font-size: 10.5px;
  font-weight: 600;
}

.camera-picker-grip {
  flex: none;
  width: 16px;
  height: 16px;
  color: rgba(203, 213, 225, 0.6);
}

.camera-picker-close {
  display: grid;
  width: 28px;
  min-height: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: #e2e8f0;
  padding: 0;
  box-shadow: none;
}

.camera-picker-close:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
}

.camera-picker-close svg {
  width: 16px;
  height: 16px;
}

.camera-picker .camera-selection-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-height: min(60vh, 460px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
}

.camera-picker .camera-selection-list button {
  min-width: 0;
  text-align: left;
}

.camera-picker .camera-selection-list button[data-screen-camera] {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
}

.camera-picker .camera-selection-command {
  text-align: center;
}

.fullscreen-close {
  display: grid;
  width: 36px;
  min-height: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
}

.fullscreen-close svg {
  width: 18px;
  height: 18px;
}

.toolbar-button.controls-toggle svg {
  transition: transform 0.18s ease;
}

.camera-fullscreen.controls-collapsed .toolbar-button.controls-toggle svg {
  transform: rotate(180deg);
}

.camera-fullscreen.mini-player .camera-picker,
.camera-fullscreen.mini-player .fullscreen-toolbar {
  display: none;
}

.camera-fullscreen.open {
  display: grid;
}

.fullscreen-open {
  overflow: hidden;
}

.fullscreen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.82);
  padding: 0.65rem 0.75rem;
}

.fullscreen-mode {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  margin-left: 1rem;
}

.fullscreen-bar .fullscreen-mode-pill {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  padding: 0.2rem 0.65rem;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.fullscreen-mode .playback-status {
  overflow: hidden;
  margin-left: 0;
  color: rgba(203, 213, 225, 0.8);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cameras without recording access: live only, no timeline tools. */
.fullscreen-bar .no-recordings-note {
  display: none;
}

.fullscreen-bar .no-audio-note {
  display: none;
}

.camera-fullscreen.no-audio .fullscreen-bar .no-audio-note {
  display: inline-block;
}

.camera-fullscreen.no-recordings .fullscreen-bar .no-recordings-note {
  display: inline-block;
}

.camera-fullscreen.no-recordings #fullscreen-timeline-title,
.camera-fullscreen.no-recordings .footage-hours-note,
.camera-fullscreen.no-recordings #fullscreen-controls,
.camera-fullscreen.no-recordings #fullscreen-live,
.camera-fullscreen.no-recordings #fullscreen-play-pause,
.camera-fullscreen.no-recordings #fullscreen-speed,
.camera-fullscreen.no-recordings #fullscreen-motion-highlights,
.camera-fullscreen.no-recordings #fullscreen-select-clip,
.camera-fullscreen.no-recordings #fullscreen-controls-toggle,
.camera-fullscreen.no-recordings .toolbar-divider,
.camera-fullscreen.no-recordings #fullscreen-zoom-in,
.camera-fullscreen.no-recordings #fullscreen-zoom-out,
.camera-fullscreen.no-recordings #fullscreen-zoom-reset {
  display: none;
}

.footage-hours-note {
  overflow: hidden;
  color: #fbbf24;
  font-size: 11.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-toolbar .footage-hours-note {
  display: block;
  margin-top: 0.15rem;
  color: #b45309;
}

.camera-fullscreen.mini-player .fullscreen-mode {
  display: none;
}

.fullscreen-bar strong {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.fullscreen-actions {
  display: flex;
  gap: 0.5rem;
}

.fullscreen-actions button {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.fullscreen-actions button:hover {
  background: rgba(255, 255, 255, 0.24);
}

.camera-fullscreen iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: #050505;
}

.fullscreen-single-view {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #050505;
}

.fullscreen-single-view > iframe,
.fullscreen-single-view > video {
  position: absolute;
  inset: 0;
}

.camera-fullscreen.mini-player {
  inset: auto;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.35rem;
  min-width: 240px;
  min-height: 156px;
  max-width: calc(100vw - 1rem);
  max-height: calc(100vh - 1rem);
  overflow: hidden;
  resize: both;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 0.35rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

.camera-fullscreen.mini-player .fullscreen-bar {
  cursor: move;
  padding: 0.4rem;
}

.camera-fullscreen.mini-player .fullscreen-bar .section-eyebrow,
.camera-fullscreen.mini-player #fullscreen-controls-toggle,
.camera-fullscreen.mini-player #fullscreen-prev,
.camera-fullscreen.mini-player #fullscreen-next,
.camera-fullscreen.mini-player .fullscreen-timeline {
  display: none;
}

.camera-fullscreen.mini-player .fullscreen-bar strong {
  font-size: 11px;
}

.mini-resize-handle {
  display: none;
}

.camera-fullscreen.mini-player .mini-resize-handle {
  display: block;
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 3;
  width: 26px;
  height: 26px;
  cursor: nwse-resize;
  touch-action: none;
}

.camera-fullscreen.mini-player .mini-resize-handle::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  border-right: 2px solid rgba(255, 255, 255, 0.65);
  border-bottom: 2px solid rgba(255, 255, 255, 0.65);
}

.camera-fullscreen.mini-player iframe,
.camera-fullscreen.mini-player #fullscreen-recording-player {
  border-radius: 6px;
}

#fullscreen-recording-player {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 8px;
  background: #050505;
}

#fullscreen-recording-player.active {
  display: block;
}

.fullscreen-multi-view {
  display: none;
  min-width: 0;
  min-height: 0;
  grid-template-columns: repeat(var(--multi-camera-columns, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.5rem;
  overflow: hidden;
  background: #050505;
}

.camera-fullscreen.multi-camera .fullscreen-multi-view {
  display: grid;
}

.fullscreen-multi-view[data-focused-span="2"] > .fullscreen-camera-view:first-child {
  grid-column-end: span 2;
}

.fullscreen-multi-view[data-focused-span="3"] > .fullscreen-camera-view:first-child {
  grid-column-end: span 3;
}

.fullscreen-multi-view[data-focused-span="4"] > .fullscreen-camera-view:first-child {
  grid-column-end: span 4;
}

.camera-fullscreen.multi-camera > .fullscreen-single-view {
  display: none;
}

.fullscreen-camera-view {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #050505;
}

.fullscreen-camera-view iframe,
.fullscreen-camera-view video,
.fullscreen-camera-loading {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: #050505;
}

.fullscreen-camera-loading {
  display: grid;
  place-items: center;
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
}

.fullscreen-camera-loading.unavailable {
  color: #fca5a5;
}

.fullscreen-camera-label {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  border-radius: 4px;
  background: rgba(5, 5, 5, 0.74);
  color: #fff;
  padding: 0.28rem 0.45rem;
  font-size: 11px;
  font-weight: 800;
}

.fullscreen-camera-label strong,
.fullscreen-camera-label small {
  display: block;
}

.fullscreen-camera-label small {
  margin-top: 0.1rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
  font-weight: 600;
}

.camera-focus-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(5, 5, 5, 0.76);
  color: #fff;
  padding: 0.3rem 0.65rem;
  box-shadow: none;
}

.camera-focus-button:hover,
.camera-focus-button:focus-visible {
  background: rgba(22, 163, 74, 0.9);
}

.camera-fullscreen.camera-inspection-mode .fullscreen-multi-view {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.camera-fullscreen.camera-inspection-mode .fullscreen-camera-view:not(.view-focused) {
  display: none;
}

.camera-fullscreen.camera-inspection-mode .fullscreen-camera-view.view-focused {
  grid-column: 1;
  grid-row: 1;
}

.camera-fullscreen.camera-inspection-mode .view-focused {
  cursor: grab;
  touch-action: none;
}

.camera-fullscreen.camera-inspection-mode .view-focused:active {
  cursor: grabbing;
}

.camera-fullscreen.camera-inspection-mode .view-focused > iframe,
.camera-fullscreen.camera-inspection-mode .view-focused > video {
  transform-origin: center;
  pointer-events: none;
  will-change: transform;
}

.camera-fullscreen.camera-inspection-mode .view-focused > .camera-focus-button {
  display: none;
}

.camera-inspection-controls {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 5;
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.82);
  padding: 0.5rem;
  cursor: default;
  backdrop-filter: blur(8px);
}

.camera-zoom-badge {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 5;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(5, 5, 5, 0.78);
  color: #fff;
  padding: 0.3rem 0.6rem;
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
}

.camera-zoom-badge:hover {
  background: rgba(79, 70, 229, 0.9);
  transform: none;
}

/* Focus-mode zoom/pan controls sit left of the floating toolbar. */
.camera-inspection-controls {
  right: 4.6rem;
}

.camera-inspection-controls button {
  min-width: 36px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 0.25rem 0.45rem;
  box-shadow: none;
}

.camera-inspection-controls button:hover:not(:disabled),
.camera-inspection-controls button:focus-visible {
  background: rgba(22, 163, 74, 0.88);
}

.camera-inspection-controls button:disabled {
  opacity: 0.38;
  cursor: default;
}

.camera-inspection-exit {
  grid-column: 1 / -1;
  justify-self: end;
}

.camera-pan-controls {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  grid-template-rows: repeat(3, 34px);
  gap: 0.2rem;
}

.camera-pan-controls [data-camera-view-action="pan-up"] {
  grid-column: 2;
  grid-row: 1;
}

.camera-pan-controls [data-camera-view-action="pan-left"] {
  grid-column: 1;
  grid-row: 2;
}

.camera-pan-controls [data-camera-view-action="reset"] {
  grid-column: 2;
  grid-row: 2;
  padding-inline: 0.2rem;
  font-size: 10px;
}

.camera-pan-controls [data-camera-view-action="pan-right"] {
  grid-column: 3;
  grid-row: 2;
}

.camera-pan-controls [data-camera-view-action="pan-down"] {
  grid-column: 2;
  grid-row: 3;
}

.camera-selection-note {
  display: block;
  color: rgba(203, 213, 225, 0.72);
  font-size: 11px;
}

.camera-selection-list {
  display: flex;
  justify-content: flex-start;
  min-width: 0;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.camera-selection-list button {
  display: grid;
  justify-items: start;
  flex: 0 0 auto;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(226, 232, 240, 0.8);
  padding: 0.35rem 0.6rem;
  box-shadow: none;
}

.camera-selection-list button small {
  margin-top: 0.1rem;
  color: rgba(203, 213, 225, 0.68);
  font-size: 9px;
  font-weight: 600;
}

.camera-selection-list .camera-selection-command {
  display: block;
  border-color: rgba(129, 140, 248, 0.48);
  color: #c7d2fe;
}

.camera-selection-list button.selected {
  border-color: rgba(34, 197, 94, 0.58);
  background: rgba(34, 197, 94, 0.2);
  color: #fff;
}

.camera-selection-list button.focused::after {
  content: "Timeline";
  margin-left: 0.4rem;
  color: #86efac;
  font-size: 9px;
  text-transform: uppercase;
}

.fullscreen-timeline {
  display: grid;
  gap: 0.5rem;
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  padding: 0.65rem;
}

.camera-fullscreen.controls-collapsed .fullscreen-timeline,
.camera-fullscreen.camera-controls-collapsed .camera-selection,
.camera-fullscreen.replay-controls-collapsed .fullscreen-replay-controls,
.camera-fullscreen.timeline-controls-collapsed #fullscreen-scrub-timeline {
  display: none;
}

.fullscreen-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.14);
}

.fullscreen-controls-sections {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.fullscreen-controls-sections button {
  min-height: 28px;
  border: 1px solid rgba(129, 140, 248, 0.38);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #e0e7ff;
  padding: 0.3rem 0.55rem;
  box-shadow: none;
}

.fullscreen-controls-sections button:hover {
  background: rgba(79, 70, 229, 0.72);
}

.fullscreen-replay-controls {
  display: grid;
  gap: 0.5rem;
}

.fullscreen-timeline .timeline-toolbar {
  align-items: center;
}

.fullscreen-timeline .section-eyebrow,
.fullscreen-timeline .recording-item span {
  color: rgba(203, 213, 225, 0.76);
}

.fullscreen-timeline .timeline-toolbar strong {
  color: #fff;
}

.fullscreen-timeline .timeline-actions button,
.fullscreen-timeline .timeline-actions select,
.fullscreen-timeline-tab {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.fullscreen-timeline .timeline-actions select {
  padding: 0.35rem 0.65rem;
}

.fullscreen-timeline .timeline-actions button:hover,
.fullscreen-timeline-tab:hover,
.fullscreen-timeline-tab.active {
  background: rgba(79, 70, 229, 0.86);
  color: #fff;
}

.fullscreen-timeline .timeline-tabs {
  gap: 0.35rem;
}

.fullscreen-timeline .timeline-ruler,
.fullscreen-timeline .timeline-readout {
  color: rgba(203, 213, 225, 0.78);
}

.fullscreen-timeline .timeline-track {
  height: 62px;
  border-color: rgba(255, 255, 255, 0.12);
  background:
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.16) 0 1px, transparent 1px 11%),
    linear-gradient(180deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.92));
}

.fullscreen-timeline .timeline-empty {
  color: rgba(203, 213, 225, 0.78);
}

.fullscreen-timeline .timeline-clip {
  top: 13px;
  height: 34px;
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.18);
  color: #fff;
}

.fullscreen-timeline .timeline-clip:hover {
  background: rgba(148, 163, 184, 0.26);
}

.timeline-clip.active-recording {
  border-color: rgba(34, 197, 94, 0.48);
  background: rgba(34, 197, 94, 0.22);
}

.timeline-clip.active-recording:hover {
  background: rgba(34, 197, 94, 0.3);
}

.fullscreen-timeline .timeline-alert {
  top: 7px;
  height: 48px;
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.34);
}

.fullscreen-timeline .timeline-scroll::-webkit-slider-runnable-track {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(90deg, transparent var(--timeline-offset, 0%), rgba(79, 70, 229, 0.46) var(--timeline-offset, 0%) calc(var(--timeline-offset, 0%) + var(--timeline-window, 100%)), transparent calc(var(--timeline-offset, 0%) + var(--timeline-window, 100%))),
    rgba(148, 163, 184, 0.2);
}

.fullscreen-timeline .timeline-scroll::-moz-range-track {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(148, 163, 184, 0.2);
}

.recording-list.compact {
  display: flex;
  max-height: 74px;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 0.1rem;
}

.recording-list.compact p {
  color: rgba(203, 213, 225, 0.78);
}

.recording-list.compact .recording-item {
  width: min(260px, 70vw);
  min-width: min(260px, 70vw);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0.45rem 0.55rem;
}

.recording-list.compact .recording-item:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.camera-preloaders {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: -1;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.camera-preloaders iframe {
  width: 1px;
  height: 1px;
  border: 0;
}

.camera-tile-meta::after {
  content: "LOW";
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.45rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.frigate-tile .camera-tile-meta::after {
  display: none;
}

.camera-page-tags {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.viewer {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #050505;
}

.viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.camera-live-view {
  min-height: 48vh;
}

#recording-player {
  display: none;
  width: 100%;
  height: 100%;
  background: #050505;
}

#recording-player.active {
  display: block;
}

.viewer-actions {
  display: flex;
  gap: 0.5rem;
}

.back-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.panel,
.empty {
  border-radius: 12px;
  padding: 0.85rem;
}

.admin-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.admin-section-head h2 {
  margin-bottom: 0.2rem;
}

.workspace-bar-lead {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.back-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

.labels-status {
  color: var(--success-text);
  font-size: 11px;
  font-weight: 800;
}

.camera-label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 0.5rem;
}

.camera-label-card {
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgb(var(--surface-rgb) / 0.72);
  transition: border-color 0.18s ease;
}

.camera-label-card.is-dirty {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.25);
}

.camera-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #050505;
}

.camera-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.camera-label-card.thumb-ready .camera-thumb img {
  opacity: 1;
}

.camera-thumb-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.camera-label-card.thumb-ready .camera-thumb-state {
  background: rgba(5, 5, 5, 0.55);
}

.camera-thumb-time:not(:empty) {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  border-radius: 4px;
  background: rgba(5, 5, 5, 0.7);
  color: rgba(255, 255, 255, 0.85);
  padding: 0.15rem 0.4rem;
  font-size: 10px;
  font-weight: 700;
}

.camera-thumb-refresh {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  min-width: 32px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(5, 5, 5, 0.7);
  padding: 0.2rem 0.5rem;
  font-size: 15px;
  line-height: 1;
  box-shadow: none;
}

.camera-thumb-refresh:hover {
  background: var(--accent);
}

.camera-label-card.thumb-queued .camera-thumb-refresh {
  animation: thumb-spin 0.9s linear infinite;
}

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

.camera-label-fields {
  display: grid;
  gap: 0.45rem;
  padding: 0.6rem;
}

.camera-stream-name {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
}

/* Settings: cards that open dialogs (Access Control). */
.settings-panel {
  padding: 0;
  overflow: hidden;
}

.settings-panel-head {
  border-bottom: 1px solid var(--border-light);
  padding: 0.9rem 1.1rem;
}

.settings-panel-head h2 {
  margin-bottom: 0.15rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr));
  gap: 0.65rem;
  padding: 0.9rem;
}

.settings-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb) / 0.72);
  color: var(--ink);
  padding: 0.95rem 1rem;
  text-align: left;
  font-weight: 400;
  box-shadow: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.settings-card:hover,
.settings-card:focus-visible {
  border-color: var(--accent-border);
  background: rgb(var(--surface-rgb) / 0.95);
  box-shadow: 0 0 0 1px var(--accent-border), 0 8px 24px rgba(15, 23, 42, 0.06);
  outline: none;
  transform: none;
}

.settings-card-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-card-icon svg {
  width: 21px;
  height: 21px;
}

.settings-card-text {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.settings-card-eyebrow {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.settings-card-title {
  color: var(--ink-strong);
  font-size: 17px;
  font-weight: 700;
}

.settings-card-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-card-chevron {
  width: 16px;
  height: 16px;
  color: var(--muted-soft);
}

/* Narrow screens: status under the text, and the description may wrap. */
@media (max-width: 600px) {
  .settings-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: 0.45rem;
  }

  .settings-card-icon {
    grid-row: 1 / 3;
    align-self: start;
  }

  .settings-card > .status-pill {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .settings-card-chevron {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .settings-card-sub {
    white-space: normal;
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  background: rgb(var(--surface-alt-rgb) / 0.9);
  color: var(--muted);
  padding: 0.2rem 0.6rem;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok,
.status-pill.warn {
  background: var(--success-soft);
  color: var(--success-text);
}

.status-pill.warn {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

:root[data-theme="dark"] .status-pill.warn,
:root[data-theme="midnight"] .status-pill.warn,
:root[data-theme="graphite"] .status-pill.warn {
  color: #fbbf24;
}

.status-pill.ok::before,
.status-pill.warn::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.settings-dialog {
  width: min(860px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: rgb(var(--surface-rgb));
  color: var(--ink);
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
}

.settings-dialog[open] {
  display: flex;
  flex-direction: column;
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.settings-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.1rem 0.85rem;
}

.settings-dialog-head h2 {
  margin: 0.1rem 0 0.15rem;
  font-size: 16px;
}

.settings-dialog-body {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  overflow: auto;
  padding: 1rem 1.1rem 1.1rem;
}

.settings-dialog .table-wrap {
  max-height: none;
}

.settings-list {
  display: grid;
  gap: 0.4rem;
  list-style: none;
}

.settings-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
}

.list-avatar {
  display: grid;
  flex: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.settings-list-main {
  flex: 1;
  min-width: 0;
}

.settings-list-main strong,
.settings-list-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-list-main span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.small-button {
  min-height: 28px;
  padding: 0.25rem 0.6rem;
}

.settings-form {
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-alt-rgb) / 0.6);
  padding: 0.85rem;
}

.settings-form.flat {
  border: 0;
  background: transparent;
  padding: 0;
}

.settings-form h3 {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 800;
}

.settings-form h3 + p {
  margin-top: -0.45rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 0.6rem;
  align-items: end;
}

.form-grid.five {
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
}

.form-grid-check {
  min-height: var(--control-height);
}

.settings-form-actions {
  display: flex;
  justify-content: flex-end;
}

.role-card {
  display: grid;
  gap: 0.55rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.role-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.role-card-head > div {
  flex: 1;
  min-width: 160px;
}

.role-card-head strong,
.role-card-head span:not(.status-pill) {
  display: block;
}

.role-card-head div span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.role-card-label {
  padding-top: 0.25rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.role-cameras-card {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgb(var(--surface-alt-rgb) / 0.6);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-weight: 400;
  box-shadow: none;
}

.role-cameras-card:hover,
.role-cameras-card:focus-visible {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  outline: none;
  transform: none;
}

.role-cameras-card .role-card-label {
  padding-top: 0;
}

.role-cameras-summary {
  display: grid;
  min-width: 0;
}

.role-cameras-summary strong {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 700;
}

.role-cameras-summary span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-cameras-edit {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="dark"] .role-cameras-edit,
:root[data-theme="midnight"] .role-cameras-edit,
:root[data-theme="graphite"] .role-cameras-edit {
  color: color-mix(in srgb, var(--accent) 55%, white);
}

.recordings-hours-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgb(var(--surface-alt-rgb) / 0.6);
  padding: 0.65rem 0.7rem;
  cursor: pointer;
}

.recordings-hours-option input {
  width: auto;
  height: auto;
  margin-top: 0.2rem;
}

.recordings-hours-option strong,
.recordings-hours-option small {
  display: block;
}

.recordings-hours-option strong {
  color: var(--ink-strong);
  font-size: 12.5px;
}

.recordings-hours-option small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.settings-dialog.narrow {
  width: min(620px, calc(100vw - 2rem));
}

.camera-pick-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.camera-pick-head [data-picked-count] {
  margin-right: auto;
}

@media (max-width: 600px) {
  .role-cameras-card {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .role-cameras-card .role-card-label {
    display: none;
  }
}

/* Weekly schedule card (Roles & schedules). */
.week-schedule {
  display: grid;
  gap: 0.6rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.65rem;
}

.week-schedule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgb(var(--surface-alt-rgb) / 0.8);
  padding: 2px;
}

.segmented label {
  display: block;
  cursor: pointer;
}

.segmented input,
.week-day-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: block;
  border-radius: 6px;
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  font-size: 12px;
  font-weight: 700;
}

.segmented input:checked + span {
  background: rgb(var(--surface-rgb));
  color: var(--ink-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.segmented input:focus-visible + span,
.week-day-toggle input:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.week-days {
  display: grid;
  grid-template-columns: 150px auto minmax(140px, 1fr);
  align-items: center;
  gap: 0.4rem 0.9rem;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
  transition: opacity 0.18s ease;
}

.week-days[disabled] {
  opacity: 0.45;
}

.week-day {
  display: contents;
}

.week-scale {
  display: flex;
  grid-column: 3;
  justify-content: space-between;
  color: var(--muted-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
}

.week-day-toggle {
  display: flex;
  grid-column: 1;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.switch {
  position: relative;
  flex: none;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: rgb(var(--track-rgb));
  transition: background 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 0.18s ease;
}

.week-day-toggle input:checked + .switch {
  background: var(--accent);
}

.week-day-toggle input:checked + .switch::after {
  transform: translateX(12px);
}

.week-day-name {
  color: var(--ink-strong);
  font-size: 12.5px;
  font-weight: 700;
}

.week-day.off .week-day-name {
  color: var(--muted);
}

.week-day-times {
  display: flex;
  grid-column: 2;
  align-items: center;
  gap: 0.4rem;
}

.week-day-times input {
  width: 112px;
}

.week-day-sep {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.week-day-closed {
  display: none;
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.week-day.off .week-day-times {
  display: none;
}

.week-day.off .week-day-closed {
  display: block;
}

.week-bar {
  position: relative;
  grid-column: 3;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgb(var(--edge-rgb) / 0.5) calc(25% - 1px) 25%),
    rgb(var(--track-rgb) / 0.55);
}

.week-bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
}

.week-day-extra {
  grid-column: 1 / -1;
}

.week-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.week-actions [data-copy-monday] {
  margin-right: auto;
}

.week-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

/* Narrow screens: day and switch on one line, the hours below, then the bar. */
@media (max-width: 600px) {
  .week-days {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .week-scale {
    display: none;
  }

  .week-day-times,
  .week-bar {
    grid-column: 1 / -1;
  }

  .week-bar {
    margin-bottom: 0.45rem;
  }

  .week-day-times input {
    flex: 1;
    width: auto;
    min-width: 0;
  }
}

.muted-note {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.subtle-button {
  background: rgb(var(--surface-rgb) / 0.78);
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength)));
}

.subtle-button:hover {
  background: rgb(var(--surface-rgb));
  color: var(--accent);
}

.stack {
  display: grid;
  gap: 0.7rem;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input,
select {
  width: 100%;
  height: var(--control-height);
  border: 1px solid rgb(var(--edge-rgb) / 0.7);
  border-radius: 6px;
  background: rgb(var(--surface-alt-rgb) / 0.8);
  color: var(--text-input);
  padding: 0 0.6rem;
  font-size: 12px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength))), 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

select {
  appearance: none;
  background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
  background-position: right 0.6rem center;
  background-repeat: no-repeat;
  background-size: 14px;
  padding-right: 2rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgb(var(--surface-rgb));
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.45rem;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgb(var(--surface-rgb) / 0.42);
  padding: 0.45rem;
}

.checkbox-grid input,
.inline input {
  width: auto;
  height: auto;
}

.table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgb(var(--surface-rgb) / 0.36);
}

.table-wrap.tall {
  max-height: 430px;
}

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

th,
td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgb(var(--surface-alt-rgb) / 0.94);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

td {
  font-size: 12px;
  font-weight: 650;
}

td small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-weight: 600;
}

.timeline-panel {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgb(var(--surface-rgb) / 0.48);
  padding: 0.75rem;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.timeline-toolbar strong {
  display: block;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 900;
}

.timeline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.timeline-actions select {
  width: auto;
  min-width: 86px;
}

.timeline-tabs {
  display: flex;
  gap: 0.5rem;
}

.timeline-tab {
  background: rgb(var(--surface-rgb) / 0.78);
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength)));
}

.timeline-tab.active {
  background: var(--accent);
  color: #fff;
}

.scrub-timeline {
  display: grid;
  gap: 0.25rem;
}

.timeline-ruler {
  position: relative;
  height: 20px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
}

.timeline-ruler span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-ruler span:first-child {
  transform: translateX(0);
}

.timeline-ruler span:last-child {
  transform: translateX(-100%);
}

.timeline-track {
  position: relative;
  height: 76px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(100, 116, 139, 0.12) 0 1px, transparent 1px 11%),
    linear-gradient(180deg, rgb(var(--surface-rgb) / 0.62), rgb(var(--track-rgb) / 0.34));
  cursor: ew-resize;
  touch-action: none;
}

.timeline-track:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.timeline-panbar {
  position: relative;
  height: 18px;
  padding: 4px 0;
}

.timeline-scroll {
  width: 100%;
  height: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: ew-resize;
  accent-color: var(--accent);
}

.timeline-scroll:disabled {
  cursor: default;
  opacity: 0.45;
}

.timeline-scroll::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent var(--timeline-offset, 0%), rgba(79, 70, 229, 0.28) var(--timeline-offset, 0%) calc(var(--timeline-offset, 0%) + var(--timeline-window, 100%)), transparent calc(var(--timeline-offset, 0%) + var(--timeline-window, 100%))),
    rgb(var(--track-rgb) / 0.56);
}

.timeline-scroll::-webkit-slider-thumb {
  appearance: none;
  width: 38px;
  height: 12px;
  margin-top: -3px;
  border: 1px solid rgba(79, 70, 229, 0.38);
  border-radius: 999px;
  background: rgb(var(--surface-rgb));
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
}

.timeline-scroll::-moz-range-track {
  height: 8px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgb(var(--track-rgb) / 0.56);
}

.timeline-scroll::-moz-range-thumb {
  width: 38px;
  height: 12px;
  border: 1px solid rgba(79, 70, 229, 0.38);
  border-radius: 999px;
  background: rgb(var(--surface-rgb));
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
}

.timeline-empty {
  display: grid;
  position: absolute;
  inset: 0;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline-selection {
  display: none;
  position: absolute;
  top: 4px;
  bottom: 4px;
  z-index: 3;
  border: 1px solid rgba(14, 165, 233, 0.65);
  border-radius: 6px;
  background: rgba(14, 165, 233, 0.2);
  pointer-events: none;
}

.timeline-clip {
  position: absolute;
  top: 17px;
  height: 42px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 6px;
  background: rgba(100, 116, 139, 0.18);
  color: var(--ink-strong);
  padding: 0.3rem;
  text-align: left;
  box-shadow: none;
  pointer-events: none;
}

.timeline-clip:hover {
  background: rgba(100, 116, 139, 0.24);
  transform: none;
}

.timeline-alert {
  position: absolute;
  top: 8px;
  height: 60px;
  min-height: 0;
  border: 1px solid rgba(245, 158, 11, 0.48);
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.32);
  box-shadow: inset 0 0 0 1px rgb(var(--highlight-rgb) / calc(0.12 * var(--highlight-strength)));
  pointer-events: none;
}

.timeline-clip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 800;
}

/* Time under the pointer; while dragging it follows the pointer and the
   video loads on release. */
/* Clip selection on the timeline: a highlighted range with a handle at each end. */
.timeline-track.select-mode {
  cursor: crosshair;
}

.timeline-track.selecting {
  cursor: ew-resize;
}

.timeline-selection {
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.9);
}

.timeline-selection-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: ew-resize;
  pointer-events: auto;
}

.timeline-selection-handle[data-edge="start"] {
  left: -7px;
}

.timeline-selection-handle[data-edge="end"] {
  right: -7px;
}

.timeline-selection-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 5px;
  width: 4px;
  border-radius: 2px;
  background: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.clip-select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.clip-select-toggle svg {
  width: 16px;
  height: 16px;
}

.clip-select-toggle.active,
.replay-row .clip-select-toggle.active {
  border-color: #0ea5e9;
  background: #0284c7;
  color: #fff;
}

.clip-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.45rem;
  border: 1px solid rgba(14, 165, 233, 0.4);
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.1);
  padding: 0.3rem 0.4rem 0.3rem 0.7rem;
}

.clip-bar-label {
  color: #0ea5e9;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.clip-bar-text {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}

.camera-fullscreen .clip-bar-text {
  color: #e2e8f0;
}

.clip-bar button {
  min-height: 28px;
  border-radius: 6px;
  background: #0284c7;
  padding: 0.2rem 0.65rem;
  font-size: 12px;
  box-shadow: none;
}

.clip-bar .clip-download {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
}

.clip-bar .clip-download svg {
  width: 15px;
  height: 15px;
}

.toolbar-button.clip-toggle.active {
  background: #0284c7;
  color: #fff;
}

.clip-bar button:last-child {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: transparent;
  color: inherit;
}

.camera-fullscreen .clip-bar button:last-child {
  color: #e2e8f0;
}

/* "Download clip" progress and save dialog. */
.clip-export-dialog {
  width: min(460px, calc(100vw - 2rem));
  margin: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.1rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.clip-export-dialog::backdrop {
  background: rgba(2, 6, 23, 0.6);
}

.clip-export-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.clip-export-head strong {
  display: block;
  margin-top: 0.15rem;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.clip-export-eyebrow {
  color: rgba(148, 163, 184, 0.9);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.clip-export-close {
  display: grid;
  width: 32px;
  min-height: 32px;
  height: 32px;
  place-items: center;
  background: transparent;
  color: #e2e8f0;
  padding: 0;
  box-shadow: none;
}

.clip-export-close svg {
  width: 18px;
  height: 18px;
}

.clip-export-range {
  margin: 0.35rem 0 0.85rem;
  color: rgba(203, 213, 225, 0.8);
  font-size: 12px;
}

.clip-export-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.clip-export-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: #0ea5e9;
  transition: width 0.3s ease;
}

.clip-export-step {
  margin-top: 0.6rem;
  color: #e2e8f0;
  font-size: 12.5px;
}

.clip-export-step.error {
  color: #f87171;
}

.clip-export-note {
  margin-top: 0.6rem;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  padding: 0.45rem 0.6rem;
  font-size: 12px;
}

.clip-export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.clip-export-secondary {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #e2e8f0;
  box-shadow: none;
}

.scrub-timeline {
  user-select: none;
  -webkit-user-select: none;
}

.timeline-hover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 5;
  width: 0;
  border-left: 1px dashed rgba(148, 163, 184, 0.9);
  pointer-events: none;
}

.timeline-hover.visible {
  display: block;
}

.timeline-hover.dragging {
  border-left: 2px solid var(--accent);
}

.timeline-hover-label {
  position: absolute;
  top: 4px;
  left: 0;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  padding: 2px 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.timeline-hover.dragging .timeline-hover-label {
  background: var(--accent);
}

.timeline-playhead {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  transform: translateX(-1px);
  z-index: 4;
  pointer-events: none;
}

.timeline-playhead::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--danger);
  transform: translateX(-50%);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22);
}

.timeline-readout {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.recording-list {
  display: grid;
  max-height: 220px;
  gap: 0.45rem;
  overflow: auto;
  padding-right: 0.25rem;
}

.recording-item {
  display: grid;
  min-height: 0;
  border: 1px solid var(--border-light);
  background: rgb(var(--surface-rgb) / 0.7);
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  text-align: left;
  box-shadow: none;
}

.recording-item:hover {
  background: rgb(var(--surface-rgb));
  color: var(--accent);
}

.recording-item.active {
  border-color: rgba(79, 70, 229, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.recording-item strong,
.recording-item span {
  display: block;
}

.recording-item span {
  color: var(--muted);
  font-size: 11px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-shell {
  width: min(440px, 100%);
}

.login-panel {
  display: grid;
  gap: 0.9rem;
  border-radius: 20px;
  padding: 1.25rem;
}

.login-panel h1 {
  font-size: 1.35rem;
}

.passkey-button {
  width: 100%;
  min-height: 40px;
  background: #0f172a;
  font-size: 13px;
}

.passkey-button:hover {
  background: #1e293b;
}

.passkey-login {
  display: grid;
  gap: 0.75rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 700;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border-light);
}

.account-content {
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.account-content h2 {
  margin-bottom: 0.2rem;
}

.passkey-note {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgb(var(--surface-rgb) / 0.6);
  color: var(--muted);
  padding: 0.65rem;
  font-size: 12px;
  font-weight: 600;
}

.passkey-add {
  display: flex;
  align-items: end;
  gap: 0.5rem;
  max-width: 560px;
  margin-bottom: 0.75rem;
}

.passkey-add label {
  flex: 1;
}

.passkey-add button {
  white-space: nowrap;
}

.passkey-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
  list-style: none;
}

.passkey-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgb(var(--surface-rgb) / 0.6);
  padding: 0.55rem 0.65rem;
}

.passkey-list strong,
.passkey-list span {
  display: block;
}

.passkey-list span,
.passkey-list .passkey-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.account-logout {
  margin-top: 0.75rem;
}

.alert.success {
  background: var(--success-soft);
  color: var(--success-text);
}

.alert {
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0.65rem;
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 992px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: center;
    gap: 0.65rem;
    min-height: 56px;
    border-bottom: 1px solid var(--border-light);
    background: rgb(var(--surface-alt-rgb) / 0.94);
    padding: 0.65rem 0.85rem;
    box-shadow: 0 10px 30px rgba(45, 57, 87, 0.08);
  }

  .app-shell {
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
    height: auto;
    flex-direction: column;
  }

  .side-rail {
    display: none;
  }

  .workspace-bar {
    flex-wrap: wrap;
    padding: 0.5rem;
  }

  .preset-controls {
    width: 100%;
  }

  .preset-picker {
    flex: 1;
  }

  .preset-picker select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .workspace-content {
    gap: 0.5rem;
    overflow: visible;
    padding: 0.4rem;
  }

  .passkey-add {
    align-items: stretch;
    flex-direction: column;
  }

  .camera-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .page-head {
    display: none;
  }

  .toolbar-actions,
  .toolbar-actions button {
    width: 100%;
  }

  .frigate-grid {
    grid-template-columns: 1fr;
  }

  .frigate-tile .camera-tile-meta {
    opacity: 1;
  }

  .tile-drag-hint {
    display: none;
  }

  .camera-fullscreen {
    min-height: 100vh;
    height: 100dvh;
    padding: 0;
    gap: 0;
    z-index: 120;
  }

  .camera-fullscreen.open:not(.mini-player) {
    grid-template-rows: minmax(0, 1fr);
  }

  .camera-fullscreen.open:not(.mini-player) > .fullscreen-single-view,
  .camera-fullscreen.open:not(.mini-player) > .fullscreen-multi-view {
    grid-row: 1;
  }

  .fullscreen-toolbar {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 2;
    align-items: flex-start;
    border-radius: 0;
    background:
      linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.68) 72%, rgba(15, 23, 42, 0));
    padding: calc(env(safe-area-inset-top, 0px) + 0.45rem) 0.45rem 0.75rem;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-bar > div:first-child {
    min-width: 0;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-bar .section-eyebrow {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-bar strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fullscreen-actions {
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .fullscreen-actions button {
    min-height: 30px;
    padding: 0.3rem 0.45rem;
    font-size: 11px;
  }

  #fullscreen-controls-toggle {
    display: none;
  }

  .fullscreen-mode {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) iframe,
  .camera-fullscreen.open:not(.mini-player) #fullscreen-recording-player,
  .camera-fullscreen.open:not(.mini-player) .fullscreen-single-view,
  .camera-fullscreen.open:not(.mini-player) .fullscreen-multi-view {
    border-radius: 0;
  }

  .fullscreen-multi-view {
    gap: 2px;
  }

  .camera-focus-button {
    top: calc(env(safe-area-inset-top, 0px) + 3.5rem);
  }

  .camera-inspection-controls {
    right: 0.45rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.45rem);
    max-width: calc(100% - 0.9rem);
  }

  body.fullscreen-open .mobile-topbar {
    display: none;
  }

  body.fullscreen-open .app-shell {
    min-height: 100vh;
  }

  .fullscreen-timeline {
    display: none;
  }

  .timeline-panel {
    display: none;
  }

  .camera-fullscreen.mini-player {
    min-width: 220px;
    min-height: 150px;
  }

    .timeline-toolbar,
  .timeline-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Rewind / forward scrubbing and the replay range picker */

.playback-scrub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.playback-scrub button {
  background: rgb(var(--surface-rgb) / 0.78);
  color: var(--text-secondary);
  padding: 0.3rem 0.55rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength)));
}

.playback-scrub button:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.scrub-hint {
  margin-left: auto;
  color: var(--muted-soft);
  font-size: 11px;
}

/* Review panel: range, rewind/forward and download on one row. */
.fullscreen-replay-controls.replay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
}

.replay-clip {
  display: flex;
  gap: 0.35rem;
}

.replay-row .playback-scrub {
  gap: 0.25rem;
}

.replay-row .playback-scrub button {
  padding: 0.3rem 0.45rem;
}

.replay-row .range-picker {
  border-top: 0;
  padding-top: 0;
}

.replay-nav {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.replay-nav button,
.replay-row .clip-select-toggle,
.replay-row .replay-download {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.replay-nav button:hover,
.replay-row .clip-select-toggle:hover,
.replay-row .replay-download:hover:not(:disabled) {
  background: rgba(79, 70, 229, 0.86);
}

.range-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.65rem;
}

.range-picker label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.range-picker input[type="datetime-local"] {
  width: auto;
  min-height: var(--control-height);
  border: 1px solid var(--card-line);
  border-radius: 6px;
  background: rgb(var(--surface-rgb) / 0.9);
  color: var(--ink);
  padding: 0.25rem 0.5rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.range-picker input[type="datetime-local"]:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.range-picker button:not(.primary) {
  background: rgb(var(--surface-rgb) / 0.78);
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 rgb(var(--highlight-rgb) / calc(0.65 * var(--highlight-strength)));
}

.range-note {
  color: var(--muted);
  font-size: 11px;
}

.playback-status {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.playback-status.busy {
  color: var(--accent);
}

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

/* The floating picture-in-picture window (Chrome / Edge). */
.pip-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #050505;
}

.pip-grid {
  display: grid;
  grid-template-columns: repeat(var(--pip-columns, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 2px;
  width: 100vw;
  height: 100vh;
}

.pip-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #050505;
}

.pip-tile iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.pip-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  border-radius: 4px;
  background: rgba(5, 5, 5, 0.72);
  color: #fff;
  padding: 2px 6px;
  font: 700 11px/1.3 "Manrope", sans-serif;
}

.pip-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  width: 26px;
  min-height: 26px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: rgba(5, 5, 5, 0.75);
  color: #fff;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
}

.pip-tile:hover .pip-remove {
  display: grid;
}

/* Rewind the grid: a compact floating timeline. */
.grid-replay {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: min(720px, calc(100vw - 1.5rem));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  padding: 0.4rem 0.55rem 0.5rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.grid-replay.replaying {
  border-color: rgba(245, 158, 11, 0.55);
}

body.fullscreen-open .grid-replay {
  display: none;
}

.grid-replay-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.grid-replay-grip {
  display: grid;
  width: 18px;
  place-items: center;
  color: rgba(203, 213, 225, 0.55);
  cursor: grab;
  touch-action: none;
}

.grid-replay.dragging .grid-replay-grip {
  cursor: grabbing;
}

.grid-replay-grip svg {
  width: 16px;
  height: 16px;
}

.grid-replay-btn,
.grid-replay-live {
  display: inline-grid;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: #e2e8f0;
  padding: 0 0.35rem;
  box-shadow: none;
}

.grid-replay-btn:hover,
.grid-replay-live:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: none;
}

.grid-replay-btn svg {
  width: 17px;
  height: 17px;
}

.grid-replay-btn.small svg {
  width: 14px;
  height: 14px;
}

.grid-replay-btn .icon-pause,
.grid-replay-btn[data-playing="true"] .icon-play {
  display: none;
}

.grid-replay-btn[data-playing="true"] .icon-pause {
  display: block;
}

.grid-replay-live {
  border: 1px solid rgba(239, 68, 68, 0.55);
  color: #fca5a5;
  padding: 0 0.55rem;
  font-size: 11.5px;
  font-weight: 800;
}

.grid-replay:not(.replaying) .grid-replay-live {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
}

.grid-replay-speed {
  width: 46px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  padding: 0 0.2rem;
  font-size: 11px;
  font-weight: 800;
  box-shadow: none;
}

.grid-replay-speed option {
  background: #0f172a;
}

.grid-replay-clock {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-replay.replaying .grid-replay-clock {
  color: #fbbf24;
}

.grid-replay-count {
  color: rgba(203, 213, 225, 0.7);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Compact timeline inside the widget. */
.grid-replay-timeline {
  margin-top: 0.3rem;
}

.grid-replay-timeline .timeline-ruler {
  height: 14px;
  color: rgba(203, 213, 225, 0.7);
  font-size: 8.5px;
}

.grid-replay-timeline .timeline-track {
  height: 34px;
  border-color: rgba(255, 255, 255, 0.12);
  background:
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.16) 0 1px, transparent 1px 11%),
    linear-gradient(180deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.92));
}

.grid-replay-timeline .timeline-clip {
  top: 7px;
  height: 18px;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.28);
}

.grid-replay-timeline .timeline-clip span {
  display: none;
}

.grid-replay-timeline .timeline-alert {
  top: 4px;
  height: 24px;
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.34);
}

.grid-replay-timeline .timeline-panbar,
.grid-replay-timeline .timeline-readout,
.grid-replay-timeline .timeline-selection,
.grid-replay-timeline .timeline-empty {
  display: none;
}

/* Tiles while rewinding. */
.tile-replay-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #050505;
  object-fit: contain;
}

.tile-replay-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #050505;
  color: rgba(226, 232, 240, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.camera-tile.replaying .tile-replay-video[hidden] + iframe,
.camera-tile.replaying .tile-link > iframe[hidden] {
  display: none;
}

.camera-tile.replaying::after,
.camera-tile.replay-live-only::after {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 3;
  border-radius: 5px;
  padding: 0.15rem 0.45rem;
  font-size: 10.5px;
  font-weight: 800;
  pointer-events: none;
}

.camera-tile.replaying::after {
  content: "REPLAY";
  background: rgba(245, 158, 11, 0.9);
  color: #1c1917;
}

.camera-tile.replay-live-only::after {
  content: "LIVE \00B7  no recordings";
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
}

/* ------------------------------------------------------------------
   Phones (tuned for iPhone 16 Pro 402x874 and Galaxy S25 FE 412x891).
   ------------------------------------------------------------------ */
.grid-replay-mobile {
  display: none;
}

@media (max-width: 992px) {
  .grid-replay-mobile {
    display: inline-grid;
    flex: none;
    width: 40px;
    min-height: 40px;
    height: 40px;
  }

  .grid-replay-mobile.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
  }

  .preset-controls .icon-button {
    width: 40px;
    min-height: 40px;
    height: 40px;
  }

  .preset-picker select {
    height: 40px;
    font-size: 14px;
  }

  /* Rewind sheet docked at the bottom. */
  .grid-replay {
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    padding: 0.55rem 0.65rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    transform: none;
  }

  body.grid-replay-open .workspace-content {
    padding-bottom: 190px;
  }

  .grid-replay-bar {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  .grid-replay-grip,
  .grid-replay-btn.small {
    display: none;
  }

  .grid-replay-clock {
    order: -1;
    flex: 1 0 calc(100% - 120px);
    text-align: left;
    font-size: 14px;
  }

  .grid-replay-count {
    order: -1;
  }

  #grid-replay-close {
    order: -1;
  }

  .grid-replay-btn,
  .grid-replay-live {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    border-radius: 10px;
  }

  .grid-replay-btn svg {
    width: 22px;
    height: 22px;
  }

  #grid-replay-play {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
  }

  .grid-replay-speed {
    width: 56px;
    height: 44px;
    font-size: 13px;
  }

  .grid-replay-timeline .timeline-track {
    height: 52px;
  }

  .grid-replay-timeline .timeline-clip {
    top: 12px;
    height: 26px;
  }

  .grid-replay-timeline .timeline-alert {
    top: 8px;
    height: 34px;
  }

  .grid-replay-timeline .timeline-ruler {
    font-size: 9.5px;
  }

  /* Finger-sized handles for clip selection. */
  .timeline-selection-handle {
    width: 30px;
  }

  .timeline-selection-handle[data-edge="start"] {
    left: -15px;
  }

  .timeline-selection-handle[data-edge="end"] {
    right: -15px;
  }

  .timeline-selection-handle::after {
    left: 12px;
    width: 6px;
  }

  .timeline-scroll {
    height: 22px;
  }

  .timeline-scroll::-webkit-slider-thumb {
    width: 48px;
    height: 20px;
    margin-top: -7px;
  }

  .timeline-hover-label {
    font-size: 12px;
    padding: 3px 8px;
  }

  /* Focused camera page: timeline back on phones. */
  .timeline-panel {
    display: grid;
    gap: 0.6rem;
    padding: 0.65rem;
  }

  .camera-live-view {
    min-height: 0;
    flex: none;
    aspect-ratio: 16 / 9;
  }

  .timeline-panel .timeline-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .timeline-panel .timeline-actions > * {
    width: 100%;
    min-height: 44px;
  }

  .timeline-panel .playback-scrub,
  .replay-row .playback-scrub {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .timeline-panel .playback-scrub button,
  .replay-row .playback-scrub button {
    min-height: 44px;
    font-size: 13px;
  }

  .timeline-panel .scrub-hint {
    display: none;
  }

  .timeline-panel .range-picker,
  .replay-row .range-picker {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem 0.5rem;
  }

  /* iOS gives date inputs their own minimum width (and centres the text):
     drop the native look so they fit the column. */
  .range-picker input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 15px;
    text-align: left;
  }

  .range-picker input[type="datetime-local"]::-webkit-date-and-time-value {
    text-align: left;
  }

  /* While a camera is open, the page behind must not scroll or show through. */
  html:has(body.fullscreen-open),
  body.fullscreen-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .camera-fullscreen.open:not(.mini-player) {
    top: 0;
    bottom: auto;
    height: 100vh;
    height: 100lvh;
    min-height: 0;
    max-width: 100vw;
    overflow: hidden;
  }

  .range-picker button {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .timeline-panel .timeline-track,
  .camera-fullscreen .fullscreen-timeline .timeline-track {
    height: 72px;
  }

  .clip-bar {
    padding: 0.45rem;
  }

  .clip-bar-text {
    flex-basis: 100%;
  }

  .clip-bar button {
    flex: 1;
    min-height: 42px;
    justify-content: center;
    font-size: 13px;
  }

  .clip-export-dialog {
    width: calc(100vw - 1.5rem);
    margin: auto auto calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  .clip-export-actions button {
    min-height: 46px;
    flex: 1;
    font-size: 15px;
  }
}

/* Portrait phone review panel: picture on top, controls underneath. */
@media (max-width: 992px) and (orientation: portrait) {
  .camera-fullscreen.open:not(.mini-player) {
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-bar {
    position: static;
    grid-row: 1;
    align-items: center;
    background: #0b1120;
    padding: calc(env(safe-area-inset-top, 0px) + 0.4rem) 0.5rem 0.4rem 0.75rem;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-mode {
    display: flex;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 0.3rem 0.5rem;
    margin: 0.3rem 0 0;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-mode .footage-hours-note {
    flex-basis: 100%;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-close {
    width: 42px;
    min-height: 42px;
    height: 42px;
  }

  .camera-fullscreen.open:not(.mini-player) > .fullscreen-single-view,
  .camera-fullscreen.open:not(.mini-player) > .fullscreen-multi-view {
    grid-row: 2;
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
  }

  .camera-fullscreen.open.multi-camera:not(.mini-player) > .fullscreen-multi-view {
    aspect-ratio: auto;
    height: min(56vh, 520px);
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-toolbar {
    display: flex;
    grid-row: 3;
    flex-direction: row;
    align-self: stretch;
    justify-self: stretch;
    justify-content: space-between;
    gap: 0.1rem;
    margin: 0;
    overflow: hidden;
    border-width: 1px 0;
    border-radius: 0;
    background: #0b1120;
    padding: 0.35rem 0.4rem;
    box-shadow: none;
    backdrop-filter: none;
    scrollbar-width: none;
  }

  /* Buttons share the width so the row always fits (no sideways scrolling). */
  .camera-fullscreen.open:not(.mini-player) .toolbar-button {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 50px;
    min-height: 44px;
    height: 44px;
  }

  .camera-fullscreen #fullscreen-zoom-reset {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) .toolbar-button svg {
    width: 21px;
    height: 21px;
  }

  .camera-fullscreen.open:not(.mini-player) .toolbar-speed {
    flex: 0 0 44px;
    width: 44px;
    height: 36px;
    align-self: center;
    font-size: 13px;
  }

  .camera-fullscreen.open:not(.mini-player) .toolbar-divider {
    flex: none;
    width: 1px;
    height: 26px;
    align-self: center;
    margin: 0 0.15rem;
  }

  /* Things that need a mouse or a wide screen stay on desktop. */
  .camera-fullscreen #fullscreen-cameras-button,
  .camera-fullscreen #fullscreen-focus,
  .camera-fullscreen #fullscreen-controls-toggle {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-timeline {
    display: flex;
    grid-row: 4;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-radius: 0;
    background: #0f172a;
    /* The panel reaches behind Safari's bottom bar; leave room to scroll past it. */
    padding: 0 0.65rem max(calc(1rem + env(safe-area-inset-bottom, 0px)), calc(100lvh - 100dvh + 1rem));
    -webkit-overflow-scrolling: touch;
  }

  /* The timeline stays in view while the buttons below scroll. */
  .camera-fullscreen .fullscreen-timeline #fullscreen-scrub-timeline {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: #0f172a;
    padding: 0.55rem 0.65rem 0.4rem;
  }

  .camera-fullscreen .fullscreen-timeline .clip-bar {
    order: 2;
    margin: 0;
  }

  .camera-fullscreen .fullscreen-timeline .replay-row {
    order: 3;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .replay-row .playback-scrub {
    order: 1;
  }

  .replay-row .replay-nav {
    order: 2;
    margin: 0;
  }

  .replay-row .replay-nav button {
    flex: 1;
    min-height: 44px;
    font-size: 14px;
  }

  .replay-row .range-picker {
    order: 3;
  }

  .camera-fullscreen .fullscreen-timeline .timeline-readout {
    color: #fff;
    font-size: 13px;
  }

  .camera-fullscreen .camera-focus-button {
    display: none;
  }
}

/* Landscape phone: the picture fills the screen, tools on the right. */
@media (max-width: 992px) and (orientation: landscape) {
  .camera-fullscreen #fullscreen-zoom-reset {
    display: none;
  }

  .camera-fullscreen.open:not(.mini-player) .fullscreen-toolbar {
    display: flex;
    grid-row: 1;
    align-self: end;
    max-height: calc(100% - 64px);
    margin-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    margin-right: calc(0.4rem + env(safe-area-inset-right, 0px));
    padding: 0.25rem;
    scrollbar-width: none;
  }

  .camera-fullscreen.open:not(.mini-player) .toolbar-button {
    width: 36px;
    min-height: 36px;
    height: 36px;
  }

  .camera-fullscreen #fullscreen-cameras-button,
  .camera-fullscreen #fullscreen-focus,
  .camera-fullscreen #fullscreen-controls-toggle {
    display: none;
  }
}
