:root {
  --bg-deep: #15161a;
  --bg-tertiary: #1e1f22;
  --bg-secondary: #2b2d31;
  --bg-primary: #313338;
  --bg-elevated: #383a40;
  --hover: rgba(255,255,255,.06);
  --selected: rgba(255,255,255,.1);
  --border: rgba(255,255,255,.08);
  --text: #dbdee1;
  --muted: #949ba4;
  --white: #f2f3f5;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --yellow: #f0b232;
  --radius: 10px;
  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { border: 0; }
body { min-height: 100vh; overflow: hidden; background: var(--bg-primary); color: var(--text); font-family: var(--font); }
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

.lobby-view { min-height: 100vh; background:
  radial-gradient(circle at 50% 20%, rgba(88,101,242,.18), transparent 36%),
  linear-gradient(145deg, #191a1f, #23252b 58%, #1b1c21); }
.lobby-header { height: 72px; padding: 0 clamp(22px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--white); text-decoration: none; font-size: 20px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--brand); box-shadow: 0 8px 28px rgba(88,101,242,.32); }
.header-actions { display: flex; gap: 8px; }
.icon-button { position: relative; width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; font-size: 18px; }
.icon-button:hover { background: var(--selected); color: var(--white); }
.unread-dot { position: absolute; width: 8px; height: 8px; right: 7px; top: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px var(--bg-deep); }
.lobby-content { width: min(1480px, calc(100% - 56px)); min-height: calc(100vh - 128px); margin: auto; padding: 42px 0; display: grid; grid-template-columns: minmax(330px, 430px) minmax(0, 1fr); gap: clamp(38px, 6vw, 96px); align-items: stretch; }
.lobby-rooms-panel { min-height: 560px; padding: 24px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 20px; background: rgba(30,31,34,.72); box-shadow: 0 18px 54px rgba(0,0,0,.22); backdrop-filter: blur(14px); }
.lobby-rooms-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.lobby-rooms-header h2 { margin-top: 5px; color: var(--white); font-size: 23px; }
.rooms-refresh { flex: 0 0 auto; font-size: 19px; }
.lobby-nickname { margin-top: 22px; display: flex; flex-direction: column; gap: 7px; }
.lobby-nickname span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.rooms-summary { margin: 18px 2px 10px; color: var(--muted); font-size: 12px; }
.lobby-rooms-list { flex: 1; min-height: 0; align-content: start; overflow-y: auto; padding-right: 4px; }
.lobby-main-panel { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-copy { width: 100%; text-align: center; margin-bottom: 38px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: #aeb5ff; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.live-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(242,63,67,.14); }
.hero-copy h1 { margin-top: 16px; color: var(--white); font-size: clamp(42px, 6vw, 68px); line-height: 1.02; letter-spacing: -.04em; }
.hero-copy h1 span { color: #8d97ff; }
.hero-copy p { max-width: 560px; margin: 20px auto 0; color: var(--muted); font-size: 17px; line-height: 1.6; }
.lobby-actions { width: min(560px, 100%); display: grid; grid-template-columns: 1fr; gap: 16px; }
.action-card { min-height: 130px; padding: 24px; display: flex; align-items: center; gap: 18px; text-align: left; color: var(--text); background: rgba(43,45,49,.88); border: 1px solid var(--border); border-radius: 18px; cursor: pointer; box-shadow: 0 16px 46px rgba(0,0,0,.18); transition: transform .18s, border-color .18s, background .18s; }
.action-card:hover { transform: translateY(-3px); background: #303239; border-color: rgba(255,255,255,.16); }
.primary-card { background: linear-gradient(145deg, rgba(88,101,242,.98), rgba(71,82,196,.98)); border-color: rgba(255,255,255,.16); }
.primary-card:hover { background: linear-gradient(145deg, #6571f5, #4d59cc); }
.action-icon { flex: 0 0 auto; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: rgba(0,0,0,.2); font-size: 28px; }
.action-copy { flex: 1; display: flex; min-width: 0; flex-direction: column; }
.action-copy strong { color: white; font-size: 18px; }
.action-copy small { margin-top: 5px; color: rgba(219,222,225,.7); font-size: 13px; }
.action-arrow { font-size: 24px; opacity: .75; }
.lobby-note { margin: 22px auto 0; display: flex; gap: 10px; align-items: flex-start; max-width: 600px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.lobby-footer { height: 56px; padding: 0 clamp(22px,5vw,72px); display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); color: #71757d; font-size: 12px; }

.app-layout { height: 100vh; display: flex; overflow: hidden; }
.rooms-sidebar { width: 72px; flex: 0 0 72px; padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--bg-tertiary); }
.room-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-primary); color: var(--text); font-weight: 700; cursor: pointer; transition: .18s; }
button.room-icon:hover, .room-icon.active { border-radius: 16px; background: var(--brand); color: white; }
.home-icon { font-size: 19px; }
.room-divider { width: 32px; height: 2px; background: var(--selected); }
.sidebar-spacer { flex: 1; }
.utility-icon { color: #aeb5ff; }
.room-sidebar { width: 250px; flex: 0 0 250px; display: flex; flex-direction: column; background: var(--bg-secondary); }
.room-sidebar-header { min-height: 64px; padding: 11px 16px; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--border); }
.room-sidebar-header div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-sidebar-header strong { overflow: hidden; color: var(--white); white-space: nowrap; text-overflow: ellipsis; }
.room-sidebar-header small { margin: 2px 0 0 19px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.room-privacy { color: var(--green); font-size: 9px; }
.room-sidebar-content { flex: 1; overflow-y: auto; padding: 18px 10px; }
.section-label { margin: 0 8px 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.channel-item { width: 100%; padding: 9px 10px; display: flex; gap: 10px; align-items: center; border-radius: 5px; background: var(--selected); color: white; font-size: 14px; }
.share-panel { margin-top: 18px; padding: 12px; border-radius: 8px; background: #232428; border: 1px solid var(--border); }
.share-status { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 12px; }
.status-indicator { width: 8px; height: 8px; margin-top: 5px; flex: 0 0 auto; border-radius: 50%; background: var(--green); }
.share-status div { display: flex; flex-direction: column; min-width: 0; }
.share-status strong { color: var(--white); font-size: 12px; }
.share-status small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.presenter-toolbar { display: flex; flex-direction: column; gap: 9px; }
.live-row { display: flex; align-items: center; justify-content: space-between; color: var(--white); font-size: 12px; }
.live-row span { display: flex; align-items: center; gap: 7px; }
.stream-stats { color: var(--muted); font-family: var(--mono); font-size: 9px; line-height: 1.5; }
.toolbar-buttons { display: flex; gap: 6px; }
.toolbar-buttons .btn { flex: 1; }
.moderator-banner { padding: 8px 12px; background: rgba(240,178,50,.12); color: var(--yellow); border-top: 1px solid rgba(240,178,50,.2); text-align: center; font-size: 11px; font-weight: 700; }
.user-footer { min-height: 58px; padding: 9px 10px; display: flex; align-items: center; gap: 9px; background: #232428; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-weight: 700; }
.user-copy { display: flex; flex-direction: column; min-width: 0; }
.user-copy strong { overflow: hidden; color: var(--white); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.user-copy small { color: var(--muted); font-size: 10px; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-primary); }
.top-bar { min-height: 64px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-title > span { color: var(--muted); font-size: 20px; }
.top-title div { display: flex; flex-direction: column; min-width: 0; }
.top-title strong { overflow: hidden; color: var(--white); white-space: nowrap; text-overflow: ellipsis; }
.top-title small { color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.room-code { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.screens-container { flex: 1; min-height: 0; padding: 18px; display: grid; gap: 16px; align-content: center; justify-content: center; overflow: auto; }
.grid-1 { width: 100%; max-width: 1500px; margin: auto; grid-template-columns: minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-multi { grid-template-columns: repeat(auto-fit, minmax(min(430px,100%),1fr)); }
.placeholder-view { grid-column: 1/-1; margin: auto; padding: 42px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.placeholder-icon { width: 82px; height: 82px; display: grid; place-items: center; border-radius: 26px; background: rgba(88,101,242,.12); color: #929bff; font-size: 38px; }
.placeholder-view h2 { margin-top: 20px; color: var(--white); font-size: 22px; }
.placeholder-view p { margin: 8px 0 20px; color: var(--muted); }
.screen-card { min-width: 0; overflow: hidden; position: relative; background: #0d0e10; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.28); }
.screen-video-box { position: relative; width: 100%; aspect-ratio: 16/9; background: black; }
.screen-video-box video { width: 100%; height: 100%; display: block; object-fit: contain; }
.screen-video-box video.fit-cover { object-fit: cover; }
.video-overlay-top, .video-overlay-bottom { position: absolute; left: 0; right: 0; padding: 12px; display: flex; align-items: center; justify-content: space-between; }
.video-overlay-top { top: 0; background: linear-gradient(rgba(0,0,0,.72),transparent); }
.video-overlay-bottom { bottom: 0; opacity: 0; background: linear-gradient(transparent,rgba(0,0,0,.82)); transition: opacity .18s; }
.screen-card:hover .video-overlay-bottom { opacity: 1; }
.badge-user { padding: 5px 10px; display: flex; align-items: center; gap: 7px; border-radius: 20px; background: rgba(0,0,0,.62); color: white; font-size: 12px; font-weight: 600; }
.video-meta { color: #c6c9cf; font-family: var(--mono); font-size: 10px; }
.controls-group { display: flex; gap: 6px; }
.btn-icon { padding: 6px 9px; border-radius: 5px; background: rgba(0,0,0,.65); color: white; cursor: pointer; font-size: 11px; }
.btn-icon:hover { background: rgba(255,255,255,.16); }

.participants-sidebar { width: 245px; flex: 0 0 245px; display: flex; flex-direction: column; background: var(--bg-secondary); }
.participants-header { min-height: 64px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.participants-header strong { font-size: 14px; }
.participants-header span { padding: 2px 7px; border-radius: 10px; background: var(--selected); color: var(--muted); font-size: 11px; }
.participants-list { flex: 1; overflow-y: auto; padding: 14px 8px; }
.participant-group { padding: 0 8px 6px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.participant-row { padding: 7px 8px; display: flex; align-items: center; gap: 9px; border-radius: 5px; cursor: default; }
.participant-row.streamer { cursor: pointer; }
.participant-row:hover { background: var(--hover); }
.participant-avatar { position: relative; width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-size: 12px; font-weight: 700; }
.participant-avatar::after { content: ''; position: absolute; width: 9px; height: 9px; right: -1px; bottom: -1px; border: 2px solid var(--bg-secondary); border-radius: 50%; background: var(--green); }
.participant-avatar.live::after { background: var(--red); }
.participant-copy { min-width: 0; display: flex; flex-direction: column; }
.participant-copy strong { overflow: hidden; color: var(--text); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.participant-copy small { color: var(--muted); font-size: 10px; }
.empty-list { padding: 30px 16px; color: var(--muted); text-align: center; font-size: 13px; }

.btn { min-height: 38px; padding: 8px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 6px; color: white; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-danger { background: var(--red); }
.btn-danger:hover { filter: brightness(.9); }
.btn-subtle { background: var(--hover); color: var(--text); }
.btn-subtle:hover { background: var(--selected); }
.btn-block { width: 100%; }
.btn-compact { min-height: 30px; padding: 5px 10px; font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 1000; padding: 20px; display: flex; align-items: center; justify-content: center; background: rgba(7,8,10,.76); opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal-card { width: min(460px,100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 17px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-primary); box-shadow: 0 24px 80px rgba(0,0,0,.55); transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal-backdrop.active .modal-card { transform: none; }
.modal-wide { width: min(720px,100%); }
.modal-admin { width: min(1040px,100%); }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; }
.modal-heading h2 { margin-top: 4px; color: var(--white); font-size: 23px; }
.modal-close { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; }
.modal-close:hover { background: var(--hover); color: white; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
input, select, textarea { width: 100%; border: 1px solid transparent; border-radius: 6px; outline: none; background: var(--bg-tertiary); color: var(--text); }
input, select { height: 42px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.segmented { padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 8px; background: var(--bg-tertiary); }
.segmented button { height: 36px; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--brand); color: white; }
.check-field { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 13px; }
.check-field input { width: 16px; height: 16px; accent-color: var(--brand); }
.helper-text { color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-error { min-height: 18px; color: #ff8d91; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.rooms-browser { display: grid; grid-template-columns: 1fr; gap: 10px; }
.room-card { padding: 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-secondary); cursor: pointer; text-align: left; color: var(--text); }
.room-card:hover { border-color: rgba(88,101,242,.75); background: #303239; }
.room-card-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; background: var(--brand); color: white; font-weight: 700; }
.room-card-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-card-copy strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.room-card-copy small { color: var(--muted); font-size: 10px; }
.room-card-status { color: var(--muted); font-size: 15px; }
.refresh-button { align-self: center; }
.updates-list { display: flex; flex-direction: column; gap: 12px; }
.update-card { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-secondary); }
.update-card.important { border-color: rgba(240,178,50,.4); }
.update-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.update-tag { padding: 3px 7px; border-radius: 10px; background: rgba(88,101,242,.16); color: #b1b7ff; font-weight: 700; text-transform: uppercase; }
.update-card h3 { margin: 9px 0 5px; color: var(--white); font-size: 17px; }
.update-card p { color: var(--text); white-space: pre-wrap; font-size: 13px; line-height: 1.55; }

.admin-toolbar { margin-bottom: 16px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; border-radius: 8px; background: var(--bg-tertiary); }
.admin-toolbar div { display: flex; gap: 6px; }
.admin-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.admin-section { min-width: 0; padding: 15px; border-radius: 10px; background: var(--bg-secondary); border: 1px solid var(--border); }
.admin-section h3 { margin-bottom: 12px; color: var(--white); font-size: 15px; }
.admin-room-list, .admin-updates { display: flex; flex-direction: column; gap: 8px; }
.admin-room { padding: 12px; border-radius: 7px; background: var(--bg-tertiary); }
.admin-room-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-room-head small { color: var(--muted); font-family: var(--mono); }
.admin-room-actions, .admin-peer-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.admin-peer { margin-top: 7px; padding-top: 7px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); font-size: 11px; }
.update-editor { display: flex; flex-direction: column; gap: 9px; }
.editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-update-row { padding: 9px; display: flex; justify-content: space-between; gap: 8px; border-radius: 6px; background: var(--bg-tertiary); font-size: 11px; }
.toast-region { position: fixed; z-index: 3000; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 360px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px; background: #17181c; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 12px; animation: toast-in .2s ease; }
.toast.error { border-color: rgba(242,63,67,.55); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

@media (max-width: 1050px) {
  .participants-sidebar { width: 210px; flex-basis: 210px; }
  .room-sidebar { width: 220px; flex-basis: 220px; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .lobby-content { width: min(680px, calc(100% - 32px)); grid-template-columns: 1fr; gap: 28px; padding: 28px 0 44px; }
  .lobby-rooms-panel { min-height: 360px; max-height: 520px; }
  .lobby-main-panel { padding: 36px 0; }
  .participants-sidebar { display: none; }
  .room-sidebar { width: 210px; flex-basis: 210px; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .lobby-header { height: 62px; }
  .lobby-content { width: min(100% - 22px, 520px); padding: 18px 0 34px; }
  .lobby-rooms-panel { min-height: 330px; padding: 18px; border-radius: 15px; }
  .lobby-main-panel { padding: 20px 0; }
  .hero-copy h1 { font-size: 40px; }
  .action-card { min-height: 110px; padding: 18px; }
  .lobby-footer { display: none; }
  .rooms-sidebar { width: 58px; flex-basis: 58px; }
  .room-icon { width: 42px; height: 42px; }
  .room-sidebar { display: none; }
  .top-bar { min-height: 58px; }
  .room-code { display: none; }
  .screens-container { padding: 10px; }
  .grid-2, .grid-multi { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 10px; }
}
