/* ==========================================================================
   机械制造工艺学 · 知识检索
   Apple Books 气质：暖纸底 + 系统无衬线 UI + 宋体长阅读
   ========================================================================== */

:root {
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong",
           "SimSun", "宋体", Georgia, serif;
  --mono: "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  --bg: #f4f3ef;
  --bg-soft: #f8f7f3;
  --paper: #fffefb;
  --surface: #ffffff;
  --sidebar: rgba(250, 249, 245, 0.80);
  --topbar: rgba(246, 245, 241, 0.74);
  --fill: rgba(29, 29, 31, 0.045);
  --fill-strong: rgba(29, 29, 31, 0.075);

  --label: #1d1d1f;
  --label2: rgba(29, 29, 31, 0.62);
  --label3: rgba(29, 29, 31, 0.38);
  --line: rgba(29, 29, 31, 0.085);
  --line-strong: rgba(29, 29, 31, 0.17);

  --accent: #9c4a31;
  --accent-hover: #843c27;
  --accent-soft: rgba(156, 74, 49, 0.075);
  --accent-line: rgba(156, 74, 49, 0.22);
  --def: #2f6a5e;
  --def-bg: rgba(47, 106, 94, 0.055);
  --warn: #9a5a17;
  --warn-bg: rgba(168, 106, 28, 0.07);
  --green: #2f6f46;

  --shadow-sm: 0 1px 2px rgba(40, 30, 18, 0.04), 0 1px 1px rgba(40, 30, 18, 0.03);
  --shadow-md: 0 10px 30px rgba(40, 30, 18, 0.06), 0 2px 8px rgba(40, 30, 18, 0.04);
  --shadow-lg: 0 40px 100px rgba(30, 22, 12, 0.20), 0 12px 32px rgba(30, 22, 12, 0.10);

  --reading-size: 18px;
  --read-font: clamp(
    var(--reading-size),
    calc(var(--reading-size) + (100vw - 1440px) * 0.004),
    26px
  );
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.32, 1.25, 0.4, 1);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-soft: #0a0a0b;
  --paper: #141416;
  --surface: #1c1c1e;
  --sidebar: rgba(18, 18, 19, 0.78);
  --topbar: rgba(10, 10, 11, 0.72);
  --fill: rgba(255, 255, 255, 0.055);
  --fill-strong: rgba(255, 255, 255, 0.09);

  --label: #f5f5f7;
  --label2: rgba(245, 245, 247, 0.62);
  --label3: rgba(245, 245, 247, 0.34);
  --line: rgba(255, 255, 255, 0.095);
  --line-strong: rgba(255, 255, 255, 0.19);

  --accent: #e08a6e;
  --accent-hover: #eda082;
  --accent-soft: rgba(224, 138, 110, 0.105);
  --accent-line: rgba(224, 138, 110, 0.28);
  --def: #7cc2b2;
  --def-bg: rgba(124, 194, 178, 0.075);
  --warn: #e2a45c;
  --warn-bg: rgba(226, 164, 92, 0.085);
  --green: #70c48e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 40px 100px rgba(0, 0, 0, 0.7), 0 12px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] body {
  background:
    radial-gradient(1100px 700px at 82% -12%, rgba(224, 138, 110, 0.055) 0%, transparent 62%),
    var(--bg);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 760px at 82% -12%, #fdf9f1 0%, rgba(253, 249, 241, 0) 62%),
    var(--bg);
  color: var(--label);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: rgba(156, 74, 49, 0.18); }
[data-theme="dark"] ::selection { background: rgba(224, 138, 110, 0.26); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4, p, dl, dd, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------------
   Shell / sidebar
   -------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  height: 100vh;
  background: var(--sidebar);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border-right: 0.5px solid var(--line);
  padding: 0 13px;
  z-index: 40;
}

#sidebarInner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.brand { padding: 18px 8px 12px; }
.brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 10px;
  padding: 4px;
  margin: -4px;
  transition: background 0.2s;
}
.brand-link:hover { background: var(--fill); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: #fbf7f1;
  background:
    linear-gradient(155deg, #b2603f 0%, #8d3f28 55%, #6f2f1d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 2px 6px rgba(80, 40, 20, 0.22);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--label3);
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.nav { display: flex; flex-direction: column; gap: 1px; padding: 6px 0 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--label2);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.16s, color 0.16s;
}
.nav-item .icon { width: 16px; height: 16px; color: var(--label3); transition: color 0.16s; }
.nav-item:hover { background: var(--fill); color: var(--label); }
.nav-item.active { background: var(--fill); color: var(--label); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }

.side-rule { height: 0.5px; background: var(--line); margin: 10px 8px 12px; }

.tree-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 10px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--label3);
}
.tree-count { font-weight: 500; letter-spacing: 0.02em; }

.tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 18px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.tree:hover { scrollbar-color: var(--line-strong) transparent; }
.tree::-webkit-scrollbar { width: 8px; }
.tree::-webkit-scrollbar-thumb {
  background: transparent;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
}
.tree:hover::-webkit-scrollbar-thumb { background: var(--line-strong); background-clip: padding-box; }

