/* ==================================================================
   六爻卜卦系统 · 样式表
   风格：宣纸墨色 + 朱红赭金，兼顾长文阅读与卦盘呈现
   ================================================================== */

:root {
  --ink: #1c1a17;
  --ink-2: #4a443c;
  --ink-3: #7a7266;
  --paper: #f6f2ea;
  --card: #fffdf8;
  --card-2: #fbf8f2;
  --accent: #8b1e1e;
  --accent-l: #b23b3b;
  --gold: #a8791f;
  --gold-l: #c9a24a;
  --line: #e2d9c9;
  --line-2: #efe8db;
  --ok: #2f6b3f;
  --ok-bg: #eef6ef;
  --warn: #9a6a10;
  --warn-bg: #fdf6e6;
  --bad: #a02a2a;
  --bad-bg: #fbeeee;
  --info: #2c5a7a;
  --info-bg: #eef4f9;
  --shadow: 0 1px 2px rgba(28, 26, 23, .06), 0 6px 20px rgba(28, 26, 23, .06);
  --shadow-lg: 0 10px 40px rgba(28, 26, 23, .14);
  --radius: 10px;
  --serif: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.35; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------------------------- 登录页 ---------------------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(168, 121, 31, .10), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(139, 30, 30, .10), transparent 45%),
    var(--paper);
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .taiji { font-size: 44px; line-height: 1; color: var(--accent); }
.login-brand h1 {
  font-size: 27px; letter-spacing: 5px; margin: 12px 0 6px; color: var(--ink);
}
.login-brand p { margin: 0; color: var(--ink-3); font-size: 13px; letter-spacing: 1.5px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs button {
  flex: 1; background: none; border: none; padding: 11px 0; cursor: pointer;
  color: var(--ink-3); font-size: 15px; border-bottom: 2px solid transparent;
  transition: all .18s;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600;
}
.field input {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card-2); color: var(--ink);
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus {
  outline: none; border-color: var(--gold-l);
  box-shadow: 0 0 0 3px rgba(201, 162, 74, .18);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--ink); cursor: pointer;
  font-size: 14px; transition: all .16s; white-space: nowrap;
}
.btn:hover { background: #f2ece0; border-color: var(--gold-l); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-l), var(--accent));
  color: #fff; border-color: var(--accent); font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(180deg, #c14646, #9a2626); border-color: #9a2626; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-l), var(--gold));
  color: #fff; border-color: var(--gold); font-weight: 700;
}
.btn-gold:hover { background: linear-gradient(180deg, #d6b05c, #b8862a); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; letter-spacing: 3px; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }

.msg { padding: 10px 13px; border-radius: 8px; font-size: 13.5px; margin-bottom: 15px; display: none; }
.msg.show { display: block; }
.msg.err { background: var(--bad-bg); color: var(--bad); border: 1px solid #f0cccc; }
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #cfe4d3; }

.login-hint {
  margin-top: 20px; padding: 12px 14px; background: var(--card-2);
  border: 1px dashed var(--line); border-radius: 8px;
  font-size: 12.5px; color: var(--ink-3); line-height: 1.7;
}
.login-hint b { color: var(--accent); }
.login-foot { text-align: center; margin-top: 18px; font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------- 应用外壳 ---------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px; height: 56px;
  background: rgba(255, 253, 248, .95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-family: var(--serif); font-size: 18px; letter-spacing: 3px;
  color: var(--ink); display: flex; align-items: center; gap: 9px; font-weight: 700;
}
.topbar .brand .mark { color: var(--accent); font-size: 21px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  padding: 7px 15px; border-radius: 8px; color: var(--ink-2);
  font-size: 14px; text-decoration: none; transition: all .16s;
}
.topbar nav a:hover { background: var(--card-2); color: var(--accent); text-decoration: none; }
.topbar nav a.active { background: var(--accent); color: #fff; font-weight: 700; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); }

.layout { display: flex; gap: 22px; padding: 22px; align-items: flex-start; max-width: 1760px; margin: 0 auto; }
.side {
  width: 340px; flex: 0 0 340px; min-width: 0;
  position: sticky; top: 78px; max-height: calc(100vh - 100px); overflow-y: auto;
}
.main { flex: 1; min-width: 0; }

/* 侧栏内的表格一律允许横向滚动，绝不撑破容器 */
.side .ref-table-wrap, .side .md-table-wrap { overflow-x: auto; }
.side .ref-table { font-size: 12px; }
.side .ref-table th, .side .ref-table td { padding: 5px 7px; white-space: nowrap; }
.card-body { min-width: 0; overflow-wrap: anywhere; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head {
  padding: 13px 18px; border-bottom: 1px solid var(--line-2);
  font-family: var(--serif); font-weight: 700; font-size: 15.5px; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-head .sub { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--ink-3); }
.card-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------- 表单 ---------------------------- */

.form-row { margin-bottom: 13px; }
.form-row label {
  display: block; font-size: 12.5px; color: var(--ink-2);
  margin-bottom: 5px; font-weight: 600;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--card-2); color: var(--ink);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--gold-l); box-shadow: 0 0 0 3px rgba(201, 162, 74, .16);
}
.form-row textarea { resize: vertical; min-height: 62px; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.form-inline .form-row { flex: 1; min-width: 74px; margin-bottom: 0; }

/* 标签行：左标题 + 右小按钮 */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btn-xs { padding: 2px 9px; font-size: 11.5px; border-radius: 6px; line-height: 1.7; }

/* 日期时间：不再嵌套 form-row，改为一格两列的网格，避免挤压溢出 */
.dt-row { display: grid; grid-template-columns: 1.35fr 1fr; gap: 7px; }
.dt-row input { min-width: 0; }
.num-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.num-row input { min-width: 0; text-align: center; }
.btn-row-2 { display: flex; gap: 8px; margin-top: 9px; }
.btn-row-2 .btn { flex: 1; }

/* 起卦时间的实时四柱预览 */
.dt-preview {
  margin-top: 7px; padding: 8px 11px; border-radius: 7px;
  background: linear-gradient(180deg, #fbf7ef, #f6f0e4);
  border: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-2);
  line-height: 1.75; font-family: var(--serif); letter-spacing: .5px;
}
.dt-preview b { color: var(--accent); }
.dt-preview .dp-err { color: var(--bad); font-family: var(--sans); }

.toss-log { margin-top: 14px; font-size: 12px; color: var(--ink-3); line-height: 1.9; }

/* 四柱面板：紧凑网格，替代原先的 4 列表格（在窄侧栏中会溢出） */
.pillar-head {
  text-align: center; font-family: var(--serif); font-size: 16px;
  letter-spacing: 1px; line-height: 1.9; margin-bottom: 10px;
  padding-bottom: 9px; border-bottom: 1px dashed var(--line);
}
.pillar-head .ph-item { display: inline-block; margin: 0 5px; white-space: nowrap; }
.pillar-head .ph-gz { color: var(--accent); font-weight: 700; font-size: 17px; }
.pillar-head .ph-lb { color: var(--ink-3); font-size: 12px; }
.pillar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.pg-item {
  display: flex; align-items: baseline; gap: 6px; min-width: 0;
  padding: 5px 8px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 6px;
}
.pg-k { flex: 0 0 auto; font-size: 11.5px; color: var(--ink-3); }
.pg-v { font-size: 13px; color: var(--ink); font-family: var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-v.hl { color: var(--accent); font-weight: 700; }
.pg-full { grid-column: 1 / -1; }
.pillar-foot { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------------------------- 卦盘 ---------------------------- */

.gua-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; }

.gua-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.gua-card-head {
  padding: 11px 16px; background: linear-gradient(180deg, #2a251e, #1c1a17);
  color: #f0e6d2; display: flex; align-items: center; justify-content: space-between;
}
.gua-card-head .t { font-family: var(--serif); font-size: 17px; letter-spacing: 2px; font-weight: 700; }
.gua-card-head .m { font-size: 11.5px; opacity: .8; }
.gua-card-head.bian { background: linear-gradient(180deg, #3a2a2a, #241a1a); }

.gua-meta {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 11px 16px;
  border-bottom: 1px solid var(--line-2); background: var(--card-2);
}
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px;
  background: #f0e9db; color: var(--ink-2); border: 1px solid var(--line);
}
.tag.red { background: var(--bad-bg); color: var(--bad); border-color: #eccfcf; }
.tag.green { background: var(--ok-bg); color: var(--ok); border-color: #cfe4d3; }
.tag.gold { background: #fbf3df; color: var(--gold); border-color: #ecdcb6; }
.tag.blue { background: var(--info-bg); color: var(--info); border-color: #cfe0ec; }

.yao-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.yao-table th {
  padding: 7px 6px; font-size: 11.5px; color: var(--ink-3); font-weight: 600;
  border-bottom: 1px solid var(--line); background: var(--card-2); text-align: center;
}
.yao-table td { padding: 6px; border-bottom: 1px dashed var(--line-2); text-align: center; }
.yao-table tr:last-child td { border-bottom: none; }
.yao-table tr.moving { background: #fff8ec; }
.yao-table tr.shi-row { background: #fdf3f3; }
.yao-table tr.ying-row { background: #f2f6fb; }
.yao-table tr.kong-row { opacity: .58; }

.yao-sym { font-family: var(--mono); font-size: 15px; letter-spacing: 1px; color: var(--ink); }
.yao-sym.yang { color: var(--accent); }
.yao-sym.yin { color: var(--ink-2); }
.yao-sym.mv { color: #c47a12; font-weight: 700; }

.lq { font-weight: 700; }
.lq-父母 { color: #2c5a7a; }
.lq-兄弟 { color: #7a5a2c; }
.lq-子孙 { color: #2f6b3f; }
.lq-妻财 { color: #a8791f; }
.lq-官鬼 { color: #8b1e1e; }

.gz { font-family: var(--serif); font-size: 14px; letter-spacing: 1px; }
.wx-金 { color: #9a7b1a; } .wx-木 { color: #2f6b3f; } .wx-水 { color: #2c5a7a; }
.wx-火 { color: #a02a2a; } .wx-土 { color: #7a5a2c; }

.badge-ss {
  display: inline-block; width: 20px; height: 20px; line-height: 20px;
  border-radius: 50%; font-size: 11px; font-weight: 700; text-align: center;
}
.badge-shi { background: var(--accent); color: #fff; }
.badge-ying { background: var(--info); color: #fff; }

.bian-arrow { color: var(--gold); font-weight: 700; }

/* 卦盘「状态」列：窄屏时允许换行但不撑破表格 */
.state-cell { text-align: left; line-height: 1.9; }
.state-cell .tag { margin: 1px 2px; }

/* 手动爻象选择器 */
.yao-sel {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card-2); color: var(--ink);
}
.yao-sel:focus { outline: none; border-color: var(--gold-l); }

/* ---------------------------- 分析 ---------------------------- */

.finding {
  border-left: 3px solid var(--line); padding: 10px 14px; margin-bottom: 9px;
  border-radius: 0 8px 8px 0; background: var(--card-2); font-size: 13.5px;
}
.finding .ft { font-weight: 700; margin-bottom: 3px; display: flex; align-items: flex-start; gap: 7px; }
.finding .fd { color: var(--ink-2); font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; }
.finding.good { border-left-color: var(--ok); background: var(--ok-bg); }
.finding.good .ft { color: var(--ok); }
.finding.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.finding.bad .ft { color: var(--bad); }
.finding.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.finding.warn .ft { color: var(--warn); }
.finding.info { border-left-color: var(--info); background: var(--info-bg); }
.finding.info .ft { color: var(--info); }
.finding .dot { flex: 0 0 auto; }

.disclaimer {
  padding: 12px 15px; background: #fdf6e6; border: 1px solid #ecdcb6;
  border-radius: 8px; font-size: 12.5px; color: var(--warn); line-height: 1.75;
}

/* ---------------------------- 课程阅读 ---------------------------- */

.chapter-list { list-style: none; margin: 0; padding: 8px; }
.chapter-list li { margin-bottom: 2px; }
.chapter-list a {
  display: flex; align-items: flex-start; gap: 9px; padding: 8px 11px;
  border-radius: 7px; color: var(--ink-2); font-size: 13.2px;
  text-decoration: none; transition: all .15s; line-height: 1.5;
}
.chapter-list a:hover { background: var(--card-2); color: var(--accent); text-decoration: none; }
.chapter-list a.active { background: var(--accent); color: #fff; font-weight: 700; }
.chapter-list .num {
  flex: 0 0 22px; height: 22px; line-height: 22px; text-align: center;
  border-radius: 5px; background: #efe7d8; color: var(--ink-2); font-size: 11.5px; font-weight: 700;
}
.chapter-list a.active .num { background: rgba(255, 255, 255, .25); color: #fff; }
.chapter-list .done::after { content: '✓'; color: var(--ok); margin-left: 5px; font-weight: 700; }
.chapter-list a.active .done::after { color: #b6f0c4; }
.part-title {
  padding: 12px 12px 6px; font-family: var(--serif); font-size: 12.5px;
  color: var(--gold); letter-spacing: 2px; font-weight: 700;
  border-top: 1px solid var(--line-2); margin-top: 8px;
}
.part-title:first-child { border-top: none; margin-top: 0; }

/* ---------------------------- Markdown 教学块 ---------------------------- */

.md-body { font-size: 15px; line-height: 1.95; color: var(--ink); }
.md-body .md-h { font-family: var(--serif); margin: 1.7em 0 .7em; color: var(--ink); }
.md-body .md-h2 {
  font-size: 22px; padding-bottom: 8px; border-bottom: 2px solid var(--accent);
  letter-spacing: 1px;
}
.md-body .md-h3 { font-size: 18px; color: var(--accent); }
.md-body .md-h4 { font-size: 16px; color: var(--ink-2); }
.md-body .md-p { margin: .85em 0; }
.md-body .md-ul, .md-body .md-ol { margin: .7em 0; padding-left: 1.7em; }
.md-body .md-ul li, .md-body .md-ol li { margin-bottom: .35em; }
.md-body .md-hr { border: none; border-top: 1px dashed var(--line); margin: 1.6em 0; }
.md-body .md-quote {
  margin: 1em 0; padding: 11px 16px; border-left: 3px solid var(--gold);
  background: var(--card-2); color: var(--ink-2); font-size: 14px; border-radius: 0 8px 8px 0;
}
.md-body .md-pre {
  background: #22201c; color: #e8e0cf; padding: 14px 16px; border-radius: 9px;
  overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
}
.md-body code {
  background: #f2ece0; padding: 1px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: .88em; color: var(--accent);
}

.md-table-wrap { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--line); border-radius: 9px; }
.md-table { width: 100%; border-collapse: collapse; font-size: 13.2px; }
.md-table th {
  background: #f4eee1; padding: 9px 11px; text-align: left; font-weight: 700;
  color: var(--ink); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.md-table td { padding: 8px 11px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:nth-child(even) td { background: #fdfbf6; }

.md-block { border-radius: 10px; margin: 1.3em 0; border: 1px solid; overflow: hidden; }
.md-block-head {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px;
  font-weight: 700; font-size: 14.5px; font-family: var(--serif); letter-spacing: .5px;
}
.md-block-icon { font-size: 16px; }
.md-block-title { flex: 1; }
.md-block-body { padding: 4px 18px 16px; font-size: 14px; }
.md-answer-summary {
  padding: 6px 18px 12px; cursor: pointer; font-size: 12.5px;
  color: var(--ink-3); list-style: none;
}
.md-answer-summary::-webkit-details-marker { display: none; }

.md-guide { border-color: #cfe0ec; background: var(--info-bg); }
.md-guide .md-block-head { background: #dfeaf3; color: var(--info); }
.md-keypoint { border-color: #cfe4d3; background: var(--ok-bg); }
.md-keypoint .md-block-head { background: #dcecdf; color: var(--ok); }
.md-chart { border-color: #e2d3ee; background: #faf6fd; }
.md-chart .md-block-head { background: #ece0f5; color: #6b3f8f; }
.md-exercise { border-color: #ecdcb6; background: var(--warn-bg); }
.md-exercise .md-block-head { background: #f7ecd2; color: var(--warn); }
.md-answer { border-color: var(--line); background: #f4f2ed; }
.md-answer .md-block-head { background: #e8e4dc; color: var(--ink-2); }
.md-books { border-color: #e3d5c3; background: #fdf8f0; }
.md-books .md-block-head { background: #f0e5d4; color: #7a5a2c; }
.md-warning { border-color: #eccfcf; background: var(--bad-bg); }
.md-warning .md-block-head { background: #f5dede; color: var(--bad); }
.md-case { border-color: #cfe7e4; background: #f1fbfa; }
.md-case .md-block-head { background: #d9eeeb; color: #1f6b63; }

.chapter-header {
  padding: 22px 26px; border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, #fffdf8, #faf6ee);
}
.chapter-header h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: 1.5px; }
.chapter-header .chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.chapter-body { padding: 8px 26px 30px; }

.toc-box {
  position: sticky; top: 78px; width: 210px; flex: 0 0 210px;
  max-height: calc(100vh - 100px); overflow-y: auto; font-size: 12.5px;
}
.toc-box a {
  display: block; padding: 4px 9px; color: var(--ink-3); border-left: 2px solid var(--line);
  text-decoration: none; line-height: 1.5;
}
.toc-box a:hover { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }
.toc-box a.lv3 { padding-left: 20px; font-size: 12px; }

/* ---------------------------- 图表页 ---------------------------- */

.chart-item { border-bottom: 1px solid var(--line-2); padding-bottom: 26px; margin-bottom: 26px; }
.chart-item:last-child { border-bottom: none; }
.chart-title {
  font-family: var(--serif); font-size: 19px; margin: 0 0 6px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.chart-id {
  font-family: var(--mono); font-size: 11.5px; background: var(--accent); color: #fff;
  padding: 2px 8px; border-radius: 4px;
}
.chart-desc { color: var(--ink-2); font-size: 13.5px; margin: 0 0 12px; }
.chart-note {
  margin-top: 12px; padding: 11px 15px; background: #fdf6e6;
  border: 1px solid #ecdcb6; border-radius: 8px; font-size: 13px; color: #7a5a10; line-height: 1.75;
}
.chart-note b, .chart-note strong { color: var(--bad); }

/* ---------------------------- 图表索引（标题 + 概述） ---------------------------- */

.idx-group { margin-bottom: 26px; }
.idx-group:last-child { margin-bottom: 6px; }
.idx-group-title {
  font-family: var(--serif); font-size: 16px; color: var(--accent);
  margin: 0 0 10px; padding-left: 10px; border-left: 4px solid var(--gold);
  display: flex; align-items: baseline; gap: 10px;
}
.idx-group-count { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
.idx-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 9px; }
.idx-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 9px;
  text-decoration: none; color: inherit; transition: all .15s; min-width: 0;
}
.idx-item:hover {
  background: #fffdf8; border-color: var(--gold-l); text-decoration: none;
  box-shadow: var(--shadow); transform: translateY(-1px);
}
.idx-item .chart-id { flex: 0 0 auto; margin-top: 2px; }
.idx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.idx-name { font-family: var(--serif); font-size: 14.5px; font-weight: 700; color: var(--ink); line-height: 1.5; }
.idx-item:hover .idx-name { color: var(--accent); }
.idx-desc { font-size: 12.3px; color: var(--ink-3); line-height: 1.6; }
.idx-imp { flex: 0 0 auto; font-size: 11px; color: var(--gold); white-space: nowrap; margin-top: 3px; }

.idx-back { margin-bottom: 14px; }
@media (max-width: 640px) { .idx-list { grid-template-columns: 1fr; } }

.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.ref-table th {
  background: #f4eee1; padding: 8px 10px; text-align: left; font-weight: 700;
  border: 1px solid var(--line); white-space: nowrap; color: var(--ink);
}
.ref-table td { padding: 7px 10px; border: 1px solid var(--line-2); vertical-align: top; }
.ref-table tbody tr:nth-child(even) td { background: #fdfbf6; }
.ref-table .hl { background: #fdf3f3 !important; font-weight: 700; color: var(--accent); }
.c-shi { color: var(--accent); font-weight: 700; }
.c-ying { color: var(--info); font-weight: 700; }
.najia-cell { text-align: left; }
.najia-unit {
  display: inline-block; margin: 2px 8px 2px 0; font-family: var(--serif);
  font-size: 12.5px; white-space: nowrap;
}
.najia-unit em { font-style: normal; font-size: 11px; color: var(--ink-3); margin-left: 3px; }
.palace-block { margin-bottom: 20px; }
.palace-title {
  font-family: var(--serif); font-size: 15.5px; color: var(--accent);
  margin: 14px 0 7px; padding-left: 9px; border-left: 4px solid var(--gold);
}
.sub-h { font-family: var(--serif); font-size: 15px; margin: 16px 0 8px; color: var(--ink); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.sk-tip { font-size: 12.8px; color: var(--ink-3); margin: 9px 0 0; line-height: 1.7; }

.shengke-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .shengke-grid { grid-template-columns: 1fr; } }
.sk-card { background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
.sk-card h4 { margin: 0 0 12px; font-size: 14.5px; color: var(--accent); }
.sk-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.wx {
  display: inline-block; padding: 5px 12px; border-radius: 7px;
  font-family: var(--serif); font-weight: 700; font-size: 14px; color: #fff;
}
.wx-mu { background: #2f6b3f; } .wx-huo { background: #a02a2a; } .wx-tu { background: #8a6a30; }
.wx-jin { background: #9a8a1a; } .wx-shui { background: #2c5a7a; }
.arw { color: var(--gold); font-weight: 700; }

.wuxing-wheel { margin-bottom: 16px; }
.ww-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.ww-item {
  padding: 12px 14px; border-radius: 9px; background: var(--card-2);
  border: 1px solid var(--line); border-left: 4px solid;
}
.ww-item .ww-name { font-family: var(--serif); font-size: 21px; font-weight: 700; display: block; }
.ww-item small { color: var(--ink-3); font-size: 11.8px; line-height: 1.6; display: block; margin-top: 3px; }
.ww-item.wx-mu { border-left-color: #2f6b3f; } .ww-item.wx-huo { border-left-color: #a02a2a; }
.ww-item.wx-tu { border-left-color: #8a6a30; } .ww-item.wx-jin { border-left-color: #9a8a1a; }
.ww-item.wx-shui { border-left-color: #2c5a7a; }
.ww-item .ww-name.wx-mu { color: #2f6b3f; } .ww-item .ww-name.wx-huo { color: #a02a2a; }
.ww-item .ww-name.wx-tu { color: #8a6a30; } .ww-item .ww-name.wx-jin { color: #9a8a1a; }
.ww-item .ww-name.wx-shui { color: #2c5a7a; }

.wx-wang { color: #a02a2a; font-weight: 700; }
.wx-xiang { color: #a8791f; font-weight: 700; }
.wx-xiu { color: var(--ink-2); }
.wx-qiu { color: var(--ink-3); }
.wx-si { color: #b0a898; }

/* ---------------------------- 自测 ---------------------------- */

.quiz-item {
  border: 1px solid var(--line); border-radius: 9px; padding: 15px 17px;
  margin-bottom: 13px; background: var(--card-2);
}
.quiz-q { font-weight: 600; margin-bottom: 11px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.quiz-opts { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
  background: var(--card); font-size: 13.5px; transition: all .14s;
}
.quiz-opt:hover { border-color: var(--gold-l); background: #fdfaf3; }
.quiz-opt input { margin: 0; cursor: pointer; }
.quiz-opt.right { background: var(--ok-bg); border-color: #9ecfa9; }
.quiz-opt.wrong { background: var(--bad-bg); border-color: #e0a5a5; }
.quiz-explain {
  margin-top: 11px; padding: 10px 13px; background: #eef4f9;
  border-left: 3px solid var(--info); border-radius: 0 7px 7px 0;
  font-size: 12.8px; color: var(--ink-2); white-space: pre-wrap; line-height: 1.75;
}
.quiz-score {
  text-align: center; padding: 22px; background: var(--card-2);
  border-radius: 10px; border: 1px solid var(--line); margin-bottom: 18px;
}
.quiz-score .big { font-size: 42px; font-family: var(--serif); font-weight: 700; color: var(--accent); }

/* ---------------------------- 记录 ---------------------------- */

.rec-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
  background: var(--card-2); font-size: 13px;
}
.rec-item .r-main { flex: 1; min-width: 0; }
.rec-item .r-q { font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.rec-item .r-m { font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------- 其他 ---------------------------- */

.empty {
  text-align: center; padding: 44px 20px; color: var(--ink-3); font-size: 13.5px;
}
.empty .big { font-size: 36px; display: block; margin-bottom: 12px; opacity: .5; }
.loading { text-align: center; padding: 30px; color: var(--ink-3); font-size: 13px; }
.spin {
  display: inline-block; width: 15px; height: 15px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: -2px; margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2a251e; color: #f0e6d2; padding: 11px 22px; border-radius: 9px;
  font-size: 13.5px; opacity: 0; transition: all .28s; z-index: 200; pointer-events: none;
  box-shadow: var(--shadow-lg); max-width: 78vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #6b1a1a; }
.toast.ok { background: #23502f; }

.search-box {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card-2); margin-bottom: 10px;
}
.search-box:focus { outline: none; border-color: var(--gold-l); }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill {
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card-2); font-size: 12.3px; cursor: pointer; color: var(--ink-2);
  transition: all .15s;
}
.pill:hover { border-color: var(--gold-l); color: var(--accent); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat {
  text-align: center; padding: 13px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: 9px;
}
.stat .v { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--accent); }
.stat .l { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

@media (max-width: 980px) {
  .layout { flex-direction: column; padding: 14px; }
  .side, .toc-box { width: 100%; flex: 1 1 auto; position: static; max-height: none; }
  .topbar { padding: 0 12px; gap: 10px; overflow-x: auto; }
  .topbar .brand span.txt { display: none; }
  .chapter-body, .chapter-header { padding-left: 16px; padding-right: 16px; }
}
