:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fbfbfc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ee;
  --border-strong: #cbd5e1;
  --shadow: 0 16px 40px rgba(15, 23, 42, .06);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, .04);
  --primary: #111827;
  --primary-hover: #1f2937;
  --secondary: #2563eb;
  --secondary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ring: 0 0 0 4px rgba(37, 99, 235, .12);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .04), transparent 30%),
    radial-gradient(circle at top right, rgba(15, 23, 42, .04), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  line-height: 1.5;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
input:focus, textarea:focus {
  border-color: var(--border-strong);
  box-shadow: var(--ring);
}
textarea {
  min-height: 120px;
  resize: vertical;
}
label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(245, 246, 248, .84);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(219, 227, 238, .9);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(180deg, #111827, #374151);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav a, .ghost-button, .nav-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.nav a:hover, .ghost-button:hover, .nav-primary:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.nav-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.nav-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.ghost-button {
  background: var(--surface);
}
.ghost-button.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecaca;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--primary);
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-soft);
}
.button:hover { transform: translateY(-1px); background: var(--primary-hover); }
.button.secondary { background: var(--secondary); border-color: var(--secondary); }
.button.secondary:hover { background: var(--secondary-hover); border-color: var(--secondary-hover); }
.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}
.page-head,
.hero,
.auth-shell,
.metrics-row,
.workspace-grid,
.admin-grid,
.leaderboard-grid,
.queue-list {
  display: grid;
  gap: 16px;
}
.page-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 18px;
}
.hero {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  align-items: stretch;
}
.auth-shell {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  align-items: center;
}
.workspace-grid {
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
}
.admin-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.leaderboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.metrics-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}
.panel,
.banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.banner {
  padding: 14px 16px;
  margin-bottom: 16px;
}
.announcement {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.notice { background: #eff6ff; border-color: #bfdbfe; }
.error { background: #fff1f2; border-color: #fecdd3; }
.hero-copy, .auth-copy {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 10px 0;
}
.eyebrow {
  margin: 0;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
h1, h2, h3, p { margin: 0; }
h1 {
  font-size: clamp(34px, 4.2vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}
h2 {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.lead { font-size: 16px; color: var(--muted); max-width: 58ch; }
.muted { color: var(--muted); }
.actions, .thread-actions, .row, .section-title, .queue-meta, .badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.section-title {
  justify-content: space-between;
  margin-bottom: 12px;
}
.metric {
  display: grid;
  gap: 6px;
}
.metric span {
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.04em;
}
.metric label {
  color: var(--muted);
  font-size: 13px;
}
.pill, .user-chip, .timer-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}
.pill.green { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.pill.danger { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }
.timer-pill { color: var(--secondary); background: #eff6ff; border-color: #bfdbfe; font-weight: 600; }
.timer-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
  margin: -4px 0 16px;
}
.timer-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--secondary);
  transition: width .25s ease;
}
.form { display: grid; gap: 14px; }
.form.composer textarea { min-height: 160px; }
.empty { display: grid; gap: 8px; padding: 8px 0; }
.thread-list { display: grid; gap: 14px; }
.thread {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fbfcfe);
}
.thread-top, .audit-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.question {
  font-weight: 650;
  line-height: 1.45;
}
.answer {
  white-space: pre-wrap;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.drawing {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.drawing svg { display: block; width: 100%; height: auto; }
.canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.draw-canvas {
  display: block;
  width: 100%;
  height: 280px;
  touch-action: none;
  background: #fff;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
.stack { display: grid; gap: 12px; }
.stack.compact { gap: 8px; }
.inline-form { display: inline-flex; }
.report-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tiny-input {
  width: 64px;
  padding: 10px 8px;
}
.table-check {
  width: auto;
  min-width: 18px;
}
.setting-row input { flex: 1 1 0; }
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}
.checkbox-row input {
  width: auto;
}
.queue-meta {
  margin: 10px 0;
}
.filter-row { margin: 12px 0; }
.filter-row input, .filter-row select { flex: 1 1 180px; }
.template-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}
.pagination { margin-top: 12px; }
.mini-card { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.compact-actions { margin-top: 12px; }
.status-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
}
.narrow { max-width: 760px; }
.footer {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 960px) {
  .hero, .auth-shell, .workspace-grid, .page-head { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .nav { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .shell, .footer { width: min(100% - 20px, 1240px); }
  .topbar { padding: 14px 12px; }
  .panel, .thread { border-radius: 12px; }
  h1 { font-size: 30px; }
  .metric span { font-size: 24px; }
  .table { display: block; overflow-x: auto; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(8px);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(480px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(8px);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(480px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}
