/* StreamVault dashboard.
   Identity: a broadcast control room. Recordings in progress form a multiviewer
   wall (live frames, name strips, tally borders, timecode). Colour is reserved
   for state: green = recording/live, yellow = monitoring, red = offline/fault,
   orange = rate limited. Everything else is quiet slate and paper.
   Type: Archivo (self-hosted, OFL). Condensed for names, labels and timecode;
   normal width for reading. */

@font-face {
  font-family: "Archivo SV";
  src: url("/static/fonts/archivo-var.woff") format("woff");
  font-weight: 400 800;
  font-stretch: 62% 100%;
  font-display: swap;
}

:root {
  --page: #1c2329;
  --panel: #232c34;
  --raised: #2c3741;
  --line: #3a4652;
  --line-soft: #2b353e;
  --text: #ebeff2;
  --mute: #9eacb8;
  --faint: #73818d;
  --rec: #3ddb84;
  --standby: #f5c84b;
  --fault: #f2645f;
  --caution: #f79a4b;
  --video: #000;
  --gutter: 16px;
  --rail-w: 96px;
  --tab-h: 62px;
  --radius: 10px;
  --font: "Archivo SV", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 400;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img, video, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

/* The condensed voice: names, labels, timecode */
.cond, h1, h2, h3, .wordmark, .badge, .umd, .tab span, .clip-dur, .clip-q, .tile-q, .seg button {
  font-stretch: 72%;
  font-variation-settings: "wdth" 72;
}
.num { font-variant-numeric: tabular-nums; }

h1 { font-size: 24px; line-height: 1.1; font-weight: 750; letter-spacing: 0.005em; }
h2 { font-size: 18px; line-height: 1.2; font-weight: 700; }
h3 { font-size: 16px; line-height: 1.2; font-weight: 700; color: var(--mute); }

/* ----------------------------------------------------------------- lamp */
.lamp {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.lamp.on { background: var(--rec); box-shadow: 0 0 0 3px rgba(61, 219, 132, 0.18); animation: tally 2.4s ease-in-out infinite; }
@keyframes tally { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot .lamp { width: 14px; height: 14px; animation: tally 1.2s ease-in-out infinite; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text);
  font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; pointer-events: none; }
.btn.primary { background: var(--text); color: var(--page); border-color: var(--text); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--fault); border-color: var(--fault); color: #230b0a; }
.btn.danger-ghost { background: transparent; border-color: rgba(242, 100, 95, 0.45); color: var(--fault); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn b { font-weight: 600; color: var(--mute); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--mute); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (hover: hover) {
  .btn:hover { border-color: var(--mute); }
  .btn.primary:hover { background: #fff; }
  .icon-btn:hover { background: var(--raised); color: var(--text); }
}

/* ---------------------------------------------------------------- inputs */
input[type="text"], input[type="search"], input[type="password"], input[type="number"], select, textarea {
  min-height: 44px; width: 100%;
  padding: 0 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
textarea { padding: 10px 12px; min-height: 96px; resize: vertical; line-height: 1.4; }
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239eacb8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mute); box-shadow: 0 0 0 1px var(--mute); }
input[type="search"]::-webkit-search-cancel-button { filter: invert(0.7); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--mute); }
.form-error { color: var(--fault); font-size: 14px; }

/* segmented control */
.seg {
  display: inline-flex; flex-wrap: nowrap;
  padding: 3px; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--mute);
  font-size: 15px; font-weight: 650; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg button:disabled { opacity: 0.4; cursor: default; }

/* switch */
input[type="checkbox"].switch {
  -webkit-appearance: none; appearance: none;
  width: 46px; height: 28px; flex: none; margin: 0;
  border-radius: 14px; background: var(--raised); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background 0.15s;
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--mute);
  transition: transform 0.15s, background 0.15s;
}
input[type="checkbox"].switch:checked { background: var(--text); border-color: var(--text); }
input[type="checkbox"].switch:checked::after { transform: translateX(18px); background: var(--page); }

/* ----------------------------------------------------------------- login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login-hint { color: var(--mute); font-size: 14px; }

.wordmark { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: 0.01em; }
.wordmark-lg { font-size: 30px; gap: 12px; }
.wordmark-lg .lamp { width: 14px; height: 14px; }

/* ------------------------------------------------------------ app frame */
.app { min-height: 100vh; }
.main { padding: 16px var(--gutter) calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); max-width: 1480px; }

