:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1f252d;
  --line: #2b323c;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #f2b233;
  --accent-ink: #1a1405;
  --ok: #3ccf7a;
  --bad: #ef5350;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 16px; }
.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--bad); }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 42px;
}
textarea { width: 100%; min-height: 60px; resize: vertical; }
button { cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.recording { background: var(--bad); border-color: var(--bad); color: #fff; }

/* join */
.join { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.card form { display: grid; gap: 14px; margin-top: 18px; }
.card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }

/* app */
#app { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; gap: 8px; margin-left: auto; }
.stats { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid currentColor; }
.pill.on { color: var(--ok); }
.pill.off { color: var(--bad); }

.layout { flex: 1; display: grid; grid-template-columns: auto minmax(280px, 1fr); gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.stage { display: flex; flex-direction: column; gap: 10px; min-width: min(420px, 100%); max-width: 100%; }
.video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; width: 640px; height: 480px; max-width: 100%; }
.video-wrap:fullscreen { width: 100vw !important; height: 100vh !important; max-width: none; border-radius: 0; }
.resize-handle { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; touch-action: none; z-index: 3;
  background: linear-gradient(135deg, transparent 0 45%, rgba(255,255,255,.55) 45% 52%, transparent 52% 64%, rgba(255,255,255,.55) 64% 71%, transparent 71% 83%, rgba(255,255,255,.55) 83% 90%, transparent 90%); }
.video-wrap:fullscreen .resize-handle { display: none; }
.view-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; z-index: 3; }
.video-wrap:hover .view-tools, .view-tools:focus-within { opacity: 1; }
@media (hover: none) { .view-tools { opacity: 1; } }
.view-tools button { min-height: 0; padding: 4px 9px; font-size: 12px; background: rgba(15,18,22,.75); }
.view-tools button.off { color: var(--muted); }
.video-wrap.resizing { outline: 2px solid var(--accent); }
#view { width: 100%; height: 100%; object-fit: contain; display: block; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; }
.rec { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.6); color: var(--bad); padding: 4px 10px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.controls input { flex: 1 1 220px; min-width: 0; }

.gallery { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-y: auto; max-height: calc(100vh - 100px); }
@media (max-width: 900px) { .gallery { max-height: none; } }
#captures { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cap { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cap img, .cap video { width: 100%; display: block; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.cap-body { padding: 8px 10px 10px; display: grid; gap: 6px; }
.cap-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.cap-btns { display: flex; gap: 6px; flex-shrink: 0; }
.cap-meta button { min-height: 0; padding: 2px 8px; font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

.voice { align-items: center; }
button.on { background: var(--ok); border-color: var(--ok); color: #06210f; font-weight: 600; }
.small { font-size: 13px; }
.meter { width: 90px; height: 10px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0%; background: var(--ok); transition: width .08s linear; }
.log-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }
.log-box summary { cursor: pointer; color: var(--muted); }
.log-box pre { max-height: 220px; overflow: auto; white-space: pre-wrap; font-size: 12px; margin: 8px 0; }
.log-box a { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
