/* =========================================================
   胖阿杰教育课 · 总站
   Design tokens: ink / paper / lamp / three spines
   ========================================================= */

:root {
  --ink: #0d1512;
  --ink-2: #121d18;
  --ink-3: #18251f;
  --paper: #ece7d8;
  --paper-dim: #cfc9b8;
  --muted: #9aa79c;
  --faint: #7c8a7f;
  --line: rgba(236, 231, 216, .13);
  --line-soft: rgba(236, 231, 216, .07);
  --gold: #d8b06a;
  --gold-deep: #8a6a33;
  --heading: #f0ebdd;
  --topbar-bg: rgba(13, 21, 18, .88);
  --scrim: rgba(6, 10, 8, .78);
  --hover: rgba(236, 231, 216, .06);
  --hover-soft: rgba(236, 231, 216, .045);
  --bar-track: rgba(236, 231, 216, .12);
  --line-strong: rgba(236, 231, 216, .32);
  --selection: rgba(216, 176, 106, .28);
  --selection-ink: #ffffff;

  --comm: #d9a95c;
  --comm-deep: #7a5a24;
  --parent: #c8775e;
  --parent-deep: #7d3a28;
  --boys: #93a86f;
  --boys-deep: #3f4d2b;
  --girls: #b0788a;
  --girls-deep: #5f3a48;
  --gp: #a08256;
  --gp-deep: #5a4227;
  --teens: #5b82a8;
  --teens-deep: #24384f;

  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  --topbar: 76px;
  --wrap: 1180px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 600px at 82% 4%, rgba(216, 176, 106, .07), transparent 68%),
    radial-gradient(700px 500px at 4% 22%, rgba(147, 168, 111, .05), transparent 70%);
}

::selection { background: var(--selection); color: var(--selection-ink); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p, ul { margin: 0; }
ul { list-style: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 8px 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
}
.skip-link:focus { top: 12px; }

.wrap {
  width: min(var(--wrap), calc(100% - 96px));
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

/* ---------------- topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 28px;
  padding-inline: max(24px, calc((100vw - var(--wrap)) / 2));
  background: var(--topbar-bg);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  flex-shrink: 0;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  align-self: center;
  filter: saturate(.95);
}
.brand b {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
}
.brand span {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .22em;
  color: var(--gold);
  text-transform: uppercase;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 13.5px;
  color: var(--muted);
}
.topnav a {
  position: relative;
  padding: 4px 0;
  transition: color .18s ease;
}
.topnav a:hover { color: var(--paper); }
.topnav a[aria-current="page"] { color: var(--paper); }
.topnav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--gold);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  transition: border-color .18s ease, color .18s ease;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--paper); }
.search-trigger svg { width: 15px; height: 15px; }
.search-trigger kbd {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--faint);
}

.menu-btn {
  display: none;
  width: 36px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
}
.menu-btn svg { width: 18px; height: 18px; }

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--topbar);
  left: 0;
  right: 0;
  z-index: 55;
  padding: 8px 24px 18px;
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.mobile-nav a {
  display: block;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  color: var(--paper-dim);
}
.mobile-nav a:last-child { border-bottom: 0; }
body.nav-open .mobile-nav { display: block; }

/* ---------------- hero ---------------- */

.hero {
  position: relative;
  padding: 96px 0 104px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(300px, .8fr);
  gap: 64px;
  align-items: center;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .26em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 26px;
}
.eyebrow::after {
  content: "";
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-deep), transparent);
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 4.7vw, 66px);
  line-height: 1.22;
  letter-spacing: .01em;
  color: var(--heading);
}
.hero h1 em {
  font-style: normal;
  color: var(--gold);
  position: relative;
}

