/*
 * design.css, loaded last.
 *
 * 1. ONE TYPE SYSTEM. Every font size in the dashboard is one of five variables (no pixel sizes
 *    anywhere else; tools/typesystem.py moved the old hard-coded ones onto them):
 *
 *                 desktop   phone
 *      --t-cap      12        14     captions, labels, chips, navigation
 *      --t-body     14        16     text, controls, numbers
 *      --t-strong   16        16     names and emphasised text (weight 600)
 *      --t-sec      20        20     section and dialog titles
 *      --t-title    28        24     page title
 *
 *    Desktop keeps the density it had: only text that was under 12 px moved (to 12).
 *    Hierarchy comes from weight and the two text colours, not from making things bigger.
 * 2. ONE SPACING SCALE: 4 / 8 / 12 / 16 / 24 / 32.
 * 3. Colours are the existing ones. Green only for Online/Live, red only for problems.
 * 4. Touch sizes (44 px) apply on phones only; desktop keeps its component sizes.
 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --t-cap: 12px;
  --t-body: 14px;
  --t-strong: 16px;
  --t-sec: 20px;
  --t-title: 28px;
  --lh-tight: 1.2;
  --lh-text: 1.5;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* The button blue is one shade deeper than before so white text on it passes AA. */
  --primary-btn: #2f6be0;
  --primary-btn-hover: #295fcb;
  --on-primary: #ffffff;
  --link: #8fb8ff;
  --danger-bg: #3b1515;
  --danger-line: #7d2c2c;
  --danger-text: #ffd6d6;
}
@media (max-width: 820px) {
  :root { --t-cap: 14px; --t-body: 16px; --t-title: 24px; }
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--t-body);
  line-height: var(--lh-text);
  font-variant-numeric: tabular-nums;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
a, .modal-body a, .main-content a:not(.btn) { color: var(--link); }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--border-focus) !important; outline-offset: 2px; }

.btn-primary, .btn-primary:visited { background: var(--primary-btn); border-color: transparent; color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-btn-hover); color: var(--on-primary); }
.btn { gap: var(--s2); }
.icon-only { padding-left: var(--s2); padding-right: var(--s2); }
.notif-badge { background: #c62828; color: #fff; }

/* ------------------------------------------------------------------ shell */
.topbar-context { display: flex; align-items: center; min-width: 0; flex: 1 1 0; overflow: hidden; }
.topbar-logo { display: none; }
.workspace-title { margin: 0; font-size: var(--t-body); font-weight: 600; line-height: var(--lh-tight); color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar { flex-wrap: nowrap; }
.app-topbar .nav-right { margin: 0 0 0 auto; padding: 0; border: 0; flex: 0 0 auto; }
#btn-open-pair > svg { display: none; }

.page-header { align-items: center; margin-bottom: var(--s4); }
.page-header h2, .detail-header h2 { font-size: var(--t-title); line-height: var(--lh-tight); font-weight: 650; margin: 0; }
.header-actions, .alerts-header-actions { display: flex; align-items: center; gap: var(--s2); }
#fleet-search-input { display: none; }
.many-phones #fleet-search-input { display: block; }

/* Notices: one line, one action. */
body > .demo-banner {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: var(--s3); min-height: 0;
  padding: var(--s1) var(--s4); font-size: var(--t-cap); background: var(--bg-card); color: var(--text-muted); border-bottom: 1px solid var(--border-light);
}
.demo-banner strong { color: var(--text-main); }
.demo-banner button { padding: var(--s1) var(--s2); border: 0; background: none; color: var(--link); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.boost-banner-inner { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.boost-banner-text { flex: 1 1 180px; display: flex; flex-direction: column; }
.boost-banner-text strong { font-size: var(--t-body); }
.boost-banner-text span { font-size: var(--t-cap); color: var(--text-muted); }
.pay-banner {
  display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4);
  background: var(--danger-bg); color: var(--danger-text); border-bottom: 1px solid var(--danger-line); font-size: var(--t-body);
}
.pay-banner strong { flex: 1; font-weight: 600; }
.pay-banner .btn { background: #fff; color: #2a0b0b; border: 0; }
.device-offline-banner {
  display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); margin-bottom: var(--s3);
  background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: var(--radius-sm); color: var(--danger-text); font-size: var(--t-body);
}

/* ------------------------------------------------------------------ home: cameras as picture cards */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.device-grid.single { grid-template-columns: minmax(0, 420px); }
.device-card.cam-card {
  display: block; padding: 0; overflow: hidden; cursor: default;
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
}
.cam-picture {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; margin: 0;
  border: 0; border-radius: 0; background: #06080c; color: #fff; overflow: hidden; cursor: pointer; font: inherit;
}
.cam-frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-noframe { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); }
.cam-frame ~ .cam-noframe { display: none; }
.cam-picture::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 40%; background: linear-gradient(to top, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0)); pointer-events: none; }
.cam-status.badge-status {
  position: absolute; top: var(--s2); left: var(--s2); z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  padding: 2px var(--s2); border: 0; border-radius: 999px; background: rgba(6, 8, 12, .78); color: #fff; font-size: var(--t-cap); font-weight: 600;
}
.cam-status .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.cam-status.badge-offline .status-dot { background: var(--danger) !important; }
.cam-status.badge-unstable .status-dot { background: var(--warning) !important; }
.cam-play {
  position: absolute; top: 50%; left: 50%; z-index: 2; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  display: grid; place-items: center; border-radius: 50%; background: rgba(6, 8, 12, .6); border: 1.5px solid rgba(255, 255, 255, .9);
}
.cam-play svg { width: 18px; height: 18px; fill: currentColor; }
.is-offline .cam-play svg { fill: none; }
.cam-picture:hover .cam-play { background: var(--primary-btn); border-color: var(--primary-btn); }
.cam-name.device-name {
  position: absolute; left: var(--s3); right: var(--s3); bottom: var(--s2); z-index: 2; text-align: left;
  font-size: var(--t-strong); font-weight: 600; line-height: var(--lh-tight); color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.is-offline .cam-frame { filter: grayscale(1) brightness(.45); }
.cam-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s3); min-height: 48px; }
.cam-controls { padding: 0 var(--s2); }
.cam-controls svg { width: 16px; height: 16px; }
.cam-hint { display: none; flex: 1; font-size: var(--t-body); color: var(--text-muted); }
.is-offline .cam-hint { display: block; }
.is-offline .cam-meta .gauges { display: none; }

