:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e3e6ee;
  --text: #1b1f2a;
  --muted: #667085;
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-soft: #eef0ff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2330;
    --border: #2a2f3d;
    --text: #e8eaf0;
    --muted: #9aa3b5;
    --brand: #7c7cf8;
    --brand-600: #6b6bf0;
    --brand-soft: #23264a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; word-break: break-word; }
.row { display: flex; gap: .75rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 1rem; }
.hidden { display: none !important; }
@media (min-width: 761px) { .mobile-only { display: none !important; } }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-weight: 500; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-danger { color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn.active, button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: auto; }
.error { color: var(--danger); font-size: .85rem; min-height: 1.2em; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.badge.live { background: #fee2e2; color: #b91c1c; }
.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: middle; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.avatar {
  --h: 230; flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: hsl(var(--h) 65% 88%); color: hsl(var(--h) 55% 30%); font-weight: 600; font-size: .9rem; position: relative;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar.lg { width: 88px; height: 88px; font-size: 1.8rem; }
.avatar.online::after { content: ""; position: absolute; right: 0; bottom: 0; width: 25%; height: 25%; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(145deg, #4f46e5, #7c3aed 60%, #db2777); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 2.4rem; }
.auth-hero ul { padding-left: 1.2rem; opacity: .95; }
.auth-form { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-form .card { width: 100%; max-width: 420px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1rem; white-space: nowrap; padding: .25rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; border-radius: 99px; padding: 0 .45rem; }
.me-chip { margin-top: auto; display: flex; gap: .6rem; align-items: center; padding: .6rem; border-top: 1px solid var(--border); }
.me-chip .name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
main.view { padding: 1.75rem 2rem; max-width: 1100px; width: 100%; }
main.view.full { max-width: none; padding: 0; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* ---------- home ---------- */
.home-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.stat { padding: .9rem 1rem; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .8rem; }
.hero { background: linear-gradient(120deg, var(--brand), #7c3aed); color: #fff; border: 0; margin-bottom: 1.25rem; }
.hero .btn { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); color: #fff; }

.post-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .6rem; }
.post-head .who { font-weight: 600; line-height: 1.2; }
.post-actions { display: flex; gap: .25rem; margin-top: .6rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.comments { margin-top: .5rem; }
.comment { display: flex; gap: .5rem; margin-bottom: .5rem; }
.comment .bubble { background: var(--surface-2); padding: .45rem .7rem; border-radius: 10px; font-size: .9rem; }
.liked { color: var(--danger); }

/* ---------- directory ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.person { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.person .avatar { width: 64px; height: 64px; font-size: 1.3rem; }
.person .name { font-weight: 600; color: var(--text); }
.profile-top { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: .5rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------- events / jobs ---------- */
.event { display: flex; gap: 1rem; align-items: flex-start; }
.date-block { flex: none; width: 60px; text-align: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); padding: .4rem 0; }
.date-block .m { font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.date-block .d { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.list > * + * { margin-top: .75rem; }
.collapsible { margin-bottom: 1.25rem; }
.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.chat-list { border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; padding: 1rem .6rem; }
.chat-list h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .75rem .5rem .35rem; margin: 0; display: flex; align-items: center; }
.chat-list a { display: flex; gap: .55rem; align-items: center; padding: .45rem .6rem; border-radius: 8px; color: var(--text); }
.chat-list a:hover { background: var(--surface-2); text-decoration: none; }
.chat-list p a { display: inline; padding: 0; color: var(--brand); }
.chat-list a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.chat-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: auto; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.msg { display: flex; gap: .65rem; padding: .3rem 0; }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .meta { font-size: .8rem; }
.msg .meta b { font-size: .9rem; margin-right: .4rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.composer { padding: .75rem 1.25rem 1rem; border-top: 1px solid var(--border); background: var(--surface); }
.composer form { display: flex; gap: .5rem; }
.composer textarea { min-height: 42px; height: 42px; max-height: 160px; }
.typing { font-size: .8rem; color: var(--muted); height: 1.2em; }

/* ---------- meet ---------- */
.meet { height: 100vh; display: flex; flex-direction: column; background: #0d0f14; color: #e8eaf0; }
.meet-top { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; }
.meet-body { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; padding: .5rem 1rem; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); grid-auto-rows: minmax(180px, 1fr); align-content: center; overflow-y: auto; }
.stage[data-count="1"] { grid-template-columns: minmax(0, 960px); justify-content: center; }
.tile { position: relative; background: #1b1f2a; border-radius: 14px; overflow: hidden; aspect-ratio: 16/9; min-height: 0; border: 2px solid transparent; transition: border-color .15s; }
.tile.speaking { border-color: #22c55e; }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.tile video.contain { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; background: #1b1f2a; }
.tile .ph .avatar { width: 84px; height: 84px; font-size: 1.8rem; }
.tile .label { position: absolute; left: .6rem; bottom: .6rem; background: rgba(0,0,0,.6); padding: .2rem .6rem; border-radius: 6px; font-size: .82rem; display: flex; gap: .4rem; align-items: center; }
.tile .label svg { width: 14px; height: 14px; color: #f87171; }
.tile .hand { position: absolute; top: .6rem; left: .6rem; font-size: 1.4rem; }
.tile .status { position: absolute; top: .6rem; right: .6rem; font-size: .72rem; background: rgba(0,0,0,.6); padding: .1rem .5rem; border-radius: 6px; }
.tile .react { position: absolute; bottom: 30%; left: 50%; font-size: 3rem; transform: translateX(-50%); animation: floatUp 2s forwards; pointer-events: none; }
@keyframes floatUp { to { transform: translate(-50%, -80px); opacity: 0; } }
.controls { display: flex; justify-content: center; gap: .6rem; padding: .9rem; flex-wrap: wrap; }
.controls button { width: 48px; height: 48px; padding: 0; border-radius: 50%; background: #2a2f3d; border: 0; color: #e8eaf0; position: relative; }
.controls button:hover { background: #3a4152; }
.controls button.off { background: #dc2626; }
.controls button.on { background: #4f46e5; }
.controls button.leave { width: auto; padding: 0 1.3rem; border-radius: 99px; background: #dc2626; font-weight: 600; }
.controls svg { width: 21px; height: 21px; }
.controls .reacts { position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); display: flex; gap: .2rem; background: #2a2f3d; padding: .35rem; border-radius: 99px; }
.controls .reacts button { width: 38px; height: 38px; font-size: 1.2rem; background: transparent; }
.side { width: 320px; background: #161922; border-left: 1px solid #262b38; display: flex; flex-direction: column; }
.side .tabs { padding: .75rem .75rem 0; margin: 0; }
.side .tabs button { background: transparent; border-color: #2a2f3d; color: #e8eaf0; }
.side .tabs button.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.side-body { flex: 1; overflow-y: auto; padding: .75rem; }
.side form { display: flex; gap: .4rem; padding: .75rem; border-top: 1px solid #262b38; }
.side input { background: #0d0f14; border-color: #2a2f3d; color: #e8eaf0; }
.side .pp { display: flex; gap: .6rem; align-items: center; padding: .4rem 0; }
.side .pp svg { width: 16px; height: 16px; }
.mchat { margin-bottom: .6rem; font-size: .9rem; }
.mchat b { font-size: .82rem; }
.lobby { flex: 1; display: grid; place-items: center; padding: 1rem; }
.lobby-inner { display: grid; grid-template-columns: minmax(0, 620px) 300px; gap: 2rem; align-items: center; width: 100%; max-width: 980px; }
.lobby .tile { aspect-ratio: 16/9; }
.lobby .controls { justify-content: flex-start; padding: .75rem 0 0; }
.meet .muted { color: #9aa3b5; }
.meet .btn-primary { font-size: 1rem; padding: .7rem 1.4rem; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #1b1f2a; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 340px; cursor: pointer; animation: slideIn .2s; }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .home-grid, .lobby-inner { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .side { position: absolute; right: 0; top: 0; bottom: 80px; z-index: 5; width: min(320px, 100%); }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 2rem 1.25rem; }
  .auth-hero h1 { font-size: 1.8rem; }
  .shell { grid-template-columns: 1fr; padding-bottom: 64px; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: 64px; flex-direction: row; padding: .35rem; z-index: 20; border-right: 0; border-top: 1px solid var(--border); }
  .sidebar .brand, .me-chip, .nav .label { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 0; padding: .4rem; font-size: .65rem; position: relative; }
  .nav .count { position: absolute; top: 0; right: 0; }
  main.view { padding: 1.25rem 1rem; }
  .filters, .grid-2 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 64px); }
  .chat.has-channel .chat-list, .chat:not(.has-channel) .chat-main { display: none; }
  .meet { height: calc(100vh - 64px); }
  .dl { grid-template-columns: 1fr; }
}

/* ---------- onboarding & profile form ---------- */
.onboard { min-height: 100vh; display: grid; place-items: start center; padding: 2rem 1rem; background: linear-gradient(160deg, var(--brand-soft), var(--bg) 45%); }
.onboard-card { width: 100%; max-width: 720px; padding: 1.5rem 1.75rem; }
.steps { display: flex; gap: .4rem; margin: 1.25rem 0 .4rem; }
.steps span { flex: 1; height: 5px; border-radius: 99px; background: var(--border); }
.steps span.done { background: var(--brand); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.choice { display: flex; align-items: center; gap: .55rem; margin: 0; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 500; }
.choice input { width: auto; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.section-title { font-size: 1rem; margin: 1.5rem 0 .75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.badge.mentor { background: #dcfce7; color: #166534; }
.group-card { display: flex; flex-direction: column; gap: .3rem; min-height: 130px; }
.filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: center; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr !important; } .filters > :first-child { grid-column: 1 / -1; } }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr !important; } }

/* ---------- stage ---------- */
.stage-banner { margin: .5rem 1rem 0; padding: .7rem 1rem; border-radius: 10px; background: #312e81; color: #e0e7ff; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stage-join { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(13, 15, 20, .82); z-index: 10; padding: 1rem; }
.meet { position: relative; }
