:root {
  --ink: #162033;
  --muted: #6f7480;
  --paper: #f6f1e8;
  --panel: #fffdf8;
  --line: #ded4c3;
  --line-strong: #c9b99f;
  --red: #b5232b;
  --red-dark: #8f171f;
  --gold: #c89d55;
  --nav: #111c2b;
  --nav-2: #182638;
  --shadow: 0 18px 48px rgba(31, 27, 20, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(181, 35, 43, 0.04), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family:
    "Noto Serif SC", "Songti SC", "STSong", "PingFang SC", "Microsoft YaHei",
    serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 100%, rgba(200, 157, 85, 0.18), transparent 28%),
    linear-gradient(180deg, var(--nav-2), var(--nav));
  color: #f7f0e5;
  padding: 20px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--red);
  color: white;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
}

.brand-title,
.brand-subtitle,
.section-label {
  margin: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 3px;
  color: rgba(247, 240, 229, 0.72);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.nav-item {
  width: 100%;
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  text-align: left;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: var(--red);
  color: #fff;
}

.nav-item:hover {
  transform: translateX(2px);
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-family: Georgia, serif;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px 4px 0;
  color: rgba(247, 240, 229, 0.58);
}

.portrait-sketch {
  width: 146px;
  height: 160px;
  display: block;
  margin: 0 0 10px 32px;
  object-fit: contain;
  filter:
    contrast(1.35)
    brightness(1.18)
    drop-shadow(0 0 1px rgba(200, 157, 85, 0.45))
    drop-shadow(0 10px 24px rgba(0, 0, 0, 0.18));
  opacity: 0.98;
  color: rgba(200, 157, 85, 0.34);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portrait-sketch .sketch-detail {
  color: rgba(200, 157, 85, 0.25);
  stroke-width: 1.05;
}

.portrait-sketch .sketch-soft {
  color: rgba(200, 157, 85, 0.19);
  stroke-width: 1.15;
}

.sidebar-note p {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 14px;
}

.sidebar-note strong {
  display: block;
  color: rgba(247, 240, 229, 0.75);
  font-size: 18px;
  line-height: 1.5;
  font-weight: 500;
}

.book-sketch {
  width: 188px;
  height: 34px;
  display: block;
  margin-top: 12px;
  color: rgba(200, 157, 85, 0.22);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.designer-credit {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(200, 157, 85, 0.18);
  color: rgba(247, 240, 229, 0.72);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px 24px;
  min-height: 64px;
  margin-bottom: 24px;
}

.topbar > div:first-child {
  min-width: 0;
}

.institution-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 14px;
  width: auto;
  min-width: 0;
  justify-self: end;
}

.college-logo {
  width: auto;
  max-width: min(100%, 54vw);
  height: 108px;
  display: block;
  object-fit: contain;
}

.section-label {
  color: var(--red);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.18;
}

.site-title {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  padding: 4px 0 18px 24px;
  font-size: clamp(42px, 5.2vw, 76px);
  font-weight: 900;
  line-height: 1.02;
  color: var(--ink);
  text-shadow: 0 10px 24px rgba(22, 32, 51, 0.14);
}

.site-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 7px;
  height: calc(100% - 24px);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 46%, var(--gold) 100%);
  box-shadow: 0 10px 20px rgba(181, 35, 43, 0.2);
}

.site-title::after {
  content: "";
  position: absolute;
  left: 24px;
  right: -18px;
  bottom: 0;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), rgba(200, 157, 85, 0.92), rgba(200, 157, 85, 0));
}

.site-title span {
  position: relative;
  z-index: 1;
  background: linear-gradient(90deg, var(--ink) 0%, #2a2230 56%, var(--red-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-title span::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 3%;
  right: -10px;
  bottom: 8px;
  height: 16px;
  background: linear-gradient(90deg, rgba(181, 35, 43, 0.13), rgba(200, 157, 85, 0.12));
}

.site-title em {
  color: var(--red-dark);
  font-style: normal;
  font-size: 0.58em;
  font-weight: 800;
  line-height: 1.12;
  padding-bottom: 8px;
  border-bottom: 3px solid rgba(200, 157, 85, 0.75);
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.small-action,
.ghost-button,
.primary-button {
  border-radius: 6px;
  min-height: 38px;
  padding: 9px 14px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.small-action,
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.64);
  color: var(--ink);
}

.primary-button {
  border: 1px solid var(--red-dark);
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff;
  box-shadow: 0 10px 22px rgba(181, 35, 43, 0.18);
}

.small-action:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.channel-panel {
  display: none;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.channel-panel.active {
  display: block;
}

.section-heading {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-size: 26px;
}

.map-layout {
  display: grid;
  grid-template-columns: 210px minmax(250px, 0.9fr) minmax(320px, 1.1fr);
  min-height: 520px;
}

.category-rail,
.topic-tree,
.detail-panel {
  padding: 22px;
}

.category-rail,
.topic-tree {
  border-right: 1px solid var(--line);
}

.category-rail {
  display: grid;
  align-content: start;
  gap: 10px;
}

.category-button {
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 7px;
  padding: 16px 14px;
  background: transparent;
  color: #756f68;
  text-align: left;
  font-size: 18px;
  font-weight: 700;
}

.category-button.active {
  color: var(--red);
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(181, 35, 43, 0.11), rgba(181, 35, 43, 0.03));
}

.tree-group {
  border-left: 1px solid var(--line-strong);
  margin-left: 9px;
  padding-left: 16px;
}

.tree-category-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 12px;
  font-weight: 700;
  text-align: left;
}

