:root {
  color-scheme: dark;
  --ink: #012140;
  --surface: #0a3a63;
  --surface-2: #04294a;
  --surface-3: #14456e;
  --line: #14456e;
  --text: #f7fcfe;
  --body: #dceaf4;
  --muted: #9db6cc;
  --primary: #3b92e0;
  --focus: #6fbbff;
  --success: #6dc080;
  --warning: #f1c233;
  --accent: #f7941d;
  --danger: #e5695f;
  --shadow: 0 16px 40px rgba(0, 16, 33, .26);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.ambient { display: none; }

.topbar {
  width: min(1240px, calc(100% - 48px));
  height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.brand { display: inline-flex; align-items: center; gap: 16px; color: var(--text); text-decoration: none; }
.brand img { width: 126px; height: auto; display: block; }
.product-name { padding-left: 16px; border-left: 1px solid var(--line); color: var(--body); font-size: .9rem; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 20px; }
.secure-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(109,192,128,.1); display: inline-block; flex: none; }

.account-chip { min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 20px; border-left: 1px solid var(--line); }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 8px; background: var(--surface-3); color: var(--text); font-size: .75rem; font-weight: 700; }
.account-copy { min-width: 0; display: grid; gap: 2px; }
.account-copy strong, .account-copy small { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: .75rem; }
.account-copy small { color: var(--muted); font-size: .65rem; }
.account-chip form { margin: 0; }
.account-chip button { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--body); cursor: pointer; font-size: .72rem; font-weight: 600; }
.account-chip button:hover { background: rgba(255,255,255,.06); }

main { width: min(1240px, calc(100% - 48px)); margin: 0 auto; position: relative; z-index: 1; }

.lobby { min-height: calc(100vh - 92px); display: grid; grid-template-columns: minmax(300px, .82fr) minmax(440px, 1.18fr); gap: clamp(48px, 8vw, 116px); align-items: center; padding: 64px 0 90px; }
.eyebrow { margin: 0 0 18px; color: var(--focus); font-size: .75rem; line-height: 1; font-weight: 700; letter-spacing: .18em; }
.intro h1 { margin: 0; font-size: clamp(3.25rem, 6.6vw, 6.2rem); line-height: .96; font-weight: 700; letter-spacing: -.06em; max-width: 740px; }
.intro-copy { max-width: 500px; margin: 30px 0 34px; color: var(--body); font-size: 1.06rem; line-height: 1.75; }
.trust-row { display: flex; flex-wrap: wrap; gap: 12px 24px; color: var(--muted); font-size: .82rem; }
.trust-row span { display: inline-flex; align-items: center; gap: 8px; }
.trust-row span::before { content: ""; width: 4px; height: 4px; background: var(--accent); border-radius: 50%; }

