:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --secondary: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Navbar ─────────────────────────────────────── */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-container {
  max-width: 1100px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.nav-brand {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.2rem; font-weight: 700; color: var(--primary);
  text-decoration: none;
}
.brand-icon { font-size: 1.4rem; }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link { text-decoration: none; color: var(--text-muted); font-size: .95rem; }
.nav-link:hover { color: var(--primary); }
.btn-nav {
  background: var(--primary); color: #fff !important;
  padding: .35rem .9rem; border-radius: 6px; font-size: .9rem;
}

/* ── Main ────────────────────────────────────────── */
.main-content { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .65rem 1.4rem; border-radius: 8px; font-size: 1rem;
  font-weight: 600; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Hero ─────────────────────────────────────────── */
.hero {
  text-align: center; padding: 3rem 0 2.5rem;
}
.hero h1 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 1rem; }
.hero p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 1.8rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ── Section headers ──────────────────────────────── */
.section-header {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
}
.badge-today {
  background: var(--primary); color: #fff;
  padding: .25rem .75rem; border-radius: 20px; font-size: .8rem; font-weight: 700;
}
.subject-tag {
  color: var(--text-muted); font-size: .9rem;
}
.daily-section { margin-bottom: 2.5rem; }

/* ── Question Card ───────────────────────────────── */
.question-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2rem; margin-bottom: 1.5rem;
}
.question-topic {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  color: var(--primary); letter-spacing: .05em; margin-bottom: .75rem;
}
.question-text {
  font-size: 1.05rem; font-weight: 500; margin-bottom: 1.5rem; line-height: 1.7;
}
.options { display: flex; flex-direction: column; gap: .75rem; }
.option-btn {
  display: flex; align-items: flex-start; gap: .75rem;
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 8px; padding: .85rem 1rem; cursor: pointer;
  text-align: left; transition: all .15s; width: 100%; font-size: 1rem;
}
.option-btn:hover { border-color: var(--primary); background: #eef2ff; }
.option-btn.correct { border-color: var(--success); background: #d1fae5; }
.option-btn.wrong { border-color: var(--danger); background: #fee2e2; }
.option-btn.show-correct { border-color: var(--success); background: #d1fae5; }
.option-btn:disabled { cursor: default; }
.option-letter {
  font-weight: 800; color: var(--primary); min-width: 1.2rem;
}
.option-text { line-height: 1.5; }

/* Result area */
.result-area { margin-top: 1.2rem; border-radius: 8px; padding: 1rem 1.2rem; }
.result-area.correct-result { background: #d1fae5; border: 1px solid #6ee7b7; }
.result-area.wrong-result { background: #fee2e2; border: 1px solid #fca5a5; }
.result-title { font-weight: 700; font-size: 1.05rem; margin-bottom: .5rem; }
.result-explanation { font-size: .95rem; line-height: 1.7; white-space: pre-line; }
.hidden { display: none !important; }

.question-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }

/* ── Subject grid ────────────────────────────────── */
.subjects-section { margin-bottom: 2.5rem; }
.subjects-section h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.subject-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
.subject-card {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1rem;
  text-decoration: none; color: var(--text); font-weight: 600;
  font-size: .9rem; transition: all .15s; text-align: center;
}
.subject-card:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.subject-icon { font-size: 2rem; }

/* ── Features ────────────────────────────────────── */
.features-section { margin-bottom: 2.5rem; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature-card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; box-shadow: var(--shadow);
}
.feature-icon { font-size: 2rem; margin-bottom: .5rem; }
.feature-card h3 { font-size: 1rem; margin-bottom: .4rem; }
.feature-card p { color: var(--text-muted); font-size: .88rem; line-height: 1.5; }

/* ── Auth pages ──────────────────────────────────── */
.auth-page {
  max-width: 440px; margin: 2rem auto;
}
.auth-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2.5rem;
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.auth-sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .95rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-weight: 600; font-size: .9rem; }
.form-group input {
  border: 2px solid var(--border); border-radius: 8px;
  padding: .65rem .9rem; font-size: 1rem; outline: none; transition: border .15s;
}
.form-group input:focus { border-color: var(--primary); }
.auth-alt { margin-top: 1.2rem; text-align: center; color: var(--text-muted); font-size: .9rem; }
.auth-alt a { color: var(--primary); font-weight: 600; }

/* ── Dashboard ───────────────────────────────────── */
.dashboard-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.dashboard-header h1 { font-size: 1.6rem; }
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: .85rem; margin-top: .2rem; }
.stat-correct .stat-number { color: var(--success); }
.stat-wrong .stat-number { color: var(--danger); }
.stat-rate .stat-number { color: var(--primary); }

.section-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem;
}
.section-card h2 { font-size: 1.15rem; margin-bottom: 1rem; }

.subject-stats { display: flex; flex-direction: column; gap: .75rem; }
.subject-row {
  display: grid; grid-template-columns: 180px 1fr 60px 60px auto;
  align-items: center; gap: .75rem;
}
.subject-name { font-weight: 600; font-size: .9rem; }
.progress-bar-wrap { background: var(--bg); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }
.subject-rate { font-weight: 700; font-size: .9rem; text-align: right; }
.rate-low { color: var(--danger); }
.rate-mid { color: var(--warning); }
.rate-high { color: var(--success); }
.subject-detail { color: var(--text-muted); font-size: .8rem; text-align: center; }

.recent-list { display: flex; flex-direction: column; gap: .5rem; }
.recent-item {
  display: grid; grid-template-columns: 30px 130px 1fr 60px;
  align-items: center; gap: .75rem; padding: .6rem .75rem;
  border-radius: 8px; font-size: .88rem; background: var(--bg);
}
.recent-item.correct { background: #f0fdf4; }
.recent-item.wrong { background: #fff1f2; }
.recent-subject { font-weight: 600; color: var(--text-muted); }
.recent-q { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-answer { font-weight: 700; text-align: center; }

/* ── Question page ───────────────────────────────── */
.question-page { }
.question-header { margin-bottom: 1.5rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-label { font-weight: 600; font-size: .85rem; color: var(--text-muted); }
.filter-chip {
  padding: .3rem .75rem; border-radius: 20px; font-size: .82rem; font-weight: 600;
  text-decoration: none; background: var(--bg); border: 2px solid var(--border);
  color: var(--text-muted); transition: all .15s;
}
.filter-chip:hover, .filter-chip.active { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.subject-badge {
  display: inline-block; background: var(--primary); color: #fff;
  padding: .25rem .9rem; border-radius: 20px; font-size: .82rem;
  font-weight: 700; margin-bottom: 1rem;
}

/* ── Alerts ──────────────────────────────────────── */
.alert {
  border-radius: 8px; padding: .85rem 1rem; margin-bottom: 1.2rem; font-size: .92rem;
}
.alert-warn { background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; }
.alert-error { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Empty state ─────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 0; }
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h2 { font-size: 1.4rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Admin ───────────────────────────────────────── */
.admin-page { max-width: 700px; }
.admin-page h1 { margin-bottom: .5rem; }
.admin-form { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0; }
.admin-form select { padding: .6rem .9rem; border-radius: 8px; border: 2px solid var(--border); font-size: 1rem; }
.admin-log { background: #1e293b; color: #94a3b8; border-radius: 8px; padding: 1rem; font-size: .85rem; min-height: 100px; max-height: 400px; overflow-y: auto; font-family: monospace; }
.admin-log div { padding: .2rem 0; border-bottom: 1px solid #334155; }

/* ── Footer ──────────────────────────────────────── */
.footer {
  text-align: center; padding: 2rem; color: var(--text-muted);
  font-size: .85rem; border-top: 1px solid var(--border); margin-top: 3rem;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.6rem; }
  .subject-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .subject-row { grid-template-columns: 1fr 1fr; }
  .recent-item { grid-template-columns: 30px 1fr; grid-template-rows: auto auto; }
}
