/* 知时 · 新中式雅致（宣纸 · 墨色 · 朱砂）
   原创离线排盘界面样式：仅使用系统字体与 CSS 绘制，无远程字体/图片/脚本。 */
:root {
  /* 纸与墨 */
  --bg-a: #faf6ec;
  --bg-b: #f1ebdd;
  --card: #fffdf8;
  --paper-soft: #f7f2e6;
  --ink: #2f3733;
  --ink-soft: #4a534d;
  --muted: #6f695d;          /* 1.2.1 加深：小字对比度 ≥ 4.5:1 */
  --line: #e3dccd;
  --line-soft: #efe9dd;
  --line-strong: #d3c8b3;
  --green-line: #d5e0d6;
  --red-line: #ecd2cb;
  --amber-line: #e5d5b1;
  --header-a: rgba(250, 246, 236, 0.97);
  --header-b: rgba(250, 246, 236, 0.82);
  --glass: rgba(255, 253, 248, 0.65);
  --nav-bg: rgba(252, 249, 241, 0.96);
  --hero-b: #f9f4e8;
  --on-primary: #fffaf2;
  /* 五行色（1.2.1） */
  --wx-mu: #3f7a4f;
  --wx-huo: #b23b2a;
  --wx-tu: #8a6428;
  --wx-jin: #a08218;
  --wx-shui: #2f5f8a;
  /* 朱砂 */
  --primary: #a5523f;
  --primary-deep: #853d2f;
  --primary-soft: #f3e6dd;
  --seal: #a5523f;
  --pink: #a5523f;
  --pink-soft: #f3e6dd;
  /* 辅助色：黛青 / 赭 / 藤黄 */
  --green: #4a6b57;
  --green-soft: #e8eee6;
  --red: #a5382a;
  --red-soft: #f7e5e0;
  --amber: #8a6428;
  --amber-soft: #f6ecd7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 6px 18px rgba(92, 74, 48, 0.07);
  --shadow-sm: 0 1px 2px rgba(64, 52, 38, 0.05);
  --serif: "Songti SC", "STSong", "SimSun", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  /* 宣纸底：两处极淡晕染 + 细密纸纹，全部由 CSS 生成 */
  background-color: var(--bg-a);
  background-image:
    radial-gradient(120% 70% at 100% 0%, rgba(165, 82, 63, 0.06) 0%, rgba(165, 82, 63, 0) 55%),
    radial-gradient(90% 60% at 0% 45%, rgba(74, 107, 87, 0.05) 0%, rgba(74, 107, 87, 0) 60%),
    radial-gradient(circle at 20% 80%, rgba(227, 220, 205, 0.55) 0%, rgba(227, 220, 205, 0) 40%),
    linear-gradient(168deg, var(--bg-a) 0%, var(--bg-b) 100%);
  background-attachment: fixed;
}

.noscript-note { margin: 16px; padding: 12px 16px; background: var(--red-soft); color: var(--red); border-radius: var(--radius-sm); }

.shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 10px;
  background: linear-gradient(180deg, var(--header-a), var(--header-b));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--seal);
  color: #fffaf2;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  font-weight: 500;
  border-radius: 2px;
}
/* 印章细边：与实体印章一致的双层框 */
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255, 250, 242, 0.55);
  border-radius: 1px;
  pointer-events: none;
}
.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 4px;
  font-weight: 600;
}
.brand-text p { margin: 1px 0 0; font-size: 13px; color: var(--muted); letter-spacing: 1.2px; }

.pill {
  flex: none;
  padding: 3px 11px;
  border-radius: 2px;
  font-size: 13px;
  letter-spacing: 0.4px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}
