/* ==========================================================
 * educoder — Quiet Pro
 * Restrained dev-tool aesthetic. Single muted accent.
 * ========================================================== */

:root {
  --bg:           #0c0c0d;
  --bg-alt:       #141417;
  --surface:      #1c1c20;
  --surface-2:    #25252b;
  --text:         #e8e8ec;
  --text-muted:   #8e8e98;
  --text-dim:     #5b5b65;
  --border:       #222227;
  --border-soft:  #1a1a1e;
  --border-h:     #2e2e35;
  --accent:       #a8b1ff;
  --accent-ink:   #0c0c0d;
  --accent-soft:  rgba(168, 177, 255, 0.10);
  --accent-ring:  rgba(168, 177, 255, 0.18);

  --good:         #7ec98f;
  --good-soft:    rgba(126, 201, 143, 0.10);
  --warn:         #e4b876;
  --warn-soft:    rgba(228, 184, 118, 0.10);
  --bad:          #e07b7b;
  --bad-soft:     rgba(224, 123, 123, 0.10);
}

html, body {
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

* { font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-soft); color: var(--text); }

a { color: inherit; text-decoration: none; transition: color 0.1s ease; }
a:hover { color: var(--accent); }

/* -------- Sidebar shell -------- */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.app-main { min-width: 0; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sidebar-brand .dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent);
}
.sidebar-section {
  padding: 14px 18px 6px;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  margin: 1px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: color 0.1s ease, background 0.1s ease;
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--surface);
}
.sidebar-link.active {
  color: var(--text);
  border-left-color: var(--accent);
}
.sidebar-link .dim { color: var(--text-dim); width: 12px; display: inline-flex; justify-content: center; }
.sidebar-foot {
  margin-top: auto;
  padding: 12px 18px;
  font-size: 11px;
  color: var(--text-dim);
}

/* -------- Top bar -------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.topbar .crumbs { color: var(--text-dim); display: flex; gap: 8px; align-items: center; }
.topbar .crumbs a { color: var(--text-muted); }
.topbar .crumbs a:hover { color: var(--accent); }
.topbar .crumbs .sep { color: var(--text-dim); opacity: 0.5; }
.topbar .crumbs .text { color: var(--text); }

/* -------- Page container -------- */
.page {
  padding: 24px;
  max-width: 1400px;
}
.page.dense { padding: 0; }
.page.narrow { max-width: 720px; }

.page-head {
  margin-bottom: 24px;
}
.page-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
.page-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* -------- Caps / labels -------- */
.caps {
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}

/* -------- Mono -------- */
.mono, pre, code, .num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* -------- Panels (flat) -------- */
.panel {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  height: 36px;
  box-sizing: border-box;
}
.panel-title {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.panel-body { padding: 14px; }
.panel-body.dense { padding: 0; }

.card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; padding: 14px; }
.card-hover:hover { border-color: var(--border-h); }

