:root {
  --bg: #f4f6fb; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #4f46e5; --brand-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #dc2626;
  --room: #0b1020; --tile: #1a2035; --tile-line: #2a3350;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; } h2 { font-size: 17px; margin: 0 0 12px; } h4 { margin: 14px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
code { background: #eef2ff; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.top { display: flex; align-items: center; gap: 22px; padding: 12px 20px; background: #0f172a; color: #e2e8f0; flex-wrap: wrap; }
.top a { color: #e2e8f0; text-decoration: none; }
.brand { font-weight: 700; font-size: 17px; }
.top nav { display: flex; gap: 16px; } .top nav a:hover { color: #fff; }
.me { margin-left: auto; font-size: 13px; color: #94a3b8; } .me a { color: #c7d2fe; }
.wrap { max-width: 1100px; margin: 22px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
details.card summary { cursor: pointer; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); max-width: 100%; }
.check { display: flex; align-items: center; gap: 8px; }
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); } .btn:disabled { opacity: .6; cursor: default; }
.btn.big { padding: 12px 20px; font-size: 16px; } .btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid #c7d2fe; }
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px; }
.list td { border-bottom: 1px solid #f1f5f9; padding: 9px 8px; vertical-align: top; }
.list tr.off td { opacity: .5; }
@media (max-width: 640px) { .list { display: block; overflow-x: auto; } }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #f1f5f9; color: #475569; }
.pill.live { background: #fee2e2; color: var(--bad); } .pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); } .pill.bad { background: #fee2e2; color: var(--bad); }
.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.okbox { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.warnbox { border-color: #fcd34d; background: #fffbeb; }
.pre { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 14px; max-height: 560px; overflow: auto; }
.pre.sel { user-select: all; font-family: ui-monospace, Menlo, monospace; }
.md p, .md li { margin: 4px 0; } .md ul, .md ol { padding-left: 22px; }
.tabs { display: flex; gap: 6px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.tab.on { background: #eef2ff; border-color: #c7d2fe; color: var(--brand); font-weight: 600; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 420px; text-align: center; } .login .stack { text-align: left; }

/* ─── Room ─────────────────────────────────────────────────────────────── */
body.bare:has(.room) { background: var(--room); color: #e2e8f0; }
.room { min-height: 100vh; display: flex; flex-direction: column; }
.room-top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap; }
.room-title { font-weight: 600; } .room .muted { color: #94a3b8; }
.rec { background: rgba(220, 38, 38, .15); color: #fca5a5; border: 1px solid rgba(220, 38, 38, .4); border-radius: 999px; padding: 3px 12px; font-size: 13px; }
.room-top .btn.ghost { margin-left: auto; color: #c7d2fe; border-color: #3b4466; }
.prejoin { max-width: 440px; margin: 8vh auto; color: var(--ink); }
.prejoin.card .muted { color: var(--muted); }
.stage { flex: 1; display: flex; gap: 12px; padding: 0 12px 12px; min-height: 0; }
.tiles { flex: 1; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); grid-auto-rows: minmax(180px, 1fr); align-content: center; }
.tiles.n1 { grid-template-columns: minmax(0, 900px); justify-content: center; }
.tiles.with-screen { grid-template-columns: 1fr 220px; grid-auto-rows: 150px; }
.tiles.with-screen .tile.screen { grid-column: 1; grid-row: 1 / span 6; }
@media (max-width: 760px) {
  .stage { flex-direction: column; }
  .tiles, .tiles.with-screen { grid-template-columns: 1fr 1fr; grid-auto-rows: 140px; }
  .tiles.with-screen .tile.screen { grid-column: 1 / span 2; grid-row: auto; height: 240px; }
  .tiles.n1 { grid-template-columns: 1fr; }
}
.tile { position: relative; background: var(--tile); border: 2px solid var(--tile-line); border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tile.speaking { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tile.screen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile.has-video video { display: block; } .tile.has-video .av { display: none; }
.av { width: 84px; height: 84px; border-radius: 50%; background: #4f46e5; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 700; }
.av.sm { width: 28px; height: 28px; font-size: 12px; display: inline-flex; margin-right: 8px; vertical-align: middle; }
.nm { position: absolute; left: 10px; bottom: 8px; background: rgba(0, 0, 0, .55); padding: 2px 10px; border-radius: 6px; font-size: 13px; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side { width: 330px; background: #111830; border: 1px solid var(--tile-line); border-radius: 14px; display: flex; flex-direction: column; padding: 10px; gap: 8px; }
@media (max-width: 760px) { .side { width: 100%; min-height: 300px; } }
.side .tab { background: transparent; color: #cbd5e1; border-color: #2a3350; } .side .tab.on { background: #1e2747; color: #fff; }
.side-tabs { display: flex; gap: 6px; }
.side-p { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.side textarea { flex: 1; min-height: 260px; resize: none; background: #0b1020; color: #e2e8f0; border-color: #2a3350; }
.people { list-style: none; margin: 0; padding: 0; } .people li { padding: 6px 2px; border-bottom: 1px solid #1e2747; }
.bar { display: flex; justify-content: center; gap: 10px; padding: 12px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--room); }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; padding: 8px 10px; border-radius: 12px; border: 1px solid #2a3350;
  background: #1a2035; color: #e2e8f0; font: inherit; font-size: 18px; cursor: pointer; }
.cbtn span { font-size: 11.5px; }
.cbtn.on { background: #1e2a5a; border-color: #4f46e5; }
#bMic:not(.on) { background: #3b1520; border-color: #dc2626; }
.cbtn.danger { background: #b91c1c; border-color: #b91c1c; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #0f172a; color: #fff; border: 1px solid #334155; padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }
