:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3348;
  --text: #e4e6f0;
  --text2: #9ca3bf;
  --primary: #6c63ff;
  --primary-hover: #7f78ff;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── NAV ──────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .logo {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  margin-right: 24px;
}
nav button {
  background: none;
  border: none;
  color: var(--text2);
  padding: 8px 16px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: .2s;
}
nav button:hover, nav button.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── CONTAINER ────────────────────────── */
.container {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ── CARDS ────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 16px; font-size: 1.1rem; }
.card h3 { margin-bottom: 8px; font-size: 1rem; color: var(--text2); }

/* ── FORMS ────────────────────────────── */
input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .9rem;
  width: 100%;
  margin-bottom: 10px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
label {
  display: block;
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: 4px;
}

/* ── BUTTONS ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ── ALTERNATIVES ─────────────────────── */
.alt-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  margin-bottom: 8px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: .95rem;
  transition: .2s;
  position: relative;
}
.alt-btn:hover { border-color: var(--primary); }
.alt-btn.selected { border-color: var(--primary); background: rgba(108,99,255,.15); }
.alt-btn.correct { border-color: var(--success); background: rgba(34,197,94,.12); }
.alt-btn.wrong { border-color: var(--danger); background: rgba(239,68,68,.12); }
.alt-btn .letter {
  font-weight: 700;
  margin-right: 10px;
  color: var(--primary);
}
.alt-comment {
  font-size: .82rem;
  color: var(--text2);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.alt-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
}
.alt-btn:hover .alt-actions,
.alt-btn.correct .alt-actions,
.alt-btn.wrong .alt-actions { display: block; }

/* ── FLASHCARD ────────────────────────── */
.flashcard {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: .2s;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.05rem;
}
.flashcard:hover { border-color: var(--primary); }
.flashcard .back { display: none; }
.flashcard.flipped .front { display: none; }
.flashcard.flipped .back { display: block; color: var(--success); }

/* ── TAGS / BADGES ────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-primary { background: rgba(108,99,255,.2); color: var(--primary); }
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,.15); color: var(--danger); }

/* ── STATS ────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
}
.stat-card .label {
  font-size: .8rem;
  color: var(--text2);
}

/* ── FILTERS ROW ──────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: end;
}
.filters > div { flex: 1; min-width: 150px; }

/* ── MODAL ────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; }

/* ── TABLE ────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
th { color: var(--text2); font-weight: 600; }

/* ── QUESTION IMAGE ───────────────────── */
.q-image {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 12px 0;
}

/* ── DASHBOARD GRID ──────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.widget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform .2s, border-color .2s;
  position: relative;
}
.widget-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.widget-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: var(--text);
}
.widget-card .icon {
  font-size: 1.5rem;
  background: var(--surface2);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.widget-content {
  flex: 1;
}

.w-full { width: 100%; }

/* ── SABIDOMETRO REFINED ─────────────── */
.sabidometro-card {
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}
.sabidometro-gauge {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--p), var(--surface2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 20px rgba(108,99,255,0.2);
}
.sabidometro-gauge::after {
  content: attr(data-score) '%';
  position: absolute;
  width: 110px;
  height: 110px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--primary);
}
.sabidometro-info h3 { font-size: 1.5rem; margin-bottom: 10px; }
.sabidometro-msg { font-size: 1.1rem; }

/* ── RANGE INDICATORS ─────────────────── */
.stat-bar-container {
  height: 45px;
  width: 100%;
  background: var(--bg);
  border-radius: 8px;
  margin: 15px 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.stat-bar-top {
  position: absolute;
  top: 0;
  left: 0;
  height: 50%;
  background: var(--primary);
  opacity: 0.4;
  transition: width 0.5s ease;
}
.stat-bar-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 50%;
  background: var(--success);
  opacity: 0.7;
  transition: width 0.5s ease;
}
.stat-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 5;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  pointer-events: none;
  color: #fff;
}

/* ── EXPLORER VIEW ───────────────────── */
.explorer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.explorer-item {
  background: var(--surface2);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: .2s;
}
.explorer-item:hover {
  border-color: var(--primary);
  background: var(--surface);
}
.explorer-item h4 { margin-bottom: 8px; color: var(--primary); }
.explorer-item .count { font-size: 0.8rem; color: var(--text2); }

/* ── JSON EDITOR ─────────────────────── */
#jsonArea {
  font-family: monospace;
  font-size: 0.85rem;
  background: #1e1e1e;
  color: #d4d4d4;
  min-height: 400px;
}

/* ── SCROLLING BAR LABELS ────────────── */
.range-label-top {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 4px;
  min-height: 1.4em;
}

/* ── PREVIEW ─────────────────────────── */
.preview-box {
  background: var(--surface2);
  border: 2px dashed var(--border);
  padding: 20px;
  margin-top: 20px;
  border-radius: var(--radius);
}
.preview-info {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* MISC ───────────────────────────────── */
.hidden { display: none !important; }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-muted { color: var(--text2); }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* scroll */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
