:root {
  --bg: #07101f;
  --surface: #101b31;
  --surface-2: #162540;
  --surface-3: #1c2e4d;
  --text: #f2f6ff;
  --muted: #a9b7d1;
  --line: #2b4267;
  --blue: #79a9ff;
  --blue-strong: #4f86ed;
  --purple: #a68bff;
  --green: #50d69a;
  --red: #ff7c88;
  --amber: #f2c764;
  --shadow: 0 22px 65px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(61, 102, 181, .25), transparent 31rem),
    radial-gradient(circle at 95% 24%, rgba(102, 74, 170, .18), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input, select { font: inherit; }

button { color: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}

.eyebrow,
.section-label {
  color: var(--blue);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 760px;
  margin-bottom: 6px;
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -.045em;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.18;
  letter-spacing: -.025em;
}

.app-header p,
.reference-intro p,
.course-intro p,
.question-lead {
  color: var(--muted);
}

.app-header p { margin-bottom: 0; }

.view-tabs {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 22, 41, .82);
}

.view-tab {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.view-tab:hover { color: var(--text); }

.view-tab.active {
  color: #07101f;
  background: var(--blue);
  font-weight: 800;
}

.course-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr);
  gap: 22px;
  align-items: stretch;
}

.intro-copy,
.method-card,
.question-card,
.tense-detail,
.period-lab {
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 24px;
  background: rgba(16, 27, 49, .92);
  box-shadow: var(--shadow);
}

.intro-copy {
  padding: clamp(24px, 4vw, 42px);
  background:
    linear-gradient(135deg, rgba(121, 169, 255, .12), rgba(166, 139, 255, .07)),
    rgba(16, 27, 49, .94);
}

.intro-copy h2 { margin: 12px 0 14px; }

.intro-copy p { max-width: 720px; }

.intro-actions,
.question-actions,
.action-right,
.course-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.intro-actions { margin-top: 26px; }

.primary-btn,
.secondary-btn,
.nav-btn,
.close-map {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #07101f;
  font-weight: 850;
}

.secondary-btn,
.nav-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.primary-btn:hover,
.secondary-btn:hover,
.nav-btn:hover { filter: brightness(1.09); }

.primary-btn:disabled,
.secondary-btn:disabled,
.nav-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.method-card {
  padding: 26px;
}

.method-step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
}

.method-step b {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #07101f;
  background: var(--blue);
}

.method-step span { display: grid; }

.method-step small { color: var(--muted); }

.method-line {
  width: 2px;
  height: 24px;
  margin: 5px 0 5px 18px;
  background: var(--line);
}

.quiz-area { position: relative; }

.course-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(7, 16, 31, .94);
  backdrop-filter: blur(14px);
}

.course-position {
  display: grid;
  min-width: 150px;
}

.course-position span:first-child {
  color: var(--muted);
  font-size: .82rem;
}

.course-position strong { font-size: 1.1rem; }

.course-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .11);
}

.course-progress > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width .2s ease;
}

.course-actions {
  justify-content: flex-end;
  color: var(--muted);
  font-size: .9rem;
}

.nav-btn { min-height: 38px; padding: 7px 11px; }

.question-map {
  position: sticky;
  top: 80px;
  z-index: 19;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(12, 23, 43, .98);
  box-shadow: var(--shadow);
}

.question-map-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.question-map-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .85rem;
}

.close-map {
  width: 40px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 1.45rem;
}

.map-module + .map-module { margin-top: 12px; }

.map-module-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.map-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 7px;
}

