:root {
  --bg: #0b0f14; --card: #151b23; --line: #263040; --text: #e6edf3; --muted: #8b98a8;
  --accent: #14b8a6; --accent-d: #0f766e; --danger: #e5484d; --warn: #f5a524; --tile: #1c2430;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.view { min-height: 100%; }
.center { display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  width: min(420px, 100%); }
.card.wide { width: min(900px, 100%); }
h1 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 26px; }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 0; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1em; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.gap { gap: 10px; } .end { justify-content: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.row { flex-direction: row; color: var(--text); }
input, select { background: #0e141b; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font: inherit; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: #1f2833; color: var(--text); font: inherit;
  cursor: pointer; text-decoration: none; }
.btn:hover { background: #283342; }
.btn.primary { background: var(--accent-d); border-color: var(--accent-d); }
.btn.primary:hover { background: var(--accent); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.pre-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 720px) { .pre-grid { grid-template-columns: 1fr; } }
.preview { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.novideo { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.pre-ctl { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; font: 600 13px system-ui; cursor: pointer;
  background: #2b3542; color: #fff; }
.round.off { background: var(--danger); }
.meter { position: absolute; left: 12px; top: 12px; width: 6px; height: 60px; background: #0006; border-radius: 3px;
  display: flex; align-items: flex-end; }
.meter i { display: block; width: 100%; height: 0; background: var(--accent); border-radius: 3px; }
.spinner { width: 36px; height: 36px; margin: 16px auto; border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* meeting */
.room { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr) auto; overflow: hidden; }
.room > .topbar { grid-row: 1; } .room > .banner { grid-row: 2; } .room > .stage { grid-row: 3; grid-column: 1; }
.room > .bar { grid-row: 4; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); min-width: 0; }
.topbar .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #3a2a07; color: var(--warn); }
.banner { grid-column: 1 / -1; padding: 6px 16px; background: #0f2a28; color: #99f6e4; font-size: 13px; }
.stage { position: relative; min-height: 0; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.spot { flex: 3; min-height: 0; }
.spot .tile { width: 100%; height: 100%; }
.spot:not([hidden]) + .grid { flex: 1; grid-auto-flow: column; grid-auto-columns: minmax(160px, 220px);
  grid-template-columns: none !important; overflow-x: auto; }
.grid { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-auto-rows: minmax(0, 1fr); align-content: stretch; }
.tile { position: relative; background: var(--tile); border-radius: 10px; overflow: hidden; min-height: 120px;
  border: 2px solid transparent; transition: border-color .15s; }
.tile.speaking { border-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.tile.screen video { object-fit: contain; }
.tile.mirror video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .avatar span { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; font-weight: 600; background: #2c3a4b; }
.tile .name { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 2px 8px;
  border-radius: 6px; background: #000a; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .q { position: absolute; right: 8px; top: 8px; font-size: 12px; padding: 2px 6px; border-radius: 6px;
  background: #000a; color: var(--warn); }
.tile .mic-off { color: var(--danger); margin-left: 4px; }

.panel { grid-row: 3; grid-column: 2; width: 320px; border-left: 1px solid var(--line); display: flex;
  flex-direction: column; min-height: 0; background: var(--card); }
@media (max-width: 720px) {
  .panel { position: fixed; inset: 0 0 64px 0; width: auto; z-index: 5; }
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 10px; background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.tab.on { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.tab.x { flex: 0 0 44px; font-size: 20px; }
.tabbody { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#tab-chat { padding: 0; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; }
.people li:hover { background: #1c2430; }
.people .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #1f3b38; color: #5eead4; }
.badge.dep { background: #2a2a45; color: #b4b4ff; }
.people select { padding: 4px; font-size: 12px; }
.lobby-item { display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 8px; background: #2a2207; }
.lobby-item b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chatlog { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg .who { font-size: 12px; color: var(--muted); }
.msg .txt { white-space: pre-wrap; word-break: break-word; }
.chatform { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chatform input { flex: 1; }

.bar { grid-column: 1 / -1; display: flex; justify-content: center; gap: 6px; padding: 8px;
  border-top: 1px solid var(--line); overflow-x: auto; }
.ctl { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px;
  padding: 6px 10px; border-radius: 10px; border: 0; background: #1f2833; color: var(--text); font: 12px system-ui; cursor: pointer; }
.ctl .ic { font-size: 18px; line-height: 1; }
.ctl.off { background: var(--danger); }
.ctl.on { background: var(--accent-d); }
.ctl.warn { background: #6b4a05; }
.ctl.danger { background: #5a1d20; }
.ctl .dot { position: absolute; top: 4px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
@media (max-width: 560px) { .ctl span:not(.ic) { display: none; } .ctl { min-width: 44px; } .topbar .btn { display: none; } }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  width: min(380px, calc(100% - 32px)); }
dialog::backdrop { background: #0008; }
.toasts { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column;
  gap: 6px; z-index: 10; width: min(420px, calc(100% - 32px)); }
.toast { background: #22303f; border: 1px solid var(--line); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
