/**
 * 紫微盘面样式（v4 专业版布局）。
 *
 * 信息密度参照专业排盘软件：一屏十二宫、每宫含宫名/干支/大限/主星亮度四化/
 * 辅煞杂曜/长生十二神/小限。为保证小屏可读，字号用 clamp 随容器缩放，
 * 手机端整体横滚（min-width），不压缩到看不清。
 */

.dawnin-ziwei-tool {
  /* 排版参数：后台「1.1 盘面字号与配色」与前台「显示设置」都改这些；
     这里给的是出厂默认，PHP 注入的同名变量会覆盖它。 */
  --zwch-base: 13px;        /* 盘面基准字号，整盘锚点 */
  --zwch-major: 1.12em;     /* 主星：原来 1.32em 太大，把辅星压成注释 */
  --zwch-minor: 0.98em;     /* 六吉六煞 */
  --zwch-adj: 0.90em;       /* 杂曜 */
  --zwch-bright: 0.78em;    /* 庙旺得利平陷 */
  --zwch-mut: 0.82em;       /* 禄权科忌方阵 */
  --zwch-name: 0.94em;      /* 宫名 */
  --zwch-meta: 0.74em;      /* 干支 / 大限 / 身宫 */
  --zwch-foot: 0.66em;      /* 长生·小限 */
  --zwch-fly: 0.70em;       /* 飞星标签 */
  --zwch-lh: 1.5;           /* 星曜行高 */
  --zwch-gap: 3px;          /* 星曜行间距 */
  --zwch-pad: 7px;          /* 宫格内边距 */
  /* 盘心信息、侧栏详解、图例说明：这三块是「读字」不是「看盘」，
     不跟盘面基准字号等比缩放（盘缩小时它们会缩到 9px 看不清），直接给像素。 */
  --zwch-aux: 13.5px;
  --zwch-name-color: #c9a96e;
  --zw-aux: #aab3c2;        /* 说明文字颜色（比 --zw-dim 亮一档） */

  --zw-line: rgba(201, 169, 110, 0.28);
  --zw-line-soft: rgba(201, 169, 110, 0.12);
  --zw-cell-bg: #0e1421;
  --zw-cell-bg2: #111828;
  --zw-major: #e8c98e;
  --zw-good: #7fc8b0;
  --zw-bad: #e0847a;
  --zw-neutral: #9aa3b2;
  --zw-dim: #8b95a6;
  --zw-lu: #46b884;
  --zw-quan: #b48ce0;
  --zw-ke: #6aa9e0;
  --zw-ji: #e0645b;
  --zw-self-bg: rgba(201, 169, 110, 0.13);
  --zw-opp-bg: rgba(106, 169, 224, 0.10);
  --zw-san-bg: rgba(127, 200, 176, 0.09);
}

/* ---------- 工具条 ---------- */
.dawnin-ziwei-tool .zw-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ---------- 运限选择器：大限 / 流年 / 流月 ---------- */
.dawnin-ziwei-tool .zw-flow-picker {
  margin: 0 0 12px;
  border: 1px solid var(--zw-line-soft);
  background: rgba(255, 255, 255, 0.015);
}

.dawnin-ziwei-tool .zw-frow {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--zw-line-soft);
}
.dawnin-ziwei-tool .zw-frow:last-child { border-bottom: none; }

/* 行首的「大限/流年/流月」用三种颜色，和宫格里的叠宫标签对上 */
.dawnin-ziwei-tool .zw-flabel {
  flex: 0 0 auto;
  width: 3em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--zwch-aux) * 0.78);
  letter-spacing: 0.06em;
  border-right: 1px solid var(--zw-line-soft);
  background: rgba(255, 255, 255, 0.02);
}
.dawnin-ziwei-tool .zw-flabel.decadal { color: #b48ce0; }
.dawnin-ziwei-tool .zw-flabel.yearly { color: #e0a860; }
.dawnin-ziwei-tool .zw-flabel.monthly { color: #6ec5a8; }

.dawnin-ziwei-tool .zw-fchips {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.dawnin-ziwei-tool .zw-fchips::-webkit-scrollbar { display: none; }

/* 选项多到装不下时，两侧给一对翻页箭头（否则滚动条是隐形的，
   桌面用户没法把后面的大限拨出来）。不溢出时箭头整体不占位。 */
.dawnin-ziwei-tool .zw-fscroll {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
}
.dawnin-ziwei-tool .zw-farrow {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  padding: 0;
  border: none;
  background: none;
  color: var(--zw-dim);
  font: inherit;
  font-size: calc(var(--zwch-aux) * 1.2);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}
.dawnin-ziwei-tool .zw-fscroll.is-scroll .zw-farrow { display: flex; }
.dawnin-ziwei-tool .zw-farrow.prev { border-right: 1px solid var(--zw-line-soft); }
.dawnin-ziwei-tool .zw-farrow.next { border-left: 1px solid var(--zw-line-soft); }
.dawnin-ziwei-tool .zw-farrow:hover:not(:disabled) {
  color: var(--gold-bright);
  background: rgba(255, 255, 255, 0.05);
}
.dawnin-ziwei-tool .zw-farrow:disabled { opacity: 0.22; cursor: default; }

/* 还有内容的那一侧做一点渐隐，免得选项被硬切掉半个字 */
.dawnin-ziwei-tool .zw-fscroll.is-scroll .zw-fchips {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}
.dawnin-ziwei-tool .zw-fscroll.is-scroll.at-start .zw-fchips {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
}
.dawnin-ziwei-tool .zw-fscroll.is-scroll.at-end .zw-fchips {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
}
.dawnin-ziwei-tool .zw-fscroll.is-scroll.at-start.at-end .zw-fchips {
  -webkit-mask-image: none;
  mask-image: none;
}

/* 宽屏不横滚，直接换行排下去：十二个大限一眼全在，不用翻 */
@media (min-width: 601px) {
  .dawnin-ziwei-tool .zw-fchips {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 1px;
  }
}

/* 面板太窄、换行要堆三四行时，JS 加这个类退回单行横滚 + 箭头 */
.dawnin-ziwei-tool .zw-picker-scroll .zw-fchips {
  flex-wrap: nowrap;
  overflow-x: auto;
}

.dawnin-ziwei-tool .zw-fchip {
  flex: 0 0 auto;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: none;
  color: var(--zw-aux);
  font: inherit;
  font-size: calc(var(--zwch-aux) * 0.82);
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.dawnin-ziwei-tool .zw-fchip:hover { color: var(--gold-bright); }
.dawnin-ziwei-tool .zw-fchip.active {
  background: rgba(201, 169, 110, 0.16);
  border-color: rgba(201, 169, 110, 0.55);
  color: var(--gold-bright);
}
.dawnin-ziwei-tool .zw-fchip[data-kind="natal"].active {
  background: rgba(201, 169, 110, 0.24);
  border-color: var(--gold);
}
/* 「本命」是被 pickerRow 单独放在滚动区外的，这里只给它一点右侧分隔 */
.dawnin-ziwei-tool .zw-fchip[data-kind="natal"] {
  margin: 4px 2px 4px 8px;
  border-color: var(--zw-line-soft);
}
.dawnin-ziwei-tool .zw-fchip[data-kind="natal"].active { border-color: var(--gold); }

.dawnin-ziwei-tool .zw-fempty {
  font-size: calc(var(--zwch-aux) * 0.8);
  color: var(--zw-dim);
  padding: 2px;
}

.dawnin-ziwei-tool .zw-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: calc(var(--zwch-aux) * 0.9);
  color: var(--zw-aux);
  cursor: pointer;
  user-select: none;
}

.dawnin-ziwei-tool .zw-switch input { accent-color: #c9a96e; width: 14px; height: 14px; }

.dawnin-ziwei-tool .zw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  margin-left: auto;
  font-size: calc(var(--zwch-aux) * 0.88);
  color: var(--zw-aux);
}

.dawnin-ziwei-tool .zw-legend i {
  display: inline-flex;
  width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  font-style: normal;
  font-size: 0.66rem;
  color: #0b0f18;
  font-weight: 700;
}

.dawnin-ziwei-tool .zw-hint {
  font-size: calc(var(--zwch-aux) * 0.9);
  color: var(--zw-aux);
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

/* ---------- 盘面 ---------- */
.dawnin-ziwei-tool .zw-chart-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dawnin-ziwei-tool .zw-chart {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, auto);
  gap: 1px;
  background: var(--zw-line);
  border: 1px solid var(--zw-line);
  /* 高度不能用 aspect-ratio 锁死：那等于给它一个确定高度，行高 auto 也不会长，
     字号一调大就被 overflow:hidden 裁掉。改成 JS 按「宽度 / 内容所需高度」取大值
     写到 min-height（见 assets/ziwei-style.js fitCharts），这里只留无 JS 时的兜底。 */
  align-content: stretch;
  min-height: 620px;
  min-width: 680px;
  max-width: 860px;
  margin: 0 auto;
  font-size: var(--zwch-base);
  transition: opacity 0.2s;
}

.dawnin-ziwei-tool .zw-cell {
  position: relative;
  background: var(--zw-cell-bg);
  padding: var(--zwch-pad);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.18s, opacity 0.18s, box-shadow 0.18s;
}

.dawnin-ziwei-tool .zw-cell:nth-child(even) { background: var(--zw-cell-bg2); }
.dawnin-ziwei-tool .zw-cell:hover { background: #16203300; background-color: rgba(201, 169, 110, 0.07); }

/* 本命特殊宫位 */
.dawnin-ziwei-tool .zw-cell.is-ming { box-shadow: inset 0 0 0 1px rgba(201, 169, 110, 0.55); }
/* 选中态：本宫 / 对宫 / 三方 */
.dawnin-ziwei-tool .zw-cell.sel-self {
  background-color: var(--zw-self-bg);
  box-shadow: inset 0 0 0 1.5px var(--gold);
  z-index: 2;
}
.dawnin-ziwei-tool .zw-cell.sel-opposite {
  background-color: var(--zw-opp-bg);
  box-shadow: inset 0 0 0 1px rgba(106, 169, 224, 0.55);
  z-index: 2;
}
.dawnin-ziwei-tool .zw-cell.sel-sanfang {
  background-color: var(--zw-san-bg);
  box-shadow: inset 0 0 0 1px rgba(127, 200, 176, 0.42);
  z-index: 2;
}
.dawnin-ziwei-tool .zw-cell.dim { opacity: 0.45; filter: saturate(0.8); }
.dawnin-ziwei-tool .zw-cell.fly-target::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(180, 140, 224, 0.75);
  pointer-events: none;
  z-index: 3;
}

/* 三层运限的「命宫」标记。用 inset 阴影而不是 outline：
   Zibll 主题里有 *{outline:0 !important}，outline 一律看不见。
   三种颜色叠加时按 svg 顺序套娃，绿色最外层，越具体越靠外。 */
.dawnin-ziwei-tool .zw-cell.is-flow-decadal { box-shadow: inset 0 0 0 2px rgba(180, 140, 224, 0.85); }
.dawnin-ziwei-tool .zw-cell.is-flow-yearly { box-shadow: inset 0 0 0 2px rgba(224, 168, 96, 0.9); }
.dawnin-ziwei-tool .zw-cell.is-flow-monthly { box-shadow: inset 0 0 0 2px rgba(110, 197, 168, 0.95); }
.dawnin-ziwei-tool .zw-cell.is-flow-decadal.is-flow-yearly {
  box-shadow: inset 0 0 0 2px rgba(180, 140, 224, 0.85), inset 0 0 0 4px rgba(224, 168, 96, 0.9);
}
.dawnin-ziwei-tool .zw-cell.is-flow-decadal.is-flow-monthly {
  box-shadow: inset 0 0 0 2px rgba(180, 140, 224, 0.85), inset 0 0 0 4px rgba(110, 197, 168, 0.95);
}
.dawnin-ziwei-tool .zw-cell.is-flow-yearly.is-flow-monthly {
  box-shadow: inset 0 0 0 2px rgba(224, 168, 96, 0.9), inset 0 0 0 4px rgba(110, 197, 168, 0.95);
}
.dawnin-ziwei-tool .zw-cell.is-flow-decadal.is-flow-yearly.is-flow-monthly {
  box-shadow: inset 0 0 0 2px rgba(180, 140, 224, 0.85), inset 0 0 0 4px rgba(224, 168, 96, 0.9), inset 0 0 0 6px rgba(110, 197, 168, 0.95);
}
.dawnin-ziwei-tool .zw-cell.is-decadal::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px dashed rgba(180, 140, 224, 0.55);
  pointer-events: none;
  z-index: 3;
}

/* 宫头 */
.dawnin-ziwei-tool .zw-cell-head {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: space-between;
}

.dawnin-ziwei-tool .zw-name {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--zwch-name);
  color: var(--zwch-name-color);
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.dawnin-ziwei-tool .zw-cell.is-ming .zw-name { color: var(--gold-bright); font-weight: 700; }
/* 宫名与运限标签挤在一行时会互相顶：允许换行，宁可两行也不压字 */
.dawnin-ziwei-tool .zw-cell-head { flex-wrap: wrap; row-gap: 2px; }

/* 叠宫标签：大命 / 流官 / 月财 —— 三层各一个色，顺序与选择器一致 */
.dawnin-ziwei-tool .zw-flow-tags {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 3px;
  margin-left: auto;
}
.dawnin-ziwei-tool .zw-ftag {
  font-size: max(8.5px, calc(var(--zwch-foot) * 0.96));
  line-height: 1.4;
  padding: 0 3px;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.dawnin-ziwei-tool .zw-ftag.decadal {
  color: #b48ce0;
  background: rgba(180, 140, 224, 0.1);
  border-color: rgba(180, 140, 224, 0.45);
}
.dawnin-ziwei-tool .zw-ftag.yearly {
  color: #e0a860;
  background: rgba(224, 168, 96, 0.1);
  border-color: rgba(224, 168, 96, 0.45);
}
.dawnin-ziwei-tool .zw-ftag.monthly {
  color: #6ec5a8;
  background: rgba(110, 197, 168, 0.1);
  border-color: rgba(110, 197, 168, 0.45);
}

/* 干支与大限 */
.dawnin-ziwei-tool .zw-cell-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  /* max() 下限：手机端整盘缩到 9px 基准时，0.8em 的干支只剩 7px，糊成一团。
     给 9px 地板，宁可略大于比例也不让它不可读。 */
  font-size: max(9px, var(--zwch-meta));
  color: var(--zw-dim);
  line-height: 1.4;
}

.dawnin-ziwei-tool .zw-gz { letter-spacing: 0.08em; }
.dawnin-ziwei-tool .zw-tag.shen {
  color: var(--zw-ji);
  border: 1px solid rgba(224, 100, 91, 0.4);
  border-radius: 2px;
  padding: 0 2px;
}
.dawnin-ziwei-tool .zw-dec { margin-left: auto; color: rgba(201, 169, 110, 0.65); }

/* 星曜 */
.dawnin-ziwei-tool .zw-stars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--zwch-gap);
  min-height: 0;
  padding-top: 1px;
}

.dawnin-ziwei-tool .zw-star {
  display: inline-flex;
  align-items: center;      /* 改成 center：亮度与四化方块不再相对字顶上下漂 */
  gap: 3px;
  line-height: var(--zwch-lh);
  white-space: nowrap;
  min-width: 0;
}

.dawnin-ziwei-tool .zw-star.is-block { flex: 0 0 auto; width: 100%; }

.dawnin-ziwei-tool .zw-star.major .zw-sname {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--zwch-major);
  font-weight: 700;
  color: var(--zw-major);
  letter-spacing: 0.04em;
}