.ch { margin-bottom: 1px; }
.ch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 31px;
  padding: 0 8px 0 10px;
  border-radius: 7px;
  color: var(--label2);
  font-size: 12.5px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.ch-row:hover { background: var(--fill); color: var(--label); }
.ch-row.open { color: var(--label); font-weight: 600; }
.ch-no {
  font-family: var(--serif);
  font-size: 11px;
  color: var(--label3);
  width: 17px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.ch-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-row .chev {
  width: 12px;
  height: 12px;
  color: var(--label3);
  transform: rotate(0deg);
  transition: transform 0.22s var(--ease-out);
}
.ch-row.open .chev { transform: rotate(90deg); }

.ch-secs {
  display: none;
  padding: 2px 0 6px;
}
.ch.open .ch-secs { display: block; }

.sec-link {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 27px;
  padding: 0 8px 0 35px;
  border-radius: 6px;
  color: var(--label2);
  font-size: 11.8px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.sec-link span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sec-link .sec-no {
  font-size: 9.5px;
  color: var(--label3);
  width: 13px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.sec-link:hover { background: var(--fill); color: var(--label); }
.sec-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sec-link.active .sec-no { color: var(--accent); opacity: 0.7; }

.side-foot {
  border-top: 0.5px solid var(--line);
  padding: 12px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  color: var(--label3);
  white-space: nowrap;
}
.side-foot a { transition: color 0.15s; }
.side-foot a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

.main {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  position: relative;
}
.main:hover { scrollbar-color: var(--line-strong) transparent; }
.main::-webkit-scrollbar { width: 11px; }
.main::-webkit-scrollbar-thumb {
  background: transparent;
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
}
.main:hover::-webkit-scrollbar-thumb { background: var(--line-strong); background-clip: padding-box; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--topbar);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.25s;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-left { gap: 6px; }

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--label3);
  white-space: nowrap;
}
.crumb a { transition: color 0.15s; }
.crumb a:hover { color: var(--label); }
.crumb .sep { opacity: 0.55; }
.crumb .now {
  color: var(--label);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--label2);
  transition: background 0.16s, color 0.16s, transform 0.12s;
}
.icon-btn:hover { background: var(--fill); color: var(--label); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 33px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--label3);
  font-size: 12.5px;
  transition: border-color 0.16s, box-shadow 0.16s, color 0.16s;
}
.search-trigger:hover {
  border-color: var(--line-strong);
  color: var(--label2);
  box-shadow: var(--shadow-sm);
}
.search-trigger .icon { width: 14px; height: 14px; }
.search-trigger kbd {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--label3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 6px;
}

.font-ctrl {
  display: flex;
  align-items: center;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 2px;
  margin-right: 2px;
}
.font-ctrl button {
  width: 27px;
  height: 27px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--label2);
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.font-ctrl button:hover { background: var(--fill); }
.font-ctrl button:active { transform: scale(0.94); }
.font-ctrl .fs-val {
  width: 34px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--label3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Shared page bits
   -------------------------------------------------------------------------- */

.view { min-height: calc(100vh - 64px); outline: none; }

.page {
  max-width: clamp(1120px, 92vw, 1720px);
  margin: 0 auto;
  padding: 0 clamp(30px, 2.4vw, 56px) 90px;
  animation: view-in 0.42s var(--ease-out) both;
}
.page-narrow { max-width: clamp(960px, 92vw, 1800px); }

@keyframes view-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-head { padding: 58px 0 30px; }
.page-head h1 {
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 14px 0 14px;
}
.page-sub {
  font-size: 14px;
  line-height: 1.8;
  color: var(--label2);
  max-width: 620px;
}

.filter {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--label3);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.filter:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter .icon { width: 15px; height: 15px; }
.filter input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--label);
}
.filter input::placeholder { color: var(--label3); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--label2);
  font-size: 11.5px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { background: var(--fill); border-color: var(--line-strong); color: var(--label); }
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff9f4;
}
[data-theme="dark"] .chip.on { color: #1a1210; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 550;
  white-space: nowrap;
}
.text-link .icon { width: 13px; height: 13px; transition: transform 0.2s var(--ease-out); }
.text-link:hover .icon { transform: translateX(2px); }

