:root {
  color-scheme: light;
  --bg: #f2f1ec;
  --bg-plain: #faf9f5;
  --surface: #ffffff;
  --surface-muted: #f7f6f1;
  --text: #151515;
  --text-soft: #5f5b55;
  --text-faint: #8c877f;
  --line: rgba(21, 21, 21, 0.12);
  --line-strong: rgba(21, 21, 21, 0.24);
  --accent: #202020;
  --accent-soft: rgba(21, 21, 21, 0.05);
  --success: #18794e;
  --success-soft: rgba(24, 121, 78, 0.1);
  --success-line: rgba(24, 121, 78, 0.3);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --danger-line: rgba(180, 35, 24, 0.28);
  --favorite: #7a6540;
  --favorite-soft: rgba(122, 101, 64, 0.1);
  --favorite-line: rgba(122, 101, 64, 0.26);
  --neon-pink: #ff71ce;
  --neon-blue: #01cdfe;
  --neon-violet: #b967ff;
  --neon-deep: #2e1f47;
  --warm-paper: #faf9f7;
  --warm-paper-muted: #f5f5f5;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --page-width: 1320px;
  --reading-width: 980px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0d;
  --bg-plain: #131311;
  --surface: #171715;
  --surface-muted: #1d1d1a;
  --text: #f4f2eb;
  --text-soft: #b4b0a8;
  --text-faint: #8f8a82;
  --line: rgba(244, 242, 235, 0.14);
  --line-strong: rgba(244, 242, 235, 0.24);
  --accent: #f4f2eb;
  --accent-soft: rgba(244, 242, 235, 0.06);
  --success: #6bd3a4;
  --success-soft: rgba(107, 211, 164, 0.12);
  --success-line: rgba(107, 211, 164, 0.36);
  --danger: #ff8b82;
  --danger-soft: rgba(255, 139, 130, 0.12);
  --danger-line: rgba(255, 139, 130, 0.36);
  --favorite: #d3b57a;
  --favorite-soft: rgba(211, 181, 122, 0.12);
  --favorite-line: rgba(211, 181, 122, 0.34);
  --neon-pink: #ff8dd8;
  --neon-blue: #62ddff;
  --neon-violet: #c994ff;
  --neon-deep: #171129;
  --warm-paper: #171715;
  --warm-paper-muted: #1d1d1a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  background: linear-gradient(180deg, var(--bg-plain) 0%, var(--bg) 100%);
}

