/* ---- house style tokens: keep in sync with gradetonic-website src/styles/global.css (:root and the surround
   presets). The app's older names below are aliases of these tokens; a tenant's colors override only the aliases,
   via an inline :root style (lib/views.js), and only where the tenant changed them. ---- */
@font-face { font-family: 'Inter Tight Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/assets/fonts/inter-tight-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Inter Tight Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/assets/fonts/inter-tight-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
:root {
  --bg: #000; --fg: #f5f5f4; --mut: #8a8a90; --line: #2a2a2e; --line-strong: #6b6b72; --card: #0f0f10; --card-hi: #18181b;
  --btn: #e7e7e5; --on: #000; --glass: rgb(0 0 0 / .72);
  --radius-sm: 8px; --radius-md: 14px; --radius-lg: 20px; --radius-pill: 999px; --bar-height: 4px;
  --sans: 'Inter Tight Variable', 'Inter Tight', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  /* App aliases (tenant-overridable). */
  --text: var(--fg);
  --muted: var(--mut);
  --surface: var(--card);
  --surface-2: var(--card-hi);
  --accent: var(--btn);
  --accent-hover: var(--accent);
  --on-accent: var(--on);
  --radius: var(--radius-md);
  /* Status colors (dots and badges only). */
  --live: #22c55e;
  --warn: #f59e0b;
  --danger: #fca5a5;
  color-scheme: dark;
  font-family: var(--sans);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--bar-height)); }
body.no-bar { padding-top: 0; }
html, body, .topbar, .card, .panel, .admin-card, .roomcard { transition: background-color .35s, color .35s, border-color .35s; }
a { color: var(--text); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
h1, h2, h3 { font-weight: 500; text-wrap: balance; }
h2, h3 { letter-spacing: -.015em; }
strong, b { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ---- SMPTE color bar (75 % bars), 4 px fixed at the top; never on a viewer page with the player (body.no-bar) ---- */
.color-bar { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: var(--bar-height); z-index: 10; display: grid; grid-template-columns: repeat(7, 1fr); }
.color-bar i:nth-child(1) { background: #c0c0c0; }
.color-bar i:nth-child(2) { background: #c0c000; }
.color-bar i:nth-child(3) { background: #00c0c0; }
.color-bar i:nth-child(4) { background: #00c000; }
.color-bar i:nth-child(5) { background: #c000c0; }
.color-bar i:nth-child(6) { background: #c00000; }
.color-bar i:nth-child(7) { background: #0000c0; }

/* ---- top bar ---- */
/* Full width; turns to glass once the page scrolls (public/js/nav.js sets .scrolled). */
.topbar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--bar-height)); z-index: 9; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid transparent; }
body.no-bar .topbar { top: env(safe-area-inset-top, 0px); }
.topbar.scrolled { background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); border-bottom-color: var(--line); }
.brand img { display: block; height: auto; max-height: 48px; max-width: min(240px, 60vw); width: auto; }
.brand svg { display: block; height: 28px; width: auto; color: var(--text); }
.wordmark { display: block; font-weight: 500; font-size: 1.05rem; letter-spacing: .18em; text-transform: uppercase; text-decoration: none; }
.brand { text-decoration: none; }
.topnav form { margin: 0; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; padding: .3rem 0; white-space: nowrap; }
.link:hover { color: var(--text); }

.wrap { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem); }
body.center .wrap { display: grid; place-items: center; }

/* ---- home ---- */
.hero { margin-bottom: 2rem; }
.eyebrow { margin: 0 0 .4rem; color: var(--muted); font-weight: 500; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.6rem, 3.6vw, 2.4rem); letter-spacing: -.025em; line-height: 1.15; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .18s ease, border-color .18s ease; }
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card-media { position: relative; display: block; aspect-ratio: 16 / 9; background: #111 center / cover no-repeat; }
.card-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.65)); }
.card-badge { position: absolute; z-index: 1; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.18); transition: background .18s; }
.card-badge svg { width: 18px; height: 18px; }
.card:hover .card-badge, .card-badge.is-open { background: var(--accent); border-color: transparent; }
.card-body { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: 1rem 1.1rem; }
.card-title { font-weight: 500; font-size: 1.05rem; }
.card-meta { color: var(--muted); font-size: .82rem; }