.topic-list {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.topic-list[hidden] {
  display: none;
}

.topic-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #504b45;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.45;
}

.topic-button::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  border-radius: 50%;
}

.topic-button.active {
  border-color: rgba(181, 35, 43, 0.16);
  background: rgba(181, 35, 43, 0.07);
  color: var(--red-dark);
  font-weight: 700;
}

.detail-panel {
  background:
    linear-gradient(180deg, rgba(200, 157, 85, 0.07), transparent 38%),
    var(--panel);
}

.detail-kicker {
  color: var(--muted);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0 0 8px;
}

.detail-panel h3 {
  margin: 0 0 22px;
  color: var(--red);
  font-size: clamp(24px, 3vw, 34px);
}

.principle-block {
  margin: 0 0 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.principle-block h4 {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 21px;
}

.principle-block p,
.source-grid p,
.qa-dialogue p,
.quiz-note p {
  margin: 0;
  color: #3d3a36;
  line-height: 1.85;
}

.detail-note {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.55);
  line-height: 1.75;
}

.detail-note strong {
  color: var(--red-dark);
}

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

.quick-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.84);
  padding: 18px;
  text-align: left;
  box-shadow: 0 12px 30px rgba(31, 27, 20, 0.06);
}

.quick-card span {
  color: var(--red);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
}

.quick-card strong {
  display: block;
  margin-top: 8px;
  line-height: 1.5;
  font-size: 17px;
}

.quote-focus {
  position: relative;
  margin: 28px;
  padding: clamp(28px, 6vw, 64px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(181, 35, 43, 0.08), transparent 42%),
    #fffaf0;
}

.quote-mark {
  position: absolute;
  left: 28px;
  top: 8px;
  color: rgba(181, 35, 43, 0.24);
  font-size: 82px;
  line-height: 1;
}

.quote-focus blockquote {
  margin: 0;
  font-size: clamp(25px, 4vw, 44px);
  line-height: 1.55;
  font-weight: 700;
}

.quote-focus p {
  margin: 26px 0 0;
  color: var(--red);
  text-align: right;
  font-size: 18px;
}

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

.source-grid div,
.message,
.quiz-card,
.score-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.source-grid div {
  padding: 18px;
}

.source-grid h3 {
  margin: 0 0 10px;
  color: var(--red-dark);
}

.qa-workbench {
  display: grid;
  gap: 14px;
  padding: 18px 22px 22px;
}

.qa-dialogue {
  min-height: 0;
  max-height: 280px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.message {
  max-width: 78%;
  padding: 13px 15px;
}

.message strong {
  display: block;
  margin-bottom: 6px;
  color: var(--red-dark);
}

.message.user {
  margin-left: auto;
  background: var(--nav);
  color: white;
}

.message.user p,
.message.user strong {
  color: white;
}

.qa-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
  padding: 14px;
  line-height: 1.7;
  min-height: 82px;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(200, 157, 85, 0.4);
  outline-offset: 2px;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  padding: 22px;
}

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

.quiz-card .quiz-analysis {
  margin-top: 22px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
}

.quiz-card h3 {
  min-height: 70px;
  margin: 18px 0;
  font-size: 22px;
  line-height: 1.5;
}

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

.option-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  text-align: left;
}

.option-button strong {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(200, 157, 85, 0.18);
  color: var(--red-dark);
  flex: 0 0 auto;
}

.option-button.correct {
  border-color: rgba(52, 126, 83, 0.55);
  background: rgba(52, 126, 83, 0.1);
}

.option-button.selected {
  border-color: rgba(200, 157, 85, 0.9);
  background: rgba(200, 157, 85, 0.15);
  box-shadow: inset 0 0 0 1px rgba(200, 157, 85, 0.22);
}