::selection {
  color: var(--surface);
  background: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

summary {
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.page-shell {
  width: min(var(--page-width), calc(100vw - 40px));
  margin: 0 auto;
  padding: 0 0 56px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 24px;
  padding: 24px 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 245, 0.88);
  backdrop-filter: blur(14px);
}

html[data-theme="dark"] .site-header {
  background: rgba(19, 19, 17, 0.88);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong,
.home-stage-copy h1,
.home-section-head h2,
.section-head h1,
.quiz-toolbar h2,
.subject-card h2,
.favorites-hero h1,
.favorites-current-group h2,
.batch-question-head h3 {
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

.brand-copy strong {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-copy small,
.hero-copy,
.toolbar-meta,
.sidebar-copy,
.chapter-meta,
.panel-note,
.modal-subtitle,
.favorite-origin,
.home-section-copy,
.favorites-toolbar-copy {
  color: var(--text-soft);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px 16px;
  min-width: 0;
}

.top-nav-link {
  flex: 0 0 auto;
  padding: 8px 0;
  color: var(--text-soft);
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.top-nav-link:hover,
.top-nav-link:focus-visible {
  color: var(--text);
  border-color: currentColor;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: 4px;
}

.theme-control-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.theme-select,
.ghost-link,
.ghost-button,
.accent-button,
.top-nav-link[href],
.favorites-directory-link {
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    transform 0.18s ease;
}

.theme-select {
  min-height: 40px;
  min-width: 128px;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--text);
  appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  white-space: nowrap;
}

.theme-select:hover {
  border-color: var(--line-strong);
  background-color: var(--surface-muted);
}

.ghost-link,
.ghost-button,
.accent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.ghost-link:hover,
.ghost-button:hover,
.accent-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.accent-button {
  border-color: transparent;
  color: var(--surface);
  background: var(--text);
}

.accent-button:hover {
  background: var(--accent);
}

.content,
.chapter-layout {
  margin-top: 30px;
}

.home-page {
  display: grid;
  gap: 40px;
}

.home-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 28px 32px;
  align-items: end;
  padding: 26px 0 30px;
  border-bottom: 1px solid var(--line);
}

.home-stage-copy {
  max-width: 860px;
}

.home-stage-copy h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 5.6rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.hero-copy {
  margin: 16px 0 0;
  max-width: 62ch;
  font-size: 1.02rem;
}

.home-stage-meta {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: flex-start;
  gap: 10px;
}

.home-meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  white-space: nowrap;
}

.home-favorites-link {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.home-favorites-link:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.home-favorites-copy {
  display: grid;
  gap: 8px;
}

.home-favorites-copy strong {
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
}

.home-favorites-copy .hero-copy {
  margin: 0;
}

.home-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
}

.home-section-head h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.home-section-copy {
  max-width: 34ch;
  margin: 0;
  text-align: right;
}

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

.subject-card {
  display: grid;
  gap: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.subject-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.subject-card-top,
.subject-card-footer,
.subject-card-metrics,
.chapter-row,
.sidebar-chapter,
.panel-head,
.nav-pagination,
.bottom-pagination,
.favorites-directory-summary,
.favorites-current-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.subject-card-mark {
  color: var(--text-faint);
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.65rem;
  line-height: 1;
}

.subject-card h2 {
  margin: 18px 0 10px;
  font-size: clamp(1.75rem, 3vw, 2.15rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.subject-card-copy {
  margin: 0;
  color: var(--text-soft);
}

.subject-card-metrics {
  margin-top: 22px;
  color: var(--text-soft);
}

.subject-card-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
}

.subject-card-footer strong {
  font-size: 1rem;
}

.card-kicker,
.eyebrow {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card-kicker {
  word-break: break-all;
}

.section-head,
.favorites-hero,
.quiz-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.section-head h1,
.favorites-hero h1,
.quiz-toolbar h2,
.sidebar h1,
.favorites-current-group h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3.8vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.chapter-list-page {
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.chapter-row {
  padding: 18px 6px;
  border-bottom: 1px solid var(--line);
}

.chapter-row:hover {
  padding-left: 12px;
  background: var(--accent-soft);
}

.chapter-row.disabled,
.sidebar-chapter.disabled {
  opacity: 0.48;
  cursor: default;
}

.chapter-row.disabled:hover,
.sidebar-chapter.disabled:hover {
  background: transparent;
  transform: none;
}

.chapter-name {
  font-size: 1.02rem;
}

.chapter-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  transition: grid-template-columns 0.2s ease, gap 0.2s ease;
}

.sidebar {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.chapter-layout.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.chapter-layout.sidebar-collapsed .sidebar {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}

.chapter-layout.sidebar-collapsed .quiz-layout {
  width: 100%;
}

.chapter-layout.sidebar-collapsed .quiz-layout > * {
  width: min(var(--reading-width), 100%);
  margin-inline: auto;
}

.sidebar-section,
.question-nav-panel,
.batch-question-card,
.favorites-toolbar,
.favorites-directory,
.favorites-current-group,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.sidebar-section,
.question-nav-panel,
.favorites-toolbar,
.favorites-directory,
.favorites-current-group,
.empty-state {
  padding: 20px;
}

.sidebar-copy {
  margin: 12px 0 18px;
}

.chapter-accordion {
  overflow: hidden;
}

.chapter-accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.chapter-accordion-summary h2,
.panel-head h3,
.favorites-directory-head h2 {
  margin: 0;
  font-size: 1rem;
}

.accordion-indicator {
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--text-soft);
  border-bottom: 1.5px solid var(--text-soft);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.chapter-accordion:not([open]) .accordion-indicator {
  transform: rotate(-45deg);
}

.chapter-sidebar-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-chapter {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
}

.sidebar-chapter:hover {
  border-color: var(--line);
  background: var(--surface-muted);
}

.sidebar-chapter.active {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--text);
}

.quiz-layout,
.favorites-content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 10px 12px;
}

.toolbar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.92rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.question-nav-item {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-weight: 600;
}

.question-nav-item.active {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.question-nav-item.correct {
  border-color: var(--success-line);
  background: var(--success-soft);
  color: var(--success);
}

.question-nav-item.incorrect {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.question-nav-item.favorited::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--favorite);
}

.panel-note {
  margin: 6px 0 0;
  font-size: 0.92rem;
}

.nav-pagination,
.bottom-pagination {
  margin-top: 16px;
}

.bottom-pagination {
  justify-content: center;
}

.bottom-page-indicator {
  min-width: 84px;
  color: var(--text-soft);
  text-align: center;
}

.nav-pagination .ghost-button[disabled],
.bottom-pagination .ghost-button[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.question-list,
.favorites-list {
  display: grid;
  gap: 18px;
}

.batch-question-card {
  padding: 24px;
}

.batch-question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.batch-question-head h3 {
  margin: 8px 0 0;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.batch-question-index {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.batch-question-actions,
.question-card-toolbar,
.favorites-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.favorite-origin {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

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

.question-block h4 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.rendered-fragment {
  color: var(--text);
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.rendered-fragment > :first-child {
  margin-top: 0;
}

.rendered-fragment > :last-child {
  margin-bottom: 0;
}

.rendered-fragment p,
.rendered-fragment ul,
.rendered-fragment ol,
.rendered-fragment table,
.rendered-fragment blockquote,
.rendered-fragment pre {
  margin-top: 0;
  margin-bottom: 1em;
}

.rendered-fragment ul,
.rendered-fragment ol {
  padding-left: 1.4em;
}

.rendered-fragment table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rendered-fragment th,
.rendered-fragment td {
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.rendered-fragment blockquote {
  padding: 12px 16px;
  border-left: 2px solid var(--line-strong);
  background: var(--surface-muted);
}

.rendered-fragment pre {
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}

.rendered-fragment code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.94em;
}

.rendered-fragment img {
  margin: 14px auto;
}

.rendered-fragment math,
.rendered-fragment mjx-container {
  max-width: 100%;
  overflow-x: auto;
}

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

.option-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.option-card:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

.option-card.option-static {
  cursor: default;
}

.option-card.option-static:hover {
  transform: none;
}

.option-card.correct {
  border-color: var(--success-line);
  background: var(--success-soft);
}

.option-card.incorrect {
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.option-label {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  flex-shrink: 0;
}

.option-card.correct .option-label {
  border-color: var(--success-line);
  color: var(--success);
}

.option-card.incorrect .option-label {
  border-color: var(--danger-line);
  color: var(--danger);
}

.judge-result {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
  color: var(--text-soft);
}

.judge-result.correct {
  border-color: var(--success-line);
  background: var(--success-soft);
  color: var(--success);
}

.judge-result.incorrect {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.question-card-toolbar {
  margin-top: 16px;
}

.ghost-button.favorite-toggle.active {
  border-color: var(--favorite-line);
  background: var(--favorite-soft);
  color: var(--favorite);
}

.inline-analysis {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.inline-analysis-head {
  margin-bottom: 12px;
  color: var(--text-soft);
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.empty-state {
  color: var(--text-soft);
  text-align: center;
}

.favorites-page-root {
  margin-top: 24px;
}

.favorites-hero-meta {
  justify-content: flex-end;
}

.favorites-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.favorites-toolbar {
  margin-bottom: 18px;
}

.favorites-toolbar-copy {
  margin: 0;
}

.favorites-directory {
  position: sticky;
  top: 92px;
}

.favorites-directory-head p {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.favorites-directory-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 4px;
}

.favorites-directory-subject {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.favorites-directory-subject:first-child {
  border-top: 0;
  padding-top: 0;
}

.favorites-directory-summary {
  cursor: pointer;
}

.favorites-directory-summary span {
  font-weight: 600;
}

.favorites-directory-summary strong,
.favorites-directory-link strong {
  color: var(--text-soft);
  font-size: 0.88rem;
  white-space: nowrap;
}

.favorites-directory-chapters {
  display: grid;
  gap: 8px;
  padding: 10px 0 2px;
}

.favorites-directory-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.favorites-directory-link:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.favorites-directory-link.active {
  border-color: var(--line-strong);
  background: var(--surface);
}

.favorites-current-group {
  padding: 20px 24px;
}

.favorites-current-group .eyebrow {
  margin-bottom: 10px;
}

.favorite-question-card .judge-result {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .home-stage,
  .favorites-layout,
  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .favorites-directory {
    position: static;
    top: auto;
  }

  .chapter-layout.sidebar-collapsed .quiz-layout > * {
    width: 100%;
  }
}

@media (max-width: 860px) {
  .page-shell {
    width: min(var(--page-width), calc(100vw - 28px));
  }

  .site-header,
  .section-head,
  .favorites-hero,
  .quiz-toolbar,
  .favorites-current-group,
  .home-section-head,
  .home-favorites-link {
    grid-template-columns: 1fr;
  }

  .site-header {
    position: static;
    gap: 16px;
    padding: 18px 0 16px;
  }

  .top-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .home-subject-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .favorites-hero-meta {
    justify-content: flex-start;
  }

  .toolbar-meta {
    align-items: flex-start;
    text-align: left;
  }

  .home-section-copy {
    text-align: left;
  }

  .question-nav-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: calc(100vw - 24px);
    padding-bottom: 40px;
  }

  .content,
  .chapter-layout {
    margin-top: 24px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .brand-copy small {
    font-size: 0.82rem;
  }

  .home-stage {
    gap: 20px;
    padding: 18px 0 24px;
  }

  .home-stage-copy h1 {
    font-size: clamp(2.3rem, 12vw, 3.8rem);
  }

  .subject-card,
  .sidebar-section,
  .question-nav-panel,
  .batch-question-card,
  .favorites-toolbar,
  .favorites-directory,
  .favorites-current-group,
  .empty-state,
  .home-favorites-link {
    padding: 16px;
    border-radius: 18px;
  }

  .chapter-row {
    padding: 16px 0;
  }

  .batch-question-head,
  .question-card-toolbar,
  .batch-question-actions,
  .favorites-current-group,
  .nav-pagination,
  .bottom-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .question-nav-item {
    min-height: 40px;
  }

  .options-list {
    gap: 8px;
  }

  .option-card {
    padding: 12px;
    gap: 12px;
  }

  .option-label {
    width: 1.75rem;
    height: 1.75rem;
  }

  .theme-select,
  .ghost-link,
  .ghost-button,
  .accent-button {
    min-height: 40px;
  }
}

.home-landing {
  gap: 72px;
}

.home-landing .home-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 24px;
  align-items: end;
}

.home-landing .home-section-head h2,
.home-cta-card h2 {
  margin: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.home-section-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--text-faint);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.home-section-label::before {
  content: "";
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-blue));
}

.home-hero {
  position: relative;
  overflow: hidden;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 36px;
  background:
    radial-gradient(circle at top left, rgba(255, 113, 206, 0.16), transparent 26%),
    radial-gradient(circle at 90% 18%, rgba(1, 205, 254, 0.16), transparent 24%),
    linear-gradient(180deg, var(--warm-paper) 0%, var(--surface) 100%);
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -18% auto;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(185, 103, 255, 0.16), transparent 68%);
  pointer-events: none;
}

html[data-theme="dark"] .home-hero {
  background:
    radial-gradient(circle at top left, rgba(255, 141, 216, 0.12), transparent 26%),
    radial-gradient(circle at 90% 18%, rgba(98, 221, 255, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(23, 17, 41, 0.9) 0%, var(--surface) 100%);
}

.home-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(320px, 420px);
  gap: 28px;
  align-items: start;
}

.home-hero-copy {
  max-width: 760px;
}

.home-hero-title {
  display: grid;
  gap: 6px;
  margin: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: clamp(3rem, 7vw, 6.5rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.home-hero-title-accent {
  color: var(--text);
  text-shadow: 0.04em 0 0 rgba(255, 113, 206, 0.42), -0.04em 0 0 rgba(1, 205, 254, 0.32);
}

html[data-theme="dark"] .home-hero-title-accent {
  text-shadow: 0.04em 0 0 rgba(255, 141, 216, 0.36), -0.04em 0 0 rgba(98, 221, 255, 0.28);
}

.home-hero-subtitle {
  max-width: 62ch;
  margin: 22px 0 0;
  color: var(--text-soft);
  font-size: 1.08rem;
  line-height: 1.85;
}

.home-hero-actions,
.home-cta-actions,
.home-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.home-primary-link,
.home-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.home-primary-link {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--neon-deep) 0%, #000 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 113, 206, 0.18);
}

.home-primary-link:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 113, 206, 0.24),
    0 10px 24px rgba(46, 31, 71, 0.18);
}

.home-secondary-link {
  background: rgba(255, 255, 255, 0.62);
  color: var(--text);
}

html[data-theme="dark"] .home-secondary-link {
  background: rgba(255, 255, 255, 0.04);
}

.home-secondary-link:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface);
}

.home-hero-actions {
  margin-top: 28px;
}

.home-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.home-info-pill,
.home-panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(185, 103, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text-soft);
  white-space: nowrap;
}

html[data-theme="dark"] .home-info-pill,
html[data-theme="dark"] .home-panel-badge {
  background: rgba(255, 255, 255, 0.04);
}

.home-scroll-indicator {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 34px;
  color: var(--text-faint);
  font-size: 0.92rem;
}

.home-scroll-line {
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-blue));
}

.home-hero-panel {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid rgba(185, 103, 255, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px);
}

html[data-theme="dark"] .home-hero-panel {
  background: rgba(23, 23, 21, 0.72);
}

.home-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.home-panel-head .home-section-label {
  margin-bottom: 0;
}

.home-panel-grid,
.home-features-grid,
.home-subject-grid {
  display: grid;
  gap: 14px;
}

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

.home-panel-card,
.home-stat-card,
.home-feature-card,
.home-list-column,
.home-subject-card,
.home-cta-card {
  border: 1px solid var(--line);
  background: var(--surface);
}

.home-panel-card {
  min-height: 132px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(250, 249, 247, 0.88);
}

html[data-theme="dark"] .home-panel-card {
  background: rgba(255, 255, 255, 0.03);
}

.home-panel-card strong,
.home-stat-card strong,
.home-feature-card h3,
.home-list-column h3,
.home-subject-card h3 {
  display: block;
  margin: 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

.home-panel-card strong {
  font-size: 1.08rem;
}

.home-panel-card p,
.home-feature-card p,
.home-subject-card p,
.home-cta-card p {
  margin: 10px 0 0;
  color: var(--text-soft);
}

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

.home-stat-card {
  min-height: 180px;
  padding: 24px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--warm-paper-muted) 100%);
}

html[data-theme="dark"] .home-stat-card {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.home-stat-card strong {
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.home-stat-card span {
  display: block;
  margin-top: 10px;
  font-size: 1rem;
}

.home-stat-card small {
  display: block;
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.7;
}

.home-timeline {
  position: relative;
  display: grid;
  gap: 0;
  margin-top: 28px;
}

.home-timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 10px;
  width: 1px;
  background: linear-gradient(180deg, var(--neon-pink), var(--neon-blue));
  opacity: 0.42;
}

.home-timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 18px;
  padding: 0 0 28px;
}

.home-timeline-item:last-child {
  padding-bottom: 0;
}

.home-timeline-marker {
  position: relative;
  z-index: 1;
  width: 21px;
  height: 21px;
  margin-top: 6px;
  border: 5px solid var(--warm-paper);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-blue));
  box-shadow: 0 0 0 1px rgba(185, 103, 255, 0.2);
}

html[data-theme="dark"] .home-timeline-marker {
  border-color: var(--surface);
}

.home-timeline-content {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.home-timeline-step {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 113, 206, 0.08);
  color: var(--text-soft);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
}

.home-timeline-content h3 {
  margin: 14px 0 8px;
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.5rem;
  line-height: 1.08;
}

.home-timeline-content p {
  max-width: 58ch;
  margin: 0;
  color: var(--text-soft);
}

.home-features-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 28px;
}