/* --------------------------------------------------------------------------
   Home
   -------------------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 22vw, 400px);
  gap: clamp(72px, 5vw, 104px);
  align-items: center;
  padding: 64px 0 54px;
}

.hero-copy > * { animation: rise 0.7s var(--ease-out) both; }
.hero-copy > *:nth-child(2) { animation-delay: 0.04s; }
.hero-copy > *:nth-child(3) { animation-delay: 0.08s; }
.hero-copy > *:nth-child(4) { animation-delay: 0.12s; }
.hero-copy > *:nth-child(5) { animation-delay: 0.16s; }
.hero-copy > *:nth-child(6) { animation-delay: 0.2s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(50px, 5.2vw, 66px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.025em;
  margin: 16px 0 20px;
}
.hero-title span { display: block; }
.hero-title .thin { color: var(--label2); font-weight: 500; }

.hero-sub {
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--label2);
  max-width: 600px;
  text-wrap: pretty;
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 536px;
  height: 58px;
  margin-top: 30px;
  padding: 0 12px 0 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  color: var(--label3);
  font-size: 14.5px;
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.25s var(--ease-out);
}
.hero-search:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.hero-search .icon { width: 19px; height: 19px; color: var(--label2); }
.hero-search .ph { flex: 1; }
.hero-search kbd {
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--label3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
  background: var(--bg-soft);
}

.hero-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--label3);
}
.hero-chips .lead { margin-right: 2px; }
.hero-chips button {
  padding: 4px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--label2);
  transition: background 0.15s, color 0.15s;
}
.hero-chips button:hover { background: var(--fill); color: var(--accent); }

.stats {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 40px;
}
.stat {
  padding: 0 22px;
  border-left: 1px solid var(--line);
}
.stat:first-child { padding-left: 0; border-left: 0; }
.stat dt {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat dd {
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--label3);
  letter-spacing: 0.04em;
}

/* book object */
.hero-book {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  animation: rise 0.9s 0.1s var(--ease-out) both;
}
.book-glow {
  position: absolute;
  top: 20px;
  left: 50%;
  width: 430px;
  height: 430px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(156, 74, 49, 0.13), rgba(156, 74, 49, 0) 66%);
  filter: blur(6px);
  pointer-events: none;
}
[data-theme="dark"] .book-glow {
  background: radial-gradient(circle at 50% 45%, rgba(224, 138, 110, 0.12), transparent 66%);
}
.book-wrap {
  position: relative;
  width: clamp(278px, 19vw, 330px);
  transform: perspective(1300px) rotateY(-10deg) rotateX(1.5deg);
  transform-style: preserve-3d;
  transition: transform 0.9s var(--ease-out);
}
.book-wrap:hover {
  transform: perspective(1300px) rotateY(-3deg) rotateX(0deg) translateY(-8px);
}
.book {
  position: relative;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  background: #6f2f1d;
  box-shadow:
    0 30px 60px rgba(45, 26, 12, 0.28),
    0 10px 22px rgba(45, 26, 12, 0.20),
    inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}
.book img { display: block; width: 100%; height: auto; filter: saturate(0.97); }
[data-theme="dark"] .book img { filter: brightness(0.84) saturate(0.92); }
.book::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 13px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.05) 58%, transparent);
  z-index: 2;
  pointer-events: none;
}
.book::after {
  content: "";
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 6px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.26) 50%, rgba(0, 0, 0, 0.12));
  z-index: 2;
  pointer-events: none;
}
.book-shadow {
  position: absolute;
  left: 2%;
  right: -1%;
  bottom: -28px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(45, 26, 12, 0.32), transparent 70%);
  filter: blur(9px);
  z-index: -1;
}
[data-theme="dark"] .book-shadow {
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.8), transparent 70%);
}
.book-badge {
  position: absolute;
  top: 22px;
  right: -22px;
  padding: 6px 11px;
  border-radius: 20px;
  background: rgba(255, 254, 250, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 18px rgba(50, 32, 16, 0.14);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #4a2c1d;
  transform: rotate(2deg);
}
.book-caption {
  margin-top: 36px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--label3);
}