.question-jump {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.question-jump.current {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(121, 169, 255, .22);
  color: var(--text);
}

.question-jump.correct {
  border-color: rgba(80, 214, 154, .65);
  background: rgba(80, 214, 154, .14);
  color: #b9f8d9;
}

.question-jump.wrong {
  border-color: rgba(255, 124, 136, .65);
  background: rgba(255, 124, 136, .12);
  color: #ffc3c9;
}

.question-card { padding: clamp(20px, 4vw, 38px); }

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.question-kind {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(121, 169, 255, .13);
  color: #cfe0ff;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.question-goal {
  color: var(--muted);
  font-size: .84rem;
  text-align: right;
}

.question-card h2 { margin-bottom: 8px; }

.question-lead { margin-bottom: 24px; }

.question-body { min-height: 250px; }

.choice-list,
.diagram-grid,
.sort-list,
.matrix-list,
.spot-line,
.match-list {
  display: grid;
  gap: 11px;
}

.choice-btn,
.diagram-option,
.token-btn,
.answer-token,
.sort-choice,
.matrix-choice,
.spot-token,
.match-choice,
.order-card,
.period-tab,
.tense-cell {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.choice-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 14px;
  padding: 13px 16px;
  text-align: left;
  line-height: 1.45;
}

.choice-btn:hover,
.diagram-option:hover,
.sort-choice:hover,
.matrix-choice:hover,
.spot-token:hover,
.match-choice:hover,
.period-tab:hover,
.tense-cell:hover { border-color: var(--blue); }

.selected {
  border-color: var(--blue) !important;
  background: rgba(121, 169, 255, .14) !important;
  box-shadow: 0 0 0 2px rgba(121, 169, 255, .13);
}

.is-correct {
  border-color: var(--green) !important;
  background: rgba(80, 214, 154, .13) !important;
}

.is-wrong {
  border-color: var(--red) !important;
  background: rgba(255, 124, 136, .12) !important;
}

.diagram-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.diagram-option {
  min-height: 170px;
  border-radius: 16px;
  padding: 14px;
  text-align: left;
}

.diagram-option strong { display: block; margin-bottom: 12px; }

.timeline {
  position: relative;
  height: 92px;
  margin: 6px 8px 0;
}

.timeline-axis {
  position: absolute;
  left: 3%;
  right: 3%;
  top: 48px;
  height: 2px;
  background: #6f83a7;
}

.timeline-axis::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border-width: 5px 0 5px 8px;
  border-style: solid;
  border-color: transparent transparent transparent #6f83a7;
}

.time-marker {
  position: absolute;
  top: 20px;
  bottom: 15px;
  width: 2px;
  background: var(--muted);
}

.time-marker.now { background: var(--amber); }

.time-marker::after {
  content: attr(data-label);
  position: absolute;
  top: 54px;
  left: 50%;
  min-width: 74px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: .74rem;
  text-align: center;
  white-space: nowrap;
}

.event-dot {
  position: absolute;
  top: 41px;
  width: 16px;
  height: 16px;
  transform: translate(-50%, 0);
  border: 3px solid var(--surface-2);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue);
}

.event-dot.secondary { background: var(--purple); box-shadow: 0 0 0 2px var(--purple); }

.event-span {
  position: absolute;
  top: 42px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
}

.event-arrow {
  position: absolute;
  top: 42px;
  height: 4px;
  background: var(--blue);
}

.event-arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border-width: 6px 0 6px 9px;
  border-style: solid;
  border-color: transparent transparent transparent var(--blue);
}

.event-label {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  color: #d8e5ff;
  font-size: .78rem;
  text-align: center;
  white-space: nowrap;
}

.builder-zone {
  min-height: 78px;
  margin-bottom: 18px;
  padding: 13px;
  border: 1px dashed #55709b;
  border-radius: 14px;
  background: rgba(5, 13, 26, .42);
}

.builder-zone.empty::before {
  content: "Нажимай слова в нужном порядке";
  color: var(--muted);
}

.token-bank,
.built-sentence,
.order-bank,
.order-result {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.token-btn,
.answer-token,
.order-card {
  min-height: 43px;
  border-radius: 11px;
  padding: 9px 12px;
}

.token-btn:disabled { opacity: .28; cursor: default; }

.answer-token {
  border-color: #526f9d;
  background: var(--surface-3);
}

.builder-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: .88rem;
}

.sort-row,
.matrix-row,
.match-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.2fr);
  gap: 14px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sort-row:last-child,
.matrix-row:last-child,
.match-row:last-child { border-bottom: 0; }

.row-context small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.row-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sort-choice,
.matrix-choice,
.match-choice {
  min-height: 40px;
  border-radius: 10px;
  padding: 8px 11px;
}

.spot-line {
  display: flex;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 7px;
  padding: 22px;
  border-radius: 16px;
  background: rgba(5, 13, 26, .43);
}

.spot-token {
  min-height: 46px;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 1.05rem;
}

.order-section + .order-section { margin-top: 20px; }

.order-section h3 { margin-bottom: 10px; font-size: .95rem; color: var(--muted); }