.dawnin-ziwei-tool .zw-star.good .zw-sname { color: var(--zw-good); font-size: var(--zwch-minor); }
.dawnin-ziwei-tool .zw-star.bad .zw-sname { color: var(--zw-bad); font-size: var(--zwch-minor); }
.dawnin-ziwei-tool .zw-star.neutral .zw-sname { color: var(--zw-neutral); font-size: var(--zwch-adj); }

/* 亮度 */
.dawnin-ziwei-tool .zw-b {
  margin-left: 0;
  font-style: normal;
  font-size: max(8.5px, var(--zwch-bright));
  padding: 0 2px;
  border-radius: 2px;
  line-height: 1.5;
  font-weight: 500;
  white-space: nowrap;
}
.dawnin-ziwei-tool .zw-b.strong { color: #f7e3b6; background: rgba(240, 217, 168, 0.20); }
.dawnin-ziwei-tool .zw-b.fair { color: #b3d4ee; background: rgba(106, 169, 224, 0.18); }
.dawnin-ziwei-tool .zw-b.flat { color: #c2c9d4; background: rgba(154, 163, 178, 0.18); }
.dawnin-ziwei-tool .zw-b.weak { color: #f0a49b; background: rgba(224, 132, 122, 0.20); }

/* 四化：生年实心，运限描边 */
.dawnin-ziwei-tool .zw-mut {
  margin-left: 0;
  font-style: normal;
  font-size: var(--zwch-mut);
  width: 1.5em;
  height: 1.5em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: #0b0f18;
  font-weight: 700;
  line-height: 1;
  flex: none;
}
.dawnin-ziwei-tool .zw-mut.lu { background: var(--zw-lu); }
.dawnin-ziwei-tool .zw-mut.quan { background: var(--zw-quan); }
.dawnin-ziwei-tool .zw-mut.ke { background: var(--zw-ke); }
.dawnin-ziwei-tool .zw-mut.ji { background: var(--zw-ji); }
.dawnin-ziwei-tool .zw-mut.flow {
  background: transparent;
  border: 1px solid currentColor;
}
.dawnin-ziwei-tool .zw-mut.flow.lu { color: var(--zw-lu); }
.dawnin-ziwei-tool .zw-mut.flow.quan { color: var(--zw-quan); }
.dawnin-ziwei-tool .zw-mut.flow.ke { color: var(--zw-ke); }
.dawnin-ziwei-tool .zw-mut.flow.ji { color: var(--zw-ji); }

/* 辅煞杂曜 */
.dawnin-ziwei-tool .zw-minors,
.dawnin-ziwei-tool .zw-adjs {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 8px;
  margin-top: 1px;
}
.dawnin-ziwei-tool .zw-adjs { opacity: 0.92; gap: 1px 7px; }

/* 空宫借星 */
.dawnin-ziwei-tool .zw-empty { display: flex; flex-direction: column; gap: 1px; }
.dawnin-ziwei-tool .zw-empty-label {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.15em;
  color: var(--zw-dim);
  letter-spacing: 0.14em;
}
.dawnin-ziwei-tool .zw-borrow { font-size: 0.66em; color: rgba(154, 163, 178, 0.8); }

/* 运限流曜 */
.dawnin-ziwei-tool .zw-flow-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 5px;
  font-size: var(--zwch-adj);
  color: rgba(180, 140, 224, 0.9);
  margin-top: 1px;
}

/* 飞星 */
.dawnin-ziwei-tool .zw-fly-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 2px;
}
.dawnin-ziwei-tool .zw-fly {
  font-size: var(--zwch-fly);
  padding: 0 4px;
  border-radius: 2px;
  border: 1px solid currentColor;
  line-height: 1.6;
  opacity: 0.8;
  white-space: nowrap;
}
.dawnin-ziwei-tool .zw-fly.lu { color: var(--zw-lu); }
.dawnin-ziwei-tool .zw-fly.quan { color: var(--zw-quan); }
.dawnin-ziwei-tool .zw-fly.ke { color: var(--zw-ke); }
.dawnin-ziwei-tool .zw-fly.ji { color: var(--zw-ji); }
.dawnin-ziwei-tool .zw-fly.to-active { opacity: 1; background: rgba(255, 255, 255, 0.06); }

/* 宫脚 */
.dawnin-ziwei-tool .zw-cell-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: max(8.5px, var(--zwch-foot));
  color: var(--zw-dim);
  line-height: 1.4;
  margin-top: auto;
}
.dawnin-ziwei-tool .zw-ages {
  color: rgba(127, 200, 176, 0.78);
  word-spacing: 0.18em;
  /* 岁数不换行：换行会把宫脚顶成两行、格子跟着长高。
     收窄由 JS 按可用宽度做，这里只保证量宽时拿得到真实内容宽度。 */
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

/* ---------- 盘心 ---------- */
.dawnin-ziwei-tool .zw-center {
  position: relative;
  z-index: 5;
  background: linear-gradient(160deg, #121a2b, #0c121d);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 9px 12px;
  gap: 4px;
  border: 1px solid var(--zw-line-soft);
  overflow: hidden;
}

.dawnin-ziwei-tool .zw-pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 2px 0 8px;
  width: 100%;
  max-width: 340px;
}
.dawnin-ziwei-tool .zw-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 2px;
  border: 1px solid var(--zw-line-soft);
  background: rgba(201, 169, 110, 0.04);
}
.dawnin-ziwei-tool .zw-pillar-label { font-size: calc(var(--zwch-aux) * 0.78); color: var(--zw-aux); }
.dawnin-ziwei-tool .zw-pillar-gz {
  font-family: 'Noto Serif SC', serif;
  font-size: calc(var(--zwch-aux) * 1.15);
  color: var(--gold-bright);
  letter-spacing: 0.08em;
}
.dawnin-ziwei-tool .zw-center-mut {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.dawnin-ziwei-tool .zw-mut-label { font-size: calc(var(--zwch-aux) * 0.85); color: var(--zw-aux); }
.dawnin-ziwei-tool .zw-mchip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: calc(var(--zwch-aux) * 0.88);
  padding: 1px 5px 1px 6px;
  border-radius: 2px;
  border: 1px solid;
  line-height: 1.6;
}
.dawnin-ziwei-tool .zw-mchip em { font-style: normal; }
.dawnin-ziwei-tool .zw-mchip i {
  font-style: normal;
  font-size: 0.9em;
  color: #0b0f18;
  border-radius: 1px;
  padding: 0 2px;
  font-weight: 700;
}
.dawnin-ziwei-tool .zw-mchip.lu { color: var(--zw-lu); border-color: rgba(70, 184, 132, 0.5); }
.dawnin-ziwei-tool .zw-mchip.lu i { background: var(--zw-lu); }
.dawnin-ziwei-tool .zw-mchip.quan { color: var(--zw-quan); border-color: rgba(180, 140, 224, 0.5); }
.dawnin-ziwei-tool .zw-mchip.quan i { background: var(--zw-quan); }
.dawnin-ziwei-tool .zw-mchip.ke { color: var(--zw-ke); border-color: rgba(106, 169, 224, 0.5); }
.dawnin-ziwei-tool .zw-mchip.ke i { background: var(--zw-ke); }
.dawnin-ziwei-tool .zw-mchip.ji { color: var(--zw-ji); border-color: rgba(224, 100, 91, 0.5); }
.dawnin-ziwei-tool .zw-mchip.ji i { background: var(--zw-ji); }

.dawnin-ziwei-tool .zw-center-title {
  font-family: 'Noto Serif SC', serif;
  font-size: calc(var(--zwch-aux) * 1.5);
  color: var(--gold-bright);
  letter-spacing: 0.1em;
  line-height: 1.4;
}

.dawnin-ziwei-tool .zw-center-sub {
  font-size: calc(var(--zwch-aux) * 0.86);
  color: var(--zw-aux);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.dawnin-ziwei-tool .zw-center-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  line-height: 1.45;
  font-size: calc(var(--zwch-aux) * 0.98);
  width: 100%;
  max-width: 400px;
  text-align: left;
}

.dawnin-ziwei-tool .zw-crow { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.dawnin-ziwei-tool .zw-crow.is-wide { grid-column: 1 / -1; }
.dawnin-ziwei-tool .zw-cv { overflow-wrap: break-word; }
.dawnin-ziwei-tool .zw-ck { color: var(--zw-aux); flex: 0 0 4.4em; font-size: 0.95em; white-space: nowrap; }
.dawnin-ziwei-tool .zw-cv { color: var(--text-warm, #e8e0d0); font-size: 1em; }
.dawnin-ziwei-tool .zw-cv.gold { color: var(--gold-bright); }

.dawnin-ziwei-tool .zw-center-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 3px;
}
.dawnin-ziwei-tool .zw-pattern-tag {
  font-size: calc(var(--zwch-aux) * 0.84);
  padding: 1px 7px;
  border: 1px solid rgba(201, 169, 110, 0.45);
  border-radius: 10px;
  color: var(--gold);
}

.dawnin-ziwei-tool .zw-center-flow {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 6px;
  font-size: calc(var(--zwch-aux) * 0.86);
  color: var(--zw-quan);
  letter-spacing: 0.06em;
}
.dawnin-ziwei-tool .zw-center-flow .zw-flow-part { white-space: nowrap; }
.dawnin-ziwei-tool .zw-center-flow .zw-flow-dot { opacity: 0.55; }

/* ---------- 侧栏详情 ---------- */
.dawnin-ziwei-tool .zw-detail-head h4 {
  font-size: var(--ziwei-section-title-size);
  color: var(--ziwei-section-title-color);
  margin-bottom: 8px;
  letter-spacing: 0.06em;
}

.dawnin-ziwei-tool .zw-detail-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dawnin-ziwei-tool .zw-badge {
  font-size: calc(var(--zwch-aux) * 0.85);
  padding: 1px 8px;
  border: 1px solid var(--zw-line);
  color: var(--zw-aux);
  border-radius: 10px;
}
.dawnin-ziwei-tool .zw-badge.gold { color: var(--gold-bright); border-color: rgba(201, 169, 110, 0.5); }

.dawnin-ziwei-tool .zw-detail-theme {
  font-size: calc(var(--zwch-aux) * 1);
  color: #b9c3d2;
  line-height: 1.9;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--zw-line-soft);
}

.dawnin-ziwei-tool .zw-detail-stars { display: flex; flex-direction: column; gap: 8px; }

.dawnin-ziwei-tool .zw-dstar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  font-size: calc(var(--zwch-aux) * 0.95);
}

.dawnin-ziwei-tool .zw-dstar-name { font-family: 'Noto Serif SC', serif; font-size: 1.16em; }
.dawnin-ziwei-tool .zw-dstar-name.major { color: var(--zw-major); font-weight: 700; }
.dawnin-ziwei-tool .zw-dstar-name.good { color: var(--zw-good); }
.dawnin-ziwei-tool .zw-dstar-name.bad { color: var(--zw-bad); }
.dawnin-ziwei-tool .zw-dstar-name.neutral { color: var(--zw-neutral); }

.dawnin-ziwei-tool .zw-dstar-text {
  flex-basis: 100%;
  font-size: calc(var(--zwch-aux) * 0.9);
  color: #9fa9b8;
  line-height: 1.8;
  padding-left: 2px;
}

.dawnin-ziwei-tool .zw-detail-empty { font-size: calc(var(--zwch-aux) * 0.95); color: #b9c3d2; line-height: 1.85; }

.dawnin-ziwei-tool .zw-detail-fly { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--zw-line-soft); }
.dawnin-ziwei-tool .zw-sub-title { font-size: calc(var(--zwch-aux) * 0.92); color: var(--gold); margin-bottom: 6px; }
.dawnin-ziwei-tool .zw-fly-list { display: flex; flex-wrap: wrap; gap: 5px; }
.dawnin-ziwei-tool .zw-fly-list .zw-fly { font-size: calc(var(--zwch-aux) * 0.86); opacity: 0.95; padding: 1px 6px; }

/* ---------- 解读区 ---------- */
/* ---------- 解读标签页 ---------- */
.dawnin-ziwei-tool .zw-itabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--zw-line-soft);
  margin-bottom: 14px;
}
.dawnin-ziwei-tool .zw-itab {
  position: relative;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--zw-aux);
  font: inherit;
  font-size: calc(var(--zwch-aux) * 0.95);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.15s;
}
.dawnin-ziwei-tool .zw-itab:hover { color: var(--gold-bright); }
.dawnin-ziwei-tool .zw-itab.active { color: var(--gold-bright); }
.dawnin-ziwei-tool .zw-itab.active::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--gold);
}
.dawnin-ziwei-tool .zw-ipanel { display: none; }
.dawnin-ziwei-tool .zw-ipanel.active { display: block; }
.dawnin-ziwei-tool .zw-ipanel.is-cols { columns: 2; column-gap: 26px; }
.dawnin-ziwei-tool .zw-ipanel p {
  font-size: var(--ziwei-body-size);
  color: var(--ziwei-body-color);
  line-height: 2;
  margin-bottom: 8px;
  break-inside: avoid;
}
.dawnin-ziwei-tool .zw-ipanel.is-cols p {
  line-height: 1.9;
  font-size: calc(var(--zwch-aux) * 0.95);
}