.pill-wait { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.pill-ok { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.pill-err { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }

/* ---------- 卡片与页面 ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
}
.page-title {
  margin: 10px 0 4px;
  font-family: var(--serif);
  font-size: 25px;
  letter-spacing: 3px;
  font-weight: 600;
}
.page-title::after {
  content: "";
  display: block;
  width: 34px;
  height: 2px;
  margin-top: 8px;
  background: var(--seal);
}

/* 页眉小标题（card h3） */
.card h3 {
  font-family: var(--serif);
  letter-spacing: 1.5px;
  font-weight: 600;
}
.card h3::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 8px;
  vertical-align: 3px;
  background: var(--seal);
  transform: rotate(45deg);
}

/* ---------- 首页 hero ---------- */
.hero {
  overflow: hidden;
  padding: 26px 22px 24px;
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(165, 82, 63, 0.08) 0%, rgba(165, 82, 63, 0) 60%),
    linear-gradient(180deg, var(--card) 0%, var(--hero-b) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}
/* 右侧淡墨山影 */
.hero::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -46px;
  width: 190px;
  height: 130px;
  background:
    radial-gradient(60% 100% at 12% 100%, rgba(74, 107, 87, 0.16) 0%, rgba(74, 107, 87, 0) 70%),
    radial-gradient(70% 100% at 52% 100%, rgba(47, 55, 51, 0.1) 0%, rgba(47, 55, 51, 0) 70%),
    radial-gradient(80% 100% at 88% 100%, rgba(165, 82, 63, 0.1) 0%, rgba(165, 82, 63, 0) 72%);
  pointer-events: none;
}
.hero-kicker {
  position: relative;
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 2.6px;
  color: var(--muted);
}
.hero h2 {
  position: relative;
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.35;
  letter-spacing: 8px;
  font-weight: 600;
}
.hero h2::after {
  content: "";
  display: block;
  width: 100%;
  max-width: 150px;
  height: 1px;
  margin-top: 12px;
  background: linear-gradient(90deg, var(--seal), rgba(165, 82, 63, 0.05));
}
.hero-sub { position: relative; margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.85; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-chips span {
  padding: 2px 10px;
  border-radius: 2px;
  background: var(--glass);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 首页入口 ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
.entry-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin: 0;
  padding: 16px 15px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.entry-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.entry-card:active { transform: translateY(0); }
.entry-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-soft);
  color: var(--primary-deep);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1;
}
.entry-card:nth-child(2) .entry-icon { background: var(--primary-soft); border-color: var(--red-line); }
.entry-card:nth-child(3) .entry-icon { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.entry-card:nth-child(4) .entry-icon { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.entry-card strong {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 1.6px;
  font-weight: 600;
}
.entry-card small { margin-top: 3px; font-size: 13px; line-height: 1.6; color: var(--muted); }

.runtime-card h3 { margin: 0 0 6px; font-size: 15px; }
.runtime-card p { margin: 0; font-size: 14px; }
.field-hint { margin: 6px 0; font-size: 13px; line-height: 1.75; color: var(--muted); }
.muted-note { margin: 12px 2px; font-size: 13px; line-height: 1.8; color: var(--muted); }

/* ---------- 表单 ---------- */
.form-card h3 { margin: 0 0 8px; font-size: 17px; }
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 10px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; letter-spacing: 0.6px; color: var(--muted); }
.field input[type="text"],
.field input:not([type]),
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--card);
  box-shadow: 0 0 0 3px rgba(165, 82, 63, 0.1);
}
.field input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }

.mode-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 14px 0 6px;
  padding: 12px 14px;
  border: 0;
  border-left: 2px solid var(--seal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--paper-soft);
}
.mode-group legend {
  display: block;
  padding: 0;
  margin-bottom: 8px;
  font-size: 13px;
  letter-spacing: 1.4px;
  color: var(--muted);
}
.mode-group label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-soft); }
.mode-group input { accent-color: var(--primary); }

