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

:root {
  /* 中性底 —— 冷调近白，不是米黄 */
  --bg:        #FCFCFD;
  --surface:   #FFFFFF;
  --surface-2: #F4F5F7;
  --surface-3: #ECEEF1;
  --border:    #E4E6EA;
  --border-2:  #D2D6DD;
  --text:      #14161A;
  --text-2:    #5B6270;
  --text-3:    #8A909C;

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

  /* 语义色阶：极性（发散，避开红绿色盲） */
  --pol-neg: #4A72B0;
  --pol-mid: #9AA1AD;
  --pol-pos: #C4863A;

  /* 意象分类（分类色板，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;
  --text:      #E9ECF1;
  --text-2:    #99A1AE;
  --text-3:    #6E7684;
  --accent:      #2DD4BF;
  --accent-hi:   #5EEAD4;
  --accent-soft: #0F2E2B;
  --pol-neg: #6E96D6;
  --pol-mid: #6E7684;
  --pol-pos: #D9A05F;
}

*, *::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.6;
  -webkit-font-smoothing: antialiased;
  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: 11px; 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: 13.5px; margin-top: 5px; max-width: 68ch; }

.eyebrow { font-size: 11px; 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: 11px; 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: 11.5px; 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: 11.5px; 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: 3px 9px; border-radius: 20px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  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: 10.5px; opacity: .65; font-variant-numeric: tabular-nums; }
.tag.sm { padding: 2px 7px; font-size: 11px; }

/* ─── 检索布局 ─────────────────────────────────────────────────────────── */
.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); border-radius: var(--r-sm);
  color: var(--text); transition: border-color var(--fast);
}
.search-in:focus { outline: none; border-color: var(--accent); }
.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: 12px; 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: 10.5px; padding: 1px 6px; border-radius: 3px; background: var(--surface-2); color: var(--text-3); }
.lex-item .cs { font-size: 11.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: 11px; 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: 14px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px;
             font-size: 10.5px; color: var(--text-3); max-width: 70%; }
.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: 7px 4px; font-size: 11.5px; color: var(--text-3);
  border: 1px solid var(--border); 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: 12.5px; }
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: 12.5px; }
.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: 7px 13px; border: 1px solid var(--border); 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; }
}
