/* ═══════════════════════════════════════════════════════════════════════════
   诗歌资产库 · 设计系统
   原则：不用水墨/卷轴/印章/宣纸。中国性由数据结构本身呈现——时间的长度、
   地理的分布、意象的网络。颜色承载语义，不做装饰。
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* 中性底 —— 冷调近白，不是米黄 */
  --bg:        #FCFCFD;
  --surface:   #FFFFFF;
  --surface-2: #F4F5F7;
  --surface-3: #ECEEF1;
  --border:    #E4E6EA;
  --border-2:  #D2D6DD;
  --border-i:  #91959C;   /* 交互控件描边，3.01:1，满足 1.4.11 */
  --text:      #14161A;
  --text-2:    #5B6270;
  --text-3:    #6A707C;   /* 4.85:1 on --bg（原 #8A909C 只有 3.13:1，不合格）*/

  /* 单一强调色：只用于"当前选中 / 可交互"，不当装饰 */
  --accent:      #0F766E;
  --accent-hi:   #14918A;
  --accent-soft: #E7F2F1;

  /* 语义色阶：极性（发散，避开红绿色盲） */
  --pol-neg: #4A72B0;
  --pol-mid: #9AA1AD;
  --pol-pos: #C4863A;
  --warn-text: #A4661A;   /* 警示文字专用，4.67:1；--pol-pos 只有 3.08:1 */

  /* 意象分类（分类色板，11 类） */
  --c-天文: #5B7FC7;  --c-地理: #7D6BA8;  --c-时序: #C4863A;
  --c-气象: #4E9DB5;  --c-植物: #4E9E6A;  --c-动物: #B5713F;
  --c-器物: #8A7B5C;  --c-建筑: #7A8290;  --c-服饰: #B06A8A;
  --c-人事: #C05B5B;  --c-神话: #8B62C4;

  --r:    8px;
  --r-sm: 5px;
  --sp:   4px;
  --fast: 160ms cubic-bezier(.4,0,.2,1);

  --sans:  "PingFang SC","HarmonyOS Sans SC","Noto Sans SC","Microsoft YaHei",-apple-system,system-ui,sans-serif;
  /* 只有诗歌正文用衬线——数据冷静，诗有呼吸 */
  --serif: "Source Han Serif SC","Noto Serif SC","Songti SC","SimSun",Georgia,serif;
}