.home-feature-card {
  min-height: 220px;
  padding: 22px;
  border-radius: 22px;
  background: var(--surface);
}

.home-feature-card:hover,
.home-subject-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.home-feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(185, 103, 255, 0.26);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 113, 206, 0.08), rgba(1, 205, 254, 0.08));
  color: var(--text);
  font-size: 1.15rem;
}

.home-feature-card h3 {
  margin-top: 20px;
  font-size: 1.4rem;
  line-height: 1.08;
}

.home-list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.home-list-column {
  padding: 22px;
  border-radius: 22px;
}

.home-list-column h3 {
  font-size: 1.28rem;
}

.home-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.home-list li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  color: var(--text-soft);
}

.home-list li span:first-child {
  color: var(--neon-violet);
}

.home-subject-section {
  scroll-margin-top: 90px;
}

.home-subject-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 28px;
}

.home-subject-card {
  display: grid;
  gap: 0;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(250, 249, 247, 0.92) 0%, rgba(245, 245, 245, 0.96) 100%);
}

html[data-theme="dark"] .home-subject-card {
  background:
    linear-gradient(180deg, rgba(23, 23, 21, 0.96) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.home-subject-card-top,
.home-subject-meta,
.home-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.home-subject-index {
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.3rem;
  color: var(--text-faint);
}

.home-subject-source {
  color: var(--text-faint);
  font-size: 0.9rem;
}

.home-subject-card h3 {
  margin-top: 18px;
  font-size: 2rem;
  line-height: 1;
}

.home-subject-meta {
  margin-top: 18px;
  color: var(--text-soft);
}

.home-cta-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 28px 30px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(1, 205, 254, 0.1), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 113, 206, 0.12), transparent 26%),
    linear-gradient(180deg, var(--warm-paper) 0%, var(--surface) 100%);
}

