:root {
  --bg: #0f1117;
  --bg-card: #181b24;
  --bg-hover: #1f2430;
  --border: #2a3142;
  --text: #e8eaef;
  --text-muted: #8b93a7;
  --accent: #5b8def;
  --accent-hover: #4a7de0;
  --success: #3ecf8e;
  --success-bg: rgba(62, 207, 142, 0.12);
  --error: #f07178;
  --error-bg: rgba(240, 113, 120, 0.12);
  --warning: #e6b450;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 720px;
  --header-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(var(--max-width) + 32px);
  margin: 0 auto;
  padding: 12px 16px;
  min-height: var(--header-h);
}

.header__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--max-width) + 32px);
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

.footer p { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover { background: var(--border); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
}

.btn--ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn--icon { border-radius: 50%; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Home */
.home-intro {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.9375rem;
}

.module-grid {
  display: grid;
  gap: 12px;
}

.module-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.module-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.module-card__icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.module-card__body { flex: 1; min-width: 0; }

.module-card__title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.module-card__desc {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.module-card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.stats-bar strong { color: var(--text); }

/* Mode select */
.mode-select {
  margin-bottom: 20px;
}

.mode-select__label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-toggle__btn {
  padding: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.mode-toggle__btn:hover { border-color: var(--text-muted); }

.mode-toggle__btn.is-active {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.1);
}

.mode-toggle__btn small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Quiz */
.quiz-top {
  margin-bottom: 20px;
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress__bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.nav-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.nav-dot {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-dot:hover { border-color: var(--accent); color: var(--text); }

.nav-dot.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.nav-dot.is-answered { background: var(--bg-hover); color: var(--text); }
.nav-dot.is-correct { border-color: var(--success); color: var(--success); }
.nav-dot.is-wrong { border-color: var(--error); color: var(--error); }

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.question-card__text {
  margin: 0 0 20px;
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.45;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.option:hover:not(:disabled) {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.option.is-selected {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.08);
}

.option.is-correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.option.is-wrong {
  border-color: var(--error);
  background: var(--error-bg);
}

.option:disabled { cursor: default; }

.option__letter {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--border);
  font-size: 0.75rem;
  font-weight: 600;
}

.option.is-correct .option__letter { background: var(--success); color: #0f1117; }
.option.is-wrong .option__letter { background: var(--error); color: #fff; }

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
}

.feedback--learn {
  background: var(--success-bg);
  border: 1px solid rgba(62, 207, 142, 0.35);
  color: var(--text);
}

.feedback--result {
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

.feedback__title {
  font-weight: 600;
  margin: 0 0 6px;
}

.feedback__title--ok { color: var(--success); }
.feedback__title--bad { color: var(--error); }

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quiz-actions .btn { flex: 1; min-width: 120px; }

/* Results */
.results {
  text-align: center;
  padding: 24px 16px;
}

.results__score {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
}

.results__label {
  color: var(--text-muted);
  margin: 0 0 24px;
}

.results__breakdown {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  max-height: 320px;
  overflow-y: auto;
}

.result-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.result-item:last-child { border-bottom: none; }

.result-item__icon { flex-shrink: 0; }
.result-item__text { flex: 1; color: var(--text-muted); }

@media (min-width: 600px) {
  .header__title { font-size: 1.25rem; }
  .question-card { padding: 24px; }
  .module-grid { grid-template-columns: 1fr 1fr; }
  .module-grid .module-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}