:root[data-theme="dark"], html.dark {
  --bg:        #0B0D10;
  --surface:   #131619;
  --surface-2: #1A1E23;
  --surface-3: #22272E;
  --border:    #262B32;
  --border-2:  #343A43;
  --border-i:  #5E646D;   /* 交互控件描边，3.04:1 */
  --text:      #E9ECF1;
  --text-2:    #99A1AE;
  --text-3:    #7D8593;   /* 5.23:1 on --bg（原 #6E7684 只有 4.25:1）*/
  --accent:      #2DD4BF;
  --accent-hi:   #5EEAD4;
  --accent-soft: #0F2E2B;
  --pol-neg: #6E96D6;
  --pol-mid: #6E7684;
  --pol-pos: #D9A05F;
  --warn-text: #E5B071;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-spacing-trim: trim-start;
  overflow-x: hidden;
}
body.reveal { animation: fade .35s ease-out; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* 数字一律等宽，表格与统计才对得齐 */
.num, td.num, .stat-v, .cnt { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ─── 骨架 ─────────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.nav {
  position: sticky; top: 0; align-self: flex-start;
  width: 208px; height: 100vh; flex: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  padding: 20px 0 12px;
  z-index: 40;
}
.brand { padding: 0 18px 18px; }
.brand b { display: block; font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.brand span { display: block; font-size: 11px; color: var(--text-3); letter-spacing: .10em; text-transform: uppercase; margin-top: 3px; }

.nav a.item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; font-size: 13.5px; color: var(--text-2);
  border-left: 2px solid transparent;
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}
.nav a.item:hover { color: var(--text); background: var(--surface-2); }
.nav a.item.on { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.nav .ico { width: 15px; height: 15px; flex: none; opacity: .85; }
.nav .sp { flex: 1; }

.foot { padding: 12px 18px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.foot .live { display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.main { flex: 1; min-width: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 34px 80px; }

/* ─── 版头 ─────────────────────────────────────────────────────────────── */
.ph { margin-bottom: 26px; }
.ph h1 { font-size: 25px; font-weight: 600; letter-spacing: -.01em; }
.ph p { color: var(--text-2); font-size: 14px; line-height: 1.8;
        margin-top: 7px; max-width: 62ch; }

.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }

/* ─── 卡片 / 面板 ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px;
}
.card.hov { transition: border-color var(--fast), transform var(--fast); }
.card.hov:hover { border-color: var(--border-2); transform: translateY(-1px); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* ─── 统计块 ───────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px,1fr)); gap: 1px;
         background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 16px 18px; }
.stat-k { font-size: 12px; color: var(--text-3); letter-spacing: .06em; }
.stat-v { font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; line-height: 1.1; }
.stat-s { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ─── 条形 ─────────────────────────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 11px; font-size: 12.5px; }
.bar .lbl { color: var(--text-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .track { height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 4px; background: var(--accent);
             transform-origin: left; animation: grow .55s cubic-bezier(.2,.8,.3,1) both; }
.bar .cnt { color: var(--text-3); font-size: 12px; text-align: right; }
@keyframes grow { from { transform: scaleX(0) } to { transform: scaleX(1) } }

/* 双层条：已标注 vs 总量 */
.bar .track.dual { position: relative; background: var(--surface-3); }
.bar .fill.total { position: absolute; inset: 0; background: var(--border-2); }
.bar .fill.done  { position: absolute; inset: 0; background: var(--accent); }

/* ─── 标签 ─────────────────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 20px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border-i);
  color: var(--text-2); cursor: pointer;
  transition: all var(--fast);
}
.tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tag.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag .n { font-size: 11.5px; opacity: .65; font-variant-numeric: tabular-nums; }
.tag.sm { padding: 4px 9px; font-size: 12px; }

/* ─── 检索布局 ─────────────────────────────────────────────────────────── */
.explore { display: grid; grid-template-columns: 244px 1fr; gap: 24px; align-items: start; }
.facets { position: sticky; top: 22px; max-height: calc(100vh - 44px); overflow-y: auto;
          padding-right: 6px; }
.facets::-webkit-scrollbar { width: 4px; }
.facets::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.fgroup { margin-bottom: 18px; }
.fgroup h4 { font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
             color: var(--text-3); margin-bottom: 8px; display: flex; justify-content: space-between; }
.fgroup h4 button { font-size: 10px; color: var(--accent); }

.search-in {
  width: 100%; padding: 9px 12px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border-i); border-radius: var(--r-sm);
  color: var(--text); transition: border-color var(--fast);
}
.search-in:focus { border-color: var(--accent); }

/* 统一焦点环。原来输入框把 outline 关掉了，只剩 1px 边框变色，
   在浅色主题下几乎看不见。用双环保证在任何底色上都可辨。 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.nav a.item:focus-visible { outline-offset: -2px; }
.swatch:focus-visible, .pcard:focus-visible, .lex-item:focus-visible { outline-offset: 1px; }
.search-in::placeholder { color: var(--text-3); }

/* ─── 诗卡 ─────────────────────────────────────────────────────────────── */
.plist { display: grid; gap: 10px; }
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 15px 17px; cursor: pointer;
  transition: border-color var(--fast), transform var(--fast);
  animation: rise .4s ease-out both;
}
.pcard:hover { border-color: var(--accent); transform: translateX(2px); }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.pcard .top { display: flex; align-items: baseline; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.pcard .ttl { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.pcard .meta { font-size: 12.5px; color: var(--text-3); }
.pcard .snip { font-family: var(--serif); font-size: 13.5px; color: var(--text-2);
               line-height: 1.85; margin-bottom: 8px;
               display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .gist { font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }

/* 极性条 */
.pol { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-3); }
.pol .t { width: 46px; height: 3px; border-radius: 2px; position: relative;
          background: linear-gradient(90deg, var(--pol-neg), var(--pol-mid), var(--pol-pos)); }
.pol .m { position: absolute; top: -2.5px; width: 2px; height: 8px; background: var(--text); border-radius: 1px; }

/* ─── 诗页 ─────────────────────────────────────────────────────────────── */
.poem-wrap { display: grid; grid-template-columns: 1fr 316px; gap: 30px; align-items: start; }
.poem-body { }
.poem-title { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: .01em; }
.poem-by { color: var(--text-2); font-size: 13.5px; margin-top: 6px; }
.poem-text {
  font-family: var(--serif); font-size: 20px; line-height: 2.5; letter-spacing: .04em;
  margin: 26px 0; white-space: pre-wrap;
}
.poem-line-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 7px 0;
                 border-bottom: 1px solid transparent; transition: border-color var(--fast); }
.poem-line-row:hover { border-bottom-color: var(--border); }
.poem-line-row .src { font-family: var(--serif); font-size: 19px; line-height: 1.95; letter-spacing: .04em; }
.poem-line-row .para { font-size: 13px; color: var(--text-3); line-height: 1.65; }

/* 行内标注：每一个标注都是入口，不是标签 */
mark.anno {
  background: none; color: inherit; cursor: pointer;
  border-bottom: 1.5px solid var(--accent); padding-bottom: 1px;
  transition: background var(--fast);
}
mark.anno:hover, mark.anno.on { background: var(--accent-soft); }
mark.anno.al { border-bottom-style: dashed; border-bottom-color: var(--pol-pos); }
mark.anno.en { border-bottom-color: var(--pol-neg); }

.side { position: sticky; top: 22px; display: grid; gap: 12px; }
.side h4 { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; }
.kv { display: grid; grid-template-columns: 62px 1fr; gap: 5px 10px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { color: var(--text); }

/* ─── 词表 ─────────────────────────────────────────────────────────────── */
.lex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px,1fr)); gap: 9px; }
.lex-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
            padding: 11px 13px; cursor: pointer; transition: all var(--fast); }