/* ways */
.ways {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 0;
}
.way {
  position: relative;
  padding: 20px 22px 19px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  transition: border-color 0.2s, transform 0.25s var(--ease-out), box-shadow 0.25s;
}
.way:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.way .num {
  font-family: var(--serif);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.way h3 { margin: 8px 0 5px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.way p { font-size: 12px; line-height: 1.7; color: var(--label2); }
.way .go {
  position: absolute;
  top: 20px;
  right: 18px;
  color: var(--label3);
  transition: color 0.2s, transform 0.2s var(--ease-out);
}
.way:hover .go { color: var(--accent); transform: translate(2px, -2px); }
.way .go .icon { width: 14px; height: 14px; }

/* block */
.block { margin-top: 66px; }
.block-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.block-head h2 {
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 8px;
}

.chapter-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  overflow: hidden;
}
.chapter-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) minmax(0, 230px) 18px;
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
  transition: background 0.16s;
}
.chapter-row:first-child { border-top: 0; }
.chapter-row:hover { background: var(--fill); }
.cr-no {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 500;
  color: var(--label3);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.chapter-row:hover .cr-no { color: var(--accent); }
.cr-main { min-width: 0; }
.cr-title { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.cr-meta { display: block; margin-top: 3px; font-size: 11.5px; color: var(--label3); }
.cr-tags {
  font-size: 11.5px;
  color: var(--label2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cr-arrow { width: 15px; height: 15px; color: var(--label3); transition: transform 0.2s var(--ease-out), color 0.2s; }
.chapter-row:hover .cr-arrow { color: var(--accent); transform: translateX(2px); }

/* questions */
.question-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.question {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease-out);
}
.question:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.question .q-ico {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--accent);
  flex: none;
}
.question .q-ico .icon { width: 13px; height: 13px; }
.question .q-text { font-size: 13.5px; line-height: 1.55; font-weight: 500; }
.question .q-hint { display: block; margin-top: 2px; font-size: 10.5px; color: var(--label3); font-weight: 400; }

.foot {
  margin-top: 78px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font-size: 11px;
  color: var(--label3);
}
.foot a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   TOC
   -------------------------------------------------------------------------- */

.toc { padding-bottom: 20px; }
.toc-ch { margin-bottom: 26px; }

.toc-ch-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 17px 4px 13px;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s;
}
.toc-ch-head:hover { border-bottom-color: var(--line-strong); }
.toc-no {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  width: 48px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.toc-ch-head div { flex: 1; min-width: 0; }
.toc-ch-head h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.toc-ch-head p { margin-top: 3px; font-size: 11px; color: var(--label3); }
.toc-ch-head > .icon { width: 15px; height: 15px; color: var(--label3); }

.toc-secs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}
.toc-sec {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  transition: background 0.15s;
}
.toc-sec:first-child { border-top: 0; }
.toc-sec:hover { background: var(--fill); }
.toc-sec.hide { display: none; }
.ts-no {
  font-size: 10.5px;
  color: var(--label3);
  font-variant-numeric: tabular-nums;
}
.ts-main { min-width: 0; }
.ts-title { display: block; font-size: 15px; font-weight: 500; letter-spacing: -0.008em; }
.ts-subs {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--label3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-meta {
  font-size: 10.5px;
  color: var(--label3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.toc-empty {
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
  color: var(--label3);
}
.toc-empty a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-line);
  padding-bottom: 1px;
}

/* chapter page */
.chapter-head { padding: 58px 0 34px; border-bottom: 1px solid var(--line); }
.chapter-title-row {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  margin: 10px 0 16px;
}
.chapter-big {
  font-family: var(--serif);
  font-size: 106px;
  line-height: 0.78;
  font-weight: 500;
  color: transparent;
  -webkit-text-stroke: 1px var(--accent-line);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.chapter-title-row h1 {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.02em;
}
.chapter-stats {
  display: flex;
  gap: 36px;
  margin-top: 26px;
}
.chapter-stats div { display: flex; flex-direction: column; gap: 3px; }
.chapter-stats .v {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chapter-stats .l { font-size: 10px; color: var(--label3); letter-spacing: 0.05em; }

.chapter-sections { margin-top: 30px; }
.chapter-concepts { margin-top: 54px; }
.chapter-concepts h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 14px;
}
.concept-cloud { display: flex; flex-wrap: wrap; gap: 7px; }

/* --------------------------------------------------------------------------
   Reader
   -------------------------------------------------------------------------- */

.reader {
  max-width: clamp(1080px, 94vw, 1880px);
  margin: 0 auto;
  padding: 34px clamp(30px, 2.4vw, 56px) 120px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(206px, 12vw, 268px);
  gap: clamp(40px, 2.8vw, 68px);
  align-items: start;
  animation: view-in 0.4s var(--ease-out) both;
}

.paper {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(58px, 3.2vw, 82px) clamp(62px, 4vw, 96px) clamp(56px, 3vw, 78px);
  box-shadow: var(--shadow-md);
}

.art-head { padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.art-head h1 {
  font-family: var(--serif);
  font-size: 37px;
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: -0.022em;
  margin: 14px 0 16px;
  text-wrap: pretty;
}
.art-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  font-size: 11.5px;
  color: var(--label3);
  font-variant-numeric: tabular-nums;
}
.art-meta span { display: inline-flex; align-items: center; }
.art-meta span + span::before {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--label3);
  opacity: 0.6;
  margin: 0 9px;
}
.art-meta .level { color: var(--accent); font-weight: 600; }
.art-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 15px; }
.art-tags .chip { height: 23px; font-size: 11px; }

.art-body { padding-top: 4px; }

.group { margin-top: 44px; }
.group:first-child { margin-top: 34px; }
.group + .group {
  margin-top: 50px;
  padding-top: 42px;
  border-top: 1px solid var(--line);
}
.group-title {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.012em;
  margin-bottom: 6px;
  scroll-margin-top: 88px;
}

.kp { margin-top: 26px; scroll-margin-top: 88px; }
.kp + .kp { margin-top: 34px; }
.kp-title {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--label);
  margin-bottom: 12px;
  scroll-margin-top: 92px;
}
.kp-title .kp-badge {
  display: inline-block;
  vertical-align: 1px;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.kp p {
  font-family: var(--serif);
  font-size: var(--read-font);
  line-height: 1.95;
  color: var(--label);
  text-align: justify;
  text-justify: inter-ideograph;
  margin: 0 0 1.02em;
  word-break: break-word;
}
.kp p:last-child { margin-bottom: 0; }
.math-display {
  display: block;
  margin: 12px 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.math-display .katex { font-size: 1.06em; }
.kp p.para-head {
  font-family: var(--sans);
  font-size: calc(var(--read-font) - 2.5px);
  font-weight: 650;
  line-height: 1.6;
  color: var(--label);
  margin: 1.65em 0 0.55em;
  text-align: left;
}
.kp p.para-head:first-child { margin-top: 0; }
.kp strong { font-weight: 650; }
.kp.flash {
  animation: kp-flash 2s var(--ease-out);
  border-radius: 10px;
}
@keyframes kp-flash {
  0% { background: var(--accent-soft); box-shadow: 0 0 0 14px var(--accent-soft); }
  100% { background: transparent; box-shadow: 0 0 0 14px transparent; }
}
.fig-ref {
  color: var(--accent);
  border-bottom: 1px dotted var(--accent-line);
  cursor: pointer;
  white-space: nowrap;
}
.fig-ref:hover { border-bottom-style: solid; }
.kp p code, .kp li code, .callout code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--fill);
}