/* 当前运限（侧栏） */
.dawnin-ziwei-tool .zw-detail-flow {
  margin: 4px 0 10px;
  padding: 8px 0 6px;
  border-top: 1px solid var(--zw-line-soft);
  border-bottom: 1px solid var(--zw-line-soft);
}
.dawnin-ziwei-tool .zw-detail-flow .zw-rel-label { flex: 0 0 34px; }
.dawnin-ziwei-tool .zw-detail-flow .zw-rel-label.decadal { color: #b48ce0; }
.dawnin-ziwei-tool .zw-detail-flow .zw-rel-label.yearly { color: #e0a860; }
.dawnin-ziwei-tool .zw-detail-flow .zw-rel-label.monthly { color: #6ec5a8; }

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .dawnin-ziwei-tool .zw-chart { min-width: 0; font-size: calc(var(--zwch-base) * 0.74); }
  .dawnin-ziwei-tool .zw-cell { padding: 4px 4px 3px; gap: 2px; }
  .dawnin-ziwei-tool .zw-boshi12 { display: none; }
}
@media (max-width: 900px) {
  .dawnin-ziwei-tool .zw-chart { min-width: 0; font-size: calc(var(--zwch-base) * 0.82); }
  .dawnin-ziwei-tool .zw-center-grid { grid-template-columns: 1fr; font-size: calc(var(--zwch-aux) * 0.86); max-width: 240px; }
  .dawnin-ziwei-tool .zw-legend { margin-left: 0; }
  .dawnin-ziwei-tool .zw-center-title { font-size: calc(var(--zwch-aux) * 1.2); }
}

/* ---------- 盘面下列表与解读标题 ---------- */
.dawnin-ziwei-tool .zw-cell-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 14px;
  font-size: calc(var(--zwch-aux) * 0.9);
  color: var(--zw-aux);
  line-height: 1.8;
}
.dawnin-ziwei-tool .zw-cell-legend b { font-weight: 500; }

.dawnin-ziwei-tool .interpret-head {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.1rem;
  color: var(--gold-bright);
  letter-spacing: 0.12em;
  padding-bottom: 10px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--zw-line-soft);
}