html[data-theme="dark"] .home-cta-card {
  background:
    radial-gradient(circle at top right, rgba(98, 221, 255, 0.08), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 141, 216, 0.08), transparent 26%),
    linear-gradient(180deg, var(--neon-deep) 0%, var(--surface) 100%);
}

.home-cta-card h2 {
  max-width: 14ch;
}

.home-footer {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.home-footer-brand strong {
  display: block;
  font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 1.4rem;
}

.home-footer-brand p {
  margin: 6px 0 0;
  color: var(--text-soft);
}

.home-footer-links a {
  padding: 8px 0;
  color: var(--text-soft);
  border-bottom: 1px solid transparent;
}

.home-footer-links a:hover {
  color: var(--text);
  border-color: currentColor;
}

@media (max-width: 1100px) {
  .home-hero-grid,
  .home-stats-grid,
  .home-features-grid,
  .home-list-grid,
  .home-subject-grid,
  .home-cta-card,
  .home-landing .home-section-head {
    grid-template-columns: 1fr;
  }

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

  .home-cta-card h2 {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .home-landing {
    gap: 56px;
  }

  .home-hero {
    padding: 24px;
    border-radius: 26px;
  }

  .home-hero-title {
    font-size: clamp(2.5rem, 11vw, 4.6rem);
  }

  .home-hero-subtitle {
    font-size: 1rem;
  }

  .home-panel-grid,
  .home-stats-grid,
  .home-features-grid,
  .home-list-grid,
  .home-subject-grid {
    grid-template-columns: 1fr;
  }

  .home-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .home-hero {
    padding: 18px;
  }

  .home-landing .home-section-head h2,
  .home-cta-card h2 {
    font-size: clamp(1.7rem, 9vw, 2.6rem);
  }

  .home-primary-link,
  .home-secondary-link {
    width: 100%;
  }

  .home-panel-grid {
    grid-template-columns: 1fr;
  }

  .home-panel-card,
  .home-stat-card,
  .home-feature-card,
  .home-list-column,
  .home-subject-card,
  .home-cta-card,
  .home-timeline-content {
    border-radius: 18px;
  }

  .home-stat-card,
  .home-feature-card,
  .home-list-column,
  .home-subject-card {
    padding: 18px;
  }

  .home-timeline-item {
    gap: 14px;
  }

  .home-subject-card h3 {
    font-size: 1.65rem;
  }
}