/* definition / warn / example callouts */
.callout {
  margin: 18px 0;
  padding: 15px 18px 15px 18px;
  border-radius: 10px;
  border-left: 2px solid var(--def);
  background: var(--def-bg);
}
.callout-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  color: var(--def);
  margin-bottom: 6px;
}
.callout .c-body {
  font-family: var(--serif);
  font-size: calc(var(--read-font) - 0.5px);
  line-height: 1.9;
  text-align: justify;
  text-justify: inter-ideograph;
}
.callout .c-body p { margin: 0 0 0.7em; }
.callout .c-body p:last-child { margin-bottom: 0; }

.callout.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.callout.warn .callout-label { color: var(--warn); }
.callout.example { border-left-color: var(--line-strong); background: var(--fill); }
.callout.example .callout-label { color: var(--label2); }

/* points */
.points { margin: 16px 0 4px; }
.points-lead {
  font-size: 11.5px;
  color: var(--label3);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.points ul { list-style: none; }
.points li {
  position: relative;
  padding-left: 17px;
  font-family: var(--serif);
  font-size: calc(var(--read-font) - 0.5px);
  line-height: 1.88;
  color: var(--label);
  text-align: justify;
  text-justify: inter-ideograph;
}
.points li + li { margin-top: 7px; }
.points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.85em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}
.points li.numbered { padding-left: 0; }
.points li.numbered::before { display: none; }
.points li.formula-li { padding-left: 0; margin: 6px 0 10px; }
.points li.formula-li::before { display: none; }
.points li.formula-li .math-display { margin: 2px 0; }
.points li strong { font-weight: 650; }

.warn-ul { list-style: none; }
.warn-ul li { position: relative; padding-left: 14px; }
.warn-ul li + li { margin-top: 7px; }
.warn-ul li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.82em;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--warn);
  opacity: 0.7;
}

/* formula */
.formula {
  margin: 22px 0;
  padding: 16px 18px 14px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.formula figcaption {
  font-size: 10.5px;
  color: var(--label3);
  letter-spacing: 0.04em;
  line-height: 1.55;
  margin-bottom: 8px;
}
.math-hint {
  margin-top: 3px;
  font-size: 9.5px;
  letter-spacing: 0.02em;
  color: var(--label3);
  text-align: right;
}
.formula .math {
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  padding: 4px 0 6px;
  scrollbar-width: thin;
}
.formula .math .katex { font-size: 1.08em; }
.math-row { display: flex; align-items: center; gap: 10px; }
.math-row + .math-row { margin-top: 7px; }
.math-body { flex: 1; min-width: 0; overflow-x: auto; text-align: center; }
.eq-tag {
  flex: none;
  min-width: 36px;
  text-align: right;
  font-size: 10.5px;
  color: var(--label3);
  font-variant-numeric: tabular-nums;
}
.formula .math::-webkit-scrollbar { height: 6px; }
.formula .math::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.formula .legend {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  list-style: none;
}
.formula .legend li {
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--label2);
}
.formula .legend li + li { margin-top: 2px; }

.math-fallback {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--label2);
  white-space: pre-wrap;
}

/* table */
.table-block { margin: 24px 0; }
.table-block figcaption {
  font-size: 10.5px;
  color: var(--label3);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: auto;
  max-width: 100%;
  background: var(--surface);
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar { height: 7px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; }
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.6;
}
.table-wrap th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  color: var(--label2);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table-wrap td {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  color: var(--label);
}
.table-wrap tr:first-child td { border-top: 0; }
.table-wrap tbody tr:hover td { background: var(--fill); }
.table-wrap td:first-child { font-weight: 600; }
.table-wrap td .katex { font-size: 1em; }

/* figure */
.figure { margin: 26px 0; }
.figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
  max-height: 62vh;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: zoom-in;
  transition: box-shadow 0.25s, transform 0.25s var(--ease-out);
}
.figure img:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.figure figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--label3);
  line-height: 1.6;
}
.figure figcaption b { font-weight: 600; color: var(--label2); margin-right: 6px; white-space: nowrap; }
.figure figcaption .src { white-space: nowrap; }

.fig-missing {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 13px 0;
  padding: 3px 0;
  color: var(--label2);
}
.fig-missing > .icon { width: 14px; height: 14px; color: var(--label3); opacity: 0.6; position: relative; top: 2px; }
.fig-missing .fm-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 7px; }
.fig-missing .fm-title { font-size: 11.5px; font-weight: 600; color: var(--label2); white-space: nowrap; }
.fig-missing .fm-cap { font-size: 11.5px; color: var(--label3); }
.fig-missing .fm-src { font-size: 9.5px; color: var(--label3); white-space: nowrap; }

/* rhyme */
.rhyme {
  position: relative;
  margin: 26px 0;
  padding: 22px 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-family: var(--serif);
  font-size: calc(var(--read-font) + 0.5px);
  line-height: 1.9;
  color: var(--label2);
}
.rhyme::before {
  content: "「";
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.55;
  margin-bottom: 6px;
}

