:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #f0eee6;
  --ink: #22201c;
  --muted: #706a60;
  --line: #ded8cb;
  --accent: #3f6f67;
  --accent-strong: #234c47;
  --warn: #9b4d30;
  --shadow: 0 16px 40px rgba(48, 42, 32, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.topbar,
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px 0 18px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 26px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

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

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions a,
.quiz-actions button,
.today-panel button,
.chapter-status-actions button,
.answer-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--accent-strong);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
  gap: 18px;
  margin: 12px 0 26px;
}

.intro-panel,
.today-panel,
.section-block,
.chapter-list,
.chapter-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel,
.today-panel {
  padding: 24px;
}

.method-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding-left: 22px;
}

.method-list li {
  padding-left: 2px;
}

.method-list strong {
  color: var(--accent-strong);
}

.today-panel {
  background: #e8f0ec;
}

.panel-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.today-phase {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.today-phase strong {
  color: var(--accent-strong);
  font-size: 18px;
}

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

.today-phase p {
  margin: 2px 0 0;
  color: var(--ink);
  line-height: 1.55;
}

.today-panel ol {
  display: grid;
  gap: 7px;
  margin: 10px 0;
  padding-left: 22px;
}

.weekly-rhythm {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--accent-strong);
  font-size: 14px;
  line-height: 1.5;
}

.section-block {
  margin: 22px 0;
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.section-card,
.chapter-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-card {
  width: 100%;
  padding: 16px;
  text-align: left;
}

.section-card.active {
  border-color: var(--accent);
  background: #edf5f2;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.study-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.chapter-list,
.chapter-detail {
  padding: 18px;
}

.chapter-list {
  position: sticky;
  top: 16px;
}

.chapter-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.chapter-header h2 {
  margin-bottom: 0;
}

.chapter-status-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chapter-status-actions button {
  background: #f7fbff;
  color: #2f6fdd;
  box-shadow: inset 0 0 0 1px #b9cdf8;
}

.chapter-status-actions button.active {
  background: #2f6fdd;
  color: white;
  box-shadow: none;
}

.chapter-button {
  width: 100%;
  margin-bottom: 8px;
  padding: 12px;
  text-align: left;
}

.chapter-button.active {
  border-color: var(--accent);
  background: #edf5f2;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 18px;
}

.point-list {
  display: grid;
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.point-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.point-list li span {
  flex: 0 0 auto;
  min-width: 28px;
  color: var(--accent-strong);
  font-weight: 700;
}

.memory-map {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid #cbded8;
  border-radius: 8px;
  background: #f0f6f4;
}

.memory-map-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.memory-map-head strong {
  color: var(--accent-strong);
}

.memory-map-head span {
  color: var(--muted);
}

.memory-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.flow-step {
  position: relative;
  min-height: 150px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.flow-step.remembered {
  border-color: var(--accent);
  background: #edf5f2;
}

.flow-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.flow-step-top > span {
  display: inline-flex;
  min-width: 64px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.flow-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.flow-tools button {
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fffdf8;
  color: var(--accent-strong);
  font-size: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.flow-step ul {
  margin: 8px 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--muted);
  font-size: 14px;
}

.flow-step li + li {
  margin-top: 7px;
}

.flow-step li {
  display: grid;
  grid-template-columns: 32px 42px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.content-index {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

.level-badge {
  display: inline-flex;
  justify-content: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e8f0ec;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}

.level-必背 {
  background: #dcebe6;
}

.level-易混 {
  background: #f6e8e1;
  color: var(--warn);
}

.level-拓展 {
  background: #f3eee0;
  color: #756246;
}

.memory-mark {
  display: inline;
  border: 0;
  border-radius: 4px;
  padding: 1px 2px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.title-mark {
  font-weight: 700;
  color: var(--ink);
}

.point-mark {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.memory-mark.marked {
  background: #dcebe6;
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.recall-list .point-mark {
  border-bottom: 1px dashed var(--accent);
  color: var(--accent-strong);
}

.recall-answer {
  display: none;
}

.memory-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.anchor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.anchor-tags span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  color: var(--accent-strong);
}

.trap-list {
  margin: 0;
  padding-left: 20px;
}

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

.memory-card {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.memory-card strong {
  display: block;
  margin-bottom: 6px;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-actions button.active,
.today-panel button,
.answer-button.correct {
  background: var(--accent);
  color: white;
  box-shadow: none;
}

.answer-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.answer-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: #fffdf8;
  color: var(--ink);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.answer-button:hover:not(:disabled) {
  background: #edf5f2;
  box-shadow: inset 0 0 0 1px var(--accent);
  transform: translateY(-1px);
}

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

.answer-label {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8f0ec;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.answer-text {
  min-width: 0;
  line-height: 1.45;
}

.answer-button.correct .answer-label {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

.answer-button.wrong .answer-label {
  background: #f1d6c9;
  color: var(--warn);
}

.answer-button.wrong {
  background: #f6e8e1;
  color: var(--warn);
  box-shadow: inset 0 0 0 1px #dfb9a7;
}

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.quiz-progress {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 4px 12px;
  background: #e8f0ec;
  color: var(--accent-strong);
  font-weight: 700;
}

@media (max-width: 900px) {
  .topbar,
  .dashboard,
  .section-heading,
  .study-layout {
    display: block;
  }

  .top-actions,
  .today-panel,
  .chapter-detail {
    margin-top: 14px;
  }

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

  .chapter-list {
    position: static;
  }

}

@media (max-width: 620px) {
  .topbar,
  main {
    width: min(100% - 20px, 1180px);
  }

  .section-grid,
  .card-grid,
  .memory-columns {
    grid-template-columns: 1fr;
  }

  .intro-panel,
  .today-panel,
  .section-block,
  .chapter-list,
  .chapter-detail {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .chapter-header {
    display: block;
  }

  .chapter-status-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }
}