/* 窄盘（手机或侧栏挤压）时盘心只留最要紧的几行，宁缺不溢 */
@media (max-width: 1200px) {
  .dawnin-ziwei-tool .zw-center-grid .zw-crow:nth-child(n+7) { display: none; }
}
@media (max-width: 900px) {
  .dawnin-ziwei-tool .zw-center { gap: 3px; padding: 8px 6px; }
  .dawnin-ziwei-tool .zw-center-title { font-size: calc(var(--zwch-aux) * 1.1); letter-spacing: 0; }
  .dawnin-ziwei-tool .zw-center-sub { font-size: calc(var(--zwch-aux) * 0.75); }
  .dawnin-ziwei-tool .zw-pillars { gap: 4px; margin: 2px 0 4px; max-width: 220px; }
  .dawnin-ziwei-tool .zw-pillar { padding: 2px 0; }
  .dawnin-ziwei-tool .zw-pillar-label { display: none; }
  .dawnin-ziwei-tool .zw-pillar-gz { font-size: calc(var(--zwch-aux) * 0.95); }
  .dawnin-ziwei-tool .zw-center-grid { font-size: calc(var(--zwch-aux) * 0.8); max-width: 220px; gap: 1px 6px; }
  .dawnin-ziwei-tool .zw-center-grid .zw-crow:nth-child(n+6) { display: none; }
  .dawnin-ziwei-tool .zw-center-mut, .dawnin-ziwei-tool .zw-center-patterns { display: none; }
  /* 十二宫速览在窄屏分两栏会挤成一行一字 */
  .dawnin-ziwei-tool .zw-ipanel.is-cols { columns: 1; }
  .dawnin-ziwei-tool .zw-ipanel.is-cols p { line-height: 1.8; }
}