.lex-item:hover { border-color: var(--accent); }
.lex-item .lm { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.lex-item .ct { font-size: 11.5px; padding: 1px 6px; border-radius: 3px; background: var(--surface-2); color: var(--text-3); }
.lex-item .cs { font-size: 12.5px; color: var(--text-3); margin-top: 5px;
                display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lex-item .fr { font-size: 12px; color: var(--text-3); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ─── 画布类可视化 ─────────────────────────────────────────────────────── */
.canvas-box { position: relative; border: 1px solid var(--border); border-radius: var(--r);
              background: var(--surface); overflow: hidden; }
.canvas-box canvas { display: block; width: 100%; }
.cb-legend { position: absolute; left: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 4px 9px;
             font-size: 11.5px; color: var(--text-3); max-width: 62%; z-index: 4;
             background: color-mix(in srgb, var(--surface) 82%, transparent);
             border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px 9px;
             pointer-events: none; }
.cb-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 4px; }
.cb-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-2);
          border-radius: var(--r-sm); padding: 7px 10px; font-size: 12px; opacity: 0;
          transition: opacity var(--fast); box-shadow: 0 4px 16px rgba(0,0,0,.10); z-index: 5; }
.cb-tip.on { opacity: 1; }

/* ─── 时间轴滑块 ───────────────────────────────────────────────────────── */
.tl { display: flex; align-items: center; gap: 3px; margin: 14px 0 4px; }
.tl button {
  flex: 1; padding: 9px 6px; font-size: 12.5px; color: var(--text-2);
  border: 1px solid var(--border-i); border-radius: var(--r-sm); background: var(--surface);
  transition: all var(--fast); white-space: nowrap;
}
.tl button:hover { color: var(--text); border-color: var(--border-2); }
.tl button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── 表 ───────────────────────────────────────────────────────────────── */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 11px;
             text-transform: uppercase; letter-spacing: .06em; padding: 7px 10px; border-bottom: 1px solid var(--border); }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.t tr:hover td { background: var(--surface-2); }

/* ─── 杂项 ─────────────────────────────────────────────────────────────── */
.muted { color: var(--text-3); font-size: 13px; line-height: 1.75; }
.hr { height: 1px; background: var(--border); margin: 22px 0; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
        background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--r-sm); }
