:root {
  --ink: #17212b;
  --muted: #637083;
  --line: #dce3ea;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #0d7c86;
  --accent-2: #b44a30;
  --accent-3: #5468d4;
  --good: #16845a;
  --bad: #b3261e;
  --shadow: 0 18px 50px rgba(24, 35, 47, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  font-size: 28px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.module-nav {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.build-version {
  margin-top: 18px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f9fbfc;
  font-size: 12px;
}

.module-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.module-button:hover {
  background: #f1f6f7;
}

.module-button.active {
  border-color: rgba(13, 124, 134, 0.24);
  background: #eaf7f8;
}

.module-number {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #dff1f3;
  font-size: 12px;
  font-weight: 800;
}

.module-name {
  font-size: 14px;
  font-weight: 700;
}

.module-topics {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

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

.topbar h2 {
  margin: 2px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

.progress {
  min-width: 190px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf1;
}

#scoreBar {
  width: 0;
  height: 100%;
  background: var(--good);
  transition: width 0.25s ease;
}

.topic-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.topic-chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
}

.topic-chip.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.study-panel,
.visual-panel,
.question-panel,
.practice-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-3);
  font-weight: 800;
}

.section-title h3 {
  margin: 0;
  font-size: 18px;
}

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

.topic-card {
  overflow: hidden;
  border: 1px solid #d7e7ea;
  border-radius: 8px;
  background: #f0fafb;
}

.topic-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  cursor: pointer;
  list-style: none;
}

.topic-card summary::-webkit-details-marker {
  display: none;
}

.topic-card summary::after {
  content: "+";
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(13, 124, 134, 0.24);
  border-radius: 8px;
  color: var(--accent);
  background: #fff;
  font-weight: 800;
}

.topic-card[open] summary::after {
  content: "-";
}

.topic-card h4 {
  margin: 0;
  font-size: 17px;
}

.topic-body {
  display: grid;
  gap: 10px;
  padding: 0 15px 15px;
}

.topic-body p,
.topic-body li,
.feedback,
.practice-list li {
  color: #344451;
  line-height: 1.65;
}

.topic-body p {
  margin: 0;
}

.formula-box,
.example-box,
.tip-box {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
}

.formula-box {
  border-left: 3px solid var(--accent);
}

.example-box {
  border-left: 3px solid var(--accent-3);
}

.tip-box {
  border-left: 3px solid var(--accent-2);
  background: #fff5f2;
}

.complete-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.complete-button {
  border: 1px solid rgba(22, 132, 90, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--good);
  background: #effaf5;
  cursor: pointer;
}

.complete-button.done {
  color: #fff;
  background: var(--good);
}

.visual-stage {
  display: grid;
  min-height: 310px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

#mathCanvas {
  width: 100%;
  max-width: 720px;
  height: auto;
  aspect-ratio: 12 / 7;
}

.mode-hint {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid #d7e7ea;
  border-radius: 8px;
  color: #315d65;
  background: #eef8f9;
  font-size: 13px;
  line-height: 1.45;
}

.visual-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.visual-controls:empty {
  display: none;
}

.visual-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.visual-control input,
.visual-control select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

.visual-control input:focus,
.visual-control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 134, 0.14);
}

.formula-readout {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #d7e7ea;
  border-radius: 8px;
  background: #f8fcfc;
  color: #344451;
  font-size: 13px;
  line-height: 1.5;
}

.formula-readout strong {
  color: var(--accent);
}

.question-card {
  min-height: 292px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.question-text {
  min-height: 68px;
  margin: 16px 0;
  font-size: 17px;
  line-height: 1.65;
}

.question-set {
  display: grid;
  gap: 12px;
  max-height: 720px;
  margin: 16px 0 0;
  overflow: auto;
}

.question-topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border: 1px solid #d7e7ea;
  border-radius: 8px;
  background: #f8fcfc;
}

.question-topic-tag {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.question-topic-tag:hover {
  border-color: var(--accent);
}

.question-topic-tag.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.mini-question {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.mini-question-text {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.mini-options {
  gap: 7px;
}

.mini-options .answer-option {
  padding: 8px 10px;
  font-size: 14px;
}

.mini-feedback {
  min-height: 0;
  margin-top: 8px;
  font-size: 13px;
}

.answer-options {
  display: grid;
  gap: 9px;
}

.answer-option {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.answer-option:hover {
  border-color: var(--accent);
}

.answer-option.correct {
  border-color: rgba(22, 132, 90, 0.4);
  background: #e9f7f1;
}

.answer-option.wrong {
  border-color: rgba(179, 38, 30, 0.35);
  background: #fff0ee;
}

.feedback {
  min-height: 44px;
  margin-top: 12px;
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.practice-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .module-nav {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

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

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

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

  .progress {
    min-width: 0;
  }
}