.hero-sub {
  margin-top: 28px;
  max-width: 29em;
  font-size: 15.5px;
  line-height: 1.95;
  color: var(--muted);
}
.hero-sub strong { color: var(--paper-dim); font-weight: 500; }
.hero-sub .br { display: block; }
.m-br { display: none; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  max-width: 470px;
}
.hero-meta div {
  padding: 15px 0 14px;
  flex: 1 1 0;
  min-width: 96px;
}
.hero-meta div + div {
  padding-left: 20px;
  border-left: 1px solid var(--line-soft);
}
.hero-meta b {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--paper);
}
.hero-meta span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--faint);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 34px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 46px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.btn svg { width: 16px; height: 16px; transition: transform .18s ease; }
.btn-primary { background: var(--gold); color: #17140c; }
.btn-primary:hover { background: #e5c07d; }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-ghost {
  border: 1px solid var(--line);
  color: var(--paper-dim);
}
.btn-ghost:hover { border-color: var(--line-strong); color: var(--paper); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--paper-dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: color .18s ease, border-color .18s ease;
}
.link-arrow:hover { color: var(--gold); border-color: var(--gold-deep); }

.hero-progress { margin-top: 26px; max-width: 380px; }
.hero-progress .hp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--faint);
  margin-bottom: 7px;
}
.hero-progress .hp-row b { font-family: var(--mono); color: var(--gold); font-weight: 500; }
.bar {
  height: 2px;
  background: var(--bar-track);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--gold);
  width: 0;
  transition: width .5s ease;
}

/* shelf */

.shelf {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 520px;
}

.shelf-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .22em;
  color: var(--faint);
  margin-bottom: 26px;
}
.shelf-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.shelf-glow {
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: 420px;
  height: 420px;
  max-width: 120%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(216, 176, 106, .16), transparent 62%);
  pointer-events: none;
}

.books {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 390px;
  padding-bottom: 12px;
}

.book {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: var(--h, 320px);
  width: var(--w, 50px);
  padding: 16px 0;
  border-radius: 2px 3px 2px 2px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .34), rgba(255, 255, 255, .1) 16%, rgba(255, 255, 255, .04) 60%, rgba(0, 0, 0, .32)),
    linear-gradient(180deg, var(--c, #8a7b62), var(--cd, #4a3f2c));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .1),
    0 18px 34px -18px rgba(0, 0, 0, .8);
  transition: transform .26s cubic-bezier(.2, .7, .3, 1), box-shadow .26s ease;
}
/* 书脊的颜色与尺寸由 catalog.js 的 accent / shelf 决定，portal.js 注入为内联变量。
   这样增删课程不需要改 CSS，也不会再出现「新加的书没有颜色」。 */

.book:hover {
  transform: translateY(-10px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .16),
    0 30px 42px -20px rgba(0, 0, 0, .85);
}

.book::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 46px;
  height: 1px;
  background: rgba(0, 0, 0, .28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12);
}

.book-code {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  writing-mode: vertical-rl;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .28em;
  color: rgba(18, 20, 14, .62);
}

.book-title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .18em;
  color: #1c2117;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .18);
}

/* 九本书并排时「胖阿杰」会重复九次，且字号在 50px 宽的书脊上已经糊成一团，
   去掉它，书脊更干净，中间的书名也更醒目。 */
.book-foot { display: none; }

.shelf-board {
  position: relative;
  height: 13px;
  margin: 0 -14px;
  background: linear-gradient(180deg, #34443a, #1a2620 62%, #101a15);
  border-top: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 26px 48px -26px rgba(0, 0, 0, .95);
}
.shelf-board::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -16px;
  height: 18px;
  background: radial-gradient(ellipse at 50% 0, rgba(0, 0, 0, .55), transparent 72%);
  filter: blur(3px);
}

.shelf-note {
  margin-top: 34px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--faint);
  text-align: center;
}
.shelf-note b { color: var(--paper-dim); font-weight: 500; }

/* ---------------- section shell ---------------- */

.section { padding: 100px 0; border-bottom: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 52px;
}

.section-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .26em;
  color: var(--gold-deep);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(27px, 3.1vw, 38px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: .01em;
  color: var(--heading);
}
.section-head .intro {
  max-width: 27em;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
  padding-bottom: 4px;
}

/* ---------------- guide ---------------- */

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.guide-card {
  position: relative;
  display: block;
  padding: 30px 32px 28px;
  background: var(--ink);
  transition: background .22s ease;
}
.guide-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 30px;
  width: 2px;
  height: 22px;
  background: var(--c);
  opacity: .85;
  transition: height .22s ease;
}
.guide-card:hover { background: var(--ink-2); }
.guide-card:hover::before { height: 40px; }

.guide-course {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: var(--muted);
  text-transform: uppercase;
}
.guide-course i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}

.guide-card h3 {
  margin-top: 14px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--heading);
  transition: color .18s ease;
}
.guide-card:hover h3 { color: var(--c); }

