:root {
  --paper: #f7f0e1;
  --paper-strong: #fffaf0;
  --ink: #27211b;
  --muted: #645646;
  --accent: #a6441f;
  --accent-soft: #d97841;
  --panel: rgba(255, 250, 240, 0.88);
  --line: rgba(39, 33, 27, 0.12);
  --deep: #17303a;
  --deep-soft: #285568;
  --shadow: 0 20px 60px rgba(53, 36, 20, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 120, 65, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(40, 85, 104, 0.16), transparent 30%),
    linear-gradient(180deg, #f2e6ce 0%, #efe2cb 38%, #f8f2e7 100%);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  line-height: 1.75;
}

a {
  color: inherit;
}

.index-shell,
.page-shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.landing-hero,
.hero-panel,
.panel,
.pager-link,
.stat-card,
.card-link {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.landing-hero,
.hero-panel {
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.96), rgba(255, 244, 227, 0.9)),
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.45));
  border-radius: 28px;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 24px;
  padding: 28px;
  margin-bottom: 28px;
}

.landing-copy h1 {
  margin: 8px 0 12px;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-panel h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.85rem, 3.6vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.hero-panel h1.long-title {
  font-size: clamp(1.35rem, 2.2vw, 1.95rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.title-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.hero-copy {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 60ch;
}

.chapter-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 22px;
  background: rgba(23, 48, 58, 0.92);
  color: #f4ebdc;
}

.search-label {
  font-size: 0.92rem;
}

.search-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 14px 16px;
  font: inherit;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.62);
}

.filter-row,
.chip-row,
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip,
.chip {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
}

.filter-chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.filter-chip.active {
  background: #f0dcc0;
  color: #2a2018;
  border-color: #f0dcc0;
}

.helper-text {
  margin: 0;
  color: rgba(244, 235, 220, 0.78);
  font-size: 0.94rem;
}

.stat-card {
  min-width: 118px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.72);
}

.stat-card strong {
  display: block;
  font-size: 1.7rem;
}

.stat-card span {
  color: var(--muted);
}

.chapter-block {
  margin-bottom: 28px;
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.chapter-head h2 {
  margin: 4px 0 0;
  font-size: 1.8rem;
}

.chapter-note {
  max-width: 42ch;
  color: var(--muted);
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card-link {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  border-radius: 22px;
  padding: 20px;
  background: var(--panel);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  animation: card-rise 380ms ease both;
}

.card-link:hover {
  transform: translateY(-4px);
  border-color: rgba(166, 68, 31, 0.34);
  box-shadow: 0 22px 60px rgba(70, 39, 20, 0.2);
}

.card-link strong {
  font-size: 1.15rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-link strong.compact-title {
  font-size: 1.05rem;
}

.card-link p {
  margin: 0;
  color: var(--muted);
}

.card-order {
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.ghost-link,
.topbar-meta {
  color: var(--deep);
  text-decoration: none;
  font-size: 0.96rem;
}

.detail-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.detail-main {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.detail-sidebar {
  min-width: 0;
}

.sidebar-card {
  position: sticky;
  top: 20px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sidebar-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-current {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.sidebar-progress {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.sidebar-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.sidebar-chapters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-chip {
  border-radius: 999px;
  padding: 7px 12px;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--deep);
  background: rgba(23, 48, 58, 0.06);
  border: 1px solid rgba(23, 48, 58, 0.08);
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.sidebar-chip.active,
.sidebar-chip:hover {
  color: #fff6ed;
  background: var(--accent);
  border-color: var(--accent);
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 4px;
}

.sidebar-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border-radius: 16px;
  text-decoration: none;
  background: rgba(23, 48, 58, 0.04);
  border: 1px solid transparent;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.sidebar-link:hover {
  transform: translateX(2px);
  background: rgba(166, 68, 31, 0.08);
  border-color: rgba(166, 68, 31, 0.18);
}

.sidebar-link.active {
  background: linear-gradient(180deg, rgba(166, 68, 31, 0.14), rgba(217, 120, 65, 0.14));
  border-color: rgba(166, 68, 31, 0.28);
}

.sidebar-link-order {
  color: var(--accent);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.sidebar-link strong {
  font-size: 0.95rem;
  line-height: 1.45;
}

.hero-panel {
  padding: 28px;
}

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

.panel {
  padding: 22px;
  border-radius: 24px;
  background: var(--panel);
  animation: card-rise 320ms ease both;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
}

.panel p {
  margin: 0 0 12px;
}

.panel-ink {
  background: linear-gradient(180deg, rgba(23, 48, 58, 0.95), rgba(32, 62, 76, 0.92));
  color: #f5eddc;
}

.panel-highlight {
  background: linear-gradient(180deg, rgba(255, 247, 232, 0.98), rgba(245, 227, 198, 0.94));
}

.panel-accent {
  background: linear-gradient(180deg, rgba(166, 68, 31, 0.92), rgba(140, 46, 18, 0.94));
  color: #fff2eb;
}

.fallback-sentence {
  font-size: 1.04rem;
}

.mini-heading {
  margin: 18px 0 8px;
  font-size: 1.05rem;
  color: var(--deep);
}

.source-list,
.advice-list {
  margin: 0;
  padding-left: 20px;
}

.mnemonic-box {
  margin: 14px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  background: rgba(166, 68, 31, 0.08);
  color: var(--accent);
}

.chip {
  background: rgba(166, 68, 31, 0.1);
  color: var(--accent);
  border: 1px solid rgba(166, 68, 31, 0.16);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap td,
.table-wrap th {
  border: 1px solid rgba(39, 33, 27, 0.14);
  padding: 10px;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.pager-link {
  display: block;
  border-radius: 24px;
  padding: 18px 20px;
  text-decoration: none;
  background: rgba(255, 250, 240, 0.88);
}

.pager-link span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.pager-link strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.pager-link-disabled {
  opacity: 0.55;
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .landing-hero,
  .grid-panels,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .chapter-head {
    flex-direction: column;
    align-items: start;
  }

  .sidebar-card {
    position: static;
  }

  .sidebar-list {
    max-height: 280px;
  }
}

@media (max-width: 640px) {
  .index-shell,
  .page-shell {
    width: min(100vw - 20px, 1200px);
    padding-top: 12px;
  }

  .landing-hero,
  .hero-panel,
  .panel,
  .card-link,
  .pager-link {
    border-radius: 20px;
    padding: 18px;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .landing-copy h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .hero-panel h1 {
    font-size: clamp(1.55rem, 7vw, 2.1rem);
  }

  .hero-panel h1.long-title {
    font-size: clamp(1.2rem, 5.6vw, 1.55rem);
  }
}