:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1f252d;
  --line: #2a313b;
  --text: #e7ebf0;
  --muted: #8b95a3;
  --accent: #3d8bfd;
  --accent-ink: #fff; /* text on accent backgrounds; set per user */
  --ok: #2fbf71;
  --warn: #f2c94c;
  --bad: #eb5757;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
a { color: var(--accent); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.narrow { max-width: 460px; margin: 8vh auto; }
label { display: block; margin: .75rem 0; color: var(--muted); font-size: .9rem; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--text); }
input[type=text], input[type=password], input[type=email], select {
  width: 100%;
  margin-top: .3rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
button {
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #3a4350; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.active { background: var(--bad); border-color: var(--bad); color: #fff; }
.error { color: var(--bad); min-height: 1.2em; }
.hint { color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > input[type=text], .row > input[type=email] { flex: 1; margin: 0; }
.pill {
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  background: var(--panel-2);
  color: var(--muted);
}
.pill.ok { background: rgba(47, 191, 113, .15); color: var(--ok); }
.pill.bad { background: rgba(235, 87, 87, .15); color: var(--bad); }

/* --- studio --- */
header.bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header.bar h1 { margin: 0; }
header.bar .grow { flex: 1; }
.panels { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; margin-top: 1rem; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }
.side { display: flex; flex-direction: column; gap: 1rem; }
#strips { display: flex; gap: .75rem; flex-wrap: wrap; align-items: stretch; }
.strip {
  width: 150px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem;
  display: flex; flex-direction: column; gap: .5rem; align-items: stretch;
}
.strip.host { border-color: #2c4a73; }
.strip.off { opacity: .7; border-color: var(--bad); }
.strip .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.strip .status { font-size: .78rem; color: var(--muted); min-height: 1.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip.off .status { color: var(--bad); }
.strip .meters { display: flex; gap: .6rem; justify-content: center; align-items: stretch; height: 180px; }
.strip canvas { width: 22px; height: 180px; border-radius: 3px; }
.strip .fader {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 28px;
  height: 180px;
  accent-color: var(--accent);
}
.strip .fader-val { font-size: .78rem; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.strip select.mode { margin: 0; padding: .3rem .4rem; font-size: .75rem; }
.strip .stats { font-size: .7rem; color: var(--muted); min-height: 2.2em; }
.strip .stats.warn { color: var(--warn); }
.strip .buttons { display: flex; gap: .4rem; }
.strip .buttons button { flex: 1; padding: .45rem .3rem; font-size: .85rem; }
.strip .kick { flex: 0 0 auto !important; color: var(--muted); }
.mix { display: flex; gap: 1rem; align-items: center; }
.mix canvas { width: 40px; height: 120px; border-radius: 4px; }
#rec-time { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 650; }
#rec-files { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .85rem; }

/* --- guest --- */
.guest-meter { width: 100%; height: 22px; }
#live.off .big-meter { opacity: .4; }
.big-meter { display: flex; justify-content: center; margin: 1rem 0; }
.big-meter canvas { width: 60px; height: 160px; border-radius: 4px; }
.banner {
  background: rgba(235, 87, 87, .15);
  border: 1px solid var(--bad);
  color: #ffb3b3;
  padding: .7rem 1rem;
  border-radius: 8px;
  margin: .75rem 0;
  font-weight: 600;
}
#people { list-style: none; padding: 0; margin: .5rem 0; }
#people li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
#people li.muted { color: var(--muted); text-decoration: line-through; }

.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--bad); color: #fff; padding: .6rem 1rem; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

button.done { background: rgba(47, 191, 113, .15); border-color: var(--ok); color: var(--ok); }
@keyframes fresh { from { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(47, 191, 113, .35); } }
input.fresh { animation: fresh 1.5s ease-out; }

/* --- invite panel --- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 15, .94);
  backdrop-filter: blur(6px);
  display: grid; grid-template-columns: 220px minmax(0, 640px); gap: 2.5rem;
  align-content: start; justify-content: center;
  padding: 12vh 2rem 2rem;
  overflow-y: auto;
}
@media (max-width: 760px) { .modal { grid-template-columns: 1fr; gap: 1rem; padding-top: 4.5rem; } }
.modal-close {
  position: fixed; top: 1rem; left: 1rem;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg); border: 0;
}
.modal-nav { display: flex; flex-direction: column; gap: .25rem; padding-top: 4.6rem; }
@media (max-width: 760px) { .modal-nav { flex-direction: row; padding-top: 0; } }
.modal-nav button {
  background: none; border: 0; text-align: left; font-size: 1.15rem; font-weight: 500;
  color: var(--muted); padding: .4rem .2rem .4rem 1.1rem; position: relative;
}
.modal-nav button.active { color: var(--text); }
.modal-nav button.active::before {
  content: ''; position: absolute; left: .1rem; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-left: 7px solid currentColor;
}
.modal-title { font-size: 2.6rem; line-height: 1.12; font-weight: 300; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 1.5rem; }
.modal-lead { font-size: 1.1rem; margin: 0 0 1.2rem; }
.linkrow { display: flex; gap: .6rem; align-items: center; }
.linkrow input {
  flex: 1; min-width: 0; margin: 0;
  padding: .7rem 1.1rem; border-radius: 999px;
  border: 2px solid #e7ebf0; background: #000; font-size: 1.05rem;
}
.linkrow input.fresh { animation: fresh 1.5s ease-out; }
.icon-btn {
  width: 48px; height: 48px; padding: 0; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.icon-btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.premove { width: 36px; height: 36px; background: var(--panel-2); border-color: var(--line); color: var(--muted); }
.linkrow button.primary { border-radius: 999px; padding: .7rem 1.3rem; }
.validity { margin: 1rem 0 .4rem; padding-left: .7rem; border-left: 3px solid var(--muted); font-size: .92rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; font-weight: 500; }
.linklike:hover:not(:disabled) { color: var(--accent); }
.personal-list { list-style: none; padding: 0; margin: 1.4rem 0 .5rem; display: flex; flex-direction: column; gap: 1.1rem; }
.personal-head { margin-bottom: .45rem; }
.personal-list .linkrow input { font-size: .95rem; padding: .55rem 1rem; }
.personal-list .icon-btn:not(.premove) { width: 42px; height: 42px; }

.validfor { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; color: var(--text); font-size: .95rem; }
.validfor select, #personal-validity { width: auto; margin: 0; border-radius: 999px; padding: .55rem .9rem; }
#personal-validity { flex: 0 0 auto; }
.pvalid.never { color: var(--warn); }
@media (max-width: 760px) {
  .modal-title { font-size: 2rem; }
  #personal-form { flex-wrap: wrap; }
  #personal-form #personal-name { flex: 1 1 100%; }
  #personal-form #personal-validity { flex: 1 1 auto; }
}
input[readonly]#name { opacity: .8; cursor: default; }

/* --- account pages --- */
a.button, a.button:visited {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 600; text-decoration: none;
}
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
.back { color: var(--muted); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--text); }
.topnav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topnav a.here, .topnav a:hover { color: var(--text); }
.topnav .who { color: var(--text); font-weight: 600; padding-right: .6rem; border-right: 1px solid var(--line); }
.page { max-width: 960px; }
.narrow-page { max-width: 560px; }
.page section.card, .page .card { margin-bottom: 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 1.25rem; }
.page-title { font-size: 2rem; font-weight: 300; margin: 0; }
.page-head form { flex: 1; max-width: 480px; }
.studio-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.studio { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.studio-info { display: flex; flex-direction: column; gap: .15rem; }
.studio-title { font-size: 1.15rem; font-weight: 650; color: var(--text); text-decoration: none; }
.studio-title:hover { text-decoration: underline; }
.banner.info { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: color-mix(in srgb, var(--accent) 35%, #fff); }
.secret { border-color: var(--ok); }
.secret input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; }
.wrap-row > input[type=text], .wrap-row > input[type=email] { flex: 1 1 200px; margin: 0; }
.wrap-row > label.check { margin: 0; }
table.users { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.users th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
table.users th, table.users td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr.disabled td:not(.actions) { color: var(--muted); text-decoration: line-through; }
table.users td.actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
table.users td.actions button { padding: .35rem .6rem; font-size: .82rem; }
@media (max-width: 760px) {
  table.users thead { display: none; }
  table.users tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  table.users td { display: block; border: 0; padding: .15rem 0; }
  table.users td.actions { justify-content: flex-start; padding-top: .4rem; }
  table.users td[data-label]:not([data-label=Name]):not([data-label=Email])::before { content: attr(data-label) ': '; color: var(--muted); }
  table.users td[data-label=Name] { font-weight: 650; }
}
.toast.ok { background: var(--ok); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* --- video --- */
.video-section { margin: 1rem 0 0; }
.video-grid {
  display: grid; gap: .6rem;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
}
.video-section .video-grid { max-width: 1200px; }
.video-section .video-grid[data-count="1"] { max-width: 560px; }
.video-section .video-grid[data-count="2"] { max-width: 980px; }
.video-grid[data-count="1"] { max-width: 760px; }
.tile {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: #05070a; border-radius: var(--radius); border: 1px solid var(--line);
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.self video { transform: scaleX(-1); }
.tile-label {
  position: absolute; left: .5rem; bottom: .5rem; max-width: calc(100% - 1rem);
  display: flex; gap: .4rem; align-items: center;
  background: rgba(0, 0, 0, .6); padding: .2rem .55rem; border-radius: 6px;
  font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-mic { display: none; color: #fff; background: var(--bad); border-radius: 4px; padding: 0 .35rem; font-size: .72rem; }
.tile.mic-off .tile-mic { display: inline-block; }
.tile.mic-off { border-color: var(--bad); }
.tile-stop {
  position: absolute; top: .5rem; right: .5rem; padding: .3rem .6rem; font-size: .78rem;
  background: rgba(0, 0, 0, .65); border-color: transparent; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-stop, .tile-stop:focus-visible { opacity: 1; }
@media (hover: none) { .tile-stop { opacity: 1; } }
.cam-preview { margin: .5rem 0; }
.cam-preview video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #05070a; transform: scaleX(-1); }
#live.wide { max-width: 980px; }
#live .video-grid { margin: .75rem 0; }
button.active-soft { border-color: var(--accent); color: var(--accent); }
@media (max-width: 600px) {
  .tile-label { font-size: .72rem; left: .3rem; bottom: .3rem; padding: .1rem .4rem; }
  .video-grid { gap: .4rem; }
}

/* --- tiles: avatars, speaking, tools --- */
.video-grid:not(.callview) .tile.no-video { display: none; }
.tile .avatar {
  position: absolute; inset: 0; display: none; place-items: center;
  font-size: clamp(1.4rem, 5vw, 3.2rem); font-weight: 650; color: #fff; letter-spacing: .02em;
  background: radial-gradient(circle at 50% 45%, hsl(var(--h, 210) 35% 30%) 0 22%, transparent 22.5%), #11151b;
}
.tile.no-video .avatar { display: grid; }
.tile.no-video video { visibility: hidden; }
.tile.speaking { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok) inset; }
.tile.mic-off.speaking { border-color: var(--bad); box-shadow: none; }
.tile-tools {
  position: absolute; top: .45rem; right: .45rem; display: flex; gap: .3rem;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; }
@media (hover: none) { .tile-tools { opacity: 1; } }
.tile-tools button {
  padding: .25rem .55rem; font-size: .76rem; border-radius: 6px;
  background: rgba(0, 0, 0, .65); border-color: transparent; color: #fff;
}
.tile-tools button.on { background: var(--bad); }
.video-grid:not(.callview) .tile-pin { display: none; }
.tile.pinned .tile-pin { background: var(--accent); color: var(--accent-ink); }

/* --- full-screen call view --- */
body.callview-open { overflow: hidden; }
.callview-overlay {
  position: fixed; inset: 0; z-index: 60; background: #000;
  display: grid; grid-template-rows: auto 1fr auto;
}
.cv-top {
  display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem;
  color: #fff; font-weight: 600; transition: opacity .25s;
}
.cv-count { color: var(--muted); font-weight: 500; }
.cv-status { color: #fff; background: var(--bad); padding: .15rem .6rem; border-radius: 6px; font-variant-numeric: tabular-nums; font-size: .85rem; }
.cv-stage { min-height: 0; padding: 0 .75rem; display: flex; }
.cv-bar {
  display: flex; justify-content: center; gap: .6rem; padding: .7rem 1rem 1rem; transition: opacity .25s;
}
.callview-overlay.idle .cv-bar, .callview-overlay.idle .cv-top { opacity: 0; }
.callview-overlay.idle { cursor: none; }
.cv-btn {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  min-width: 78px; padding: .5rem .7rem; border-radius: 10px;
  background: #1f252d; border-color: #2a313b; color: #fff; font-size: .78rem; font-weight: 600;
}
.cv-btn svg { width: 24px; height: 24px; }
.cv-btn.off { background: #3a1d1f; border-color: #6b2a2e; color: #ffb3b3; }
.cv-btn:disabled { opacity: .6; }
.cv-btn.danger-btn { background: var(--bad); border-color: var(--bad); }

.video-grid.callview {
  flex: 1; min-height: 0; max-width: none !important; width: 100%; height: 100%;
  gap: .5rem; margin: 0;
}
.video-grid.callview .tile { aspect-ratio: auto; border-radius: 12px; min-height: 0; cursor: pointer; }
.video-grid.callview .tile-label { font-size: .9rem; }
.video-grid.callview .tile video { object-fit: cover; }

/* gallery: equal tiles sized to fit the screen */
.video-grid.callview.gallery, .video-grid.callview:not(.speaker) {
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
  align-content: center;
}

/* speaker: one large tile, everyone else in a centred strip underneath */
.video-grid.callview.speaker {
  grid-template-columns: minmax(0, 1fr) repeat(var(--strip, 1), minmax(0, 210px)) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 118px;
}
.video-grid.callview.speaker .tile.stage {
  grid-column: 1 / -1; grid-row: 1;
  width: 100%; justify-self: center; max-width: calc((100vh - 270px) * 16 / 9);
  cursor: default;
}
.video-grid.callview.speaker .tile.stage video { object-fit: contain; background: #000; }
.video-grid.callview.speaker .tile:not(.stage) .tile-label { font-size: .72rem; left: .3rem; bottom: .3rem; }
.video-grid.callview.speaker .tile:not(.stage) .avatar { font-size: 1.4rem; }
.video-grid.callview.speaker .tile:not(.stage) .tile-tools button { padding: .15rem .4rem; font-size: .68rem; }
@media (max-width: 600px) {
  .cv-btn { min-width: 0; flex: 1; padding: .45rem .3rem; font-size: .7rem; }
  .video-grid.callview.speaker {
    grid-template-columns: minmax(0, 1fr) repeat(var(--strip, 1), minmax(0, 130px)) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 80px;
    gap: .35rem;
  }
  .video-grid.callview.speaker .tile.stage { max-width: none; }
  .video-grid.callview.speaker .tile:not(.stage) .avatar { font-size: .9rem; inset: 0 0 1.25rem 0; background: radial-gradient(circle at 50% 50%, hsl(var(--h, 210) 35% 30%) 0 34%, transparent 35%), #11151b; }
  .video-grid.callview.speaker .tile:not(.stage) .tile-label { font-size: .62rem; padding: .05rem .3rem; }
  .video-grid.callview.speaker .tile:not(.stage) .tile-mic { font-size: .58rem; }
}

/* admin: accent picker */
.branding-cell input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.branding-cell .linklike { font-size: .78rem; color: var(--muted); }

/* --- per-user branding --- */
.brand-logo { display: block; max-height: 34px; max-width: 220px; width: auto; height: auto; object-fit: contain; }
header.bar h1.has-logo { line-height: 0; }
.brand { display: inline-flex; align-items: center; }
.brand .brand-logo { max-height: 30px; max-width: 160px; }
.guest-brand { display: flex; justify-content: center; margin: -.25rem 0 1rem; }
.guest-brand .brand-logo { max-height: 56px; max-width: 260px; }
.cv-logo { max-height: 26px; max-width: 140px; object-fit: contain; }
.branding-cell { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.branding-cell .logo-thumb {
  height: 28px; max-width: 90px; object-fit: contain; border-radius: 4px;
  background: repeating-conic-gradient(#2a313b 0 25%, #1f252d 0 50%) 50% / 10px 10px;
}
.branding-cell button { padding: .3rem .55rem; font-size: .78rem; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }

.live-devices { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.live-devices label { margin: .5rem 0; }
.live-devices label:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (max-width: 600px) { .live-devices { grid-template-columns: 1fr; } }

.branding-cell .hex-input {
  width: 6.4rem; margin: 0; padding: .35rem .5rem; font-size: .85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase;
}
.branding-cell .hex-input.invalid { border-color: var(--bad); }

/* --- reconnecting --- */
.pill.warn { background: rgba(242, 201, 76, .15); color: var(--warn); }
.banner.warn { background: rgba(242, 201, 76, .12); border-color: var(--warn); color: #ffe7a3; }
.strip.reconnecting { opacity: .55; border-style: dashed; border-color: var(--warn); }
.strip.reconnecting .status { color: var(--warn); }

/* --- chat --- */
.badge {
  display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .35rem;
  border-radius: 999px; background: var(--bad); color: #fff;
  font-size: .72rem; line-height: 1.25rem; text-align: center; font-weight: 700; letter-spacing: 0;
  vertical-align: middle;
}
.chat { display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.chat-log { list-style: none; margin: 0; padding: 0 .1rem 0 0; overflow-y: auto; max-height: 260px; display: flex; flex-direction: column; gap: .55rem; }
.chat-empty { margin: .2rem 0; }
.chat-msg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; }
.chat-msg.mine { background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.chat-msg.private { border-style: dashed; border-color: var(--warn); }
.chat-head { display: flex; align-items: baseline; gap: .45rem; font-size: .78rem; margin-bottom: .1rem; }
.chat-who { font-weight: 700; color: var(--text); background: none; border: 0; padding: 0; font-size: .8rem; cursor: pointer; }
span.chat-who { cursor: default; }
button.chat-who:hover { text-decoration: underline; }
.chat-private { color: var(--warn); font-weight: 600; }
.chat-time { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.35; }
.chat-form { display: flex; flex-direction: column; gap: .4rem; }
.chat-to { margin: 0; padding: .35rem .5rem; font-size: .82rem; }
.chat-to.private { border-color: var(--warn); color: var(--warn); }
.chat-row { display: flex; gap: .4rem; align-items: flex-end; }
.chat-input {
  flex: 1; resize: none; margin: 0; min-height: 38px; max-height: 120px; padding: .5rem .65rem;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: .92rem;
}
.chat-send { padding: .5rem .9rem; }
.chat-error { margin: 0; font-size: .82rem; }
#live .chat-log { max-height: 220px; }

/* chat drawer in the full-screen view */
.cv-drawer {
  position: fixed; top: 3.2rem; right: .75rem; bottom: 6.2rem; width: min(360px, 92vw); z-index: 2;
  background: #12161c; border: 1px solid var(--line); border-radius: 12px; padding: .75rem;
  display: flex; flex-direction: column;
}
.cv-drawer .chat { flex: 1; }
.cv-drawer .chat-log { max-height: none; flex: 1; }
.callview-overlay.chat-open .cv-stage { padding-right: calc(min(360px, 92vw) + 1.5rem); }
.callview-overlay.idle.chat-open .cv-bar, .callview-overlay.idle.chat-open .cv-top { opacity: 1; }
.cv-btn { position: relative; }
.cv-btn .badge { position: absolute; top: .2rem; right: .35rem; margin: 0; }
.cv-btn.on { border-color: var(--accent); }
@media (max-width: 600px) {
  .cv-drawer { left: .5rem; right: .5rem; width: auto; top: 3rem; bottom: 5.5rem; }
  .callview-overlay.chat-open .cv-stage { padding-right: .75rem; visibility: hidden; }
}

/* recordings kept in the browser (crash-safe) */
#local-recs { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
#local-recs h3 { margin: 0 0 .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.local-recs { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .6rem; }
.local-recs li { background: var(--panel-2, rgba(255,255,255,.03)); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; display: grid; gap: .45rem; }
.lr-head { display: grid; gap: .1rem; font-size: .9rem; }
.lr-head .hint { margin: 0; font-size: .8rem; }
.local-recs .row button { padding: .35rem .7rem; font-size: .85rem; }
.local-recs details summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.local-recs details a { display: block; font-size: .85rem; padding: .15rem 0 .15rem .9rem; word-break: break-all; }

/* recording indicators + server backups */
.pill.rec { background: rgba(229, 72, 77, .15); color: #ff8a8d; margin-right: .4rem; font-weight: 600; }
.warn-text { color: #f0c96b; }
.backup-toggle { margin-top: .6rem; font-size: .9rem; }
#backup-status { margin: .25rem 0 0; min-height: 0; }
#server-recs { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
#server-recs h3 { margin: 0 0 .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.lr-files { display: flex; flex-wrap: wrap; gap: .35rem; }
.lr-files a { font-size: .82rem; padding: .25rem .55rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); background: var(--panel); }
.lr-files a::before { content: '↓ '; color: var(--accent); }
.lr-files a:hover { border-color: var(--accent); }
.lr-files a.muted-link { color: var(--muted); }

/* ---------- pre-call check (guest) ---------- */
.precheck { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem 1rem; margin: 1rem 0; background: var(--panel-2); }
.precheck-head h2 { margin: 0; font-size: .95rem; }
.precheck-head .hint { display: block; margin: .15rem 0 0; }
.checks { list-style: none; margin: .8rem 0 .4rem; padding: 0; display: grid; gap: .55rem; }
.checks li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; align-items: start; }
.checks li > div { display: grid; gap: .1rem; }
.checks li b { font-size: .92rem; }
.ck-msg { font-size: .85rem; color: var(--muted); line-height: 1.35; }
.ck-icon { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 700; margin-top: .05rem; }
.checks li[data-state="running"] .ck-icon { border-color: var(--accent); border-top-color: transparent; animation: ckspin .8s linear infinite; }
.checks li[data-state="ok"] .ck-icon { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }
.checks li[data-state="ok"] .ck-icon::after { content: '✓'; }
.checks li[data-state="fixed"] .ck-icon { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }
.checks li[data-state="fixed"] .ck-icon::after { content: '✓'; }
.checks li[data-state="warn"] .ck-icon { background: #8a6a12; border-color: #8a6a12; color: #fff; }
.checks li[data-state="warn"] .ck-icon::after { content: '!'; }
.checks li[data-state="bad"] .ck-icon { background: #a3282d; border-color: #a3282d; color: #fff; }
.checks li[data-state="bad"] .ck-icon::after { content: '✕'; }
.checks li[data-state="ok"] .ck-msg, .checks li[data-state="fixed"] .ck-msg { color: var(--text); }
.checks li[data-state="warn"] .ck-msg { color: #f0c96b; }
.checks li[data-state="bad"] .ck-msg { color: #ff8a8d; }
@keyframes ckspin { to { transform: rotate(360deg); } }
.ck-prompt { margin: .6rem 0 .4rem; padding: .7rem .8rem; border-radius: 10px; background: rgba(61, 139, 253, .12); border: 1px solid rgba(61, 139, 253, .4); font-weight: 600; font-size: .95rem; }
.precheck .guest-meter { margin: .4rem 0 .6rem; }
.ck-summary { margin: .2rem 0 .7rem; font-weight: 600; font-size: .9rem; }
.ck-summary.ok { color: #4fd18b; }
.ck-summary.warn { color: #f0c96b; }

/* ---------- pre-call check (host strips) ---------- */
.precheck-badges { display: flex; flex-wrap: nowrap; gap: .2rem; justify-content: center; height: 1.15rem; overflow: hidden; margin: .1rem 0 .3rem; }
.ckb { font-size: .68rem; font-weight: 600; line-height: 1; padding: .2rem .4rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; cursor: help; }
.ckb.ok { color: #4fd18b; border-color: rgba(79, 209, 139, .35); }
.ckb.warn { color: #1b1404; border-color: #e0b54f; background: #e0b54f; }
.ckb.bad { color: #fff; border-color: #c9393f; background: #c9393f; }
.ckb.none { font-style: italic; }
.strip.flash { animation: stripflash 0.6s ease-in-out 4; }
@keyframes stripflash { 50% { box-shadow: 0 0 0 2px #f0c96b; } }
