@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;600;700;800;900&display=swap');

:root {
  --avi-bg: #000000;
  --avi-white: #ffffff;
  --avi-yellow: #ffcc00;
  --avi-yellow-dark: #e0b600;
  --avi-ink: #000000;
  --avi-line: rgba(255, 255, 255, 0.16);
  --avi-line-soft: rgba(255, 255, 255, 0.08);
  --avi-text-soft: rgba(255, 255, 255, 0.72);
  --avi-fill-soft: rgba(255, 255, 255, 0.06);
  --avi-ink-soft: rgba(0, 0, 0, 0.7);
  --avi-ink-line: rgba(0, 0, 0, 0.15);
  --avi-green: #34d17e;
  --avi-green-bg: rgba(52, 209, 126, 0.14);
  --avi-red: #ff5c5c;
  --avi-red-bg: rgba(255, 92, 92, 0.14);
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.5);
  --font-body: 'Figtree', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; background: var(--avi-bg); font-size: 16px; }
body { margin: 0; min-width: 320px; background: var(--avi-bg); color: var(--avi-white); font-family: var(--font-body); font-size: 1rem; font-weight: 400; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3 { font-family: var(--font-body); font-weight: 600; }
:focus-visible { outline: 3px solid var(--avi-yellow); outline-offset: 2px; }

.trainer-page { min-height: 100vh; background: var(--avi-bg); color: var(--avi-white); }

.avi-hero { background: var(--avi-bg); border-bottom: 1px solid var(--avi-line); }
.avi-hero__inner { max-width: 1180px; margin: 0 auto; padding: 52px 24px 38px; }
.avi-hero__eyebrow { display: inline-flex; align-items: center; background: var(--avi-yellow); color: var(--avi-ink); padding: 7px 16px; border-radius: 999px; font-size: .8rem; font-weight: 800; letter-spacing: .02em; margin-bottom: 18px; }
.avi-hero h1 { max-width: 24ch; margin: 0 0 12px; color: var(--avi-white); font-size: clamp(1.9rem, 3.6vw, 2.7rem); line-height: 1.15; }
.avi-hero p { max-width: 58ch; margin: 0 0 22px; color: var(--avi-text-soft); font-size: 1.05rem; line-height: 1.55; }
.avi-hero__stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 8px; }
.avi-hero__stat strong, .avi-hero__stat span { display: block; }
.avi-hero__stat strong { color: var(--avi-yellow); font-size: 1.4rem; }
.avi-hero__stat span { color: var(--avi-text-soft); font-size: .82rem; }

.avi-main { position: relative; z-index: 2; max-width: 1180px; min-height: 360px; margin: 0 auto 60px; padding: 34px 24px 0; }
.avi-card { background: var(--avi-bg); border: 1px solid var(--avi-line); border-radius: var(--radius-lg); }
.setup-card { padding: 28px; margin-bottom: 28px; }
.setup-card h2 { margin: 0 0 6px; padding-left: 12px; border-left: 4px solid var(--avi-yellow); color: var(--avi-white); font-size: 1.3rem; }
.setup-card__sub { margin: 0 0 22px; color: var(--avi-text-soft); font-size: .95rem; line-height: 1.55; }
.loading-copy { color: var(--avi-text-soft); }
.error-copy { color: var(--avi-red); }