.guide-card p {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--muted);
}

.guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--faint);
}
.guide-foot .nums {
  font-family: var(--mono);
  letter-spacing: .08em;
  color: var(--paper-dim);
}
.guide-foot .go {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--faint);
  transition: transform .2s ease, color .2s ease;
}
.guide-card:hover .go { color: var(--c); transform: translateX(4px); }

/* ---------------- courses ---------------- */

.course-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }

.course {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  background: var(--ink);
  transition: background .22s ease;
}
.course:hover { background: var(--ink-2); }

.course-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 20px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, .03) 24%, rgba(0, 0, 0, .05) 74%, rgba(0, 0, 0, .18)),
    var(--c);
  overflow: hidden;
}
.course-cover::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(18, 20, 14, .22);
  pointer-events: none;
}
.course-cover::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(18, 20, 14, .16);
  box-shadow: 3px 0 7px -3px rgba(0, 0, 0, .35);
  z-index: 1;
}
.cover-code {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .22em;
  color: rgba(18, 20, 14, .68);
}
.cover-title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: .24em;
  color: #1b2016;
}
.cover-count {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  color: rgba(18, 20, 14, .68);
}

.course-body {
  padding: 30px 34px 28px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.course-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .2em;
  color: var(--c);
}
.course-label span { color: var(--faint); }

.course-state {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 7px;
  background: var(--gold);
  color: #17140c;
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  letter-spacing: .1em;
  vertical-align: 5px;
}

.course-body h3 {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--heading);
}
.course-tagline {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--paper-dim);
  opacity: .9;
}
.course-desc {
  margin-top: 12px;
  max-width: 44em;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--muted);
}

.course-mods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}
.course-mods li {
  padding: 4px 9px;
  border: 1px solid var(--line-soft);
  font-size: 11px;
  line-height: 1.5;
  color: var(--faint);
}

.course-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.course-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--faint);
}
.course-meta b { color: var(--paper-dim); font-weight: 500; }
.course-actions { display: flex; align-items: center; gap: 20px; }

.btn-sm {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  background: var(--paper);
  color: var(--ink);
}
.btn-sm:hover { background: #fff; }
.btn-sm svg { width: 14px; height: 14px; }

.course-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--faint);
}
.course-progress .bar { flex: 1; max-width: 220px; }
.course-progress b { font-family: var(--mono); color: var(--paper-dim); font-weight: 500; }

/* ---------------- index ---------------- */

.index-tools {
  position: sticky;
  top: var(--topbar);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  font-size: 12.5px;
  color: var(--muted);
  transition: color .16s ease, border-color .16s ease;
}
.tab b { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--faint); }
.tab:hover { color: var(--paper); border-color: var(--line); }
.tab[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
.tab[aria-pressed="true"] b { color: rgba(13, 21, 18, .55); }

.idx-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  min-width: 220px;
}
.idx-search svg { width: 14px; height: 14px; color: var(--faint); flex-shrink: 0; }
.idx-search input {
  width: 100%;
  border: 0;
  background: none;
  color: var(--paper);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.idx-search input::placeholder { color: var(--faint); }
.idx-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.idx-course { border-top: 1px solid var(--line); padding-top: 30px; margin-top: 30px; }
.idx-course:first-of-type { border-top: 0; margin-top: 10px; padding-top: 0; }

.idx-course-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}
.idx-course-head i {
  width: 7px;
  height: 7px;
  background: var(--c);
  flex-shrink: 0;
  transform: translateY(-2px);
}
.idx-course-head h3 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  color: var(--heading);
}
.idx-course-head span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--faint);
}
.idx-course-head a {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}
.idx-course-head a:hover { color: var(--c); border-color: var(--c); }

.idx-group { margin-bottom: 22px; }
.idx-group h4 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .14em;
  color: var(--faint);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 2px;
}

