:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --ink: #172033;
  --muted: #7b8498;
  --line: #e7eaf1;
  --line-strong: #d9deea;
  --primary: #5b67d8;
  --primary-dark: #4652c5;
  --primary-soft: #eef0ff;
  --green: #24a86b;
  --green-soft: #eaf9f1;
  --red: #df5d63;
  --red-soft: #fff0f1;
  --shadow: 0 18px 50px rgba(32, 47, 93, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 11% 3%, rgba(113, 122, 225, 0.08), transparent 22rem),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid rgba(91, 103, 216, 0.26);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 42px 20px;
}

.brand,
.top-actions,
.toolbar-actions,
.bottom-actions,
.sidebar-heading,
.answer-panel-header,
.lesson-card-header {
  display: flex;
  align-items: center;
}

.brand {
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #7580e7, #515dca);
  color: white;
  font-size: 19px;
  font-weight: 800;
  box-shadow: 0 9px 20px rgba(91, 103, 216, 0.27);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow.accent {
  color: var(--primary);
}

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

h1 {
  margin-bottom: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.top-actions {
  gap: 14px;
}

.ghost-button,
.small-button,
.secondary-button,
.primary-button,
.text-button {
  border: 0;
  transition: 160ms ease;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.ghost-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: white;
}

.button-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  line-height: 1;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 18px 42px 60px;
}

.hero {
  position: relative;
  display: flex;
  min-height: 214px;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  padding: 40px 48px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.98), rgba(246, 247, 255, 0.95)),
    var(--surface);
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 64%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(91, 103, 216, 0.35));
  content: "";
}

.hero h2 {
  max-width: 610px;
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.055em;
  line-height: 1.12;
}