.order-result {
  min-height: 70px;
  padding: 12px;
  border: 1px dashed #55709b;
  border-radius: 14px;
}

.feedback {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(5, 13, 26, .5);
}

.feedback.good { border-color: rgba(80, 214, 154, .62); }
.feedback.bad { border-color: rgba(255, 124, 136, .62); }
.feedback strong { display: block; margin-bottom: 5px; }
.feedback .rule { margin-top: 10px; color: #d9e5fb; }

.question-actions {
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.reference-intro { margin-bottom: 20px; }
.reference-intro h2 { margin: 9px 0 8px; }

.tense-grid {
  display: grid;
  grid-template-columns: 150px repeat(4, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.grid-label {
  display: grid;
  min-height: 74px;
  place-items: center;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: .83rem;
}

.grid-label strong { display: block; color: var(--text); }

.tense-cell {
  min-height: 92px;
  border-radius: 14px;
  padding: 12px;
  text-align: left;
}

.tense-cell strong,
.tense-cell small { display: block; }

.tense-cell small { margin-top: 5px; color: var(--muted); }

.tense-cell.active {
  border-color: var(--blue);
  background: rgba(121, 169, 255, .14);
}

.tense-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr);
  gap: 26px;
  padding: clamp(20px, 4vw, 34px);
}

.detail-copy h2 { margin-bottom: 8px; }

.formula {
  display: inline-flex;
  margin: 8px 0 16px;
  border-radius: 10px;
  padding: 8px 11px;
  background: rgba(121, 169, 255, .12);
  color: #d8e7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.example-box {
  margin-top: 15px;
  padding: 14px 16px;
  border-left: 3px solid var(--purple);
  background: rgba(166, 139, 255, .07);
}

.detail-timeline {
  align-self: center;
  min-height: 180px;
  border-radius: 18px;
  padding: 24px 16px;
  background: rgba(5, 13, 26, .42);
}

.detail-timeline .timeline { margin-top: 20px; }

.detail-caption {
  color: var(--muted);
  font-size: .86rem;
  text-align: center;
}

.period-lab { margin-top: 22px; padding: clamp(20px, 4vw, 34px); }
.period-lab h2 { margin: 8px 0 18px; }

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.period-tab {
  min-height: 42px;
  border-radius: 11px;
  padding: 9px 13px;
}

.period-tab.active {
  border-color: var(--blue);
  background: rgba(121, 169, 255, .14);
}

.period-explanation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .75fr);
  gap: 22px;
  align-items: center;
}

.sentence-pair {
  display: grid;
  gap: 9px;
}

.sentence-good,
.sentence-bad {
  padding: 13px 15px;
  border-radius: 12px;
}

.sentence-good { border: 1px solid rgba(80, 214, 154, .55); background: rgba(80, 214, 154, .1); }
.sentence-bad { border: 1px solid rgba(255, 124, 136, .55); background: rgba(255, 124, 136, .08); }

@media (max-width: 900px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .course-intro { grid-template-columns: 1fr; }
  .course-bar { grid-template-columns: 1fr auto; }
  .course-progress { grid-column: 1 / -1; grid-row: 2; }
  .course-actions { grid-column: 2; grid-row: 1; }
  .course-actions > span { display: none; }
  .tense-detail,
  .period-explanation { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 16px; }
  .view-tabs { width: 100%; }
  .view-tab { flex: 1; }
  .course-bar { gap: 10px; }
  .course-actions .nav-btn:last-child { display: none; }
  .question-head { align-items: flex-start; flex-direction: column; }
  .question-goal { text-align: left; }
  .diagram-grid { grid-template-columns: 1fr; }
  .sort-row,
  .matrix-row,
  .match-row { grid-template-columns: 1fr; gap: 8px; }
  .question-actions { align-items: stretch; flex-direction: column-reverse; }
  .action-right { justify-content: stretch; }
  .question-actions button { flex: 1; }
  .spot-line { display: flex; flex-wrap: wrap; padding: 14px; }
  .question-map { top: 74px; }
}

@media (max-width: 430px) {
  .course-bar { grid-template-columns: 1fr auto; }
  .course-actions { gap: 5px; }
  .nav-btn { padding-inline: 9px; }
  .method-card { padding: 20px; }
  .question-card { border-radius: 18px; }
}

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