/* 侧栏三方四正 */
.dawnin-ziwei-tool .zw-detail-rel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--zw-line-soft);
}
.dawnin-ziwei-tool .zw-rel-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: calc(var(--zwch-aux) * 0.9);
  padding: 4px 0;
  border-bottom: 1px dashed rgba(201, 169, 110, 0.1);
}
.dawnin-ziwei-tool .zw-rel-row:last-child { border-bottom: none; }
.dawnin-ziwei-tool .zw-rel-label { color: var(--zw-aux); flex: 0 0 30px; }
.dawnin-ziwei-tool .zw-rel-name { color: var(--gold); flex: 0 0 78px; }
.dawnin-ziwei-tool .zw-rel-stars { color: #b9c3d2; flex: 1; }

/* 关键：grid 子项默认 min-width:auto，会把 680px 的盘面顶出屏幕，
   导致整页横向溢出（手机端输入框被裁就是这个原因）。必须显式归零。 */
.dawnin-ziwei-tool .result-grid > * { min-width: 0; }
.dawnin-ziwei-tool .chart-panel { min-width: 0; }
.dawnin-ziwei-tool .zw-chart-wrap { max-width: 100%; }

@media (max-width: 600px) {
  .dawnin-ziwei-tool .chart-panel { padding: 14px 10px; }
  .dawnin-ziwei-tool .zw-chart { font-size: calc(var(--zwch-base) * 0.74); }
  .dawnin-ziwei-tool .zw-cell { padding: 4px 4px 3px; }
  /* 手机上不再单独放大主星：倍数统一由 --zwch-major 控制，否则一设就爆格 */
  .dawnin-ziwei-tool .zw-adjs { display: none; }
  /* 手机上宫脚只留小限岁数：长生·十二神 6 个字会把 82px 的格子挤成两行 */
  .dawnin-ziwei-tool .zw-cell-foot .zw-cs { display: none; }
  .dawnin-ziwei-tool .zw-cell-foot { justify-content: flex-end; }
  .dawnin-ziwei-tool .zw-cell-legend { font-size: calc(var(--zwch-aux) * 0.86); }
}

/* 飞星连线层：不占格、不挡点击 */
.dawnin-ziwei-tool .zw-fly-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* 必须压在盘心（z-index:5）之上：弧线虽然是绕着盘心走的，
     但盘心四角是圆的、格子是方的，抬一层才不会被切出「断头线」。 */
  z-index: 6;
  overflow: visible;
}

