:root {
  --paper: #f6f0e5;
  --paper-deep: #ede2d0;
  --card: #fffdf8;
  --ink: #2d2924;
  --muted: #756d63;
  --line: #ded2c1;
  --red: #984c3d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(160, 103, 63, .09), transparent 30rem),
    linear-gradient(180deg, #f8f3ea 0, var(--paper) 42rem);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

.hero { border-bottom: 1px solid var(--line); }
.site-nav {
  display: flex;
  gap: 8px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px 0;
  font-size: 13px;
}
.site-nav a, .site-nav span {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}
.site-nav a:hover { color: var(--red); background: rgba(255,255,255,.65); }
.site-nav span { color: #fff; background: var(--red); }

.hero-inner { max-width: 920px; margin: 0 auto; padding: 56px 24px 48px; text-align: center; }
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
h1, h2, h3 { font-family: "Songti SC", "STSong", "SimSun", serif; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 62px); font-weight: 600; letter-spacing: .06em; line-height: 1.2; }
.hero-copy { max-width: 720px; margin: 22px auto 30px; color: var(--muted); font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.stat-item { display: flex; flex-direction: column; padding: 15px 10px; background: rgba(255,253,248,.78); }
.stat-item strong { color: var(--red); font-family: Georgia, serif; font-size: 23px; line-height: 1.2; }
.stat-item span { color: var(--muted); font-size: 12px; }
.source-note { max-width: 720px; margin: 13px auto 0; color: var(--muted); font-size: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 54px 24px 80px; }
.overview-section { margin-bottom: 66px; }
.section-heading, .catalog-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 22px; }
.section-heading h2, .catalog-head h2 { margin: 0; font-size: 30px; font-weight: 600; }
.section-heading > p { max-width: 440px; margin: 0; color: var(--muted); font-size: 13px; }
.theme-overview { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.theme-card {
  position: relative;
  min-height: 142px;
  padding: 17px;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255,253,248,.82);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.theme-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--theme); }
.theme-card:hover { transform: translateY(-2px); border-color: var(--theme); box-shadow: 0 10px 26px rgba(76,58,37,.08); }
.theme-card.active { color: #fff; border-color: var(--theme); background: var(--theme); }
.theme-card.active::before { background: rgba(255,255,255,.65); }
.theme-card strong { display: block; margin: 11px 0 7px; font-family: "Songti SC", "STSong", serif; font-size: 18px; }
.theme-card small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
.theme-card.active small { color: rgba(255,255,255,.82); }
.theme-count { color: var(--theme); font-size: 12px; font-weight: 700; }
.theme-card.active .theme-count { color: #fff; }

.result-count { color: var(--muted); font-size: 13px; }
.catalog-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(246,240,229,.94);
  backdrop-filter: blur(10px);
}
.search-wrap { flex: 1; }
.search-wrap input, .source-wrap select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdf9;
  font: inherit;
  font-size: 14px;
}
.search-wrap input:focus, .source-wrap select:focus { outline: 2px solid rgba(152,76,61,.2); border-color: var(--red); }
.source-wrap { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.source-wrap select { width: 130px; }
.reset-btn { height: 40px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.reset-btn:hover { color: var(--red); border-color: var(--red); }
.active-filter { min-height: 32px; padding: 9px 2px 0; color: var(--muted); font-size: 12px; }

.material-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.material-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 19px 20px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--theme);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 7px 22px rgba(77,57,34,.045);
}
.card-topline { display: flex; align-items: center; gap: 8px; }
.episode-number { color: var(--theme); font-size: 13px; font-weight: 800; letter-spacing: .05em; }
.theme-pill { padding: 2px 8px; border-radius: 999px; color: var(--theme); background: color-mix(in srgb, var(--theme) 10%, white); font-size: 11px; }
.duration { margin-left: auto; color: var(--muted); font-size: 11px; }
.material-card h3 { margin: 10px 0 2px; font-size: 22px; line-height: 1.35; }
.source-line { margin: 0 0 13px; color: var(--theme); font-size: 12px; }
.hook { margin: 0 0 14px; color: #514a42; font-size: 14px; }
.original-preview { display: flex; gap: 10px; padding: 12px; border-radius: 9px; background: #f7f1e7; }
.quote-mark { display: inline-grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; border: 1px solid var(--theme); border-radius: 50%; color: var(--theme); font-family: "Songti SC", serif; font-size: 13px; }
blockquote { margin: 0; color: #5c5147; font-family: "Songti SC", "STSong", serif; font-size: 14px; line-height: 1.7; }
details { margin: 8px 0 0; }
summary { color: var(--theme); font-size: 12px; cursor: pointer; }
.original-full { margin-top: 8px; padding: 12px; white-space: pre-wrap; border-left: 2px solid var(--theme); color: #564d44; background: #faf7f0; font-family: "Songti SC", serif; font-size: 14px; }
.golden { margin: 14px 0 0; color: var(--red); font-family: "Songti SC", serif; font-size: 14px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: auto; padding-top: 16px; }
.full-script-link, .episode-audio-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--theme);
  border-radius: 7px;
  color: var(--theme);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.episode-audio-link { color: #fff; background: var(--theme); }
.full-script-link:hover, .episode-audio-link:hover { filter: brightness(.94); }
.material-card:target { box-shadow: 0 0 0 4px color-mix(in srgb, var(--theme) 18%, transparent); }
.empty-state { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

.script-dialog {
  width: min(820px, calc(100vw - 28px));
  max-height: min(88vh, 920px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 28px 90px rgba(45, 34, 24, .28);
}
.script-dialog::backdrop { background: rgba(40, 32, 25, .58); backdrop-filter: blur(3px); }
.dialog-shell { display: flex; flex-direction: column; max-height: min(88vh, 920px); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); background: #f8f2e8; }
.dialog-zl { color: var(--red); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.dialog-head h2 { margin: 4px 0 1px; font-size: 27px; line-height: 1.3; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-close { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.dialog-close:hover { color: var(--red); border-color: var(--red); }
.dialog-body { padding: 24px; overflow-y: auto; white-space: pre-wrap; color: #463f38; font-family: "Songti SC", "STSong", "SimSun", serif; font-size: 16px; line-height: 1.9; }
.dialog-actions { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-top: 1px solid var(--line); background: #faf6ef; }
.dialog-actions button { padding: 7px 12px; border: 1px solid var(--red); border-radius: 7px; color: #fff; background: var(--red); cursor: pointer; }
.dialog-actions span { color: #4e7b58; font-size: 12px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px max(24px, calc((100vw - 1132px) / 2)); color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
footer p { margin: 0; }
footer a { color: var(--red); text-decoration: none; white-space: nowrap; }
code { color: #6e5543; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 920px) {
  .theme-overview { grid-template-columns: repeat(2, 1fr); }
  .material-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-nav { padding: 12px 14px 0; }
  .hero-inner { padding: 38px 16px 34px; }
  .hero-copy { font-size: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  main { padding: 38px 12px 56px; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .theme-overview { grid-template-columns: 1fr; }
  .theme-card { min-height: 112px; }
  .catalog-tools { position: static; flex-wrap: wrap; }
  .search-wrap { flex-basis: 100%; }
  .source-wrap { flex: 1; }
  .source-wrap select { width: 100%; }
  .material-card { padding: 16px; }
  .card-actions { grid-template-columns: 1fr; }
  .dialog-head { padding: 17px 16px 14px; }
  .dialog-head h2 { font-size: 22px; }
  .dialog-body { padding: 18px 16px; font-size: 15px; }
  .dialog-actions { padding: 10px 16px; }
  footer { flex-direction: column; padding: 22px 16px; }
}
