/* 易中之言 · 样式表
   结构：字体 → 设计变量（亮 / 夜读）→ 基础 → 版式组件 → 各区块 → 词条详情 → 响应式与特殊媒体 */

/* ---------- 字体：思源宋体子集，构建时替换为带哈希的文件名 ---------- */
@font-face { font-family: 'Yi Serif'; src: url('serif-400.dcbbaf171e.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Yi Serif'; src: url('serif-600.38bb4d54af.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Yi Display'; src: url('serif-900.8d2ef1604f.woff2') format('woff2'); font-weight: 900; font-display: swap; }

/* ---------- 设计变量 ---------- */
/* 颜色用 light-dark() 一处定义两种模式。无 JS 时跟随系统；
   有 JS 时 head 内联脚本在首帧前写入 data-theme，手动切换同样写在这里。 */
:root { color-scheme: light dark; }
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }
:root {
  --serif: 'Yi Serif', 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', STSong, SimSun, serif;
  --display: 'Yi Display', var(--serif);
  --sans: system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --paper:     light-dark(#f5f1e8, #101513);
  --surface:   light-dark(#fffdf9, #171d1a);
  --surface-2: light-dark(#efe9dc, #1e2622);
  --ink:       light-dark(#1b2925, #ebe6da);
  --ink-2:     light-dark(#3f504a, #c6c0b2);
  --muted:     light-dark(#5b6963, #9ba69f);
  --line:      light-dark(#d9d0bd, #34403a);
  --line-2:    light-dark(#e8e2d4, #252e29);
  --jade:      light-dark(#2b5d4b, #86bfa5);
  --jade-ink:  light-dark(#245241, #93c9b0);
  --jade-deep: light-dark(#14302a, #d4e9dd);
  --on-jade:   light-dark(#f4f1e8, #0f1a16);
  --cinnabar:  light-dark(#a3351f, #f0937c);
  --cinnabar-soft: light-dark(#f7e4dc, #3b211b);
  --seal:      light-dark(#a3351f, #b8452c);
  --gold:      light-dark(#b08a4f, #c9a46a);
  --gold-ink:  light-dark(#77571f, #d8b980);
  --mark:      light-dark(#f3dfa8, #5b4a1f);

  /* 文字关系三色：标签底色 / 标签文字 / 小圆点 */
  --yuan-ink: light-dark(#275f49, #9fd3b9); --yuan-bg: light-dark(#e2eee6, #1b3328); --yuan-dot: light-dark(#2f7d5b, #4fa07c);
  --yan-ink:  light-dark(#855310, #e6bd76); --yan-bg:  light-dark(#f5e8cf, #382a13); --yan-dot:  light-dark(#c3821f, #c08a32);
  --yi-ink:   light-dark(#4a5a80, #b4bee2); --yi-bg:   light-dark(#e5e8f1, #252b40); --yi-dot:   light-dark(#6574a2, #7f8cc0);

  /* 卦象地图：单色相顺序色阶，0 档为空卦 */
  --heat-0: light-dark(#ece6d9, #1c2420); --heat-0-ink: light-dark(#5b6963, #9ba69f);
  --heat-1: light-dark(#d3e5da, #1d3a2e);
  --heat-2: light-dark(#a3c9b4, #2b5946);
  --heat-3: light-dark(#3d765c, #549276);
  --heat-4: light-dark(#275a47, #8fc8ad);
  --heat-1-ink: light-dark(#1b2925, #ebe6da);
  --heat-2-ink: light-dark(#1b2925, #ebe6da);
  --heat-3-ink: light-dark(#f4f1e8, #0f1a16);
  --heat-4-ink: light-dark(#f4f1e8, #0f1a16);

  --hero-1: light-dark(#14302a, #0b1210); --hero-2: light-dark(#1f4337, #142621);
  --hero-ink: light-dark(#eef0e6, #ebe6da); --hero-muted: light-dark(#c8cfc3, #b9c1b6); --hero-gold: light-dark(#d9bf8a, #d8bd86);

  --shadow-tint: light-dark(rgb(27 41 37 / .06), rgb(0 0 0 / .35));
  --shadow-1: 0 1px 2px var(--shadow-tint), 0 2px 8px var(--shadow-tint);
  --shadow-2: 0 2px 6px var(--shadow-tint), 0 14px 32px var(--shadow-tint);
  --shadow-3: 0 24px 64px light-dark(rgb(15 25 22 / .22), rgb(0 0 0 / .55));

  --r-s: 6px; --r-m: 10px; --r-l: 16px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --wrap: 1200px;
  --gutter: clamp(18px, 4vw, 48px);
  --topbar: 56px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar) + 16px); }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font: 16px/1.75 var(--sans); font-kerning: normal; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, blockquote, figure, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--jade-ink); text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { color: var(--cinnabar); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--mark); color: var(--ink); }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--r-s); background: var(--jade-deep); color: var(--on-jade); }
.skip-link:focus { top: 12px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }
.label { display: block; margin-bottom: var(--s-1); font-size: 12px; line-height: 1.5; letter-spacing: .16em; color: var(--gold-ink); }
.icon-btn svg, .btn svg, .detail-links svg, .chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.detail-links svg { display: inline-block; width: 13px; height: 13px; vertical-align: -1px; }

/* 原文高亮：朱字加着重号，这是全站的核心视觉语言 */
.hit {
  font-weight: inherit; color: var(--cinnabar);
  text-emphasis: filled dot var(--cinnabar); -webkit-text-emphasis: filled dot var(--cinnabar);
  text-emphasis-position: under right; -webkit-text-emphasis-position: under right;
}

/* ---------- 按钮与表单 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4);
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--jade); color: var(--jade-ink); }
.btn-primary { background: var(--jade); border-color: var(--jade); color: var(--on-jade); }
.btn-primary:hover { background: var(--jade-deep); border-color: var(--jade-deep); color: var(--on-jade); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; flex: none;
  border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink-2);
  transition: background-color .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.field {
  width: 100%; min-width: 0; height: 42px; padding: 0 var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: var(--ink);
  font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.field:hover { border-color: color-mix(in srgb, var(--jade) 45%, var(--line)); }
.field:focus { outline: 0; border-color: var(--jade); box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade) 20%, transparent); }
select.field {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search .field { padding-left: 38px; }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none;
  min-width: 22px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2);
  font: 12px/20px var(--mono); color: var(--muted); text-align: center;
}
.search .field:focus ~ kbd, .search .field:not(:placeholder-shown) ~ kbd { display: none; }
input[type='search']::-webkit-search-cancel-button { cursor: pointer; }

/* 分段选择（文字关系） */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 7px;
  font-size: 14px; color: var(--ink-2); white-space: nowrap; transition: background-color .15s, color .15s;
}
.seg label:hover span { background: var(--surface-2); color: var(--ink); }
.seg input:checked + span { background: var(--jade); color: var(--on-jade); }
.seg input:focus-visible + span { outline: 2px solid var(--jade); outline-offset: 2px; }
.seg .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.seg input:checked + span .dot { box-shadow: 0 0 0 1.5px var(--on-jade); }

/* 状态标签：颜色之外始终带文字 */
.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; flex: none;
  border-radius: 999px; font-size: 12px; line-height: 1; letter-spacing: .04em; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill[data-status='原文'] { background: var(--yuan-bg); color: var(--yuan-ink); }
.pill[data-status='演化'] { background: var(--yan-bg); color: var(--yan-ink); }
.pill[data-status='待考'] { background: var(--yi-bg); color: var(--yi-ink); }
.pill-quiet { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.dot[data-status='原文'] { background: var(--yuan-dot); }
.dot[data-status='演化'] { background: var(--yan-dot); }
.dot[data-status='待考'] { background: var(--yi-dot); }

/* 卦画 */
.hexagram { fill: currentColor; flex: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  background: color-mix(in srgb, var(--paper) 86%, transparent); border-bottom: 1px solid transparent;
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  transition: border-color .2s, background-color .2s;
}
.topbar.is-stuck { border-bottom-color: var(--line-2); }
.topbar .wrap { display: flex; align-items: center; gap: var(--s-4); height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.seal {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 5px;
  background: var(--cinnabar); color: var(--paper); font: 900 18px/1 var(--display);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .22);
}
.brand-name { font: 600 17px/1 var(--serif); letter-spacing: .16em; }
.topnav { display: flex; gap: 2px; margin-left: auto; }
.topnav a {
  padding: 6px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14px; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current='true'] { color: var(--jade-ink); background: color-mix(in srgb, var(--jade) 10%, transparent); }
.theme-btn .moon { display: none; }
:root[data-theme='dark'] .theme-btn .sun { display: none; }
:root[data-theme='dark'] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) .theme-btn .sun { display: none; }
  :root:where(:not([data-theme='light'])) .theme-btn .moon { display: block; }
}

/* ---------- 首屏 ---------- */
.hero { position: relative; overflow: hidden; color: var(--hero-ink); background: linear-gradient(160deg, var(--hero-1) 0%, var(--hero-2) 100%); }
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(ellipse 60% 70% at 85% 30%, rgb(217 191 138 / .14), transparent 70%),
              radial-gradient(ellipse 40% 50% at 10% 100%, rgb(163 53 31 / .18), transparent 70%);
}
.hero-art { position: absolute; right: max(var(--gutter), calc((100vw - var(--wrap)) / 2 + var(--gutter))); top: 50%; transform: translateY(-50%); color: rgb(255 255 255 / .05); pointer-events: none; }
.hero-art .hexagram { width: clamp(180px, 26vw, 340px); height: auto; }
.hero .wrap { position: relative; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: var(--s-7); align-items: center; padding-block: clamp(48px, 9vw, 104px); }
.kicker { display: inline-flex; align-items: center; gap: 10px; margin-bottom: var(--s-4); font-size: 13px; letter-spacing: .32em; color: var(--hero-gold); }
.kicker::before { content: ''; width: 28px; height: 1px; background: currentColor; opacity: .6; }
.hero h1 { font: 900 clamp(44px, 7.4vw, 88px)/1.05 var(--display); letter-spacing: .12em; margin-right: -.12em; }
.hero-lede { max-width: 34em; margin-top: var(--s-5); font: 400 clamp(16px, 1.6vw, 19px)/1.9 var(--serif); color: var(--hero-muted); }
.hero-lede strong { color: var(--hero-ink); font-weight: 600; }
.hero-search { display: flex; gap: var(--s-2); max-width: 520px; margin-top: var(--s-6); }
.hero-search .search { flex: 1; }
.hero-search .field { height: 48px; border-color: rgb(255 255 255 / .16); background: rgb(255 255 255 / .08); color: var(--hero-ink); font-size: 16px; }
.hero-search .field::placeholder { color: var(--hero-muted); opacity: .85; }
.hero-search .field:focus { border-color: var(--hero-gold); box-shadow: 0 0 0 3px rgb(217 191 138 / .22); background: rgb(255 255 255 / .12); }
.hero-search .search svg { stroke: var(--hero-muted); }
.hero-search .search kbd { border-color: rgb(255 255 255 / .2); background: rgb(255 255 255 / .06); color: var(--hero-muted); }
.hero-search .btn { height: 48px; border-color: var(--hero-gold); background: var(--hero-gold); color: #1b2925; font-size: 15px; }
.hero-search .btn:hover { background: #e8d3a6; border-color: #e8d3a6; color: #1b2925; }
.stats { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); margin-top: var(--s-6); }
.stat { display: grid; gap: 2px; }
.stat b { font: 600 28px/1.1 var(--sans); letter-spacing: -.01em; color: var(--hero-ink); }
.stat span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--hero-muted); }
.stat .dot { width: 7px; height: 7px; border-radius: 50%; }
.hero .stat .dot[data-status='原文'] { background: #6fbf98; }
.hero .stat .dot[data-status='演化'] { background: #e0aa55; }
.hero .stat .dot[data-status='待考'] { background: #9da9d6; }

/* 今日一词 */
.daily {
  position: relative; padding: var(--s-5); border-radius: var(--r-l); color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow-3);
}
.daily::after { content: ''; position: absolute; inset: 6px; border: 1px solid var(--line-2); border-radius: 11px; pointer-events: none; }
.daily-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-3); }
.daily-top .label { margin: 0; }
.daily-word { display: block; font: 600 34px/1.25 var(--serif); letter-spacing: .1em; color: var(--ink); text-decoration: none; }
.daily-word:hover { color: var(--cinnabar); }
.daily-py { margin-top: 2px; font-size: 14px; color: var(--muted); letter-spacing: .02em; }
.daily-quote { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px dashed var(--line); font: 400 17px/2 var(--serif); color: var(--ink-2); }
.daily-src { margin-top: var(--s-2); font-size: 13px; color: var(--muted); }
.daily-actions { position: relative; z-index: 1; display: flex; gap: var(--s-2); margin-top: var(--s-4); }

/* ---------- 区块通用 ---------- */
.section { padding-block: clamp(56px, 8vw, 104px); }
.section + .section { border-top: 1px solid var(--line-2); }
.section-alt { background: var(--surface); }
.section-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-2) var(--s-5); align-items: baseline; max-width: 820px; margin-bottom: var(--s-7); }
.section-no { grid-row: span 2; font: 600 15px/1 var(--serif); color: var(--cinnabar); letter-spacing: .2em; writing-mode: vertical-rl; padding-top: 6px; }
.section-head h2 { font: 600 clamp(26px, 3.2vw, 36px)/1.3 var(--serif); letter-spacing: .06em; }
.section-head p { color: var(--ink-2); font-size: 16px; max-width: 40em; }

/* ---------- 壹 · 三种路径 ---------- */
.paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.path {
  position: relative; display: flex; flex-direction: column; padding: var(--s-5); border: 1px solid var(--line-2); border-radius: var(--r-l);
  background: var(--surface); box-shadow: var(--shadow-1); transition: border-color .18s, box-shadow .18s, transform .18s var(--ease);
}
/* 整张卡片可点：成语链接撑满卡片，和词库卡片 .card-link 同一做法 */
.path:hover { border-color: color-mix(in srgb, var(--cinnabar) 45%, var(--line)); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.path:has(.path-word:focus-visible) { outline: 2px solid var(--jade); outline-offset: 2px; }
.path-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.path-head h3 { font: 600 20px/1.3 var(--serif); letter-spacing: .08em; }
.path-word {
  align-self: flex-start; margin-top: var(--s-5); font: 600 30px/1.3 var(--serif); letter-spacing: .1em; color: var(--ink);
  text-decoration: underline 2px transparent; text-underline-offset: 8px; transition: color .18s, text-decoration-color .18s;
}
.path-word::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.path-word:focus-visible { outline: 0; }
.path:hover .path-word { color: var(--cinnabar); text-decoration-color: currentColor; }
.path-more { margin-top: var(--s-3); font-size: 14px; color: var(--cinnabar); }
.path-more::after { content: ' →'; display: inline-block; transition: transform .18s var(--ease); }
.path:hover .path-more::after { transform: translateX(4px); }
.path .quote { margin-top: var(--s-3); }
.path-explain { margin-top: auto; padding-top: var(--s-4); font-size: 15px; color: var(--ink-2); }
.path-explain strong { color: var(--ink); font-weight: 600; }
.path-arrow { display: flex; align-items: center; gap: 8px; margin: var(--s-4) 0 0; font-size: 13px; color: var(--muted); }
.path-arrow::before { content: ''; height: 1px; flex: 1; background: var(--line); }
.paths-note { margin-top: var(--s-5); font-size: 15px; color: var(--ink-2); }

.quote { font: 400 18px/2 var(--serif); color: var(--ink); }
blockquote.quote { padding: var(--s-3) var(--s-4); border-left: 3px solid var(--gold); background: color-mix(in srgb, var(--gold) 8%, transparent); border-radius: 0 var(--r-s) var(--r-s) 0; }

/* ---------- 贰 · 卦象地图 ---------- */
.gua-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s-6); align-items: start; }
.gua-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.gua-cell {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 6px;
  aspect-ratio: 1 / 1.08; min-height: 64px; padding: 6px 2px; border: 0; border-radius: 8px;
  background: var(--heat-0); color: var(--heat-0-ink); font-size: 13px; line-height: 1.2;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.gua-cell .hexagram { width: clamp(16px, 2.2vw, 24px); height: auto; opacity: .9; }
.gua-name { font: 600 14px/1.2 var(--serif); white-space: nowrap; }
/* 卦序号叠在色块上：不用 opacity（会降对比度），直接继承格子墨色 */
.gua-n { position: absolute; left: 6px; top: 4px; font-size: 10px; color: inherit; }
.gua-count { position: absolute; right: 6px; top: 4px; font-size: 11px; font-weight: 600; color: inherit; }
.gua-cell[data-bin='0'] .gua-count { display: none; }
.gua-cell[data-bin='1'] { background: var(--heat-1); color: var(--heat-1-ink); }
.gua-cell[data-bin='2'] { background: var(--heat-2); color: var(--heat-2-ink); }
.gua-cell[data-bin='3'] { background: var(--heat-3); color: var(--heat-3-ink); }
.gua-cell[data-bin='4'] { background: var(--heat-4); color: var(--heat-4-ink); }
.gua-cell:not([data-bin='0']) { cursor: pointer; }
.gua-cell:not([data-bin='0']):hover, .gua-cell:not([data-bin='0']):focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-2); z-index: 1; }
.gua-cell[data-bin='0'] { cursor: default; }
.gua-side { display: grid; gap: var(--s-5); }
.legend { display: grid; gap: var(--s-2); }
.legend-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.legend-scale span { height: 10px; border-radius: 2px; }
.legend-scale span:nth-child(1) { background: var(--heat-0); }
.legend-scale span:nth-child(2) { background: var(--heat-1); }
.legend-scale span:nth-child(3) { background: var(--heat-2); }
.legend-scale span:nth-child(4) { background: var(--heat-3); }
.legend-scale span:nth-child(5) { background: var(--heat-4); }
.legend-ticks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gua-top { display: grid; gap: 2px; }
.gua-top li { display: flex; align-items: center; gap: var(--s-3); padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.gua-top .hexagram { width: 16px; height: auto; color: var(--jade); }
.gua-top b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.gua-top button { all: unset; cursor: pointer; color: var(--ink); }
.gua-top button:hover { color: var(--cinnabar); }
.gua-top button:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; border-radius: 3px; }
.other-src { display: flex; flex-wrap: wrap; gap: 6px; }
.tooltip {
  position: fixed; z-index: 60; max-width: 240px; padding: 10px 12px; border-radius: var(--r-m);
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-2); pointer-events: none;
  font-size: 13px; line-height: 1.6; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tooltip.is-on { opacity: 1; transform: none; }
.tooltip strong { display: block; font: 600 15px/1.4 var(--serif); }
.tooltip-words { margin-top: 4px; color: color-mix(in srgb, var(--paper) 78%, transparent); }

/* ---------- 叁 · 词族 ---------- */
.families { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.family { padding: var(--s-5); border: 1px solid var(--line-2); border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow-1); }
.family-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.family-head .label { margin: 0; }
.family-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.family .quote { font-size: 19px; }
.family .chips { margin-top: var(--s-4); }
.families-more { margin-top: var(--s-5); }
.families-more > summary { display: inline-flex; list-style: none; }
.families-more > summary::-webkit-details-marker { display: none; }
.families-more[open] > summary .more-open { display: none; }
.families-more:not([open]) > summary .more-close { display: none; }
.families-more .families { margin-top: var(--s-4); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  font: 400 15px/1 var(--serif); text-decoration: none; letter-spacing: .04em;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--jade); background: var(--jade); color: var(--on-jade); }
.chip-no { font: 11px/1 var(--mono); color: var(--muted); letter-spacing: 0; }
.chip:hover .chip-no { color: inherit; opacity: .8; }
button.chip { cursor: pointer; }
.chip[aria-pressed='true'] { border-color: var(--jade); background: var(--jade); color: var(--on-jade); }

/* ---------- 肆 · 词库 ---------- */
.filters {
  position: sticky; top: var(--topbar); z-index: 20; display: grid; gap: var(--s-2);
  grid-template-columns: minmax(200px, 1.6fr) auto minmax(120px, .7fr) minmax(120px, .7fr) auto;
  align-items: center; margin-inline: calc(var(--s-3) * -1); padding: var(--s-3);
  background: color-mix(in srgb, var(--paper) 92%, transparent); border-radius: var(--r-l);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.filters.is-stuck { box-shadow: 0 1px 0 var(--line-2), 0 12px 24px -18px rgb(0 0 0 / .25); border-radius: 0 0 var(--r-l) var(--r-l); }
.filters .btn { height: 42px; }
.result-line { display: flex; align-items: center; gap: var(--s-3); margin: var(--s-4) 0 var(--s-2); font-size: 14px; color: var(--muted); min-height: 32px; }
.result-line strong { color: var(--ink); font-weight: 600; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.active-filters button {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.active-filters button::after { content: '×'; font-size: 15px; line-height: 1; color: var(--muted); }
.active-filters button:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
.group { content-visibility: auto; contain-intrinsic-size: auto 1200px; }
.group + .group { margin-top: var(--s-7); }
.group-head { display: flex; align-items: baseline; gap: var(--s-3); padding: var(--s-4) 0 var(--s-3); border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); }
.group-head h3 { font: 600 20px/1.3 var(--serif); letter-spacing: .1em; }
.group-head span { font-size: 13px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.card {
  position: relative; display: flex; flex-direction: column; gap: var(--s-2); min-height: 100%;
  padding: var(--s-4) var(--s-4) var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-m);
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: border-color .18s, box-shadow .18s;
}
.card:hover { border-color: var(--line); box-shadow: var(--shadow-2); }
.card:has(.card-link:focus-visible) { outline: 2px solid var(--jade); outline-offset: 2px; }
.card-top { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; color: var(--muted); }
.card-no { font: 12px/1 var(--mono); color: var(--gold-ink); }
.card-top .pill { margin-left: auto; }
.card-word { font: 600 21px/1.35 var(--serif); letter-spacing: .06em; overflow-wrap: anywhere; }
.card-link { color: var(--ink); text-decoration: none; }
.card-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.card-link:focus-visible { outline: 0; }
.card:hover .card-link { color: var(--cinnabar); }
.card-py { margin-top: -4px; font-size: 13px; color: var(--muted); }
.card-quote {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font: 400 15px/1.85 var(--serif); color: var(--ink-2);
}
.card-quote .hit { text-emphasis: none; -webkit-text-emphasis: none; }
.card-src { margin-top: auto; padding-top: var(--s-2); border-top: 1px dashed var(--line-2); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: var(--s-8) var(--s-5); border: 1px dashed var(--line); border-radius: var(--r-l); text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: var(--s-2); font: 600 20px/1.4 var(--serif); color: var(--ink); }
.empty .btn { margin-top: var(--s-4); }

/* ---------- 伍 · 小测验 ---------- */
.quiz { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-6); align-items: start; }
.quiz-card { padding: clamp(20px, 3vw, 36px); border: 1px solid var(--line-2); border-radius: var(--r-l); background: var(--paper); }
.quiz-progress { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); font-size: 13px; color: var(--muted); }
.quiz-bar { display: flex; gap: 4px; }
.quiz-bar i { width: 28px; height: 4px; border-radius: 2px; background: var(--line); }
.quiz-bar i.is-done { background: var(--jade); }
.quiz-bar i.is-wrong { background: var(--cinnabar); }
.quiz-bar i.is-now { background: var(--gold); }
.quiz-word { margin-top: var(--s-5); font: 600 clamp(30px, 4vw, 40px)/1.3 var(--serif); letter-spacing: .1em; }
.quiz .quote { margin-top: var(--s-3); }
.quiz-ask { margin-top: var(--s-5); font-size: 15px; color: var(--ink-2); }
.quiz-options { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.quiz-options .btn { min-height: 44px; padding: 0 var(--s-5); font-size: 15px; }
.quiz-options .btn .dot { width: 8px; height: 8px; border-radius: 50%; }
.quiz-options .btn[aria-pressed='true'].is-right { border-color: var(--jade); background: var(--yuan-bg); color: var(--yuan-ink); }
.quiz-options .btn[aria-pressed='true'].is-wrong { border-color: var(--cinnabar); background: var(--cinnabar-soft); color: var(--cinnabar); }
.quiz-options .btn.is-answer { border-color: var(--jade); }
.quiz-options .btn:disabled { cursor: default; }
.quiz-feedback { margin-top: var(--s-4); padding: var(--s-4); border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line-2); font-size: 15px; color: var(--ink-2); }
.quiz-feedback strong { color: var(--ink); }
.quiz-next { margin-top: var(--s-4); }
.quiz-aside { display: grid; gap: var(--s-3); font-size: 15px; color: var(--ink-2); }
.quiz-aside dt { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.quiz-aside dd { margin: 2px 0 var(--s-3) 15px; font-size: 14px; }
.quiz-aside .dot { width: 7px; height: 7px; border-radius: 50%; }
.quiz-result { text-align: center; padding-block: var(--s-5); }
.quiz-result b { display: block; font: 600 56px/1.1 var(--sans); color: var(--jade-ink); }
.quiz-result p { margin-top: var(--s-2); color: var(--ink-2); }
.quiz-result .btn { margin-top: var(--s-4); }

/* ---------- 陆 · 方法 ---------- */
.method { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
.method h3 { margin-bottom: var(--s-3); font: 600 18px/1.4 var(--serif); letter-spacing: .08em; }
.method p, .method li { font-size: 15px; color: var(--ink-2); }
.method p + p { margin-top: var(--s-3); }
.method li { padding-left: 1em; text-indent: -1em; }
.method li + li { margin-top: var(--s-2); }
.method li::before { content: '·'; display: inline-block; width: 1em; text-indent: 0; color: var(--gold-ink); }
.method dl { display: grid; gap: var(--s-3); }
.method dt { display: flex; align-items: center; gap: 8px; }
.method dd { font-size: 15px; color: var(--ink-2); }

/* ---------- 页脚 ---------- */
.footer { padding: var(--s-7) 0 var(--s-8); border-top: 1px solid var(--line-2); font-size: 14px; color: var(--muted); }
.footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-4); }
.footer a { color: var(--ink-2); }

/* ---------- 词条详情：抽屉与独立页共用 ---------- */
.detail-head { padding-bottom: var(--s-5); border-bottom: 1px solid var(--line-2); }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--muted); }
.detail-no { font: 13px/1 var(--mono); color: var(--gold-ink); margin-right: 4px; }
.detail-gua { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--ink-2); }
.detail-gua .hexagram { color: var(--jade); width: 18px; height: auto; }
.detail-gua span + .hexagram { margin-left: 8px; }
.detail-word { margin-top: var(--s-4); font: 600 clamp(36px, 5vw, 48px)/1.25 var(--serif); letter-spacing: .1em; overflow-wrap: anywhere; }
.detail-py { margin-top: var(--s-1); font-size: 16px; color: var(--muted); letter-spacing: .03em; }
.detail-meaning { margin-top: var(--s-4); font-size: 17px; color: var(--ink); }
.detail-meaning .label { display: inline; margin-right: 10px; }
.detail-sec { padding-top: var(--s-5); }
.detail-sec > p { color: var(--ink-2); }
.detail-sec .quote { margin-top: var(--s-1); font-size: 19px; }
.quote-legend { margin-top: var(--s-2); font-size: 13px; color: var(--muted); }
.quote-legend .hit { text-emphasis: none; -webkit-text-emphasis: none; }
.example { font-family: var(--serif); font-size: 17px; line-height: 1.9; }
.draft-flag { display: block; margin-top: var(--s-1); font-size: 12px; color: var(--muted); }
.detail-note p { font-size: 15px; }
.detail-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line-2); font-size: 14px; color: var(--muted); }

dialog.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(600px, 100vw); max-width: none; height: 100dvh; max-height: none;
  margin: 0; padding: 0; border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
  overscroll-behavior: contain;
}
dialog.drawer::backdrop { background: rgb(12 20 17 / .42); backdrop-filter: blur(2px); }
dialog.drawer[open] { display: flex; flex-direction: column; animation: drawer-in .28s var(--ease); }
dialog.drawer[open]::backdrop { animation: fade-in .28s var(--ease); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.drawer-bar { display: flex; align-items: center; gap: 4px; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line-2); flex: none; }
.drawer-bar .grow { flex: 1; }
.drawer-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 var(--s-2); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-6) clamp(20px, 4vw, 40px) var(--s-7); }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 80; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: var(--shadow-2);
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* 独立词条页 */
.entry-page { max-width: 760px; margin: 0 auto; padding: var(--s-6) var(--gutter) var(--s-8); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-5); font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--ink-2); }
.entry-card { padding: clamp(24px, 5vw, 48px); border: 1px solid var(--line-2); border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow-1); }
.entry-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-5); }
.pager a { display: grid; gap: 2px; padding: var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--surface); color: var(--ink); text-decoration: none; }
.pager a:hover { border-color: var(--jade); color: var(--ink); }
.pager a span { font-size: 13px; color: var(--muted); }
.pager a b { font: 600 18px/1.4 var(--serif); letter-spacing: .06em; }
.pager .next { text-align: right; grid-column: 2; }

/* 404 */
.notfound { display: grid; place-items: center; min-height: 60vh; padding: var(--s-8) var(--gutter); text-align: center; }
.notfound .hexagram { width: 64px; height: auto; margin: 0 auto var(--s-5); color: var(--gold); }
.notfound h1 { font: 600 32px/1.3 var(--serif); letter-spacing: .1em; }
.notfound p { margin-top: var(--s-3); color: var(--ink-2); }
.notfound .btn { margin-top: var(--s-5); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .filters .search { grid-column: 1 / -1; }
  .filters .seg { grid-column: 1 / -1; justify-self: start; }
  .gua-layout { grid-template-columns: 1fr; }
  .gua-side { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .quiz { grid-template-columns: 1fr; }
  .method { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: 1fr; gap: var(--s-6); }
  .hero-art { top: 18%; }
  .paths { grid-template-columns: 1fr; }
  .families { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .theme-btn { margin-left: auto; }
}
@media (max-width: 640px) {
  :root { --topbar: 52px; }
  body { font-size: 15px; }
  .section-head { grid-template-columns: 1fr; margin-bottom: var(--s-6); }
  .section-no { writing-mode: horizontal-tb; grid-row: auto; padding: 0; }
  .hero-search { flex-direction: column; }
  .hero-search .btn { justify-content: center; }
  .stats { gap: var(--s-3) var(--s-5); }
  .stat b { font-size: 24px; }
  .cards { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; margin-inline: calc(var(--gutter) * -1); padding: var(--s-2) var(--gutter); border-radius: 0; }
  .filters .btn { grid-column: 1 / -1; justify-content: center; }
  .seg { width: 100%; overflow-x: auto; }
  .seg label { flex: 1; }
  .seg span { justify-content: center; padding: 0 8px; }
  .gua-grid { gap: 3px; }
  .gua-cell { min-height: 0; aspect-ratio: 1 / 1.15; padding: 4px 1px; border-radius: 6px; }
  .gua-cell .hexagram { width: 14px; }
  .gua-name { font-size: 12px; }
  .gua-n { display: none; }
  .gua-count { right: 3px; top: 2px; font-size: 10px; }
  .method { grid-template-columns: 1fr; }
  dialog.drawer { inset: auto 0 0 0; width: 100vw; height: 94dvh; border-radius: var(--r-l) var(--r-l) 0 0; }
  dialog.drawer[open] { animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
  .drawer-body { padding: var(--s-5) var(--gutter) var(--s-7); }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .hit { color: Highlight; text-emphasis-color: Highlight; }
  .gua-cell { border: 1px solid CanvasText; }
  .gua-cell[data-bin='0'] { border-style: dashed; }
  .pill { border: 1px solid CanvasText; }
  .seg input:checked + span { outline: 2px solid Highlight; }
}
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .hero-search, .daily-actions, .filters, .result-line, .quiz-section, .skip-link, .theme-btn, dialog, .toast, .entry-actions, .pager, .gua-side { display: none !important; }
  .hero { background: none; color: #000; }
  .hero-lede, .stat span, .stat b { color: #000; }
  .section { padding-block: 24pt; }
  .card { break-inside: avoid; box-shadow: none; }
  .group { content-visibility: visible; }
  a { color: inherit; }
}