/* Numbers are body size, semibold. Never bigger than the camera's name. */
.gauges { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-body); line-height: var(--lh-tight); }
.gauge { display: inline-flex; align-items: center; gap: 6px; color: var(--text-main); white-space: nowrap; }
.gauge b { font-weight: 600; }
.gauge svg { flex: none; color: var(--text-muted); width: 1.25em; height: 1.25em; }
.gauge svg.g-bat { width: 1.9em; height: 1em; }
.gauge .g-bat-fill { color: var(--text-main); }
.gauge .g-bolt { display: inline-flex; margin-left: -4px; }
.gauge .g-bolt svg { width: 1em; height: 1em; color: var(--primary); fill: var(--primary); }
.gauge[data-state="low"], .gauge[data-state="hot"], .gauge[data-state="loud"],
.gauge[data-state="low"] svg, .gauge[data-state="hot"] svg, .gauge[data-state="loud"] svg,
.gauge[data-state="low"] .g-bat-fill { color: var(--danger); }

.day-strip { padding: 0 var(--s3) var(--s3); }
.day-bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 20px; align-items: end; }
.day-bars i { display: block; height: 2px; border-radius: 1px; background: var(--border-light); }
.day-bars i.on { background: var(--primary); }
.day-bars i.on.bad { background: var(--danger); }
.day-axis { display: flex; justify-content: space-between; margin-top: var(--s1); font-size: var(--t-cap); line-height: var(--lh-tight); color: var(--text-muted); }

.cam-skeleton { border: 1px solid var(--border-light); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-card); }
.sk { background: var(--bg-card-muted); animation: sk-pulse 1.1s ease-in-out infinite alternate; }
.sk-picture { aspect-ratio: 16 / 9; }
.sk-line { height: 14px; width: 55%; margin: var(--s4) var(--s3); border-radius: 4px; }
@keyframes sk-pulse { from { opacity: .55; } to { opacity: 1; } }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; padding: var(--s6) var(--s4); grid-column: 1 / -1; }
.empty-state[style*="display: block"] { display: flex !important; }
.empty-state h3 { font-size: var(--t-sec); line-height: var(--lh-tight); font-weight: 600; margin: var(--s2) 0 0; }
.empty-state p { font-size: var(--t-body); color: var(--text-muted); margin: 0 0 var(--s2); max-width: 36ch; }
.empty-state p:empty { display: none; }
.empty-art { color: var(--text-dim); max-width: 100%; height: auto; }
.art-accent { stroke: var(--primary); }
.state-icon { color: var(--danger); display: inline-flex; }

