:root {
  --bg: #0f1218; --panel: #171b23; --panel-2: #1e232d; --line: #2a303c;
  --text: #e6e9ef; --muted: #8b93a3; --accent: #3b82f6; --accent-2: #2563eb;
  --danger: #ef4444; --ok: #22c55e; --warn: #f59e0b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.grow { flex: 1; }
.caption { color: var(--muted); font-size: 12px; margin: 0; }
.error { color: #fca5a5; margin: 0; font-size: 13px; }
h1 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { border-color: #3a4252; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-2); }
button.danger { color: #fecaca; border-color: #7f1d1d; }
button.danger:hover { background: #3b1414; }
button.active { border-color: var(--accent); color: #bfdbfe; }
button.small { padding: 2px 8px; font-size: 12px; }
input[type=text] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%;
}
input[type=text]:focus { outline: none; border-color: var(--accent); }

/* ── Join ── */
.join { height: 100%; display: grid; place-items: center; padding: 16px; overflow: auto; }
.card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 8px;
}
.card label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.card .code { font-size: 22px; letter-spacing: .12em; text-align: center; font-variant-numeric: tabular-nums; }
.card button { margin-top: 10px; padding: 10px; }

/* ── Session ── */
.session { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.toolbar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.status { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.notice { padding: 6px 12px; font-size: 13px; background: #172554; color: #bfdbfe; border-bottom: 1px solid var(--line); }
.banner { padding: 6px 12px; background: #3b1414; border-bottom: 1px solid var(--line); }
.body { flex: 1; display: flex; min-height: 0; }

.stage { flex: 1; position: relative; background: #000; min-width: 0; outline: none; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage.controlling video { cursor: crosshair; }
.stage.controlling { box-shadow: inset 0 0 0 2px var(--accent); }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.rec-badge {
  position: absolute; top: 10px; left: 10px; background: rgba(220, 38, 38, .9); color: #fff;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; pointer-events: none;
}

.side { width: 320px; max-width: 45%; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
.panel + .panel { border-top: 1px solid var(--line); }
.panel.chat { flex: 1; }
.panel.files { flex: 1; overflow: auto; }
.panel-head { display: flex; align-items: center; gap: 8px; }

/* Chat */
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.chat-empty { color: var(--muted); font-size: 12px; text-align: center; margin: auto; }
.msg { max-width: 90%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  white-space: pre-wrap; word-break: break-word; text-align: left;
}
.msg.mine .bubble { background: #1e3a8a; border-color: #1e40af; }
.chat-form { display: flex; gap: 6px; }

/* Files */
.offer { background: var(--panel-2); border: 1px solid var(--warn); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.offer-title { margin: 0; word-break: break-word; }
.row { display: flex; gap: 6px; justify-content: flex-end; }
.xfer-list { display: flex; flex-direction: column; gap: 8px; }
.xfer { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.xfer.failed { border-color: #7f1d1d; }
.xfer-top, .xfer-bottom { display: flex; align-items: center; gap: 6px; }
.xfer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer-status { flex: 1; }
.xfer progress { width: 100%; height: 6px; }

.dropzone {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: rgba(37, 99, 235, .25); border: 3px dashed var(--accent); font-size: 18px; color: #fff;
}

@media (max-width: 700px) {
  .body { flex-direction: column; }
  .side { width: auto; max-width: none; height: 45%; border-left: 0; border-top: 1px solid var(--line); }
}