/* recap */
.kp.recap { margin-top: 44px; }
.kp.recap .kp-title { display: none; }
.recap-box {
  padding: 22px 24px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 13px;
}
.recap-box .recap-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 8px;
}
.recap-box p {
  font-size: calc(var(--read-font) - 1px);
  line-height: 1.92;
}

/* prev / next */
.art-foot { margin-top: 58px; padding-top: 26px; border-top: 1px solid var(--line); }
.pn-label {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.13em;
  color: var(--label3);
  margin-bottom: 10px;
}
.pn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pn {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  transition: border-color 0.2s, background 0.2s;
}
.pn:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.pn .pn-k { display: block; font-size: 10px; color: var(--label3); }
.pn .pn-t { display: block; margin-top: 3px; font-size: 13px; font-weight: 600; line-height: 1.5; }
.pn.next { text-align: right; }
.pn.next .pn-t { color: var(--label); }
.pn.empty { opacity: 0; pointer-events: none; }

/* rail */
.rail {
  position: sticky;
  top: 92px;
  font-size: 12px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-block + .rail-block { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.rail-title {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label3);
  margin-bottom: 10px;
}
.rail-nav { display: flex; flex-direction: column; }
.rail-nav .rn-group {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--label2);
  padding: 9px 0 4px 11px;
  line-height: 1.5;
}
.rail-nav a {
  display: block;
  padding: 4.5px 0 4.5px 11px;
  border-left: 2px solid transparent;
  color: var(--label3);
  font-size: 11.5px;
  line-height: 1.55;
  transition: color 0.15s, border-color 0.15s;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.rail-nav a:hover { color: var(--label); }
.rail-nav a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.rail-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.rail-chips button {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 10.5px;
  color: var(--label2);
  transition: border-color 0.15s, color 0.15s;
}
.rail-chips button:hover { border-color: var(--accent-line); color: var(--accent); }
.rail-meta { font-size: 10.5px; line-height: 1.9; color: var(--label3); }
.rail-meta b { display: block; font-weight: 600; color: var(--label2); font-size: 11px; margin-bottom: 2px; }

/* --------------------------------------------------------------------------
   Search page
   -------------------------------------------------------------------------- */

.page-search { max-width: clamp(900px, 80vw, 1240px); }
.search-head { padding-top: 56px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  margin-top: 22px;
  padding: 0 14px 0 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}
.search-box .icon { width: 18px; height: 18px; color: var(--label2); }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--label);
}
.search-box input::placeholder { color: var(--label3); }
.search-box .clear {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill-strong);
  color: var(--label2);
}
.search-box .clear .icon { width: 12px; height: 12px; }
.search-box .clear:hover { background: var(--line-strong); }

.search-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 30px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.search-summary p { font-size: 12.5px; color: var(--label3); }
.search-summary b { color: var(--label); font-weight: 650; font-variant-numeric: tabular-nums; }
.search-summary .q { color: var(--label2); }
.chapter-filters { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.chapter-filters .chip { height: 24px; font-size: 10.5px; }

.concept-hits {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0 4px;
  font-size: 11px;
  color: var(--label3);
}
.concept-hits .lead { margin-right: 2px; letter-spacing: 0.04em; }
.concept-hits button {
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--fill);
  font-size: 11px;
  color: var(--label2);
  transition: background 0.15s, color 0.15s;
}
.concept-hits button:hover { background: var(--accent-soft); color: var(--accent); }