@keyframes sh { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.empty { text-align: center; padding: 54px 20px; color: var(--text-3); font-size: 13px; }
.btn { padding: 8px 14px; border: 1px solid var(--border-i); border-radius: var(--r-sm);
       font-size: 12.5px; color: var(--text-2); transition: all var(--fast); background: var(--surface); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager { display: flex; gap: 7px; justify-content: center; margin-top: 22px; }

.theme-t { position: fixed; right: 16px; bottom: 16px; z-index: 60;
           width: 34px; height: 34px; border-radius: 50%; background: var(--surface);
           border: 1px solid var(--border); display: grid; place-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .nav { width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; position: sticky; }
  .brand { display: none; }
  .nav a.item { border-left: none; border-bottom: 2px solid transparent; padding: 8px 12px; white-space: nowrap; }
  .nav a.item.on { border-left: none; border-bottom-color: var(--accent); }
  .nav .sp, .foot { display: none; }
  .wrap { padding: 20px 16px 60px; }
  .explore, .poem-wrap { grid-template-columns: 1fr; }
  .facets, .side { position: static; max-height: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════
   移动端适配
   ═══════════════════════════════════════════════════════════════════════ */

/* 刘海屏安全区 */
.nav, .wrap { padding-left: max(var(--sp), env(safe-area-inset-left));
              padding-right: max(var(--sp), env(safe-area-inset-right)); }
.theme-t { bottom: max(16px, env(safe-area-inset-bottom)); }

@media (max-width: 720px) {
  html { font-size: 15.5px; }
  .wrap { padding: 16px 14px 72px; }

  /* 可视化：视口高度自适应，覆盖内联的固定高度 */
  .canvas-box { height: 58vh !important; min-height: 300px; max-height: 440px; }
  .canvas-box canvas { touch-action: none; }   /* 允许在画布上拖动而不滚页面 */
  .cb-legend { font-size: 10px; gap: 3px 7px; max-width: 92%; bottom: 8px; left: 10px; }
  .cb-tip { font-size: 12.5px; padding: 8px 11px; max-width: 66vw; }

  /* 触摸目标 ≥ 40px */
  .tag { padding: 7px 12px; font-size: 13px; }
  .tag.sm { padding: 5px 10px; font-size: 12px; }
  .tl button { padding: 11px 10px; font-size: 12.5px; }
  .btn { padding: 10px 15px; font-size: 13px; }
  .nav a.item { padding: 12px 14px; }
  .search-in { padding: 12px 13px; font-size: 16px; }  /* 16px 防 iOS 聚焦时缩放 */

  /* 检索页：筛选面板默认收起，避免结果被推到屏幕外 */
  .explore { gap: 14px; }
  .facets { max-height: 0; overflow: hidden; padding: 0;
            transition: max-height .28s ease, padding .28s ease; }
  .facets.open { max-height: 62vh; overflow-y: auto; padding: 12px 0 4px;
                 border-bottom: 1px solid var(--border); }
  .facet-toggle { display: flex; align-items: center; justify-content: space-between;
                  width: 100%; padding: 11px 14px; margin-bottom: 10px;
                  border: 1px solid var(--border); border-radius: var(--r-sm);
                  background: var(--surface); font-size: 13.5px; }
  .facet-toggle .chev { transition: transform var(--fast); color: var(--text-3); }
  .facet-toggle.open .chev { transform: rotate(180deg); }

  /* 诗页正文在小屏收紧行距，一屏能多看两句 */
  .poem-text { font-size: 18px; line-height: 2.2; }
  .poem-line-row .src { font-size: 17px; line-height: 1.85; }
  .poem-title { font-size: 25px; }
  .ph h1 { font-size: 21px; }
  .stat-v { font-size: 23px; }

  /* 表格横向滚动而不是撑破页面 */
  table.t { font-size: 12px; }
  table.t th, table.t td { padding: 7px 8px; white-space: nowrap; }

  .lex-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .kv { grid-template-columns: 56px 1fr; }
}

/* 桌面端不显示移动端的筛选开关 */
.facet-toggle { display: none; }

@media (max-width: 400px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .lex-grid { grid-template-columns: repeat(2, 1fr); }
  .canvas-box { height: 52vh !important; min-height: 260px; }
}

/* 触摸设备：hover 态不残留 */
@media (hover: none) {
  .card.hov:hover { transform: none; }
  .pcard:hover { transform: none; }
}

/* ═══ 可视化工具条 / 全屏 ═══════════════════════════════════════════════ */
.viz-tools {
  position: absolute; right: 10px; top: 10px; z-index: 6;
  display: flex; flex-direction: column; gap: 4px;
}
.viz-tools button {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-i);
  border-radius: var(--r-sm); color: var(--text-2); font-size: 14px; line-height: 1;
  transition: all var(--fast);
}
.viz-tools button:hover { border-color: var(--accent); color: var(--accent); }
.viz-tools button:active { background: var(--accent-soft); }

.canvas-box.viz-full,
.canvas-box:fullscreen {
  height: 100vh !important; max-height: none; width: 100vw;
  border-radius: 0; border: none; background: var(--bg);
}
.canvas-box:fullscreen .viz-tools { right: 16px; top: 16px; }

/* 画布上禁用默认手势，交给我们自己的平移缩放 */
.canvas-box canvas { touch-action: none; user-select: none; -webkit-user-select: none; }

@media (max-width: 720px) {
  .viz-tools { right: 8px; top: 8px; }
  .viz-tools button { width: 38px; height: 38px; font-size: 16px; }
}

/* ═══ 移动端底部导航 ═══════════════════════════════════════════════════ */
.mnav { display: none; }

@media (max-width: 980px) {
  /* 顶部只留品牌条，主导航挪到底部 tab bar —— 拇指够得着 */
  .nav {
    flex-direction: row; align-items: center; width: 100%; height: auto;
    padding: 8px 14px; border-right: none; border-bottom: 1px solid var(--border);
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .nav .brand { display: block; padding: 0; }
  .nav .brand b { font-size: 14px; }
  .nav .brand span { font-size: 9.5px; }
  .nav #nav { display: none; }
  .nav .sp { flex: 1; }
  .nav .foot { display: block; padding: 0; border: none; text-align: right; }
  .nav .foot > div:last-child { display: none; }

  .wrap { padding-bottom: 96px; }

  .mnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 2px 7px; font-size: 10.5px; color: var(--text-3);
    transition: color var(--fast); min-width: 0;
  }
  .mnav a svg { width: 20px; height: 20px; stroke: currentColor; fill: none;
                stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .mnav a.on { color: var(--accent); }
  .mnav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  .theme-t { bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* 更多面板 */
  .msheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    background: var(--surface); border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0; padding: 14px 14px calc(84px + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 -8px 32px rgba(0,0,0,.12);
  }
  .msheet.open { transform: translateY(0); }
  .msheet .grip { width: 36px; height: 4px; border-radius: 2px; background: var(--border-2);
                  margin: 0 auto 12px; }
  .msheet a { display: block; padding: 13px 10px; font-size: 14px;
              border-bottom: 1px solid var(--border); }
  .msheet a.on { color: var(--accent); }
  .msheet-mask { position: fixed; inset: 0; z-index: 54; background: rgba(0,0,0,.28);
                 opacity: 0; pointer-events: none; transition: opacity .26s; }
  .msheet-mask.open { opacity: 1; pointer-events: auto; }
}

/* ═══ 色谱 ══════════════════════════════════════════════════════════════ */
.cchip .sw {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
  border: 1px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 8px; }
.swatch {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto;
  gap: 2px 10px; align-items: center; text-align: left;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); transition: all var(--fast);
}
.swatch:hover { border-color: var(--accent); transform: translateY(-1px); }
.swatch .chip {
  grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
}
.swatch .nm { font-family: var(--serif); font-size: 14.5px; font-weight: 600; }
.swatch .cd { font-size: 11px; color: var(--text-3); letter-spacing: .04em; }
.swatch .hx { display: none; }
.swatch .fr { grid-column: 2; font-size: 11.5px; color: var(--text-3); }
.swatch .nm, .swatch .cd, .swatch .fr { grid-column: 2; }
.swatch .nm { grid-row: 1; }
.swatch .cd { grid-row: 2; }
.swatch .fr { display: none; }

@media (max-width: 720px) {
  .swatches { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); }
}

/* ═══ 诗人时间轴 ════════════════════════════════════════════════════════
   朝代条与生卒年直方图共用一条真实年份坐标，所以都用绝对定位按年份摆。
   注意别叫 .tl —— 那个类名已经被朝代切片按钮组占了（display:flex），
   撞上去会让容器宽度归零。 */
.tline { position: relative; }
.tline-eras { position: relative; height: 40px; }
.tline-eras .era {
  position: absolute; top: 0; height: 40px; border-radius: 3px;
  opacity: .5; transition: opacity var(--fast), transform var(--fast);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); overflow: hidden; padding: 0 2px;
}
.tline-eras .era:hover { opacity: .85; }
.tline-eras .era.on { opacity: 1; box-shadow: 0 0 0 2px var(--accent); z-index: 2; }
.tline-eras .era.empty { opacity: .18; }
.tline-eras .era .lb { font-size: 11.5px; white-space: nowrap; }
.tline-eras .era .nn { font-size: 10px; opacity: .9; }
/* 过渡期人数极少，画成边界上的窄标记 */
.tline-eras .trans {
  position: absolute; top: -3px; width: 5px; height: 46px; margin-left: -2.5px;
  border-radius: 3px; background: var(--text-3); opacity: .45; z-index: 3;
}
.tline-eras .trans:hover, .tline-eras .trans.on { opacity: 1; background: var(--accent); }

.yhist { position: relative; height: 64px; }
.yhist .yb {
  position: absolute; bottom: 0; height: 100%;
  display: flex; align-items: flex-end; padding: 0 1px;
}
.yhist .yb span { width: 100%; background: var(--border-2); border-radius: 2px 2px 0 0;
                  transition: background var(--fast), height .4s cubic-bezier(.2,.8,.3,1); }
.yhist .yb:hover span { background: var(--text-3); }
.yhist .yb.on span { background: var(--accent); }
.tline-axis { position: relative; height: 15px; margin-top: 3px;
           border-top: 1px solid var(--border); }
.tline-axis span { position: absolute; top: 3px; transform: translateX(-50%);
                font-size: 11px; color: var(--text-3); white-space: nowrap; }
.ynum { width: 92px; padding: 7px 9px; font-size: 13px; }

@media (max-width: 720px) {
  .tline-eras, .tline-eras .era { height: 44px; }
  .tline-eras .era .lb { font-size: 9.5px; }
  .tline-eras .era .nn { display: none; }
  .tline-axis span:nth-child(even) { display: none; }
  .ynum { width: 78px; }
}

/* ═══ 安装到桌面 ════════════════════════════════════════════════════════ */
.install-bar {
  /* 隐藏态必须是真隐藏。原来只靠 translateY(140%)，而 140% 算的是自身高度
     （62px→87px），底部又留了 84px 安全距，结果没移出去，一直压着底栏。 */
  position: fixed; z-index: 70; left: 50%; transform: translate(-50%, 140%);
  visibility: hidden; pointer-events: none;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  width: min(520px, calc(100vw - 28px));
  padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  transition: transform .34s cubic-bezier(.2,.9,.3,1), visibility 0s .34s;
}
.install-bar.on {
  transform: translate(-50%, 0); visibility: visible; pointer-events: auto;
  transition: transform .34s cubic-bezier(.2,.9,.3,1), visibility 0s;
}
/* 手机端不要这条：屏幕本来就窄，底栏是主导航，不能被它占。
   想装的人走浏览器菜单「添加到主屏幕」即可。 */
@media (max-width: 767px) { .install-bar { display: none !important; } }
.install-bar img { width: 40px; height: 40px; border-radius: 9px; flex: none; }
.install-bar .tx { flex: 1; min-width: 0; line-height: 1.35; }
.install-bar .tx b { display: block; font-size: 13.5px; }
.install-bar .tx span { font-size: 11.5px; color: var(--text-3); }
.install-bar .btn { flex: none; padding: 8px 13px; font-size: 12.5px; }

@media (max-width: 980px) {
  .install-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .install-bar { gap: 9px; padding: 10px 11px; }
  .install-bar .tx span { display: none; }
  .install-bar #ibno { display: none; }
}

/* ═══ 地图图例 ══════════════════════════════════════════════════════════ */
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-3);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 10px; pointer-events: none;
}
.map-legend .lg-bar { width: 96px; height: 8px; border-radius: 4px;
                      box-shadow: inset 0 0 0 1px var(--border-2); }
