:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #eaf1ff;
  background: #05070e;
  --surface: #0b101e;
  --surface-raised: #171f33;
  --line: #94b2ff29;
  --muted: #95a7c7;
  --header: 62px;
  --dock: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { height: 100dvh; min-height: 240px; }
button, input, textarea { font: inherit; }
button {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-raised); color: #eaf1ff; font-weight: 650; cursor: pointer; padding: 10px 16px;
}
button:hover { background: #24314b; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #77ddff; outline-offset: 3px; }
svg { width: 21px; height: 21px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; }
.icon-button { width: 44px; height: 44px; min-width: 44px; padding: 0; background: transparent; }

/* One bounded call surface: only chat and participant panels may scroll. */
.call-header {
  position: absolute; inset: 0 0 auto; z-index: 10; height: var(--header);
  display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center;
  gap: 12px; padding: 8px 18px; background: linear-gradient(#05070ef5,#05070e99 85%,transparent);
}
.heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { color: #eaf1ff; text-decoration: none; font-size: 17px; font-weight: 850; letter-spacing: -.7px; white-space: nowrap; }
.brand span { color: #19cbb6; }
.session-heading { min-width: 0; border-left: 1px solid var(--line); padding-left: 14px; }
h1 { overflow: hidden; margin: 0; font-size: 14px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
#connection { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; }
.layout-switcher { display: flex; align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: #0b101ee8; }
.layout-switcher button { border: 0; border-radius: 999px; background: transparent; min-height: 32px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.layout-switcher svg { width: 16px; height: 16px; }
.layout-switcher button[aria-pressed=true] { background: linear-gradient(135deg,#1685ff,#08bce8); color: #fff; box-shadow: 0 3px 14px #1685ff33; }
.call-stats { justify-self: end; display: flex; align-items: center; gap: 10px; font-size: 11px; color: #c4d4ee; font-variant-numeric: tabular-nums; }
#duration { color: var(--muted); }
#classroom { position: absolute; inset: 0; min-width: 0; min-height: 0; }

.welcome {
  position: absolute; inset: var(--header) 0 0; display: grid;
  grid-template-columns: minmax(0,1.25fr) minmax(280px,.75fr); align-items: center;
  gap: clamp(24px,4vw,70px); padding: 36px clamp(20px,5vw,80px); max-width: 1440px; margin: auto;
}
.welcome-preview {
  position: relative; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 15px; border: 1px solid var(--line); border-radius: 20px;
  background: radial-gradient(ellipse at 50% 40%,#202d43,#0b101e 75%); color: var(--muted);
}
.welcome-preview > svg { width: 54px; height: 54px; stroke-width: 1.2; }
.welcome-preview > span { font-size: 13px; }
.welcome-preview .preview-private { position: absolute; bottom: 18px; left: 18px; font-size: 11px; }
.eyebrow { font-size: 10px; letter-spacing: 1.8px; font-weight: 800; color: #37d4c4; }
.welcome-copy h2 { font-size: clamp(25px,3vw,38px); line-height: 1.16; letter-spacing: -1px; margin: 12px 0 16px; }
.welcome-copy p { font-size: 14px; line-height: 1.65; color: var(--muted); max-width: 420px; }
.join-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 12px; }
.primary { background: linear-gradient(135deg,#147fff,#08b8e5); border-color: #148afc; color: white; }
.welcome-copy .hint { font-size: 11px; }

.stage { position: absolute; inset: 0; display: grid; gap: 12px; padding: calc(var(--header) + 10px) 16px var(--dock); overflow: hidden; min-width: 0; min-height: 0; }
.featured, .gallery, .camera-strip { min-width: 0; min-height: 0; }
.stage[data-layout=gallery] { display: block; }
.stage[data-layout=gallery] .gallery { width: 100%; height: 100%; display: flex; align-content: center; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; }
.stage[data-layout=gallery] .featured, .stage[data-layout=gallery] .camera-strip { display: none; }
.stage:not([data-layout=gallery]) { grid-template-columns: minmax(0,1fr) clamp(110px,17vw,190px); grid-template-rows: minmax(0,1fr); }
.stage:not([data-layout=gallery]) .gallery { display: none; }
.featured { display: grid; place-items: center; }
.camera-strip { display: flex; align-items: stretch; justify-content: center; flex-direction: column; gap: 10px; overflow: hidden; }
.stage.solo { grid-template-columns: minmax(0,1fr); }
.stage.solo .camera-strip { display: none; }
.stage.has-pages { padding-bottom: calc(var(--dock) + 58px); }
.tile {
  position: relative; flex: 0 0 auto; aspect-ratio: 16/9; min-width: 0; overflow: hidden;
  display: grid; place-items: center; border: 1px solid #94b2ff24; border-radius: 16px;
  background: radial-gradient(ellipse at 45% 40%,#18223a,#0b101e); cursor: pointer;
}
.tile[data-featured=true] { border-color: #168bff9e; }
.tile:focus-visible { outline: 3px solid #77ddff; outline-offset: -3px; }
.tile video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #080d18; }
.tile[data-source=screen] video { object-fit: contain; }
.tile[data-local=true][data-source=camera] video { transform: scaleX(-1); }
.tile[data-camera-off=true] video { visibility: hidden; }
.avatar { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg,#1f5790,#24304e); color: #e6f0ff; font-size: 24px; font-weight: 750; }
.tile[data-camera-off=false] .avatar { visibility: hidden; }
.name { position: absolute; bottom: 10px; left: 10px; z-index: 1; max-width: calc(100% - 20px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; font-weight: 650; padding: 5px 8px; border-radius: 7px; background: #03070dcc; color: #fff; }
.tile .hand-badge { position: absolute; top: 10px; left: 10px; display: none; width: 28px; height: 28px; place-items: center; border-radius: 8px; background: #745517dd; color: #ffe5a5; font-size: 18px; }
.tile[data-hand-raised=true] .hand-badge { display: grid; }
.tile .muted-badge { position: absolute; top: 10px; right: 10px; border-radius: 6px; background: #0b101ed9; color: #adc1e0; font-size: 10px; padding: 4px 6px; }
.tile[data-mic-off=false] .muted-badge, .tile[data-source=screen] .muted-badge { display: none; }
.camera-strip .avatar { width: 36px; height: 36px; font-size: 15px; }
.camera-strip .name { font-size: 10px; bottom: 5px; left: 5px; max-width: calc(100% - 10px); padding: 3px 5px; }
.camera-strip .muted-badge { top: 5px; right: 5px; font-size: 9px; }
.camera-strip .hand-badge { top: 5px; left: 5px; width: 23px; height: 23px; font-size: 14px; }
.empty { position: absolute; inset: var(--header) 0 var(--dock); display: grid; place-items: center; font-size: 14px; color: var(--muted); }
.pager { position: absolute; bottom: calc(var(--dock) + 4px); left: 50%; display: flex; align-items: center; gap: 12px; transform: translateX(-50%); z-index: 2; background: #0b101ee8; border: 1px solid var(--line); padding: 3px 5px; border-radius: 999px; font-size: 11px; }
.pager button { min-height: 44px; width: 44px; padding: 0; border: 0; background: transparent; }
.pager svg { width: 16px; height: 16px; }
.reverse { transform: rotate(180deg); }

.controls {
  position: absolute; z-index: 20; bottom: max(14px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px; max-width: calc(100% - 24px); border: 1px solid var(--line);
  border-radius: 22px; background: #0b101ef5; box-shadow: 0 16px 40px #0005; backdrop-filter: blur(16px);
}
.controls > button { flex-direction: column; gap: 4px; padding: 7px 8px; width: 60px; min-width: 60px; height: 52px; border: 0; border-radius: 14px; background: #171f33; font-size: 10px; }
.controls #mic[aria-pressed=true], .controls #camera[aria-pressed=true] { background: linear-gradient(135deg,#1587ff,#08bee8); color: white; }
.controls button[aria-expanded=true], .controls #hand[aria-pressed=true], .controls #share[aria-pressed=true] { background: #154e7c; color: #a7edff; }
.controls > button.leave { min-width: 72px; width: 72px; margin-left: 3px; border-radius: 999px; background: linear-gradient(135deg,#f43f5e,#c41540); color: #fff; }
.off-mark { position: absolute; width: 24px; height: 2px; top: 19px; left: 18px; background: #ffb3c1; transform: rotate(-45deg); box-shadow: 0 0 0 1px #171f33; }
.controls button[aria-pressed=true] .off-mark { display: none; }
.controls .mobile-control { display: none; }
.status { position: absolute; z-index: 25; top: calc(var(--header) + 10px); left: 50%; transform: translateX(-50%); max-width: min(92%,620px); margin: 0; padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px; background: #10192ceb; color: #d5e4f5; text-align: center; font-size: 12px; line-height: 1.5; pointer-events: none; }
.status:empty { display: none; }
body[data-state=ready] .status, body[data-state=joining] .status { top: auto; bottom: 18px; }
body[data-state=closed] .status { top: 50%; font-size: 15px; padding: 20px; pointer-events: auto; }

.side-panel { position: absolute; z-index: 15; top: var(--header); bottom: var(--dock); right: 14px; width: 310px; border: 1px solid var(--line); border-radius: 18px; background: #0b101ef7; box-shadow: 0 14px 50px #0005; display: flex; flex-direction: column; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-heading h2 { font-size: 14px; margin: 0; }
.chat-panel { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.messages { overflow: auto; overscroll-behavior: contain; min-height: 0; flex: 1; padding: 12px; }
.panel-empty { margin: 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.message { padding: 10px; margin: 0 0 10px; border-radius: 10px; background: #172037; }
.message header { display: flex; gap: 8px; align-items: baseline; }
.message strong { font-size: 11px; color: #c8e5ff; }
.message time { margin-left: auto; font-size: 10px; color: var(--muted); }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; margin: 7px 0 0; }
.chat-form { display: flex; align-items: end; gap: 5px; padding: 10px; border-top: 1px solid var(--line); }
textarea { resize: none; min-width: 0; width: 100%; background: #151f34; color: #eaf1ff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; line-height: 1.4; }
textarea::placeholder { color: var(--muted); }
.people-panel { overflow: auto; overscroll-behavior: contain; }
.people-panel ul { padding: 8px; margin: 0; list-style: none; }
.person { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 10px; }
.person .avatar { width: 34px; height: 34px; font-size: 12px; flex-shrink: 0; }
.person-name { font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.person-role { display: block; font-size: 10px; color: var(--muted); }
.person-hand { margin-left: auto; color: #ffd77d; }
.unread { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px; background: #ff5170; color: #fff; font-size: 9px; display: grid; place-items: center; }
body.has-panel .stage { right: 338px; }
body.has-panel .controls { left: calc((100% - 338px)/2); }
.more-menu, .reaction-menu { position: absolute; z-index: 30; bottom: calc(var(--dock) - 8px); left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 16px; background: #10182a; padding: 8px; box-shadow: 0 12px 35px #0008; }
.more-menu { width: min(270px,calc(100% - 24px)); display: grid; grid-template-columns: 1fr; gap: 3px; }
.more-menu button { justify-content: flex-start; border: 0; background: transparent; min-height: 44px; font-size: 12px; }
.reaction-menu { display: flex; gap: 4px; }
.reaction-menu button { width: 44px; padding: 0; font-size: 24px; background: transparent; border: 0; }
.reaction-feed { position: absolute; z-index: 28; bottom: calc(var(--dock) + 8px); left: 20px; display: grid; gap: 6px; pointer-events: none; }
.reaction { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 999px; background: #182440e8; border: 1px solid var(--line); font-size: 11px; animation: reaction-in .2s ease-out; }
.reaction span { font-size: 24px; }
#remote-audio { display: none; }
[hidden] { display: none !important; }
@keyframes reaction-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width:1080px) {
  .brand { font-size: 14px; }
  .heading { gap: 8px; }
  .session-heading { padding-left: 8px; }
  .call-header { gap: 8px; padding-inline: 12px; }
  .layout-switcher button { padding-inline: 9px; }
  .call-stats { gap: 7px; }
  .controls > button { min-width: 53px; width: 53px; }
  body.has-panel .controls > button { min-width: 44px; width: 44px; }
  .side-panel { width: 280px; }
  body.has-panel .stage { right: 306px; }
  body.has-panel .controls { left: calc((100% - 306px)/2); }
}
@media (min-width:700px) and (max-width:1080px) {
  body.has-panel .controls .desktop-control { display: none; }
  body.has-panel .controls .mobile-control { display: flex; }
}
@media (max-width:699px), (max-height:520px) and (max-width:960px) {
  :root { --header: 54px; --dock: 92px; }
  .call-header { grid-template-columns: minmax(0,1fr) auto; padding: 6px 12px; }
  .brand, .layout-switcher { display: none !important; }
  .session-heading { border: 0; padding: 0; }
  h1 { font-size: 12px; }
  .call-stats { gap: 7px; font-size: 10px; }
  .call-stats .icon-button { width: 44px; height: 44px; min-height: 44px; min-width: 44px; }
  .stage { padding: calc(var(--header) + 8px) 8px var(--dock); gap: 10px; }
  .stage:not([data-layout=gallery]) { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto; }
  .camera-strip { flex-direction: row; align-items: center; gap: 7px; height: 78px; }
  .tile { border-radius: 13px; }
  .name { font-size: 10px; bottom: 7px; left: 7px; }
  .controls { gap: 5px; padding: 7px; border-radius: 999px; max-width: calc(100% - 12px); bottom: max(12px,env(safe-area-inset-bottom)); }
  .controls > button, .controls > button.leave, body.has-panel .controls > button { width: 44px; min-width: 44px; height: 48px; min-height: 48px; padding: 5px 4px; border-radius: 50%; gap: 2px; }
  .controls > button.leave { margin-left: 0; }
  .controls svg { width: 20px; height: 20px; }
  .control-label { font-size: 8px; }
  .controls .desktop-control { display: none; }
  .controls .mobile-control { display: flex; }
  .off-mark { left: 10px; top: 17px; width: 23px; }
  .welcome { grid-template-columns: minmax(0,1fr); gap: 18px; padding: 16px 18px 52px; align-content: center; }
  .welcome-preview { max-height: 30dvh; width: min(100%,460px); justify-self: center; }
  .welcome-preview > svg { width: 36px; height: 36px; }
  .welcome-preview .preview-private { font-size: 9px; left: 12px; bottom: 12px; }
  .welcome-copy { max-width: 460px; justify-self: center; }
  .welcome-copy h2 { font-size: 25px; margin: 8px 0 10px; }
  .welcome-copy p { font-size: 12px; margin: 0; }
  .welcome-copy .hint { font-size: 10px; }
  .join-actions { margin: 18px 0 10px; }
  .join-actions button { min-height: 46px; font-size: 12px; padding-inline: 14px; }
  .side-panel { left: 8px; right: 8px; width: auto; top: calc(var(--header) + 8px); bottom: calc(var(--dock) + 2px); }
  body.has-panel .stage { right: 0; }
  body.has-panel .controls { left: 50%; }
  .reaction-feed { left: 10px; }
  .status { font-size: 11px; padding: 8px 12px; }
  .more-menu { bottom: calc(var(--dock) - 6px); }
}
@media (orientation:landscape) and (max-height:520px) and (max-width:960px) {
  :root { --header: 46px; --dock: 75px; }
  .call-header { height: 46px; }
  .stage:not([data-layout=gallery]) { grid-template-columns: minmax(0,1fr) 110px; grid-template-rows: minmax(0,1fr); gap: 8px; }
  .camera-strip { height: 100%; flex-direction: column; justify-content: center; }
  .controls { bottom: 8px; padding: 5px; gap: 5px; }
  .controls > button, .controls > button.leave { min-height: 44px; height: 44px; }
  .controls .control-label { font-size: 8px; }
  .welcome { grid-template-columns: minmax(0,1fr) minmax(230px,1fr); gap: 25px; padding: 16px 28px 28px; }
  .welcome-preview { max-height: none; width: 100%; }
  .welcome-copy h2 { font-size: 22px; }
  .welcome-copy p { font-size: 11px; }
  .welcome-copy .hint { display: none; }
  .join-actions { margin: 13px 0 0; gap: 7px; }
  .join-actions button { min-height: 40px; padding: 8px 12px; }
  .welcome-preview .preview-private { font-size: 9px; }
  .stage.solo { grid-template-columns: minmax(0,1fr); }
}
@media (max-width:360px) {
  .controls { gap: 3px; padding: 6px; }
  .controls > button, .controls > button.leave { width: 44px; min-width: 44px; }
  .call-stats { gap: 5px; }
  #people-count { max-width: 65px; white-space: nowrap; overflow: hidden; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