/* ================= 盘面显示设置（前台实时调节） =================
   面板挂在 body 下，不用 .dawnin-ziwei-tool 的变量，颜色直接写字面值，
   免得「把某处颜色改黑 → 面板自己看不见」这种自伤。 */
.dawnin-ziwei-tool .zw-style-toggle {
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--zw-line);
  color: var(--zw-aux);
  font: inherit;
  font-size: calc(var(--zwch-aux) * 0.9);
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}
.dawnin-ziwei-tool .zw-style-toggle:hover,
.dawnin-ziwei-tool .zw-style-toggle[aria-expanded="true"] {
  color: var(--gold-bright);
  border-color: rgba(201, 169, 110, 0.55);
  background: rgba(201, 169, 110, 0.08);
}
.dawnin-ziwei-tool .zw-style-toggle::before {
  content: '';
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #0e1421, inset 0 0 0 3px currentColor;
}

.zw-style-pop {
  position: fixed;
  z-index: 99999;
  width: 320px;
  max-height: 76vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #0f1626;
  border: 1px solid rgba(201, 169, 110, 0.35);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  color: #cfd6e0;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  font-size: 13px;
  display: none;
}
.zw-style-pop.is-open { display: block; }

.zw-style-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: #121b2d;
  border-bottom: 1px solid rgba(201, 169, 110, 0.18);
  font-family: 'Noto Serif SC', serif;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: #e0c088;
}
.zw-style-close {
  background: none;
  border: none;
  color: #8d97a8;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.zw-style-close:hover { color: #e0c088; }

.zw-style-body { padding: 12px 14px 6px; }
.zw-style-group { margin-bottom: 14px; }
.zw-style-title {
  font-size: 0.72rem;
  color: #9aa6b8;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed rgba(201, 169, 110, 0.14);
}

.zw-style-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  cursor: pointer;
}
.zw-style-label {
  flex: 0 0 60px;
  font-size: 0.76rem;
  color: #b6bfcd;
  white-space: nowrap;
}
.zw-style-range {
  flex: 1;
  min-width: 0;
  height: 3px;
  accent-color: #c9a96e;
  cursor: pointer;
}
.zw-style-val {
  flex: 0 0 42px;
  text-align: right;
  font-size: 0.72rem;
  color: #e0c088;
  font-variant-numeric: tabular-nums;
}