/* ---- password panel ---- */
.panel { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 2rem; text-align: center; }
.panel h1 { font-size: 1.6rem; margin-bottom: .4rem; }
.panel-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); color: var(--accent); margin-bottom: 1rem; }
.panel-icon svg { width: 22px; height: 22px; }
.stack { display: grid; gap: .75rem; margin-top: 1.4rem; }
input[type="password"], .panel input[type="text"], .panel input[type="email"] { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem; }
input[type="password"]:focus, .panel input:focus { border-color: var(--line-strong); }
/* Selects outside .form (tables, inline forms): iOS otherwise renders them small in the system font. */
select { font: inherit; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .6rem; min-height: 36px; }
.alert { background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.5); color: var(--danger); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: 1rem 0 0; font-size: .9rem; }
.back { display: inline-block; margin-top: 1.4rem; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--text); }

/* ---- buttons ---- */
/* Pills: .btn filled (--btn on --on), .btn.ghost outlined (1.5px --line-strong); ghost keeps its compact size. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font: inherit; font-weight: 500; font-size: 15px; line-height: 1.3; white-space: nowrap; color: var(--on-accent); background: var(--accent); border: 1.5px solid transparent; border-radius: var(--radius-pill); padding: 11px 20px; cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, opacity .15s; }
.btn:hover { background: var(--accent-hover); opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[hidden] { display: none; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text); padding: .5rem 1rem; font-size: .85rem; }
.btn.ghost:hover { opacity: 1; border-color: var(--text); }

/* ---- stream page ---- */
.stage-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.status { margin: .35rem 0 0; display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .88rem; }
.sep { opacity: .5; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--live); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 1.8s infinite; }
.dot.wait { background: var(--warn); }
.dot.err { background: var(--accent); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { font-size: .85rem; text-decoration: none; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.locked::before { content: "🔒 "; font-size: .75em; }

/* The frame keeps 16:9 by itself (never SLDP's measurement): the width follows the available height, so a short
   viewport (a phone in landscape, a low browser window) gives a smaller 16:9 frame instead of a full-width strip.
   --player-chrome is the room left for the header and toolbar. */
.player-frame { --player-chrome: 240px; position: relative; width: min(100%, calc((100dvh - var(--player-chrome)) * 16 / 9)); min-width: min(100%, 280px); aspect-ratio: 16 / 9; margin: 0 auto; background: #050505; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#gradetonic_player_wrapper { position: absolute; inset: 0; }
/* SLDP writes a pixel height on its wrapper when it measures the container (also mid-rotation); 100% wins. */
#gradetonic_player_wrapper > div, #gradetonic_player_wrapper video { width: 100% !important; height: 100% !important; }
#gradetonic_player_wrapper video { object-fit: contain; background: #000; }
@media (orientation: landscape) and (max-height: 520px) {
  .player-frame { --player-chrome: 110px; }
}
/* Full screen (public/js/player.js): the element API where it exists, the native iPhone video player, otherwise a
   pseudo full screen that fills the viewport inside the safe areas. */
#player_frame:fullscreen, #player_frame:-webkit-full-screen { max-height: none; aspect-ratio: auto; width: 100%; height: 100%; border: 0; border-radius: 0; background: #000; }
/* By id: the surround rule makes the frame transparent on non-black backgrounds. */
#player_frame.pseudo-fs { position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100dvh; max-height: none; aspect-ratio: auto; margin: 0; border: 0; border-radius: 0; background: #000;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
html.pseudo-fs-on, html.pseudo-fs-on body { overflow: hidden; }
.player-frame.pseudo-fs #gradetonic_player_wrapper { inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.fs-close, .rotate-hint { display: none; }
.player-frame.pseudo-fs .fs-close { display: block; position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: calc(env(safe-area-inset-right) + 10px); z-index: 20; min-width: 44px; min-height: 44px; background: rgba(0,0,0,.6); color: #f5f5f4; border-color: rgba(245,245,244,.6); }
.player-frame.pseudo-fs .fs-close:focus-visible { outline-color: #f5f5f4; }
@media (orientation: portrait) {
  .player-frame.pseudo-fs .rotate-hint { display: block; position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 16px); margin: 0 64px; text-align: center; color: #d4d4d8; font-size: .9rem; z-index: 15; pointer-events: none; }
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1rem; }
.toolbar .muted { margin-left: auto; }

/* ---- SLDP player skin (3.1.4 and 2.13.3) ----
   SLDP has no color option: it injects its own stylesheet (blue #008ee8, orange hover #ff8814) after ours, so every
   rule here is scoped to the player container to win on specificity. Neutral white/grey on black; the control bar
   and the big play button sit on a dark backdrop, so they keep their contrast on every surround color. The buttons
   are made focusable in public/js/player.js; the focus ring is white with a black halo. */
#gradetonic_player_wrapper .sldp_cbar { display: block; padding: 12px 15px; }
#gradetonic_player_wrapper .sldp_cbar_video { background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,.45)); }
#gradetonic_player_wrapper .sldp_btn { width: 25px; height: 25px; margin-right: 10px; font-size: 22px; color: #f5f5f4; opacity: .85; border-radius: 4px; transition: opacity .2s, color .2s; }
#gradetonic_player_wrapper .sldp_btn:hover { color: #fff; opacity: 1; }
#gradetonic_player_wrapper .sldp_expand_btn { font-size: 20px; }
#gradetonic_player_wrapper .sldp_btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px rgba(0,0,0,.85); opacity: 1; }
#gradetonic_player_wrapper .sldp_volume_slider { background: rgba(245,245,244,.55); }
#gradetonic_player_wrapper .sldp_volume_thumb,
#gradetonic_player_wrapper .sldp-progress-thumb { background: #f5f5f4; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
#gradetonic_player_wrapper .sldp_volume_thumb:hover,
#gradetonic_player_wrapper .sldp-progress-thumb:hover { background: #fff; }
#gradetonic_player_wrapper .sldp-load-bar { background-color: #d4d4d8; }
#gradetonic_player_wrapper .sldp-base-bar { background-color: rgba(255,255,255,.3); }
#gradetonic_player_wrapper .sldp-time-ind { color: #d4d4d8; }
/* The "connecting" bar at the top (SLDP's loading indicator) */
#gradetonic_player_wrapper .sldp_indicator { background-color: #d4d4d8; height: 3px; }
/* Big play button (phones and tablets): our play ring instead of the blue glyph */
#gradetonic_player_wrapper .sldp_mobile_ctrl { color: #f5f5f4; }
#gradetonic_player_wrapper .sldp_mobile_ctrl_icon { font-size: 0; width: 76px; height: 76px; border-radius: 50%; opacity: 1; background: rgba(0,0,0,.55); border: 2px solid rgba(245,245,244,.9); box-sizing: border-box; position: relative; }
#gradetonic_player_wrapper .sldp_mobile_ctrl_icon::before { content: ""; position: absolute; left: 50%; top: 50%; translate: -38% -50%; border-style: solid; border-width: 13px 0 13px 22px; border-color: transparent transparent transparent #f5f5f4; }
#gradetonic_player_wrapper .sldp_mobile_ctrl_icon.sldp-icon-pause-o::before { translate: -50% -50%; width: 20px; height: 24px; border: 0; border-left: 6px solid #f5f5f4; border-right: 6px solid #f5f5f4; box-sizing: border-box; }
#gradetonic_player_wrapper .sldp_cfg_dialog,
#gradetonic_player_wrapper .sldp_capt_dialog { background: #0f0f10; border: 1px solid #26262a; border-radius: 8px; }
#gradetonic_player_wrapper .sldp_cfg_dialog li:hover,
#gradetonic_player_wrapper .sldp_capt_dialog li:hover { background-color: #26262a; }
#gradetonic_player_wrapper .sldp_message { background: rgba(0,0,0,.75); border-radius: 8px; color: #f5f5f4; font-family: inherit; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: .7rem 1.1rem; border-radius: var(--radius-pill); font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: opacity .4s, translate .4s; z-index: 50; }
.toast.error { border-color: rgba(220,38,38,.6); }
.toast.out { opacity: 0; translate: -50% 8px; }

/* ---- footer ---- */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: 1.2rem clamp(1rem, 4vw, 2.5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.foot a { color: var(--muted); }

@media (max-width: 640px) {
  .toolbar .muted { margin-left: 0; width: 100%; }
  .player-frame { border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- admin ---- */
.colors { display: grid; gap: .9rem 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.colors label { display: flex; align-items: center; gap: .7rem; font-size: .9rem; color: var(--text); font-weight: 500; }
.colors input[type="color"] { width: 46px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }
.colors small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.admin-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.topnav { display: flex; align-items: center; gap: 1.2rem; }
.topnav a.link { text-decoration: none; }
.admin-list { display: grid; gap: 1rem; margin-bottom: 1rem; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; scroll-margin-top: 1rem; }
.admin-card + .admin-card { margin-top: 0; }
.admin-card-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
.admin-card h2 { margin: 0; font-size: 1.15rem; }
.admin-card .muted a { color: var(--muted); }
.fields { display: grid; gap: .9rem 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.fields label { display: grid; gap: .35rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
.fields input { width: 100%; font: inherit; font-size: .95rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .85rem; }
.fields input:focus { border-color: var(--line-strong); }
/* Banners stay achromatic: the client's picture is the only color. Errors (.alert) keep a red edge. */
.notice { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text); border-radius: var(--radius-sm); padding: .6rem .9rem; margin: 0 0 1rem; }
.hero .muted { margin: .5rem 0 0; }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem 1rem; text-align: left; overflow-x: auto; }

/* ---- player notices (402/423/429/503, warn line) ---- */
.notice-overlay { position: absolute; inset: auto 0 0 0; margin: 0; padding: 1rem 1.2rem; background: rgba(0,0,0,.72); color: #f5f5f4; font-size: .95rem; text-align: center; z-index: 5; }
.warn-line { margin: .75rem 0 0; color: var(--warn); font-size: .88rem; }
.topnav button.link { padding: 0; }

/* ---- surround: color around the picture (public/js/surround.js) ----
   Text tokens per surround meet WCAG AA 4.5:1 for small text (muted, warn), see docs/decisions.md P8. */
.gt-surround { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.gt-surround-label { font-size: .8rem; color: var(--muted); margin-right: .15rem; }
.gt-swatch { width: 22px; height: 22px; padding: 0; border-radius: 50%; cursor: pointer; border: 1px solid rgba(128,128,128,.7); transition: transform .12s; }
.gt-swatch:hover { transform: scale(1.12); }
.gt-swatch[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
.gt-swatch:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
html[data-gt-surround] body { transition: background-color .2s, color .2s; }
/* The website's presets, with one deviation: muted on mid grey is #141414 (website #1f1f1f is 4.2:1 on #808080;
   #141414 is 4.7:1). The aliases point back at the tokens, so a tenant's text color never lands on a grey/white surround. */
html[data-gt-surround]:not([data-gt-surround="black"]) { --text: var(--fg); --muted: var(--mut); --surface: var(--card); --surface-2: var(--card-hi); --accent: var(--btn); --on-accent: var(--on); }
html[data-gt-surround="psgrey"] { --bg: #282828; --mut: #a1a1a7; --line: #3c3c3c; --card: #303030; --card-hi: #3a3a3a; --glass: rgb(40 40 40 / .78); }
html[data-gt-surround="midgrey"] { --bg: #808080; --fg: #0a0a0a; --mut: #141414; --line: #6a6a6a; --line-strong: #3a3a3a; --card: #787878; --card-hi: #8c8c8c; --btn: #0a0a0a; --on: #f5f5f4; --glass: rgb(128 128 128 / .8); --warn: #000; --danger: #3d0000; color-scheme: light; }
html[data-gt-surround="white"] { --bg: #fff; --fg: #0b0b0b; --mut: #5c5c61; --line: #d6d6d3; --line-strong: #7c7c81; --card: #f4f4f3; --card-hi: #e9e9e7; --btn: #0b0b0b; --on: #fff; --glass: rgb(255 255 255 / .8); --warn: #b45309; --danger: #b91c1c; color-scheme: light; }
/* Keep the area around the picture pure: no dark frame on a grey or white surround. */
html[data-gt-surround]:not([data-gt-surround="black"]) .player-frame { background: transparent; border-color: transparent; }
@media (prefers-reduced-motion: reduce) { .gt-swatch, html[data-gt-surround] body { transition: none; } }

/* ---- forms and admin ---- */
.panel-wide { width: min(100%, 480px); text-align: left; }
.form .field { display: grid; gap: .35rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input[type="number"], .form input[type="datetime-local"], .form select, .form textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .85rem; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--line-strong); }
.form .row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.adminnav { display: flex; flex-wrap: wrap; gap: 1rem; }
.adminnav a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.adminnav a[aria-current="page"], .adminnav a:hover { color: var(--text); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: var(--radius-pill); font-size: .78rem; font-weight: 500; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.ok { color: var(--live); border-color: var(--live); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--danger); border-color: rgba(220,38,38,.75); }
/* /sa → Capacity: egress against capacity with the 60 % and 80 % marks. */
.cap-bar { position: relative; height: 10px; border-radius: var(--radius-pill); background: var(--card-hi); border: 1px solid var(--line); overflow: hidden; margin: .5rem 0 1rem; }
.cap-bar i { position: absolute; inset: 0 auto 0 0; background: var(--live); }
.cap-bar i.warn { background: var(--warn); }
.cap-bar i.bad { background: var(--danger); }
.cap-bar b { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.prompt-block { margin: .6rem 0 1.2rem; }
.prompt-block pre.code { white-space: pre-wrap; font-size: .8rem; max-height: 28rem; overflow-y: auto; }
.mono, code, pre { font-family: var(--mono); font-size: .85rem; }
.section { margin-top: 2rem; }
.section h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
.colors { display: grid; gap: .9rem 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.form input[type="color"] { width: 56px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.table-wrap { overflow-x: auto; }
.btn.small-btn { padding: .3rem .75rem; font-size: .8rem; }
.steps { padding-left: 1.2rem; display: grid; gap: .35rem; }

/* /admin dashboard: one card per room */
.roomcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; scroll-margin-top: 1rem; }
.roomcard:target { border-color: var(--line-strong); }
.roomcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.roomcard-head h2 { display: inline; margin: 0 .5rem 0 0; font-size: 1.1rem; }
.roomcard-actions { flex-wrap: wrap; gap: .4rem; margin: .8rem 0; align-items: flex-start; }
.roomcard h3 { margin: .6rem 0 .3rem; }
.viewer-list { list-style: none; margin: 0; padding: 0; }
.viewer-row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .35rem 0; border-top: 1px solid var(--line); }
.viewer-row > span:first-child { min-width: 8rem; }
.viewer-row details { margin-left: auto; }
details.confirm { display: inline-block; }
details.confirm > summary { list-style: none; cursor: pointer; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > form { display: inline-block; margin-left: .3rem; }
.preview-img { display: block; width: 100%; max-width: 480px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.preview-img.small { width: auto; max-width: 240px; max-height: 96px; }

/* Secure room modal */
dialog.modal { max-width: 34rem; width: calc(100% - 2rem); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
dialog.modal::backdrop { background: rgba(0,0,0,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.danger-text { color: var(--danger); }

/* ---- spacing and compact controls (house-style pass, phone review) ---- */
body.admin .wrap > h1, body.admin .wrap > section > h1 { margin-bottom: 1.2rem; }
.table .btn { padding: .35rem .9rem; font-size: .82rem; }
.table .row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 .4rem; }
.table td:last-child .row:last-child { margin-bottom: 0; }

/* Phone: logo and "Sign out" on one line, the section links below as one scrollable row. */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .4rem 1rem; padding: .75rem 1rem; }
  .brand svg { height: 24px; }
  .topnav { display: contents; }
  .topnav > form { margin-left: auto; }
  .topnav > .adminnav { order: 2; width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 1.1rem; padding: .2rem 0 .1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topnav > .adminnav::-webkit-scrollbar { display: none; }
  .adminnav a { white-space: nowrap; }
}