.answer-card {
  margin-top: 22px;
  padding: 20px 24px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.9), rgba(252, 249, 242, 0.55));
  box-shadow: 0 1px 2px rgba(70, 50, 30, 0.03), 0 8px 24px -18px rgba(70, 50, 30, 0.25);
}
[data-theme="dark"] .answer-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  box-shadow: none;
}
.answer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}
.answer-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.answer-kicker .icon { width: 12px; height: 12px; }
.answer-src {
  font-size: 10.5px;
  color: var(--label3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.answer-body {
  font-size: 14px;
  line-height: 1.95;
  color: var(--label);
  letter-spacing: 0.005em;
}
.answer-body p { margin: 0 0 8px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body .katex { font-size: 0.95em; }
.answer-body .def-box, .answer-body .callout { margin: 8px 0; }
.answer-factors {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: grid;
  gap: 13px;
}
.answer-factors li {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
}
.answer-factors li + li { padding-top: 11px; border-top: 1px solid var(--line); }
.af-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--label);
  line-height: 1.65;
}
.af-text {
  font-size: 13.5px;
  color: var(--label);
  line-height: 1.8;
}
@media (max-width: 1180px) {
  .answer-factors li { grid-template-columns: 1fr; gap: 2px; }
}
.answer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--accent);
}
.answer-link .icon { width: 12px; height: 12px; }
.answer-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.results { padding-top: 6px; }
.result {
  position: relative;
  display: block;
  padding: 22px 36px 22px 0;
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.22s var(--ease-out);
}
.result:hover { padding-left: 8px; }
.result-crumb {
  font-size: 10.5px;
  color: var(--label3);
  letter-spacing: 0.02em;
  margin-bottom: 5px;
}
.result h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
  transition: color 0.16s;
}
.result:hover h3 { color: var(--accent); }
.result-card {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 550;
}
.result-snippet {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--label2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
mark {
  background: rgba(156, 74, 49, 0.14);
  color: inherit;
  border-radius: 2.5px;
  padding: 0 1.5px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
[data-theme="dark"] mark { background: rgba(224, 138, 110, 0.2); }
.result h3 mark { padding: 0 2px; }
.result-arrow {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--label3);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s var(--ease-out);
}
.result:hover .result-arrow { opacity: 1; transform: translateY(-50%) translateX(2px); color: var(--accent); }
.result-arrow .icon { width: 15px; height: 15px; }

.more-btn {
  display: block;
  margin: 26px auto 0;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  color: var(--label2);
  transition: border-color 0.15s, background 0.15s;
}
.more-btn:hover { border-color: var(--line-strong); background: var(--fill); }

.empty {
  padding: 72px 0;
  text-align: center;
}
.empty .e-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--label3);
}
.empty .e-icon .icon { width: 24px; height: 24px; }
.empty h3 { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.empty p { margin-top: 7px; font-size: 12.5px; color: var(--label3); line-height: 1.8; }
.empty .sugs { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 18px; }

/* --------------------------------------------------------------------------
   Search overlay
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 11vh 40px 40px;
}
.overlay[hidden] { display: none; }
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 16, 0.30);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  animation: fade 0.24s ease both;
}
[data-theme="dark"] .overlay-backdrop { background: rgba(0, 0, 0, 0.58); }

.spotlight {
  position: relative;
  width: min(716px, calc(100vw - 80px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 19px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: spot-in 0.34s var(--ease-out) both;
}
@keyframes spot-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.spotlight-input {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 66px;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--line);
}
.spotlight-input .icon { width: 19px; height: 19px; color: var(--label2); }
.spotlight-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--label);
}
.spotlight-input input::placeholder { color: var(--label3); }
.keycap {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--label3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
  background: var(--bg-soft);
}
.keycap:hover { color: var(--label2); border-color: var(--line-strong); }

.spotlight-body {
  max-height: min(54vh, 440px);
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}
.spotlight-body::-webkit-scrollbar { width: 8px; }
.spotlight-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.spot-hint {
  padding: 16px 14px 8px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--label3);
}
.spot-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.spot-chips button {
  padding: 6px 11px;
  border-radius: 20px;
  background: var(--fill);
  font-size: 12px;
  color: var(--label2);
  transition: background 0.15s, color 0.15s;
}
.spot-chips button:hover { background: var(--accent-soft); color: var(--accent); }

.spot-item {
  display: block;
  padding: 11px 13px;
  border-radius: 11px;
  transition: background 0.12s;
}
.spot-item.on { background: var(--fill); }
.spot-crumb { font-size: 10px; color: var(--label3); margin-bottom: 2px; }
.spot-title { font-size: 14px; font-weight: 600; line-height: 1.5; }
.spot-snippet {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--label2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spot-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 6px 2px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 550;
}
.spot-all:hover { background: var(--accent-soft); }
.spot-all .icon { width: 13px; height: 13px; }
.spot-empty { padding: 34px 16px 40px; text-align: center; font-size: 12.5px; color: var(--label3); line-height: 1.8; }

.spotlight-foot {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 42px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--label3);
  background: var(--bg-soft);
}
.spotlight-foot kbd {
  font-family: var(--sans);
  font-size: 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  margin-right: 2px;
}
.spotlight-foot a { margin-left: auto; color: var(--accent); font-size: 11px; }

/* --------------------------------------------------------------------------
   Terms
   -------------------------------------------------------------------------- */

.terms-page {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - 64px);
  min-height: 0;
  animation: view-in 0.4s var(--ease-out) both;
}
.terms-list {
  border-right: 0.5px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 30px 16px 0 30px;
  background: var(--bg-soft);
}
.terms-head { padding-right: 14px; }
.terms-head h1 {
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 9px 0 4px;
}
.terms-head p { font-size: 11.5px; color: var(--label3); }
.terms-list .filter { margin-top: 16px; height: 38px; }
.term-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 6px; }
.term-filter .chip { height: 22px; font-size: 10px; padding: 0 8px; }
.term-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 30px 0;
  scrollbar-width: thin;
}
.term-items::-webkit-scrollbar { width: 8px; }
.term-items::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.term-group {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--label3);
  padding: 16px 8px 5px;
}
.term-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 8px;
  transition: background 0.13s;
}
.term-item:hover { background: var(--fill); }
.term-item.on { background: var(--accent-soft); }
.term-item .ti-name { display: block; font-size: 13px; font-weight: 550; line-height: 1.45; }
.term-item .ti-type { display: block; font-size: 9.5px; color: var(--label3); margin-top: 1px; }
.term-item.on .ti-name { color: var(--accent); font-weight: 650; }
.term-item.on .ti-type { color: var(--accent); opacity: 0.7; }