.zw-style-colors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 6px;
}
.zw-style-color {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.73rem;
  color: #cfd6e0;
  min-width: 0;
}
.zw-style-color span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zw-style-color input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(201, 169, 110, 0.35);
  background: none;
  cursor: pointer;
  flex: none;
}
.zw-style-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.zw-style-color input[type="color"]::-webkit-color-swatch { border: none; }

.zw-style-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  background: #121b2d;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}
.zw-style-reset {
  padding: 4px 12px;
  background: none;
  border: 1px solid rgba(201, 169, 110, 0.4);
  color: #e0c088;
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}
.zw-style-reset:hover { background: rgba(201, 169, 110, 0.12); }
.zw-style-note { font-size: 0.68rem; color: #6f7987; }

/* 手机：改成底部抽屉，滑块才够长 */
.zw-style-pop.is-sheet {
  left: 8px !important;
  right: 8px !important;
  top: auto !important;
  bottom: 8px;
  width: auto;
  max-height: 72vh;
}

@media (max-width: 600px) {
  .dawnin-ziwei-tool .zw-style-toggle { font-size: calc(var(--zwch-aux) * 0.84); padding: 4px 10px; }
  /* 手机：三行选择器要尽量矮，多出来的高度全留给盘面 */
  .dawnin-ziwei-tool .zw-flow-picker { margin-bottom: 10px; }
  .dawnin-ziwei-tool .zw-flabel { width: 2.6em; font-size: calc(var(--zwch-aux) * 0.72); }
  .dawnin-ziwei-tool .zw-fchips { padding: 3px 6px; gap: 3px; }
  .dawnin-ziwei-tool .zw-fchip { padding: 1px 7px; font-size: calc(var(--zwch-aux) * 0.76); }
  /* 手机上箭头要够大好点，别跟文字抢地方 */
  .dawnin-ziwei-tool .zw-farrow { width: 26px; font-size: calc(var(--zwch-aux) * 1.45); }
  .dawnin-ziwei-tool .zw-toolbar { gap: 8px 12px; margin-bottom: 10px; }
  .dawnin-ziwei-tool .zw-legend { margin-left: 0; }
}

/* 滑块：原生 range 在暗色下是一条惨白粗线，这里统一成细轨+金点 */
.zw-style-range {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 16px;
}
.zw-style-range::-webkit-slider-runnable-track {
  height: 3px;
  background: rgba(201, 169, 110, 0.22);
  border-radius: 2px;
}
.zw-style-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #c9a96e;
  border: 1px solid #0f1626;
  box-shadow: 0 0 0 1px rgba(201, 169, 110, 0.5);
  cursor: pointer;
}
.zw-style-range:active::-webkit-slider-thumb { background: #e0c088; }
.zw-style-range::-moz-range-track {
  height: 3px;
  background: rgba(201, 169, 110, 0.22);
  border-radius: 2px;
}
.zw-style-range::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #c9a96e;
  border: 1px solid #0f1626;
  cursor: pointer;
}
.zw-style-range:focus-visible { outline: 1px solid rgba(201, 169, 110, 0.6); outline-offset: 3px; }