details.form-card { cursor: pointer; padding-top: 16px; }
details.form-card summary {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 1.2px;
  font-weight: 600;
  color: var(--primary-deep);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.form-card summary::-webkit-details-marker { display: none; }
details.form-card summary::before {
  content: "＋";
  color: var(--primary);
  font-weight: 600;
  font-family: var(--serif);
}
details.form-card[open] summary::before { content: "－"; }
details.form-card .field-grid { margin-top: 12px; }

.form-error {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-size: 14px;
  white-space: pre-wrap;
}
.form-note {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13.5px;
}

/* ---------- 按钮 ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.btn {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 3px;
  padding: 12px 22px;
  box-shadow: 0 4px 12px rgba(165, 82, 63, 0.16);
}
.btn-primary:hover { background: var(--primary-deep); }
.btn-ghost { background: transparent; color: var(--primary-deep); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--paper-soft); }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: var(--red-line); }
.btn-danger-ghost:hover { background: var(--red-soft); }

/* ---------- 结果区 ---------- */
#result-card { padding: 15px; }
#result-toolbar { display: flex; flex-direction: column; gap: 10px; }
.candidate-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  -webkit-overflow-scrolling: touch;
}
.cand-tab {
  flex: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  letter-spacing: 0.6px;
  cursor: pointer;
}
.cand-tab.is-active {
  background: var(--primary-soft);
  border-color: var(--line-strong);
  color: var(--primary-deep);
  font-weight: 600;
}
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-actions .btn { padding: 8px 14px; font-size: 13px; letter-spacing: 0.6px; }

.cand-header { margin: 16px 0 8px; }
.cand-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 2px;
}
.cand-header p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

.pillar-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.pillar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--card), var(--paper-soft));
}
.pillar-label { font-size: 13px; letter-spacing: 2px; color: var(--muted); }
.pillar-gz {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--ink);
}
.pillar-gz.missing { font-size: 13px; color: var(--muted); letter-spacing: 0; font-family: inherit; }

.section-title {
  margin: 26px 0 10px;
  padding-left: 12px;
  border-left: 2px solid var(--seal);
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 2px;
  font-weight: 600;
}
.section-note { margin: 8px 0; font-size: 13px; line-height: 1.7; color: var(--muted); }

