:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --blue: #1a73e8;
  --green: #188038;
  --yellow: #fbbc04;
  --red: #d93025;
  --shadow: 0 14px 35px rgba(60, 64, 67, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.logo span,
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.topbar nav {
  flex: 1;
}

.topbar nav a {
  padding: 8px 10px;
  color: var(--muted);
}

.topbar nav a.active {
  color: var(--blue);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.shell.narrow {
  max-width: 850px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(26, 115, 232, 0.12), transparent 32%), var(--bg);
}

.login-panel,
.panel,
.quick-card,
.course-card,
.unit,
.lesson-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-panel {
  width: min(100%, 430px);
  padding: 34px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 18px 0 8px;
  font-size: 30px;
}

.stack {
  display: grid;
  gap: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.ghost {
  color: var(--blue);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: stretch;
  margin-bottom: 30px;
}

.hero h1,
.course-hero h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
}

.hero p,
.course-hero p {
  max-width: 680px;
  color: var(--muted);
  font-size: 17px;
}

.quick-card,
.panel {
  padding: 20px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.course-card {
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: 22px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.course-card span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.course-card h2 {
  font-size: 24px;
}

.course-card p,
.muted,
.empty,
.hint {
  color: var(--muted);
}

.hint {
  margin: -4px 0 0;
  font-size: 13px;
}

.metrics,
.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: auto;
}

.metrics b,
.stat-strip b {
  display: block;
  font-size: 24px;
}

.metrics small,
.stat-strip span {
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0;
}

.section-head.compact {
  margin: 0 0 14px;
}

.course-hero {
  padding: 18px 0 26px;
}

.back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--blue);
}

.stat-strip {
  max-width: 620px;
  margin-top: 22px;
}

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

.side-panel,
.main-panel {
  display: grid;
  gap: 16px;
}

.file-list,
.job-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.file-list li,
.job-list li,
.exam-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.file-list a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.status {
  color: var(--muted);
}

.status.completed,
.status.answered,
.status.graded,
.status.ready {
  color: var(--green);
}

.status.failed {
  color: var(--red);
}

.unit {
  padding: 22px;
}

.unit-title {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.unit-title > span {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  height: 42px;
  border-radius: 50%;
  background: #e8f0fe;
  color: var(--blue);
  font-weight: 700;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.lesson-card {
  padding: 18px;
}

.lesson-card small {
  color: var(--blue);
  font-weight: 700;
}

.lesson-card p,
.qa-item,
.result p,
.result li {
  color: #3c4043;
}

.gate-list {
  display: grid;
  gap: 18px;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.gate-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.chapter-block {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.chapter-block:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.chapter-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 2px;
}

.chapter-head p {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.chapter-head h3 {
  margin: 0;
  font-size: 22px;
}

.chapter-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.gate-row:hover {
  border-color: #aecbfa;
  box-shadow: 0 10px 24px rgba(60, 64, 67, 0.1);
  transform: translateY(-1px);
}

.gate-number,
.gate-step span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8f0fe;
  color: var(--blue);
  font-weight: 700;
}

.gate-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.gate-main strong {
  overflow-wrap: anywhere;
}

.gate-main small,
.gate-meta {
  color: var(--muted);
}

.gate-action {
  color: var(--blue);
  font-weight: 700;
}

.gate-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 760px);
  gap: 28px;
  max-width: 1180px;
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  padding: 28px;
}

.gate-sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
}

.gate-sidebar h1 {
  font-size: 30px;
  line-height: 1.18;
}

.gate-sidebar p {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.gate-steps {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.gate-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px;
  color: var(--muted);
}

.gate-step.active {
  border-color: #aecbfa;
  background: #f3f7ff;
  color: var(--text);
}

.gate-step.done span {
  background: #e6f4ea;
  color: var(--green);
}

.gate-stage {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: calc(100vh - 120px);
}

.gate-progress,
.gate-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gate-progress span {
  color: var(--blue);
  font-weight: 700;
}

.gate-progress b {
  color: var(--muted);
}

.focus-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(24px, 5vw, 52px);
  box-shadow: var(--shadow);
}

.focus-card h2 {
  max-width: 720px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.15;
}

.focus-copy {
  max-width: 700px;
  color: #3c4043;
  font-size: 20px;
  line-height: 1.85;
}

.exercise-card {
  display: grid;
  gap: 18px;
}

.teaching-card {
  display: grid;
  gap: 20px;
}

.lesson-head span,
.exercise-head span {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--blue);
  font-weight: 700;
}

.lesson-head h2 {
  margin: 0;
}

.teaching-goal,
.teaching-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: #fff;
}

.teaching-goal {
  border-color: #c4eed0;
  background: #f6fff8;
}

.teaching-block.main-teach {
  border-color: #c6dafc;
  background: #f8fbff;
}

.teaching-block.warning {
  border-color: #fad2cf;
  background: #fff8f7;
}

.teaching-block.ready-check {
  border-color: #fde293;
  background: #fffdf6;
}

.teaching-goal h3,
.teaching-block h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.teaching-list,
.term-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.term-list b {
  display: block;
  margin-bottom: 3px;
}

.term-list p,
.teaching-list p {
  margin: 0;
}

.exercise-box,
.answer-panel,
.formula-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: #fff;
}

.exercise-box.subtle {
  background: #f8fafc;
}

.exercise-box h3,
.answer-panel h3,
.formula-list h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.exercise-box ul,
.answer-panel ul,
.formula-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.answer-input {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.answer-input textarea {
  margin-top: 8px;
  min-height: 150px;
  font-weight: 400;
}

.answer-panel {
  border-color: #c4eed0;
  background: #f6fff8;
}

.hint-button {
  justify-self: start;
}

.formula-card {
  display: grid;
  gap: 18px;
}

.formula-list ul {
  padding: 0;
  list-style: none;
}

.formula-list li {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 1fr) minmax(160px, 1.1fr);
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.formula-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.formula-list .math-line {
  display: block;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f1f3f4;
  color: #174ea6;
  overflow-x: auto;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 12px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
}

.markdown-body code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #f1f3f4;
  color: #174ea6;
}

.markdown-body strong {
  color: var(--text);
}

.ask-form {
  display: grid;
  gap: 12px;
}

.qa-item {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.answer.pending {
  color: var(--muted);
}

.exam-list {
  display: grid;
  gap: 10px;
}

.exam-row b {
  color: var(--blue);
}

.exam-question {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.exam-question span {
  color: var(--text);
  font-weight: 700;
}

.exam-question small {
  color: var(--muted);
}

.score {
  font-size: 34px;
  font-weight: 700;
  color: var(--green);
}

.notice {
  border-radius: var(--radius);
  padding: 10px 12px;
}

.notice.error {
  background: #fce8e6;
  color: var(--red);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  background: #fff;
}

@media (max-width: 900px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .course-grid,
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .gate-shell {
    grid-template-columns: 1fr;
  }

  .gate-sidebar {
    position: static;
  }

  .gate-stage {
    min-height: auto;
  }

  .topbar {
    padding: 0 16px;
  }

  .shell {
    padding: 20px 16px;
  }
}

@media (max-width: 560px) {
  .section-head,
  .file-list li,
  .job-list li,
  .exam-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .gate-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .chapter-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .gate-meta,
  .gate-action {
    grid-column: 2;
  }

  .gate-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .focus-copy {
    font-size: 18px;
  }

  .formula-list li {
    grid-template-columns: 1fr;
  }

  .stat-strip,
  .metrics {
    grid-template-columns: 1fr;
  }

  .hero h1,
  .course-hero h1 {
    font-size: 36px;
  }
}
