:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #fff;
  --panel-2: #eef2ed;
  --border: #e1e6df;
  --text: #23372f;
  --muted: #6d7b72;
  --accent: #23705a;
  --accent-hover: #195a47;
  --accent-soft: #e8f2eb;
  --ok: #2d7955;
  --warn: #93630f;
  --bad: #b94a43;
  --radius: 18px;
  --nav-height: 72px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 94px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body:has(.modal:not([hidden])) { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 5.5vw, 42px); font-weight: 600; line-height: 1.17; letter-spacing: -1.25px; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -.4px; }
h3 { font-size: 17px; font-weight: 600; line-height: 1.4; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
button, .btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 16px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}
button:active, .btn-link:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }
button.primary, .btn-link.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: #fff6f4; color: var(--bad); border-color: #f0d8d3; }
button.danger.subtle { background: transparent; border-color: transparent; }
a { color: var(--accent); text-decoration: none; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #74ac91; outline-offset: 3px; }
input, select, textarea {
  min-width: 0;
  min-height: 46px;
  border: 1px solid #d6dfd6;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; width: 100%; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 20px; accent-color: var(--accent); cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 1.1px; text-transform: uppercase; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 110; border-radius: 8px; padding: 12px 18px; background: var(--text); color: #fff; }
.skip-link:focus { top: 12px; }

/* Header and primary navigation. Mobile uses a dedicated thumb-reachable bar. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: calc(74px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); font-size: 24px; font-weight: 650; line-height: 1; letter-spacing: -1px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: #fff; }
.brand-mark svg { width: 27px; height: 27px; }
.brand-caption { display: block; margin-top: 5px; font-size: 10px; font-weight: 500; letter-spacing: .1px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.camera-status { display: inline-flex; align-items: center; gap: 7px; max-width: 150px; font-size: 12px; font-weight: 500; }
#dotlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: block; width: 7px; height: 7px; flex: none; border-radius: 50%; background: #a8b6ac; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px #e5eee5; }
.dot.off { background: var(--bad); box-shadow: 0 0 0 4px #f5e9e4; }
.logout { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--muted); }
.logout svg { width: 19px; height: 19px; }
.tabs {
  position: fixed;
  z-index: 35;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding: 7px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 54px; padding: 5px 2px 8px; color: var(--muted); font-size: 10px; font-weight: 550; line-height: 1.3; transition: color 150ms ease; }
.tabs a svg { width: 24px; height: 24px; padding: 1px; border-radius: 8px; transition: background-color 150ms ease; }
.tabs a.active { color: var(--accent); }
.tabs a.active svg { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); }
main { max-width: 1260px; margin: 0 auto; padding: 28px max(20px, env(safe-area-inset-right, 0px)) calc(var(--nav-height) + 28px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); }
main:focus { outline: none; }
.tabview { min-width: 0; animation: appear 180ms ease both; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { margin-bottom: 24px; }
.page-heading > .eyebrow { margin-bottom: 9px; }
.page-description { color: var(--muted); font-size: 14px; margin-top: 10px; max-width: 560px; }
.app-footer { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 38px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.footer-brand { font-size: 16px; font-weight: 650; color: var(--text); letter-spacing: -.5px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

/* Home: camera first, then the recent activity. Technical status stays tucked away. */
.dashboard-layout { display: grid; grid-template-areas: "camera" "recent" "controls"; gap: 27px; }
.camera-card { grid-area: camera; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.dash-preview { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #243d35; color: #fff; }
#dashPreview { width: 100%; height: 100%; object-fit: cover; display: block; }
.dash-preview::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg, rgba(10, 25, 19, .25), transparent 35%, transparent 55%, rgba(10, 25, 19, .55)); pointer-events: none; }
.dash-preview-empty { display: flex; height: 100%; align-items: center; justify-content: center; flex-direction: column; gap: 7px; text-align: center; padding: 58px 24px 38px; }
.dash-preview-empty svg { color: #a5c7b5; width: 47px; height: 47px; margin-bottom: 5px; stroke-width: 1.35; }
.dash-preview-empty p { color: #e0ece4; font-size: 17px; letter-spacing: -.2px; }
.dash-preview-empty > span { max-width: 220px; color: #b1c4b9; font-size: 12px; line-height: 1.5; }
.preview-camera { position: absolute; z-index: 1; top: 16px; left: 16px; display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 7px; background: rgba(19, 36, 28, .65); font-size: 11px; font-weight: 500; }
.preview-dot { width: 5px; height: 5px; border-radius: 50%; background: #a9bcae; }
.preview-caption { position: absolute; z-index: 1; bottom: 14px; left: 16px; color: #e3eee7; font-size: 10px; }
.dash-preview:has(#dashPreview[hidden]) .preview-caption { display: none; }
.camera-card-footer { display: flex; flex-direction: column; gap: 14px; padding: 17px; }
.camera-card-copy { display: flex; flex-direction: column; gap: 3px; }
.camera-card-copy strong { font-size: 14px; font-weight: 550; }
.live-cta { min-height: 48px; font-size: 14px; }
.live-cta svg { width: 18px; height: 18px; fill: currentColor; stroke-width: 0; }
.dash-section { min-width: 0; }
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.dash-head h2 { font-size: 19px; }
.dash-head .eyebrow { margin-bottom: 6px; }
.section-caption { color: var(--muted); font-size: 11px; }
.quick-panel { grid-area: controls; padding: 21px 18px 17px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.quick-panel .dash-head { align-items: baseline; gap: 8px; margin-bottom: 20px; }
.quick-panel .dash-head h2 { font-size: 16px; }
.quick { display: grid; gap: 17px; }
.quick-group { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.quick-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.seg { display: flex; width: 100%; padding: 4px; gap: 3px; border: 1px solid #e7ece5; border-radius: 11px; background: #f3f5f1; }
.seg-btn { flex: 1; min-width: 0; min-height: 44px; padding: 9px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; }
.seg-btn.on { background: #fff; color: var(--accent); box-shadow: 0 1px 4px rgba(24, 49, 34, .1); }
.quick-footnote { margin-top: 19px; padding-top: 13px; border-top: 1px solid #edf0ea; color: var(--muted); font-size: 11px; line-height: 1.6; }
.recent-section { grid-area: recent; }
.text-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; flex: none; font-size: 12px; font-weight: 550; }
.text-link span { font-size: 19px; }
.recent-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.recent-card { display: block; padding: 0; min-height: 0; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: var(--panel); color: var(--text); text-align: left; font: inherit; cursor: pointer; transition: border-color 150ms ease, transform 150ms ease; }
.recent-card:nth-child(n+5) { display: none; }
.recent-thumb { display: block; width: 100%; aspect-ratio: 16/11; object-fit: cover; background: #253e35; }
.recent-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 11px; }
.recent-meta .small { font-size: 11px; }
.system-details { margin-top: 28px; border-top: 1px solid var(--border); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.system-details > summary, .filter-details > summary { display: flex; align-items: center; gap: 10px; min-height: 58px; font-size: 13px; font-weight: 550; }
.system-details > summary::after, .filter-details > summary::after, .set-group > summary::after, .help-details > summary::after { content: ""; width: 7px; height: 7px; flex: none; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 160ms ease; }
details[open] > summary::after { transform: rotate(225deg); }
.summary-hint { display: none; margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.system-details .cards { padding-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { padding: 18px 16px; min-width: 0; border: 1px solid var(--border); border-radius: 13px; background: var(--panel); }
.card .k { color: var(--muted); font-size: 11px; font-weight: 500; }
.card .v { margin-top: 7px; color: var(--text); font-size: 24px; font-weight: 550; letter-spacing: -.8px; overflow-wrap: anywhere; line-height: 1.25; font-variant-numeric: tabular-nums; }
.card .v.ok { color: var(--ok); }.card .v.warn { color: var(--warn); }.card .v.bad { color: var(--bad); }.card .v.accent { color: var(--accent); }
.bar { height: 5px; margin-top: 13px; overflow: hidden; border-radius: 5px; background: var(--panel-2); }
.bar > span { display: block; height: 100%; background: var(--accent); }.bar.warn > span { background: var(--warn); }.bar.bad > span { background: var(--bad); }

/* Live video never shifts layout during connection. */
.live-stage { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.video-wrap, .player-wrap { position: relative; background: #17251f; overflow: hidden; }
.video-wrap { aspect-ratio: 16/10; }
.video-wrap video, .player-wrap video { display: block; width: 100%; height: 100%; object-fit: contain; background: #121c17; }
.player-wrap video { max-height: 60dvh; }
.live-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; color: #b5c8bd; text-align: center; padding: 20px; }
.live-ph-icon svg { width: 46px; height: 46px; stroke-width: 1.3; margin-bottom: 7px; color: #a9c8b6; }
.live-ph h2 { font-size: 19px; color: #e6eee8; letter-spacing: -.25px; }
.live-ph p { font-size: 12px; }
.live-start-note { display: block; color: #9db1a4; font-size: 10px; }
.live-controls { padding: 16px; }
.live-controls #goLive { flex: 1; min-height: 48px; }.live-controls #goLive svg { fill: currentColor; stroke-width: 0; width: 17px; }
.live-controls #liveState { width: 100%; font-size: 12px; }.live-controls #liveState:empty { display: none; }
.live-controls > button:not(.primary) { flex: 1 1 auto; }
.video-wrap:fullscreen { display: flex; align-items: center; justify-content: center; aspect-ratio: auto; background: #000; }
.video-wrap:fullscreen video { max-height: 100dvh; }
.help-details { margin-top: 18px; padding: 0 4px; color: var(--muted); font-size: 12px; }
.help-details > summary { display: flex; gap: 12px; align-items: center; min-height: 44px; width: fit-content; }
.help-details > p { max-width: 650px; padding: 8px 0 12px; line-height: 1.8; }

/* History controls and recording cards. */
.history-tools { margin-bottom: 22px; }
.presets { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 9px; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.presets button { flex: none; min-height: 44px; border-radius: 9px; padding: 9px 12px; font-size: 12px; background: transparent; border-color: transparent; }
.presets button.on { border-color: #c9dbce; background: var(--accent-soft); color: var(--accent); }
.filter-details { border: 1px solid var(--border); border-radius: 13px; background: var(--panel); }
.filter-details > summary { padding: 0 16px; min-height: 53px; }.filter-details > summary svg { width: 18px; height: 18px; }
.filter-details[open] > summary { border-bottom: 1px solid var(--border); }
.filters { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 18px 16px; }
.filters label { display: flex; flex-direction: column; min-width: 0; gap: 6px; color: var(--muted); font-size: 12px; }
.filters label > input, .filters label > select { width: 100%; max-width: 100%; }
.filters label.chk { display: flex; flex-direction: row; align-items: center; gap: 10px; min-height: 44px; color: var(--text); }
.filter-actions { display: flex; gap: 8px; grid-column: 1/-1; }.filter-actions > button { flex: 1; }
.hist-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 13px; }
.hist-bar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hist-bar-actions button { padding: 9px 12px; font-size: 12px; }
.sel-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 20px; padding: 14px; border: 1px solid #c0d8c8; border-radius: 13px; background: var(--accent-soft); }
#selectMode.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.rec-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.load-more { display: flex; min-width: 170px; margin: 25px auto 0; }
.day-sep { grid-column: 1/-1; color: var(--muted); padding: 14px 0 4px; font-size: 12px; font-weight: 550; }
.rec-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: var(--panel); cursor: pointer; transition: border-color 150ms ease; }
.rec-thumb { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #253e35; }
.rec-body { padding: 15px 16px; }
.rec-time { font-size: 14px; font-weight: 550; font-variant-numeric: tabular-nums; }
.rec-sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.badge { display: inline-flex; align-items: center; padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 10px; font-weight: 500; line-height: 1.3; background: #f7f8f4; }
.badge.motion { color: #70568b; border-color: #e3d9ed; background: #f5eff9; }
.badge.object { color: #3e7362; border-color: #d9e8df; background: #eff5ef; }
.badge.sound { color: #966524; border-color: #eddfbf; background: #fbf5e8; }
.badge.seen { color: var(--ok); border-color: #cde2d2; background: #edf6ee; }
.rec-del, .rec-seen { position: absolute; top: 9px; width: 44px; height: 44px; min-height: 44px; border-radius: 10px; padding: 0; border-color: rgba(255,255,255,.13); background: rgba(20,36,27,.75); color: #fff; font-size: 19px; }
.rec-del { right: 9px; }.rec-seen { right: 59px; }.rec-seen.on { background: var(--accent); border-color: var(--accent); }
.rec-grid.selecting .rec-del, .rec-grid.selecting .rec-seen { display: none; }
.rec-grid.selecting .rec-card::after { position: absolute; top: 14px; left: 14px; display: grid; place-items: center; content: ""; width: 25px; height: 25px; border: 2px solid #fff; border-radius: 50%; background: rgba(20,36,27,.6); color: #fff; }
.rec-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.rec-grid.selecting .rec-card.selected::after { content: "✓"; background: var(--accent); border-color: var(--accent); }
.empty-state { text-align: center; border: 1px dashed #cfdace; border-radius: 15px; padding: 37px 20px; color: var(--muted); }
.empty-state .empty-icon { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 14px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 18px; }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: 16px; }.empty-state p { max-width: 290px; margin: 7px auto 0; font-size: 12px; }

/* Insights. */
.insights-layout { display: grid; gap: 16px; margin-top: 22px; }
.ins-section { min-width: 0; padding: 21px 17px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.ins-section h2 { font-size: 16px; margin-bottom: 18px; }.ins-section h2:has(+ p) { margin-bottom: 4px; }.ins-section > p { margin-bottom: 20px; }
.daybar { display: grid; grid-template-columns: 82px minmax(0, 1fr) 30px; align-items: center; gap: 10px; min-height: 35px; font-size: 12px; }
.daybar-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.daybar-track { height: 9px; overflow: hidden; border-radius: 5px; background: #f0f3ed; }
.daybar-track > span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: #80ad90; }
.daybar-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.daybar.clickable { cursor: pointer; min-height: 44px; }
.export-row { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 25px; }
.export-row .btn-link { gap: 17px; }

/* Settings: calm sections with a save action always within reach. */
#settings { max-width: 940px; margin: 0 auto; }
.settings { display: flex; flex-direction: column; gap: 13px; }
.set-group { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); overflow: hidden; }
.set-group > summary { display: flex; align-items: center; min-height: 62px; padding: 17px 19px; font-weight: 550; font-size: 14px; gap: 14px; user-select: none; }
.set-group[open] > summary { border-bottom: 1px solid #edf0e9; }
.set-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 22px 19px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.field > label { font-size: 13px; font-weight: 500; }.field > input, .field > select { width: 100%; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 15px; }
.field.inline > label:first-child { flex: 1; }
.field.inline .field-hint { flex-basis: 100%; }
.field-hint { font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.switch { position: relative; display: inline-block; width: 48px; height: 44px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch .slider { position: absolute; inset: 9px 0; border: 1px solid #d3ddd2; border-radius: 999px; background: #dce5da; transition: background-color 150ms ease, border-color 150ms ease; pointer-events: none; }
.switch .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #b6c4b4; transition: transform 150ms ease; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(22px); box-shadow: none; }
.switch input:focus-visible + .slider { outline: 3px solid #74ac91; outline-offset: 3px; }
.settings-save { position: sticky; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; margin: 20px -1px 0; padding: 15px 0; background: var(--bg); border-top: 1px solid var(--border); z-index: 5; }
.settings-save button { flex: 1 1 auto; min-height: 48px; }.settings-save #settingsMsg:empty { display: none; }
.settings-save #settingsMsg { flex: 1 1 100%; text-align: center; }

/* Scrollable player with a close control that stays visible. */
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.modal:not([hidden]) .modal-inner { animation: sheet-in 180ms cubic-bezier(.22, 1, .36, 1); }
.modal { position: fixed; z-index: 70; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-top: max(12px, env(safe-area-inset-top, 0px)); background: rgba(15,29,21,.76); overscroll-behavior: contain; }
.modal-inner { width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border-radius: 20px 20px 0 0; }
.modal-heading { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; min-height: 65px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--border); background: var(--panel); font-size: 14px; font-weight: 550; }
.modal-close { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: #eff3ed; border-radius: 50%; }
.modal-close svg { width: 20px; height: 20px; }
.player-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.modal-content { padding: 20px 18px max(24px, env(safe-area-inset-bottom, 0px)); }
.modal-meta .rec-time { font-size: 17px; }.modal-meta .rec-sub { margin-top: 6px; }
.modal-actions { margin: 20px 0 23px; gap: 7px; }.modal-actions > * { flex: 1 1 auto; font-size: 12px; padding: 10px 12px; }
#seenBtn.on { background: var(--accent-soft); color: var(--ok); border-color: #c6dfcd; }
.note-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.note-input { display: block; width: 100%; }
.event-track { position: relative; height: 44px; margin-top: 20px; overflow: hidden; border-radius: 8px; background: var(--panel-2); }
.event-mark { position: absolute; top: 0; height: 100%; min-width: 8px; border-radius: 4px; opacity: .85; cursor: pointer; }
.event-mark.motion { background: #9a78b2; }.event-mark.object { background: #5d9b7d; }.event-mark.sound { background: #c7a350; }
.event-list { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.event-list-title { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 550; }
.event-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left; padding: 12px; border-radius: 10px; }
.event-row.object { border-color: #d5e5d8; }.event-row.motion { border-color: #e2d6ea; }.event-row.sound { border-color: #eadfbc; }
.event-label { font-size: 13px; font-weight: 550; }.event-detail { color: var(--muted); font-size: 11px; text-align: right; }

/* Feedback. */
.banner { padding: 13px 20px; background: #fbf2db; border-bottom: 1px solid #e9d4a0; color: #765818; font-size: 12px; text-align: center; }
.toasts { position: fixed; z-index: 100; right: 16px; left: 16px; bottom: calc(var(--nav-height) + 13px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { width: fit-content; max-width: 430px; padding: 13px 18px; border: 1px solid #c5d8ca; border-radius: 12px; background: #f9fcf7; color: var(--text); box-shadow: 0 6px 25px rgba(26,52,33,.14); font-size: 13px; opacity: 0; transform: translateY(6px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }.toast.ok { border-color: #b4d2bf; }.toast.bad { border-color: #e4b8b0; background: #fff6f3; color: var(--bad); }

/* Sign-in. */
.login-body { display: grid; place-items: center; min-height: 100svh; background: #eff2ea; padding: max(24px, env(safe-area-inset-top, 0px)) 20px max(24px, env(safe-area-inset-bottom, 0px)); }
.login-main { width: 100%; max-width: 410px; margin: 0; padding: 0; }
.login-brand { width: fit-content; display: flex; margin: 0 auto 33px; font-size: 29px; gap: 10px; }
.login-brand .brand-mark { width: 42px; height: 42px; }
.login-card { padding: 34px 26px 28px; border: 1px solid #dfe5d9; border-radius: 22px; background: var(--panel); }
.login-illustration { display: grid; place-items: center; width: 70px; height: 70px; margin-bottom: 25px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.login-illustration svg { width: 44px; height: 44px; stroke-width: 1.4; }
.login-card .eyebrow { margin-bottom: 8px; }.login-card h1 { font-size: 31px; }
.login-description { margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.login-card > label { display: block; margin: 29px 0 8px; color: var(--text); font-size: 12px; font-weight: 550; }
.login-card input, .login-card button { width: 100%; min-height: 50px; }
.login-card button { margin-top: 13px; justify-content: space-between; padding-inline: 17px; }
.login-card .error { margin-top: 15px; font-size: 12px; }
.login-footer { margin-top: 25px; color: var(--muted); font-size: 11px; text-align: center; }

@media (min-width: 520px) {
  .camera-card-footer { flex-direction: row; align-items: center; justify-content: space-between; gap: 18px; padding: 19px; }
  .live-cta { flex: none; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .dash-preview { aspect-ratio: 16/9; }.dash-preview-empty > span { max-width: none; }
  .recent-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-actions { justify-content: flex-end; }.filter-actions > button { flex: 0 1 auto; }
  .summary-hint { display: inline; }.system-details > summary::after, .filter-details > summary::after { margin-left: 6px; }
  .hist-bar { flex-direction: row; align-items: center; justify-content: space-between; gap: 15px; }
  .sel-bar { flex-direction: row; align-items: center; justify-content: space-between; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .video-wrap { aspect-ratio: 16/9; }.live-ph h2 { font-size: 24px; }.live-ph p { font-size: 14px; }.live-start-note { font-size: 12px; }
  .live-controls #goLive { flex: 0 1 auto; }.live-controls > button:not(.primary) { flex: 0 1 auto; }.live-controls #liveState { width: auto; }
  .insights-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }.insights-days { grid-column: 1/-1; }
  .export-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .settings-save button { flex: 0 1 auto; }.settings-save #settingsMsg { flex: 1; text-align: left; }
  .modal { padding: 24px; align-items: center; }.modal-inner { width: min(940px, 100%); max-height: 92dvh; border-radius: 20px; }.modal-content { padding: 24px; }
}
@media (min-width: 800px) {
  :root { --nav-height: 0px; }
  .topbar { height: 84px; padding: 0 32px; gap: 24px; }
  .brand { font-size: 25px; gap: 11px; }.brand-caption { font-size: 10px; }.brand-mark { width: 40px; height: 40px; }
  .tabs { position: static; display: flex; width: auto; height: auto; gap: 4px; padding: 5px; background: transparent; border: 0; }
  .tabs a { flex-direction: row; gap: 7px; min-height: 42px; padding: 11px 12px; border-radius: 9px; font-size: 12px; }
  .tabs a svg { width: 18px; height: 18px; padding: 0; }.tabs a.active { background: var(--accent-soft); }.tabs a.active svg { box-shadow: none; background: transparent; }
  .topbar-right { gap: 13px; }.camera-status { max-width: 150px; }
  main { padding: 38px 32px 30px; }.page-heading { margin-bottom: 30px; }.page-description { font-size: 15px; }
  .dashboard-layout { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); grid-template-areas: "camera controls" "recent recent"; gap: 22px; align-items: stretch; }
  .camera-card { display: flex; flex-direction: column; }.dash-preview { flex: 1; min-height: 280px; }.camera-card-footer { padding: 21px; }
  .quick-panel { padding: 23px 22px 18px; }.quick { grid-template-columns: minmax(0, 1fr); gap: 15px; }.quick-footnote { margin-top: 17px; }
  .quick-panel .section-caption { display: none; }.quick-panel .dash-head { margin-bottom: 19px; }
  .recent-section { margin-top: 13px; }.recent-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }.recent-thumb { aspect-ratio: 16/10; }
  .recent-card:nth-child(n+5) { display: block; }
  .recent-meta { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: 13px 12px; }
  .dash-head h2 { font-size: 22px; }.quick-panel .dash-head h2 { font-size: 17px; }.text-link { font-size: 13px; }
  .system-details { margin-top: 33px; }.system-details .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filter-details > summary { min-height: 56px; }.filters { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 22px; }
  .presets { gap: 8px; }.presets button { font-size: 13px; padding-inline: 16px; }
  .rec-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }.hist-bar { margin-bottom: 18px; }
  .insights-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }.ins-section { padding: 24px; }.daybar { grid-template-columns: 110px minmax(0, 1fr) 38px; gap: 18px; }
  .ins-section h2 { font-size: 18px; }.insights-days .daybar { min-height: 37px; }
  .set-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 27px; padding: 25px; }.set-group > summary { padding: 21px 25px; font-size: 15px; }
  .settings-save { bottom: 0; margin-top: 25px; padding: 18px 0; }
  .live-controls { padding: 21px; gap: 10px; }.video-wrap { aspect-ratio: 16/8.5; }.live-ph-icon svg { width: 59px; height: 59px; margin-bottom: 12px; }
  .live-ph h2 { font-size: 28px; }.live-ph p { font-size: 15px; }.live-start-note { margin-top: 5px; }
  .toasts { left: auto; right: 26px; bottom: 26px; align-items: flex-end; }.app-footer { margin-top: 44px; }
}
@media (min-width: 1100px) {
  .topbar { padding-inline: max(32px, calc((100vw - 1196px) / 2)); }
  .tabs { gap: 7px; }.tabs a { padding: 11px 16px; font-size: 13px; }
  main { padding-top: 43px; }.dashboard-layout { grid-template-columns: minmax(0, 1.65fr) minmax(330px, 1fr); gap: 26px; }
  .quick-panel .section-caption { display: block; }.quick-panel { padding: 25px; }.camera-card-footer { padding: 23px; }
  .preview-camera { top: 21px; left: 21px; }.preview-caption { left: 21px; bottom: 18px; font-size: 11px; }
  .cards .card { padding: 24px; }.card .v { font-size: 29px; }.card .k { font-size: 12px; }
  .rec-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .insights-layout { grid-template-columns: 1.5fr 1fr; }.insights-days { grid-column: 1; grid-row: span 2; }
}
@media (hover: hover) {
  button:hover, .btn-link:hover { border-color: #adc8b6; background: #f6f9f3; }
  button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  button.danger:hover { background: #f9e9e4; border-color: #e7c1b9; }
  .tabs a:hover { color: var(--accent); }.logout:hover { background: var(--panel-2); color: var(--text); }
  .seg-btn:hover { background: #e9eee5; }.seg-btn.on:hover { background: #fff; }
  .recent-card:hover { border-color: #a7c3af; transform: translateY(-2px); }.rec-card:hover { border-color: #a7c3af; }
  .rec-del, .rec-seen { opacity: 0; transition: opacity 140ms ease, background-color 140ms ease; }
  .rec-card:hover .rec-del, .rec-card:hover .rec-seen, .rec-del:focus-visible, .rec-seen:focus-visible, .rec-seen.on { opacity: 1; }
  .rec-del:hover { background: var(--bad); border-color: transparent; }.rec-seen:hover { background: var(--accent); border-color: transparent; }
  .daybar.clickable:hover .daybar-label { color: var(--accent); }.daybar.clickable:hover .daybar-track > span { background: var(--accent); }
}
@media (max-width: 359px) {
  .topbar { padding-inline: 14px; gap: 8px; }.brand { gap: 7px; }.topbar-right { gap: 2px; }.camera-status { font-size: 10px; max-width: 115px; }
  main { padding-inline: 14px; }.dash-head { gap: 8px; }.dash-head h2 { font-size: 17px; }.text-link { font-size: 11px; }
  .quick-panel .section-caption { display: none; }.seg-btn { padding-inline: 4px; font-size: 11px; }.tabs a { font-size: 9px; }
  .login-card { padding: 28px 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