.idx-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 34px; }
.idx-list li { border-bottom: 1px solid var(--line-soft); }
.idx-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  transition: background .16s ease, padding .16s ease;
}
.idx-row:hover { background: var(--hover-soft); padding-inline: 8px; }
.idx-row .n {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--faint);
}
.idx-row .t {
  font-size: 14px;
  line-height: 1.5;
  color: var(--paper-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.idx-row:hover .t { color: var(--paper); }
.idx-row .min { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.idx-row .arrow { color: var(--faint); font-size: 14px; transition: transform .16s ease, color .16s ease; }
.idx-row:hover .arrow { color: var(--c); transform: translateX(3px); }

.idx-empty {
  padding: 64px 0;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
}
.idx-empty b { display: block; font-family: var(--serif); font-size: 18px; font-weight: 500; color: var(--paper-dim); margin-bottom: 6px; }

/* ---------------- about ---------------- */

.about-grid {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.portrait { position: relative; }
.portrait-frame {
  position: relative;
  padding: 10px;
  background: #f4efe2;
  transform: rotate(-1.6deg);
  box-shadow: 0 24px 40px -26px rgba(0, 0, 0, .9);
}
.portrait-frame img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: center 38%; }
.portrait-frame::after {
  content: "";
  position: absolute;
  inset: 10px;
  box-shadow: inset 0 0 0 1px rgba(23, 26, 18, .12);
}
.portrait figcaption {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.9;
  letter-spacing: .1em;
  color: var(--faint);
  transform: rotate(-1.6deg);
}

.portrait-quote {
  margin-top: 30px;
  padding-left: 14px;
  border-left: 1px solid var(--gold-deep);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.95;
  color: var(--muted);
  transform: rotate(-1.6deg);
}

.about-copy { max-width: 42em; }
.about-copy p {
  font-size: 15px;
  line-height: 2.05;
  color: var(--paper-dim);
  margin-bottom: 18px;
}
.about-copy p.lead {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.9;
  color: var(--heading);
}
.about-copy strong { color: var(--gold); font-weight: 500; }
.about-sign {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--faint);
}
.about-sign b {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: .06em;
  color: var(--paper);
}

/* ---------------- upcoming ---------------- */

.next-list { border-top: 1px solid var(--line); }
.next-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 20px;
  padding: 18px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.next-row .nm { font-family: var(--serif); font-size: 17px; color: var(--paper-dim); }
.next-row .nt { font-size: 12px; color: var(--faint); }
.next-row .st {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  color: var(--faint);
  border: 1px solid var(--line);
  padding: 3px 8px;
}
.next-row .st.now { color: var(--gold); border-color: var(--gold-deep); }

/* ---------------- closing + footer ---------------- */

.closing {
  padding: 84px 0;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.closing p {
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 27px);
  line-height: 1.8;
  color: var(--heading);
}
.closing span {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.site-foot {
  padding: 34px 0 44px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--faint);
}
.site-foot .fb { font-family: var(--mono); letter-spacing: .1em; }
.site-foot a { border-bottom: 1px solid var(--line); }
.site-foot a:hover { color: var(--paper-dim); }

/* ---------------- search layer ---------------- */

.search-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: start center;
  padding: 12vh 20px 40px;
  background: var(--scrim);
  backdrop-filter: blur(6px);
}
.search-panel {
  width: min(720px, 100%);
  background: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9);
  max-height: 74vh;
  display: flex;
  flex-direction: column;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.search-field svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }
.search-field input {
  flex: 1;
  border: 0;
  background: none;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 19px;
  outline: none;
}
.search-field input::placeholder { color: var(--faint); font-size: 16px; font-family: var(--sans); }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-close {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--faint);
  border: 1px solid var(--line);
  padding: 4px 7px;
}
.search-close:hover { color: var(--paper); }
.search-results { overflow-y: auto; padding: 6px 0 10px; }
.search-hint .hint-face { width: 68px; height: 68px; margin-bottom: 14px; }

