:root {
  --ink: #20242a;
  --muted: #68727f;
  --line: #d9dee5;
  --paper: #f6f7f4;
  --surface: #ffffff;
  --red: #8f3428;
  --red-strong: #6f261f;
  --green: #356d5a;
  --blue: #315f86;
  --gold: #ad7a24;
  --soft-red: #f6ebe8;
  --soft-green: #eaf4ef;
  --soft-blue: #eaf1f7;
  --shadow: 0 14px 34px rgba(32, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.62;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

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

.sidebar,
.study-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--surface);
  border-color: var(--line);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 16px;
}

.study-panel {
  border-left: 1px solid var(--line);
  padding: 22px 18px;
}

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

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

.brand h1,
.brand p,
.panel-section h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.meta,
.empty,
label,
.panel-section h2 {
  color: var(--muted);
}

.brand p {
  margin-top: 2px;
  font-size: 13px;
}

.unit-nav {
  display: grid;
  gap: 6px;
}

.unit-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.unit-button:hover,
.unit-button.is-active {
  border-color: #d5aaa2;
  background: var(--soft-red);
}

.unit-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--red-strong);
  background: #f1d7d0;
  font-weight: 800;
}

.unit-title,
.unit-theme {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-title {
  font-weight: 800;
}

.unit-theme {
  color: var(--muted);
  font-size: 12px;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
}

.search-wrap,
.select-wrap {
  display: grid;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(143, 52, 40, 0.14);
}

.view-tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab {
  min-width: 58px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.tab.is-active {
  color: #fff;
  background: var(--red);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stats-row div,
.panel-section,
.lesson-card,
.reader,
.study-card,
.writing-card,
.quiz-card,
.result-card,
.overview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-row div {
  padding: 14px 16px;
}

.stats-row strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.stats-row span {
  color: var(--muted);
  font-size: 13px;
}

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

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

.overview-card,
.lesson-card,
.reader,
.study-card,
.writing-card,
.quiz-card,
.result-card {
  padding: 16px;
}

.overview-card h2,
.lesson-card h3,
.reader h2,
.study-card h3,
.writing-card h3,
.quiz-card h3,
.result-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0;
}

.overview-card p,
.lesson-card p,
.reader p,
.study-card p,
.writing-card p,
.quiz-card p,
.result-card p {
  margin: 8px 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #cbd4dc;
  border-radius: 999px;
  color: #40505e;
  background: #f7fafb;
  font-size: 12px;
}

.tag.red {
  border-color: #dfb8b0;
  color: var(--red-strong);
  background: var(--soft-red);
}

.tag.green {
  border-color: #b7d6c8;
  color: var(--green);
  background: var(--soft-green);
}

.tag.blue {
  border-color: #b7cce0;
  color: var(--blue);
  background: var(--soft-blue);
}

.lesson-list,
.card-list,
.writing-list,
.pending-list,
.question-list {
  display: grid;
  gap: 10px;
}

.lesson-card {
  display: grid;
  gap: 10px;
}

.lesson-card header,
.reader-header,
.practice-header,
.panel-heading,
.lesson-actions {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.lesson-actions {
  align-items: center;
  justify-content: flex-start;
}

.meta {
  font-size: 12px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border-radius: 8px;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  border: 1px solid var(--red);
  color: #fff;
  background: var(--red);
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  color: var(--red-strong);
  background: #fff;
}

.text-button {
  min-height: 34px;
  border: 0;
  color: var(--blue);
  background: transparent;
  padding: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
}

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

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 16px;
  align-items: start;
}

.reader-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.reader-main h3,
.note-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.reader-text {
  white-space: pre-wrap;
  font-family:
    "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  font-size: 18px;
  line-height: 1.9;
}

.reader-aside {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reader-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.reader-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

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

.note-block p {
  margin: 0;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.reader-aside .word-grid {
  grid-template-columns: 1fr;
}

.word-note {
  border: 1px solid #e0d6c3;
  border-radius: 8px;
  padding: 10px;
  background: #fffaf2;
}

.word-note strong {
  display: block;
  color: var(--red-strong);
  font-size: 17px;
}

.word-note span {
  display: block;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  margin-top: 2px;
}

.word-note p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-links a {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.source-links a:hover {
  text-decoration: underline;
}

.study-card {
  display: grid;
  gap: 8px;
}

.study-card dl {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.deep-dive dl {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.study-card dt,
.deep-dive dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.study-card dd,
.deep-dive dd {
  margin: 0;
}

.writing-card ul,
.reader-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.quiz-options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

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

.answer-box {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.6;
  outline: none;
}

.answer-box:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(143, 52, 40, 0.14);
}

.answer-key {
  border: 1px solid #d9c98d;
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.answer-key strong {
  display: block;
  color: #70520f;
  margin-bottom: 6px;
}

.answer-key ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.option-label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}

.option-label:has(input:checked) {
  border-color: var(--red);
  background: var(--soft-red);
}

.option-label.is-correct {
  border-color: #9acbb4;
  background: var(--soft-green);
}

.option-label.is-wrong {
  border-color: #e2a99d;
  background: #fff2ee;
}

.result-score {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.panel-section {
  margin-bottom: 14px;
  padding: 14px;
}

.panel-section h2 {
  font-size: 13px;
  text-transform: uppercase;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.progress-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.pet-intro {
  border: 1px solid #ead7bd;
  border-radius: 8px;
  padding: 10px;
  background: #fffaf2;
}

.pet-intro strong {
  display: block;
  color: var(--red-strong);
}

.pet-intro p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.progress-symbol {
  display: grid;
  place-items: center;
  min-height: 132px;
  border: 1px solid #d5d9cc;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfaf4 0%, #fff 100%);
}

.seal {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border: 3px solid var(--red);
  border-radius: 22px;
  color: var(--red);
  background: #fff9f6;
  font-size: 34px;
  font-weight: 900;
}

.pet-stage {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1px solid #d5d9cc;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 24%, rgba(173, 122, 36, 0.18), transparent 34%),
    linear-gradient(180deg, #fbfaf4 0%, #fff 100%);
}

.pet-orbit {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border: 1px dashed #d8c9a4;
  border-radius: 50%;
}

.pet-creature {
  position: relative;
  width: 72px;
  height: 76px;
  border: 3px solid #5b3a2d;
  border-radius: 42% 42% 34% 34%;
  background: #dfb56e;
  box-shadow: 0 12px 0 rgba(91, 58, 45, 0.12);
}

.pet-creature::before,
.pet-creature::after {
  content: "";
  position: absolute;
  top: -13px;
  width: 22px;
  height: 24px;
  border: 3px solid #5b3a2d;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: inherit;
}

.pet-creature::before {
  left: 8px;
  transform: rotate(-18deg);
}

.pet-creature::after {
  right: 8px;
  transform: rotate(18deg);
}

.pet-face::before,
.pet-face::after {
  content: "";
  position: absolute;
  top: 31px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2b201c;
}

.pet-face::before {
  left: 21px;
}

.pet-face::after {
  right: 21px;
}

.pet-book {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 34px;
  height: 20px;
  border: 2px solid #5b3a2d;
  border-radius: 4px;
  background: #fff8e9;
  transform: translateX(-50%);
}

.pet-book::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  border-left: 1px solid #c9a96f;
}

.stage-2 {
  width: 82px;
  height: 84px;
  background: #91c6a8;
}

.stage-3 {
  width: 92px;
  height: 92px;
  background: #82b7d8;
}

.stage-4 {
  width: 104px;
  height: 98px;
  background: #d79a9f;
}

.stage-3::before,
.stage-3::after,
.stage-4::before,
.stage-4::after {
  top: -18px;
  height: 30px;
}

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

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.progress-block {
  display: grid;
  gap: 6px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.progress-label strong {
  color: var(--ink);
}

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

.progress-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfd;
}

.progress-stats strong {
  display: block;
  font-size: 20px;
}

.progress-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.next-goal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #d9c98d;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fffaf0;
}

.next-goal span {
  color: #70520f;
  font-size: 12px;
  font-weight: 800;
}

.next-goal strong {
  color: var(--ink);
  font-size: 13px;
}

.achievement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.achievement {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #f8f8f6;
  font-size: 12px;
  font-weight: 800;
}

.achievement.is-done {
  border-color: #b7d6c8;
  color: var(--green);
  background: var(--soft-green);
}

.recite-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recite-card strong {
  display: block;
  color: var(--red-strong);
  font-size: 17px;
}

.recite-excerpt {
  max-height: 180px;
  overflow: auto;
  border-left: 3px solid var(--gold);
  padding-left: 10px;
  white-space: pre-wrap;
  font-family:
    "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
}

.pending-item {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .study-panel {
    position: static;
    grid-column: 1 / -1;
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .study-panel {
    position: static;
    height: auto;
  }

  .toolbar,
  .stats-row,
  .overview-grid,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .reader-aside {
    position: static;
    max-height: none;
  }

  .view-tabs {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .reader-header,
  .lesson-card header {
    display: grid;
  }
}
