/* Tokens — dark by default, light via [data-theme="light"]. */
:root {
  --bg:         #0a0a0a;
  --bg-elev:    #111113;
  --bg-elev-2:  #18181b;
  --border:     #26262a;
  --border-strong: #34343a;
  --text:       #e8e8ea;
  --text-dim:   #9a9aa3;
  --text-faint: #6a6a73;
  --accent:     #e5e5e7;
  --accent-fg:  #0a0a0a;
  --danger:     #f87171;
  --ok:         #86efac;
  --warn:       #fbbf24;

  --radius:     8px;
  --radius-lg:  12px;

  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 12px rgba(0,0,0,.5);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg:         #fafafa;
  --bg-elev:    #ffffff;
  --bg-elev-2:  #f4f4f5;
  --border:     #e4e4e7;
  --border-strong: #d4d4d8;
  --text:       #18181b;
  --text-dim:   #52525b;
  --text-faint: #a1a1aa;
  --accent:     #18181b;
  --accent-fg:  #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }

button {
  font: inherit;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
button:hover { background: var(--bg-elev-2); border-color: var(--text-faint); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
button.primary:hover { opacity: .9; background: var(--accent); }

button.ghost {
  background: transparent;
  border-color: var(--border);
}

input, textarea, select {
  font: inherit;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 12px;
  border-radius: var(--radius);
  width: 100%;
  outline: none;
  transition: border-color .15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--text-faint); }
textarea { font-family: var(--font-mono); min-height: 160px; resize: vertical; }

label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

code, pre, kbd { font-family: var(--font-mono); font-size: 13px; }
pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
}
:not(pre) > code {
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-weight: 600;
  letter-spacing: -.01em;
  padding: 4px 8px 20px;
  font-size: 15px;
}
.brand small { display: block; color: var(--text-faint); font-weight: 400; font-size: 12px; margin-top: 2px; }
.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13.5px;
}
.nav-link:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-link.active { background: var(--bg-elev-2); color: var(--text); }
.sidebar .spacer { flex: 1; }

.main {
  padding: 44px 56px 96px;
  max-width: 1100px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.015em;
  margin: 0 0 6px;
}
.page-header .subtitle {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
}
.crumbs {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.crumbs a:hover { color: var(--text-dim); }

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
}
.card + .card { margin-top: 20px; }
.card h2, .card h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.card p { color: var(--text-dim); margin: 6px 0; }
ul.card, ol.card { padding: 12px 28px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar .spacer { display: none; }
  .main { padding: 24px 20px 60px; }
}

/* Stat tiles */
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; }
.stat .hint  { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* Progress bar */
.progress {
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 2px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--text-dim);
}

/* Pills / badges */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-elev-2);
}
.pill.easy   { color: var(--ok); }
.pill.medium { color: var(--warn); }
.pill.hard   { color: var(--danger); }

/* List of items */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.list li:first-child { border-top: none; }
.list .title { color: var(--text); line-height: 1.45; }
.list .meta  { color: var(--text-faint); font-size: 12.5px; margin-top: 3px; }

/* Forms */
.form { display: grid; gap: 14px; max-width: 420px; }
.form .actions { display: flex; gap: 10px; justify-content: flex-end; }
.error-text { color: var(--danger); font-size: 13px; }
.ok-text    { color: var(--ok);     font-size: 13px; }

/* Score badge */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 13px;
}
.score.high { color: var(--ok); }
.score.mid  { color: var(--warn); }
.score.low  { color: var(--danger); }

/* Markdown content */
.md { line-height: 1.65; }
.md h1, .md h2, .md h3 { letter-spacing: -.01em; margin-top: 22px; margin-bottom: 8px; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 16px; }
.md h3 { font-size: 14.5px; }
.md p { color: var(--text); margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; margin: 8px 0; }
.md li { margin: 4px 0; }
.md code { font-size: 12.5px; }
.md a { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--text-dim); }

/* Login page */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -.01em;
}
.auth-card .subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Small helpers */
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--font-mono); }
.small { font-size: 12.5px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
