:root {
  --bg: #0f1117; --panel: #171a23; --panel-2: #1e2230; --line: #2a2f3e;
  --text: #e7e9ee; --muted: #99a0b0; --brand: #6366f1; --brand-2: #818cf8;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --accent: #38bdf8;
  --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f5f6fa; --panel:#ffffff; --panel-2:#f0f2f7; --line:#e2e5ee;
          --text:#1a1d27; --muted:#5b6273; --shadow:0 6px 20px rgba(20,25,50,.08); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--brand-2); text-decoration: none; }
.muted { color: var(--muted); }
.center { display: grid; place-items: center; min-height: 40vh; }

.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand-name { font-weight: 700; }
.brand-tag { color: var(--muted); font-size: 12px; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.layout { display: flex; min-height: calc(100vh - 55px); }
.sidebar { width: 224px; border-right: 1px solid var(--line); background: var(--panel);
  padding: 14px 10px; flex-shrink: 0; }
.sidebar .navitem { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--text); cursor: pointer; font-size: 14px; margin-bottom: 2px; }
.sidebar .navitem:hover { background: var(--panel-2); }
.sidebar .navitem.active { background: var(--brand); color: #fff; }
.sidebar .navgroup { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; padding: 14px 12px 4px; }
.main { flex: 1; padding: 24px 28px; max-width: 1200px; }

.pagehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.pagehead h1 { font-size: 22px; margin: 0; }
.pagehead p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px){ .grid.cols-3,.grid.cols-4{ grid-template-columns:1fr 1fr; } .sidebar{ display:none; } }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .n { font-size: 30px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 9px 15px; border-radius: 9px;
  cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.badge.brand { color: #fff; background: var(--brand); border-color: var(--brand); }
.pill-role { text-transform: capitalize; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: var(--panel-2); }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.login-wrap { max-width: 420px; margin: 8vh auto; }
.login-wrap .card { padding: 28px; }
.hero-title { font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.hero-sub { color: var(--muted); margin: 0 0 20px; }

.banner { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px;
  border: 1px solid var(--line); }
.banner.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: var(--warn); }
.banner.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 12px 18px; border-radius: 10px; z-index: 100; font-size: 14px; }
.toast.ok { border-color: var(--ok); } .toast.bad { border-color: var(--bad); }

.spacer { height: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 60; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px;
  width: min(560px, 92vw); max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 4px; }

/* ---- guided inbox ---- */
.bell { position: relative; }
.bell-badge { position: absolute; top: -4px; right: -4px; background: var(--brand); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px; }
.bell-badge.alert { background: var(--bad); }
.inbox-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 70; opacity: 0; transition: opacity .2s; }
.inbox-back.show { opacity: 1; }
.inbox-drawer { position: absolute; top: 0; right: 0; height: 100%; width: min(400px, 92vw);
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s; }
.inbox-back.show .inbox-drawer { transform: translateX(0); }
.inbox-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.inbox-tabs { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); }
.inbox-tab { background: none; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font-size: 13px;
  font-weight: 600; border-bottom: 2px solid transparent; display: flex; gap: 6px; align-items: center; }
.inbox-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { background: var(--panel-2); border-radius: 999px; font-size: 11px; padding: 0 6px; }
.inbox-list { flex: 1; overflow: auto; padding: 8px; }
.inbox-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; }
.inbox-item:hover { background: var(--panel-2); border-color: var(--line); }
.inbox-item.sev2 { border-left: 3px solid var(--warn); }
.inbox-item.sev3 { border-left: 3px solid var(--bad); }
.inbox-item.read { opacity: .62; }
.inbox-ico { font-size: 18px; }
.inbox-title { font-weight: 650; font-size: 14px; }
.inbox-body { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.inbox-time { color: var(--muted); font-size: 11px; margin-top: 4px; }
.inbox-go { color: var(--muted); font-size: 20px; align-self: center; }
.inbox-empty { text-align: center; padding: 48px 20px; color: var(--muted); }

/* ---- guided tour ---- */
.tour-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10,12,20,.66); border: 2px solid var(--brand);
  transition: all .25s ease; pointer-events: none; }
.tour-pop { position: fixed; width: min(340px, 90vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 18px; z-index: 91; pointer-events: auto; }
.tour-step { font-family: var(--mono, ui-monospace, monospace); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); font-weight: 700; }
.tour-pop h3 { margin: 6px 0 6px; font-size: 17px; }
.tour-pop p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }

/* ---- help menu ---- */
.help-back { position: fixed; inset: 0; z-index: 80; }
.help-menu { position: absolute; top: 52px; right: 20px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.help-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.help-item:hover { background: var(--panel-2); }

/* ---- live room ---- */
.roommain { max-width: none; padding: 0; }
.room-wrap { display: flex; flex-direction: column; height: calc(100vh - 55px); }
.room-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.room-body { display: flex; flex: 1; min-height: 0; }
.room-stage { flex: 1; padding: 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-content: start; overflow: auto; background: var(--bg); }
.room-side { width: 320px; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
.room-roster { padding: 14px; border-bottom: 1px solid var(--line); }
.room-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: 14px; } .chat-msg.cand .chat-name { color: var(--accent); }
.chat-name { font-weight: 700; margin-right: 6px; }
.chat-sys { font-size: 12px; color: var(--muted); text-align: center; }
.chat-in { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.room-controls { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; justify-content: center; }
.vtile { background: #0b0d13; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 16/10; display: grid; place-items: center; }
.vtile .vslot { width: 100%; height: 100%; }
.vtile .vslot video { width: 100%; height: 100%; object-fit: cover; }
.vtile.local { outline: 2px solid var(--brand); }
.vtile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.lobby { grid-column: 1/-1; display: grid; place-items: center; min-height: 50vh; }
.lobby-card { text-align: center; max-width: 380px; padding: 30px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.brand { background: var(--brand); }
@media (max-width: 820px){ .room-side{ width: 100%; } .room-body{ flex-direction: column; } }

/* ---- coding session ---- */
.code-wrap { display: flex; flex-direction: column; height: calc(100vh - 55px); }
.code-body { display: flex; flex: 1; min-height: 0; }
.code-problem { width: 320px; border-right: 1px solid var(--line); background: var(--panel); padding: 16px; overflow: auto; }
.code-statement { font-size: 14px; line-height: 1.6; }
.code-editor-col { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.code-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.code-toolbar select { max-width: 180px; }
.code-editor { flex: 1; width: 100%; border: none; border-radius: 0; resize: none; background: #0b0d13; color: #e7e9ee;
  font: 13px/1.55 "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; padding: 14px; tab-size: 2; }
.code-editor:focus { outline: none; }
.code-io { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); max-height: 30vh; }
.code-stdin { font-family: ui-monospace, monospace; font-size: 13px; }
.code-output { background: #0b0d13; color: #d7f5df; border-radius: 8px; padding: 12px; margin: 0; overflow: auto;
  font: 12.5px/1.5 ui-monospace, monospace; white-space: pre-wrap; min-height: 80px; max-height: 26vh; border: 1px solid var(--line); }
@media (prefers-color-scheme: light){ .code-editor, .code-output { background: #0f1320; } }
@media (max-width: 820px){ .code-problem{ display:none; } .code-body{ flex-direction: column; } }