.active-rooms { max-width: 500px; margin-top: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.active-rooms-heading { min-height: 72px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.active-rooms-heading .eyebrow { margin: 0 0 7px; font-size: .64rem; }
.active-rooms-heading h2 { margin: 0; color: var(--text); font-size: 1rem; line-height: 1.2; letter-spacing: -.01em; }
.active-room-count { min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-3); color: var(--body); font-size: .75rem; font-weight: 700; }
.active-rooms-list { display: grid; }
.active-rooms-empty { margin: 0; padding: 20px 16px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.active-room-row { min-height: 68px; padding: 12px 12px 12px 16px; display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.active-room-row + .active-room-row { border-top: 1px solid var(--line); }
.active-room-status { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(109,192,128,.1); }
.active-room-copy { min-width: 0; display: grid; gap: 4px; }
.active-room-copy strong { color: var(--text); font-size: .85rem; letter-spacing: .06em; }
.active-room-copy span { overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.active-room-row button { min-width: 72px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); color: var(--text); cursor: pointer; font-size: .78rem; font-weight: 700; }
.active-room-row button:hover { background: var(--primary); border-color: var(--primary); }

.prejoin-card { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.preview-wrap { position: relative; min-height: 320px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.video-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.halo-placeholder { width: 112px; height: 112px; object-fit: contain; opacity: .88; }
.video-fallback p { margin: 0; font-size: .84rem; }
.preview-badge { position: absolute; top: 18px; left: 18px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; background: rgba(7,17,31,.72); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; font-size: .75rem; backdrop-filter: blur(8px); }
.preview-badge span { width: 6px; height: 6px; background: var(--success); border-radius: 50%; }
.preview-controls { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 9px; }
.icon-btn { width: 43px; height: 43px; border: 1px solid rgba(255,255,255,.16); background: rgba(7,17,31,.78); border-radius: 50%; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); }
.icon-btn svg, .control-btn svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.off, .control-btn.off { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.icon-btn.off::after, .control-btn.off::after { content: ""; position: absolute; width: 23px; height: 2px; background: currentColor; transform: rotate(45deg); border-radius: 2px; }

.join-form { padding: 26px 22px 18px; }
.join-form label { display: block; margin: 0 0 9px; color: #bfccd5; font-size: .78rem; font-weight: 600; }
.join-form input { width: 100%; height: 50px; padding: 0 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.035); color: var(--text); font-size: .95rem; transition: border-color .2s, background .2s; }
.join-form input::placeholder { color: #65798b; }
.join-form input:focus { border-color: var(--focus); background: rgba(255,255,255,.055); }
.room-row { display: grid; grid-template-columns: 1fr 158px; gap: 12px; align-items: end; margin-top: 18px; }
.primary-btn, .secondary-btn { border: 0; border-radius: 11px; min-height: 50px; cursor: pointer; font-weight: 700; font-size: .88rem; transition: transform .18s, filter .18s, background .18s; }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-btn { background: var(--primary); color: var(--text); display: flex; justify-content: center; align-items: center; gap: 9px; }
.primary-btn svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.secondary-btn { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); }
.secondary-btn.compact { width: auto; min-height: 42px; padding: 0 18px; }
.form-separator { display: flex; align-items: center; gap: 12px; margin: 17px 0; color: #627486; font-size: .75rem; }
.form-separator::before, .form-separator::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.form-status { margin: 15px 0 0; text-align: center; color: var(--muted); font-size: .75rem; min-height: 1.2em; }
.device-setup-button { width: 100%; min-height: 44px; margin-top: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--body); display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-size: .82rem; font-weight: 600; }
.device-setup-button:hover { background: rgba(255,255,255,.05); }
.device-setup-button svg { width: 17px; fill: none; stroke: var(--focus); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.meeting { padding: 42px 0 38px; min-height: calc(100vh - 92px); }
.meeting-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.meeting-header .eyebrow { margin-bottom: 8px; }
.meeting-header h1 { margin: 0; font-size: 1.75rem; line-height: 1.2; font-weight: 600; letter-spacing: -.04em; }
.room-chip { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 5px 0 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--body); font-size: .76rem; line-height: 1; font-weight: 600; letter-spacing: .1em; }
.room-chip button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; cursor: pointer; }
.room-chip svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.meeting-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; min-height: min(680px, calc(100vh - 195px)); }
.stage { position: relative; min-height: 560px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.video-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 4px; height: 100%; min-height: 560px; }
.video-tile { position: relative; overflow: hidden; min-height: 260px; background: var(--surface-2); }
.video-tile:only-child { grid-column: 1 / -1; }
.video-tile video { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .18s; }
.video-tile.local video { transform: scaleX(-1); }
.tile-placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.tile-placeholder img { width: min(34%, 176px); height: auto; opacity: .7; }
.video-tile.camera-off video { opacity: 0; }
.video-name { position: absolute; z-index: 2; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 7px; padding: 7px 10px; background: rgba(1,33,64,.82); border-radius: 8px; font-size: .76rem; }
.host-pill { padding: 3px 6px; border-radius: 4px; background: rgba(247,148,29,.15); color: #ffb45a; font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.empty-room { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: var(--surface-2); z-index: 2; }
.empty-room[hidden] { display: none; }
.empty-room h2 { margin: 25px 0 7px; font-size: 1.5rem; line-height: 1.2; font-weight: 600; }
.empty-room p { margin: 0 0 22px; color: var(--muted); font-size: .9rem; }
.empty-halo { width: 112px; height: 112px; object-fit: contain; opacity: .9; }

.control-dock { position: absolute; z-index: 4; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: rgba(1,33,64,.94); box-shadow: 0 12px 32px rgba(0,0,0,.28); }
.control-btn { position: relative; min-width: 70px; height: 54px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font-size: .64rem; color: #c8d3dc; }
.control-btn:hover { background: rgba(255,255,255,.07); }
.control-btn.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.dock-rule { width: 1px; height: 32px; background: var(--line); margin: 0 2px; }

.people-panel { display: flex; flex-direction: column; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1rem; line-height: 1.2; font-weight: 600; }
.panel-heading span { min-width: 25px; height: 25px; padding: 0 7px; display: grid; place-items: center; background: var(--surface-3); border-radius: 999px; color: var(--muted); font-size: .75rem; }
.people-list { flex: 1; padding: 10px 0; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.person-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 8px; background: var(--surface-3); color: var(--body); font-size: .72rem; font-weight: 700; }
.person-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.person-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 600; }
.person-copy span { color: var(--muted); font-size: .68rem; }
.invite-card { display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: center; padding: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.invite-card svg { width: 22px; fill: none; stroke: var(--focus); stroke-width: 1.6; }
.invite-card div { display: flex; flex-direction: column; gap: 3px; }
.invite-card strong { font-size: .72rem; }
.invite-card span { color: var(--muted); font-size: .62rem; }
.invite-card button { border: 0; background: transparent; color: var(--focus); cursor: pointer; font-size: .7rem; font-weight: 700; }
.connection-status { display: flex; align-items: center; gap: 8px; margin: 15px 0 0; color: var(--muted); font-size: .68rem; }
.connection-status span { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.connection-status.connected span { background: var(--success); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; z-index: 20; padding: 11px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .8rem; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.device-dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.device-dialog::backdrop { background: rgba(1, 20, 38, .76); backdrop-filter: blur(4px); }
.device-dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.dialog-heading .eyebrow { margin-bottom: 8px; }
.dialog-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.dialog-close { width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--body); cursor: pointer; font-size: 1.6rem; line-height: 1; }
.dialog-copy { margin: 12px 0 20px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.device-fields { display: grid; gap: 16px; }
.device-fields label { display: grid; gap: 8px; color: var(--body); font-size: .875rem; font-weight: 600; }
.device-fields select { width: 100%; min-height: 48px; padding: 0 40px 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 1rem; }
.device-fields select:disabled { color: var(--muted); opacity: .78; cursor: not-allowed; }
.device-status { min-height: 20px; margin: 16px 0; color: var(--muted); font-size: .82rem; }
.dialog-done { width: 100%; }

.auth-page { min-height: 100vh; }
.auth-topbar { border-bottom-color: rgba(20,69,110,.8); }
.auth-main { min-height: calc(100vh - 92px); display: grid; place-items: center; padding: 48px 0 72px; }
.auth-card { width: min(480px, 100%); padding: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.auth-halo { width: 88px; height: 88px; margin: 0 auto 28px; object-fit: contain; }
.auth-card .eyebrow { margin-bottom: 14px; }
.auth-card h1 { margin: 0; font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.05; letter-spacing: -.04em; }
.auth-copy { margin: 20px auto 28px; color: var(--body); font-size: 1rem; line-height: 1.65; }
.google-signin { min-height: 44px; display: flex; justify-content: center; align-items: center; }
.auth-status { min-height: 20px; margin: 18px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.auth-status.error { color: var(--danger); }
.auth-assurance { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.auth-assurance span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(109,192,128,.1); }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 48px; padding-top: 48px; }
  .intro h1 { font-size: clamp(3.2rem, 13vw, 5.6rem); }
  .intro-copy { margin-top: 22px; }
  .prejoin-card { max-width: 680px; width: 100%; }
  .meeting-layout { grid-template-columns: 1fr; }
  .people-panel { min-height: 220px; }
}

@media (max-width: 560px) {
  .topbar, main { width: min(100% - 28px, 1240px); }
  .topbar { height: 74px; }
  .secure-label { font-size: 0; }
  .topbar-actions { gap: 10px; }
  .account-chip { padding-left: 10px; }
  .account-copy { display: none; }
  .account-chip button { padding: 0 9px; }
  .lobby { min-height: auto; padding: 44px 0 54px; }
  .intro h1 { font-size: clamp(3rem, 16vw, 4.2rem); }
  .trust-row { gap: 10px 16px; }
  .prejoin-card { padding: 7px; border-radius: 12px; }
  .preview-wrap { min-height: 210px; border-radius: 8px; }
  .join-form { padding: 21px 13px 13px; }
  .room-row { grid-template-columns: 1fr; }
  .primary-btn { margin-top: 4px; }
  .meeting { padding-top: 26px; }
  .meeting-header { align-items: center; }
  .meeting-header h1 { font-size: 1.25rem; }
  .room-chip { height: 38px; }
  .meeting-layout { min-height: 0; }
  .stage, .video-grid { min-height: 540px; }
  .video-grid { grid-template-columns: 1fr; }
  .video-tile { min-height: 260px; }
  .control-dock { width: calc(100% - 24px); justify-content: center; bottom: 12px; }
  .control-btn { flex: 1; min-width: 0; padding: 0 5px; }
  .control-btn span { font-size: .58rem; }
  .empty-room { padding: 22px; }
  .device-dialog form { padding: 20px; }
  .auth-main { min-height: calc(100vh - 74px); padding: 28px 0 48px; }
  .auth-card { padding: 36px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
