:root {
  --blue: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #15803d;
  --green-light: #f0fdf4;
  --red: #b91c1c;
  --red-light: #fef2f2;
  --orange: #c2410c;
  --orange-light: #fff7ed;
  --gold-light: #fefce8;
  --gold: #a16207;
  --gray: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --text: #111827;
  --sidebar-w: 300px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px 16px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand-icon { font-size: 30px; }
.brand h1 { font-size: 16px; color: #fff; }
.brand p { font-size: 12px; color: #94a3b8; }

.progress-box { background: #1e293b; border-radius: 10px; padding: 12px; margin-bottom: 20px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; color: #cbd5e1; }
.progress-bar { height: 8px; background: #334155; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: #22c55e; border-radius: 4px; transition: width .4s; }

.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin: 18px 8px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px;
  margin-bottom: 2px;
}
.nav-link:hover { background: #1e293b; color: #fff; }
.nav-link.active { background: var(--blue); color: #fff; }
.nav-link.done::after { content: "✓"; margin-left: auto; color: #22c55e; font-weight: 700; }
.nav-link.active.done::after { color: #bbf7d0; }
.mod-num { font-size: 11px; font-weight: 700; background: #1e293b; border-radius: 4px; padding: 2px 5px; color: #93c5fd; }
.nav-link.active .mod-num { background: rgba(255,255,255,.2); color: #fff; }
.autosave-note { font-size: 11px; color: #64748b; margin-top: 24px; line-height: 1.5; }

/* ── Content ── */
.content { margin-left: var(--sidebar-w); flex: 1; padding: 40px 48px; max-width: 1080px; }
.section { display: none; animation: fadein .25s; }
.section.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.module-tag { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--blue); margin-bottom: 6px; }
h2 { font-size: 28px; margin-bottom: 12px; }
h3 { font-size: 19px; margin: 30px 0 12px; }
.lead { font-size: 16px; color: #374151; line-height: 1.7; margin-bottom: 18px; }
p { line-height: 1.65; }

/* ── Cards ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin: 14px 0; }
.flip-card, .home-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.flip-card h4 { margin: 8px 0 6px; font-size: 15px; }
.flip-card .reveal { display: none; font-size: 14px; color: #374151; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.flip-card.open .reveal { display: block; }
.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.mini-badge { display: inline-block; font-size: 11px; font-weight: 700; background: var(--blue-light); color: var(--blue); padding: 3px 8px; border-radius: 20px; }

.home-card { cursor: pointer; }
.home-card .mod-label { font-size: 11px; font-weight: 700; color: var(--blue); text-transform: uppercase; }
.home-card h4 { margin: 6px 0; }
.home-card p { font-size: 13px; color: var(--gray); }
.home-card .status { font-size: 12px; margin-top: 10px; font-weight: 600; }
.home-card .status.done { color: var(--green); }
.home-card .status.todo { color: var(--gray); }

/* ── Info boxes ── */
.info-box { border-radius: 12px; padding: 18px 20px; margin: 18px 0; border: 1px solid; }
.info-box h3 { margin: 0 0 8px; font-size: 16px; }
.info-box.blue { background: var(--blue-light); border-color: #bfdbfe; }
.info-box.green { background: var(--green-light); border-color: #bbf7d0; }
.info-box.red { background: var(--red-light); border-color: #fecaca; }
.info-box.orange { background: var(--orange-light); border-color: #fed7aa; }
.info-box.gold { background: var(--gold-light); border-color: #fde68a; }
.info-box.neutral { background: #fff; border-color: var(--border); }
.info-box ol, .info-box ul { margin: 8px 0 0 20px; line-height: 1.8; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tip { background: var(--gold-light); border-left: 4px solid #eab308; padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 14px 0; font-size: 14px; }

/* ── Tables ── */
.compare-table { overflow-x: auto; margin: 14px 0; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #0f172a; color: #fff; font-size: 13px; }
td.ok { color: var(--green); font-weight: 600; }
td.warn { color: var(--orange); font-weight: 600; }

/* ── Do / Don't ── */
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0; }
.do, .dont { border-radius: 12px; padding: 16px 18px; }
.do { background: var(--green-light); border: 1px solid #bbf7d0; }
.dont { background: var(--red-light); border: 1px solid #fecaca; }
.do h4 { color: var(--green); margin-bottom: 8px; }
.dont h4 { color: var(--red); margin-bottom: 8px; }
.do ul, .dont ul { margin-left: 18px; line-height: 1.8; font-size: 14px; }

/* ── Rule lists ── */
.rule-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.rule-list .rule { padding: 12px 16px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.rule-list.red .rule { background: var(--red-light); border-left: 4px solid var(--red); }
.rule-list.orange .rule { background: var(--orange-light); border-left: 4px solid #f97316; }

/* ── Timeline ── */
.timeline { position: relative; margin: 20px 0 20px 12px; padding-left: 28px; border-left: 3px solid #bfdbfe; }
.timeline-item { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.timeline-item::before {
  content: ""; position: absolute; left: -37px; top: 20px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--blue);
}
.timeline-date { font-size: 12px; font-weight: 700; color: var(--blue); text-transform: uppercase; }
.timeline-item h4 { margin: 4px 0; }
.timeline-item .reveal { display: none; font-size: 14px; color: #374151; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.timeline-item.open .reveal { display: block; }

/* ── Stepper ── */
.stepper { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.step { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: relative; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 10px;
}
.step h4 { font-size: 14px; margin-bottom: 6px; }
.step p { font-size: 13px; color: var(--gray); }

/* ── Order game ── */
.order-game { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 12px 0; }
.order-pool { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.order-chip {
  padding: 10px 16px; border-radius: 30px; border: 2px solid var(--blue); color: var(--blue);
  background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; transition: all .15s;
}
.order-chip:hover { background: var(--blue-light); }
.order-chip.used { opacity: .35; pointer-events: none; }
.order-slots { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 46px; }
.order-slot { padding: 10px 16px; border-radius: 30px; background: var(--blue-light); font-weight: 600; font-size: 14px; }
.order-result { margin-top: 12px; font-weight: 700; }
.order-result.good { color: var(--green); }
.order-result.bad { color: var(--red); }

/* ── Simulator ── */
.simulator { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 12px 0; }
.sim-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sim-btn {
  padding: 9px 14px; border-radius: 30px; border: 1.5px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13px; transition: all .15s;
}
.sim-btn:hover { border-color: var(--blue); color: var(--blue); }
.sim-btn.selected { background: var(--blue); border-color: var(--blue); color: #fff; }
.sim-verdict { border-radius: 10px; padding: 16px; min-height: 60px; }
.sim-verdict .placeholder { color: var(--gray); font-style: italic; }
.sim-verdict.v-red { background: var(--red-light); border: 1px solid #fecaca; }
.sim-verdict.v-orange { background: var(--orange-light); border: 1px solid #fed7aa; }
.sim-verdict.v-green { background: var(--green-light); border: 1px solid #bbf7d0; }
.verdict-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.v-red .verdict-title { color: var(--red); }
.v-orange .verdict-title { color: var(--orange); }
.v-green .verdict-title { color: var(--green); }
.verdict-ref { font-size: 12px; color: var(--gray); margin-top: 8px; font-style: italic; }

/* ── Buttons ── */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all .15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1e40af; color: #fff; }
.btn.complete { margin-top: 26px; background: var(--green); border-color: var(--green); color: #fff; }
.btn.complete:hover { background: #166534; color: #fff; }
.btn.complete.is-done { background: #fff; color: var(--green); }

/* ── Quiz ── */
.quiz-inline { margin-top: 30px; }
.quiz-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 14px; }
.quiz-box .q-text { font-weight: 700; margin-bottom: 12px; }
.q-opts { display: flex; flex-direction: column; gap: 8px; }
.q-opt {
  text-align: left; padding: 11px 14px; border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff; cursor: pointer; font-size: 14px; transition: all .12s;
}
.q-opt:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-light); }
.q-opt.correct { border-color: var(--green); background: var(--green-light); font-weight: 700; }
.q-opt.wrong { border-color: var(--red); background: var(--red-light); }
.q-opt:disabled { cursor: default; }
.q-explain { display: none; margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--blue-light); font-size: 14px; line-height: 1.6; }
.q-explain.show { display: block; }
.q-explain .q-ref { display: block; margin-top: 6px; font-size: 12px; color: var(--gray); font-style: italic; }
.quiz-title { font-size: 17px; font-weight: 800; margin-bottom: 12px; }

/* ── Exam ── */
.exam-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 18px 0; }
.exam-level-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px; text-align: center; }
.exam-level-card h3 { margin: 0 0 8px; }
.exam-level-card p { font-size: 14px; color: var(--gray); margin-bottom: 8px; }
.best-score { font-weight: 700; color: var(--text) !important; }
.exam-progress { font-size: 13px; color: var(--gray); margin-bottom: 10px; }
.exam-score-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 26px; text-align: center; margin-top: 18px; }
.exam-score-box .big-score { font-size: 44px; font-weight: 800; }
.exam-score-box .pass { color: var(--green); }
.exam-score-box .fail { color: var(--red); }

/* ── Flashcards ── */
.flashcard-zone { max-width: 620px; margin: 24px auto; text-align: center; }
.flashcard { perspective: 1200px; cursor: pointer; height: 300px; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px; font-size: 18px; line-height: 1.6;
}
.flashcard-front { background: #0f172a; color: #fff; }
.flashcard-back { background: var(--blue-light); border: 2px solid #bfdbfe; transform: rotateY(180deg); }
.fc-hint { font-size: 12px; color: #94a3b8; margin-top: 16px; }
.fc-ref { font-size: 12px; color: var(--gray); font-style: italic; margin-top: 14px; }
.fc-controls { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 18px; }
#fc-counter { font-weight: 700; color: var(--gray); }

/* ── Glossary ── */
.search-input {
  width: 100%; padding: 13px 16px; border-radius: 10px; border: 1.5px solid var(--border);
  font-size: 15px; margin: 14px 0 20px;
}
.search-input:focus { outline: none; border-color: var(--blue); }
.gl-term { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; }
.gl-term h4 { color: var(--blue); margin-bottom: 4px; }
.gl-term p { font-size: 14px; color: #374151; }
.gl-empty { color: var(--gray); font-style: italic; }

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; height: auto; }
  body { flex-direction: column; }
  .content { margin-left: 0; padding: 24px 18px; }
  .two-col, .dodont { grid-template-columns: 1fr; }
}

/* ── Icons (Lucide) ── */
svg.icon, i.icon { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
h2 svg.icon, h3 svg.icon { width: 19px; height: 19px; vertical-align: -3px; }
.brand-icon svg.icon { width: 30px; height: 30px; color: #93c5fd; vertical-align: middle; }
.nav-link svg.icon { width: 15px; height: 15px; }
.autosave-note svg.icon { width: 13px; height: 13px; }
svg.icon.dot-green { color: var(--green); }
svg.icon.dot-blue { color: var(--blue); }
svg.icon.dot-red { color: var(--red); }
svg.icon.dot-orange { color: #f97316; }
svg.icon.icon-light { color: #fff; }
.do h4 svg.icon { color: var(--green); }
.dont h4 svg.icon { color: var(--red); }
.verdict-title svg.icon { width: 18px; height: 18px; }
.exam-level-card h3 svg.icon { width: 14px; height: 14px; }
.rule svg.icon { margin-right: 6px; vertical-align: -3px; }
.sim-btn svg.icon { width: 14px; height: 14px; }
