:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #121a2d;
  --panel-2: #182238;
  --text: #f4f7fb;
  --muted: #9eabc3;
  --line: #28344c;
  --accent: #5d8cff;
  --accent-2: #7aa2ff;
  --good: #33c481;
  --danger: #ef5a67;
  --warn: #f3b548;
  --shadow: 0 18px 50px rgba(0,0,0,.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin:0; min-height:100vh; background:linear-gradient(180deg,#090e1b,#0d1425); color:var(--text); }
button,input,textarea { font:inherit; }
button { cursor:pointer; }
.hidden { display:none !important; }
.muted { color:var(--muted); }
.shell { min-height:100vh; display:flex; flex-direction:column; }
.topbar { min-height:64px; padding:12px 22px; display:flex; align-items:center; justify-content:space-between; gap:16px; border-bottom:1px solid var(--line); background:rgba(9,14,27,.86); backdrop-filter:blur(10px); position:sticky; top:0; z-index:20; }
.brand { display:flex; align-items:center; gap:12px; min-width:0; }
.logo { width:36px; height:36px; display:grid; place-items:center; border-radius:10px; background:var(--accent); font-weight:800; }
.brand h1 { margin:0; font-size:18px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.badge { display:inline-flex; align-items:center; gap:7px; border-radius:999px; padding:7px 11px; font-size:12px; font-weight:700; background:var(--panel-2); color:var(--muted); }
.badge.live { background:rgba(239,90,103,.15); color:#ff9da6; }
.badge.live::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--danger); box-shadow:0 0 0 5px rgba(239,90,103,.12); }
.main { width:min(1440px,100%); margin:0 auto; padding:22px; flex:1; }
.join-wrap { max-width:640px; margin:7vh auto; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:18px; box-shadow:var(--shadow); }
.join-card { padding:30px; }
.join-card h2 { margin:0 0 10px; font-size:28px; }
.join-card p { color:var(--muted); line-height:1.6; }
.form-grid { display:grid; gap:14px; margin-top:24px; }
label { display:grid; gap:7px; font-size:13px; font-weight:650; color:#d6deec; }
input, textarea { width:100%; border:1px solid var(--line); background:#0e1627; color:var(--text); border-radius:11px; padding:11px 12px; outline:none; }
textarea { min-height:100px; resize:vertical; }
input:focus, textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(93,140,255,.15); }
.btn { border:1px solid transparent; border-radius:11px; padding:10px 14px; font-weight:750; color:white; background:var(--accent); }
.btn:hover { filter:brightness(1.06); }
.btn.secondary { background:var(--panel-2); border-color:var(--line); color:#e3e9f4; }
.btn.danger { background:var(--danger); }
.btn.good { background:var(--good); }
.btn.warn { background:var(--warn); color:#1c160a; }
.btn.small { padding:7px 10px; font-size:12px; border-radius:9px; }
.btn:disabled { cursor:not-allowed; opacity:.45; filter:none; }
.error { color:#ff9da6; min-height:20px; font-size:13px; }
.webinar-grid { display:grid; grid-template-columns:minmax(0,1fr) 360px; gap:18px; align-items:stretch; }
.stage-card { overflow:hidden; min-width:0; }
.video-stage { background:#03050a; aspect-ratio:16/9; display:grid; place-items:center; position:relative; overflow:hidden; }
.video-stage video { width:100%; height:100%; object-fit:contain; background:#020308; }
.video-placeholder { position:absolute; inset:0; display:grid; place-items:center; color:#78869e; text-align:center; padding:24px; }
.stage-meta { padding:16px 18px; display:flex; align-items:center; justify-content:space-between; gap:14px; }
.stage-title { min-width:0; }
.stage-title h2 { font-size:18px; margin:0 0 5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stage-title p { margin:0; color:var(--muted); font-size:13px; }
.controls { display:flex; gap:9px; flex-wrap:wrap; justify-content:flex-end; }
.chat-card { display:flex; flex-direction:column; min-height:560px; max-height:calc(100vh - 108px); }
.chat-head { padding:16px 17px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
.chat-head h3 { margin:0; font-size:16px; }
.chat-list { flex:1; min-height:0; overflow:auto; padding:14px; display:flex; flex-direction:column; gap:10px; }
.msg { padding:10px 11px; border:1px solid var(--line); border-radius:12px; background:#0e1627; }
.msg.admin { border-color:rgba(93,140,255,.55); background:rgba(93,140,255,.10); }
.msg-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:4px; }
.msg-name { font-size:12px; font-weight:800; color:#dfe7f6; }
.msg-time { color:#6f7d96; font-size:10px; }
.msg-body { font-size:14px; line-height:1.45; word-break:break-word; white-space:pre-wrap; }
.msg-actions { margin-top:7px; display:flex; gap:6px; }
.chat-form { border-top:1px solid var(--line); padding:12px; display:flex; gap:8px; }
.chat-form input { min-width:0; }
.chat-note { padding:10px 14px; font-size:12px; color:var(--muted); border-top:1px solid var(--line); }
.audio-bin { display:none; }

.admin-layout { display:grid; grid-template-columns:360px minmax(0,1fr); gap:18px; align-items:start; }
.stack { display:grid; gap:18px; }
.panel { padding:18px; }
.panel h2,.panel h3 { margin:0 0 14px; }
.row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.row.space { justify-content:space-between; }
.switch-row { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:10px 0; border-bottom:1px solid var(--line); }
.switch-row:last-child { border-bottom:0; }
.switch { width:44px; height:24px; position:relative; }
.switch input { display:none; }
.switch span { position:absolute; inset:0; border-radius:999px; background:#344057; transition:.2s; }
.switch span::after { content:""; width:18px; height:18px; border-radius:50%; position:absolute; left:3px; top:3px; background:white; transition:.2s; }
.switch input:checked + span { background:var(--accent); }
.switch input:checked + span::after { transform:translateX(20px); }
.kpi-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.kpi { border:1px solid var(--line); background:#0e1627; border-radius:12px; padding:12px; }
.kpi strong { display:block; font-size:22px; }
.kpi span { color:var(--muted); font-size:11px; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; font-size:13px; }
th,td { padding:10px 9px; text-align:left; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
.admin-video { aspect-ratio:16/9; background:#03050a; border-radius:14px; overflow:hidden; display:grid; place-items:center; }
.admin-video video { width:100%; height:100%; object-fit:contain; }
.login-overlay { position:fixed; inset:0; z-index:100; background:rgba(4,7,14,.88); display:grid; place-items:center; padding:20px; }
.login-box { width:min(420px,100%); padding:26px; }
.status-line { min-height:20px; color:var(--muted); font-size:12px; }

@media (max-width:1050px) {
  .webinar-grid { grid-template-columns:1fr; }
  .chat-card { min-height:420px; max-height:620px; }
  .admin-layout { grid-template-columns:1fr; }
}
@media (max-width:680px) {
  .main { padding:12px; }
  .topbar { padding:10px 12px; }
  .stage-meta { align-items:flex-start; flex-direction:column; }
  .controls { justify-content:flex-start; }
  .join-card { padding:20px; }
  .kpi-grid { grid-template-columns:1fr 1fr; }
}

/* --- Studio prowadzącego / układ chatu --- */
.spacer-12 { height:12px; }
.small-text { font-size:12px; line-height:1.45; }
.admin-sidebar { min-width:0; }
.admin-workspace { min-width:0; }
.studio-grid {
  display:grid;
  grid-template-columns:minmax(0,1fr) 390px;
  gap:18px;
  align-items:stretch;
}
.host-panel { min-width:0; }
.host-panel-head { margin-bottom:14px; }
.host-panel-head h2 { margin:0; }
.admin-chat-card { min-height:640px; max-height:calc(100vh - 108px); }
.host-live-controls { margin-top:14px; display:grid; gap:8px; }
.preview-note { margin-top:8px; }
.device-test {
  margin-top:14px;
  padding:13px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#0e1627;
  display:grid;
  gap:10px;
}
.device-test-head { align-items:flex-start; }
.device-test-controls { align-items:center; }
.mic-meter-wrap { min-width:150px; flex:1; display:grid; gap:5px; }
.mic-meter { height:8px; border-radius:999px; overflow:hidden; background:#253149; }
.mic-meter span { display:block; height:100%; width:0; background:var(--good); transition:width .08s linear; }

/* Przełączniki ustawień: tekst i suwak nigdy na siebie nie nachodzą. */
.switch-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:16px;
}
.switch-copy { min-width:0; line-height:1.45; }
.switch { display:block; width:44px; min-width:44px; height:24px; justify-self:end; }

/* Miniatura podglądu nie wpływa na publikację kamery ani nagrywanie. */
.host-panel.preview-mini .admin-video {
  width:min(280px,100%);
  aspect-ratio:16/9;
  justify-self:end;
  margin-left:auto;
  border:1px solid var(--line);
  box-shadow:0 10px 28px rgba(0,0,0,.28);
}
.host-panel.preview-mini .device-test { margin-top:10px; }

@media (max-width:1280px) {
  .studio-grid { grid-template-columns:minmax(0,1fr) 340px; }
}
@media (max-width:1050px) {
  .studio-grid { grid-template-columns:1fr; }
  .admin-chat-card { min-height:420px; max-height:620px; }
}
@media (max-width:680px) {
  .host-panel-head { align-items:flex-start; }
  .device-test-head { align-items:flex-start; }
  .device-test-controls { align-items:stretch; flex-direction:column; }
  .mic-meter-wrap { width:100%; }
  .host-panel.preview-mini .admin-video { width:220px; }
}

/* --- Panel administratora: zakładki i kompaktowe studio --- */
.admin-tabs {
  display:flex;
  gap:8px;
  margin-bottom:18px;
  border-bottom:1px solid var(--line);
}
.admin-tab {
  border:0;
  border-bottom:2px solid transparent;
  background:transparent;
  color:var(--muted);
  padding:10px 13px;
  font-weight:750;
}
.admin-tab:hover { color:var(--text); }
.admin-tab.active { color:var(--text); border-bottom-color:var(--accent); }
.admin-tab-page { min-width:0; }

.badge.connected { background:rgba(51,196,129,.13); color:#8ee5bc; }

.studio-toolbar {
  margin-top:10px;
  min-height:42px;
  display:flex;
  align-items:center;
  gap:7px;
  flex-wrap:wrap;
  padding:8px;
  border:1px solid var(--line);
  background:#0e1627;
  border-radius:12px;
}
.icon-btn {
  width:34px;
  height:34px;
  display:inline-grid;
  place-items:center;
  flex:0 0 34px;
  border:1px solid var(--line);
  border-radius:9px;
  color:#fff;
  background:var(--panel-2);
  font-weight:800;
  line-height:1;
  cursor:pointer;
}
.icon-btn:hover { filter:brightness(1.08); }
.icon-btn.secondary { background:var(--panel-2); }
.icon-btn.good { background:var(--good); border-color:transparent; }
.icon-btn.danger { background:var(--danger); border-color:transparent; }
.icon-btn.warn { background:var(--warn); border-color:transparent; color:#1c160a; }
.icon-btn.active-media { box-shadow:0 0 0 3px rgba(51,196,129,.13); }
.icon-btn:disabled { opacity:.35; cursor:not-allowed; filter:none; }
.toolbar-separator { width:1px; align-self:stretch; min-height:24px; background:var(--line); margin:0 2px; }
.toolbar-spacer { flex:1; }
.recording-timer {
  display:inline-flex;
  align-items:center;
  min-width:94px;
  justify-content:center;
  padding:7px 9px;
  border-radius:9px;
  background:rgba(239,90,103,.13);
  color:#ff9da6;
  font-variant-numeric:tabular-nums;
  font-size:12px;
  font-weight:800;
}

.device-test-page { max-width:980px; margin:0 auto; }
.device-test-page h2 { margin-bottom:6px; }
.test-video { margin-top:18px; max-height:540px; }
.device-test-actions { display:flex; gap:9px; flex-wrap:wrap; margin-top:14px; }
.device-test-page .mic-meter-wrap { margin-top:16px; max-width:520px; }

.recordings-panel .download-btn { text-decoration:none; display:inline-block; white-space:nowrap; }
.recordings-panel td:first-child { max-width:520px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Podgląd miniaturowy nie wyłącza publikacji kamery ani nagrywania. */
.host-panel.preview-mini .admin-video {
  width:min(300px,100%);
  aspect-ratio:16/9;
  margin-left:auto;
  border:1px solid var(--line);
  box-shadow:0 10px 28px rgba(0,0,0,.28);
}

@media (max-width:680px) {
  .admin-tabs { overflow:auto; }
  .admin-tab { white-space:nowrap; }
  .studio-toolbar { gap:6px; }
  .toolbar-separator { display:none; }
  .recording-timer { order:20; width:100%; }
  .device-test-actions { flex-direction:column; align-items:stretch; }
}