.table-scroll {
  margin: 10px 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 9px 5px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.data-table th {
  font-family: var(--serif);
  color: var(--primary-deep);
  font-size: 13px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table tr.row-current td { background: var(--green-soft); }
.data-table tr.row-maybe td { background: var(--amber-soft); }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 2px;
  font-size: 13px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag-good { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.tag-bad { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.tag-mid { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.tag-plain { background: var(--paper-soft); color: var(--muted); border-color: var(--line); }

.shensha-item {
  margin: 12px 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
}
.shensha-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.shensha-head strong { font-family: var(--serif); font-size: 16px; letter-spacing: 1.4px; }
.shensha-pos { margin: 6px 0 2px; font-size: 14px; }
.shensha-rule { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.shensha-src { margin: 0; font-size: 13px; color: var(--muted); }
.shensha-src details { margin-top: 4px; }
.shensha-src summary { font-size: 13px; color: var(--primary-deep); cursor: pointer; }
.warn-list { margin: 8px 0; padding-left: 20px; }
.warn-list li { margin: 4px 0; font-size: 13px; }
.kv-line { margin: 5px 0; font-size: 13.5px; }
.kv-line strong { color: var(--primary-deep); font-weight: 600; }
.empty-box {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 13px;
}
.result-note {
  margin: 18px 0 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

/* ---------- 档案 ---------- */
.archive-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.archive-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  border-left: 2px solid var(--seal);
}
.archive-info strong { font-family: var(--serif); font-size: 16px; letter-spacing: 1px; }
.archive-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.archive-actions { display: flex; gap: 8px; }
.archive-actions .btn { padding: 7px 14px; font-size: 13px; }
.empty-note {
  margin: 20px 0;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 1px;
  background: var(--glass);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- 我的 ---------- */
.plain-list { margin: 6px 0 0; padding-left: 18px; }
.plain-list li { margin: 7px 0; font-size: 13.5px; line-height: 1.8; }
#page-mine .card h3 { margin: 0 0 8px; font-size: 15.5px; }
#page-mine .card p { margin: 6px 0; font-size: 13.5px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  width: 100%;
  max-width: 540px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  gap: 4px;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  letter-spacing: 1.4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--primary-deep); }
.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 18px;
  height: 2px;
  background: var(--seal);
}

/* ---------- 桌面适配 ---------- */
@media (min-width: 640px) {
  .shell { max-width: 640px; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
  .result-actions .btn { font-size: 13.5px; }
  .tabbar { max-width: 640px; }
}
@media (min-width: 960px) {
  .shell { max-width: 860px; }
  .hero { padding: 30px 34px; }
  .grid-cards { grid-template-columns: repeat(4, 1fr); }
  .tabbar {
    max-width: 460px;
    bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    box-shadow: var(--shadow);
  }
  .tab.is-active { background: transparent; }
  .tab.is-active::before { top: -7px; }
  .archive-item { flex-direction: row; align-items: center; justify-content: space-between; }
  .result-actions { justify-content: flex-end; }
}

/* ---------- AI 深度解析面板 ---------- */
#ai-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
#ai-panel h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--primary-deep);
}
#ai-panel h3::before { content: none; }
.ai-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ai-head .tag { align-self: flex-start; }
.ai-key-block { margin: 10px 0; }
.ai-key-note {
  margin: 4px 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
}
.ai-key-note.ai-key-builtin { background: var(--red-soft); color: var(--red); border-left-color: var(--red-line); }
.ai-key-block .field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  font: inherit;
  font-size: 15px;
}
.ai-context-block { margin: 10px 0; }
.ai-context-pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-inputs { margin: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.ai-inputs .field textarea,
.ai-followup .field textarea {
  width: 100%;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
}
.ai-inputs .field textarea:focus,
.ai-followup .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(165, 82, 63, 0.1);
}
.ai-count { align-self: flex-end; font-size: 13px; color: var(--muted); }
.ai-compose-block { margin: 10px 0; }
.ai-consent-block { margin: 12px 0; }
.ai-consent-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-soft); cursor: pointer; line-height: 1.7; }
.ai-consent-row input { flex: none; margin-top: 4px; width: 17px; height: 17px; accent-color: var(--primary); }
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.ai-actions .btn { padding: 9px 14px; font-size: 13.5px; letter-spacing: 0.6px; }
.ai-status {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
}
.ai-response { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ai-warn-note {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
}
.ai-meta-list { margin: 6px 0; padding-left: 18px; }
.ai-meta-list li { font-size: 13px; color: var(--muted); margin: 2px 0; }
.ai-md { font-size: 14px; line-height: 1.85; }
.ai-md h2 {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 1.6px;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.ai-md h3 { font-family: var(--serif); font-size: 16px; letter-spacing: 1.2px; margin: 16px 0 6px; color: var(--ink); }
.ai-md h4 { font-size: 14.5px; margin: 12px 0 4px; color: var(--ink); }
.ai-md p { margin: 7px 0; }
.ai-md-p { margin: 7px 0; }
.ai-md-list { margin: 6px 0; padding-left: 22px; }
.ai-md-list li { margin: 4px 0; }
.ai-md blockquote { margin: 10px 0; padding: 6px 12px; border-left: 2px solid var(--seal); color: var(--muted); background: var(--paper-soft); }
.ai-md pre.ai-md-code {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-md-table-wrap { max-width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ai-md-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13px; }
.ai-md-table th, .ai-md-table td { min-width: 130px; max-width: 340px; padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.ai-md-table th { background: var(--primary-soft); color: var(--primary-deep); font-family: var(--serif); letter-spacing: 0.8px; }
.ai-md-table tr:last-child td { border-bottom: 0; }
.ai-md hr { border: none; border-top: 1px dashed var(--line); margin: 14px 0; }
.ai-md-empty { padding: 12px; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--amber); font-size: 13px; }

/* 1.2.1 追问与思考深度 */
.ai-effort { margin: 10px 0; }
.ai-followup { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.ai-followup .btn { align-self: flex-start; }
.ai-turn-question { margin: 18px 0 4px; padding-top: 12px; border-top: 1px dashed var(--line); color: var(--primary); font-size: 15px; }


/* ================= 1.2.1 结果页：传统排盘格 ================= */
.ref-line { margin: 4px 0 12px; font-size: 14px; color: var(--ink-soft); }
.ref-label { display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 3px; background: var(--primary-soft); color: var(--primary-deep); font-size: 13px; }
.chart-grid {
  display: grid; grid-template-columns: 40px repeat(4, 1fr); gap: 6px;
  margin: 8px 0 4px; padding: 12px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card), var(--paper-soft));
}
.chart-col { display: grid; grid-template-rows: 22px 26px 112px auto; justify-items: center; align-items: center; text-align: center; min-width: 0; }
.chart-labels { grid-template-rows: 22px 26px 56px 56px auto; justify-items: start; color: var(--muted); font-size: 13px; }
.chart-labels .chart-label:first-child { grid-row: 2; }
.chart-labels .chart-label:nth-child(2) { grid-row: 3; }
.chart-labels .chart-label:nth-child(3) { grid-row: 4; }
.chart-labels .chart-label:nth-child(4) { grid-row: 5; align-self: start; padding-top: 6px; }
.chart-head { font-size: 13px; letter-spacing: 2px; color: var(--muted); }
.chart-god { font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; }
.chart-gz { display: grid; grid-template-rows: 56px 56px; align-items: center; font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; }
.chart-missing { grid-row: 3; font-size: 13px; color: var(--muted); }
.chart-hidden { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px dashed var(--line); width: 100%; align-items: center; font-size: 15px; }
.hidden-line { display: flex; gap: 4px; align-items: baseline; justify-content: center; }
.hidden-line small { font-size: 13px; color: var(--muted); }
.hidden-line.is-main { font-weight: 600; }
.wx-mu { color: var(--wx-mu); } .wx-huo { color: var(--wx-huo); } .wx-tu { color: var(--wx-tu); }
.wx-jin { color: var(--wx-jin); } .wx-shui { color: var(--wx-shui); }

.dayun-list { list-style: none; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dayun-item { display: flex; align-items: center; gap: 10px; white-space: nowrap; padding: 10px 12px; border-top: 1px solid var(--line-soft); background: var(--card); }
.dayun-item:first-child { border-top: 0; }
.dayun-item.is-current { background: var(--green-soft); }
.dayun-item.is-maybe { background: var(--amber-soft); }
.dayun-index { width: 18px; color: var(--muted); font-size: 13px; text-align: right; }
.dayun-gz { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: 2px; min-width: 56px; }
.dayun-years { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--ink); }
.dayun-age { font-size: 13px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.dayun-item .tag + .dayun-age, .dayun-age + .tag { margin-left: 0; }
.dayun-item .tag { margin-left: 4px; }

.relation-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.relation-chip { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; }
.relation-chip strong { color: var(--primary-deep); font-weight: 600; }
.relation-chip small { margin-left: 6px; color: var(--muted); font-size: 13px; }

.shensha-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
details.shensha-item { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); padding: 0 12px; box-shadow: none; }
details.shensha-item > summary { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; list-style: none; }
details.shensha-item > summary::-webkit-details-marker { display: none; }
details.shensha-item > summary .shensha-pos { margin: 0; color: var(--ink-soft); font-size: 14px; }
details.shensha-item > summary .tag { margin-left: auto; }
details.shensha-item[open] { padding-bottom: 8px; }
.shensha-rule, .shensha-src { margin: 4px 0; font-size: 13.5px; color: var(--ink-soft); }

details.fold { margin: 12px 0; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 0 12px; }
details.fold > summary { padding: 10px 0; cursor: pointer; color: var(--primary-deep); font-size: 14px; }
details.fold[open] { padding-bottom: 10px; }
details.fold .data-table { font-size: 13px; }

.warn-box { margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--amber); border-radius: var(--radius-sm); background: var(--amber-soft); }
.warn-box strong { color: var(--amber); }


/* ================= 1.2.1 今日卡 / 档案 / AI 预设 ================= */
.today-card { padding: 18px 20px; }
.today-card h3 { margin: 0 0 6px; }
.today-date { margin: 0; font-size: 13px; color: var(--muted); }
.today-gz { margin: 4px 0 8px; font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: 1px; }
.today-pillar small, .today-pillar { white-space: nowrap; }
.today-note { margin: 6px 0 10px; font-size: 14.5px; color: var(--ink-soft); line-height: 1.75; }
#today-card #home-runtime-text { margin: 6px 0 0; }

.save-form { margin: 10px 0 4px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--paper-soft); display: flex; flex-direction: column; gap: 8px; }
.save-form .field input, .save-form .field select { width: 100%; }
.archive-title { display: flex; align-items: center; gap: 8px; }
.archive-title strong { font-family: var(--serif); font-size: 17px; }
.archive-gz { margin: 4px 0 0; font-family: var(--serif); font-size: 18px; letter-spacing: 2px; color: var(--ink); }
.archive-item { flex-wrap: wrap; }
.archive-item .qa-fold { flex-basis: 100%; margin: 10px 0 0; }
.qa-item { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.qa-item:first-of-type { border-top: 0; }
.qa-q { margin: 0 0 4px; font-size: 14px; color: var(--ink); }
.qa-answer summary { font-size: 13px; color: var(--primary-deep); cursor: pointer; }
.qa-text { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-soft); max-height: 320px; overflow: auto; }
.qa-feedback { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 6px; }
.qa-feedback .qa-note { grid-column: 1 / -1; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.qa-feedback select { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.qa-feedback .btn { grid-column: 2; grid-row: 1; }

.ai-subject { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.ai-subject .field-hint { grid-column: 1 / -1; margin: 0; }
.ai-subject select, .ai-effort select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-soft); color: var(--ink); font: inherit; font-size: 14px; }
.ai-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-soft); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.preset-chip:hover { border-color: var(--primary); color: var(--primary-deep); }
.preset-chip:disabled { opacity: .5; cursor: not-allowed; }

/* ================= 1.2.1 深色模式（跟随系统） ================= */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-a: #1b1d1b;
    --bg-b: #161816;
    --card: #232623;
    --paper-soft: #2a2d29;
    --ink: #ece6da;
    --ink-soft: #cfc8ba;
    --muted: #a39c8e;
    --line: #3a3d38;
    --line-soft: #2f322e;
    --line-strong: #4a4d47;
    --primary: #d9826b;
    --primary-deep: #e9a08b;
    --primary-soft: #3a2723;
    --seal: #c4644f;
    --pink: #d9826b;
    --pink-soft: #3a2723;
    --green: #8fbf9c;
    --green-soft: #213026;
    --green-line: #2f4535;
    --red: #e58b7c;
    --red-soft: #3a2320;
    --red-line: #553029;
    --amber: #d9b26a;
    --amber-soft: #352c1c;
    --amber-line: #4f4126;
    --header-a: rgba(27, 29, 27, 0.97);
    --header-b: rgba(27, 29, 27, 0.85);
    --glass: rgba(35, 38, 35, 0.7);
    --nav-bg: rgba(30, 32, 30, 0.96);
    --hero-b: #1f221f;
    --on-primary: #1b1d1b;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --wx-mu: #7fbf8c;
    --wx-huo: #ec8a76;
    --wx-tu: #d2a868;
    --wx-jin: #dcc36a;
    --wx-shui: #7fb0dc;
  }
  body {
    background-image:
      radial-gradient(120% 70% at 100% 0%, rgba(217, 130, 107, 0.07) 0%, rgba(217, 130, 107, 0) 55%),
      linear-gradient(168deg, var(--bg-a) 0%, var(--bg-b) 100%);
  }
}