.hero-copy {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.hero-decoration {
  position: relative;
  width: 220px;
  height: 170px;
  margin-right: 35px;
}

.decoration-ring {
  position: absolute;
  border: 1px solid rgba(91, 103, 216, 0.2);
  border-radius: 50%;
}

.ring-one {
  top: 18px;
  right: 22px;
  width: 132px;
  height: 132px;
}

.ring-two {
  top: 45px;
  right: 49px;
  width: 78px;
  height: 78px;
  border-color: rgba(91, 103, 216, 0.4);
}

.decoration-dot {
  position: absolute;
  border-radius: 50%;
}

.dot-one {
  top: 24px;
  right: 20px;
  width: 11px;
  height: 11px;
  background: #7d87e6;
}

.dot-two {
  right: 72px;
  bottom: 18px;
  width: 7px;
  height: 7px;
  background: #f09c70;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 28px;
}

.stat-card {
  min-height: 92px;
  padding: 18px 20px;
  border: 1px solid rgba(231, 234, 241, 0.8);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
}

.stat-card-accent {
  background: linear-gradient(140deg, #5b67d8, #7781e5);
  color: white;
  border-color: transparent;
}

.stat-card-accent .stat-label,
.stat-card-accent .stat-suffix {
  color: rgba(255, 255, 255, 0.7);
}

.stat-label,
.stat-suffix {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat-card strong {
  display: inline-block;
  margin: 8px 5px 0 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.stat-suffix {
  display: inline-block;
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: start;
}

.content-column {
  min-width: 0;
}

.section-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 13px;
}

.section-toolbar h3,
.sidebar-heading h3,
.answer-panel h3 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.lesson-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lesson-select {
  max-width: 220px;
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lesson-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 103, 216, 0.12);
}

.toolbar-actions {
  gap: 6px;
}

.small-button {
  padding: 8px 11px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.small-button:hover,
.small-button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.progress-track {
  height: 5px;
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eaf6;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #8690ed);
  transition: width 220ms ease;
}

.lesson-card,
.answer-panel,
.sidebar-card {
  border: 1px solid rgba(231, 234, 241, 0.9);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: 0 12px 38px rgba(32, 47, 93, 0.045);
}

.lesson-card-header {
  justify-content: space-between;
  padding: 24px 28px 19px;
  border-bottom: 1px solid var(--line);
}

.chapter-tag {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.lesson-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  padding: 8px 0 8px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.text-button:hover {
  color: var(--red);
}

.lesson-body {
  padding: 18px 28px 30px;
}

.lesson-paragraph {
  margin: 0;
  color: #273149;
  font-size: 16px;
  line-height: 2.15;
}

.lesson-paragraph + .lesson-paragraph {
  margin-top: 12px;
}

.lesson-paragraph.section-divider {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px dashed var(--line-strong);
}

.blank-button {
  display: inline-flex;
  align-items: center;
  min-width: 70px;
  justify-content: center;
  margin: 0 2px;
  padding: 0 8px 2px;
  border: 0;
  border-bottom: 2px solid #aab2ca;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: inherit;
  font-weight: 800;
  line-height: 1.6;
  transition: 160ms ease;
}

.blank-button:hover,
.blank-button.active {
  border-bottom-color: var(--primary);
  background: #e2e5ff;
}

.blank-button.is-correct {
  border-bottom-color: var(--green);
  background: var(--green-soft);
  color: #168552;
}

.blank-button.is-showing {
  border-bottom-color: #c48e35;
  background: #fff8e8;
  color: #a16b14;
}

.blank-check {
  display: inline-grid;
  width: 17px;
  height: 17px;
  margin-left: 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 11px;
  line-height: 1;
}

.inline-answer-popover {
  width: min(760px, 100%);
  margin: 11px 0 12px;
  padding: 16px 17px 17px;
  border: 1px solid #dfe3ff;
  border-radius: 15px;
  background: linear-gradient(140deg, #ffffff, #f8f9ff);
  box-shadow: 0 12px 28px rgba(69, 82, 197, 0.1);
  animation: popover-in 160ms ease-out;
}

.inline-answer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.inline-answer-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.inline-answer-popover .answer-message {
  margin: 0 0 11px;
  font-size: 12px;
}

.inline-answer-popover .options-grid {
  gap: 8px;
}

.inline-answer-popover .option-button {
  min-height: 42px;
  padding: 8px 11px;
  font-size: 13px;
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.answer-panel {
  margin-top: 18px;
  padding: 22px 24px 24px;
  background: linear-gradient(140deg, #ffffff, #fbfbff);
}

.answer-panel-header {
  justify-content: space-between;
  gap: 16px;
}

.question-counter {
  min-width: 43px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.answer-content {
  margin-top: 18px;
}

.empty-state {
  padding: 21px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.answer-message {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.answer-message.success {
  color: var(--green);
  font-weight: 800;
}

.answer-message.error {
  color: var(--red);
  font-weight: 700;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  transition: 160ms ease;
}

.option-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.option-letter {
  display: inline-grid;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  place-items: center;
  border-radius: 7px;
  background: #f0f2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.option-button.correct {
  border-color: #92d9b5;
  background: var(--green-soft);
  color: #167b4b;
}

.option-button.correct .option-letter {
  background: var(--green);
  color: white;
}

.option-button.wrong {
  border-color: #f0a6aa;
  background: var(--red-soft);
  color: #b13c44;
}

.option-button.wrong .option-letter {
  background: var(--red);
  color: white;
}

.option-button:disabled {
  cursor: default;
}

.next-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.bottom-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 17px;
}

.secondary-button,
.primary-button {
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--muted);
}

.secondary-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.primary-button {
  background: var(--primary);
  color: white;
  box-shadow: 0 7px 17px rgba(91, 103, 216, 0.21);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.sidebar-card {
  padding: 22px 18px;
}

.sidebar-heading {
  justify-content: space-between;
  padding: 0 4px 17px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h3 {
  font-size: 19px;
}

.sidebar-count {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.blank-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  padding: 18px 4px 14px;
}

.blank-chip {
  display: grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.blank-chip:hover,
.blank-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.blank-chip.done {
  border-color: #a7e0c3;
  background: var(--green-soft);
  color: var(--green);
}

.blank-chip.done.active {
  border-color: var(--green);
}

.sidebar-tip {
  display: flex;
  gap: 8px;
  padding: 12px 11px;
  border-radius: 10px;
  background: #f8f9fc;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.tip-icon {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  place-items: center;
  border: 1px solid #b9c0d1;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 26px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  border-radius: 10px;
  background: #20283d;
  color: white;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .topbar,
  .page {
    padding-right: 22px;
    padding-left: 22px;
  }

  .hero {
    padding: 32px;
  }

  .hero-decoration {
    margin-right: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .progress-sidebar {
    order: -1;
  }

  .blank-list {
    display: flex;
    flex-wrap: wrap;
  }

  .blank-chip {
    min-width: 36px;
    padding: 0 8px;
  }
}

@media (max-width: 650px) {
  .topbar {
    align-items: flex-start;
    gap: 14px;
  }

  .top-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 9px;
  }

  .hero {
    min-height: 0;
    padding: 28px 24px;
  }

  .hero-decoration {
    display: none;
  }

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

  .section-toolbar,
  .lesson-card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .lesson-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .lesson-select {
    max-width: 100%;
  }

  .toolbar-actions {
    width: 100%;
  }

  .small-button {
    flex: 1;
  }

  .lesson-card-header,
  .lesson-body {
    padding-right: 20px;
    padding-left: 20px;
  }

  .lesson-paragraph {
    font-size: 15px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .bottom-actions {
    flex-direction: column-reverse;
  }

  .bottom-actions button {
    width: 100%;
  }
}