.map-legend .lg-t { color: var(--text-2); }
@media (max-width: 720px) {
  .map-legend { left: 8px; bottom: 8px; padding: 5px 8px; font-size: 10px; }
  .map-legend .lg-bar { width: 64px; }
}
.swatch .src { grid-column: 2; grid-row: 3; font-size: 10px; color: var(--accent);
               justify-self: start; }
.swatch .src.no { color: var(--text-3); }
.swatch { grid-template-rows: auto auto auto; }
.swatch .chip { grid-row: 1 / 4; }

/* ═══ 单色画像 ══════════════════════════════════════════════════════════ */
.color-hero { display: grid; grid-template-columns: 132px 1fr; gap: 22px; align-items: start; }
.color-hero .big { width: 132px; height: 132px; border-radius: 14px; }
@media (max-width: 720px) {
  .color-hero { grid-template-columns: 84px 1fr; gap: 14px; }
  .color-hero .big { width: 84px; height: 84px; border-radius: 11px; }
  .color-hero h1 { font-size: 26px !important; }
}


/* ═══ 无障碍 ════════════════════════════════════════════════════════════ */
/* 2.4.1 跳过导航：键盘用户每页要穿过 8 个导航项才到内容 */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  padding: 10px 16px; background: var(--accent); color: #fff;
  border-radius: var(--r-sm); font-size: 14px;
  transition: top var(--fast);
}
.skip-link:focus { top: 8px; }

