:root {
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: #263943;
  background: #f2f6f8;
  font-synthesis: none;
  --paper: #fff;
  --line: #d1dde3;
  --muted: #4b606d;
  --accent: #009fd1;
  --action: #006f95;
  --action-hover: #005d7f;
  --accent-light: #e3f5fb;
  --dark: #263943;
  --logo-slate: #394b55;
  --stage: #182a34;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 4px; }
a { color: inherit; }
svg { width: 21px; height: 21px; display: block; }
.topbar {
  height: 76px;
  padding: 0 max(clamp(20px, 4.1vw, 72px), env(safe-area-inset-right)) 0 max(clamp(20px, 4.1vw, 72px), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; background: var(--paper);
}
.brand { display: inline-flex; align-items: center; gap: 12px; flex: none; color: var(--logo-slate); font-size: .96rem; font-weight: 750; letter-spacing: .095em; text-decoration: none; }
.brand img { display: block; width: 65px; height: auto; }
.demo-marker { margin-left: auto; border: 1px solid var(--line); padding: 5px 9px; border-radius: 7px; color: var(--muted); font-size: .79rem; }
.lobby {
  max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .75fr);
  align-items: center; gap: clamp(20px, 3vw, 44px); min-height: calc(100svh - 76px); padding: 50px clamp(20px, 4vw, 56px);
}
.lobby-story {
  min-width: 0; min-height: 492px; padding: clamp(28px, 5vw, 68px); border-radius: 22px;
  display: flex; flex-direction: column; justify-content: center;
  background:
    linear-gradient(132deg, transparent 62%, #009fd126 62%, #009fd106 86%, transparent 86%),
    radial-gradient(ellipse at 100% 100%, #315669, transparent 73%),
    #223640;
  color: #f6fbfd;
}
h1, h2, p { margin: 0; }
.lobby h1 { margin: 0 0 16px; font-size: clamp(2.45rem, 5.35vw, 4.85rem); line-height: .99; letter-spacing: -.055em; font-weight: 720; overflow-wrap: anywhere; }
.lobby h1 span { display: block; color: #62d6f4; }
.lobby-story > p { max-width: 34ch; font-size: clamp(1rem, 1.6vw, 1.15rem); line-height: 1.6; color: #d2e4ed; }
.lobby-features { display: flex; flex-wrap: wrap; gap: 13px 24px; margin-top: 29px; font-size: .86rem; color: #e4f0f5; }
.lobby-features div { display: flex; align-items: center; gap: 8px; }
.lobby-features svg { width: 17px; height: 17px; color: #62d6f4; }
.lobby-card { padding: clamp(25px, 3.8vw, 37px); border: 1px solid var(--line); background: var(--paper); border-radius: 21px; box-shadow: 0 14px 45px #2639430c; }
.lobby-card-icon { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 11px; background: var(--accent-light); color: var(--action); margin-bottom: 20px; }
.lobby-card h2 { font-size: 1.58rem; letter-spacing: -.045em; }
.subtle { margin-top: 6px; color: var(--muted); font-size: .87rem; line-height: 1.5; }
.lobby-card form { display: grid; margin-top: 18px; }
.name-field { display: grid; }
.staff-name { display: grid; gap: 5px; margin: 10px 0 8px; color: var(--muted); font-size: .83rem; }
.staff-name strong { color: var(--dark); font-size: .98rem; }
.host-fields { display: grid; }
label { margin-top: 10px; margin-bottom: 6px; color: var(--dark); font-weight: 650; font-size: .83rem; }
input { min-width: 0; width: 100%; height: 45px; padding: 9px 12px; border: 1px solid #b8cad4; border-radius: 8px; background: var(--paper); color: var(--dark); }
input::placeholder { color: #536e7d; }
.button { min-height: 43px; border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-size: .86rem; font-weight: 670; text-decoration: none; }
.button svg { width: 17px; height: 17px; flex: none; }
.primary { color: #fff; background: var(--action); border-color: var(--action); }
.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.secondary { background: var(--paper); color: var(--dark); border-color: #b8cad4; }
.secondary:hover { background: var(--accent-light); }
.lobby-submit { justify-content: space-between; margin-top: 23px; min-height: 48px; padding-inline: 15px; }
.form-notice { margin-top: 13px; color: #854127; font-size: .9rem; line-height: 1.5; }
#lobby-home, #lobby-copy, #staff-sign-out { margin-top: 15px; }
.staff-access { display: grid; gap: 8px; }
body:has(.player:not([hidden])) { overflow: hidden; background: var(--stage); }
body:has(.player:not([hidden])) .topbar { display: none; }
.player {
  --inset-left: max(clamp(12px, 2vw, 32px), env(safe-area-inset-left));
  --inset-right: max(clamp(12px, 2vw, 32px), env(safe-area-inset-right));
  --inset-top: max(clamp(12px, 2.3vh, 24px), env(safe-area-inset-top));
  --inset-bottom: max(clamp(12px, 2.3vh, 24px), env(safe-area-inset-bottom));
  --header-space: calc(var(--inset-top) + 67px);
  --controls-space: calc(var(--inset-bottom) + 72px);
  --accent-on-dark: #77d9f2;
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--stage);
  color: #f1f8fb;
}
.player:fullscreen { width: 100%; height: 100%; }
.player:focus-visible, .player :focus-visible { outline-color: var(--accent-on-dark); }
.stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0f1d26;
}
.tile-grid, .share-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  gap: 2px;
}
.tile-grid { grid-auto-rows: minmax(0, 1fr); }
.tile-grid:has(> .person-tile:nth-child(2)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile-grid > .person-tile:nth-child(2n+3):last-child { grid-column: 1 / -1; }
.person-tile, .screen-tile {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.person-tile {
  --name-bottom: 12px;
  background: radial-gradient(ellipse at 50% 49%, #315569, #253e4b 63%, #1c303b);
}
.person-tile:where(:only-child, :nth-child(odd):nth-last-child(-n+2), :nth-child(even):last-child) {
  --name-bottom: var(--controls-space);
}
@media (min-width: 540px) and (orientation: landscape) {
  .tile-grid:has(> .person-tile:nth-child(5)) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tile-grid:has(> .person-tile:nth-child(5)) > .person-tile { grid-column: span 2; }
  .tile-grid:has(> .person-tile:nth-child(5)) > .person-tile:where(:nth-child(3n+1):nth-last-child(2), :nth-child(3n+2):last-child) { grid-column: span 3; }
  .tile-grid:has(> .person-tile:nth-child(5)) > .person-tile:nth-child(3n+1):last-child { grid-column: 1 / -1; }
  .tile-grid:where(:has(> .person-tile:nth-child(5))) > .person-tile { --name-bottom: 12px; }
  .tile-grid:where(:has(> .person-tile:nth-child(5))) > .person-tile:where(
    :nth-child(3n+1):nth-last-child(-n+3), :nth-child(3n+2):nth-last-child(-n+2), :nth-child(3n+3):last-child
  ) { --name-bottom: var(--controls-space); }
}
@media (orientation: portrait) {
  .tile-grid:has(> .person-tile:nth-child(2):last-child) { grid-template-columns: 1fr; }
  .tile-grid:where(:has(> .person-tile:nth-child(2):last-child)) > .person-tile:first-child { --name-bottom: 12px; }
}
.screen-tile { background: #0a141b; }
.person-tile video, .screen-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.screen-tile video { object-fit: contain; }
.person-tile video[data-local="true"] { transform: scaleX(-1); }
.avatar {
  display: grid;
  place-items: center;
  width: clamp(40px, min(10vw, 14dvh), 112px);
  aspect-ratio: 1;
  border: 1px solid #a7e3f4;
  border-radius: 50%;
  color: #163c4e;
  background: #92d9ed;
  font-size: clamp(1rem, min(3.2vw, 5.5dvh), 2.5rem);
  font-weight: 720;
}
.tile-name {
  position: absolute;
  z-index: 1;
  bottom: var(--name-bottom, 12px);
  left: var(--inset-left);
  max-width: calc(100% - var(--inset-left) - 8px);
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 6px;
  background: #101f29e8;
  color: #f3f8fa;
  font-size: .76rem;
}
.share-grid {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding-top: var(--header-space);
}
.stage:has(.share-grid:not([hidden])) .tile-grid {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  padding: 6px var(--inset-right) var(--controls-space) var(--inset-left);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
.stage:has(.share-grid:not([hidden])) .person-tile {
  flex: 0 0 auto;
  height: clamp(52px, 14dvh, 128px);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}
.stage:has(.share-grid:not([hidden])) .avatar { width: clamp(26px, 6.5dvh, 49px); font-size: clamp(.7rem, 2.2dvh, 1rem); }
.stage:has(.share-grid:not([hidden])) .person-tile .tile-name {
  bottom: 4px; left: 4px; max-width: calc(100% - 8px); padding: 3px 5px; font-size: .67rem;
}
.player-header, .player-footer {
  position: absolute;
  inset-inline: 0;
  z-index: 2;
  padding-inline: var(--inset-left) var(--inset-right);
  pointer-events: none;
}
.player-header {
  inset-block-start: 0;
  padding-top: var(--inset-top);
  padding-bottom: 25px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, #0b171ff5, #0b171fbd 55%, transparent);
}
.player-identity, .player-actions, .session-meta { display: flex; align-items: center; }
.player-identity { min-width: 0; gap: clamp(9px, 1.4vw, 18px); }
.player-brand {
  display: grid;
  align-content: center;
  gap: 3px;
  place-items: center;
  flex: none;
  width: 75px;
  height: 49px;
  border-radius: 9px;
  background: #f6fbfd;
  color: var(--logo-slate);
  font-size: .55rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
}
.player-brand img { display: block; width: 56px; height: auto; }
.session { min-width: 0; }
.session h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.06rem, 2.15vw, 1.78rem);
  font-weight: 710;
  line-height: 1.1;
  letter-spacing: -.035em;
}
.session h1:focus { outline: none; }
.session-meta { flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; color: #d6e9f2; font-size: .75rem; }
.connection-status, .people-count, .recording-pill { display: inline-flex; flex: none; align-items: center; gap: 5px; white-space: nowrap; }
.connection-status > span:first-child, .recording-pill > span:first-child { width: 7px; height: 7px; border-radius: 50%; }
.connection-status > span:first-child { background: #a3b8c5; }
.connection-status[data-connected="true"] > span:first-child { background: var(--accent-on-dark); }
.people-count svg { width: 15px; height: 15px; }
.recording-pill { padding: 3px 6px; border-radius: 5px; background: #661f29; color: #ffe3e7; font-weight: 700; }
.recording-pill > span:first-child { background: #ffa3ae; }
.player-actions { flex: none; gap: 7px; }
.player-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 41px;
  min-height: 39px;
  padding: 6px 10px;
  border: 1px solid #7193a582;
  border-radius: 8px;
  background: #182b38e8;
  color: #f3f8fa;
  font-size: .82rem;
  font-weight: 650;
  pointer-events: auto;
}
.player-button svg { width: 18px; height: 18px; }
.player-button:hover { background: #304d5f; }
.player-footer {
  inset-block-end: 0;
  padding-top: 21px;
  padding-bottom: var(--inset-bottom);
  display: grid;
  justify-items: center;
  gap: 8px;
  background: linear-gradient(0deg, #0b171ff5, #0b171fa3 50%, transparent);
}
.toolbar {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
  padding: 5px;
  border: 1px solid #5671828c;
  border-radius: 14px;
  background: #101e28ef;
  box-shadow: 0 7px 22px #08131a8c;
  pointer-events: auto;
}
.tool {
  min-width: 73px;
  max-width: 102px;
  min-height: 50px;
  padding: 5px 6px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #233948;
  color: #f3f8fa;
  font-size: .71rem;
  line-height: 1.05;
}
.tool:hover { background: #355368; }
.tool[aria-pressed="true"] { background: #81d8ee; color: #123746; }
.tool.leave, #record-button[aria-pressed="true"] { background: #702933; color: #ffe4e8; }
.tool.leave:hover, #record-button[aria-pressed="true"]:hover { background: #8a3542; }
.room-notice {
  max-width: min(100%, 48ch);
  padding: 8px 12px;
  border: 1px solid #a66364;
  border-radius: 8px;
  background: #391f26f5;
  color: #ffe3e8;
  font-size: .84rem;
  text-align: center;
}
.recording-archive { width: min(100% - 32px, 640px); margin: 48px auto; }
.recording-archive h1 { margin-bottom: 19px; font-size: clamp(1.55rem, 6vw, 2.4rem); letter-spacing: -.045em; overflow-wrap: anywhere; }
.recordings-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.recordings-card h2 { margin-bottom: 10px; font-size: 1.1rem; }
.recordings-list { display: grid; gap: 6px; list-style: none; padding: 0; margin: 0; }
.recording-row { display: flex; align-items: center; gap: 8px; padding: 6px; }
.recording-label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; line-height: 1.25; }
.recording-label small { display: block; color: var(--muted); margin-top: 3px; font-size: .72rem; }
.empty { color: var(--muted); font-size: .86rem; line-height: 1.5; }
.recording-row .button { min-height: 33px; padding: 5px 8px; }
.archive-home { margin-top: 16px; }
dialog { color: var(--dark); background: var(--paper); padding: 24px; width: min(440px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 15px; }
dialog::backdrop { background: #112029a8; }
dialog h2 { font-size: 1.4rem; letter-spacing: -.03em; }
dialog p { margin-top: 8px; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 860px) {
  .lobby-story { min-height: 440px; padding-inline: clamp(24px, 4vw, 45px); }
}
@media (max-width: 620px) {
  .topbar { height: 59px; }
  .lobby {
    grid-template-columns: minmax(0, 1fr); min-height: auto; gap: 14px;
    padding: 18px max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .lobby-story { min-height: 0; padding: 30px 24px; border-radius: 17px; }
  .lobby-card { border-radius: 17px; }
  .lobby h1 { font-size: clamp(2.15rem, 9.8vw, 3.2rem); margin-bottom: 12px; }
  .lobby-features { margin-top: 16px; }
  .demo-marker { font-size: .68rem; }
  .player-header { gap: 8px; }
  .player-brand { width: 48px; height: 36px; border-radius: 6px; font-size: .42rem; }
  .player-brand img { width: 37px; }
  .session-meta { gap: 3px 7px; font-size: .68rem; }
  .session-meta svg { width: 13px; height: 13px; }
  #copy-invite > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .player-button { min-width: 42px; min-height: 42px; padding: 5px; }
  .tool { min-width: 48px; max-width: 64px; font-size: .67rem; }
}
@media (max-height: 480px) {
  .player { --header-space: calc(var(--inset-top) + 45px); --controls-space: calc(var(--inset-bottom) + 58px); }
  .player-header { padding-bottom: 13px; }
  .tool { min-height: 40px; }
  .tool svg { width: 18px; height: 18px; }
  .person-tile .avatar { width: clamp(25px, 12dvh, 64px); font-size: clamp(.72rem, 4dvh, 1.4rem); }
}
