:root {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: rgba(15, 23, 42, 0.1);
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #0f9f6e;
  --amber: #b7791f;
  --red: #c2410c;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  --radius: 28px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.13), transparent 28%),
    radial-gradient(circle at 82% 4%, rgba(15, 159, 110, 0.11), transparent 24%),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 42%, #eef3fb 100%);
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
.flash-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 3px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0 22px;
  backdrop-filter: blur(20px);
}

.brand,
.session,
.section-title,
.card-top,
.flash-actions,
.mode-tabs {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: 0 12px 38px rgba(37, 99, 235, 0.16);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.2;
  stroke-linejoin: round;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
}

h2 {
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.22;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.session {
  gap: 12px;
}

.timer {
  min-width: 132px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.timer span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timer small {
  color: var(--muted);
  font-weight: 700;
}

.primary-btn,
.ghost-btn,
.grade-btn,
.tab {
  border-radius: 999px;
  padding: 0 20px;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.primary-btn {
  background: #111827;
  color: #fff;
  box-shadow: 0 14px 36px rgba(17, 24, 39, 0.18);
}

.ghost-btn,
.grade-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.primary-btn:hover,
.ghost-btn:hover,
.grade-btn:hover,
.tab:hover {
  transform: translateY(-1px);
}

.primary-btn:active,
.ghost-btn:active,
.grade-btn:active,
.tab:active {
  transform: scale(0.98);
}

.hero-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 20px;
}

.glass-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
}

.score-card,
.plan-card {
  padding: 24px;
}

.score-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
}

.ring {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle closest-side, #fff 72%, transparent 73%),
    conic-gradient(var(--blue) var(--progress), #e6ecf7 0);
}

.ring span {
  font-size: 30px;
  font-weight: 900;
}

.section-title {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.phase {
  min-height: 104px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.phase.active {
  border-color: rgba(37, 99, 235, 0.42);
  background: var(--blue-soft);
}

.phase strong {
  display: block;
  margin-bottom: 8px;
}

.phase span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.mode-tabs {
  gap: 10px;
  margin: 20px 0;
  padding: 8px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
}

.tab {
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.tab.active {
  background: #111827;
  color: #fff;
}

.panel {
  display: none;
  animation: panelIn 240ms ease both;
}

.active-panel {
  display: block;
}

.overview-grid,
.trainer-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.overview-grid .glass-card,
.flash-card,
.quiz-card,
.side-panel,
#wrong .glass-card {
  padding: 28px;
}

.mnemonic-list {
  display: grid;
  gap: 12px;
}

.mnemonic {
  padding: 16px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
}

.mnemonic strong {
  display: block;
  margin-bottom: 8px;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.map-card {
  min-height: 152px;
  padding: 18px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--line);
}

.map-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 20px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.trainer-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.flash-card,
.quiz-card {
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.card-top {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

#flashQuestion,
#quizQuestion,
#finalQuestion {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.24;
  margin-bottom: 28px;
}

.answer {
  padding: 22px;
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--line);
  color: #1f2937;
  font-size: 22px;
  line-height: 1.8;
  animation: answerIn 220ms ease both;
}

.hidden {
  display: none;
}

.flash-actions {
  gap: 12px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 28px;
}

.grade-btn.good {
  color: var(--green);
  border-color: rgba(15, 159, 110, 0.24);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-stats div {
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: center;
}

.mini-stats strong {
  display: block;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.mini-stats span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shortcut-box,
.progress-stack {
  display: grid;
  gap: 8px;
}

.shortcut-box span,
.progress-stack span {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  min-height: 58px;
  padding: 16px 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
  color: var(--text);
}

.option.correct {
  border-color: rgba(15, 159, 110, 0.42);
  background: #eafaf4;
}

.option.wrong {
  border-color: rgba(194, 65, 12, 0.38);
  background: #fff4ed;
}

.feedback {
  min-height: 42px;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.wrong-list {
  display: grid;
  gap: 12px;
}

.wrong-item {
  padding: 18px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
}

.wrong-item strong {
  display: block;
  margin-bottom: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
  line-height: 1.7;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes answerIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .topbar,
  .hero-grid,
  .overview-grid,
  .trainer-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .session {
    justify-content: space-between;
  }

  .timeline,
  .map-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .score-card {
    grid-template-columns: 1fr;
  }

  .ring {
    width: 116px;
    height: 116px;
  }

  .mode-tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  .tab {
    flex: 1 1 calc(33.333% - 10px);
  }
}

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