/* 屏幕阅读器专用文本：给 canvas 之类无法直接读的内容提供等价描述 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 强制高对比模式下保住边界 */
@media (forced-colors: active) {
  .tag, .btn, .swatch, .lex-item, .pcard { border: 1px solid ButtonBorder; }
  .tag.on, .tl button.on { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ── 窄屏布局：可视化不要被工具条挤扁 ── */
@media (max-width: 560px) {
  .canvas-box { height: 46vh !important; min-height: 240px; }
  /* 工具条改横排放到右上，竖排会压掉小屏一半的图 */
  .viz-tools { flex-direction: row; right: 8px; top: 8px; left: auto; bottom: auto;
               gap: 5px;
               background: color-mix(in srgb, var(--surface) 88%, transparent);
               padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
  .map-legend { left: 8px; bottom: 8px; }
  .cb-legend { max-width: calc(100% - 20px); }
  /* 安装条上移，别压住底部内容 */
  .install-bar { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* ═══ 朗读 / 解读 ═══════════════════════════════════════════════════════ */
.tts-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tts-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border-i); background: var(--surface); color: var(--text-2);
  transition: all var(--fast);
}
.tts-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tts-btn:disabled { opacity: .55; cursor: progress; }
.tts-btn .ic { font-size: 10px; }
.tts-btn.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.tts-btn.playing .ic::before { content: '■'; }
.tts-btn.playing .ic { font-size: 9px; }
.tts-voice { padding: 7px 10px; font-size: 12.5px; width: auto; }
.tts-hint { font-size: 12px; flex: 1; min-width: 0; }
@media (max-width: 560px) {
  .tts-hint { flex-basis: 100%; }
}

/* ── 二十四节气色带 ─────────────────────────────────────────────── */
.term-row{display:flex;align-items:center;gap:12px;margin-bottom:5px}
.term-lab{flex:0 0 84px;display:flex;justify-content:space-between;align-items:baseline;
  gap:6px;font-size:12.5px;color:var(--text-2)}
.term-lab .num{font-size:11px;color:var(--text-3)}
.term-band{flex:1;display:flex;height:30px;border-radius:5px;overflow:hidden;
  box-shadow:inset 0 0 0 1px var(--border)}
.tseg{flex:1;border:0;padding:0;cursor:pointer;position:relative;
  transition:transform .12s ease,z-index 0s}
.tseg:hover,.tseg:focus-visible{transform:scaleY(1.42);z-index:2;border-radius:3px;
  box-shadow:0 0 0 1.5px var(--bg),0 3px 10px rgba(0,0,0,.34)}
.tseg:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
/* 窄屏：16 等分会把色段压到 15px，低于 24×24 的最小点击目标。
   整块横向滚动（一个滚动容器，24 行一起动），色段保持可点。 */
@media (max-width:720px){
  #terms{overflow-x:auto;-webkit-overflow-scrolling:touch;padding-bottom:6px}
  #terms>.term-row{min-width:520px}
  .term-row{gap:8px}
  .term-lab{flex:0 0 56px;font-size:11.5px;position:sticky;left:0;
    background:var(--surface);z-index:3;padding-right:2px}
  .term-lab .num{display:none}
  .term-band{height:40px}
  .tseg:hover,.tseg:focus-visible{transform:none;box-shadow:0 0 0 2px var(--bg),0 0 0 3.5px var(--accent)}
}

/* ── 色名出处与原文用例 ─────────────────────────────────────────── */
.src-q{font-family:var(--serif);font-size:19px;line-height:1.9;margin:6px 0 8px;
  padding-left:14px;border-left:3px solid var(--border-2);color:var(--text)}
.src-by{font-size:13px;color:var(--text-2);display:flex;align-items:center;flex-wrap:wrap;gap:4px}
.mention-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(258px,1fr));
  gap:8px;margin-top:11px}
.mention{text-align:left;background:var(--surface);border:1px solid var(--border);
  border-radius:8px;padding:10px 12px;cursor:pointer;display:grid;gap:3px;
  transition:border-color .14s ease,background .14s ease}
.mention:hover{border-color:var(--border-2);background:var(--surface-2)}
.mention:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.mention .mt{font-size:13.5px;color:var(--text)}
.mention .mb{font-size:11.5px;color:var(--text-3)}
.mention .mx{font-family:var(--serif);font-size:13.5px;line-height:1.7;color:var(--text-2)}
.mention mark{padding:0 2px;border-radius:2px}
@media (max-width:520px){.mention-list{grid-template-columns:1fr}.src-q{font-size:17px}}

/* ── 标注控制条 ─────────────────────────────────────────────────── */
.ctl{margin-bottom:14px}
.ctl-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.ctl-state{font-size:14px;padding:4px 11px;border-radius:999px;
  border:1px solid var(--border-2);color:var(--text-2)}
.ctl-state.on{color:var(--accent);border-color:var(--accent)}
.ctl-state.warn{color:var(--warn-text);border-color:var(--warn-text)}
.ctl-state.off{color:var(--text-3)}
.ctl-row .btn{min-width:82px;min-height:38px}
.ctl-msg{font-size:12.5px}
.ctl-auth{display:flex;align-items:center;gap:9px;flex-wrap:wrap;
  margin-top:12px;padding-top:12px;border-top:1px solid var(--border)}
.ctl-auth label{font-size:12.5px;color:var(--text-2)}
.ctl-auth input{flex:1;min-width:200px}
@media (max-width:520px){
  .ctl-row{gap:9px}
  .ctl-msg{flex:1 0 100%}
  .ctl-auth input{min-width:0}
}

/* 两个显式的控制按钮：禁用态要一眼看出来，
   否则「启动」灰着还去点，会以为是坏了 */
.ctl-row .btn:disabled{opacity:.36;cursor:not-allowed}
.ctl-row .btn:not(:disabled)#ctlresume{border-color:var(--accent);color:var(--accent)}
.ctl-row .btn:not(:disabled)#ctlpause{border-color:var(--warn-text);color:var(--warn-text)}

/* 词表挂载 ≠ 模型标注。视觉上必须区别开，虚线边 + 弱化，
   否则读者会以为这两种东西证据强度一样。 */
.auto-card{border-style:dashed;border-color:var(--border-2)}
.auto-card .auto-note{font-size:12px;line-height:1.7;margin:2px 0 10px}
.auto-card .auto-note b{color:var(--text)}
.auto-im{opacity:.88}

/* 全库检索的结果里混着未标注的诗，弱化标记以示区别 */
.tag.sm.dim{opacity:.62;border-style:dashed}

/* ── 意象相近的诗 ──────────────────────────────────────────────── */
.simlist{display:grid;gap:7px;margin-top:11px}
.simitem{text-align:left;background:var(--surface);border:1px solid var(--border);
  border-radius:8px;padding:10px 12px;cursor:pointer;display:grid;gap:4px;
  transition:border-color .14s ease,background .14s ease}
.simitem:hover{border-color:var(--border-2);background:var(--surface-2)}
.simitem:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.simitem .st{font-family:var(--serif);font-size:15px;color:var(--text)}
.simitem .sb{font-size:11.5px;color:var(--text-3)}
.simitem .sw{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}

/* ── 应用区 ────────────────────────────────────────────────────── */
.appgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));
  gap:12px;margin-top:18px}
.appcard{text-align:left;background:var(--surface);border:1px solid var(--border);
  border-radius:12px;padding:18px 16px;cursor:pointer;display:grid;gap:6px;
  transition:border-color .16s ease,background .16s ease,transform .16s ease}
.appcard:hover{border-color:var(--accent);background:var(--surface-2);transform:translateY(-2px)}
.appcard:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.appcard .ai{font-size:22px;line-height:1;color:var(--accent)}
.appcard .al{font-size:16px;color:var(--text)}
.appcard .ad{font-size:12.5px;line-height:1.65;color:var(--text-3)}
@media (max-width:520px){.appgrid{grid-template-columns:1fr}}
