:root {
  --bg: #FFFFFF;
  --bg-alt: #F5F5F7;
  --card-bg: #FFFFFF;
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --blue: #0071E3;
  --blue-hover: #0077ED;
  --green: #1D8A3E;
  --red: #D70015;
  --orange: #C76A00;
  --purple: #8E44C4;
  --separator: rgba(0,0,0,0.1);
  --pill-bg: rgba(0,113,227,0.1);
  --green-bg: rgba(29,138,62,0.1);
  --red-bg: rgba(215,0,21,0.08);
  --segment-active-bg: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-alt: #1D1D1F;
    --card-bg: #1D1D1F;
    --text: #F5F5F7;
    --text-secondary: #86868B;
    --blue: #2997FF;
    --blue-hover: #5AB1FF;
    --green: #30D158;
    --red: #FF453A;
    --orange: #FF9F0A;
    --purple: #BF5AF2;
    --separator: rgba(255,255,255,0.14);
    --pill-bg: rgba(41,151,255,0.16);
    --green-bg: rgba(48,209,88,0.15);
    --red-bg: rgba(255,69,58,0.15);
    --segment-active-bg: #3A3A3C;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-alt: #1D1D1F;
  --card-bg: #1D1D1F;
  --text: #F5F5F7;
  --text-secondary: #86868B;
  --blue: #2997FF;
  --blue-hover: #5AB1FF;
  --green: #30D158;
  --red: #FF453A;
  --orange: #FF9F0A;
  --purple: #BF5AF2;
  --separator: rgba(255,255,255,0.14);
  --pill-bg: rgba(41,151,255,0.16);
  --green-bg: rgba(48,209,88,0.15);
  --red-bg: rgba(255,69,58,0.15);
  --segment-active-bg: #3A3A3C;
}

