/* 画布局（后天八卦九宫看自家）专属样式；共享变量与基础类见 assets/base.css，本文件不重复定义 */

/* ---------- 顶层容器 ---------- */
.hp-card { position: relative; }
.hp-card .hp-n { letter-spacing: 0; }
.hp-good { border-left: 4px solid var(--jade); }
.hp-bad { border-left: 4px solid var(--cinnabar); }
.hp-note { border-left: 4px solid var(--water); }
.hp-warn {
  background: #fdf6e6;
  border-color: #e3d3a8;
  font-size: 14.5px;
  line-height: 1.9;
}
.hp-warn b { color: var(--cinnabar); }
.hp-report > .card + .card { margin-top: 16px; }
.hp-badtxt { color: var(--cinnabar); }

/* ---------- 房型笔刷 ---------- */
.hp-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 12px;
  margin: 6px 0 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .45);
}
.hp-pal-cat { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.hp-pal-name {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--gold);
  border-right: 1px solid var(--line);
  padding-right: 8px;
  margin-right: 4px;
}
.hp-pen { cursor: pointer; text-align: left; line-height: 1.5; }
.hp-pen b { display: inline-block; min-width: 1.6em; color: var(--cinnabar); font-weight: 700; }
.hp-pen i { font-style: normal; color: var(--gold); margin-left: 4px; font-size: 11px; }
.hp-pen:hover { border-color: var(--gold); }
.hp-pen.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.hp-pen.on b { color: #f0d9a8; }
.hp-pen.on i { color: #f0d9a8; }
/* 墙门笔：与房型笔区分，图标取墨色，选中仍反白 */
.hp-pen-seam { border-style: solid; }
.hp-pen-seam b { color: var(--ink-soft); }
.hp-pen-seam.on { background: var(--gold); border-color: var(--gold); color: #fffdf7; }
.hp-pen-seam.on b { color: #fffdf7; }

/* ---------- 画板：CSS 网格，格与缝交替成轨 ---------- */
.hp-stage { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.hp-grid {
  --hp-seam: 10px;
  position: relative;
  display: grid;
  flex: 1 1 460px;
  max-width: 720px;
  border: 2px solid var(--ink-soft);
  border-radius: 6px;
  padding: 6px;
  background: #fffdf7;
  touch-action: none;
  user-select: none;
}
/* 格：落在偶数轨（auto 行 × 1fr 列），以 aspect-ratio 撑出正方 */
.hp-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbf7ee;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.hp-cell b { font-size: clamp(11px, 1.5vw, 17px); font-weight: 700; letter-spacing: 0; }
.hp-grid[data-brushkind="cell"] .hp-cell { cursor: crosshair; }
.hp-grid[data-brushkind="seam"] .hp-cell { cursor: default; }
.hp-cell:hover { border-color: var(--gold); }
.hp-grid[data-brushkind="cell"] .hp-cell:hover { box-shadow: inset 0 0 0 1px rgba(168, 132, 60, .4); }
.hp-cell:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
/* 拖框成间的实时预览：盖在房型底色与吉凶内描边之上，抬笔即消失 */
.hp-cell.hp-pre { background: rgba(168, 132, 60, .22); box-shadow: inset 0 0 0 2px var(--gold); }
.hp-empty { background: repeating-linear-gradient(135deg, #f2ece0 0 5px, #ece4d5 5px 10px); }
.hp-cg {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0;
  color: rgba(43, 38, 32, .55);
  pointer-events: none;
}
.hp-on-ji { box-shadow: inset 0 0 0 2px rgba(74, 124, 89, .55); }
.hp-on-xiong { box-shadow: inset 0 0 0 2px rgba(157, 59, 44, .45); }

/* 门冲视线：叠在房型底色与吉凶描边之上，不夺点击 */
.hp-cell.hp-ray-path::after,
.hp-cell.hp-ray-hit::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  pointer-events: none;
}
.hp-cell.hp-ray-path::after { background: rgba(168, 132, 60, .14); box-shadow: inset 0 0 0 2px rgba(168, 132, 60, .45); }
.hp-cell.hp-ray-hit::after { background: rgba(157, 59, 44, .16); box-shadow: inset 0 0 0 3px var(--cinnabar); }
.hp-chong {
  position: absolute;
  top: -2px;
  left: -2px;
  z-index: 3;
  font-style: normal;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 700;
  background: var(--cinnabar);
  color: #fff8f0;
  padding: 1px 3px;
  border-radius: 3px;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

/* 缝：H 在缝行×格列（横 bar），V 在格行×缝列（竖 bar） */
.hp-seam {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}
.hp-grid[data-brushkind="seam"] .hp-seam { cursor: crosshair; }
.hp-grid[data-brushkind="cell"] .hp-seam { cursor: default; }
.hp-seam-none { background: rgba(43, 38, 32, .05); }
.hp-grid[data-brushkind="seam"] .hp-seam-none:hover {
  background: rgba(168, 132, 60, .3);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.hp-seam:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; z-index: 2; }
/* 墙：实线隔断，填满缝轨 */
.hp-wall { background: var(--ink-soft); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.hp-grid[data-brushkind="seam"] .hp-wall:hover { background: var(--ink); }
/* 门：开口 + 开向箭头（箭头所指即门冲之方） */
.hp-door { background: #fffaf0; box-shadow: inset 0 0 0 1px rgba(168, 132, 60, .55); }
.hp-grid[data-brushkind="seam"] .hp-door:hover { box-shadow: inset 0 0 0 2px var(--gold); }
.hp-arrow { width: 0; height: 0; display: block; }
.hp-face-up .hp-arrow { border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--cinnabar); }
.hp-face-down .hp-arrow { border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 7px solid var(--cinnabar); }
.hp-face-left .hp-arrow { border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-right: 7px solid var(--cinnabar); }
.hp-face-right .hp-arrow { border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 7px solid var(--cinnabar); }
/* 射线所冲之缝（见墙／门对门）标红环 */
.hp-seam-hit { box-shadow: 0 0 0 2px var(--cinnabar); z-index: 1; }
/* 窗：采光通风口，玻璃色 + 中梃，区别于实墙与门 */
.hp-window { background: #cfe3e6; box-shadow: inset 0 0 0 1px rgba(53, 97, 127, .55); }
.hp-grid[data-brushkind="seam"] .hp-window:hover { box-shadow: inset 0 0 0 2px #35617f; }
.hp-win-glyph { display: block; background: rgba(53, 97, 127, .75); }
.hp-seam-H .hp-win-glyph { width: 62%; height: 1px; }
.hp-seam-V .hp-win-glyph { width: 1px; height: 62%; }

/* 指北：落在末行整宽轨，不再绝对定位 */
.hp-rose {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 2px 0;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 2px;
}
.hp-rose b { font-size: 15px; color: var(--cinnabar); }

/* ---------- 房型配色（18 键） ---------- */
.hp-k-ting { background: #f4e6c8; border-color: #dcc28a; }
.hp-k-men { background: #f6ded4; border-color: #d99b83; }
.hp-k-chu { background: #f7e3c2; border-color: #dcb071; }
.hp-k-wei { background: #dce8ef; border-color: #9dbccf; }
.hp-k-wo { background: #e3ecdc; border-color: #adc5a1; }
.hp-k-ci { background: #e9eee2; border-color: #bccdb1; }
.hp-k-kid { background: #f7e7d6; border-color: #dcb98f; }
.hp-k-eld { background: #e6e6d8; border-color: #babaa2; }
.hp-k-shu { background: #e2e4ee; border-color: #a9aecf; }
.hp-k-can { background: #efead9; border-color: #c9bf9e; }
.hp-k-yang { background: #e0efe9; border-color: #a3cbb9; }
.hp-k-xuan { background: #ece5dc; border-color: #c3b49e; }
.hp-k-sto { background: #e7e4dd; border-color: #bdb7a8; }
.hp-k-wash { background: #dbe9ea; border-color: #9cc0c2; }
.hp-k-stai { background: #eae4d4; border-color: #c2b494; }
.hp-k-win { background: #eef4f8; border-color: #b6d2e0; }
.hp-k-fish { background: #dfeaf0; border-color: #a2c6d8; }
.hp-k-god { background: #f0e4d2; border-color: #cfae7c; }

/* ---------- 侧栏表单 ---------- */
.hp-side { flex: 1 1 320px; min-width: 280px; }
.hp-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .55);
}
.hp-form-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.hp-lbl {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-right: 2px;
  white-space: nowrap;
}
.hp-form-row .chip { cursor: pointer; }
.hp-form-row .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.hp-chk { display: inline-flex; gap: 4px; align-items: center; font-size: 14px; }
.hp-num { width: 74px; padding: 4px 6px; }
.hp-num.sm { width: 58px; }
.hp-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.hp-actions .btn[disabled] { opacity: .4; cursor: default; }
.hp-actions .btn.ghost[disabled]:hover { background: transparent; color: var(--ink); }
.hp-draft { margin: 8px 0 0; line-height: 1.7; }
.hp-draft .chip.tiny { margin-left: 4px; vertical-align: baseline; }
/* 侧栏小标题与分段条：比正文标题轻，避免抢「第一步／第二步」的分量 */
.hp-side-h { font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--gold); margin: 0 0 8px; }
.hp-stepbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 24px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
}
.hp-legend { margin-top: 12px; font-size: 14px; }
/* 报告首尾的「回盘面」条：画—看—再画 的来回不必滚半天 */
.hp-jump { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 0 0 12px; }
.hp-jump .chip.tiny { cursor: pointer; }
.hp-live { margin: 2px 0; }
.hp-live b { color: var(--cinnabar); }

/* ---------- 宫位盘 ---------- */
.hp-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 640px;
  margin: 10px 0;
}
.hp-brow { display: contents; }
.hp-bcell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 8px 10px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hp-bdir { font-size: 11px; color: var(--ink-soft); letter-spacing: 2px; }
.hp-bgua { font-size: 19px; letter-spacing: 3px; }
.hp-bstar { font-size: 14px; }
.hp-brooms { font-size: 15px; letter-spacing: 3px; margin-top: auto; }
.hp-ji { border-left: 4px solid var(--jade); }
.hp-ji .hp-bstar { color: #33603f; font-weight: 700; }
.hp-xiong { border-left: 4px solid var(--cinnabar); }
.hp-xiong .hp-bstar { color: #8d3527; font-weight: 700; }
.hp-bcell.hp-miss { background: #f4efe4; border-style: dashed; }
.hp-miss .hp-brooms { color: var(--cinnabar); }
.hp-gualeg { margin-top: 10px; }
.hp-missrow th, .hp-missrow td { background: #f7e9e5 !important; }

/* ---------- 结论条目 ---------- */
.hp-find {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  background: rgba(255, 255, 255, .5);
}
.hp-find h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.hp-find p { margin: 4px 0; font-size: 14.5px; }
.hp-find p > b { color: var(--gold); margin-right: 6px; }
.hp-where { color: var(--water); font-size: 13.5px !important; }
.hp-adv { border-top: 1px dotted var(--line); padding-top: 6px; margin-top: 8px; }
.hp-adv > b { color: var(--cinnabar) !important; }
.hp-fix {
  font-size: 13.5px;
  margin: 6px 0 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f5f0e2;
  color: var(--ink-soft);
}
.hp-fix b { color: var(--ink); margin-right: 4px; }
.hp-good .hp-find { border-left-color: var(--jade); }
.hp-bad .hp-find { border-left-color: var(--cinnabar); }
.hp-note .hp-find { border-left-color: var(--water); }
/* 门冲条目：按类着色，开向 chip 醒目 */
.hp-dcl-bad { border-left-color: var(--cinnabar); }
.hp-dcl-note { border-left-color: var(--water); }
.hp-dcl-good { border-left-color: var(--jade); }
.hp-dcl-face {
  color: var(--cinnabar);
  border-color: rgba(157, 59, 44, .45);
  background: rgba(157, 59, 44, .07);
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}
.hp-dcl h3 { flex-wrap: wrap; }
.hp-wide { width: 100%; table-layout: fixed; font-size: 14px; }
.hp-wide th, .hp-wide td { padding: 6px 8px; word-break: break-word; overflow-wrap: anywhere; }
.hp-wide th:first-child { width: 96px; }
.hp-wide th small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }

/* ---------- 供设 ---------- */
.hp-faiths { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 8px 0 4px; }
.hp-faith {
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, .55);
}
.hp-faith b { display: block; letter-spacing: 2px; color: var(--cinnabar); margin-bottom: 4px; }
.hp-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--jade);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(255, 255, 255, .5);
}
.hp-item h4 { margin: 0 0 4px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; letter-spacing: 1px; }
.hp-item p, .hp-text p { margin: 2px 0; }
.hp-item b, .hp-text b { color: var(--gold); }
.hp-text {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(255, 253, 247, .7);
}
.hp-text > b:first-child { color: var(--cinnabar); font-size: 15px; }
.hp-notes { margin: 6px 0; padding-left: 22px; }
.hp-notes li { font-size: 14.5px; margin: 4px 0; }
.hp-notes li::marker { color: var(--gold); }

/* ---------- 九宫查表 ---------- */
.hp-pal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .5);
}
.hp-pal h4 { margin: 0 0 6px; font-size: 15.5px; letter-spacing: 2px; color: var(--cinnabar); }
.hp-pal p { margin: 3px 0; }
.hp-pal b { color: var(--gold); }
.hp-how { margin: 8px 0; padding-left: 24px; }
.hp-how li { margin: 3px 0; font-size: 14.5px; }
.hp-note {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fdf6e6;
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-soft);
}
.chip.tiny { font-size: 11.5px; padding: 0 7px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  /* 竖排时盘面占满卡片实宽、高度随格子走 */
  .hp-stage { flex-direction: column; align-items: stretch; }
  .hp-grid { max-width: none; flex: 0 0 auto; width: 100%; min-width: 0; --hp-seam: 11px; }
  .hp-cg { display: none; }
  .hp-board { gap: 5px; }
  .hp-bcell { min-height: 78px; padding: 6px; }
  .hp-bgua { font-size: 16px; }
  .hp-brooms { font-size: 13px; letter-spacing: 1px; }
}
/* 更窄的手机：缝加宽便于手指点画，格内字与「冲」标收紧，十二列也不溢出 */
@media (max-width: 480px) {
  .hp-grid { padding: 4px; --hp-seam: 12px; }
  .hp-cell b { font-size: 10px; }
  .hp-chong { font-size: 8px; padding: 0 2px; top: -1px; left: -1px; }
  .hp-face-up .hp-arrow, .hp-face-down .hp-arrow { border-left-width: 3px; border-right-width: 3px; }
  .hp-face-left .hp-arrow, .hp-face-right .hp-arrow { border-top-width: 3px; border-bottom-width: 3px; }
}

/* ---------- 打印 ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .site-header, .fs-toolbar, .hp-palette, .hp-actions, .hp-rose, .hp-jump, .hp-draft, .hp-side-h,
  .footer-disclaimer, .nav { display: none !important; }
  .page { max-width: none; padding: 0; }
  .hp-card, .card { box-shadow: none; border: 1px solid #b9b0a0; break-inside: avoid; page-break-inside: avoid; }
  .hp-grid { border: 1.5px solid #333; background: #fff; max-width: 100%; --hp-seam: 8px; }
  .hp-cell, .hp-bcell, .hp-missrow th, .hp-missrow td, .hp-pen, .badge,
  .hp-seam, .hp-wall, .hp-door, .hp-window, .hp-win-glyph, .hp-arrow, .hp-chong, .hp-seam-hit {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .hp-cell.hp-ray-path::after, .hp-cell.hp-ray-hit::after {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .hp-seam-none { background: transparent; }
  .hp-bcell, .hp-find, .hp-faith, .hp-item, .hp-text, .hp-pal, .hp-warn, .hp-note { background: #fff; }
  .hp-board { max-width: 100%; }
  .hp-stage { display: block; }
  .hp-side { min-width: 0; }
  .hp-form { display: none; }
  table.kv th, table.kv td { border-color: #b9b0a0; }
  .hp-report .card + .card { margin-top: 10px; }
}

/* ══════ 勘测版增补：院子格 · 缝隙大门 ══════ */
.hp-k-yard { background: #edf3e2; }
.hp-k-yard b { color: #4a7c59; }
.hp-k-yard .hp-cg { color: #4a7c59; }
.hp-seam.hp-maindoor { background: #9d3b2c; box-shadow: 0 0 0 2px rgba(157, 59, 44, .3); }
.hp-seam.hp-maindoor .hp-arrow { border-bottom-color: #fffdf6; border-top-color: #fffdf6; border-right-color: #fffdf6; border-left-color: #fffdf6; }
.hp-md-tag { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 9px; line-height: 1; letter-spacing: 1px; color: #fffdf6; text-decoration: none; pointer-events: none; white-space: nowrap; text-indent: 1px; }
@media print {
  .hp-k-yard { background: #f3f1e6; }
  .hp-seam.hp-maindoor { background: #6b4a42; }
}

/* ══════ 手指落点增补：缝笔时把缝隙命中区向两侧扩，格笔时把格子扩满轨距 ══════
   缝隙轨只有约 9–11px 宽，手指难以对准；扩后不必看准细缝也能画上墙／门。
   只在对应笔生效：缝笔时缝压住邻格边缘，格笔时格吞掉缝轨，二者不互相抢点。 */
.hp-grid[data-brushkind="seam"] .hp-seam { z-index: 3; }
.hp-grid[data-brushkind="seam"] .hp-seam::before { content: ''; position: absolute; }
.hp-grid[data-brushkind="seam"] .hp-seam-H::before { left: -3px; right: -3px; top: -10px; bottom: -10px; }
.hp-grid[data-brushkind="seam"] .hp-seam-V::before { top: -3px; bottom: -3px; left: -10px; right: -10px; }
.hp-grid[data-brushkind="cell"] .hp-cell { z-index: 2; }
.hp-grid[data-brushkind="cell"] .hp-cell::before { content: ''; position: absolute; inset: -6px; }
@media (max-width: 480px) {
  .hp-grid { --hp-seam: 9px; }
  .hp-cell b { font-size: 10.5px; }
}
