/* Nokada - shared component styles (raw values matching tailwind-config.js; the Play CDN
   does not process @apply in external sheets). Follows the HR OS template look. */
html, body { height: 100%; }
/* App shell height: dvh = the visible viewport on mobile (100vh hides the bottom bar under Safari's
   toolbar); identical to 100vh on desktop. */
.nk-app { height: 100vh; height: 100dvh; }
body {
  margin: 0; color: #1A1816; background: #F7F5F0;
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
input, button, select, textarea { font-family: inherit; }
[x-cloak] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }

body.page-canvas {
  background-image: radial-gradient(rgba(122,118,111,0.13) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.page-card {
  background: #fff; border: 1px solid #E8E3D9; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(28,24,18,0.04), 0 12px 32px -20px rgba(28,24,18,0.10);
}
.page-title-icon {
  width: 34px; height: 34px; border-radius: 9px; background: #fff; border: 1px solid #E8E3D9;
  display: inline-flex; align-items: center; justify-content: center; color: #3A3833; flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(28,24,18,0.05);
}

/* ---- sidebar ---- */
.nk-side {
  width: 212px; flex-shrink: 0; height: 100vh; height: 100dvh; background: #fff; border-right: 1px solid #EDEAE3;
  display: flex; flex-direction: column; transition: width .15s ease;
}
.nk-side.is-rail { width: 58px; }
.nk-side.is-rail .nk-hide-rail { display: none; }
/* top-right signed-in user */
.nk-avatar { width: 30px; height: 30px; border-radius: 999px; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--nk-avatar-bg, #ECE8DF); color: #3A372F; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.nk-avatar.hidden { display: none; }
.nk-avatar:hover, .nk-avatar[aria-expanded="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #DDD8CE; }
.nk-user-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; max-width: 280px; background: #fff;
  border: 1px solid #E6E1D7; border-radius: 10px; box-shadow: 0 8px 24px rgba(30,26,18,.12); z-index: 60; overflow: hidden; }
.nk-user-menu.hidden { display: none; }
.nk-user-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 0; background: none;
  font-size: 13px; color: #3A372F; cursor: pointer; text-align: left; }
.nk-user-item:hover { background: #F6F3EC; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: #3A3833; text-decoration: none; white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: #F4F1EA; }
.nav-link.is-active { background: #F4F1EA; color: #1A1816; font-weight: 600; }
.nav-link .nav-icon { color: #6B6862; display: inline-flex; flex-shrink: 0; }
.nav-link.is-active .nav-icon { color: #DC2626; }
.nav-section-label {
  padding: 16px 12px 5px; font-size: 10.5px; font-weight: 600; color: #9A968F;
  letter-spacing: 0.08em; text-transform: uppercase; user-select: none;
}

/* ---- buttons, inputs, chips ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 7px; border: 1px solid #E7E2D8; background: #fff;
  font-size: 12.5px; font-weight: 500; color: #1A1816; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #F4F1EA; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-accent { background: #DC2626; border-color: #DC2626; color: #fff; }
.btn-accent:hover { background: #B91C1C; border-color: #B91C1C; }
.btn-ink { background: #1A1816; border-color: #1A1816; color: #fff; }
.btn-ink:hover { background: #3A3833; }
.btn-icon { width: 30px; padding: 0; }
.seg { display: inline-flex; border: 1px solid #E7E2D8; border-radius: 7px; overflow: hidden; background: #fff; }
.seg > button {
  height: 28px; min-width: 32px; padding: 0 9px; border: 0; background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 500; color: #3A3833; border-right: 1px solid #F1EEE7;
}
.seg > button:last-child { border-right: 0; }
.seg > button:hover { background: #F4F1EA; }
.seg > button.is-on { background: #1A1816; color: #fff; }
.input {
  height: 32px; padding: 0 10px; border: 1px solid #E7E2D8; border-radius: 7px; background: #fff;
  font-size: 12.5px; color: #1A1816; outline: none; min-width: 0;
}
.input:focus { border-color: #1A1816; box-shadow: 0 0 0 3px rgba(28,24,18,0.06); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid #E7E2D8; background: #fff; font-size: 11.5px; font-weight: 500; color: #3A3833;
  cursor: pointer; user-select: none;
}
.chip:hover { background: #F4F1EA; }
.chip.is-on { background: #1A1816; border-color: #1A1816; color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.pill-ok { background: #E7F3EC; color: #0F7A3C; }
.pill-warn { background: #FFF3DA; color: #8A5A00; }
.pill-bad { background: #FBE1E1; color: #A02323; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-ok { background: #1F9D55; } .dot-bad { background: #D33A3A; } .dot-warn { background: #D89B14; }
.sev-alert { background: #DC2626; } .sev-detection { background: #D89B14; }

/* ---- video tiles ---- */
.stage { background: #151412; }
.tile { position: relative; background: #000; overflow: hidden; contain: strict; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile video.pv { visibility: hidden; }
.tile.show-pv video.pv.front { visibility: visible; }   /* two preview elements, the back one loads the next hour */
.tile img.pf { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; background: #000; }
.tile.show-pv.show-pf img.pf { visibility: visible; }
.tile .t-label, .tile .t-time {
  position: absolute; top: 6px; padding: 2px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 500;
  color: #fff; background: rgba(0,0,0,0.55); pointer-events: none; white-space: nowrap;
}
.tile .t-label { left: 6px; }
.tile .t-time { right: 6px; font-variant-numeric: tabular-nums; }
.tile .t-badge { position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; color: #fff; background: rgba(220,38,38,0.85); padding: 1px 6px; border-radius: 4px; pointer-events: none; display: none; }
.tile.show-pv .t-badge { display: block; background: rgba(26,24,22,0.8); }
.tile .t-msg {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  padding: 16px; font-size: 13px; color: #EDEAE3; pointer-events: none;
  background: repeating-linear-gradient(135deg, #1d1c1a 0 10px, #24221f 10px 20px);
}
.tile.has-msg .t-msg { display: flex; }
.tile .t-spin {
  position: absolute; right: 8px; bottom: 8px; width: 16px; height: 16px; border-radius: 50%; display: none;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; animation: nkspin .8s linear infinite;
}
.tile.is-loading .t-spin { display: block; }
.tile.is-focus { outline: 2px solid #DC2626; outline-offset: -2px; }
@keyframes nkspin { to { transform: rotate(360deg); } }

/* ---- timeline ---- */
.tl-wrap { position: relative; user-select: none; touch-action: none; }
.tl-wrap canvas { display: block; width: 100%; }
.tl-tip {
  position: absolute; pointer-events: none; z-index: 5; background: #1A1816; color: #fff; font-size: 11px;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -100%); display: none;
}

/* ---- thumbnails ---- */
.nk-sim-btn { height: 26px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: #B91C1C; font-size: 12px; font-weight: 500; cursor: pointer; }
.nk-sim-btn:hover { background: #FBE1E1; }
.thumb { aspect-ratio: 16/9; background: #EDEAE3; object-fit: cover; width: 100%; display: block; }
.ev-row { display: flex; gap: 10px; padding: 6px; border-radius: 8px; cursor: pointer; content-visibility: auto; contain-intrinsic-size: 64px; }
.ev-row:hover { background: #F4F1EA; }
.ev-row.is-cur { background: #FBE1E1; }

/* ---- perf overlay ---- */
#nk-perf {
  position: fixed; right: 10px; top: 100px; z-index: 60; width: 340px; max-height: 60vh; overflow: hidden; pointer-events: none; opacity: .92;
  background: rgba(26,24,22,0.92); color: #EDEAE3; font: 11px/1.45 "Geist Mono", Consolas, monospace;
  border-radius: 10px; padding: 9px 11px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
#nk-perf table { width: 100%; border-collapse: collapse; }
#nk-perf td, #nk-perf th { padding: 1px 4px; text-align: right; white-space: nowrap; }
#nk-perf td:first-child, #nk-perf th:first-child { text-align: left; }
#nk-perf th { color: #9A968F; font-weight: 500; }
#nk-perf .ok { color: #6EE7A1; } #nk-perf .bad { color: #FCA5A5; }
#nk-perf .perf-min { display: none; }

/* ---- storage page (storage.html) ---- */
.st-summary { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.st-figs { min-width: 420px; }
.st-bar { position: relative; height: 14px; border-radius: 7px; background: #EDEAE3; overflow: visible; }
.st-bar-used { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: #3A3833; min-width: 2px; }
.st-bar-proj { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; border-radius: 2px; background: #DC2626; }
.st-bar-proj.is-over { left: auto !important; right: -2px; box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
.st-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.st-key-used { background: #3A3833; } .st-key-proj { background: #DC2626; width: 3px; }
.st-day { background: #FBFAF7; border: 1px solid #F1EEE7; border-radius: 7px; padding: 4px 2px 3px; text-align: center; }
.st-day.is-dim { opacity: .5; }
.st-table th { font-size: 11px; font-weight: 600; color: #7A766F; text-transform: uppercase; letter-spacing: .04em; padding: 9px 10px; border-bottom: 1px solid #EDEAE3; white-space: nowrap; }
.st-table td { padding: 7px 10px; border-bottom: 1px solid #F4F1EA; vertical-align: middle; }
.st-table tbody tr:hover { background: #FBFAF7; }
.st-table tr.is-sel { background: #FBFAF7; }
.st-table tr.is-changed td:first-child { box-shadow: inset 3px 0 0 #D89B14; }
.st-table tfoot td { border-bottom: 0; border-top: 1px solid #EDEAE3; padding-top: 10px; padding-bottom: 10px; }
.st-prof-sel { min-width: 170px; }
.st-pill-off { background: #F1EEE7; color: #6B6862; }
.st-cards .is-changed { box-shadow: inset 3px 0 0 #D89B14, 0 1px 2px rgba(28,24,18,0.04); }
.st-draft { position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; padding: 0 16px 14px; pointer-events: none; }
.st-draft-in {
  max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px;
  background: #fff; border: 1px solid #E8E3D9; border-radius: 12px; pointer-events: auto;
  box-shadow: 0 12px 32px -8px rgba(28,24,18,.28);
}
.st-modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.st-modal-bg { position: absolute; inset: 0; background: rgba(26,24,22,.38); }
.st-modal-box { position: relative; width: 100%; max-width: 620px; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px 20px; }
.st-field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; font-weight: 500; color: #7A766F; min-width: 0; }
.st-field .input { width: 100%; }
.st-warn { background: #FBE1E1; color: #A02323; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }

/* ---- phones / small tablets ("compact") ------------------------------------------------------
   Everything below applies only at (max-width: 767px) or to short touch screens (phone landscape).
   Keep this query in sync with nk.COMPACT_Q in app.js. Desktop (>= 768 px, or any mouse window
   taller than 520 px) never matches, so nothing here changes the desktop layout. */
.nk-mob-only { display: none !important; }
.nk-menu-btn {
  width: 40px; height: 40px; margin-left: -8px; border: 0; background: transparent; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; color: #3A3833; cursor: pointer;
}
#nk-scrim { display: none; }
.nk-check { display: inline-flex; flex-shrink: 0; }
.mc-rate-cycle { display: none !important; }
.nk-ov { display: none; }
@media (max-width: 767px), (max-height: 520px) and (pointer: coarse) {
  .nk-mob-only { display: revert !important; }
  .nk-mob-only.flex, .nk-mob-only.inline-flex { display: flex !important; }
  .nk-desk-only { display: none !important; }
  body { -webkit-text-size-adjust: 100%; }

  /* sidebar -> off-canvas drawer, opened from the topbar menu button */
  .nk-side, .nk-side.is-rail {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80; width: 248px; height: 100dvh;
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 32px rgba(0,0,0,.18);
    padding-left: env(safe-area-inset-left);
  }
  .nk-side.is-open { transform: none; }
  .nk-side.is-rail .nk-hide-rail { display: revert; }
  .nk-side [data-act="rail"] { display: none; }
  .nk-side .nav-link { padding: 11px 12px; font-size: 14px; }
  #nk-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(26,24,22,.35); }
  #nk-scrim.is-open { display: block; }
  #nk-top { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  body[data-compact-top="0"] #nk-top { display: none !important; }

  /* tap targets >= 40 px; 16 px inputs stop iOS zooming on focus */
  .btn { height: 40px; padding: 0 13px; font-size: 13px; }
  .btn-icon { width: 40px; padding: 0; }
  .seg > button { height: 38px; min-width: 40px; font-size: 12.5px; }
  .chip { height: 32px; padding: 0 12px; font-size: 12.5px; }
  .input { height: 40px; font-size: 16px; }
  input.input, select.input { font-size: 16px !important; }
  .nk-filters .nk-search-btn { height: 40px !important; flex: 1 1 100%; }
  .nk-check { display: inline-flex; padding: 10px; margin: -10px; }
  .nk-check input { width: 20px; height: 20px; }

  /* video: no double-tap zoom on the stage (we use double-tap = focus) */
  .stage { touch-action: manipulation; }
  .tile .t-label, .tile .t-time { font-size: 11px; padding: 1px 6px; top: 4px; }
  .tile .t-label { left: 4px; } .tile .t-time { right: 4px; }
  .tile { container-type: inline-size; }
  .tile .t-msg { font-size: 12px; padding: 8px; }

  /* transport overlay over the video (camera + multicam; nk.mobOverlay positions + hides it) */
  .nk-ov {
    display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; justify-content: center;
    padding: 8px 8px; pointer-events: none; transition: opacity .2s ease;
  }
  .nk-ov.is-hidden { opacity: 0; }
  .nk-ov.is-docked .nk-ov-pill { box-shadow: none; background: rgba(255,255,255,.08); }
  .is-crop .tile video, .is-crop .tile img.pf { object-fit: cover; }
  .nk-ov-pill {
    display: flex; align-items: center; gap: 2px; padding: 3px 5px; border-radius: 999px; pointer-events: auto;
    background: rgba(18,17,15,.66); box-shadow: 0 2px 12px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.10);
  }
  .nk-ov.is-hidden .nk-ov-pill { pointer-events: none; }
  .nk-ov-btn {
    width: 42px; height: 42px; flex-shrink: 0; border: 0; border-radius: 999px; background: transparent; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
    -webkit-tap-highlight-color: transparent; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5));
  }
  .nk-ov-btn:active { background: rgba(255,255,255,.18); }
  .nk-ov-play { width: 48px; height: 48px; background: rgba(255,255,255,.16); }
  .nk-ov-rate { font-size: 14px; font-weight: 600; width: 44px; }
  .nk-ov-more svg { transition: transform .18s ease; }
  .nk-ov-more.is-open svg { transform: rotate(180deg); }
  .nk-ov-more.is-open { background: rgba(255,255,255,.16); }

  /* multicam: the toolbar becomes the "more" sheet - collapsed by default, opened from the overlay's arrow,
     it floats over the bottom of the timeline so the stage never moves or resizes. Transport + speed live
     in the overlay. !important: Tailwind's utilities are injected after this sheet and would win. */
  .mc-main { position: relative; }
  .mc-tl { padding-bottom: env(safe-area-inset-bottom); }
  .mc-bar { display: none !important; }
  .mc-bar.is-open {
    display: flex !important; position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
    justify-content: center; gap: 6px !important; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)) !important;
    border-bottom-width: 0 !important; border-top: 1px solid #EDEAE3; box-shadow: 0 -8px 24px rgba(28,24,18,.16);
  }
  .mc-bar .mc-sp, .mc-bar .mc-transport, .mc-bar .mc-rate, .mc-bar .mc-rate-cycle { display: none !important; }
  .mc-bar .mc-clock { min-width: 0 !important; padding: 0 4px !important; }
  .mc-bar .mc-picker-panel {
    position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto;
    max-height: 65dvh; overflow-y: auto; z-index: 90;
  }
  .mc-bar .mc-picker-panel label { padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
  .mc-bar .mc-picker-panel input { width: 18px; height: 18px; }
  .mc-bar .mc-picker-panel button { padding: 10px 6px; font-size: 13px; }
  .mc-legend { display: none !important; }

  /* camera page: one scrolling column; the player block (video + timeline + the "more" panel when open) is
     sticky at the top of the scroller (.cam-body, below the topbar) while the review list scrolls under it */
  .cam-body { flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .cam-body > section { flex: none !important; position: sticky; top: 0; z-index: 20; background: #fff; box-shadow: 0 6px 14px -10px rgba(28,24,18,.35); }
  .cam-body .cam-bar { order: 3; justify-content: center; border-bottom-width: 0 !important; border-top: 1px solid #EDEAE3; }
  .cam-body .cam-bar:not(.is-open) { display: none !important; }
  .cam-body .cam-bar .cam-transport, .cam-body .cam-bar .cam-rate { display: none !important; }
  .cam-body .cam-bar .cam-sp { display: none; }
  .cam-body .cam-bar .cam-title { order: -1; width: 100%; justify-content: center; margin-right: 0 !important; }
  .cam-body .cam-bar .cam-clock { min-width: 0 !important; }
  .cam-body .stage { flex: none !important; height: min(56.25vw, 62dvh); }
  .cam-body .cam-tl { order: 2; }
  .cam-body > aside { width: 100% !important; border-left-width: 0 !important; border-top: 1px solid #EDEAE3; flex: none !important; }
  .cam-body > aside .cam-list { overflow: visible !important; flex: none !important; }
  .ev-row { padding: 8px 6px; }
  /* camera page review list: 2-column thumbnail grid, label + time over the image */
  /* camera page: review filters collapse behind the "Review items" row */
  .rv-head { padding-top: 6px !important; padding-bottom: 6px !important; }
  .rv-head .rv-filters { display: none; padding-top: 8px; }
  .rv-head.is-open .rv-filters { display: block; }
  .rv-head .rv-filters > div:first-child > div:first-child { display: none; }
  .rv-toggle { width: 100%; align-items: center; gap: 10px; min-height: 40px; text-align: left; }
  .rv-toggle .rv-sum { flex: 1; min-width: 0; font-size: 12.5px; color: #6B675F; }
  .rv-toggle .rv-chev { flex-shrink: 0; transition: transform .15s ease; color: #3A3833; }
  .rv-head.is-open .rv-chev { transform: rotate(180deg); }
  .cam-list { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
  .cam-list > [x-ref="sentinel"] { grid-column: 1 / -1; }
  .cam-list .ev-row { position: relative; display: block; padding: 0; border-radius: 10px; overflow: hidden; contain-intrinsic-size: 110px; }
  .cam-list .ev-row .ev-thumb { width: 100% !important; border-radius: 10px; }
  .cam-list .ev-row .ev-thumb > span { width: 4px !important; }
  .cam-list .ev-row .ev-meta {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 5px 10px !important;
    background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,.45) 60%, rgba(0,0,0,0));
    color: #fff; pointer-events: none;
  }
  .cam-list .ev-row .ev-meta > div { color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
  .cam-list .ev-row .ev-meta > div:first-child { font-size: 13px; line-height: 1.2; }
  .cam-list .ev-row .ev-meta > div:nth-child(2) { font-size: 11px; line-height: 1.25; opacity: .95; }
  .cam-list .ev-row .ev-meta > div:nth-child(3) { font-size: 10px; margin-top: 0; opacity: .85; }
  .cam-list .ev-row.is-cur { outline: 3px solid #E5484D; outline-offset: -3px; background: none; }
  .cam-body aside .seg > button { height: 36px !important; font-size: 12px !important; }

  /* storage: summary stacks, table -> card list (storage.html), draft bar + dialogs edge to edge */
  .st-summary { grid-template-columns: minmax(0, 1fr) !important; }
  .st-figs { min-width: 0 !important; }
  .st-figs .text-xl { font-size: 16px !important; }
  .st-bulk { width: 100%; flex-wrap: wrap; }
  .st-bulk select { flex: 1 1 140px; }
  .st-draft { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .st-draft-in { flex-wrap: wrap; padding: 10px 12px; }
  .st-draft-in > div:first-child { flex: 1 1 100%; }
  .st-draft-in .btn { flex: 1 1 0; }
  .st-modal { align-items: flex-end; padding: 0; }
  .st-modal-box { max-width: none; border-radius: 14px 14px 0 0 !important; max-height: 88dvh; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }

  /* search: filters collapse behind a toggle */
  .nk-filters { display: none !important; }
  .nk-filters.is-open { display: grid !important; }
  .nk-filters .input[type="datetime-local"] { flex: 1 1 200px; min-width: 0; }
  .nk-sim-btn { height: 34px; padding: 0 10px; font-size: 13px; }

  /* perf overlay: small, top (over the video, never over the controls dock), tap to expand/collapse */
  #nk-perf {
    left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top)); bottom: auto; width: auto;
    max-height: 40dvh; overflow: auto; pointer-events: auto; font-size: 10px;
  }
  #nk-perf.is-min { left: auto; width: auto; max-height: none; padding: 5px 10px; }
  #nk-perf.is-min .perf-body, #nk-perf.is-min .perf-head { display: none !important; }
  #nk-perf.is-min .perf-min { display: block; white-space: nowrap; }
}
/* tiny tiles (phone 3x3): keep the camera name, drop the per-tile clock (the dock shows it) */
@container (max-width: 170px) {
  .tile .t-time { display: none; }
  .tile .t-label { font-size: 10px; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; }
}
/* phone landscape: every pixel of height goes to video */
@media (max-height: 520px) and (pointer: coarse) {
  /* overlay: one compact row */
  .nk-ov { padding: 5px 8px; }
  .nk-ov-btn { width: 40px; height: 40px; }
  .nk-ov-play { width: 44px; height: 44px; }
  /* multicam "more" sheet: one row (scrolls sideways if needed) */
  .mc-bar.is-open {
    padding-top: 4px !important; padding-bottom: calc(4px + env(safe-area-inset-bottom)) !important; gap: 4px !important;
    flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start; scrollbar-width: none;
    padding-left: max(8px, env(safe-area-inset-left)) !important; padding-right: max(8px, env(safe-area-inset-right)) !important;
  }
  .mc-bar > * { flex-shrink: 0; }
  .mc-bar .mc-link { display: none !important; }
  .mc-bar .mc-zp { display: none; }
  .mc-bar .mc-clock [x-ref="date"] { display: none; }
  .mc-bar .btn, .mc-bar .seg > button { height: 36px; }

  /* camera page: two columns (video + timeline left, review list scrolling on its own right) - the video
     never moves; the "more" panel floats over the top of the list column */
  .cam-body { flex-direction: row; overflow: hidden; position: relative; }
  .cam-body > section { flex: 1 1 0 !important; min-height: 0; position: static; box-shadow: none; padding-left: env(safe-area-inset-left); }
  .cam-body .stage { flex: 1 1 0 !important; height: auto; min-height: 0; }
  .cam-body > aside {
    width: 300px !important; border-top-width: 0 !important; border-left: 1px solid #EDEAE3 !important;
    display: flex; flex-direction: column; min-height: 0; padding-right: env(safe-area-inset-right);
  }
  /* max-content rows: in a fixed-height grid scroller the overflow:hidden cards would collapse to 0 */
  .cam-body > aside .cam-list { overflow-y: auto !important; flex: 1 1 0 !important; min-height: 0; grid-auto-rows: max-content; }
  /* label chips: one sideways-scrolling row instead of three wrapped ones */
  .cam-body > aside .flex-wrap { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  .cam-body > aside .flex-wrap > * { flex-shrink: 0; }
  .cam-body .cam-bar.is-open {
    position: absolute; top: 0; right: 0; width: 300px; max-height: 100%; overflow-y: auto; z-index: 30;
    border-top-width: 0 !important; box-shadow: 0 10px 24px rgba(28,24,18,.18);
  }
  .cam-body .cam-bar .cam-title { justify-content: flex-start; }
}
@media (max-width: 767px) {
  /* multi-cam portrait: the open "more" panel sits in the flow below the timeline and shrinks the
     (mostly empty) video stage, instead of floating over the timeline lanes */
  .mc-main > .stage { order: 1; }
  .mc-main > .mc-tl { order: 2; }
  .mc-main > .mc-bar.is-open { order: 3; position: static !important; box-shadow: none !important; }
  .nk-res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .nk-cam-grid { gap: 12px !important; }
}
