/* Camerold viewer. Colors are CSS variables (same palette as the Android app); dark theme via prefers-color-scheme or [data-theme]. */
/* ===== Colors: Light by default, Dark per system or user choice (data-theme) ===== */
:root {
  color-scheme: light;
  --bg: #f2f3f5; --card: #ffffff; --input: #f0f1f4; --text: #111318; --text2: #6a707b; --text3: #9aa0aa;
  --line: rgba(17, 19, 24, .08); --accent: #3d5afe; --accent-ink: #fff; --accent-soft: rgba(61, 90, 254, .1); --icon-bg: #f0f1f4;
  --seg-bg: #eceef1; --seg-on: #ffffff; --seg-ink: #111318; --switch-off: #c7cbd2;
  --ok: #12a150; --warn: #d97706; --bad: #e5484d; --live: #ff3b30;
  --radius: 24px; --radius-s: 16px; --shadow: none;
  --font: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #000000; --card: #17181b; --input: #24262b; --text: #f2f3f5; --text2: #9ea3ac; --text3: #6b707a; --line: rgba(255, 255, 255, .1);
    --accent: #7b8cff; --accent-ink: #0b0f2a; --accent-soft: rgba(123, 140, 255, .16); --icon-bg: #24262b;
    --seg-bg: #24262b; --seg-on: #3a3d45; --seg-ink: #f2f3f5; --switch-off: #3a3d45;
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #000000; --card: #17181b; --input: #24262b; --text: #f2f3f5; --text2: #9ea3ac; --text3: #6b707a; --line: rgba(255, 255, 255, .1);
  --accent: #7b8cff; --accent-ink: #0b0f2a; --accent-soft: rgba(123, 140, 255, .16); --icon-bg: #24262b;
  --seg-bg: #24262b; --seg-on: #3a3d45; --seg-ink: #f2f3f5; --switch-off: #3a3d45;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ===== Login / settings pages ===== */
#login, .page { max-width: 560px; margin: 0 auto; padding: 0 16px calc(120px + env(safe-area-inset-bottom)); }
.page { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.appbar { display: flex; align-items: center; gap: 8px; height: 64px; margin: 0 -8px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box; }
.appbar h2 { margin: 0; font-size: 20px; font-weight: 500; }
.appbar .page-title { flex: 1; min-width: 0; margin: 0 0 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.appbar + .page-sub { margin-top: 0; }
.in-app .appbar { height: 56px; } /* same height as the app's own top bars */
.brand { flex: 1; display: flex; align-items: center; gap: 12px; padding-left: 12px; font-size: 28px; font-weight: 700; letter-spacing: -.3px; }
.brand-ic { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn { width: 48px; height: 48px; border: 0; border-radius: 24px; background: transparent; color: var(--text);
  display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: var(--accent-soft); }
.page-title { margin: 8px 4px 0; font-size: 20px; font-weight: 500; }
#camListBox { margin-top: 20px; }
#camListBox .section-title { margin-top: 28px; }
.page-sub { margin: 6px 4px 20px; color: var(--text2); font-size: 14px; line-height: 1.45; }
.or { display: flex; align-items: center; gap: 12px; margin: 4px 4px 12px; color: var(--text2); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note { margin: 10px 4px 0; color: var(--text2); font-size: 13px; line-height: 1.5; }
.row.col { flex-direction: column; align-items: stretch; gap: 10px; }
#ownBroker > .row::before { content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 1px; background: var(--line); }
#brokerResult .s { margin: 0; font-size: 14px; }
#brokerResult.ok .s { color: var(--ok); } #brokerResult.bad .s { color: var(--bad); }
.text-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 44px; margin: 0 0 8px;
  border: 0; background: transparent; color: var(--accent); font-size: 15px; font-weight: 500; cursor: pointer; border-radius: 22px; }
.text-btn svg.i { width: 20px; height: 20px; }
.text-btn:active { background: var(--accent-soft); }
.tonal { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 56px; margin-bottom: 12px;
  border: 0; border-radius: 28px; background: var(--card); color: var(--accent); font-size: 16px; font-weight: 500; cursor: pointer; }
.tonal:active, .pill:active { transform: scale(.98); }
/* Group label above a card, lined up with the card's edge */
.section-title { margin: 28px 4px 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
/* The one row style (same as the app): title 16px, value 14px, text starting at the same place */
.row { position: relative; display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 12px 20px; }
.row + .row::before, .row + pre + .row::before {
  content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 1px; background: var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 16px; line-height: 1.3; }
.row .s { font-size: 14px; line-height: 1.35; color: var(--text2); margin-top: 4px; }
.field { flex-direction: column; align-items: stretch; gap: 4px; cursor: text; }
.field > span { font-size: 16px; line-height: 1.3; color: var(--text); }
.field input { border: 0; outline: 0; background: transparent; padding: 0; font-size: 16px; line-height: 1.35; width: 100%; color: var(--text2); }
.field input::placeholder { color: var(--text3); opacity: 1; }
.row select { border: 0; background: transparent; color: var(--text2); font-size: 14px; text-align: right; outline: 0; max-width: 55%; }
.row.link { color: var(--accent); justify-content: center; font-weight: 500; cursor: pointer; border: 0; background: transparent;
  width: 100%; text-decoration: none; }
.group.gap { margin-top: 16px; }
.s.ok { color: var(--ok); }
#netResult { margin: 0; padding: 4px 20px 16px; white-space: pre-wrap; font: 14px/1.7 var(--font); color: var(--text); }
#netResult:empty { display: none; }
#loginMsg { margin: 14px 20px 0; color: var(--bad); font-size: 14px; min-height: 1em; }
.foot { text-align: center; color: var(--text2); font-size: 12px; margin-top: 24px; }
.bottom-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent); display: flex; justify-content: center; z-index: 5; }
.pill { width: 100%; max-width: 488px; height: 56px; border: 0; border-radius: 28px; font-size: 17px; font-weight: 500; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); }
.pill:disabled { opacity: .6; }

/* Password with show/hide, share row */
.pw-line { display: flex; align-items: center; gap: 8px; }
.pw-line input { flex: 1; min-width: 0; }
.eye { flex: none; width: 40px; height: 40px; margin: -10px -10px -10px 0; border: 0; border-radius: 20px; background: transparent;
  color: var(--text2); display: grid; place-items: center; cursor: pointer; }
.eye:active { background: var(--accent-soft); }

/* Saved cameras: the last picture seen from each, name and "watched … ago" on it, ⋮ in the corner.
   One per row for one or two cameras, two per row from three on. */
#camList { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
#camList.many { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cam-card { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; cursor: pointer; color: #fff;
  background: radial-gradient(120% 90% at 20% 10%, hsl(var(--hue, 225) 38% 30%), #101319 72%); isolation: isolate;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s; }
.cam-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Play button in the middle, on hover (computers) */
.cam-card .play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, .2); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transform: scale(.85); transition: opacity .2s, transform .2s; pointer-events: none; }
.cam-card .play svg.i { width: 22px; height: 22px; fill: #fff; stroke: none; margin-left: 3px; }
@media (hover: hover) {
  .cam-card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, .22); }
  .cam-card:hover .play { opacity: 1; transform: none; }
  .cam-card:hover .ph { opacity: 0; }
}
.cam-card .ph { transition: opacity .2s; }
#camList.many .cam-card { aspect-ratio: 4 / 3; border-radius: 20px; }
.cam-card:active { transform: scale(.985); }
.cam-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
.cam-card .ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .35); z-index: -1; }
.cam-card .ph svg.i { width: 34px; height: 34px; }
.cam-card::after { content: ""; position: absolute; inset: 45% 0 0; z-index: -1;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72)); }
.cam-card .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px 14px; }
#camList.many .cam-card .info { padding: 10px 12px 11px; }
.cam-card .t { font-size: 17px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.cam-card .s { margin-top: 2px; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#camList.many .cam-card .t { font-size: 15px; } #camList.many .cam-card .s { font-size: 12px; }
.cam-more { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; color: #fff;
  background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.cam-more svg.i { width: 20px; height: 20px; }
.cam-more:active { background: rgba(0, 0, 0, .5); }
/* Ways to add a camera: one card of rows */
.row.act { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.row.act:active { background: var(--accent-soft); }
.act-ic { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); }
.act-ic svg.i { width: 20px; height: 20px; }
.add-card .row + .row::before { left: 76px; }
.add-card svg.chev { width: 18px; height: 18px; color: var(--text3); }
.add-card + input + #manualBox .or, .add-card ~ #manualBox .or { margin-top: 24px; }
/* Bottom sheet (actions for a camera) */
.dlg.sheet { align-items: flex-end; cursor: default; }
.sheet-card { width: 100%; max-width: 480px; background: var(--card); border-radius: 24px; padding: 8px;
  animation: dlg-up .25s cubic-bezier(.2, .8, .2, 1); }
.sheet-title { display: flex; flex-direction: column; padding: 14px 16px 10px; }
.sheet-title b { font-size: 17px; } .sheet-title span { font-size: 13px; color: var(--text2); margin-top: 2px; }
.sheet-btn { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px; border: 0; border-radius: 14px;
  background: transparent; color: var(--text); font-size: 16px; text-align: left; cursor: pointer; }
.sheet-btn:active { background: var(--accent-soft); }
.sheet-btn svg.i { color: var(--text2); }
.sheet-btn.danger, .sheet-btn.danger svg.i { color: var(--bad); }
.sheet-btn.muted { justify-content: center; color: var(--text2); font-weight: 600; margin-top: 4px; }
/* Undo bar */
#snack { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 16px; max-width: min(calc(100% - 32px), 480px); padding: 10px 10px 10px 18px; border-radius: 14px;
  background: #23262d; color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
#login:has(#goBar:not([hidden])) #snack { bottom: calc(96px + env(safe-area-inset-bottom)); }
#snack button { flex: none; white-space: nowrap; border: 0; background: transparent; color: #8fb2ff; font-weight: 700; font-size: 14px; padding: 8px 10px; cursor: pointer; }
/* QR for another viewer: just the code on a white card, tap anywhere to close */
.dlg { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: dlg-fade .2s; cursor: pointer; }
.qr-card { width: min(84vw, 340px); padding: 18px; border-radius: 32px; background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: dlg-up .3s cubic-bezier(.2, .8, .2, 1); }
.qr-card svg { display: block; width: 100%; aspect-ratio: 1; height: auto; }
.qr-cap { margin: 6px 4px 0; text-align: center; font-size: 14px; line-height: 1.35; color: #4a505b; }
.qr-cap b { display: block; color: #161a23; font-size: 15px; }
.qr-acts { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.qr-acts button { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: 20px;
  background: #eef2ff; color: #2a52e0; font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; }
.qr-acts button:hover { background: #e0e7ff; }
.qr-acts button svg.i { width: 18px; height: 18px; }
@keyframes dlg-fade { from { opacity: 0; } }
@keyframes dlg-up { from { transform: scale(.92); opacity: 0; } }

/* Switch */
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 50px; height: 28px; margin: 0; border-radius: 14px;
  background: var(--switch-off); position: relative; cursor: pointer; transition: background .2s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(22px); }

/* ===== QR scanner ===== */
#scanner { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; align-items: center; justify-content: center; }
#scanVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Dark cover above the camera until real frames arrive, then it fades out. The <video> itself is never animated:
   changing a camera video's opacity makes Android WebView draw it small in the top-left corner. */
#scanCover { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 30%, #1d2533, #07090c);
  transition: opacity .3s; pointer-events: none; }
#scanner.has-frames #scanCover { opacity: 0; }
.scan-frame { position: relative; width: min(70vw, 300px); aspect-ratio: 1; border-radius: 28px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); outline: 3px solid rgba(255, 255, 255, .9); outline-offset: -3px; }
.scan-frame::after { content: ""; position: absolute; left: 10%; right: 10%; height: 2px; top: 10%; background: #4b8dff;
  box-shadow: 0 0 12px #4b8dff; animation: scanline 2s ease-in-out infinite alternate; }
@keyframes scanline { to { top: 90%; } }
.scan-top { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; gap: 12px; }
.scan-top h3 { margin: 0; font-size: 20px; }
.scan-bottom { position: absolute; left: 24px; right: 24px; bottom: max(32px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px; }
#scanHint { align-self: stretch; text-align: center; font-size: 15px; padding: 14px 18px; border-radius: 20px; }
.pill-glass { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border: 0; border-radius: 22px; cursor: pointer;
  color: #fff; font-size: 15px; font-weight: 600; background: rgba(255, 255, 255, .16); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.pill-glass svg.i { width: 20px; height: 20px; }

/* ===== Viewer ===== */
.glass { background: rgba(30, 30, 32, .55); -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, .08); color: #fff; }
#viewer { position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
#player { position: relative; background: #000; color: #fff; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#zoom { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
#video { position: absolute; object-fit: contain; background: #000; transform-origin: 50% 50%; }

/* Portrait (like YouTube on phones): video sticks to the top, content below */
#viewer.stacked #player { position: sticky; top: 0; z-index: 5; padding-top: env(safe-area-inset-top);
  height: calc(min(56.25vw, 62vh) + env(safe-area-inset-top)); }
#viewer.stacked #stage { top: env(safe-area-inset-top); }
/* Landscape / fullscreen: video fills the screen */
#viewer.immersive { overflow: hidden; background: #000; }
#viewer.immersive #player { position: absolute; inset: 0; }
#viewer.immersive #below { display: none; }

/* ---- Waiting / problem screen over the player ---- */
#overlay { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 20px; pointer-events: none;
  color: #fff; text-align: center; overflow: hidden; transition: opacity .35s; }
/* Slowly drifting colour glow instead of a flat black box */
#overlay::before { content: ""; position: absolute; inset: -30%; z-index: -1;
  background:
    radial-gradient(40% 45% at 30% 35%, rgba(75, 141, 255, .32), transparent 70%),
    radial-gradient(35% 40% at 72% 68%, rgba(47, 179, 106, .20), transparent 70%),
    radial-gradient(30% 35% at 70% 25%, rgba(155, 110, 255, .18), transparent 70%),
    #07090e;
  animation: ov-drift 14s ease-in-out infinite alternate; }
#overlay[data-mode=problem]::before { background:
    radial-gradient(40% 45% at 35% 40%, rgba(245, 165, 36, .22), transparent 70%),
    radial-gradient(35% 40% at 70% 65%, rgba(242, 68, 58, .14), transparent 70%), #0b0a0a; }
#overlay[data-mode=busy]::before { background: rgba(5, 6, 8, .72); animation: none; }
@keyframes ov-drift { to { transform: translate(6%, -4%) rotate(8deg) scale(1.08); } }

.ov-card { display: flex; flex-direction: column; align-items: center; max-width: 340px; }
.ov-icon { position: relative; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 16px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.ov-icon svg.i { width: 28px; height: 28px; }
/* Sonar rings while searching */
.ov-icon i { position: absolute; inset: -1px; border-radius: 50%; border: 2px solid rgba(120, 170, 255, .7);
  animation: ov-ping 2.2s cubic-bezier(.2, .6, .3, 1) infinite; }
.ov-icon i:nth-child(2) { animation-delay: 1.1s; }
@keyframes ov-ping { from { transform: scale(1); opacity: .9; } to { transform: scale(2.3); opacity: 0; } }
#overlay:not([data-mode=loading]) .ov-icon i { display: none; }
#overlay[data-mode=problem] .ov-icon { background: rgba(245, 165, 36, .18); border-color: rgba(245, 165, 36, .45); color: #ffc65c; }
.ov-title { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.ov-text { margin-top: 6px; font-size: 14px; line-height: 1.45; opacity: .78; }

.ov-steps { list-style: none; display: flex; gap: 6px; margin: 18px 0 0; padding: 0; }
.ov-steps li { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px; border-radius: 16px;
  background: rgba(255, 255, 255, .07); font-size: 12px; opacity: .5; transition: opacity .3s, background .3s; }
.ov-steps b { font-weight: 600; white-space: nowrap; }
.ov-steps span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); flex: none; position: relative; }
.ov-steps li.active { opacity: 1; background: rgba(75, 141, 255, .22); }
.ov-steps li.active span { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
.ov-steps li.done { opacity: .9; }
.ov-steps li.done span { border-color: var(--ok); background: var(--ok); }
.ov-steps li.done span::after { content: ""; position: absolute; left: 3px; top: 0; width: 3px; height: 7px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.ov-retry { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; opacity: .65; }
.mini-spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite; flex: none; }

/* Reconnecting while video was already showing: keep the last frame, blurred, with a small pill */
#reconnectPill { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: flex; align-items: center;
  gap: 10px; padding: 10px 16px; border-radius: 22px; font-size: 14px; font-weight: 600; pointer-events: none; }
/* The camera phone is hot and running at lower quality */
#heatPill { position: absolute; left: 50%; top: calc(58px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 6px; max-width: calc(100% - 32px); padding: 6px 12px 6px 8px; border-radius: 16px;
  font-size: 13px; font-weight: 600; color: #fff; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#heatPill svg.i { width: 18px; height: 18px; color: #ffb547; }
.warn-badge { color: #ffb547; }
.srow.off { opacity: .4; pointer-events: none; }
.srow.field { flex-direction: column; align-items: stretch; gap: 4px; }
.srow.field > span { font-size: 16px; line-height: 1.3; color: var(--text); }
.srow.field input { border: 0; outline: 0; background: transparent; padding: 0; font-size: 16px; line-height: 1.35; width: 100%; color: var(--text2); }
.srow.field input::placeholder { color: var(--text3); opacity: 1; }
.srow.btns { justify-content: flex-end; gap: 8px; }
.sbtn { height: 40px; padding: 0 16px; border: 0; border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  font-size: 14px; font-weight: 600; cursor: pointer; }
.sbtn.primary { background: var(--accent); color: var(--accent-ink); }
.sbtn:disabled { opacity: .5; }
#camTurnStatus.ok { color: var(--ok); } #camTurnStatus.bad { color: var(--bad); }

/* ===== Tabs (below the video in portrait, in the sheet in landscape) ===== */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--seg-bg); }
.tabs button { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; color: var(--text2); font-size: 14px; font-weight: 600; cursor: pointer; }
.tabs button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs button svg.i { width: 18px; height: 18px; }
.tabs button.on { background: var(--seg-on); color: var(--seg-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.tab-dot { position: absolute; top: 8px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
#viewer.stacked .sheet-head { position: sticky; top: calc(min(56.25vw, 62vh) + env(safe-area-inset-top)); z-index: 4;
  margin: 0 -16px; padding: 10px 16px; background: var(--bg); }
#viewer.immersive .tabs { margin: 0 0 6px; }
.pane > .sgroup-title:first-child { margin-top: 16px; }
.pane > .sgroup:first-child, .pane > div:first-child > .sgroup:first-child { margin-top: 8px; }

/* ===== Timelapse ===== */
.tl-card { padding: 18px 20px 20px; }
.tl-head { display: flex; align-items: center; gap: 14px; }
.tl-head .t { font-size: 17px; font-weight: 600; } .tl-head .s { font-size: 13px; color: var(--text2); margin-top: 2px; }
.tl-ic { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); }
.tl-ic.on { background: var(--bad); color: #fff; animation: tlPulse 2s ease-in-out infinite; }
@keyframes tlPulse { 50% { box-shadow: 0 0 0 7px rgba(229, 72, 77, .16); } }
.tl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.tl-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--input); min-width: 0; }
.tl-stats b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-stats span { font-size: 12px; color: var(--text2); }
.tl-go { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; margin-top: 16px; border: 0;
  border-radius: 24px; background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 600; cursor: pointer; }
.tl-go svg.i { width: 18px; height: 18px; fill: currentColor; }
.tl-go.stop { background: var(--bad); color: #fff; }
.tl-go:active { transform: scale(.98); }
.s.warn, #tlSub.warn { color: var(--warn); }
.tl-card + .sgroup, .sgroup + .sgroup { margin-top: 12px; }
button.srow.link { width: 100%; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.srow.link:active { background: var(--accent-soft); border-radius: var(--radius); }
.srow.link.locked { opacity: .55; }
.row-ic { width: 24px; height: 24px; color: var(--text2); display: grid; place-items: center; flex: none; }
.row-ic svg.i { width: 22px; height: 22px; }
svg.chev { width: 18px; height: 18px; color: var(--text3); }
.tl-empty-card { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 18px 20px; border-radius: var(--radius);
  background: var(--card); color: var(--text2); font-size: 14px; }

/* Camera storage: used · this timelapse · free */
.store-card { padding: 16px 20px 18px; }
.store-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.store-head b { font-size: 13px; font-weight: 600; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.store-bar { display: flex; height: 10px; margin: 12px 0 10px; border-radius: 5px; overflow: hidden; background: var(--input); }
.store-bar i { display: block; height: 100%; transition: width .4s; }
.store-bar i.used { background: var(--text2); opacity: .45; }
.store-bar i.need { background: var(--accent); border-radius: 0 5px 5px 0; }
.store-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text2); }
.store-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.store-legend i { width: 8px; height: 8px; border-radius: 50%; }
.store-legend i.used { background: var(--text2); opacity: .45; } .store-legend i.need { background: var(--accent); }
.store-legend i.free { background: var(--input); box-shadow: inset 0 0 0 1px var(--line); }
.store-card > .s { font-size: 13px; color: var(--text2); margin-top: 10px; }
.store-card > .s:empty { display: none; }

/* Settings sheet with its estimate */
.tl-sheet { max-height: 88vh; overflow-y: auto; padding: 8px 8px 12px; }
.tl-sheet .srow { padding: 10px 12px; min-height: 0; }
.tl-sheet .srow + .srow::before { left: 12px; right: 12px; }
.tl-sheet .pill { display: block; margin: 12px auto 4px; height: 48px; font-size: 16px; background: var(--accent); color: var(--accent-ink); }
.tl-est { margin: 0 4px 6px; padding: 14px; border-radius: 18px; background: var(--accent-soft); }
.tl-est-head { font-size: 13px; font-weight: 600; color: var(--accent); }
.tl-est .tl-stats { margin-top: 10px; }
.tl-est .tl-stats > div { background: var(--card); }
.tl-est > .s { font-size: 13px; color: var(--text2); margin-top: 10px; }
#selTlInt button, #selTlDur button { min-width: 0; padding: 0 4px; }
.tl-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; position: relative; }
.tl-item + .tl-item::before { content: ""; position: absolute; top: 0; left: 92px; right: 0; height: 1px; background: var(--line); }
.tl-thumb { width: 68px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--input); flex: none;
  display: grid; place-items: center; color: var(--text3); }
.tl-thumb svg.i { width: 20px; height: 20px; }
.tl-item .t { font-size: 15px; } .tl-item .s { font-size: 13px; color: var(--text2); margin-top: 2px; }
.tl-item .grow { flex: 1; min-width: 0; } .tl-item .t, .tl-item .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-item .icon-btn { width: 40px; height: 40px; color: var(--text2); }
.tl-item .icon-btn.confirm { color: var(--bad); background: rgba(229, 72, 77, .12); }
.tl-item .bar { height: 3px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.tl-item .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.tl-empty { padding: 16px 20px; color: var(--text2); font-size: 14px; }
/* How many people are watching (camera tells), next to the timelapse badge */
.viewers-pill { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 7px; margin-left: 6px; border-radius: 12px;
  background: rgba(0, 0, 0, .4); color: #fff; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.viewers-pill svg.i { width: 15px; height: 15px; }
.tl-badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 6px; margin: 0 4px 0 6px; border: 0;
  border-radius: 13px; background: rgba(229, 72, 77, .9); color: #fff; font-size: 12px; font-weight: 700; cursor: pointer; }
.tl-badge svg.i { width: 15px; height: 15px; }
#player.waiting #heatPill { display: none; }
#flash { position: absolute; inset: 0; z-index: 4; background: #fff; opacity: 0; pointer-events: none; }
#flash.go { animation: shutter .35s ease-out; }
@keyframes shutter { from { opacity: .75; } to { opacity: 0; } }
#video { transition: filter .4s; }
#player.reconnecting #video { filter: blur(8px) brightness(.6) saturate(.8); }

#player.waiting .ctl-bottom { display: none; }

/* Small player (portrait): compact layout, shifted below the top bar */
#viewer.stacked #overlay { padding: 44px 16px 10px; }
#viewer.stacked .ov-icon { width: 44px; height: 44px; margin-bottom: 8px; }
#viewer.stacked .ov-icon svg.i { width: 20px; height: 20px; }
#viewer.stacked .ov-title { font-size: 15px; }
#viewer.stacked .ov-text { font-size: 12.5px; margin-top: 4px; }
#viewer.stacked .ov-steps { margin-top: 10px; gap: 4px; }
#viewer.stacked .ov-steps li { padding: 4px 8px 4px 6px; font-size: 11px; }
#viewer.stacked .ov-retry { margin-top: 8px; font-size: 12px; }
#viewer.stacked #overlay[data-mode=problem] .ov-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* YouTube-style controls: show on tap, auto-hide after a few seconds */
#ctl { position: absolute; inset: 0; z-index: 3; pointer-events: none; transition: opacity .25s; }
#viewer.stacked #ctl { top: env(safe-area-inset-top); }
#player.hide-ctl #ctl { opacity: 0; }
#player.hide-ctl #ctl * { pointer-events: none !important; }
.ctl-top, .ctl-bottom { position: absolute; left: 0; right: 0; display: flex; padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
.ctl-top { top: 0; align-items: center; gap: 4px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); padding-bottom: 28px; }
#viewer.immersive .ctl-top { padding-top: max(8px, env(safe-area-inset-top)); }
.ctl-bottom { bottom: 0; flex-direction: column; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); padding-top: 34px; }
#viewer.immersive .ctl-bottom { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.ctl-title { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 4px; }
.ctl-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl-title span { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#viewer.stacked .ctl-title { visibility: hidden; }
.ctl-row { display: flex; align-items: center; gap: 2px; min-height: 36px; }
/* Never push the right-hand buttons (snapshot, rotate, full screen) off screen, e.g. with a large system font:
   buttons keep their size; the zoom text shortens and the lens list scrolls instead */
.ctl-row > * { flex-shrink: 0; }
.ctl-row .grow { flex: 1 1 0; min-width: 0; }
#zoomTxt { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#lenses { flex-shrink: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#lenses::-webkit-scrollbar { display: none; }
#lenses button { flex: none; }
@media (max-width: 600px) { #viewer.immersive #zoomTxt { display: none; } }
.ib { pointer-events: auto; width: 40px; height: 40px; border: 0; border-radius: 20px; background: transparent; color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: none; }
.ib:active { background: rgba(255, 255, 255, .18); }
.ib:disabled { opacity: .35; }
.ib svg.i { width: 20px; height: 20px; }
.ib.sm { width: 36px; height: 36px; }
.ib.sm svg.i { width: 19px; height: 19px; }
#ctl .squeezed { display: none; }
.ib.on { background: rgba(255, 255, 255, .92); color: #000; }
#bTorch { touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
#bTorch.strobe { animation: strobe .5s steps(1) infinite; }
@keyframes strobe { 0% { background: #ffd54a; color: #000; } 50% { background: rgba(255, 255, 255, .18); color: #fff; } }
#zoomTxt { font-size: 13px; font-variant-numeric: tabular-nums; opacity: .9; margin-left: 2px; white-space: nowrap; }
#viewer.stacked #zoomTxt .max { display: none; }
#viewer.stacked #lenses button { min-width: 36px; padding: 0 8px; }
#lenses { pointer-events: auto; display: flex; gap: 2px; padding: 2px; border-radius: 18px; background: rgba(0, 0, 0, .35); }
#lenses:empty { display: none; }
#lenses button { height: 28px; min-width: 36px; padding: 0 9px; border: 0; border-radius: 16px; background: transparent; color: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer; }
#lenses button.on { background: rgba(255, 255, 255, .92); color: #000; }

/* Zoom bar replaces the video seek bar */
.ytbar { pointer-events: auto; -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent;
  cursor: pointer; --p: 0%; }
.ytbar::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--live) var(--p), rgba(255, 255, 255, .3) var(--p)); }
.ytbar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--live); transition: transform .15s; }
.ytbar:active::-webkit-slider-thumb { transform: scale(1.4); }
.ytbar::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .3); }
.ytbar::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--live); }
.ytbar::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--live); }
.ytbar:disabled { opacity: .4; }

