: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);
}

.visual-panel,
.practice-panel {
  grid-column: span 1;
}

.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;
}

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

.topic-detail {
  padding: 15px;
  border: 1px solid #d7e7ea;
  border-radius: 8px;
  background: #f0fafb;
}

.topic-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.topic-detail-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.topic-detail h4,
.topic-detail p {
  margin: 0;
}

.topic-detail h4 {
  font-size: 18px;
}

.topic-detail p,
.topic-detail li {
  color: #344451;
  line-height: 1.65;
}

.topic-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.topic-detail-grid div {
  padding: 11px;
  border: 1px solid #dce8ec;
  border-radius: 8px;
  background: #fff;
}

.topic-detail-grid strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.topic-detail-grid ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.topic-advice {
  margin-top: 12px !important;
  color: #315d65 !important;
  font-weight: 700;
}

.concept-block {
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.mistake-block {
  padding: 10px 12px;
  border-left-color: var(--accent-2);
  border-radius: 8px;
  background: #fff5f2;
}

.concept-block h4 {
  margin: 0 0 7px;
  font-size: 15px;
}

.concept-block p,
.formula-list li,
.practice-list li {
  margin: 0;
  color: #3d4856;
  line-height: 1.68;
}

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

.practice-focus {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #315d65;
  background: #eef8f9;
  font-weight: 800;
}

.visual-stage {
  position: relative;
  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;
}

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

.visual-controls label {
  display: grid;
  gap: 5px;
  min-width: 130px;
  color: var(--muted);
  font-size: 12px;
}

.visual-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.mode-hint,
.formula-control {
  grid-column: 1 / -1;
}

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

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

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

.formula-control input[readonly] {
  color: var(--muted);
  background: #f5f7f9;
}

.slider-control {
  position: relative;
  padding-top: 2px;
}

.slider-value {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--ink);
  font-weight: 700;
}

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

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

.question-topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

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

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

.question-topic-tag.active {
  border-color: rgba(36, 99, 235, 0.35);
  background: #eef5ff;
  color: var(--accent);
  font-weight: 700;
}

.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;
}

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

.question-card > .answer-options {
  gap: 14px;
}

.question-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.question-item-title {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 700;
}

.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;
  color: var(--muted);
  line-height: 1.55;
}

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

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

.solid-stage {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  perspective: 780px;
  background:
    linear-gradient(#eef4f6 1px, transparent 1px),
    linear-gradient(90deg, #eef4f6 1px, transparent 1px);
  background-size: 34px 34px;
}

.solid-stage.visible {
  display: grid;
}

.cube {
  position: relative;
  width: var(--cube-size, 150px);
  height: var(--cube-size, 150px);
  transform-style: preserve-3d;
  animation: rotateCube 9s linear infinite;
}

.cube span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 2px solid rgba(13, 124, 134, 0.72);
  color: #0b5960;
  background: rgba(255, 255, 255, 0.54);
  font-weight: 800;
}

.front { transform: translateZ(var(--cube-depth, 75px)); }
.back { transform: rotateY(180deg) translateZ(var(--cube-depth, 75px)); }
.right { transform: rotateY(90deg) translateZ(var(--cube-depth, 75px)); }
.left { transform: rotateY(-90deg) translateZ(var(--cube-depth, 75px)); }
.top { transform: rotateX(90deg) translateZ(var(--cube-depth, 75px)); }
.bottom { transform: rotateX(-90deg) translateZ(var(--cube-depth, 75px)); }

@keyframes rotateCube {
  from { transform: rotateX(-18deg) rotateY(0deg); }
  to { transform: rotateX(-18deg) rotateY(360deg); }
}

@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;
  }

  .topic-detail-grid {
    grid-template-columns: 1fr;
  }
}