.rail {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: rgba(28, 35, 41, 0.94);
  border-top: 1px solid var(--line-soft);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.rail .wordmark { display: none; }
.tab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); text-decoration: none; font-size: 13px; font-weight: 650;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); }
.tab-count {
  position: absolute; top: 7px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--rec); color: #08240f; font-size: 12px; line-height: 18px; font-weight: 800; text-align: center;
}
.tab-count.warn { background: var(--caution); color: #2b1503; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 6px 0 14px; }
.crumb { display: inline-block; color: var(--mute); text-decoration: none; font-size: 14px; margin-bottom: 4px; }
.crumb::before { content: "‹ "; }

.block { margin-top: 26px; }
.block-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.block-meta { color: var(--mute); font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; width: auto; }
.toolbar select { flex: 0 1 220px; width: auto; }
.empty, .note { color: var(--mute); font-size: 15px; padding: 18px 2px; max-width: 64ch; }
.more { display: flex; justify-content: center; padding: 18px 0; }

/* ---------------------------------------------------------------- meters */
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; width: 100%; }
.meter { display: grid; gap: 4px; min-width: 0; }
.meter-label { font-size: 12px; color: var(--mute); }
.meter-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-value small { font-size: 12px; color: var(--mute); font-weight: 500; }
.bar { height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--text); border-radius: 2px; }
.bar.hot > i { background: var(--fault); }

.banners { display: grid; gap: 8px; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: var(--panel); border-left: 3px solid var(--mute); font-size: 15px; }
.banner.fault { border-left-color: var(--fault); }
.banner.caution { border-left-color: var(--caution); }
.banner strong { font-weight: 700; }

/* ---------------------------------------------------------- multiviewer */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
.tile { min-width: 0; display: grid; gap: 0; }
.tile-frame {
  position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  background: var(--video);
  box-shadow: 0 0 0 2px var(--rec);
}
.tile-frame img { width: 100%; height: 100%; object-fit: cover; }
.tile-frame .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #3c4650; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; }
.tile-tally {
  position: absolute; left: 8px; top: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.62);
  font-size: 12px; font-weight: 800; color: var(--rec);
}
.tile-tally .lamp { width: 8px; height: 8px; }
.tile-q { position: absolute; right: 8px; top: 8px; padding: 3px 7px; border-radius: 6px; background: rgba(0, 0, 0, 0.62); font-size: 12px; font-weight: 750; }
.umd {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 8px;
  padding: 8px 10px 9px;
  background: #0f1418; border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 0 0 2px var(--rec);
}
.umd-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.umd-tc { font-size: 17px; font-weight: 750; color: var(--rec); font-variant-numeric: tabular-nums; }
@media (min-width: 640px) {
  .umd-name { font-size: 16px; }
  .umd-tc { font-size: 19px; }
}
.umd-title { grid-column: 1 / -1; font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-stretch: 100%; font-variation-settings: "wdth" 100; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px 0; font-size: 14px; color: var(--mute); }
.tile-foot .num { color: var(--text); font-weight: 600; }
.tile.stopping .tile-frame, .tile.stopping .umd { box-shadow: 0 0 0 2px var(--faint); }
.tile.stopping .umd-tc, .tile.stopping .tile-tally { color: var(--mute); }

.wall-empty {
  display: grid; gap: 4px; align-content: center; justify-items: start;
  min-height: 120px; padding: 20px; border-radius: var(--radius);
  background: var(--panel); color: var(--mute); font-size: 15px;
}
.wall-empty strong { color: var(--text); font-size: 17px; font-weight: 650; }