#pinchChip { position: absolute; left: 50%; transform: translateX(-50%); top: 56px; z-index: 3; padding: 6px 12px; border-radius: 14px;
  font-size: 12px; pointer-events: none; white-space: nowrap; }
#stats { position: absolute; left: 10px; top: 56px; z-index: 3; border-radius: var(--radius-s); padding: 10px 14px;
  display: grid; grid-template-columns: max-content 1fr; gap: 3px 20px; font-size: 13px; pointer-events: none; }
#stats span:nth-child(odd) { opacity: .7; }
/* Portrait: connection info sits below the video (doesn't cover buttons) */
#statsHome #stats { position: static; padding: 16px 20px; border-radius: var(--radius); gap: 8px 20px;
  background: transparent; color: var(--text); border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; font-size: 14px; }
#statsHome #stats span:nth-child(odd) { opacity: 1; color: var(--text2); }
#statsHome:not(:has(#stats span))::after { content: attr(data-empty); display: block; padding: 16px 20px; color: var(--text2); font-size: 14px; }
#stats span:nth-child(even) { font-weight: 600; font-variant-numeric: tabular-nums; }
#toast { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 4; padding: 8px 14px; border-radius: 16px;
  font-size: 13px; pointer-events: none; white-space: nowrap; }
#focusRing { position: absolute; z-index: 2; width: 76px; height: 76px; margin: -38px 0 0 -38px; border: 2px solid #ffd60a; border-radius: 50%;
  pointer-events: none; opacity: 0; transform: scale(1.5); transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s; }