.topic-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.topic-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; border: 2px solid var(--avi-line); border-radius: 999px; background: transparent; color: var(--avi-text-soft); font-size: .86rem; font-weight: 600; transition: background .12s ease, border-color .12s ease, color .12s ease, transform .08s ease; }
.topic-pill:hover { border-color: var(--avi-white); color: var(--avi-white); }
.topic-pill:active { transform: scale(.97); }
.topic-pill__check { display: flex; flex: none; align-items: center; justify-content: center; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 5px; color: transparent; font-size: .72rem; font-weight: 900; }
.topic-pill.is-active { border-color: var(--avi-yellow); background: var(--avi-yellow); color: var(--avi-ink); }
.topic-pill.is-active .topic-pill__check { border-color: var(--avi-ink); background: var(--avi-ink); color: var(--avi-yellow); }
.pill-acc { opacity: .8; }
.topic-pills-actions { display: flex; gap: 14px; margin-bottom: 22px; }
.topic-pills-actions button { padding: 4px 0; border: 0; background: none; color: var(--avi-yellow); font-size: .82rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border: 0; border-radius: 999px; font-size: .98rem; font-weight: 700; transition: transform .1s ease, box-shadow .15s ease, background .15s ease, color .15s ease; }
.btn-primary { background: var(--avi-yellow); color: var(--avi-ink); box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--avi-yellow-dark); }
.btn-catalog { padding: 9px 16px; border: 1px solid var(--avi-yellow); background: transparent; color: var(--avi-yellow); font-size: .82rem; box-shadow: none; }
.btn-catalog:hover { background: var(--avi-yellow); color: var(--avi-ink); }
.btn-ghost { border: 1.5px solid var(--avi-line); background: transparent; color: var(--avi-white); }
.btn-ghost:hover { border-color: var(--avi-white); }
.btn-secondary { background: var(--avi-white); color: var(--avi-ink); }
.btn-secondary:hover { background: var(--avi-yellow); }

.quiz-layout { max-width: 820px; margin: 0 auto; scroll-margin-top: 12px; }
.quiz-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.quiz-progress { flex: 1; min-width: 220px; }
.quiz-progress__bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--avi-line-soft); }
.quiz-progress__fill { height: 100%; background: var(--avi-yellow); transition: width .3s ease; }
.quiz-progress__label { display: flex; justify-content: space-between; margin-top: 6px; color: var(--avi-text-soft); font-size: .82rem; }
.streak-badge { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: var(--avi-yellow); color: var(--avi-ink); font-size: .85rem; font-weight: 800; white-space: nowrap; }
.question-card { padding: 32px; }
.question-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.tag { padding: 5px 11px; border: 1px solid var(--avi-line); border-radius: 999px; background: var(--avi-fill-soft); color: var(--avi-text-soft); font-size: .75rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.tag-topic { border-color: var(--avi-yellow); background: var(--avi-yellow); color: var(--avi-ink); }
.tag-diff { color: var(--avi-white); }
.question-card__text { margin: 0 0 26px; color: var(--avi-white); font-size: 1.28rem; line-height: 1.5; }
.options-list { display: grid; gap: 12px; }
.option-btn { display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 16px 18px; border: 1.5px solid var(--avi-line); border-radius: var(--radius-md); background: var(--avi-fill-soft); color: var(--avi-white); text-align: left; font-size: 1rem; line-height: 1.45; transition: border-color .12s ease, background .12s ease, transform .08s ease; }
.option-btn:hover:not(:disabled) { border-color: var(--avi-yellow); }
.option-btn:active:not(:disabled) { transform: scale(.995); }
.option-btn__letter { display: flex; flex: none; align-items: center; justify-content: center; width: 30px; height: 30px; border: 1.5px solid var(--avi-line); border-radius: 50%; background: var(--avi-bg); color: var(--avi-white); font-size: .88rem; font-weight: 700; }
.option-btn.is-correct { border-color: var(--avi-green); background: var(--avi-green-bg); }
.option-btn.is-correct .option-btn__letter { border-color: var(--avi-green); background: var(--avi-green); color: var(--avi-ink); }
.option-btn.is-wrong { border-color: var(--avi-red); background: var(--avi-red-bg); }
.option-btn.is-wrong .option-btn__letter { border-color: var(--avi-red); background: var(--avi-red); color: var(--avi-white); }
.option-btn.is-wrong::after { content: '✕'; margin-left: auto; color: var(--avi-red); font-weight: 800; }
.option-btn.is-dimmed { opacity: .4; }

.feedback-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px dashed var(--avi-line); }
.feedback-msg { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; font-weight: 700; }
.feedback-msg.ok { color: var(--avi-green); }
.feedback-msg.no { color: var(--avi-red); }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.feedback-actions .btn { padding: 11px 18px; font-size: .86rem; }
.confidence-control { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: center; width: 100%; margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--avi-line); border-radius: var(--radius-md); background: transparent; color: var(--avi-text-soft); text-align: left; transition: border-color .12s ease, background .12s ease; }
.confidence-control:hover:not(:disabled) { border-color: var(--avi-yellow); }
.confidence-control.is-active { border-color: var(--avi-yellow); background: rgba(255, 204, 0, .08); }
.confidence-control:disabled { opacity: 1; }
.confidence-control__mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--avi-line); border-radius: 50%; color: var(--avi-yellow); font-weight: 900; }
.confidence-control.is-active .confidence-control__mark { border-color: var(--avi-yellow); background: var(--avi-yellow); color: var(--avi-ink); }
.confidence-control__copy strong, .confidence-control__copy small { display: block; }
.confidence-control__copy strong { margin-bottom: 2px; color: var(--avi-white); font-size: .82rem; }
.confidence-control__copy small { font-size: .72rem; line-height: 1.45; }
.confidence-control__action { color: var(--avi-yellow); font-size: .74rem; font-weight: 800; white-space: nowrap; }