/* -------- KPI tiles -------- */
.kpi {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-dim); font-weight: 500; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-delta { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.kpi-delta.up   { color: var(--good); }
.kpi-delta.down { color: var(--bad); }

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: var(--surface); border-color: var(--border-h); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: #b8c0ff; border-color: #b8c0ff; color: var(--accent-ink); }
.btn-ghost { border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-danger { color: var(--bad); border-color: rgba(224,123,123,0.3); }
.btn-sm { height: 24px; padding: 0 10px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

/* legacy aliases */
.pill          { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 5px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.pill:hover    { background: var(--surface); border-color: var(--border-h); }
.pill-primary  { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.pill-primary:hover { background: #b8c0ff; }
.pill-ghost    { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.pill-ghost:hover { color: var(--text); background: var(--surface); }

/* -------- Inputs -------- */
input, textarea, select, button { color-scheme: dark; font-family: inherit; }
input:focus, textarea:focus, select:focus { outline: none; }

.input-warp, .field {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 10px;
  color: var(--text);
  font-size: 12px;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.input-warp::placeholder, .field::placeholder { color: var(--text-dim); }
.input-warp:hover, .field:hover { border-color: var(--border-h); }
.input-warp:focus, .field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}
textarea.input-warp, textarea.field {
  height: auto;
  padding: 8px 10px;
  line-height: 1.55;
  min-height: 80px;
  font-family: 'JetBrains Mono', monospace;
}
.field.mono, .input-warp.mono { font-family: 'JetBrains Mono', monospace; }
select.input-warp, select.field {
  appearance: none; -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 24px;
}
input[type="checkbox"] { accent-color: var(--accent); }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-dim); font-weight: 500; }
.form-grid { display: grid; gap: 14px; }

/* -------- Tables -------- */
.table-wrap {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: auto;
  max-height: 100%;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
  z-index: 2;
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
  padding: 0 14px;
  height: 32px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 0 14px;
  height: 30px;
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  border-bottom: 1px solid var(--border-soft);
}
.table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.table tbody tr:hover td { background: var(--surface); }
.table tbody tr.clickable td { cursor: pointer; }
.table tbody tr.selected td { background: var(--accent-soft); }
.table tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.table .num, .table .right { text-align: right; font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.table th.right { text-align: right; }
.table .dim { color: var(--text-dim); }
.table .muted { color: var(--text-muted); }
.table .rank { color: var(--text-dim); width: 36px; }
.table tbody tr:last-child td { border-bottom: 0; }

/* -------- Badges (outline only) -------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--border-h);
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
}
.badge-accent { color: var(--accent); border-color: rgba(168,177,255,0.30); }
.badge-good   { color: var(--good); border-color: rgba(126,201,143,0.30); }
.badge-warn   { color: var(--warn); border-color: rgba(228,184,118,0.30); }
.badge-bad    { color: var(--bad); border-color: rgba(224,123,123,0.30); }
.badge-magenta{ color: #d4a8ff; border-color: rgba(212,168,255,0.30); }

/* legacy chips — outline only */
.chip { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; border: 1px solid var(--border-h); background: transparent; color: var(--text-muted); font-weight: 500; }
.chip-easy   { color: var(--good); border-color: rgba(126,201,143,0.30); }
.chip-medium { color: var(--warn); border-color: rgba(228,184,118,0.30); }
.chip-hard   { color: var(--bad);  border-color: rgba(224,123,123,0.30); }
.chip-pass   { color: var(--good); border-color: rgba(126,201,143,0.30); }
.chip-fail   { color: var(--bad);  border-color: rgba(224,123,123,0.30); }
.chip-pending{ color: var(--warn); border-color: rgba(228,184,118,0.30); }

.dot-status { display: inline-block; width: 6px; height: 6px; border-radius: 50%; vertical-align: middle; }
.dot-good   { background: var(--good); }
.dot-warn   { background: var(--warn); }
.dot-bad    { background: var(--bad); }
.dot-idle   { background: var(--text-dim); }

/* -------- Code -------- */
pre, code { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
pre.codeblock {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  overflow: auto;
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
}

/* -------- CodeMirror -------- */
.cm-editor {
  background: var(--bg) !important;
  color: var(--text) !important;
  height: 100%;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace !important;
}
.cm-editor.cm-focused { outline: none !important; }
.cm-gutters { background: var(--bg) !important; border-right: 1px solid var(--border-soft) !important; color: var(--text-dim) !important; }
.cm-activeLineGutter { background: var(--surface) !important; color: var(--text-muted) !important; }
.cm-line { caret-color: var(--accent); }
.cm-cursor { border-left: 2px solid var(--accent) !important; }
.cm-selectionBackground { background: var(--accent-soft) !important; }
.cm-tooltip, .cm-panels { background: var(--bg-alt) !important; border-color: var(--border) !important; color: var(--text) !important; }

/* -------- Auth shell -------- */
.auth-shell {
  max-width: 360px;
  width: 100%;
  margin: 96px auto 24px;
  padding: 0 16px;
}
.auth-shell.wide { max-width: 480px; }
.auth-shell .logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 32px;
}
.auth-shell .logo .dot {
  width: 8px; height: 8px; border-radius: 2px; background: var(--accent);
}
.auth-shell h1 {
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}
.auth-shell .lead { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.auth-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
}
.auth-row { margin-bottom: 16px; }
.auth-row label { display: block; font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.auth-error { color: var(--bad); font-size: 11px; margin-top: 6px; font-family: 'JetBrains Mono', monospace; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--text-muted); font-size: 12px; }
.auth-foot a { color: var(--accent); }
.btn-fullw {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 32px;
  padding: 0 16px;
  border-radius: 5px;
  font-size: 12px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent);
  cursor: pointer; transition: background 0.1s ease;
  font-family: inherit;
}
.btn-fullw:hover { background: #b8c0ff; }

.role-radio input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.role-card {
  border: 1px solid var(--border); border-radius: 5px; padding: 12px 14px;
  cursor: pointer; transition: border-color 0.1s ease, background 0.1s ease;
  background: var(--bg);
}
.role-card:hover { border-color: var(--border-h); }
.role-card.selected {
  border-color: var(--accent); background: var(--accent-soft);
}

/* -------- Anti-cheat -------- */
.anticheat-veil {
  position: fixed; inset: 0; background: var(--bg); color: var(--text);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  z-index: 99999; padding: 64px; text-align: center; gap: 16px;
}
.anticheat-veil.hidden { display: none; }
.anticheat-veil h2 { font-size: 22px; letter-spacing: -0.01em; font-weight: 600; }

.cheat-banner {
  background: var(--bad-soft); border: 1px solid rgba(224,123,123,0.30);
  color: var(--bad); padding: 6px 10px; border-radius: 4px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

/* -------- Live timer -------- */
.timer {
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  color: var(--text);
}
.timer.warning { color: var(--warn); }
.timer.danger  { color: var(--bad); }

/* -------- Scrollbar -------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 0; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--surface-2); }

/* -------- Prose -------- */
.prose-warp { color: var(--text); line-height: 1.65; font-size: 13px; }
.prose-warp h1, .prose-warp h2, .prose-warp h3 { color: var(--text); letter-spacing: -0.01em; font-weight: 600; }
.prose-warp h1 { font-size: 16px; margin: 14px 0 8px; }
.prose-warp h2 { font-size: 14px; margin: 12px 0 6px; }
.prose-warp h3 { font-size: 12px; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.10em; color: var(--text-muted); }
.prose-warp p  { margin: 6px 0; }
.prose-warp code { background: var(--bg); border: 1px solid var(--border-soft); padding: 1px 5px; border-radius: 3px; font-size: 11px; color: var(--accent); }
.prose-warp pre { background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 10px; overflow: auto; }
.prose-warp ul, .prose-warp ol { padding-left: 18px; margin: 6px 0; }
.prose-warp li { margin: 2px 0; }
.prose-warp a { color: var(--accent); text-decoration: none; }
.prose-warp a:hover { text-decoration: underline; }
.prose-warp strong { color: var(--text); font-weight: 600; }

/* -------- Brand -------- */
.brand-mark { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.brand-mark .dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent);
}

/* -------- Bar (used for progress) -------- */
.bar-track { height: 4px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* -------- Section title (above table) -------- */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.section-title .dim { color: var(--text-dim); text-transform: none; letter-spacing: 0; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* utility */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.stack-2 > * + * { margin-top: 8px; }
.stack-3 > * + * { margin-top: 16px; }
.stack-4 > * + * { margin-top: 24px; }
