:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161c25;
  --surface-raised: #1c2430;
  --surface-soft: #111720;
  --border: #2a3442;
  --text: #f4f7fb;
  --muted: #8e9bad;
  --accent: #f4f7fb;
  --accent-dark: #aeb8c5;
  --danger: #ff5a67;
  --warning: #e9b949;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.55rem, 3vw, 2.35rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 1.15rem; }
h3 { margin: 0; font-size: .92rem; }
.muted, small { color: var(--muted); }
.eyebrow { margin-bottom: 7px; color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .16em; }

.app-header {
  position: sticky; top: 0; z-index: 30; height: 66px; padding: 0 clamp(16px, 3vw, 42px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-bottom: 1px solid var(--border); background: rgba(13, 17, 23, .94); backdrop-filter: blur(14px);
}
.brand, .login-brand { display: inline-flex; align-items: center; font-weight: 800; letter-spacing: -.02em; }
.primary-nav { display: flex; align-items: center; gap: 7px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.primary-nav a { min-height: 34px; padding: 8px 16px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: var(--text); background: var(--surface-raised); }
.primary-nav a[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); }
.account { justify-self: end; display: flex; align-items: center; gap: 10px; font-size: .78rem; color: var(--muted); }
.account a:hover { color: var(--text); }
.role-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: rgba(244, 247, 251, .09); color: var(--accent); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
/* header account + settings dropdown */
.account-menu { justify-self: end; position: relative; }
.account-menu > summary { display: flex; align-items: center; gap: 8px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); cursor: pointer; list-style: none; font-size: .78rem; font-weight: 700; color: var(--muted); }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover { color: var(--text); }
.account-menu .account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu .gear { font-size: 1.02rem; line-height: 1; }
.account-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 264px; max-width: calc(100vw - 24px); padding: 14px; display: grid; gap: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-raised); box-shadow: 0 14px 44px rgba(0, 0, 0, .5); z-index: 40; }
.account-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.account-info strong { color: var(--text); font-size: .9rem; }
.menu-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--muted); }
.menu-field select { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.menu-note { color: var(--muted); font-size: .68rem; margin-top: -6px; }
.menu-logout { display: block; padding: 8px 10px; text-align: center; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-weight: 700; font-size: .8rem; }
.menu-logout:hover { border-color: var(--danger); color: var(--danger); }
@media (max-width: 640px) { .account-menu .account-name { display: none; } }
/* initial/home view toggle + click-to-edit routine row */
.list-btn.home { width: 30px; padding: 0; color: var(--muted); font-size: 15px; }
.list-btn.home.on { color: var(--accent); border-color: var(--accent); }
.editable-row { cursor: pointer; }
.editable-row .inline-name { cursor: text; }
.ptz-options { border-top: 0; padding-top: 2px; }

.app-main { width: min(1460px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 48px); flex: 1 1 auto; min-height: 0; }
.page-heading, .focus-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-heading p:last-child { margin-bottom: 0; }
.heading-actions { position: relative; display: flex; align-items: center; gap: 10px; }
.camera-count { padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .78rem; }

.camera-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 2vw, 22px); }
.camera-tile { overflow: hidden; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: transform .18s, border-color .18s, box-shadow .18s; cursor: pointer; }
.camera-tile:not(.empty-slot):hover, .camera-tile:not(.empty-slot):focus-visible { transform: translateY(-2px); border-color: #3a495b; box-shadow: 0 14px 40px rgba(0, 0, 0, .22); outline: none; }
.tile-preview { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #080b0f; }
.tile-preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; opacity: 0; transition: opacity .25s; }
.camera-tile.is-live iframe { opacity: 1; }
.preview-placeholder, .video-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--muted); text-align: center; background: radial-gradient(circle at 50% 35%, #1a222d, #0c1118 72%); }
.camera-tile.is-live .preview-placeholder { opacity: 0; pointer-events: none; }
.placeholder-icon { width: 46px; height: 32px; display: block; border: 2px solid #465366; border-radius: 8px; position: relative; opacity: .7; }
.placeholder-icon::after { content: ""; position: absolute; right: -10px; top: 8px; border-width: 7px 9px 7px 0; border-style: solid; border-color: transparent #465366 transparent transparent; transform: rotate(180deg); }
.status-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 27px; padding: 5px 9px; border: 1px solid rgba(142, 155, 173, .3); border-radius: 999px; background: rgba(13, 17, 23, .78); color: var(--muted); font-size: .67rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; backdrop-filter: blur(8px); }
.tile-preview > .status-badge { position: absolute; top: 12px; left: 12px; z-index: 2; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.recording, .status-badge.live { color: var(--accent); border-color: rgba(244, 247, 251, .35); }
.status-badge.offline { color: var(--danger); border-color: rgba(255, 90, 103, .35); }
.status-badge.stalled { color: var(--warning); border-color: rgba(233, 185, 73, .35); }
.tile-footer { min-height: 78px; padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tile-title-group { min-width: 0; display: grid; gap: 4px; }
.tile-title-group small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-name { max-width: 100%; padding: 0; overflow: hidden; border: 0; background: none; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-weight: 750; cursor: text; }
.rename-input { display: none; width: min(300px, 100%); padding: 7px 9px; border: 1px solid var(--accent); border-radius: 7px; background: var(--surface-soft); color: var(--text); outline: none; font-weight: 700; }
.camera-tile.is-renaming .camera-name { display: none; }
.camera-tile.is-renaming .rename-input { display: block; }
.icon-button { min-width: 42px; min-height: 42px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised); cursor: pointer; }
.icon-button:hover { border-color: var(--accent-dark); }
.info-button { min-width: 34px; min-height: 34px; border-radius: 50%; font-family: Georgia, serif; font-style: italic; }
.empty-slot { cursor: default; opacity: .58; }
.empty-slot .tile-footer > div { display: grid; gap: 4px; }

.primary-button, .secondary-button, .panel-toggle, .text-button { min-height: 42px; padding: 0 16px; border-radius: 10px; font-weight: 750; cursor: pointer; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #10151c; }
.primary-button:hover { background: #fff; }
.primary-button:disabled { border-color: var(--border); background: var(--surface-raised); color: #667386; cursor: not-allowed; }
.primary-button.compact { min-height: 36px; padding: 0 13px; font-size: .78rem; }
.secondary-button, .panel-toggle, .text-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.text-button.active { color: var(--accent); border-color: rgba(244, 247, 251, .4); }
.panel-toggle { display: none; }

.app-dialog { width: min(480px, calc(100vw - 28px)); padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 30px 90px #000a; }
.app-dialog::backdrop { background: rgba(2, 5, 9, .72); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.metadata-list { margin: 0; display: grid; }
.metadata-list div { padding: 13px 0; display: grid; grid-template-columns: 42% 1fr; gap: 12px; border-top: 1px solid var(--border); }
.metadata-list dt { color: var(--muted); font-size: .8rem; }
.metadata-list dd { margin: 0; text-align: right; font-size: .86rem; font-weight: 650; }

.focus-main { width: 100%; max-width: none; padding: 22px clamp(16px, 2.5vw, 36px) 18px; display: flex; flex-direction: column; }
.focus-heading { margin-bottom: 15px; align-items: center; }
.focus-heading h1 { font-size: clamp(1.35rem, 2.2vw, 1.9rem); }
.focus-actions { display: flex; align-items: center; gap: 9px; }
/* The layout fills the viewport and the video stage takes whatever vertical
   space is left, so collapsing the recordings panel hands that space to the
   video instead of leaving it empty. This replaces a fixed
   "max-height: calc(100vh - 470px)" reservation that assumed the panel was
   always expanded - it capped the video well below its natural height when
   collapsed, and still overflowed by ~25px when open. The media inside is
   object-fit: contain, so it stays correctly proportioned at any box size. */
.focus-layout { min-height: 0; flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) 310px; align-items: stretch; gap: 16px; }
.player-surface, .controls-panel, .table-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.player-surface { min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.controls-panel { align-self: start; }
.video-stage { position: relative; width: 100%; flex: 1 1 auto; min-height: 220px; background: #05070a; }
.video-stage iframe, .video-stage video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #05070a; }
#recorded-player { display: none; }
.history-hold-frame { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; object-fit: contain; background: #05070a; }
.history-hold-frame[hidden] { display: none; }
.video-empty { display: none; z-index: 3; }
.video-loading { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 9px; background: rgba(5, 7, 10, .68); color: var(--text); }
.video-loading[hidden] { display: none; }
.video-loading small { width: min(330px, 80vw); min-height: 1.2em; text-align: center; }
.loading-spinner { width: 34px; height: 34px; border: 3px solid #3b4655; border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stream-details { position: absolute; z-index: 4; right: 13px; top: 13px; padding: 5px 8px; border-radius: 6px; background: rgba(5, 8, 12, .74); color: #e9eef5; font-size: .67rem; font-weight: 750; letter-spacing: .06em; pointer-events: none; backdrop-filter: blur(6px); }
.player-volume, .quality-control { position: absolute; z-index: 4; bottom: 13px; min-height: 36px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 9px; background: rgba(5, 8, 12, .78); color: #e9eef5; backdrop-filter: blur(7px); }
.player-volume { left: 13px; width: min(190px, calc(100% - 150px)); padding: 4px 7px; display: grid; grid-template-columns: 30px minmax(75px, 1fr); align-items: center; gap: 7px; }
.player-volume.with-tuning { left: 55px; width: min(190px, calc(100% - 192px)); }
.audio-tuning-button { position: absolute; z-index: 5; left: 13px; bottom: 13px; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255, 255, 255, .15); border-radius: 9px; background: rgba(5, 8, 12, .78); color: #e9eef5; backdrop-filter: blur(7px); cursor: pointer; }
.audio-tuning-button:hover, .audio-tuning-button.active { border-color: rgba(255, 255, 255, .4); background: rgba(30, 39, 51, .92); }
.audio-tuning-button svg { width: 18px; height: 18px; fill: #e9eef5; stroke: #e9eef5; stroke-width: 1.5; stroke-linecap: round; }
.audio-tuning-popover { position: absolute; z-index: 8; left: 13px; bottom: 57px; width: min(340px, calc(100% - 26px)); max-height: min(460px, calc(100% - 70px)); padding: 14px; overflow-x: hidden; overflow-y: auto; border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; background: rgba(12, 17, 24, .96); color: #e9eef5; box-shadow: 0 16px 44px #000b; backdrop-filter: blur(12px); }
.audio-tuning-popover[hidden] { display: none; }
.audio-tuning-popover header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.audio-tuning-popover header strong { font-size: .9rem; }
.audio-tuning-popover header button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.audio-tuning-popover header button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.audio-mute { width: 30px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; font-size: .85rem; }
.audio-mute:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.audio-mute:disabled { cursor: default; opacity: .45; }
.player-volume input { min-width: 0; width: 100%; accent-color: var(--accent); cursor: pointer; }
.player-volume input:disabled { cursor: default; opacity: .45; }
.player-audio-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.quality-control { right: 13px; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.quality-control[hidden] { display: none; }
.quality-control button { min-width: 42px; min-height: 28px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: #aeb9c6; font-size: .69rem; font-weight: 800; cursor: pointer; }
.quality-control button.active { background: #e9eef5; color: #10151d; }
.transport-bar { min-height: 54px; padding: 7px 12px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.transport-button { border: 0; background: transparent; }
.speed-control { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; }
.speed-control[hidden] { display: none; }
.speed-control select, .timeline-bar input, .timeline-bar select, .clip-editor input, .stack-form input, .stack-form select { min-height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); color: var(--text); }
.playback-time { min-width: 0; text-align: right; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transport-right { margin-left: auto; display: flex; align-items: center; gap: 9px; min-width: 0; }
.transport-right .speed-control { margin-left: 0; }
.transport-actions { display: flex; align-items: center; gap: 5px; }
.transport-action { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); font-size: .78rem; font-weight: 700; cursor: pointer; }
.transport-action .ta-icon { font-size: .95rem; line-height: 1; }
.transport-action:hover:not(:disabled) { border-color: var(--accent); }
.transport-action:disabled { opacity: .45; cursor: default; }
.alarm-action.active { border-color: var(--danger); color: var(--danger); animation: alarm-pulse 1s ease-in-out infinite; }
.alarm-action .alarm-count { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .6rem; font-weight: 800; display: grid; place-items: center; }
.alarm-action .alarm-count:empty { display: none; }
@keyframes alarm-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); } 50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); } }
/* Pan & tilt status badge → movement-options dropdown */
.ptz-options-menu { position: relative; }
.ptz-options-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.ptz-options-menu > summary::-webkit-details-marker { display: none; }
.ptz-options-menu > summary::after { content: '▾'; font-size: .7rem; color: var(--muted); }
.ptz-options-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; max-width: calc(100vw - 24px); padding: 12px 14px; display: grid; gap: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-raised); box-shadow: 0 14px 44px rgba(0, 0, 0, .5); z-index: 20; }
.ptz-options-panel .menu-title { color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.ptz-options-panel .menu-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .8rem; color: var(--text); }
.ptz-options-panel select { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.ptz-options-panel .menu-range { display: flex; align-items: center; gap: 8px; }
.ptz-options-panel .menu-range input { width: 92px; }
.history-disabled .ptz-options-menu { display: none; }
.timeline-panel > summary { display: flex; align-items: center; gap: 9px; padding: 11px 16px; list-style: none; cursor: pointer; }
.timeline-panel > summary::-webkit-details-marker { display: none; }
.timeline-panel > summary::before { content: '▸'; color: var(--muted); font-size: .68rem; transition: transform .15s ease; }
.timeline-panel[open] > summary::before { transform: rotate(90deg); }
.timeline-panel > summary:hover .timeline-summary-title { color: var(--accent); }
.timeline-summary-title { color: var(--text); font-size: .92rem; font-weight: 700; }
/* Sits directly beside the title so it reads as that section's state rather
   than an unrelated value stranded at the far edge of the row. */
.timeline-summary-hint { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.timeline-summary-hint::before { content: '·'; margin-right: 6px; }
.timeline-body { padding: 2px 16px 13px; overflow: hidden; }
/* Date, navigation and clip actions share one lane. The date and zoom controls
   are self-describing, so their visible labels are dropped for the vertical
   space; both keep an aria-label. */
.timeline-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
/* Compact overrides: this lane sits under the video, so its controls are kept
   smaller than the app's default 40px form height. */
.timeline-bar input[type=date], .timeline-controls select { min-height: 30px; padding: 0 7px; font-size: .74rem; border-radius: 7px; }
.timeline-bar input[type=date] { width: 8.6rem; font-variant-numeric: tabular-nums; }
.timeline-bar input[type=date]::-webkit-calendar-picker-indicator { opacity: .4; cursor: pointer; }
.timeline-bar input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: .85; }
.timeline-controls { display: flex; align-items: center; gap: 5px; margin: 0 auto; }
.timeline-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.timeline-pan { min-width: 30px; min-height: 30px; border-radius: 7px; font-size: 1.1rem; }
.timeline-seek { min-width: 30px; min-height: 30px; border-radius: 7px; font-size: .85rem; letter-spacing: -.08em; }
/* A continuous ribbon: the old repeating gradient drew six fixed cells, which
   read as 4-hour chunks and implied boundaries the timeline no longer has. */
.timeline-track { position: relative; height: 39px; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.timeline-track:active { cursor: grabbing; }
.timeline-segments, .timeline-selection, .timeline-grid { position: absolute; inset: 0; }
.timeline-grid { pointer-events: none; }
.timeline-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: #202a36; }
.timeline-gridline.day-boundary { background: #344355; }
.timeline-segment { position: absolute; top: 7px; height: 25px; min-width: 0; padding: 0; border: 0; border-radius: 2px; background: var(--accent-dark); opacity: .92; cursor: pointer; }
.timeline-segment:hover { background: var(--accent); }
.timeline-selection { display: none; z-index: 3; border: 2px solid var(--accent); border-top: 0; border-bottom: 0; background: rgba(244, 247, 251, .15); pointer-events: none; }
.timeline-playhead { display: none; position: absolute; z-index: 4; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 8px #fff8; pointer-events: none; }
/* Ticks are absolutely positioned at their true time, not distributed evenly,
   so a label always sits at the moment it names. */
.timeline-scale { position: relative; height: 15px; margin-top: 5px; color: #667386; font-size: .62rem; font-variant-numeric: tabular-nums; }
.timeline-tick { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.timeline-tick::before { content: ''; position: absolute; bottom: 100%; left: 50%; width: 1px; height: 4px; background: var(--border); }
.timeline-tick.day-boundary { color: var(--muted); font-weight: 700; }
.timeline-tick.day-boundary::before { height: 7px; background: var(--accent-dark); }
.timeline-legend { min-height: 22px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .65rem; }
.timeline-legend > span { display: flex; align-items: center; gap: 5px; }
.timeline-legend i { width: 9px; height: 9px; border-radius: 2px; background: var(--accent-dark); }
.timeline-legend > span:nth-child(2) i { border: 1px solid var(--border); background: var(--surface-soft); }
#selection-label { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.timeline-legend strong { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.secondary-button.compact { min-height: 36px; padding: 0 13px; font-size: .78rem; }
/* Destructive actions live in a modal rather than in the toolbar, following the
   routine dialog. Only an unobtrusive trigger sits in the plain interface. */
.recording-options { min-width: 30px; min-height: 30px; border-radius: 7px; font-size: 1rem; letter-spacing: .05em; }
.recording-options:hover { border-color: var(--danger); color: var(--danger); }
.dialog-divider { margin: 4px 0 14px; border-top: 1px solid var(--border); }
.dialog-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 3px; border-radius: 10px; background: var(--surface-soft); }
.dialog-tab { flex: 1; min-height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 650; cursor: pointer; }
.dialog-tab:hover { color: var(--text); }
.dialog-tab.active { background: var(--surface-raised); color: var(--text); }
.checkbox-field { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; color: var(--muted); font-size: .76rem; }
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--danger); }
.starred-list { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }
.starred-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.starred-label { display: grid; gap: 2px; min-width: 0; }
.starred-label strong { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.starred-label span { color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
.starred-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.starred-actions .compact { min-height: 30px; padding: 0 9px; font-size: .72rem; display: inline-grid; place-items: center; }
.starred-empty { justify-content: center; color: var(--muted); font-size: .74rem; }
#delete-range-summary { font-weight: 650; font-variant-numeric: tabular-nums; }
#delete-all-confirm { letter-spacing: .06em; }
.danger-button { min-height: 34px; padding: 0 13px; border: 1px solid rgba(255, 90, 103, .45); border-radius: 9px; background: transparent; color: var(--danger); font-size: .76rem; font-weight: 600; cursor: pointer; }
.danger-button:hover:not(:disabled) { border-color: var(--danger); background: rgba(255, 90, 103, .12); }
.danger-button:disabled { opacity: .38; cursor: not-allowed; }
.danger-button.compact { min-height: 36px; padding: 0 13px; font-size: .78rem; }
.clip-editor { padding-top: 10px; display: flex; align-items: end; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--border); }
.clip-editor[hidden] { display: none; }
.clip-editor label { display: grid; gap: 4px; color: var(--muted); font-size: .67rem; font-weight: 700; }
.clip-editor input { min-height: 36px; }

.controls-panel { min-height: 0; max-height: calc(100vh - 205px); padding: 17px; overflow: auto; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 4px; }
.panel-close { display: none; }
.control-section { padding: 15px 0; border-top: 1px solid var(--border); }
.control-section:first-of-type { border-top: 0; }
.control-section > summary { position: relative; min-height: 30px; padding: 0 24px; display: flex; align-items: center; justify-content: center; gap: 9px; text-align: center; font-size: .86rem; font-weight: 750; cursor: pointer; list-style: none; }
.control-section > summary::-webkit-details-marker { display: none; }
.control-section > summary::after { content: "+"; position: absolute; right: 0; color: var(--muted); font-size: 1rem; }
.control-section[open] > summary::after { content: "−"; }
.control-section > summary .capability { margin-left: auto; }
.compact-section { padding: 10px 0; }
.control-note { margin: 10px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.history-disabled > summary { color: var(--muted); }
.history-disabled > summary::before { content: "History mode"; order: 2; color: var(--warning); font-size: .62rem; font-weight: 700; text-transform: uppercase; }
.history-disabled .ptz-grid { display: none; }
.history-disabled .section-heading .capability { display: none; }
.history-disabled .section-heading::after { content: "History mode"; color: var(--warning); font-size: .62rem; font-weight: 700; text-transform: uppercase; }
.record-toggle { cursor: pointer; }
.record-toggle:hover { background: var(--surface-raised); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.capability { color: var(--muted); font-size: .65rem; font-weight: 750; text-transform: uppercase; }
.capability.available { color: var(--accent); }
.capability.unavailable { color: var(--danger); }
.ptz-grid { width: 190px; margin: 12px auto 0; display: grid; grid-template-columns: repeat(3, 56px); grid-template-areas: ". up ." "left stop right" ". down ."; gap: 7px; justify-content: center; }
.ptz-grid button { width: 56px; height: 50px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-raised); font-size: 1.2rem; cursor: pointer; touch-action: manipulation; }
.ptz-grid button:hover, .ptz-grid button:active { border-color: var(--accent); color: var(--accent); }
.ptz-grid button:disabled { opacity: .38; cursor: not-allowed; }
.ptz-grid [data-ptz="up"] { grid-area: up; }.ptz-grid [data-ptz="left"] { grid-area: left; }.ptz-grid [data-ptz="stop"] { grid-area: stop; }.ptz-grid [data-ptz="right"] { grid-area: right; }.ptz-grid [data-ptz="down"] { grid-area: down; }
.ptz-grid button { touch-action: none; }
.ptz-tune { margin: 8px 0 4px; display: grid; gap: 8px; }
.ptz-tune label { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); font-weight: 650; }
.ptz-tune select { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.ptz-tune input[type=range] { flex: 1; min-width: 0; }
.ptz-tune-val { min-width: 52px; text-align: right; color: var(--text); }
.history-disabled .ptz-tune { display: none; }
.preset-save { margin-top: 10px; display: flex; gap: 7px; }
.preset-save input { flex: 1; min-width: 0; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.preset-save input:disabled { opacity: .5; }
.preset-save .secondary-button { white-space: nowrap; }
.preset-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.preset-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.preset-list .preset-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.preset-list .preset-go { padding: 5px 14px; border-radius: 7px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.preset-list .preset-go:disabled { opacity: .5; cursor: default; }
.preset-list .preset-delete { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.preset-list .preset-delete:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.preset-list .preset-delete:disabled { opacity: .5; cursor: default; }
.preset-list .preset-empty { justify-content: center; color: var(--muted); font-size: .85rem; }
.history-disabled .preset-save, .history-disabled .preset-list { display: none; }
/* Views & Routines: nested collapsibles */
.subsection { border-top: 1px solid var(--border); padding: 9px 0 3px; }
.subsection > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; cursor: pointer; list-style: none; font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.subsection > summary::-webkit-details-marker { display: none; }
.subsection > summary::after { content: '+'; color: var(--muted); font-weight: 700; }
.subsection[open] > summary::after { content: '−'; }
#schedule-sub { padding-left: 4px; }
.history-disabled .subsection, .history-disabled #routine-mode, .history-disabled #routine-new { pointer-events: none; opacity: .5; }
/* routine status + mode */
/* routines subsection title controls */
.sub-actions { display: flex; align-items: center; gap: 7px; }
#routines-sub > summary { justify-content: flex-start; }
#routines-sub > summary .sub-actions { margin-left: auto; }
.info-btn { width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 700; font-size: .72rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.info-btn:hover { color: var(--text); border-color: var(--accent); }
.routine-toggle { padding: 2px 11px; border-radius: 999px; border: 1px solid var(--border); background: transparent; font-size: .6rem; font-weight: 800; letter-spacing: .04em; cursor: pointer; color: var(--muted); }
.routine-toggle.on { color: var(--accent); border-color: var(--accent); }
.routine-toggle.scheduled { color: var(--warning); border-color: var(--warning); }
.add-routine { display: block; width: 100%; margin-top: 8px; padding: 5px; background: transparent; border: 1px dashed var(--border); border-radius: 9px; color: var(--muted); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.add-routine:hover { color: var(--accent); border-color: var(--accent); }
.routine-list, .schedule-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.routine-list li, .schedule-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.routine-list li.active { border-color: var(--accent); }
.routine-list .item-label, .schedule-list .item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routine-list .item-label { font-weight: 650; }
.list-btn { padding: 4px 10px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--text); font-weight: 700; font-size: .78rem; cursor: pointer; }
.list-btn.go, .list-btn.run { border-color: var(--accent); color: var(--accent); }
.list-btn.del { width: 28px; height: 28px; color: var(--muted); font-size: 16px; padding: 0; }
.list-btn.del:hover { color: var(--danger); border-color: var(--danger); }
.list-btn:disabled { opacity: .5; cursor: default; }
.preset-empty, .list-empty { justify-content: center; color: var(--muted); font-size: .85rem; }
/* schedule editor */
.schedule-add { display: grid; gap: 8px; margin-top: 6px; }
.schedule-add select, .schedule-times input { padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.schedule-times { display: flex; gap: 8px; }
.schedule-times label { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: .72rem; color: var(--muted); }
.schedule-days { display: flex; gap: 4px; flex-wrap: wrap; }
.schedule-days button { width: 34px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: .72rem; font-weight: 700; cursor: pointer; }
.schedule-days button.on { border-color: var(--accent); color: var(--accent); }
/* routine editor dialog */
.stack-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: .8rem; font-weight: 650; }
.stack-field input { padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.routine-steps { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.routine-steps li { display: flex; align-items: center; gap: 6px; }
.routine-steps .step-index { width: 20px; color: var(--muted); font-weight: 700; font-size: .8rem; }
.routine-steps select { flex: 1; min-width: 0; padding: 7px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.routine-steps .step-dwell { width: 68px; padding: 7px 6px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.routine-steps .step-btn { width: 28px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
/* inline rename (views + routines) */
.inline-name { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: text; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-rename-input { flex: 1; min-width: 0; padding: 4px 7px; border-radius: 6px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); font: inherit; }
.switch-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.switch-row span { display: grid; gap: 2px; }
.switch-row strong { font-size: .82rem; }
.switch-row small { font-size: .68rem; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 44px; height: 25px; padding: 3px; flex: 0 0 auto; border-radius: 999px; background: #3b4655; transition: background .18s; }
.switch-row i::after { content: ""; width: 19px; height: 19px; display: block; border-radius: 50%; background: white; transition: transform .18s; }
.switch-row input:checked + i { background: var(--accent-dark); }
.switch-row input:checked + i::after { transform: translateX(19px); }
.switch-row input:disabled + i { opacity: .4; }
.segmented-control { margin-top: 11px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 10px; background: var(--surface-soft); }
.segmented-control button { min-height: 38px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .73rem; font-weight: 700; cursor: pointer; }
.segmented-control button.active { background: var(--surface-raised); color: var(--accent); }
.segmented-control button:disabled { opacity: .55; cursor: default; }
.control-field { margin-top: 14px; }
.control-field.compact-field { margin-top: 7px; }
.control-field .field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .74rem; font-weight: 750; }
#ircut-modes { grid-template-columns: repeat(3, 1fr); }
.led-toggles { display: inline-flex; gap: 6px; }
.led-btn { min-height: 26px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .02em; cursor: pointer; }
.led-btn.on { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.led-btn:disabled { opacity: .5; cursor: default; }
.audio-tuning-readout { margin: 10px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.audio-level-row { min-height: 48px; margin-top: 8px; padding: 7px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--text); }
.audio-level-row > span { min-width: 0; }
.audio-level-row strong { display: flex; align-items: center; gap: 5px; font-size: .76rem; }
.audio-level-row small { display: block; margin-top: 2px; color: var(--muted); font-size: .65rem; }
.audio-level-row select { min-width: 92px; min-height: 34px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); color: var(--text); }
.audio-level-row select:disabled { opacity: .5; cursor: default; }
.audio-tuning-readout[hidden] { display: none; }
.audio-tuning-readout > span { min-width: 0; padding: 8px 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-size: .65rem; }
.audio-tuning-readout strong { display: block; margin-top: 3px; color: var(--text); font-size: .74rem; }
.audio-readout-label { display: flex; align-items: center; gap: 5px; }
.info-tip { position: relative; width: 15px; height: 15px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid #657184; border-radius: 50%; color: #b9c3cf; font-size: .58rem; font-style: normal; font-weight: 800; cursor: help; }
.info-tip::after { content: attr(data-tooltip); position: absolute; z-index: 12; left: 50%; bottom: calc(100% + 7px); width: min(220px, 70vw); padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #151c26; color: var(--text); box-shadow: 0 8px 24px #000a; font-size: .66rem; font-weight: 500; line-height: 1.35; opacity: 0; pointer-events: none; transform: translate(-50%, 4px); transition: .15s; }
.info-tip:hover::after, .info-tip:focus::after { opacity: 1; transform: translate(-50%, 0); }
.audio-tuning-readout > span:nth-child(odd) .info-tip::after { left: -10px; transform: translateY(4px); }
.audio-tuning-readout > span:nth-child(even) .info-tip::after { right: -10px; left: auto; transform: translateY(4px); }
.audio-tuning-readout > span .info-tip:hover::after, .audio-tuning-readout > span .info-tip:focus::after { transform: translateY(0); }
.audio-defaults { width: 100%; margin-top: 4px; }
.alarm-control { color: var(--muted); }
.alarm-control.active { color: var(--danger); border-color: rgba(255, 90, 103, .55); background: rgba(255, 90, 103, .08); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; max-width: calc(100vw - 32px); padding: 10px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-raised); box-shadow: 0 12px 40px #0008; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .2s; font-size: .8rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }

.table-card { overflow: hidden; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: 17px 20px; text-align: left; border-bottom: 1px solid var(--border); font-size: .82rem; }
.users-table th { color: var(--muted); background: var(--surface-soft); font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; }
.users-table tr:last-child td { border-bottom: 0; }
.status-dot { width: 7px; height: 7px; display: inline-block; margin-right: 8px; border-radius: 50%; background: var(--danger); }
.status-dot.active { background: var(--accent); }
.stack-form { display: grid; gap: 15px; }
.stack-form label { display: grid; gap: 7px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.stack-form input, .stack-form select { width: 100%; }
.stack-form small { font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; }
.camera-checklist, .camera-fieldset { display: grid; gap: 8px; }
.camera-checklist { margin: 18px 0; }
.camera-checklist label, .camera-fieldset label { min-height: 42px; padding: 9px 11px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); color: var(--text); cursor: pointer; }
.camera-checklist input, .camera-fieldset input { width: 18px; height: 18px; accent-color: var(--accent); }
.camera-fieldset { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.camera-fieldset legend { padding: 0 5px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.camera-fieldset.is-disabled { opacity: .55; }
.role-guide summary { min-height: 42px; padding: 0 14px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: .78rem; font-weight: 750; cursor: pointer; list-style: none; }
.role-guide summary::-webkit-details-marker { display: none; }
.role-guide > div { position: absolute; z-index: 15; top: calc(100% + 8px); right: 0; width: min(360px, calc(100vw - 30px)); padding: 15px; display: grid; grid-template-columns: 72px 1fr; gap: 9px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-raised); box-shadow: 0 18px 50px #0008; font-size: .75rem; }
.role-guide > div span { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 20%, #17232c, var(--bg) 55%); }
.login-shell { width: min(420px, 100%); }
.login-card { padding: clamp(25px, 7vw, 40px); border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: 0 25px 80px #0006; }
.login-brand { margin-bottom: 42px; font-size: 1.15rem; }
.login-card h1 { font-size: 2rem; }
.login-card .primary-button { margin-top: 8px; }
.form-error { padding: 10px 12px; border: 1px solid rgba(255, 90, 103, .4); border-radius: 8px; background: rgba(255, 90, 103, .08); color: #ff9ba3; font-size: .78rem; }

@media (max-width: 840px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .app-header { height: 58px; grid-template-columns: 1fr auto; padding: 0 16px; backdrop-filter: none; }
  .account > span { display: none; }
  .primary-nav { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; height: calc(62px + env(safe-area-inset-bottom)); padding: 6px 10px env(safe-area-inset-bottom); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: rgba(13, 17, 23, .97); }
  .primary-nav a { min-height: 48px; }
  /* The nav is fixed to the bottom here, so the page must reserve its height or
     the last controls in the panel sit underneath it and cannot be reached. */
  .app-main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .app-main { padding: 22px 15px; }
  .camera-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: center; }
  .focus-main { padding: 12px 10px; }
  .focus-heading { margin-bottom: 10px; }
  .focus-heading .eyebrow { display: none; }
  .focus-actions .secondary-button { padding: 0 11px; }
  .panel-toggle { display: inline-flex; align-items: center; }
  .focus-layout { display: block; }
  .video-stage { flex: 0 0 auto; min-height: 0; max-height: none; aspect-ratio: 16/9; }
  .controls-panel { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(340px, 92vw); max-height: none; padding: calc(18px + env(safe-area-inset-top)) 18px calc(72px + env(safe-area-inset-bottom)); border-radius: 16px 0 0 16px; transform: translateX(105%); transition: transform .22s ease; box-shadow: -20px 0 60px #0009; }
  .controls-panel.open { transform: translateX(0); }
  .panel-close { display: inline-grid; }
  .transport-bar { gap: 5px; }
  .transport-bar .text-button { padding: 0 10px; }
  .playback-time { min-width: 0; flex: 1; font-size: .68rem; }
  .timeline-panel > summary { padding: 10px 11px; }
  .timeline-body { padding: 2px 11px 12px; }
  .timeline-bar { flex-wrap: wrap; }
  .timeline-track { height: 40px; }
}

@media (max-width: 560px) {
  .brand span:last-child { display: none; }
  .account { gap: 6px; }
  .page-heading { margin-bottom: 18px; }
  .page-heading .camera-count { display: none; }
  .camera-grid { gap: 12px; }
  .tile-footer { min-height: 68px; padding: 12px 13px; }
  .focus-actions { gap: 6px; }
  .focus-actions .status-badge { display: none; }
  .focus-heading h1 { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .transport-bar { min-height: 48px; padding: 4px 6px; }
  .player-volume { width: min(175px, calc(100% - 125px)); grid-template-columns: 30px minmax(60px, 1fr); }
  .player-volume.with-tuning { width: min(175px, calc(100% - 167px)); }
  .audio-tuning-popover { position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto; max-height: calc(100dvh - 100px); }
  .transport-button { min-width: 38px; min-height: 38px; }
  .speed-control { margin-left: 0; }
  .speed-control > span, .speed-control { font-size: 0; gap: 0; }
  .speed-control select { min-height: 38px; font-size: .72rem; }
  .timeline-bar input[type=date] { width: 118px; }
  .timeline-controls { margin: 0; }
  .timeline-controls select { width: 96px; padding: 0 6px; }
  /* Swatches are decorative once the track is a plain ribbon; dropping them
     stops the status text wrapping onto its own line on a phone. */
  .timeline-legend > span:nth-child(1), .timeline-legend > span:nth-child(2) { display: none; }
  .timeline-legend strong { display: none; }
  .dialog-tab { font-size: .74rem; padding: 0 6px; }
  .starred-list li { flex-wrap: wrap; }
  .starred-actions { width: 100%; }
  .timeline-actions { margin-left: auto; }
  .clip-editor { display: grid; grid-template-columns: 1fr 1fr auto; }
  .clip-editor input { min-width: 0; width: 100%; }
  .heading-actions { gap: 7px; }
  .role-guide summary { padding: 0 10px; }
  .users-table thead { display: none; }
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; }
  .users-table tr { padding: 12px 15px; border-bottom: 1px solid var(--border); }
  .users-table tr:last-child { border-bottom: 0; }
  .users-table td { padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; border: 0; text-align: right; }
  .users-table td::before { content: attr(data-label); color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
  .app-dialog { padding: 19px; }
}

@media (max-height: 760px) and (min-width: 841px) {
  .app-header { height: 58px; }
  .focus-main { padding-top: 13px; }
  .focus-heading { margin-bottom: 10px; }
  .video-stage { max-height: calc(100vh - 380px); }
  .timeline-panel { padding-top: 9px; padding-bottom: 10px; }
  .timeline-track { height: 40px; }
  .timeline-segment { top: 10px; }
  .control-section { padding: 10px 0; }
  .ptz-grid { margin-top: 7px; grid-template-columns: repeat(3, 47px); }
  .ptz-grid button { width: 47px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