/* ------------------------------------------------------------- watchlist */
.add-form { display: flex; gap: 8px; margin-bottom: 10px; }
.add-form input { flex: 1; }
.watchlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.acct { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); min-height: 66px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: hsl(var(--hue, 210) 18% 30%); color: hsl(var(--hue, 210) 30% 86%);
  font-size: 14px; font-weight: 800; font-stretch: 72%; font-variation-settings: "wdth" 72; text-transform: uppercase;
}
.acct-main { min-width: 0; display: grid; gap: 3px; }
.acct-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.acct-name b { font-size: 17px; font-weight: 750; font-stretch: 72%; font-variation-settings: "wdth" 72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-nick { color: var(--mute); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.acct-status { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--mute); }
.acct-detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.acct-facts { display: none; }
.acct-side { display: flex; align-items: center; gap: 2px; }
.acct.is-paused .acct-name b { color: var(--mute); }

.badge { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 13px; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.rec, .badge.live { color: var(--rec); }
.badge.live::before { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.badge.monitor { color: var(--standby); }
.badge.offline, .badge.fault { color: var(--fault); }
.badge.limited { color: var(--caution); }
.badge.checking::before { animation: tally 0.9s ease-in-out infinite; }

/* --------------------------------------------------------------- library */
.lib-summary { color: var(--mute); font-size: 14px; margin: -2px 0 6px; }
.lib-group { margin-top: 18px; }
.lib-group h3 { margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; }
.clip {
  display: grid; gap: 2px; min-width: 0; padding: 0; text-align: left;
  border: 0; background: transparent; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.clip-frame { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; background: var(--raised); margin-bottom: 6px; }
.clip-frame img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.clip-frame .initials { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #46525e; font-stretch: 72%; font-variation-settings: "wdth" 72; text-transform: uppercase; }
.clip-q, .clip-dur { position: absolute; z-index: 2; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, 0.66); font-size: 13px; font-weight: 750; }
.clip-q { left: 7px; top: 7px; }
.clip-dur { right: 7px; bottom: 7px; font-variant-numeric: tabular-nums; }
.clip-state { position: absolute; z-index: 2; left: 7px; bottom: 7px; display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); font-size: 12px; font-weight: 800; font-stretch: 72%; font-variation-settings: "wdth" 72; }
.clip-state.rec { color: var(--rec); }
.clip-state.busy { color: var(--standby); }
.clip-state.fault { color: var(--fault); }
.clip-state .lamp { width: 7px; height: 7px; }
.clip-who { font-weight: 750; font-size: 16px; font-stretch: 72%; font-variation-settings: "wdth" 72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-line { display: flex; justify-content: space-between; gap: 8px; color: var(--mute); font-size: 14px; font-variant-numeric: tabular-nums; }
.clip-title { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .clip:hover .clip-frame { box-shadow: 0 0 0 2px var(--mute); } }

/* Recently deleted */
.trash-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.trash-item { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.trash-thumb { width: 54px; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden; background: var(--raised); }
.trash-thumb img { width: 100%; height: 100%; object-fit: cover; }
.trash-main { display: grid; gap: 4px; min-width: 0; }
.trash-main b { font-weight: 750; font-stretch: 72%; font-variation-settings: "wdth" 72; font-size: 17px; }
.trash-meta { color: var(--mute); font-size: 14px; }
.trash-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* -------------------------------------------------------------- activity */
.activity { list-style: none; margin: 0; padding: 0; }
.act-day { margin: 18px 0 6px; font-size: 16px; font-weight: 700; color: var(--mute); font-stretch: 72%; font-variation-settings: "wdth" 72; }
.ev { display: grid; grid-template-columns: 66px 10px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.ev time { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transform: translateY(-1px); }
.ev.k-live .ev-dot { background: var(--rec); }
.ev.k-saved .ev-dot { background: var(--text); }
.ev.l-warn .ev-dot { background: var(--caution); }
.ev.l-error .ev-dot { background: var(--fault); }
.ev p { min-width: 0; overflow-wrap: anywhere; }
.ev-user { padding: 0; border: 0; background: none; color: var(--text); font-weight: 750; font-stretch: 72%; font-variation-settings: "wdth" 72; font-size: 16px; cursor: pointer; }
.ev.l-error p { color: #ffd2d0; }

/* --------------------------------------------------------------- player */
.player { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--page); }
.pl-top { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: env(safe-area-inset-top) 8px 0; border-bottom: 1px solid var(--line-soft); }
.pl-who { min-width: 0; display: grid; }
.pl-who b { font-size: 18px; font-weight: 800; font-stretch: 72%; font-variation-settings: "wdth" 72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-who span { font-size: 13px; color: var(--mute); }
.pl-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pl-stage { position: relative; background: var(--video); display: grid; place-items: center; }
.pl-stage video { display: block; width: 100%; max-height: 62vh; max-height: 62dvh; object-fit: contain; background: var(--video); }
.pl-msg { position: absolute; inset: 12px 12px auto 12px; padding: 10px 12px; border-radius: 8px; background: rgba(28, 35, 41, 0.92); font-size: 14px; }
.pl-side { display: grid; gap: 16px; align-content: start; padding: 16px var(--gutter) calc(28px + env(safe-area-inset-bottom)); }
.pl-title { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.pl-title.none { color: var(--faint); font-weight: 400; }
.pl-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { display: grid; gap: 2px; }
.fact span { font-size: 12px; color: var(--mute); }
.fact b { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; font-stretch: 72%; font-variation-settings: "wdth" 72; }
.pl-quality { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pl-actions { display: grid; gap: 8px; }
.pl-note { color: var(--mute); font-size: 14px; }
.pl-note:empty { display: none; }
.pl-versions { display: grid; border-top: 1px solid var(--line-soft); }
.ver { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); align-items: center; }
.ver-name { font-weight: 750; font-size: 16px; font-stretch: 72%; font-variation-settings: "wdth" 72; }
.ver-name .playing { color: var(--rec); font-weight: 700; margin-left: 6px; }
.ver-meta { grid-column: 1 / -1; color: var(--mute); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.ver-actions { display: flex; gap: 4px; grid-row: 1; grid-column: 2; }
.ver-actions .icon-btn { width: 40px; height: 40px; }

/* ----------------------------------------------------- sheet, modal, toast */
.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(8, 11, 14, 0.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 80vh; overflow-y: auto;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel); border-radius: 14px 14px 0 0; border-top: 1px solid var(--line);
}
.sheet-panel.pop { left: auto; right: auto; bottom: auto; transform: none; width: 280px; border-radius: 10px; border: 1px solid var(--line); padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); }
.sheet-head { padding: 10px 12px 8px; display: grid; gap: 2px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.sheet-head b { font-size: 17px; font-weight: 800; font-stretch: 72%; font-variation-settings: "wdth" 72; }
.sheet-head span { font-size: 13px; color: var(--mute); overflow-wrap: anywhere; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 48px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 16px; text-align: left; text-decoration: none; cursor: pointer;
}
.sheet-item.danger { color: var(--fault); }
.sheet-item small { margin-left: auto; color: var(--mute); font-size: 14px; }
@media (hover: hover) { .sheet-item:hover { background: var(--raised); } }

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(8, 11, 14, 0.6); }
.modal-card { width: 100%; max-width: 420px; display: grid; gap: 12px; padding: 20px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.modal-card h2 { font-size: 21px; }
.modal-card p { color: var(--mute); font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toasts { position: fixed; z-index: 95; left: 0; right: 0; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px;
  max-width: 560px; padding: 10px 10px 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--page); font-size: 15px; font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.error { background: var(--fault); color: #230b0a; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 800; padding: 6px 8px; cursor: pointer; text-decoration: underline; }

/* -------------------------------------------------------------- settings */
.settings { display: grid; gap: 14px; max-width: 760px; }
.set-section { background: var(--panel); border-radius: 12px; padding: 16px; display: grid; gap: 14px; }
.set-section > h2 { font-size: 21px; }
.set-intro { color: var(--mute); font-size: 15px; margin-top: -8px; max-width: 64ch; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.set-row.stack { grid-template-columns: minmax(0, 1fr); }
.set-row label, .set-row .set-label { font-weight: 600; }
.set-help { grid-column: 1 / -1; color: var(--mute); font-size: 14px; max-width: 64ch; }
.set-row input[type="number"] { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.set-row select { width: auto; min-width: 140px; }
.set-pair { display: flex; align-items: center; gap: 8px; color: var(--mute); }
.set-row.stack > .seg, .set-row.stack > .set-actions { justify-self: start; }
input[type="file"] { max-width: 100%; color: var(--mute); font-size: 14px; }
input[type="file"]::file-selector-button {
  margin-right: 12px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.set-status { font-size: 14px; color: var(--mute); }
.set-status.ok { color: var(--rec); }
.set-status.bad { color: var(--fault); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.proxy-results { display: grid; gap: 6px; font-size: 14px; }
.proxy-results .ok { color: var(--rec); }
.proxy-results .bad { color: var(--fault); }
.update-log { margin: 0; max-height: 220px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: #141a1f; color: var(--mute); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.noscript { padding: 24px; }

/* ------------------------------------------------------------ responsive */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .meters { grid-template-columns: repeat(4, minmax(0, auto)); width: auto; gap: 8px 26px; }
  .meter { min-width: 92px; }
  .meter.storage { min-width: 180px; }
  .wall { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 18px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 20px 14px; }
  .acct { grid-template-columns: 40px minmax(0, 1fr) auto auto; }
  .acct-facts { display: grid; justify-items: end; gap: 2px; font-size: 13px; color: var(--mute); text-align: right; font-variant-numeric: tabular-nums; }
  .sheet-panel { left: 50%; right: auto; transform: translateX(-50%); width: 420px; bottom: 16px; border-radius: 14px; border: 1px solid var(--line); }
  .pl-actions { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 960px) {
  :root { --gutter: 32px; }
  .rail {
    top: 0; bottom: 0; right: auto; width: var(--rail-w); height: auto;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px;
    padding: 18px 8px; border-top: 0; border-right: 1px solid var(--line-soft); background: var(--page);
  }
  .rail .wordmark { display: flex; flex-direction: column; gap: 6px; align-items: center; font-size: 15px; margin-bottom: 18px; text-align: center; line-height: 1.05; }
  .wordmark-text { max-width: 80px; }
  .tab { flex: none; min-height: 64px; border-radius: 10px; }
  .tab[aria-current="page"] { background: var(--panel); }
  .tab-count { top: 6px; left: calc(50% + 8px); }
  .main { margin-left: var(--rail-w); padding: 24px var(--gutter) 48px; }
  .toasts { bottom: 24px; left: var(--rail-w); }
  h1 { font-size: 36px; }
  .block { margin-top: 32px; }
  /* One fixed row the size of the window: the video is scaled to fit it, never taller. */
  .pl-body { display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .pl-stage { height: 100%; min-height: 0; min-width: 0; overflow: hidden; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
  .pl-stage video { width: 100%; height: 100%; max-height: 100%; }
  .pl-side { overflow-y: auto; border-left: 1px solid var(--line-soft); padding: 20px 24px 32px; }
  .pl-actions { grid-template-columns: 1fr; }
}

@media (min-width: 1280px) {
  .wall { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .lamp.on, .boot .lamp, .badge.checking::before { animation: none; }
  input[type="checkbox"].switch, input[type="checkbox"].switch::after { transition: none; }
}