.fleet-notifications, .plan-hint {
  display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s3);
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md);
}
.fleet-notifications > svg { color: var(--text-muted); flex: none; width: 16px; height: 16px; }
.fleet-notifications > strong, .plan-hint strong { flex: 1; font-size: var(--t-body); font-weight: 500; color: var(--text-muted); }
.plan-hint .plan-hint-lock { flex: 1; }
body.is-demo .fleet-notifications, .no-phones :is(.fleet-notifications, .plan-hint) { display: none !important; }

/* ------------------------------------------------------------------ phone screen: live picture */
.video-card.live-card { background: none; border: 0; border-radius: 0; overflow: visible; }
.live-card .video-viewport { height: auto; max-height: 70vh; aspect-ratio: 16 / 9; border-radius: var(--radius-md); overflow: hidden; background: #06080c; }
.live-card .video-viewport.is-portrait { aspect-ratio: 3 / 4; }
.live-card .video-viewport video { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; }
.live-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); }
.live-card .video-overlay { z-index: 2; background: rgba(0, 0, 0, .28); gap: var(--s3); padding: var(--s4); }
.live-play.btn { padding-left: var(--s5); padding-right: var(--s5); }
.live-card .video-overlay #video-status { font-size: var(--t-body); color: #fff; max-width: 40ch; }
.live-card .video-overlay #video-status:empty { display: none; }
.live-card .video-live-tag {
  z-index: 3; top: var(--s2); left: var(--s2); padding: 2px var(--s2) 2px 20px; border-radius: 999px;
  background: rgba(6, 8, 12, .78); color: #fff; font-size: var(--t-cap); font-weight: 600; text-transform: none; letter-spacing: 0;
}
.live-card .video-live-tag::before { content: ''; position: absolute; left: 8px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--success); }
.live-hd {
  position: absolute; z-index: 3; top: var(--s2); right: var(--s2); padding: 2px var(--s2); display: inline-flex; align-items: center; gap: var(--s1);
  border: 0; border-radius: 999px; background: rgba(6, 8, 12, .78); color: #fff; font: inherit; font-size: var(--t-cap); font-weight: 600; cursor: pointer;
}
.live-hd svg { width: 12px; height: 12px; }
/* Controls in a row under the picture: nothing covers what the camera sees. */
.live-bar { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) 0 0; }
.live-bar > button svg { width: 16px; height: 16px; }
.live-bar > button#btn-audio-stream-toggle[aria-pressed="false"] { color: var(--text-muted); }
.live-under { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s5); padding: var(--s3) 0 0; }
.live-under .toolbar-zoom-group { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.live-under .zoom-range { width: 140px; }
.live-under .zoom-label { font-size: var(--t-cap); color: var(--text-muted); min-width: 4ch; text-align: right; }
.live-more { margin-top: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--border-light); }
.live-more > summary { list-style: none; cursor: default; font-size: var(--t-cap); font-weight: 600; color: var(--text-muted); margin-bottom: var(--s2); }
.live-more > summary::-webkit-details-marker { display: none; }
.live-more-grid { display: flex; flex-wrap: wrap; gap: var(--s2); padding-bottom: var(--s2); }