.catalog-note { max-width: 1180px; margin: 0 auto; padding: 0 24px 44px; color: var(--avi-text-soft); text-align: center; font-size: .78rem; line-height: 1.5; }

.modal-backdrop { position: fixed; z-index: 200; inset: 0; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 6vh 20px; background: rgba(0, 0, 0, .7); animation: fadeIn .18s ease; }
.modal-card { position: relative; width: 100%; max-width: 560px; padding: 36px; border-radius: var(--radius-lg); background: var(--avi-white); color: #2a2a2a; box-shadow: var(--shadow-lg); color-scheme: light; animation: popIn .22s ease; }
.result-score { margin-bottom: 8px; text-align: center; }
.result-score__big { color: #2a2a2a; font-size: 3.4rem; font-weight: 800; line-height: 1; }
.result-score__sub { margin-top: 6px; color: #4a4a4a; font-size: .95rem; }
.result-headline { margin: 18px 0 10px; color: #2a2a2a; text-align: center; font-size: 1.35rem; }
.result-copy { margin: 0 0 24px; color: #4a4a4a; text-align: center; font-size: .98rem; line-height: 1.6; }
.result-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 24px; }
.result-summary span { padding: 13px 8px; border: 1px solid var(--avi-ink-line); border-radius: 12px; color: var(--avi-ink-soft); text-align: center; font-size: .75rem; }
.result-summary strong { display: block; margin-bottom: 3px; color: var(--avi-ink); font-size: 1.25rem; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.result-actions .btn-primary { color: var(--avi-ink); }
.result-actions .btn-ghost { border-color: var(--avi-ink-line); color: var(--avi-ink); }
.result-actions .btn-ghost:hover { border-color: var(--avi-ink); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 640px) {
  .avi-hero__inner { padding: 40px 20px 30px; }
  .avi-main { padding: 26px 16px 0; margin-bottom: 42px; }
  .setup-card, .question-card { padding: 22px; }
  .question-card__text { font-size: 1.12rem; }
  .setup-actions { align-items: stretch; }
  .setup-actions .btn { width: 100%; }
  .feedback-row, .feedback-actions { align-items: stretch; }
  .feedback-actions { width: 100%; }
  .feedback-actions .btn { flex: 1 1 100%; width: 100%; }
  .confidence-control { grid-template-columns: auto minmax(0, 1fr); }
  .confidence-control__action { grid-column: 2; }
  .modal-card { padding: 26px; }
  .result-score__big { font-size: 2.6rem; }
  .result-summary { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}

[hidden] { display: none !important; }
