:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --border: #334155;
  --proj-bg: #000;
  --proj-hint: #888;
}
.field { margin: 8px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
a { color: var(--accent-2); }
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--panel);
}
header.top h1 { margin: 0; font-size: 18px; }
header.top .meta { color: var(--muted); font-size: 13px; }
main { max-width: 900px; margin: 0 auto; padding: 20px; }
main.wide { max-width: 1200px; }
section.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
h2 { margin-top: 0; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
button {
  cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font: inherit;
}
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { background: var(--accent-2); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.question {
  display: flex; gap: 12px; padding: 12px; border-radius: 8px;
  background: var(--panel-2); margin-bottom: 8px; align-items: flex-start;
}
.question.answered { border-left: 3px solid var(--good); }
.question.hidden-q { opacity: 0.45; }
.question .body { flex: 1; }
.question .text { white-space: pre-wrap; }
.question .answer {
  margin-top: 8px; padding: 8px; border-radius: 6px;
  background: rgba(34, 197, 94, 0.1); border-left: 2px solid var(--good); font-size: 14px;
}
.vote-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 10px; min-width: 52px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.vote-btn.voted { background: var(--accent); border-color: var(--accent); color: white; }
.vote-btn .count { font-weight: 600; }
.vote-btn .label { font-size: 11px; color: var(--muted); }
.vote-btn.voted .label { color: rgba(255,255,255,0.8); }

.option {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--panel-2); margin-bottom: 8px; cursor: pointer;
  position: relative; overflow: hidden;
  width: 100%; color: var(--text); font: inherit; text-align: left;
}
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.option.selected { border-color: var(--accent); background: rgba(99, 102, 241, 0.15); }
.option.correct { border-color: var(--good); }
.option.wrong { border-color: var(--bad); }
.option.disabled { cursor: default; opacity: 0.85; }
.option .bar {
  position: absolute; inset: 0; background: rgba(99, 102, 241, 0.18);
  transform-origin: left; transform: scaleX(0); transition: transform 0.4s ease;
  pointer-events: none;
}
.option .opt-text { flex: 1; position: relative; z-index: 1; }
.option .opt-pct { position: relative; z-index: 1; font-weight: 600; color: var(--accent-2); }
.option img.opt-img { max-height: 80px; max-width: 120px; border-radius: 4px; position: relative; z-index: 1; }
.q-image { max-width: 100%; max-height: 280px; border-radius: 8px; margin: 8px 0; display: block; }

.proj { padding: 40px 60px; }
.proj h1 { font-size: 48px; margin: 0 0 12px; }
.proj .code-display { font-size: 32px; color: var(--muted); margin-bottom: 24px; }
.proj .question { font-size: 20px; padding: 16px; }
.proj .option { font-size: 24px; padding: 20px; }
.proj .q-image { max-height: 360px; }

/* Compact card variant for admin tables */
section.card.compact { padding: 12px 14px; margin-bottom: 12px; }
section.card.compact h2 { font-size: 12px; margin: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-head .card-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
input.inline, select.inline { width: auto; padding: 5px 8px; font-size: 13px; }
select.inline.narrow { min-width: 100px; }
button.small { padding: 4px 10px; font-size: 13px; }
button.xsmall { padding: 2px 8px; font-size: 11px; border-radius: 6px; }

/* Compact admin table */
.ctable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctable th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.ctable td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ctable tr:last-child td { border-bottom: none; }
.ctable td.num, .ctable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ctable td.actions, .ctable th.actions { text-align: right; white-space: nowrap; }
.ctable td.actions button, .ctable td.actions a { margin-left: 8px; }
.ctable td.actions a:first-child { margin-left: 0; }
.ctable tr.rowable { cursor: pointer; }
.ctable tr.rowable:hover { background: rgba(255,255,255,0.03); }
.ctable tr.rowable.selected { background: rgba(99, 102, 241, 0.10); }
.ctable code { font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* Compact editor inside detail pane */
.row.gap { gap: 8px; flex-wrap: wrap; }
.field-row { margin: 6px 0; }
.editor-q.compact { background: var(--panel-2); padding: 10px 12px; border-radius: 8px; margin-top: 10px; }
.editor-q.compact textarea { min-height: 50px; font-size: 14px; }
.editor-q.compact .options { margin-top: 6px; }
.editor-opt { display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.editor-opt input[type="text"] { flex: 1; }
.thumb { max-height: 60px; max-width: 100px; border-radius: 4px; }
.thumb-sm { max-height: 32px; max-width: 60px; border-radius: 4px; }

/* QS status badges (reuse badge structure) */
.badge-live { background: rgba(34, 197, 94, 0.18); color: var(--good); border: 1px solid var(--good); }
.badge-closed { background: rgba(148, 163, 184, 0.18); color: var(--muted); border: 1px solid var(--border); }
.badge-planning { background: rgba(245, 158, 11, 0.18); color: var(--warn); border: 1px solid var(--warn); }
.badge-ended { background: rgba(148, 163, 184, 0.18); color: var(--muted); border: 1px solid var(--border); }
.badge-queued { background: rgba(99, 102, 241, 0.18); color: var(--accent-2); border: 1px solid var(--accent); }

/* Drill-down results */
.result-q { background: var(--panel-2); padding: 10px 12px; border-radius: 8px; margin-top: 10px; }
.result-opt {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-top: 4px; border-radius: 6px;
  background: var(--panel); overflow: hidden;
}
.result-opt.correct { box-shadow: inset 2px 0 0 var(--good); }
.result-bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(99, 102, 241, 0.18); z-index: 0; transition: width 0.3s ease; }
.result-mark, .result-text, .result-num { position: relative; z-index: 1; }
.result-mark { width: 14px; color: var(--good); font-weight: bold; }
.result-text { flex: 1; }
.result-num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; max-width: 360px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); z-index: 100; }
.toast-error { border-color: var(--bad); color: var(--bad); background: rgba(239, 68, 68, 0.08); }
.error-banner { background: rgba(239, 68, 68, 0.12); border: 1px solid var(--bad); color: var(--bad); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.info-banner { background: rgba(99, 102, 241, 0.12); border: 1px solid var(--accent); color: var(--accent-2); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; vertical-align: middle; }
.badge-draft { background: rgba(245, 158, 11, 0.18); color: var(--warn); border: 1px solid var(--warn); }
.badge-ready { background: rgba(34, 197, 94, 0.18); color: var(--good); border: 1px solid var(--good); }