:root[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-alt: #F5F5F7;
  --card-bg: #FFFFFF;
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --blue: #0071E3;
  --blue-hover: #0077ED;
  --green: #1D8A3E;
  --red: #D70015;
  --orange: #C76A00;
  --purple: #8E44C4;
  --separator: rgba(0,0,0,0.1);
  --pill-bg: rgba(0,113,227,0.1);
  --green-bg: rgba(29,138,62,0.1);
  --red-bg: rgba(215,0,21,0.08);
  --segment-active-bg: #FFFFFF;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: rgba(0,0,0,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.nav-title { color: #F5F5F7; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.nav-back { color: #F5F5F7; font-size: 13px; cursor: pointer; opacity: 0.85; min-width: 60px; }
.nav-back:hover { opacity: 1; }
.nav-spacer { min-width: 60px; display: flex; justify-content: flex-end; }

.nav-controls { display: flex; align-items: center; gap: 10px; }
.theme-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer;
}
.theme-btn:hover { background: rgba(255,255,255,0.16); }
.lang-flags { display: flex; gap: 4px; background: rgba(255,255,255,0.08); border-radius: 980px; padding: 3px; }
.lang-flag {
  width: 26px; height: 22px; border-radius: 980px; border: none; cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  background: transparent; opacity: 0.55;
}
.lang-flag.active { background: rgba(255,255,255,0.9); opacity: 1; }
.timer-pill { color: #F5F5F7; font-size: 13px; font-weight: 600; background: rgba(255,255,255,0.1); padding: 5px 12px; border-radius: 980px; }
.timer-pill.low { background: rgba(255,69,58,0.35); }

.menu-card { position: relative; }
.menu-card .module-subtitle { min-height: 20px; }
.badge-new { position: absolute; top: 18px; right: 18px; background: var(--purple); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 980px; letter-spacing: 0.02em; }

.exam-toggle-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 0 0 32px; }
.exam-toggle-row label { font-size: 15px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 10px; }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; background: var(--separator); border-radius: 980px; transition: background .2s; cursor: pointer; }
.switch-slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .switch-slider { background: var(--blue); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

.history-item { background: var(--card-bg); border: 1px solid var(--separator); border-radius: 16px; padding: 18px 22px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.history-main { font-size: 16px; font-weight: 600; }
.history-meta { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.history-score { font-size: 20px; font-weight: 700; flex-shrink: 0; }

.progress-track { height: 3px; background: var(--separator); flex-shrink: 0; }
.progress-fill { height: 100%; background: var(--blue); transition: width .3s ease; }

.section { flex: 1; padding: 64px 22px 80px; }
@media (max-width: 700px) { .section { padding: 40px 18px 56px; } }

.container { max-width: 980px; margin: 0 auto; width: 100%; }
.container-narrow { max-width: 640px; margin: 0 auto; width: 100%; }

.hero-eyebrow { text-align: center; color: var(--blue); font-size: 17px; font-weight: 600; margin: 0 0 10px; }
.hero-title { text-align: center; font-size: 56px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.07; margin: 0 0 18px; }
@media (max-width: 700px) { .hero-title { font-size: 32px; } }
.hero-subtitle { text-align: center; font-size: 21px; color: var(--text-secondary); max-width: 560px; margin: 0 auto 56px; line-height: 1.45; }
@media (max-width: 700px) { .hero-subtitle { font-size: 16px; margin-bottom: 36px; } }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

.module-card {
  background: var(--card-bg);
  border: 1px solid var(--separator);
  border-radius: 20px;
  padding: 32px 28px;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}
.module-card:hover { transform: translateY(-6px); box-shadow: 0 20px 40px rgba(0,0,0,0.12); }
.module-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 22px; }
.module-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.01em; }
.module-subtitle { font-size: 15px; color: var(--text-secondary); }
.module-arrow { margin-top: 22px; color: var(--blue); font-size: 15px; font-weight: 600; }

.segmented-wrap { display: flex; justify-content: center; margin-bottom: 44px; }
.segmented { display: inline-flex; background: var(--bg-alt); border: 1px solid var(--separator); border-radius: 980px; padding: 4px; }
.segmented button {
  padding: 11px 26px;
  border: none;
  background: transparent;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.segmented button.active { background: var(--segment-active-bg); box-shadow: 0 2px 10px rgba(0,0,0,.15); font-weight: 700; }

.btn-row { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.btn-primary {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 980px;
  padding: 15px 34px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--blue);
  border: none;
  padding: 15px 20px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { text-decoration: underline; }

.quiz-wrap { max-width: 680px; margin: 0 auto; }
.domain-pill { display: inline-block; background: var(--pill-bg); color: var(--blue); font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 980px; margin-bottom: 22px; }
.scenario-box { background: var(--bg-alt); border-radius: 16px; padding: 20px 24px; font-size: 16px; color: var(--text-secondary); margin-bottom: 22px; line-height: 1.5; }
.question-text { font-size: 28px; font-weight: 600; letter-spacing: -0.012em; line-height: 1.3; margin-bottom: 34px; }
@media (max-width: 700px) { .question-text { font-size: 21px; margin-bottom: 26px; } }

.answers { display: flex; flex-direction: column; gap: 12px; }
.answer {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--separator);
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .15s;
}
.answer:hover:not(.disabled) { border-color: var(--blue); transform: translateY(-2px); }
.answer .badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.answer-text { font-size: 16px; line-height: 1.45; }
.answer.correct { border-color: var(--green); background: var(--green-bg); }
.answer.correct .badge { background: var(--green); color: #fff; }
.answer.wrong { border-color: var(--red); background: var(--red-bg); }
.answer.wrong .badge { background: var(--red); color: #fff; }
.answer.disabled { cursor: default; }

.explanation {
  background: var(--bg-alt);
  border-radius: 16px;
  padding: 20px 22px;
  margin-top: 20px;
  font-size: 15px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  line-height: 1.5;
}

.quiz-actions { max-width: 680px; margin: 34px auto 0; display: flex; justify-content: flex-end; }

.ring-wrap { display: flex; justify-content: center; padding: 0 0 24px; }
.ring-wrap svg { width: 200px; height: 200px; }
.ring-bg { stroke: var(--separator); fill: none; stroke-width: 14; }
.ring-fg { stroke: var(--blue); fill: none; stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring-text { font-size: 34px; font-weight: 700; fill: var(--text); font-family: inherit; }
.ring-sub { font-size: 14px; fill: var(--text-secondary); font-family: inherit; }

.stat-card { background: var(--card-bg); border: 1px solid var(--separator); border-radius: 16px; padding: 20px 22px; }
.stat-top { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 10px; gap: 12px; }
.stat-top span:first-child { color: var(--text); font-weight: 500; }
.stat-top span:last-child { color: var(--text-secondary); flex-shrink: 0; }
.stat-bar-track { height: 6px; background: var(--bg-alt); border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--blue); border-radius: 3px; }

.section-label { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 56px 0 20px; text-align: center; }
@media (max-width: 700px) { .section-label { font-size: 20px; margin: 40px 0 16px; } }

.missed-item { background: var(--card-bg); border: 1px solid var(--separator); border-radius: 16px; padding: 20px 22px; margin-bottom: 14px; }
.missed-item .q { font-weight: 600; margin-bottom: 8px; font-size: 16px; }
.missed-item .ans { color: var(--green); font-size: 14px; margin-bottom: 6px; font-weight: 500; }
.missed-item .exp { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

.empty-note { text-align: center; color: var(--text-secondary); font-size: 16px; margin: 32px 0; }

.center-fill { flex: 1; display: flex; align-items: center; justify-content: center; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--separator); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .35s ease; }