.search-hint { padding: 22px 22px 26px; font-size: 12.5px; line-height: 1.9; color: var(--faint); }
.search-hint b { color: var(--paper-dim); font-weight: 500; }
.search-group-label {
  padding: 14px 22px 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--faint);
}
.result {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 22px;
  border-left: 2px solid transparent;
}
.result:hover, .result.is-active {
  background: var(--hover);
  border-left-color: var(--c);
}
.result i { width: 5px; height: 5px; background: var(--c); border-radius: 50%; }
.result .rt {
  display: block;
  font-size: 14px;
  color: var(--paper-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result.is-active .rt { color: var(--paper); }
.result .rm { display: block; font-size: 11px; color: var(--faint); margin-top: 1px; }
.result .rn { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }

/* ---------------- responsive ---------------- */

@media (max-width: 1080px) {
  .wrap { width: calc(100% - 64px); }
  .hero-grid { gap: 40px; }
  .hero-meta div { min-width: 80px; }
  .about-grid { grid-template-columns: 180px minmax(0, 1fr); gap: 40px; }
  .books { height: 330px; }
  .book { width: calc(var(--w) * .8); height: calc(var(--h) * .8); }
}

@media (max-width: 900px) {
  .topnav { display: none; }
  .menu-btn { display: grid; }
  .hero { padding: 64px 0 76px; }
  .hero-grid { grid-template-columns: 1fr; gap: 56px; }
  .shelf { justify-self: center; max-width: 460px; }
  .books { height: 310px; }
  .book { width: calc(var(--w) * .9); height: calc(var(--h) * .84); }
  .section { padding: 76px 0; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 38px; }
  .section-head .intro { max-width: none; }
  .guide-grid { grid-template-columns: 1fr; }
  .course { grid-template-columns: 116px minmax(0, 1fr); }
  .cover-code { font-size: 8px; letter-spacing: .1em; }
  .course-body { padding: 26px 26px 24px; }
  .idx-list { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; gap: 34px; }
  .portrait { width: 190px; }
}

@media (max-width: 620px) {
  .wrap { width: calc(100% - 40px); }
  .topbar { gap: 12px; padding-inline: 20px; }
  .brand span { display: none; }
  .search-trigger .txt, .search-trigger kbd { display: none; }
  .search-trigger { width: 36px; height: 34px; justify-content: center; padding: 0; }
  .hero { padding: 52px 0 64px; }
  .hero h1 { font-size: clamp(29px, 8.6vw, 40px); line-height: 1.26; }
  .hero-sub { font-size: 14.5px; margin-top: 22px; }
  .m-br { display: block; }
  .hero-meta { max-width: none; margin-top: 30px; }
  .hero-meta div { padding: 12px 0; min-width: 0; }
  .hero-meta div + div { padding-left: 12px; }
  .hero-meta b { font-size: 21px; }
  .hero-meta span { font-size: 10.5px; }
  .hero-actions { gap: 16px; margin-top: 26px; }
  .btn { height: 44px; padding: 0 18px; font-size: 13.5px; }
  .shelf { max-width: 360px; }
  .books { height: 240px; gap: 4px; }
  .book { width: calc(var(--w) * .7); height: calc(var(--h) * .64); padding: 12px 0 10px; }
  .book-title { font-size: 17px; letter-spacing: .14em; }
  .book-code, .book-foot { font-size: 7.5px; }
  .book::after { bottom: 38px; }
  .shelf-note { margin-top: 26px; font-size: 11.5px; }
  .section { padding: 60px 0; }
  .section-head h2 { font-size: 26px; }
  .guide-card { padding: 24px 22px 22px; }
  .guide-card h3 { font-size: 19px; }
  .course { grid-template-columns: 1fr; }
  .course-cover {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    min-height: 0;
  }
  .course-cover::after { inset: 6px; }
  .cover-title { writing-mode: horizontal-tb; font-size: 21px; letter-spacing: .16em; }
  .cover-code, .cover-count { font-size: 8.5px; }
  .course-body { padding: 22px 20px 22px; }
  .course-body h3 { font-size: 22px; }
  .course-foot { gap: 14px; }
  .course-actions { gap: 14px; }
  .index-tools { align-items: stretch; }
  .idx-search { margin-left: 0; width: 100%; }
  .idx-row { grid-template-columns: 30px minmax(0, 1fr) 14px; gap: 8px; padding: 11px 2px; }
  .idx-row .t { white-space: normal; line-height: 1.55; }
  .idx-row .min { display: none; }
  .idx-course-head { flex-wrap: wrap; gap: 8px 10px; }
  .idx-course-head a { margin-left: 0; }
  .about-copy p { font-size: 14px; }
  .about-copy p.lead { font-size: 17px; }
  .next-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .next-row .nt { grid-column: 1 / 2; }
  .next-row .st { grid-row: 1; grid-column: 2; }
  .site-foot { flex-direction: column; gap: 8px; }
  .search-layer { padding-top: 8vh; }
  .search-field input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ---------------- theme switch ---------------- */

.theme-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.theme-btn:hover { color: var(--gold); border-color: var(--line-strong); }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn .i-sun { display: none; }
html[data-theme="dark"] .theme-btn .i-sun { display: block; }
html[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------------- daylight theme ---------------- */

html[data-theme="light"] {
  --ink: #f3eee3;
  --ink-2: #faf6ec;
  --ink-3: #fffdf7;
  --paper: #1d231f;
  --paper-dim: #343c35;
  --muted: #5b635c;
  --faint: #646c65;
  --line: rgba(29, 35, 31, .16);
  --line-soft: rgba(29, 35, 31, .085);
  --line-strong: rgba(29, 35, 31, .3);
  --gold: #8a6222;
  --gold-deep: #7c571f;
  --heading: #1a201b;
  --topbar-bg: rgba(243, 238, 227, .9);
  --scrim: rgba(43, 38, 28, .38);
  --hover: rgba(29, 35, 31, .055);
  --hover-soft: rgba(29, 35, 31, .04);
  --bar-track: rgba(29, 35, 31, .12);
  --selection: rgba(216, 176, 106, .42);
  --selection-ink: #1d231f;
}

html[data-theme="light"] body::before {
  background:
    radial-gradient(900px 600px at 82% 2%, rgba(216, 176, 106, .22), transparent 66%),
    radial-gradient(760px 520px at 2% 26%, rgba(147, 168, 111, .12), transparent 70%);
}

html[data-theme="light"] .topbar { box-shadow: 0 1px 0 rgba(29, 35, 31, .04); }
html[data-theme="light"] .brand img { border-color: var(--line-strong); }

html[data-theme="light"] .hero h1 em { color: #a8762c; }
html[data-theme="light"] .btn-primary { background: #c9a45c; color: #1a1710; }
html[data-theme="light"] .btn-primary:hover { background: #d8b26c; }

html[data-theme="light"] .guide-card,
html[data-theme="light"] .course { background: var(--ink-2); }
html[data-theme="light"] .guide-card:hover,
html[data-theme="light"] .course:hover { background: var(--ink-3); }

html[data-theme="light"] .course-label { color: var(--muted); }
html[data-theme="light"] .course-state { background: #c9a45c; color: #1a1710; }
html[data-theme="light"] .btn-sm:hover { background: #2a322c; }
html[data-theme="light"] .tab[aria-pressed="true"] b { color: rgba(244, 239, 228, .62); }
html[data-theme="light"] .idx-row:hover .arrow { color: var(--paper-dim); }
html[data-theme="light"] .guide-card:hover h3 { color: var(--paper); }
html[data-theme="light"] .guide-course i,
html[data-theme="light"] .idx-course-head i,
html[data-theme="light"] .result i { box-shadow: 0 0 0 1px rgba(29, 35, 31, .22); }

html[data-theme="light"] .book {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .12),
    0 16px 28px -20px rgba(29, 35, 31, .5);
}
html[data-theme="light"] .shelf-glow {
  background: radial-gradient(circle, rgba(216, 176, 106, .26), transparent 64%);
}

html[data-theme="light"] .portrait-frame {
  background: #fffdf7;
  box-shadow: 0 20px 34px -26px rgba(29, 35, 31, .45);
}

html[data-theme="light"] .search-panel {
  box-shadow: 0 32px 70px -30px rgba(29, 35, 31, .35);
}
html[data-theme="light"] .search-field,
html[data-theme="light"] .search-results { background: var(--ink-2); }

html[data-theme="light"] .search-layer { background: rgba(30, 26, 18, .52); }
html[data-theme="light"] .search-hint { color: var(--muted); font-size: 13px; }
html[data-theme="light"] .search-hint b { color: var(--paper); }
html[data-theme="light"] .search-field input::placeholder { color: var(--muted); }
html[data-theme="light"] .result .rm { color: var(--muted); }

html[data-theme="light"] .shelf-board {
  background: linear-gradient(180deg, #9a7549, #76573a 58%, #5f452c);
  border-top-color: rgba(255, 255, 255, .35);
}
html[data-theme="light"] .shelf-board::after {
  background: radial-gradient(ellipse at 50% 0, rgba(29, 35, 31, .3), transparent 72%);
}

html[data-theme="light"] .search-panel {
  background: #fffdf7;
  border-color: rgba(29, 35, 31, .22);
}
html[data-theme="light"] .search-field,
html[data-theme="light"] .search-results { background: #fffdf7; }