.option-button.wrong {
  border-color: rgba(181, 35, 43, 0.55);
  background: rgba(181, 35, 43, 0.08);
}

.submit-answer,
.reference-answer,
.next-question {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--red-dark);
  border-radius: 7px;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  box-shadow: 0 10px 22px rgba(181, 35, 43, 0.14);
}

.reference-answer {
  border-color: var(--line-strong);
  background: rgba(255, 253, 248, 0.84);
  color: var(--red-dark);
  box-shadow: none;
}

.next-question {
  margin-top: 14px;
}

.quiz-feedback {
  min-height: 76px;
  margin-top: 16px;
  line-height: 1.7;
}

.quiz-feedback.success {
  color: #2f7a51;
}

.quiz-feedback.error {
  color: var(--red-dark);
}

.score-panel h3 {
  margin: 0 0 12px;
}

.score-number {
  font-size: 64px;
  line-height: 1;
  color: var(--red);
  font-weight: 800;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.score-panel > p {
  color: var(--muted);
  line-height: 1.65;
}

.quiz-note {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.quiz-note strong {
  color: var(--red-dark);
}

.quiz-analysis {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.analysis-score-card {
  padding: 16px;
  border: 1px solid rgba(181, 35, 43, 0.18);
  border-radius: 7px;
  background: rgba(181, 35, 43, 0.055);
}

.analysis-score-card span {
  display: block;
  color: var(--red);
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
}

.analysis-score-card strong {
  display: block;
  margin: 8px 0;
  color: var(--red-dark);
  font-size: 18px;
}

.analysis-score-card p,
.quiz-analysis li p,
.quiz-analysis li span {
  color: var(--muted);
  line-height: 1.65;
}

.quiz-analysis h4 {
  margin: 18px 0 10px;
  color: var(--red-dark);
}

.quiz-analysis ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quiz-analysis li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
}

.quiz-analysis li strong,
.quiz-analysis li span {
  display: block;
}

.quiz-analysis li p {
  margin: 8px 0 0;
}

.confetti-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: 42%;
  left: 50%;
  width: var(--size, 8px);
  height: calc(var(--size, 8px) * 1.6);
  background: var(--red);
  opacity: 0.9;
  border-radius: 2px;
  box-shadow: 0 0 14px currentColor;
  animation: firework 2100ms cubic-bezier(0.12, 0.72, 0.22, 1) forwards;
}

.confetti.spark {
  border-radius: 50%;
}

@keyframes firework {
  0% {
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) scale(1) rotate(760deg);
    opacity: 0;
  }
}

@keyframes fall {
  to {
    transform: translateY(95vh) rotate(520deg);
    opacity: 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

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

  .sidebar {
    padding: 18px 12px;
  }

  .brand div:not(.brand-mark),
  .nav-item span:last-child {
    display: none;
  }

  .sidebar-note {
    display: grid;
    place-items: center;
    margin-top: 36px;
    padding: 0;
  }

  .sidebar-note p,
  .sidebar-note strong,
  .designer-credit {
    display: none;
  }

  .portrait-sketch {
    width: 58px;
    height: 64px;
    margin: 0;
    filter:
      contrast(1.4)
      brightness(1.2)
      drop-shadow(0 0 1px rgba(200, 157, 85, 0.55));
    stroke-width: 2.2;
  }

  .book-sketch {
    display: none;
  }

  .portrait-sketch path:nth-child(n+9) {
    display: none;
  }

  .portrait-photo {
    width: 44px;
    height: 54px;
    margin-bottom: 0;
  }

  .institution-strip {
    gap: 8px;
  }

  .college-logo {
    width: auto;
    height: 82px;
    max-width: 42vw;
  }

  .brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 13px 8px;
  }

  .map-layout {
    grid-template-columns: 180px minmax(240px, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .source-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
  }

  .sidebar-note {
    display: none;
  }

  .brand {
    padding: 0;
    border: 0;
  }

  .nav-list {
    flex: 1;
    justify-content: flex-end;
    display: flex;
    gap: 6px;
    margin: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    width: 46px;
    min-width: 46px;
    flex: 0 0 auto;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .institution-strip {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .college-logo {
    width: auto;
    height: 68px;
    max-width: 33vw;
  }

  .map-layout,
  .quiz-layout,
  .qa-form {
    grid-template-columns: 1fr;
  }

  .category-rail,
  .topic-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .message {
    max-width: 100%;
  }

  .quote-focus,
  .source-grid {
    margin: 16px;
    padding-left: 0;
    padding-right: 0;
  }

  .quote-focus {
    padding: 34px 20px 24px;
  }
}
