:root{
  --bg:#202124; --surface:#2d2e31; --surface2:#3c4043; --text:#e8eaed; --muted:#9aa0a6;
  --accent:#4f8cff; --accent2:#7c5cff; --danger:#ea4335; --radius:14px;
  --font: system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);color:var(--text);font-family:var(--font);-webkit-font-smoothing:antialiased}
button,input{font:inherit;color:inherit}
.hidden{display:none!important}
.screen{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.topbar{display:flex;align-items:center;padding:14px 22px}
.brand{display:flex;align-items:center;gap:10px;font-weight:600;font-size:1.25rem;color:var(--text);text-decoration:none;letter-spacing:.2px}
.logo{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,var(--accent),var(--accent2));position:relative;display:inline-block}
.logo::after{content:"";position:absolute;left:7px;top:9px;width:11px;height:12px;border-radius:3px;background:#fff}
.logo::before{content:"";position:absolute;left:19px;top:11px;border:4px solid transparent;border-right:6px solid #fff;border-left:0;transform:scale(1.1)}

/* buttons */
.btn{border:0;border-radius:999px;padding:10px 22px;cursor:pointer;background:var(--surface2);transition:filter .15s,background .15s}
.btn:hover{filter:brightness(1.12)}
.btn.primary{background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff;font-weight:600}
.btn.text{background:transparent;color:var(--accent)}
.btn.text:hover{background:rgba(79,140,255,.12)}
.btn.big{padding:14px 26px;font-size:1.02rem}
.btn.small{padding:6px 14px;font-size:.85rem}
.btn:disabled{opacity:.5;cursor:not-allowed}
.round{width:50px;height:50px;border-radius:50%;border:0;background:var(--surface2);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;position:relative;transition:background .15s,transform .1s}
.round:hover{filter:brightness(1.15)}
.round:active{transform:scale(.95)}
.round.off{background:var(--danger)}
.round.on{background:#8ab4f8;color:#202124}
.round.flat{background:transparent}
.round.flat.active{background:rgba(138,180,248,.2);color:#8ab4f8}
.round.leave{background:var(--danger);width:64px;border-radius:26px}
.icon-btn{background:none;border:0;font-size:1.7rem;line-height:1;cursor:pointer;color:var(--muted);padding:4px 10px;border-radius:8px}
.icon-btn:hover{background:var(--surface2);color:var(--text)}
.badge{position:absolute;right:-2px;top:-2px;min-width:18px;height:18px;border-radius:9px;background:var(--surface2);color:var(--text);font-size:.7rem;display:flex;align-items:center;justify-content:center;padding:0 5px}
.badge.alert{background:var(--accent);color:#fff}
.note{color:var(--muted);font-size:.9rem;min-height:1.2em;margin:.8rem 0 0}
.fine{color:var(--muted);font-size:.82rem}
input[type=text]{background:var(--surface);border:1px solid var(--surface2);border-radius:10px;padding:12px 14px;width:100%;outline:none}
input[type=text]:focus{border-color:var(--accent)}

/* home */
.hero{flex:1;display:grid;grid-template-columns:1.1fr .9fr;gap:40px;align-items:center;max-width:1180px;width:100%;margin:0 auto;padding:20px 28px}
.hero h1{font-size:clamp(2rem,4.6vw,3.2rem);line-height:1.1;margin:0 0 16px;font-weight:600}
.sub{color:var(--muted);font-size:1.1rem;line-height:1.55;max-width:520px;margin:0 0 28px}
.hero-actions{display:flex;flex-wrap:wrap;gap:14px;align-items:center}
.join-form{display:flex;align-items:center;gap:6px;background:var(--surface);border:1px solid var(--surface2);border-radius:999px;padding:4px 6px 4px 18px}
.join-form:focus-within{border-color:var(--accent)}
.join-form input{background:none;border:0;padding:10px 0;width:210px}
.join-form input:focus{border:0}
.hero-art{display:flex;justify-content:center}
.art-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;width:min(420px,90%)}
.art-tile{aspect-ratio:4/3;border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:2.6rem;font-weight:700;color:#fff}
.art-tile.a{background:linear-gradient(135deg,#4f8cff,#3b5bdb)}
.art-tile.b{background:linear-gradient(135deg,#7c5cff,#a24bd8)}
.art-tile.c{background:linear-gradient(135deg,#1fb89a,#0f8f7a)}
.art-tile.d{background:linear-gradient(135deg,#ff8a4f,#e0562d)}
.foot{text-align:center;color:var(--muted);font-size:.85rem;padding:18px}

/* lobby */
.lobby{flex:1;display:grid;grid-template-columns:1.3fr 1fr;gap:48px;align-items:center;max-width:1100px;width:100%;margin:0 auto;padding:20px 28px}
.preview{position:relative;aspect-ratio:16/9;background:#000;border-radius:var(--radius);overflow:hidden}
.preview video{width:100%;height:100%;object-fit:cover;transform:scaleX(-1)}
.preview-off{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:#111;color:var(--muted);font-size:1.1rem}
.preview.cam-off .preview-off{display:flex}
.preview-controls{position:absolute;left:0;right:0;bottom:14px;display:flex;justify-content:center;gap:14px}
.join-panel{display:flex;flex-direction:column;gap:12px}
.join-panel h2{font-size:1.7rem;font-weight:500;margin:0}
.code-line{margin:0;color:var(--muted)}
.code-line strong{color:var(--text);letter-spacing:.5px}
.join-panel label{font-size:.85rem;color:var(--muted);margin-top:8px}

/* meeting */
#meeting{height:100vh;height:100dvh;min-height:0;overflow:hidden}
.meeting-main{flex:1;display:flex;min-height:0;padding:12px 12px 0;gap:12px}
.grid{flex:1;display:grid;gap:10px;min-width:0;min-height:0;grid-template-columns:repeat(var(--cols,1),minmax(0,1fr));grid-template-rows:repeat(var(--rows,1),minmax(0,1fr))}
.tile{position:relative;background:var(--surface);border-radius:var(--radius);overflow:hidden;min-height:0;min-width:0;border:2px solid transparent;transition:border-color .15s}
.tile.speaking{border-color:#8ab4f8}
.tile video{width:100%;height:100%;object-fit:cover;background:#000;display:block}
.tile.self.mirror video{transform:scaleX(-1)}
.tile.sharing video{object-fit:contain}
.tile .avatar{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:var(--surface)}
.tile.cam-off .avatar{display:flex}
.tile .avatar span{width:min(110px,38%);aspect-ratio:1;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:clamp(1.6rem,4vw,2.8rem);font-weight:600;color:#fff;text-transform:uppercase}
.tile .label{position:absolute;left:10px;bottom:10px;max-width:calc(100% - 20px);display:flex;align-items:center;gap:6px;background:rgba(0,0,0,.55);padding:4px 10px;border-radius:8px;font-size:.88rem}
.tile .label .nm{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tile .label .mic{display:none;color:#f28b82;line-height:0}
.tile.mic-off .label .mic{display:inline-flex}
.tile.connecting::after{content:"Connecting...";position:absolute;top:10px;right:10px;background:rgba(0,0,0,.55);padding:3px 10px;border-radius:8px;font-size:.78rem;color:var(--muted)}

.side{width:340px;max-width:100%;background:var(--surface);border-radius:var(--radius);display:flex;flex-direction:column;min-height:0;flex:none}
.side-head{display:flex;align-items:center;justify-content:space-between;padding:14px 12px 10px 18px}
.side-head h3{margin:0;font-weight:500;font-size:1.05rem}
.panel{flex:1;display:flex;flex-direction:column;min-height:0}
.chat-log{flex:1;overflow-y:auto;padding:6px 18px;display:flex;flex-direction:column;gap:12px}
.msg .meta{font-size:.78rem;color:var(--muted);margin-bottom:2px}
.msg .meta b{color:var(--text);font-weight:600;margin-right:6px}
.msg .body{white-space:pre-wrap;word-break:break-word;font-size:.95rem;line-height:1.4}
.msg .body a{color:#8ab4f8}
.chat-empty{color:var(--muted);font-size:.88rem;text-align:center;margin-top:20px}
.chat-form{display:flex;gap:8px;padding:12px}
.chat-form input{border-radius:999px}
.people-list{list-style:none;margin:0;padding:6px 12px;overflow-y:auto}
.people-list li{display:flex;align-items:center;gap:12px;padding:8px 6px}
.people-list .pav{width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:600;color:#fff;text-transform:uppercase;flex:none}
.people-list .pn{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.people-list .ps{color:var(--muted);font-size:.8rem}

.controls{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:12px 18px calc(12px + env(safe-area-inset-bottom))}
.ctrl-center{display:flex;gap:12px;align-items:center}
.ctrl-right{display:flex;gap:8px;justify-content:flex-end}
.ctrl-left{display:flex;align-items:center;gap:10px;min-width:0}
.room-label{color:var(--muted);font-size:.95rem;white-space:nowrap}

.left-main{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;text-align:center}
.left-main h2{font-weight:500;font-size:2rem;margin:0}

.toast{position:fixed;left:50%;bottom:96px;transform:translate(-50%,20px);background:#323232;color:#fff;padding:10px 18px;border-radius:10px;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:50;font-size:.92rem;max-width:90vw;text-align:center}
.toast.show{opacity:1;transform:translate(-50%,0)}

@media (max-width:860px){
  .hero,.lobby{grid-template-columns:1fr;gap:26px}
  .hero-art{display:none}
  .lobby{align-content:center}
  .side{position:fixed;inset:0 0 0 0;width:auto;z-index:30;border-radius:0}
  .controls{grid-template-columns:auto 1fr;gap:6px}
  .ctrl-left{display:none}
  .ctrl-center{justify-content:center;gap:8px}
  .round{width:46px;height:46px}
  .round.leave{width:56px}
}
@media (max-width:480px){
  .join-form input{width:140px}
  .ctrl-right .round{width:40px;height:40px}
}