/* ------------------------------------------------------------------ alerts: a timeline */
.alerts-list.timeline { display: block; background: none; border: 0; padding: 0; }
.tl-day { font-size: var(--t-cap); font-weight: 600; line-height: var(--lh-tight); color: var(--text-muted); margin: var(--s5) 0 var(--s1); }
.tl-day:first-of-type { margin-top: var(--s1); }
.alert-row.tl-item {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); width: 100%;
  margin: 0; padding: var(--s2) 0; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--border-light); border-radius: 0; box-shadow: none;
}
.alert-row.tl-item:hover { background: var(--bg-card); }
.tl-thumb { position: relative; display: grid; place-items: center; width: 96px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-sm); background: var(--bg-card-muted); color: var(--text-muted); }
.tl-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tl-icon { display: inline-grid; place-items: center; }
.tl-icon svg { width: 20px; height: 20px; }
.tl-thumb img + .tl-icon { position: absolute; left: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 4px; background: rgba(6, 8, 12, .78); color: #fff; }
.tl-thumb img + .tl-icon svg { width: 14px; height: 14px; }
.is-problem .tl-thumb { background: var(--danger-bg); color: var(--danger); }
.tl-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-item .alert-title { font-size: var(--t-body); font-weight: 600; line-height: var(--lh-tight); color: var(--text-main); }
.tl-meta { display: flex; flex-wrap: wrap; gap: 0 var(--s2); font-size: var(--t-cap); color: var(--text-muted); }
.tl-item .alert-device-badge, .tl-item .alert-time { padding: 0; border: 0; background: none; font: inherit; color: inherit; letter-spacing: 0; text-transform: none; }
.tl-go { color: var(--text-dim); display: inline-flex; padding-right: var(--s1); }
.tl-go svg { width: 16px; height: 16px; }
.pagination-bar.one-page :is(.btn-page-nav, .pagination-pages) { display: none; }
.pagination-controls { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.pagination-controls select { width: auto; }

/* ------------------------------------------------------------------ recordings */
.history-days { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.hd-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); flex: 0 1 420px; }
.hd-day { display: flex; align-items: center; justify-content: center; gap: var(--s1); min-height: 32px; border-radius: var(--radius-sm); font-size: var(--t-cap); font-weight: 600; background: var(--bg-card-muted); color: var(--text-main); border: 1px solid var(--primary); }
.hd-day.locked { border: 1px dashed var(--border-light); background: none; color: var(--text-dim); font-weight: 500; }
.hd-day svg { width: 12px; height: 12px; }
.clip-thumb { aspect-ratio: 16 / 9; height: auto; }
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.clip-title { font-size: var(--t-body); font-weight: 600; }
.clip-when { display: block; font-size: var(--t-cap); color: var(--text-muted); }

/* ------------------------------------------------------------------ dialogs */
.pair-steps { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: var(--s1); }
.pair-steps li { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: var(--s3); padding: var(--s1) 0; text-align: left; }
.pair-steps li > div { display: flex; flex-direction: column; align-items: flex-start; }
.pair-steps li > span { all: unset; }
.pair-steps strong { font-size: var(--t-body); font-weight: 600; line-height: var(--lh-tight); }
.pair-steps a { font-size: var(--t-body); font-weight: 600; }
.pair-n { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-right: var(--s1); border-radius: 50%; background: var(--primary-btn); color: var(--on-primary); font-size: var(--t-cap); font-weight: 700; }
.pair-pic { color: var(--text-dim); width: 40px; height: 40px; }
#modal-pair .qr-container { width: min(232px, 70vw); margin: 0 auto; padding: var(--s3); background: #fff; border-radius: var(--radius-md); }
#modal-pair .qr-container #qr-canvas { position: relative; }
#modal-pair .qr-container :is(img, canvas) { width: 100% !important; height: auto !important; display: block; }
.pair-or { margin: var(--s3) 0 0; font-size: var(--t-cap); color: var(--text-muted); }
.pairing-code { font-size: 32px; line-height: var(--lh-tight); font-weight: 700; letter-spacing: .16em; margin: 0; font-family: inherit; }
.pair-expires { margin: var(--s1) 0 0; font-size: var(--t-cap); color: var(--text-muted); }

.upgrade-visual { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #06080c; margin-bottom: var(--s3); }
.upgrade-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upgrade-visual .uv-soft { filter: blur(5px); transform: scale(1.04); }
.upgrade-visual .uv-sharp { clip-path: inset(0 0 0 50%); }
.upgrade-visual::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: #fff; }
.upgrade-visual span { position: absolute; bottom: var(--s2); z-index: 2; padding: 2px var(--s2); border-radius: 999px; background: rgba(6, 8, 12, .78); color: #fff; font-size: var(--t-cap); font-weight: 600; }
.upgrade-visual .uv-a { left: var(--s2); }
.upgrade-visual .uv-b { right: var(--s2); }
.upgrade-days { margin-bottom: var(--s3); }
.upgrade-actions { display: grid; gap: var(--s2); }
.upgrade-more > summary { cursor: pointer; font-weight: 600; font-size: var(--t-body); padding: var(--s2) 0; }
#usage-note:empty { display: none; }
#usage-note { color: var(--danger); }

/* ------------------------------------------------------------------ phones and small tablets */
@media (max-width: 820px) {
  /* Touch sizes. */
  .btn, .app-layout .btn-sm, .btn-sm, .btn-page-nav, .page-btn, .notif-link, .notif-foot,
  #tab-login, #tab-register, #btn-pw-toggle, .interval-picker .interval-opt { min-height: 44px; }
  .btn-page-nav, .page-btn, .icon-only, .cam-controls { min-width: 44px; }
  #btn-forgot-password, .pair-steps a { min-height: 44px; display: inline-flex; align-items: center; }
  .btn-close, .notif-btn, .account-btn, .boost-banner-close { width: 44px; height: 44px; min-width: 44px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea { min-height: 44px; }
  .demo-banner button { min-height: 44px; }

  /* One top bar: breadcrumb left, actions right. */
  .navbar { min-height: 0; padding: 0; border: 0; display: block; }
  .navbar .brand-link { display: none !important; }
  .app-topbar { position: sticky; top: 0; z-index: 850; min-height: 56px; padding: var(--s1) var(--s3) var(--s1) var(--s4); gap: var(--s3); }
  .main-content { padding: var(--s4) var(--s4) 96px; }
  .page-header { flex-direction: row; gap: var(--s3); }
  .page-header .header-actions { width: auto; flex: 0 0 auto; }
  .many-phones .page-header .header-actions { flex: 1 1 100%; }
  .alerts-header-actions { flex: 1 1 100%; width: 100%; flex-wrap: nowrap; }
  .alerts-header-actions select { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; }
  .alerts-header-actions .btn.icon-only, .header-actions .btn.icon-only { flex: 0 0 44px; width: 44px; }

  .device-grid, .device-grid.single { grid-template-columns: minmax(0, 1fr); }
  .cam-play { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
  .cam-play svg { width: 22px; height: 22px; }

  /* Phone tools: every tab visible in a grid, nothing cut off at the edge. */
  .studio-sidebar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s1); padding: 0 0 var(--s2); margin-bottom: 0; border-bottom: 0; overflow: visible; }
  .studio-sidebar .device-tab { width: 100%; min-width: 0; min-height: 40px; padding: 0 var(--s1); justify-content: center; overflow: hidden; text-overflow: ellipsis; }
  .studio-sidebar .device-tab > svg { display: none; }
  .studio-layout { gap: 0; }
  .studio-content { padding-top: 0 !important; margin-top: 0 !important; border-top: 0 !important; }

  /* The picture runs edge to edge; its controls are five equal buttons under it. */
  .live-card .video-viewport { margin: 0 calc(-1 * var(--s4)); width: auto; border-radius: 0; }
  .live-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); }
  .live-bar > button, .live-bar > button.btn { flex-direction: column; gap: 2px; min-height: 56px; padding: var(--s1); font-size: var(--t-cap); }
  .live-bar > button svg { width: 20px; height: 20px; }
  .live-under .toolbar-zoom-group { width: 100%; }
  .live-under .zoom-range { flex: 1 1 80px; width: auto; min-height: 44px; }

  .hd-day { flex-direction: column; min-height: 48px; gap: 0; }

  /* Dialogs use the whole width. */
  .modal-overlay { padding: 0 !important; align-items: flex-end !important; }
  .modal-card { width: 100% !important; max-width: none !important; max-height: 100dvh; margin: 0 !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; overflow-y: auto; }
  #modal-pair .modal-card { min-height: 100dvh; border-radius: 0 !important; }
  .pair-steps li { grid-template-columns: 48px minmax(0, 1fr); }
  .pair-pic { width: 48px; height: 48px; }
  #modal-pair .qr-container { width: min(264px, 72vw); }
  .pairing-code { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.download-compare > summary, .download-updates > summary { cursor: pointer; font-weight: 600; font-size: var(--t-body); }
.download-compare[open] > summary { margin-bottom: var(--s3); }
@media (max-width: 820px) {
  .studio-sidebar .device-tab { min-height: 44px; }
  .download-compare > summary, .download-updates > summary, .upgrade-more > summary { min-height: 44px; display: flex; align-items: center; }
}
.topbar-context { justify-content: flex-start; }
.detail-header h2 { font-size: var(--t-sec); }
.gauges { gap: var(--s1) var(--s3); }
@media (min-width: 821px) {
  /* Desktop: the picture keeps a fixed share of the screen so every control stays in view. */
  .live-card .video-viewport { aspect-ratio: auto; height: clamp(320px, 54vh, 620px); max-height: none; }
}
.topbar-context { flex-direction: column; align-items: flex-start; justify-content: center; }
.workspace-title { text-align: left; max-width: 100%; }
.app-topbar .topbar-context { flex: 1 1 0; width: 0; min-width: 0; }
.app-topbar .nav-right { flex: 0 0 auto; width: auto; }
@media (max-width: 820px) {
  .toolbar-zoom-group .btn { min-width: 44px; padding-left: var(--s1); padding-right: var(--s1); }
  .interval-picker .interval-opt { min-height: 44px !important; }
  /* The HD chip stays small to keep the picture clear; its tap area is extended around it. */
  .live-hd::before { content: ''; position: absolute; inset: -12px -6px -12px -10px; }
}