#focusRing.show { opacity: 1; transform: scale(1); }
#focusRing::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #ffd60a; }
#focusRing.fade-out { opacity: 0; transition-duration: .8s; }

/* Area below the video (portrait mode) */
#below { padding: 14px 16px 4px; }
#below h2 { margin: 0; font-size: 20px; font-weight: 700; }
.substatus { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--text2); font-size: 14px; }
/* View-only link: the camera refuses changes, so its controls aren't shown; a small pill says why */
#viewer.viewonly .owner-only, #viewer.viewonly .tl-item .del { display: none !important; }
.role-pill { display: none; align-items: center; gap: 4px; height: 22px; padding: 0 8px 0 6px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.role-pill svg.i { width: 14px; height: 14px; }
#viewer.viewonly .role-pill { display: inline-flex; }
.rec-pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; cursor: pointer;
  background: rgba(229, 72, 77, .12); color: var(--bad); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.rec-pill[hidden] { display: none; }
.rec-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); animation: recBlink 1.6s ease-in-out infinite; }
@keyframes recBlink { 50% { opacity: .25; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: 20px;
  background: var(--input); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip svg.i { width: 18px; height: 18px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip:disabled { opacity: .4; }

/* Camera settings: below the video in portrait, a slide-in panel in landscape/fullscreen */
#scrim { position: fixed; inset: 0; z-index: 9; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .25s; }
#scrim.show { opacity: 1; pointer-events: auto; }
#panel { padding: 8px 16px calc(28px + env(safe-area-inset-bottom)); }
#viewer.immersive #panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 82%; overflow-y: auto;
  overscroll-behavior: contain; border-radius: 28px 28px 0 0; padding: 6px 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(24, 24, 26, .92); -webkit-backdrop-filter: blur(30px) saturate(1.6); backdrop-filter: blur(30px) saturate(1.6);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); color: #fff; color-scheme: dark;
  --card: rgba(255, 255, 255, .07); --text: #fff; --text2: rgba(255, 255, 255, .62); --line: rgba(255, 255, 255, .1);
  --seg-bg: rgba(255, 255, 255, .08); --seg-on: #fff; --seg-ink: #000; --switch-off: #3a3a3c; --accent: #4b8dff; }
#viewer.immersive #panel.open { transform: none; }
@media (min-width: 760px) {
  #viewer.immersive #panel { left: auto; right: 16px; bottom: 16px; width: 400px; max-height: calc(100% - 32px); border-radius: 28px; }
}
.sheet-head { padding: 6px 4px 4px; }
#viewer.immersive .sheet-head { position: sticky; top: -6px; z-index: 1; margin: -6px -16px 0; padding: 6px 20px 2px;
  background: rgba(24, 24, 26, .97); border-radius: 28px 28px 0 0; }
.grabber { display: none; width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .3); margin: 6px auto 10px; cursor: grab; }
#viewer.immersive .grabber { display: block; }
#panel h3 { margin: 6px 4px 0; font-size: 20px; font-weight: 500; }
/* Same group label and row metrics as the rest of the app */
.sgroup-title { margin: 28px 4px 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.sgroup { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.srow { position: relative; display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 12px 20px; }
.srow + .srow::before { content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 1px; background: var(--line); }
.srow.col { flex-direction: column; align-items: stretch; gap: 10px; }
.srow .grow { flex: 1; min-width: 0; }
.srow .t { font-size: 16px; line-height: 1.3; }
.srow .s { font-size: 14px; line-height: 1.35; color: var(--text2); margin-top: 4px; }
.srow .v { color: var(--text2); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.srow .head { display: flex; justify-content: space-between; align-items: baseline; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 14px; background: var(--seg-bg); }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 11px; background: transparent; color: var(--text); font-size: 14px;
  font-weight: 600; cursor: pointer; padding: 0 2px; }
.seg button.on { background: var(--seg-on); color: var(--seg-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button:disabled { opacity: .3; cursor: default; }
#selFocus button { font-size: 13px; }
.range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-top: -4px; }
.srange { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; --p: 0%; }
.srange::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--seg-bg) var(--p)); }
.srange::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.srange::-moz-range-track { height: 6px; border-radius: 3px; background: var(--seg-bg); }
.srange::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.srange::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }

/* ===== Continuous recording ===== */
.rec-days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; }
.rec-days::-webkit-scrollbar { display: none; }
.rec-chip { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 76px; padding: 8px 14px;
  border: 0; border-radius: 14px; background: var(--card); color: var(--text); cursor: pointer; text-align: left; }
.rec-chip b { font-size: 14px; font-weight: 600; white-space: nowrap; }
.rec-chip span { font-size: 12px; color: var(--text2); white-space: nowrap; }
.rec-chip.on { background: var(--accent); color: var(--accent-ink); }
.rec-chip.on span { color: inherit; opacity: .8; }
.rec-line { padding: 14px 16px 6px; }
.rec-line[hidden] { display: none; }
.rec-track { position: relative; height: 18px; border-radius: 6px; background: var(--input); overflow: hidden; }
.rec-track i { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: .75; cursor: pointer; border-radius: 2px; }
.rec-track i.kept { background: var(--warn); opacity: .9; }
.rec-track i.live { background: var(--bad); opacity: 1; animation: recBlink 1.6s ease-in-out infinite; }
.rec-hours { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--text3, var(--text2)); font-variant-numeric: tabular-nums; }
.rec-item { position: relative; }
.rec-item + .rec-item::before { content: ""; position: absolute; top: 0; left: 92px; right: 0; height: 1px; background: var(--line); }
.rec-item > .tl-item { cursor: pointer; }
.rec-item.open > .tl-item { background: var(--accent-soft); }
.rec-item .t { display: flex; align-items: center; gap: 8px; }
.rec-item .t .when { overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.rec-item .tag { flex: none; padding: 1px 7px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.rec-item .tag[hidden] { display: none; }
.rec-item .tag.live { background: rgba(229, 72, 77, .14); color: var(--bad); }
.rec-item .tag.kept { background: rgba(217, 119, 6, .14); color: var(--warn); }
.rec-item .bar.busy i { width: 30% !important; animation: recBusy 1.1s ease-in-out infinite; }
@keyframes recBusy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.rec-item .acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 12px 12px; }
.rec-item .acts[hidden] { display: none; }
.rec-act { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px; border: 0; border-radius: 18px;
  background: var(--input); color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.rec-act svg.i { width: 17px; height: 17px; }
.rec-act.keep.on { background: rgba(217, 119, 6, .14); color: var(--warn); }
.rec-act.del { color: var(--bad); }
.rec-act.del.confirm { background: rgba(229, 72, 77, .14); }
.cut-big { margin-top: 6px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#cutDlg .tl-est > .s { font-size: 13px; color: var(--text2); margin-top: 6px; }
/* A downloaded recording */
.play-card { width: min(100%, 960px); border-radius: 20px; overflow: hidden; background: var(--card); cursor: default;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: dlg-up .25s cubic-bezier(.2, .8, .2, 1); }
.play-card video { display: block; width: 100%; max-height: 72vh; background: #000; }
.play-card video[hidden] { display: none; }
.play-bar { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; }
.play-bar .grow { flex: 1; min-width: 0; }
.play-bar .t { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-bar .s { font-size: 13px; color: var(--text2); margin-top: 2px; }
.play-bar .pill { width: auto; height: 40px; padding: 0 16px; display: inline-flex; align-items: center; gap: 6px; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); flex: none; }
.play-bar .pill svg.i { width: 18px; height: 18px; }
/* Four tabs on a narrow phone: text only */
@media (max-width: 420px) { .tabs button svg.i { display: none; } .tabs button { font-size: 13px; } }

/* The app's floating window (picture in picture): only the picture */
html.pip #ctl, html.pip #panel, html.pip #scrim, html.pip #toast, html.pip #stats, html.pip #pinchChip,
html.pip #focusRing, html.pip #heatPill { display: none !important; }
html.pip #viewer.immersive .ov-card { transform: scale(.6); }

/* Cameras page title (in the app it moves into the top bar and keeps that bar's size) */
#login > .page-title { margin-top: 12px; font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
/* Phone, three cameras or more: the last one watched big, the others two by two below it */
@media (max-width: 599px) {
  #camList.many .cam-card:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; border-radius: var(--radius); }
  #camList.many .cam-card:first-child .info { padding: 12px 16px 14px; }
  #camList.many .cam-card:first-child .t { font-size: 17px; } #camList.many .cam-card:first-child .s { font-size: 13px; }
}

/* ===== Tablets, unfolded foldables, computers ===== */
/* Cameras page: one wide column. Big title, the cameras as a grid of pictures, the ways to add one as tiles */
@media (min-width: 600px) {
  #login { max-width: 760px; padding-left: 24px; padding-right: 24px; }
  .page { max-width: 680px; }
  #login > .page-title { margin-top: 20px; font-size: 30px; }
  #login > .page-sub { margin-bottom: 24px; font-size: 15px; }
  #camListBox { margin-top: 0; }
  #camList, #camList.many { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
  #camList .cam-card, #camList.many .cam-card { aspect-ratio: 4 / 3; border-radius: var(--radius); }
  #camList.many .cam-card .info { padding: 12px 16px 14px; }
  #camList.many .cam-card .t { font-size: 17px; } #camList.many .cam-card .s { font-size: 13px; }
  #camListBox .section-title { margin-top: 40px; }
  .add-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px;
    background: none; border-radius: 0; overflow: visible; }
  .add-card .row.act { flex-direction: column; align-items: flex-start; gap: 14px; min-height: 0; padding: 20px;
    border-radius: var(--radius); background: var(--card); transition: background .15s, transform .15s; }
  .add-card .row + .row::before, .add-card svg.chev { display: none; }
  .add-card .act-ic { width: 44px; height: 44px; border-radius: 14px; }
  .add-card .act-ic svg.i { width: 22px; height: 22px; }
  .add-card .row.act .t { font-weight: 600; }
  #manualBox, #loginMsg { max-width: 560px; margin-left: auto; margin-right: auto; }
  /* The button right under the form instead of stuck to the bottom of a tall screen */
  #goBar { position: static; padding: 4px 0 0; background: none; }
  #goBar .pill { max-width: 560px; }
  #login:has(#goBar:not([hidden])) #snack { bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@media (min-width: 600px) and (hover: hover) {
  .add-card .row.act:hover { background: var(--accent-soft); }
}
@media (min-width: 900px) {
  #login:has(#camListBox:not([hidden])) { max-width: 1120px; padding-left: 40px; padding-right: 40px; }
  #camList, #camList.many { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
  #camList .cam-card, #camList.many .cam-card { aspect-ratio: 16 / 10; }
  #login .appbar { height: 80px; }
}
/* Sheets and dialogs in the middle of a big screen instead of stuck to its bottom edge */
@media (min-width: 600px) and (min-height: 600px) { .dlg.sheet { align-items: center; } }

/* Upright tablet / unfolded foldable: the phone layout, with the settings in a readable column */
@media (min-width: 600px) {
  #viewer.stacked #below, #viewer.stacked #panel { max-width: 720px; margin: 0 auto; }
}

/* Video on the left, title + settings in a column on the right (like YouTube on a tablet) */
#viewer.split { display: grid; overflow: hidden; grid-template-columns: minmax(0, 1fr) clamp(320px, 34vw, 440px);
  grid-template-rows: auto minmax(0, 1fr); }
#viewer.split #player { grid-column: 1; grid-row: 1 / 3; border-radius: 20px;
  margin: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#viewer.split #below { grid-column: 2; grid-row: 1; padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 4px 20px; }
#viewer.split .chips { margin: 14px -20px 0; padding: 0 20px 4px; }
#viewer.split #panel { grid-column: 2; grid-row: 2; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 max(20px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) 20px; }
#viewer.split .sheet-head { position: sticky; top: 0; z-index: 4; margin: 0 -20px; padding: 12px 20px 10px; background: var(--bg); }
#viewer.split #scrim { display: none; }
#viewer.split .ctl-title { visibility: hidden; }
#viewer.split #zoomTxt .max { display: none; }
#viewer.split .tabs button svg.i { display: none; }