.term-detail {
  overflow-y: auto;
  padding: 58px 64px 80px;
  min-width: 0;
  scrollbar-width: thin;
}
.term-detail::-webkit-scrollbar { width: 10px; }
.term-detail::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; }
.term-inner { max-width: 860px; margin: 0 auto; }
.term-inner h1 {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 12px 0 10px;
}
.term-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 2px 7px;
  margin-bottom: 4px;
}
.term-def {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.95;
  color: var(--label);
  margin-top: 20px;
  text-align: justify;
  text-justify: inter-ideograph;
}
.term-sec { margin-top: 38px; }
.term-sec h3 {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label3);
  margin-bottom: 12px;
}
.term-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 2px;
  border-top: 1px solid var(--line);
  transition: padding-left 0.2s var(--ease-out);
}
.term-link-row:first-of-type { border-top: 0; }
.term-link-row:hover { padding-left: 6px; }
.term-link-row .tl-main { min-width: 0; }
.term-link-row .tl-k { display: block; font-size: 10px; color: var(--label3); }
.term-link-row .tl-t { display: block; font-size: 13.5px; font-weight: 550; margin-top: 1px; }
.term-link-row .icon { width: 14px; height: 14px; color: var(--label3); }
.term-link-row:hover .tl-t { color: var(--accent); }
.term-forms { display: flex; flex-wrap: wrap; gap: 6px; }
.term-forms span {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--label2);
}
.term-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 30px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--label);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
}
.term-cta:hover { opacity: 0.88; transform: translateY(-1px); }
.term-cta .icon { width: 14px; height: 14px; }
.term-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--label3);
  gap: 10px;
  padding-bottom: 60px;
}
.term-empty .icon { width: 30px; height: 30px; opacity: 0.6; }
.term-empty p { font-size: 13px; }

/* --------------------------------------------------------------------------
   Concept sheet
   -------------------------------------------------------------------------- */

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.sheet-layer[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 16, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fade 0.22s ease both;
}
[data-theme="dark"] .sheet-backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet {
  position: relative;
  width: min(620px, calc(100vw - 80px));
  max-height: min(78vh, 760px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 40px 38px;
  animation: sheet-in 0.38s var(--ease-spring) both;
  scrollbar-width: thin;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.sheet .sh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sheet .sh-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--label2);
  flex: none;
}
.sheet .sh-close:hover { background: var(--fill-strong); }
.sheet .sh-close .icon { width: 13px; height: 13px; }
.sheet h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 10px 0 8px;
}
.sheet .sh-def {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.92;
  color: var(--label);
  margin-top: 16px;
  text-align: justify;
  text-justify: inter-ideograph;
}
.sheet .term-sec { margin-top: 26px; }
.sheet .term-sec h3 { margin-bottom: 9px; }
.sheet .sh-links { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet .sh-links a {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--label2);
}
.sheet .sh-links a:hover { border-color: var(--accent-line); color: var(--accent); }
.sheet .sh-sections a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--label2);
}
.sheet .sh-sections a:hover { color: var(--accent); }
.sheet .sh-sections .icon { width: 13px; height: 13px; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox[hidden] { display: none; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade 0.2s ease both;
}
.lightbox-figure {
  position: relative;
  margin: 0;
  max-width: 90vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: sheet-in 0.32s var(--ease-out) both;
}
.lightbox-figure img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.lightbox-figure figcaption { font-size: 12px; color: rgba(255, 255, 255, 0.72); }
.lightbox-close {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 40px;
}
.about-card {
  padding: 26px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.about-card h3 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 10px;
}
.about-card p, .about-card li {
  font-size: 13px;
  line-height: 1.9;
  color: var(--label2);
}
.about-card ul { list-style: none; }
.about-card li { position: relative; padding-left: 14px; }
.about-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}
.about-card strong { color: var(--label); font-weight: 600; }

/* --------------------------------------------------------------------------
   Desktop gate
   -------------------------------------------------------------------------- */

.gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: var(--bg);
}
.gate-card { max-width: 340px; text-align: center; }
.gate-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 28px;
  color: #fbf7f1;
  background: linear-gradient(155deg, #b2603f, #7a3320);
}
.gate-card h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.gate-card p { margin-top: 8px; font-size: 13px; line-height: 1.8; color: var(--label3); }

/* --------------------------------------------------------------------------
   Responsive (desktop only)
   -------------------------------------------------------------------------- */

@media (max-width: 1379px) {
  .reader {
    grid-template-columns: minmax(0, 1fr);
    max-width: 1040px;
    padding-right: clamp(28px, 3vw, 40px);
    padding-left: clamp(28px, 3vw, 40px);
  }
  .rail { display: none; }
}

@media (max-width: 1220px) {
  .shell { grid-template-columns: 256px minmax(0, 1fr); }
  .sidebar { padding: 0 10px; }
  .hero { gap: 44px; grid-template-columns: minmax(0, 1fr) 300px; }
  .book-wrap { width: 248px; }
  .cr-tags { display: none; }
  .chapter-row { grid-template-columns: 56px minmax(0, 1fr) 18px; }
  .paper { padding: 48px clamp(38px, 4vw, 56px) 50px; }
  .page { padding: 0 30px 80px; }
}

@media (max-width: 1099px) {
  .gate { display: flex; }
  .shell { display: none; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .rail, .art-foot, .lightbox, .sheet-layer, .overlay { display: none !important; }
  .shell { display: block; height: auto; }
  .main { height: auto; overflow: visible; }
  .reader { display: block; max-width: none; padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .kp p, .points li { font-size: 11pt; line-height: 1.8; }
  .group { break-inside: avoid-page; }
  .hero-copy > *, .hero-book { animation: none !important; opacity: 1 !important; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
