:root {
  --bg: #ffffff;
  --fg: #1f1f1f;
  --muted: #5f6368;
  --line: #dadce0;
  --primary: #0b57d0;
  --primary-fg: #ffffff;
  --primary-soft: #d3e3fd;
  --field: #ffffff;
  --m-bg: #202124;
  --m-surface: #3c4043;
  --m-surface-2: #2d2e31;
  --m-fg: #e8eaed;
  --m-muted: #9aa0a6;
  --m-red: #ea4335;
  --m-blue: #8ab4f8;
  --m-tile: #3c4043;
  --panel-bg: #ffffff;
  --panel-fg: #1f1f1f;
  --radius: 12px;
  font-family: "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314;
    --fg: #e3e3e3;
    --muted: #9aa0a6;
    --line: #3c4043;
    --primary: #a8c7fa;
    --primary-fg: #062e6f;
    --primary-soft: #004a77;
    --field: #1e1f20;
    --panel-bg: #1e1f20;
    --panel-fg: #e3e3e3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131314; --fg: #e3e3e3; --muted: #9aa0a6; --line: #3c4043;
  --primary: #a8c7fa; --primary-fg: #062e6f; --primary-soft: #004a77;
  --field: #1e1f20; --panel-bg: #1e1f20; --panel-fg: #e3e3e3; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.view { height: 100dvh; display: flex; flex-direction: column; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 999px; border: 0; background: transparent; font-weight: 500; font-size: 15px; text-decoration: none; color: var(--primary); white-space: nowrap; transition: background .15s, box-shadow .15s; }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { box-shadow: 0 1px 3px rgba(0,0,0,.3); filter: brightness(1.05); }
.btn.outline { border: 1px solid var(--line); }
.btn.outline:hover, .btn.text:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { height: 48px; padding: 0 28px; }
.btn.full { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; flex: none; }
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* Home */
.home-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; color: var(--fg); text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #1a73e8, #34a853); color: #fff; display: grid; place-items: center; }
.home-clock { color: var(--muted); font-size: 18px; }
.home-main { flex: 1; display: flex; align-items: center; justify-content: center; gap: 64px; padding: 24px 48px; overflow: auto; }
.home-copy { max-width: 560px; }
.home-copy h1 { font-size: clamp(32px, 4.5vw, 44px); font-weight: 400; margin: 0 0 16px; line-height: 1.15; letter-spacing: -.5px; }
.home-copy > p { font-size: 18px; color: var(--muted); margin: 0 0 40px; line-height: 1.5; }
.home-copy hr { max-width: 520px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.join-form { display: flex; align-items: center; gap: 8px; }
.input-wrap { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border: 1px solid var(--muted); border-radius: 6px; background: var(--field); color: var(--muted); min-width: 0; }
.input-wrap:focus-within { border: 2px solid var(--primary); padding: 0 13px; }
.input-wrap input { border: 0; outline: 0; background: transparent; width: 200px; color: var(--fg); font-size: 16px; }
.home-art { max-width: 380px; text-align: center; }
.home-art h2 { font-weight: 400; font-size: 24px; margin: 28px 0 8px; }
.art-grid { width: 300px; height: 300px; margin: 0 auto; border-radius: 50%; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--primary-soft); padding: 40px; }
.art-tile { border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 30px; animation: float 6s ease-in-out infinite; }
.art-tile.a { background: #5f8fe0; } .art-tile.b { background: #e37400; animation-delay: -1.5s; }
.art-tile.c { background: #188038; animation-delay: -3s; } .art-tile.d { background: #a142f4; animation-delay: -4.5s; }
@keyframes float { 50% { transform: translateY(-6px) scale(1.02); } }
@media (max-width: 900px) {
  .home-main { flex-direction: column; justify-content: flex-start; gap: 40px; padding: 24px 16px; }
  .home-art { display: none; }
  .home-actions { flex-direction: column; align-items: stretch; }
  .join-form .input-wrap { flex: 1; }
  .input-wrap input { width: 100%; }
}

/* Lobby */
.lobby-main { flex: 1; display: flex; align-items: center; justify-content: center; gap: 48px; padding: 16px 32px 32px; overflow: auto; }
.preview { position: relative; width: min(740px, 100%); aspect-ratio: 16/9; background: #202124; border-radius: 10px; overflow: hidden; color: #fff; flex: none; }
.preview video { width: 100%; height: 100%; object-fit: cover; }
.preview video.mirror { transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; background: #202124; }
.preview-name { position: absolute; top: 14px; left: 18px; font-size: 15px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.preview-controls { position: absolute; bottom: 16px; left: 0; right: 0; display: flex; justify-content: center; gap: 20px; }
.preview-meter { position: absolute; bottom: 24px; left: 20px; display: flex; gap: 3px; align-items: center; height: 24px; width: 24px; padding: 0 4px; border-radius: 50%; background: #1a73e8; justify-content: center; opacity: 0; transition: opacity .2s; }
.preview-meter.on { opacity: 1; }
.preview-meter i { width: 3px; height: 4px; background: #fff; border-radius: 2px; transition: height .08s; }
.round { width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(255,255,255,.7); background: transparent; color: #fff; display: grid; place-items: center; transition: background .15s; }
.round:hover { background: rgba(255,255,255,.15); }
.round.off { background: var(--m-red); border-color: var(--m-red); }
.round.ghost { border-color: transparent; background: rgba(0,0,0,.3); }
.lobby-side { text-align: center; min-width: 280px; max-width: 360px; }
.lobby-side h1 { font-weight: 400; font-size: 32px; margin: 0 0 8px; }
.lobby-side .field { text-align: left; margin: 24px 0; }
.lobby-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 1000px) {
  .lobby-main { flex-direction: column; justify-content: flex-start; gap: 24px; padding: 8px 16px 24px; }
  .lobby-side { max-width: 100%; width: 100%; }
}

.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; font-size: 13px; color: var(--muted); }
.field input, .field select { height: 46px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--muted); background: var(--field); color: var(--fg); font-size: 16px; outline: 0; width: 100%; }
.field input:focus, .field select:focus { border: 2px solid var(--primary); padding: 0 13px; }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Meeting */
.meeting { background: var(--m-bg); color: var(--m-fg); color-scheme: dark; }
.stage-wrap { flex: 1; display: flex; min-height: 0; padding: 16px 16px 0; gap: 16px; }
.stage { flex: 1; min-width: 0; min-height: 0; position: relative; display: flex; gap: 8px; overflow: hidden; }
.grid { flex: 1; min-width: 0; min-height: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-content: center; overflow: hidden; }
.grid .tile { width: var(--tw, 100%); height: var(--th, 100%); flex: none; }
.spotlight-main { flex: 1; min-width: 0; min-height: 0; display: flex; }
.spotlight-main .tile { flex: 1; }
.filmstrip { width: 240px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: none; }
.filmstrip .tile { aspect-ratio: 16/9; flex: none; }
@media (max-width: 760px) {
  .stage.spot { flex-direction: column; }
  .filmstrip { width: auto; height: 110px; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .filmstrip .tile { height: 100%; width: auto; }
}

.tile { position: relative; background: var(--m-tile); border-radius: var(--radius); overflow: hidden; min-width: 0; min-height: 0; isolation: isolate; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen video, .tile.contain video { object-fit: contain; background: #111; }
.tile.mirror video { transform: scaleX(-1); }
.tile.novideo video { opacity: 0; }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.tile:not(.novideo) .avatar { display: none; }
.tile .avatar span { width: clamp(48px, 28%, 160px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: clamp(20px, 4vw, 64px); color: #fff; font-weight: 500; text-transform: uppercase; transition: box-shadow .1s; }
.tile.speaking .avatar span { box-shadow: 0 0 0 6px rgba(138,180,248,.35), 0 0 0 12px rgba(138,180,248,.15); }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 3px solid transparent; pointer-events: none; transition: border-color .15s; z-index: 3; }
.tile.speaking::after { border-color: var(--m-blue); }
.tile .label { position: absolute; left: 12px; bottom: 10px; font-size: 14px; display: flex; align-items: center; gap: 6px; text-shadow: 0 1px 2px rgba(0,0,0,.7); max-width: calc(100% - 24px); z-index: 2; }
.tile .label b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
.tile .badge { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(32,33,36,.6); }
.tile .badge svg { width: 18px; height: 18px; }
.tile .badge.hand { background: #fff; color: #202124; width: auto; padding: 0 8px; border-radius: 14px; gap: 4px; display: flex; align-items: center; font-size: 13px; }
.tile.hand-up::after { border-color: #fff; }
.tile .hover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4px; opacity: 0; transition: opacity .15s; z-index: 2; pointer-events: none; }
.tile:hover .hover, .tile:focus-within .hover { opacity: 1; }
.tile .hover .tools { display: flex; gap: 2px; background: rgba(32,33,36,.75); border-radius: 999px; padding: 4px; pointer-events: auto; }
.tile .hover .icon-btn { width: 36px; height: 36px; color: #fff; }
.tile .hover .icon-btn.on { color: var(--m-blue); }
.tile .presenting { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(32,33,36,.82); z-index: 1; text-align: center; padding: 12px; }
.tile .presenting p { margin: 0; font-size: 18px; }
.filmstrip .tile .presenting p { font-size: 13px; }
.filmstrip .tile .presenting .btn { height: 32px; padding: 0 12px; font-size: 13px; }
.tile .presenting .btn { background: var(--m-blue); color: #062e6f; }

.reactions-layer { position: fixed; left: 0; bottom: 80px; width: 260px; height: 70vh; pointer-events: none; z-index: 30; overflow: hidden; }
.reaction { position: absolute; bottom: 0; display: flex; flex-direction: column; align-items: center; animation: rise 3.8s ease-out forwards; }
.reaction .e { font-size: 44px; line-height: 1; }
.reaction .n { font-size: 12px; background: rgba(32,33,36,.8); color: #fff; padding: 2px 8px; border-radius: 10px; margin-top: 4px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
@keyframes rise {
  0% { transform: translateY(20px) scale(.6); opacity: 0; }
  10% { transform: translateY(0) scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(-60vh) translateX(var(--dx, 0)); opacity: 0; }
}

/* Bottom bar */
.bar { height: 80px; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; position: relative; }
.bar-left { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-left .sep { margin: 0 12px; color: var(--m-muted); }
.bar-center { display: flex; gap: 10px; justify-content: center; }
.bar-right { display: flex; gap: 4px; justify-content: flex-end; }
.ctl { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--m-surface); color: var(--m-fg); display: grid; place-items: center; transition: background .15s, border-radius .2s; }
.ctl:hover { filter: brightness(1.15); }
.ctl.off { background: var(--m-red); color: #fff; }
.ctl.on { background: var(--m-blue); color: #062e6f; }
.ctl.end { width: 64px; border-radius: 999px; background: var(--m-red); color: #fff; }
.ctl.flat { background: transparent; }
.ctl.flat:hover { background: rgba(255,255,255,.08); filter: none; }
.ctl.flat.on { color: var(--m-blue); background: transparent; }
.ctl .count { position: absolute; top: 2px; right: 0; font-size: 11px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--m-surface); color: var(--m-fg); display: grid; place-items: center; }
.ctl .dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--m-blue); }
.ctl:disabled { opacity: .4; cursor: default; filter: none; }
@media (max-width: 760px) {
  .bar { grid-template-columns: 1fr; height: auto; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .bar-left { display: none; }
  .bar-center { gap: 6px; flex-wrap: wrap; }
  .bar-right { justify-content: center; }
  .ctl { width: 44px; height: 44px; }
  .ctl.end { width: 56px; }
  .stage-wrap { padding: 8px 8px 0; }
}

.popover { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%); background: var(--m-surface-2); border-radius: 999px; padding: 6px; display: flex; gap: 2px; box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 40; }
.popover button.emoji { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; font-size: 26px; transition: transform .1s, background .1s; }
.popover button.emoji:hover { background: rgba(255,255,255,.1); transform: scale(1.15); }
.popover.menu { flex-direction: column; border-radius: 8px; padding: 8px 0; left: auto; right: 50%; transform: translateX(160px); min-width: 240px; }
.popover.menu button { display: flex; align-items: center; gap: 16px; border: 0; background: transparent; padding: 10px 20px; text-align: left; font-size: 15px; }
.popover.menu button:hover { background: rgba(255,255,255,.08); }
@media (max-width: 760px) { .toasts { bottom: 150px; } .reactions-layer { bottom: 140px; } .popover { bottom: 120px; } .popover.menu { right: 8px; transform: none; } }

/* Side panel */
.panel { width: 360px; flex: none; background: var(--panel-bg); color: var(--panel-fg); border-radius: 8px; margin-bottom: 0; display: flex; flex-direction: column; min-height: 0; color-scheme: light dark; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 24px; }
.panel-head h2 { font-size: 18px; font-weight: 400; margin: 0; }
.panel-body { padding: 8px 24px 24px; overflow-y: auto; flex: 1; min-height: 0; }
.panel-body h3 { font-size: 15px; font-weight: 500; margin: 12px 0 8px; }
.panel-body .link-text { word-break: break-all; color: var(--muted); font-size: 14px; }
.panel-body .btn.text { padding: 0 12px; margin-left: -12px; }
.panel .muted { color: var(--muted); }
.section-label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 24px 0 8px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.people .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 14px; flex: none; text-transform: uppercase; }
.people .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .nm small { display: block; color: var(--muted); font-size: 12px; }
.people .ic { color: var(--muted); display: flex; gap: 4px; }
.people .ic svg { width: 20px; height: 20px; }
.chat { display: flex; flex-direction: column; padding: 0; }
.chat-note { margin: 8px 16px; padding: 12px; font-size: 12px; text-align: center; border-radius: 8px; background: color-mix(in srgb, var(--fg, #000) 5%, transparent); color: var(--muted); }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 24px; min-height: 0; }
.msg { margin: 0 0 14px; }
.msg .meta { font-size: 13px; margin-bottom: 3px; }
.msg .meta b { font-weight: 500; margin-right: 8px; }
.msg .meta time { color: var(--muted); font-size: 12px; }
.msg .text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg .text a { color: var(--primary); }
.msg.cont { margin-top: -10px; }
.msg.cont .meta { display: none; }
.chat-form { display: flex; align-items: flex-end; gap: 4px; margin: 12px 16px 16px; padding: 4px 4px 4px 16px; border-radius: 24px; background: color-mix(in srgb, var(--fg, #000) 7%, transparent); }
.chat-form textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; padding: 10px 0; max-height: 120px; font-size: 14px; color: var(--panel-fg); }
.chat-form .icon-btn { color: var(--primary); }
@media (max-width: 760px) {
  .panel { position: fixed; inset: 0; width: auto; z-index: 50; border-radius: 0; }
}

/* Banner + toasts */
.banner { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--m-surface-2); color: var(--m-fg); padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 60; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.toasts { position: fixed; left: 16px; bottom: 96px; display: flex; flex-direction: column; gap: 8px; z-index: 70; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: #303134; color: #e8eaed; padding: 12px 16px; border-radius: 6px; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.4); animation: toastin .2s ease-out; cursor: default; }
.toast b { font-weight: 500; display: block; margin-bottom: 2px; }
.toast.click { cursor: pointer; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* Left view */
.left main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; }
.left h1 { font-weight: 400; font-size: 34px; margin: 0 0 12px; }
.left-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }

/* Dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--panel-bg); color: var(--panel-fg); box-shadow: 0 8px 32px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog form { padding: 12px 24px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-right: -12px; }
.dialog-head h2 { font-weight: 400; font-size: 22px; margin: 0; }
.dialog-foot { display: flex; justify-content: flex-end; margin-top: 16px; }

.host-line { margin: 20px 0 0; color: var(--muted); min-height: 1.2em; }
.host-line button { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 500; }
.host-line button:hover { text-decoration: underline; }
.form-error { color: #d93025; font-size: 14px; min-height: 1.2em; margin: 4px 0 0; }
