/* ==========================================================================
   線上排盤 /chart/ 版面樣式
   1. 色彩與基礎  2. 版面骨架（含頁面標題）  3. 日期表單  4. 區塊與面板
   5. 四柱神煞與易經卦  6. 數字頻率圖  7. 大限鑽石圖
   8. 高峰／通道與本命太極  9. 首頁  10. 列印
   11. 本命太極八卦（列印第二頁）
   ========================================================================== */

/* 1. 色彩與基礎 ----------------------------------------------------------- */
:root {
  --app-ink: var(--chart-title-color, #17172a);
  --app-muted: #696d7a;
  --app-line: #e2e4ea;
  --app-line-strong: #cdd1da;
  --app-surface: #f6f7f9;
  --app-paper: #ffffff;
  --app-accent: var(--chart-accent, #9f4f04);

  /* 藏青：頁首、首頁入口、易經卦卡片、八卦中宮等深色底一律用這個顏色 */
  --app-navy: #1f2f52;
  --app-navy-soft: #2b3e68;

  /* 曆別：陽曆紅、陰曆綠（與圓圈圖的原生色一致） */
  --app-solar: #e5281b;
  --app-lunar: #12a150;
  /* 曆別的淡底與深色字（四柱神煞的曆別欄、日期列） */
  --app-solar-tint: #fdeeec;
  --app-solar-ink: #a8160c;
  --app-lunar-tint: #e7f5ec;
  --app-lunar-ink: #0a6634;

  /* 語意色：目標、挑戰、通道、流年、目前所在大限 */
  --app-goal: #1d4f91;
  --app-goal-tint: #eaf1fb;
  --app-goal-line: #bcd0ec;
  --app-chal: #a52222;
  --app-chal-tint: #fbeceb;
  --app-chal-line: #ecc4c1;
  --app-chan: #8a5a00;
  --app-chan-tint: #fdf3dc;
  --app-chan-line: #ead29a;
  --app-year: #2c6b2f;
  --app-year-tint: #e8f4e6;
  --app-now: #e3a008;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--app-ink);
  background: #ffffff;
  font-family: var(--chart-front-font, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", Arial, sans-serif);
  font-size: var(--chart-content-size, 18px);
  font-weight: var(--chart-content-weight, 400);
  line-height: var(--chart-content-line, 34px);
  letter-spacing: var(--chart-content-spacing, 0);
}

/* 2. 版面骨架 ------------------------------------------------------------- */
.app-shell {
  box-sizing: border-box;
  width: 100%;
  max-width: 1120px;
  margin: clamp(20px, 4vw, var(--chart-main-top, 40px)) auto clamp(32px, 6vw, var(--chart-main-bottom, 64px));
  padding: 0 16px;
  color: var(--app-ink);
  font-family: var(--chart-front-font, "Noto Sans TC", sans-serif);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0;
  font-variant-numeric: lining-nums tabular-nums;
}

/* 首頁與結果頁：頁首下方留 18px，與 /chart2/、/chart3/ 一致 */
.app-results .app-shell,
.app-home .app-shell {
  margin-top: 18px;
}

.app-shell *,
.app-shell *::before,
.app-shell *::after {
  box-sizing: border-box;
}

.app-shell button,
.app-shell input,
.app-shell select,
.app-shell textarea {
  font-family: inherit;
}

.app-shell a {
  color: var(--app-accent);
  font-weight: 700;
  text-decoration: none;
}

.app-shell a:hover {
  text-decoration: underline;
}

.app-shell :focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

/* 頁首：與 /chart2/、/chart3/ 同一規格（深色橫條、圓印、主標＋英文副標、右側操作鈕） */
.site-header {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 20;
  background: var(--app-navy); color: #f6f1e7;  /* 與分頁圖示同一藏青色 */
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; max-width: 1120px; min-height: 56px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
.brand { display: flex; align-items: center; color: inherit; text-decoration: none; }
.brand:focus-visible { outline: 2px solid #dcbd7c; outline-offset: 4px; border-radius: 4px; }
.brand-mark {
  box-sizing: border-box; width: 36px; height: 36px; margin-right: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(246, 241, 231, .8); border-radius: 50%;  /* 圓形印章（保留原配色） */
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-weight: 900; font-size: 19px; line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-weight: 600; font-size: 19px; letter-spacing: .12em; }
.brand-sub { font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; font-size: 12.5px; font-weight: 500; line-height: 1.3; letter-spacing: .14em; color: #d4e1f4; }
.header-actions { display: flex; gap: 8px; }
.hbtn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; margin: 0; padding: 0 12px;
  border: 1px solid rgba(246, 241, 231, .5); border-radius: 5px; background: transparent; color: #f6f1e7;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif; font-size: 15px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.hbtn:hover { background: rgba(255, 255, 255, .12); }
.hbtn:focus-visible { outline: 2px solid #dcbd7c; outline-offset: 2px; }
/* 頁首：老K書苑連結（金色，吸引點閱） */
.hbtn-ebook {
  gap: 8px; padding: 0 12px 0 5px; border-color: #dcbd7c; border-radius: 999px;
  background: linear-gradient(180deg, rgba(220, 189, 124, .22), rgba(220, 189, 124, .08)); color: #f6e7bf; text-decoration: none;
}
.hbtn-ebook:hover { background: #dcbd7c; border-color: #dcbd7c; color: var(--app-navy); text-decoration: none; }
.ebook-seal {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none;
  border-radius: 50%; background: #dcbd7c; color: var(--app-navy);
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-weight: 900; font-size: 14px; line-height: 1;
}
.hbtn-ebook:hover .ebook-seal { background: var(--app-navy); color: #dcbd7c; }
.ebook-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.ebook-txt b { font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-size: 15px; font-weight: 700; letter-spacing: .12em; }
.ebook-txt small { font-size: 10.5px; font-weight: 500; letter-spacing: .06em; opacity: .8; }
.ebook-go { width: 16px; height: 16px; flex: none; transition: transform .2s; }
.hbtn-ebook:hover .ebook-go { transform: translateX(3px); }
.hbtn-ebook { min-height: 40px; }
@media screen and (max-width: 600px) {
  .hbtn-ebook { min-height: 34px; padding: 0 9px 0 4px; gap: 6px; }
  .ebook-seal { width: 24px; height: 24px; font-size: 13px; }
  .ebook-txt small, .ebook-go { display: none; }
  .ebook-txt b { font-size: 14px; letter-spacing: .06em; }
}
@media screen and (max-width: 400px) {
  .app-results .ebook-txt { display: none; }
  .app-results .hbtn-ebook { padding: 0 4px; }
}
.hdr-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 16px);
  padding: 10px 18px; border-radius: 999px; background: var(--app-navy); color: #fff; font-size: 14px; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.hdr-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media screen and (max-width: 600px) {
  .header-inner { min-height: 52px; }
  .brand-mark { width: 32px; height: 32px; font-size: 17px; }
  .brand-title { font-size: 17px; }
  .hbtn { min-height: 34px; padding: 0 10px; font-size: 14px; }
}

/* 3. 日期表單 ------------------------------------------------------------- */
.query-bar {
  padding: 14px 18px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
}

/* 年月日與時辰、性別之間的換行點；預設不作用 */
.date-break {
  display: none;
  flex-basis: 100%;
  height: 0;
}

.home-intro .date-break {
  display: block;
}

/* 首頁寬螢幕：表單與下方入口同寬，年月日、時辰、性別與按鈕排成一列 */
@media screen and (min-width: 1040px) {
  .home-intro .date-break {
    display: none;
  }
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.select,
.date-select {
  height: 46px;
  max-width: 100%;
  margin: 0;
  padding: 0 36px 0 14px;
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23696d7a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center;
  color: var(--app-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  font-variant-numeric: lining-nums tabular-nums;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.date-select:hover {
  border-color: #a9aebb;
}

.date-select:focus-visible {
  border-color: var(--app-accent);
  outline: 2px solid var(--app-accent);
  outline-offset: 1px;
}

.date-select-year {
  min-width: 190px;
}

.date-select-short {
  min-width: 84px;
}

.date-select-time {
  min-width: 206px;
}

/* 性別：兩個選項的切換鈕（原生 radio，方向鍵可切換） */
.seg-group {
  display: inline-flex;
  gap: 3px;
  height: 46px;
  padding: 3px;
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  background: #fff;
}

.seg-group:hover {
  border-color: #a9aebb;
}

.seg {
  position: relative;
  flex: 1 1 0;
  display: inline-flex;
}

.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--app-muted);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease;
}

.seg input:checked + span {
  background: var(--app-navy);
  color: #fff;
}

.seg input:focus-visible + span {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.app-shell .date-unit {
  color: var(--app-muted);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  margin: 0;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .1em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary {
  border-color: var(--app-accent);
  background: var(--app-accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(.92);
}

/* 結果頁表單：標題在上的欄位排版（與 /chart2/ 同一規格；字型用 Noto Sans TC，清楚易讀） */
.query-bar--grid {
  padding: 22px 24px 24px;
  border-color: var(--app-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 23, 42, .04), 0 6px 20px rgba(23, 23, 42, .05);
}
.qform {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.65fr) minmax(0, 1.5fr);
  gap: 16px 24px;
  align-items: end;
  margin: 0;
  text-align: left;
}
.qform, .qform * { font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "微軟正黑體", sans-serif; }
.qf { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; }
.qf-label { color: var(--app-ink); font-size: 15px; font-weight: 500; line-height: 1.4; letter-spacing: .04em; }
.qf-label small { margin-left: 6px; color: var(--app-muted); font-size: 13px; font-weight: 400; letter-spacing: .02em; }
.qf-dates { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }   /* 月、日依內容寬度，其餘給年份 */
.qf-dates .qf-select { padding: 0 30px 0 12px; background-position: right 11px center; }
.qf-select,
.qf-name input {
  box-sizing: border-box; width: 100%; height: 52px; margin: 0;
  border: 1px solid var(--app-line-strong); border-radius: 10px; background-color: #fff;
  color: var(--app-ink); font-size: 18px; font-weight: 400; line-height: 1.2; letter-spacing: .02em;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.qf-select {
  padding: 0 38px 0 16px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2357596a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 14px;
}
.qf-name input { padding: 0 16px; }
.qf-name input::placeholder { color: #9a9eab; }
.qf-select:hover, .qf-name input:hover { border-color: #a9aebb; }
.qf-select:focus-visible, .qf-name input:focus-visible { outline: none; border-color: var(--app-accent); box-shadow: 0 0 0 3px rgba(159, 79, 4, .16); }
.qf-name { grid-column: 1 / 3; }
.qf-seg { box-sizing: border-box; width: 100%; height: 52px; padding: 4px; border-radius: 10px; border-color: transparent; background: #eff0f4; }
.qf-seg:hover { border-color: transparent; }
.qf-seg .seg span { border-radius: 7px; font-size: 17px; font-weight: 500; letter-spacing: .2em; padding-left: calc(14px + .2em); }
.qf-seg .seg input:checked + span { background: #fff; color: var(--app-ink); font-weight: 700; box-shadow: 0 1px 3px rgba(23, 23, 42, .14); }
.qf-submit .btn { width: 100%; height: 52px; border-radius: 999px; font-size: 18px; letter-spacing: .4em; padding-left: calc(22px + .4em); }

@media screen and (max-width: 900px) {
  .qform { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .qf-date, .qf-name, .qf-submit { grid-column: 1 / -1; }
}
@media screen and (max-width: 560px) {
  .query-bar--grid { padding: 16px 14px 18px; }
  .qform { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .qf-date, .qf-name, .qf-submit, .qf-time, .qf-sex { grid-column: 1; }
  .qf-dates { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .qf-select, .qf-name input { height: 48px; font-size: 16px; }
  .qf-select { padding: 0 26px 0 11px; background-position: right 9px center; background-size: 12px; }
  /* 手機：月、日依內容寬度，其餘空間給年份，日期才不會被截斷 */
  .qf-dates { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
  .qf-dates .qf-select { padding: 0 23px 0 9px; background-position: right 7px center; }
  .qf-name input { padding: 0 12px; }
  .qf-seg, .qf-submit .btn { height: 48px; }
}

/* 匯出列：報表姓名 + 匯出按鈕，位於日期表單下方 */

.print-head,
.print-foot {
  display: none;
}

/* 4. 區塊與面板 ----------------------------------------------------------- */
.chart-section {
  margin-top: 40px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--app-ink);
}

.app-shell .section-title {
  margin: 0;
  color: var(--app-ink);
  font-size: 22px;
  font-weight: var(--chart-heading-weight, 700);
  line-height: 1.35;
  letter-spacing: .04em;
}

.section-note {
  margin: 0;
  color: var(--app-muted);
  font-size: 14px;
  line-height: 1.5;
}

.key-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  color: var(--app-muted);
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
}

.key-list li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.key {
  flex: 0 0 auto;
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.key-dot { border-radius: 50%; }
.key-solar { background: var(--app-solar); }
.key-lunar { background: var(--app-lunar); }
.key-mature { background: #111; }
.key-learning { background: #9ca3af; }
.key-empty { border: 1.5px dashed #a9aebb; background: #fff; }
.key-goal { background: var(--app-goal); }
.key-chal { background: var(--app-chal); }
.key-now { border: 3px solid var(--app-now); background: #fff; }

.dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-paper);
  container-type: inline-size;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: 52px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--app-line);
  background: var(--app-surface);
  font-size: 15px;
  line-height: 1.4;
}

.cal-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 12px 3px 10px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.cal-tag::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--app-solar);
  content: "";
}

.panel-lunar .cal-tag::before,
.cal-tag-lunar::before {
  background: var(--app-lunar);
}

.panel-head-label {
  color: var(--app-muted);
  font-weight: 600;
}

.panel-head-value {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .03em;
}

.panel-head-meta {
  margin-left: auto;
  color: var(--app-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.panel-head-meta b {
  color: var(--app-ink);
  font-size: 16px;
  font-weight: 700;
}

/* 5. 四柱神煞與易經卦 ------------------------------------------------------
   上排陽曆、下排陰曆，日期列在外側、神煞相對；右側深色卡為易經卦。
   神煞的三種樣式（紅字／藍字／圓底白字）對應 chart1.php 的 shenShaClass()。 */
/* 標題旁：這次排盤依據的性別與時辰 */
.pillar-basis {
  display: inline-block;
  margin-left: 12px;
  padding: 3px 12px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .04em;
  vertical-align: middle;
  white-space: nowrap;
}

.pillar-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 216px;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-paper);
}

.pillar-rows {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.pillar-row {
  --cal: var(--app-solar);
  --cal-tint: var(--app-solar-tint);
  --cal-ink: var(--app-solar-ink);
  display: grid;
  grid-template-columns: 188px repeat(4, minmax(0, 1fr));
  min-width: 0;
}

.pillar-lunar {
  --cal: var(--app-lunar);
  --cal-tint: var(--app-lunar-tint);
  --cal-ink: var(--app-lunar-ink);
  border-top: 1px solid var(--app-line-strong);
}

.pillar-lunar .cal-tag::before {
  background: var(--app-lunar);
}

.pillar-id {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 12px 10px 12px 14px;
  background: var(--cal-tint);
  box-shadow: inset 4px 0 0 var(--cal);
  text-align: center;
}

.pillar-id-main {
  color: var(--app-ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .08em;
  white-space: nowrap;
}

.pillar-id-sub {
  margin-left: 8px;
  padding-left: 9px;
  border-left: 1px solid var(--app-line-strong);
  color: var(--cal-ink);
}

.pillar-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--app-line);
}

/* 陰曆列上下顛倒：神煞在上、日期在下，與陽曆列相對 */
.pillar-lunar .pillar-cell {
  flex-direction: column-reverse;
}

.pillar-date {
  display: block;
  height: 40px;
  overflow: hidden;
  background: var(--cal-tint);
  color: var(--cal-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 40px;
  text-align: center;
  white-space: nowrap;
}

.pillar-date b {
  margin-right: 4px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .02em;
}

.pillar-cell.is-unknown .pillar-date b {
  opacity: .5;
}

.pillar-sha {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
}

.sha {
  color: var(--app-ink);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.sha-red {
  color: #d91507;
  font-weight: 800;
}

.sha-blue {
  color: #1524c0;
  font-weight: 500;
}

.sha-disc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  font-size: 23px;
}

.sha-wen { background: #8f4586; }
.sha-gu { background: #00a600; }
.sha-po { background: #bb3d00; }
.sha-ji { background: #000; }

/* ○：沒有出生時辰，與圓圈圖的「無此數字」同樣以虛線圓表示 */
.sha-none {
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1.5px dashed #a9aebb;
  border-radius: 50%;
  color: transparent;
  font-size: 0;
}

.hex-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 16px 14px;
  background: var(--app-navy);
  color: #fff;
  text-align: center;
}

.hex-caption {
  margin: 0 0 13px;
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .16em;
}

.hex-caption b {
  margin-left: 8px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
}

/* 卦象以六條橫線繪製（不依賴系統的易經符號字型）；左為來源數字、右為上下卦名 */
.hex-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
  width: 100%;
}

.hex-lines {
  display: grid;
  gap: 6px;
}

.hex-line {
  display: block;
  height: 8px;
  border-radius: 1.5px;
  background: #fff;
}

.hex-line.is-yin {
  background: linear-gradient(90deg, #fff 0 39%, transparent 39% 61%, #fff 61% 100%);
}

.hex-digit {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.hex-tri {
  justify-self: start;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .1em;
  white-space: nowrap;
}

.app-shell .hex-name {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  align-items: baseline;
  gap: 7px;
  margin-top: 14px;
  color: #fde68a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .12em;
  white-space: nowrap;
  text-decoration: none;
}

.hex-name strong {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: .08em;
}

/* 點選可看說明的小圖示（打開的書） */
.hex-name::after {
  align-self: center;
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 4.2C6.6 3.1 4.6 2.8 2 3v9c2.6-.2 4.6.1 6 1.2 1.4-1.1 3.4-1.4 6-1.2V3c-2.6-.2-4.6.1-6 1.2zm0 0v9' fill='none' stroke='%23fde68a' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: .8;
  content: "";
}

.app-shell .hex-name:hover {
  color: #fff7cc;
  text-decoration: none;
}

.app-shell .hex-name:focus-visible {
  outline-color: #fde68a;
  outline-offset: 4px;
}

.hex-no {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, .6);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .12em;
}

/* 6. 數字頻率圖 ----------------------------------------------------------- */
.num-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.num-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 136px;
  border-right: 1px solid var(--app-line);
  border-bottom: 1px solid var(--app-line);
}

.num-cell:nth-child(3n) {
  border-right: 0;
}

.num-count {
  position: absolute;
  top: 8px;
  right: 11px;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.num-ring {
  width: 100%;
  max-width: 150px;
  min-height: 0 !important;
}

.num-ring-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.num-ring-empty span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 1.5px dashed #a9aebb;
  border-radius: 50%;
  color: #8a8f9c;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.panel-foot {
  padding: 10px 16px;
  background: var(--app-paper);
}

.panel-foot .key-list {
  justify-content: center;
}

/* 7. 大限鑽石圖 ----------------------------------------------------------- */
.dm-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 14px 22px;
}

.dm {
  /* --c 欄寬、--r 列高：依面板寬度等比縮放 */
  --c: 40px;
  --r: max(54px, var(--c));
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--c)) calc(var(--c) * 2.8);
  grid-template-rows: repeat(3, var(--r)) calc(var(--r) * 1.5) repeat(3, var(--r));
  align-items: center;
  justify-items: center;
}

@supports (width: 1cqi) {
  .dm {
    --c: clamp(33px, calc((100cqi - 30px) / 7.8), 64px);
  }
}

.dm-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--c) * 5);
  height: calc(var(--r) * 7.5);
  overflow: visible;
  pointer-events: none;
}

.dm-lines path {
  fill: none;
  stroke: #b4bac7;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.dm-node {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: calc(var(--c) * 1.5);
  height: calc(var(--r) - 12px);
  border: 1px solid;
  border-radius: 10px;
  line-height: 1.1;
}

.dm-num {
  font-size: clamp(18px, calc(var(--c) * .37), 23px);
  font-weight: 700;
  line-height: 1;
}

.dm-age {
  margin-top: 4px;
  font-size: clamp(10px, calc(var(--c) * .2), 12.5px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.dm-top {
  border-color: var(--app-goal-line);
  background: var(--app-goal-tint);
  color: var(--app-goal);
}

.dm-bot {
  border-color: var(--app-chal-line);
  background: var(--app-chal-tint);
  color: var(--app-chal);
}

.dm-node.is-current {
  color: #fff;
  box-shadow: 0 0 0 3px var(--app-now);
}

.dm-top.is-current {
  border-color: var(--app-goal);
  background: var(--app-goal);
}

.dm-bot.is-current {
  border-color: var(--app-chal);
  background: var(--app-chal);
}

.dm-base {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: calc(var(--c) * 1.2);
  height: calc(var(--r) * 1.5 - 10px);
  border: 1px solid var(--app-line-strong);
  border-radius: 10px;
  background: #fff;
  line-height: 1;
}

.dm-base-unit {
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
}

.dm-base-val {
  font-size: clamp(15px, calc(var(--c) * .34), 19px);
  font-weight: 700;
}

.dm-base-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--app-surface);
  border: 1px solid var(--app-line-strong);
  font-size: 13px;
  font-weight: 700;
}

.dm-plus {
  position: relative;
  z-index: 1;
  color: var(--app-muted);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.dm-stat,
.dm-eq {
  justify-self: start;
  margin-left: clamp(8px, calc(var(--c) * .3), 18px);
}

.dm-stat {
  display: inline-flex;
  align-items: stretch;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--app-ink);
  border-radius: 8px;
  line-height: 1;
}

.dm-stat span,
.dm-stat b {
  display: flex;
  align-items: center;
  justify-content: center;
}

.dm-stat span {
  padding: 0 clamp(6px, calc(var(--c) * .18), 10px);
  background: var(--app-navy);
  color: #fff;
  font-size: clamp(12.5px, calc(var(--c) * .26), 14px);
  font-weight: 700;
  white-space: nowrap;
}

.dm-stat b {
  min-width: clamp(34px, calc(var(--c) * .8), 46px);
  padding: 0 6px;
  background: #fff;
  color: var(--app-ink);
  font-size: clamp(17px, calc(var(--c) * .36), 20px);
  font-weight: 700;
}

.dm-stat-year {
  border-color: var(--app-year);
}

.dm-stat-year span { background: var(--app-year); }
.dm-stat-year b { background: var(--app-year-tint); color: var(--app-year); }

.dm-stat-chan {
  border-color: var(--app-chan);
}

.dm-stat-chan span { background: var(--app-chan); }
.dm-stat-chan b { background: var(--app-chan-tint); color: var(--app-chan); }

.dm-eq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px clamp(3px, calc(var(--c) * .1), 6px);
  max-width: calc(var(--c) * 2.8 - clamp(8px, calc(var(--c) * .3), 18px));
  font-size: clamp(15px, calc(var(--c) * .34), 18px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.dm-eq-step {
  display: inline-flex;
  align-items: center;
  gap: clamp(3px, calc(var(--c) * .1), 6px);
}

.dm-eq i {
  color: var(--app-muted);
  font-style: normal;
  font-weight: 600;
}

.dm-eq b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(28px, calc(var(--c) * .68), 34px);
  height: clamp(28px, calc(var(--c) * .68), 34px);
  padding: 0 6px;
  border-radius: 8px;
  background: var(--app-navy);
  color: #fff;
  font-weight: 700;
}

/* 8. 高峰／通道與本命太極 --------------------------------------------------- */
.pc-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.pc-block {
  min-width: 0;
}

.pc-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  min-height: 34px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.pc-now {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--app-now);
  color: #241a00;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.pc-grid {
  display: grid;
  gap: 6px;
}

.pc-row {
  display: flex;
  gap: 6px;
}

.pc-row > * {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.pc-row > .pc-label,
.pc-row > .pc-corner {
  flex: 0 0 52px;
}

.pc-ages > * {
  height: 26px;
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.pc-ages > .is-current {
  background: var(--app-now);
  color: #241a00;
}

.pc-label {
  height: 54px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
}

.pc-label.type-top { background: var(--app-goal); }
.pc-label.type-channel { background: var(--app-chan); }
.pc-label.type-bot { background: var(--app-chal); }

.pc-val {
  height: 54px;
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 22px;
  font-weight: 700;
}

.pc-val.type-channel {
  color: var(--app-chan);
}

.pc-val.is-current {
  border-width: 2px;
}

.pc-val.type-top.is-current {
  border-color: var(--app-goal);
  background: var(--app-goal-tint);
  color: var(--app-goal);
}

.pc-val.type-channel.is-current {
  border-color: var(--app-chan);
  background: var(--app-chan-tint);
}

.pc-val.type-bot.is-current {
  border-color: var(--app-chal);
  background: var(--app-chal-tint);
  color: var(--app-chal);
}

.core-grid {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  grid-template-rows: 26px repeat(3, 54px);
  gap: 6px;
  justify-content: center;
}

.core-caption {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.core-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--app-line-strong);
  border-radius: 8px;
  background: var(--app-surface);
  line-height: 1;
}

.core-box strong {
  font-size: 21px;
  font-weight: 700;
}

.core-box small {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
}

.core-box.is-goal {
  border-color: var(--app-goal);
  background: var(--app-goal-tint);
  color: var(--app-goal);
}

.core-box.is-chan {
  border-color: var(--app-chan);
  background: var(--app-chan-tint);
  color: var(--app-chan);
}

.core-box.is-chal {
  border-color: var(--app-chal);
  background: var(--app-chal-tint);
  color: var(--app-chal);
}

.core-top { grid-area: 2 / 2; }
.core-left { grid-area: 3 / 1; }
.core-mid { grid-area: 3 / 2; }
.core-right { grid-area: 3 / 3; }
.core-bottom { grid-area: 4 / 2; }

/* 9. 首頁 ----------------------------------------------------------------- */
.home-intro {
  max-width: 1088px;
  margin: 0 auto;
  text-align: center;
}

.home-intro .query-bar:not(.query-bar--grid) {
  padding: 20px 18px;
}

/* 首頁入口 */
.gate-intro { max-width: 1088px; margin: 16px auto 0; }
.gate {
  --g: #dcbd7c;
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 44px; align-items: center;
  background: var(--app-navy); color: #e8edf5; border-radius: 12px;
  padding: 40px 44px; overflow: hidden;
  background-image: radial-gradient(circle at 16% 50%, rgba(220, 189, 124, .18), transparent 55%);
}
.gate::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(220, 189, 124, .35); border-radius: 6px; pointer-events: none; }
.gate-emblem { position: relative; display: flex; flex-direction: column; align-items: center; }
.num-mark {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  width: min(240px, 66vw); padding: 4px;
  border: 1.5px solid var(--g); border-radius: 4px;
}
.num-mark span {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  border: 1px solid rgba(220, 189, 124, .32); color: var(--g);
  font-family: var(--chart-front-font, Georgia, serif); font-weight: 700; font-size: 34px; line-height: 1;
}
.num-mark .c { background: var(--g); border-color: var(--g); color: var(--app-navy); }
.num-mark-cap { margin: 8px 0 0; color: #9fb0cc; font-size: 12px; line-height: 1.4; letter-spacing: .3em; padding-left: .3em; }
.gate-body { position: relative; min-width: 0; }
.gate-kicker { margin: 0 0 6px; color: var(--g); font-size: 13px; line-height: 1.4; letter-spacing: .3em; }
.app-shell .gate-title { margin: 0; color: #fff; font-size: clamp(32px, 5.4vw, 48px); font-weight: var(--chart-heading-weight, 700); line-height: 1.2; letter-spacing: .16em; }
.gate .motto { margin: 12px 0 14px; color: var(--g); font-size: clamp(17px, 2.4vw, 20px); font-weight: 700; line-height: 1.6; letter-spacing: .24em; }
.m-br { display: none; }
.gate-desc { max-width: 34em; margin: 0 0 22px; color: #c3cde0; font-size: 15px; line-height: 1.75; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-gold { border-color: var(--g); background: var(--g); color: var(--app-navy); }
.btn-gold:hover { background: #e8cf98; border-color: #e8cf98; }
.app-shell .btn-line { border-color: rgba(220, 189, 124, .55); background: transparent; color: #e8edf5; }
.app-shell .btn-line:hover { border-color: var(--g); color: #fff; text-decoration: none; }
.gate-feats { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.gate-feats li { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--app-line); border-radius: 12px; background: var(--app-paper); }
.gate-feats b { color: var(--app-ink); font-size: 16px; line-height: 1.4; letter-spacing: .1em; }
.gate-feats span { color: var(--app-muted); font-size: 13px; line-height: 1.6; }
.query-bar.flash { animation: barFlash 1.2s ease-out; }
@keyframes barFlash { 0% { box-shadow: 0 0 0 0 rgba(159, 79, 4, .45); } 100% { box-shadow: 0 0 0 14px rgba(159, 79, 4, 0); } }

@media screen and (max-width: 760px) {
  .gate { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 30px 22px 28px; text-align: center; }
  .num-mark { width: min(200px, 60vw); }
  .num-mark span { font-size: 28px; }
  .gate-desc { margin-left: auto; margin-right: auto; }
  .gate-actions { justify-content: center; }
  .gate-actions .btn { flex: 1 1 140px; }
  .m-br { display: inline; }
  .gate-feats { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .query-bar.flash { animation: none; } }

/* 響應式 ------------------------------------------------------------------ */
@media screen and (max-width: 900px) {
  .dual-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .date-break {
    display: block;
  }

  .pillar-board {
    grid-template-columns: minmax(0, 1fr) 190px;
  }

  .pillar-row {
    grid-template-columns: 132px repeat(4, minmax(0, 1fr));
  }

  .pillar-id {
    padding-right: 6px;
    padding-left: 10px;
  }

  .pillar-id-main {
    font-size: 18px;
    letter-spacing: .04em;
  }

  .pc-wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    max-width: 520px;
    margin: 0 auto;
  }

  /* 陰曆表在桌機為鏡像排列；單欄時改回由左至右 */
  .pc-grid.is-reverse .pc-row {
    flex-direction: row-reverse;
  }
}

@media screen and (max-width: 640px) {
  .chart-section {
    margin-top: 32px;
  }

  .app-shell .section-title {
    font-size: 20px;
  }

  .query-bar {
    padding: 14px;
  }

  .date-break,
  .home-intro .date-break {
    display: none;
  }

  .date-field:first-of-type,
  .date-field-time,
  .date-field-sex {
    grid-column: 1 / -1;
  }

  .seg-group {
    flex: 1 1 auto;
  }

  .date-field .date-select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }

  /* 四柱：曆別改為各列上方的標題條，四柱均分整個寬度；易經卦移到下方橫排 */
  .pillar-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .pillar-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pillar-id {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 9px 12px 9px 16px;
  }

  .pillar-id + .pillar-cell {
    border-left: 0;
  }

  .pillar-lunar .pillar-cell {
    flex-direction: column;
  }

  .pillar-date {
    height: 36px;
    border-top: 1px solid var(--app-line);
    border-bottom: 1px solid var(--app-line);
    background: var(--app-paper);
    line-height: 34px;
  }

  .pillar-date b {
    font-size: 17px;
  }

  .pillar-sha {
    min-height: 62px;
  }

  .hex-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "figure caption" "figure name" "figure no";
    align-content: center;
    justify-items: start;
    column-gap: 20px;
    padding: 18px 16px;
    text-align: left;
  }

  .hex-caption {
    grid-area: caption;
    margin-bottom: 0;
  }

  .hex-figure {
    grid-area: figure;
    grid-template-columns: auto 74px auto;
    width: auto;
  }

  .app-shell .hex-name {
    grid-area: name;
    margin-top: 10px;
  }

  .hex-no {
    grid-area: no;
  }

  .num-cell {
    height: 120px;
  }

  .panel-head {
    padding: 10px 12px;
  }

  .dm-wrap {
    padding: 20px 10px 18px;
  }

  @supports (width: 1cqi) {
    .dm {
      --c: clamp(33px, calc((100cqi - 22px) / 7.8), 64px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .seg span {
    transition: none;
  }
}

/* 10. 列印／匯出 PDF -------------------------------------------------------
   一頁 A4 直式。先以 960px 的桌機版面排版，再整體縮放到紙張寬度
   （A4 扣除左右邊界為 190mm ≈ 718px；718 ÷ 960 ≈ .746）。
   版面高度已預留餘裕，調整下方尺寸時請確認仍在一頁之內。 */
@page {
  size: A4 portrait;
  margin: 8mm 10mm;
}

@media print {
  html,
  body {
    min-height: 0;
    background: #fff;
  }

  .site-header,
  .hdr-toast,
  .query-bar {
    display: none !important;
  }

  .app-shell {
    width: 960px;
    max-width: none;
    margin: 0;
    padding: 0;
    zoom: .746;
  }

  .app-shell * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .chart-section,
  .panel,
  .pc-block,
  .print-head {
    break-inside: avoid;
  }

  /* 頁首：品牌、報表名稱與基本資料 */
  .print-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px 24px;
  }

  .print-brand {
    display: flex;
    align-items: baseline;
    gap: 14px;
    min-width: 0;
    line-height: 1.1;
  }

  .print-brand strong {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: .04em;
  }

  .print-brand span {
    color: var(--app-muted);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .3em;
  }

  .print-doc {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: .3em;
  }

  .print-meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 28px;
    margin: 0;
    padding: 9px 16px;
    border: 1px solid var(--app-line-strong);
    border-top: 2px solid var(--app-ink);
    border-radius: 0 0 10px 10px;
    background: var(--app-surface);
    line-height: 1.3;
  }

  .print-meta > div {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
  }

  .print-meta > div:last-child {
    margin-left: auto;
  }

  .print-meta dt {
    color: var(--app-muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
  }

  .print-meta dd {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .03em;
    white-space: nowrap;
  }

  /* 沒填姓名時留一條可手寫的底線 */
  .print-meta dd[data-print-name] {
    min-width: 150px;
    min-height: 23px;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
  }

  .print-meta dd[data-print-name]:empty {
    border-bottom: 1px solid var(--app-ink);
  }

  /* 區塊間距與面板：比螢幕略為收緊 */
  .chart-section {
    margin-top: 15px;
  }

  .section-head {
    margin-bottom: 10px;
    padding-bottom: 6px;
  }

  .app-shell .section-title {
    font-size: 20px;
  }

  .dual-grid {
    gap: 16px;
  }

  .panel-head {
    min-height: 42px;
    padding: 5px 14px;
  }

  /* 四柱神煞：一頁 A4 放不下完整版，列印時收成一條橫帶
     （標題｜陽曆四柱｜陰曆四柱｜易經卦）。日期已在頁首與下方面板，這裡只留神煞。 */
  .pillar-section {
    display: flex;
    align-items: stretch;
    margin-top: 8px;
    overflow: hidden;
    border: 1px solid var(--app-line-strong);
    border-radius: 10px;
  }

  .pillar-section .section-head {
    flex: 0 0 auto;
    align-items: center;
    margin: 0;
    padding: 0 10px;
    border: 0;
    background: var(--app-navy);
  }

  .app-shell .pillar-section .section-title {
    color: #fff;
    font-size: 15px;
    letter-spacing: .06em;
    white-space: nowrap;
  }

  .pillar-basis {
    margin-left: 8px;
    padding: 0;
    border: 0;
    color: rgba(255, 255, 255, .78);
    font-size: 12.5px;
    letter-spacing: .02em;
  }

  .pillar-section .section-note,
  .pillar-date b,
  .hex-caption-lead,
  .hex-digit,
  .hex-tri,
  .hex-no,
  .hex-name::after {
    display: none;
  }

  .pillar-board {
    flex: 1 1 auto;
    display: flex;
    min-width: 0;
    border: 0;
    border-radius: 0;
  }

  .pillar-rows {
    flex: 1 1 auto;
    display: flex;
  }

  .pillar-row {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    height: 34px;
    padding-right: 6px;
    border-top: 0;
  }

  .pillar-row + .pillar-row {
    border-left: 1px solid var(--app-line-strong);
  }

  .pillar-id {
    flex: 0 0 auto;
    flex-direction: row;
    align-self: stretch;
    gap: 6px;
    padding: 0 8px;
    box-shadow: none;
  }

  .pillar-id .cal-tag {
    gap: 5px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 13px;
  }

  .pillar-id-main {
    font-size: 15px;
    letter-spacing: .04em;
  }

  .pillar-id-sub {
    margin-left: 6px;
    padding-left: 6px;
  }

  .pillar-cell,
  .pillar-lunar .pillar-cell {
    flex: 1 1 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-left: 0;
  }

  .pillar-date {
    height: auto;
    background: none;
    color: var(--app-muted);
    font-size: 13px;
    line-height: 1;
  }

  .pillar-sha {
    flex: 0 0 auto;
    min-height: 0;
  }

  .sha {
    font-size: 17px;
  }

  .sha-disc {
    width: 23px;
    height: 23px;
    font-size: 13.5px;
  }

  .sha-none {
    width: 18px;
    height: 18px;
    font-size: 0;
  }

  .hex-card {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    padding: 0 10px;
  }

  .hex-caption {
    margin: 0;
    font-size: 12.5px;
    letter-spacing: .08em;
  }

  .hex-caption b {
    margin-left: 5px;
    font-size: 15px;
    letter-spacing: .04em;
  }

  .hex-figure {
    display: grid;
    grid-template-columns: 22px;
    gap: 2px;
    width: auto;
  }

  .hex-lines {
    gap: 2px;
  }

  .hex-line {
    height: 2.5px;
    border-radius: 0;
  }

  .app-shell .hex-name {
    gap: 3px;
    margin-top: 0;
    font-size: 14px;
    letter-spacing: .06em;
  }

  .hex-name strong {
    font-size: 17px;
    letter-spacing: .04em;
  }

  /* 原為 103px；加入四柱橫帶後收 5px × 3 列，維持頁尾前的餘裕 */
  .num-cell {
    height: 98px;
  }

  .num-ring {
    zoom: .77;
  }

  .num-ring-empty {
    zoom: 1;
  }

  /* 滿圈的圓弧在 PDF 會於 12 點鐘方向留下一道細縫；圓形端點讓首尾相接且不凸出圓環 */
  .num-ring .apexcharts-radialbar-area {
    stroke-linecap: round;
  }

  .panel-foot {
    padding: 7px 14px;
  }

  .dm-wrap {
    padding: 13px 12px 12px;
  }

  /* 固定欄寬列高；右側欄加寬，讓「= 37 = 10 = 1」這類三段算式不換行 */
  .dm {
    --c: 50px;
    --r: 49px;
    grid-template-columns: repeat(5, var(--c)) calc(var(--c) * 3.5);
  }

  .dm-base {
    gap: 3px;
  }

  .dm-eq {
    flex-wrap: nowrap;
    max-width: none;
  }

  .pc-wrap {
    gap: 26px;
  }

  .pc-title {
    margin-bottom: 6px;
  }

  .pc-label,
  .pc-val {
    height: 46px;
  }

  .core-grid {
    grid-template-rows: 26px repeat(3, 46px);
  }

  /* 頁尾 */
  .print-foot {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-top: 9px;
    padding-top: 7px;
    border-top: 1px solid var(--app-line-strong);
    color: var(--app-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
  }
}

/* 11. 本命太極八卦 -----------------------------------------------------------
   components/chart13.php。九宮依方位排列（上南下北、左東右西），
   數對左字＝外能（陽曆紅）、右字＝內能（陰曆綠）；底色依流年吉凶分四級。
   列印時自成第二頁（版面高度以 960px 寬設計，縮放後約 1400px 內）。 */
.bg8-section {
  --bg8-good: #8a5a00;
  --bg8-good-tint: #fdf3dc;
  --bg8-good-line: #ead29a;
  --bg8-calm: #4b5563;
  --bg8-calm-tint: #f3f4f6;
  --bg8-calm-line: #d6d9e0;
  --bg8-shift: #1d4f91;
  --bg8-shift-tint: #eaf1fb;
  --bg8-shift-line: #bcd0ec;
  --bg8-bad: #a52222;
  --bg8-bad-tint: #fbeceb;
  --bg8-bad-line: #ecc4c1;
  --bg8-star: #7a2e8e;
  margin-top: 56px;
}

.bg8-print-head { display: none; }

.bg8-title-sub {
  margin-left: 10px;
  padding: 2px 10px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  vertical-align: middle;
}

.bg8-key-good { background: var(--bg8-good-tint); border: 1.5px solid var(--bg8-good); }
.bg8-key-calm { background: var(--bg8-calm-tint); border: 1.5px solid var(--bg8-calm); }
.bg8-key-shift { background: var(--bg8-shift-tint); border: 1.5px solid var(--bg8-shift); }
.bg8-key-bad { background: var(--bg8-bad-tint); border: 1.5px solid var(--bg8-bad); }

.bg8-section .is-solar { color: var(--app-solar); }
.bg8-section .is-lunar { color: var(--app-lunar); }

/* ① 原理 */
.bg8-how {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.bg8-how-step {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
}

.bg8-how-no {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--app-navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.bg8-how-step b {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: .06em;
}

.bg8-how-step p {
  margin: 2px 0 0;
  color: #3b3f4c;
  font-size: 14px;
  line-height: 1.6;
}

.bg8-how-step em {
  font-style: normal;
  font-weight: 700;
}

.bg8-how-step em.is-now {
  padding: 0 4px;
  border-radius: 4px;
  background: #fdecb5;
  color: #5a3d00;
}

.bg8-how-step strong {
  font-family: "Oswald", var(--chart-front-font, sans-serif);
  font-size: 18px;
  letter-spacing: .04em;
}

.bg8-how-step:has(.bg8-path) {
  padding-right: 78px;
}

.bg8-path {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 58px;
  height: 58px;
}

.bg8-path rect {
  fill: #fff;
  stroke: var(--app-line-strong);
  stroke-width: 1;
}

.bg8-path text {
  fill: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.bg8-path polyline {
  fill: none;
  stroke: var(--app-accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: .75;
}

/* ② 九宮盤 */
.bg8-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, auto);
  gap: 10px;
}

.bg8-cell {
  --t: var(--bg8-calm);
  --t-tint: var(--bg8-calm-tint);
  --t-line: var(--bg8-calm-line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--app-line-strong);
  border-radius: 12px;
  background: var(--app-paper);
}

.tier-good { --t: var(--bg8-good); --t-tint: var(--bg8-good-tint); --t-line: var(--bg8-good-line); }
.tier-calm { --t: var(--bg8-calm); --t-tint: var(--bg8-calm-tint); --t-line: var(--bg8-calm-line); }
.tier-shift { --t: var(--bg8-shift); --t-tint: var(--bg8-shift-tint); --t-line: var(--bg8-shift-line); }
.tier-bad { --t: var(--bg8-bad); --t-tint: var(--bg8-bad-tint); --t-line: var(--bg8-bad-line); }

.bg8-cell.is-center {
  border: 2px solid var(--app-navy);
}

.bg8-cell.is-now {
  border-color: var(--app-now);
  box-shadow: 0 0 0 3px var(--app-now);
}

.bg8-cell-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--app-line);
  line-height: 1.2;
}

.bg8-dir {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--app-navy);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
}

.bg8-gua {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .06em;
}

.bg8-gua small {
  margin-left: 4px;
  padding: 1px 6px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
}

.bg8-star {
  margin-left: auto;
  color: var(--bg8-star);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.bg8-star small {
  margin-left: 3px;
  color: var(--app-muted);
  font-size: 12px;
}

.is-center .bg8-cell-head {
  background: var(--app-navy);
  color: #fff;
}

.is-center .bg8-dir {
  background: #fff;
  color: var(--app-navy);
}

.is-center .bg8-gua small,
.is-center .bg8-star,
.is-center .bg8-star small {
  border-color: rgba(255, 255, 255, .4);
  color: #f1d9ff;
}

.bg8-cell-main {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 10px 4px;
}

.bg8-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 92px;
  border: 1.5px solid var(--t-line);
  border-radius: 10px;
  background: var(--t-tint);
}

.bg8-pair b {
  font-family: "Oswald", var(--chart-front-font, sans-serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .02em;
}

.bg8-yn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--t);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .1em;
}

.bg8-yn i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--t);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0;
}

.bg8-hexbox {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
}

.bg8-hex {
  grid-row: 1 / 3;
  display: grid;
  gap: 4px;
  width: 46px;
}

.bg8-hex i {
  display: block;
  height: 6px;
  border-radius: 1px;
  background: var(--app-ink);
}

.bg8-hex i.is-yin {
  background: linear-gradient(90deg, var(--app-ink) 0 40%, transparent 40% 60%, var(--app-ink) 60% 100%);
}

/* 上下卦之間留一點縫，方便讀出兩個三爻卦 */
.bg8-hex i:nth-child(3) { margin-bottom: 3px; }

.app-shell .bg8-hexname {
  align-self: end;
  justify-self: start;
  padding: 0;
  border: 0;
  border-bottom: 1px dashed var(--app-line-strong);
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--app-ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .06em;
  white-space: nowrap;
}

.app-shell .bg8-hexname:hover { border-bottom-color: var(--app-accent); color: var(--app-accent); }

.bg8-hexkw {
  align-self: start;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.bg8-kw {
  margin: 4px 10px 0;
  color: var(--t);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.bg8-facts {
  display: grid;
  gap: 2px;
  margin: 6px 10px 0;
  font-size: 13.5px;
  line-height: 1.5;
}

.bg8-facts > div {
  display: flex;
  gap: 8px;
}

.bg8-facts dt {
  flex: 0 0 30px;
  color: var(--app-muted);
  font-weight: 700;
}

.bg8-facts dd {
  margin: 0;
  min-width: 0;
  color: #2a2d38;
  font-weight: 600;
}

.bg8-ages {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: auto 0 0;
  padding: 8px 10px 10px;
  list-style: none;
}

.bg8-ages li {
  min-width: 23px;
  padding: 1px 2px;
  border-radius: 4px;
  color: #3b3f4c;
  font-family: "Oswald", var(--chart-front-font, sans-serif);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
}

.bg8-ages li.is-past { color: #a3a7b3; }

.bg8-ages li.is-now {
  background: var(--app-now);
  color: #241a00;
  font-weight: 700;
}

/* ③ 深入解讀 */
.bg8-read {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1.15fr;
  gap: 12px;
  margin-top: 16px;
}

.bg8-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-paper);
}

.bg8-card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--app-line);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .06em;
}

.bg8-card h3 small {
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}

.bg8-card p {
  margin: 8px 0 0;
  color: #2a2d38;
  font-size: 14.5px;
  line-height: 1.7;
}

.bg8-card p b { font-weight: 700; }

.bg8-core {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bg8-hex.is-lg {
  width: 54px;
  gap: 5px;
}

.bg8-hex.is-lg i { height: 7px; }

.bg8-card .bg8-core-name {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .08em;
}

.bg8-core-name small {
  margin-left: 8px;
  color: var(--app-muted);
  font-size: 13px;
  letter-spacing: .04em;
}

.bg8-card .bg8-core-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.bg8-core-tags span {
  padding: 1px 9px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  background: var(--app-surface);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.bg8-core-tags span[class^="tier-"] {
  border-color: var(--t);
  background: var(--t-tint);
  color: var(--t);
}

.bg8-dist {
  display: flex;
  gap: 3px;
  height: 26px;
  margin-bottom: 10px;
}

.bg8-dist span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  border: 1px solid var(--t-line);
  border-radius: 6px;
  background: var(--t-tint);
  color: var(--t);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.bg8-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.bg8-list > div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.bg8-list dt {
  padding: 1px 0;
  border-radius: 5px;
  background: var(--t-tint);
  color: var(--t);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
}

.bg8-list dd {
  margin: 0;
  color: #2a2d38;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.bg8-list dd span {
  display: inline-block;
  margin: 0 8px 2px 0;
  font-weight: 700;
}

.bg8-list dd span small {
  margin-left: 3px;
  color: var(--bg8-good);
  font-size: 12px;
}

.bg8-list dd em {
  display: block;
  color: var(--app-muted);
  font-size: 12.5px;
  font-style: normal;
  font-weight: 600;
}

.bg8-cycle {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bg8-cycle li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0 6px;
  border: 1px solid var(--t-line);
  border-radius: 6px;
  background: var(--t-tint);
  line-height: 1.1;
}

.bg8-cycle b {
  font-family: "Oswald", var(--chart-front-font, sans-serif);
  font-size: 15px;
  font-weight: 500;
}

.bg8-cycle span {
  font-size: 13px;
  font-weight: 700;
}

.bg8-cycle small {
  color: var(--t);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.bg8-cycle li.is-past { opacity: .5; }

.bg8-cycle li.is-now {
  border: 2px solid var(--app-now);
  box-shadow: 0 0 0 1px var(--app-now);
  opacity: 1;
}

.bg8-note {
  margin: 12px 0 0;
  color: var(--app-muted);
  font-size: 13px;
  line-height: 1.6;
}

@media screen and (max-width: 980px) {
  .bg8-how { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bg8-read { grid-template-columns: minmax(0, 1fr); }
}

@media screen and (max-width: 860px) {
  .bg8-cell-main { grid-template-columns: 86px minmax(0, 1fr); }
  .bg8-pair { height: 80px; }
  .bg8-pair b { font-size: 36px; }
  .bg8-hexbox { grid-template-columns: 36px minmax(0, 1fr); column-gap: 8px; }
  .bg8-hex { width: 36px; gap: 3px; }
  .bg8-hex i { height: 5px; }
  .bg8-star small { display: none; }
}

/* 手機：九宮改為單欄，依飛星順序（中→乾→兌…）由上而下 */
@media screen and (max-width: 640px) {
  .bg8-section { margin-top: 40px; }
  .bg8-how { grid-template-columns: minmax(0, 1fr); }
  .bg8-board { grid-template-columns: minmax(0, 1fr); }
  .bg8-cell { grid-area: auto !important; }
  .bg8-cell-main { grid-template-columns: 104px minmax(0, 1fr); }
  .bg8-pair { height: 88px; }
  .bg8-pair b { font-size: 42px; }
  .bg8-star small { display: inline; }
  .bg8-title-sub { display: none; }
}

@media print {
  .bg8-section {
    break-before: page;
    page-break-before: always;
    margin-top: 0;
  }

  .bg8-print-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--app-line-strong);
    line-height: 1.2;
  }

  .bg8-print-head strong {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .04em;
  }

  .bg8-print-head span {
    color: var(--app-muted);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .3em;
  }

  .bg8-print-head em {
    margin-left: auto;
    font-size: 15px;
    font-style: normal;
    font-weight: 700;
  }

  .bg8-how,
  .bg8-board,
  .bg8-read {
    break-inside: avoid;
  }

  .bg8-how { margin-bottom: 12px; }
  .bg8-how-step { padding: 10px 12px; }
  .bg8-read { margin-top: 12px; }
  .bg8-card { padding: 12px 14px; }
  .bg8-card p { font-size: 14px; line-height: 1.65; }

  .bg8-cell.is-now { box-shadow: 0 0 0 2px var(--app-now); }

  /* 第二頁高度收緊：原理列、九宮、解讀卡都要在一頁之內 */
  .bg8-section .section-head { margin-bottom: 10px; }
  .bg8-how { gap: 8px; margin-bottom: 10px; }
  .bg8-how-step { padding: 8px 10px; gap: 8px; }
  .bg8-how-step:has(.bg8-path) { padding-right: 66px; }
  .bg8-path { top: 8px; right: 8px; width: 52px; height: 52px; }
  .bg8-how-step b { font-size: 14.5px; }
  .bg8-how-step p { font-size: 13px; line-height: 1.5; }
  .bg8-board { gap: 8px; }
  .bg8-cell-head { padding: 5px 10px; }
  .bg8-cell-main { padding: 8px 10px 2px; }
  .bg8-pair { height: 80px; }
  .bg8-pair b { font-size: 40px; }
  .bg8-kw { margin-top: 2px; font-size: 12.5px; }
  .bg8-facts { margin-top: 4px; font-size: 13px; line-height: 1.42; }
  .bg8-ages { padding: 5px 10px 7px; }
  .bg8-read { gap: 10px; margin-top: 10px; }
  .bg8-card { padding: 10px 12px; }
  .bg8-card h3 { margin-bottom: 8px; padding-bottom: 5px; font-size: 16px; }
  .bg8-card p { margin-top: 6px; font-size: 13.5px; line-height: 1.55; }
  .bg8-list { gap: 5px; }
  .bg8-list dd { font-size: 13.5px; line-height: 1.5; }
  .bg8-note { margin-top: 8px; font-size: 12px; }
}

/* 14. App 下載推廣卡（KKNumerology 太極靈數）-------------------------------- */
.app-promo {
  --g: #dcbd7c;
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 22px; align-items: center;
  margin: 28px 0 0; padding: 22px 26px;
}
.app-home .app-promo { max-width: 1088px; margin: 16px auto 0; box-sizing: border-box; }
.app-promo {
  border-radius: 12px; background: var(--app-navy); color: #e8edf5;
  background-image: radial-gradient(circle at 8% 50%, rgba(220, 189, 124, .2), transparent 50%);
}
.app-promo::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(220, 189, 124, .3); border-radius: 8px; pointer-events: none; }
.app-promo-icon { position: relative; width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.app-promo-body { position: relative; min-width: 0; }
.app-promo-kicker { margin: 0 0 2px; color: var(--g); font-size: 12px; line-height: 1.4; letter-spacing: .3em; }
.app-shell .app-promo-title { margin: 0; color: #fff; font-size: clamp(20px, 2.8vw, 26px); font-weight: var(--chart-heading-weight, 700); line-height: 1.3; letter-spacing: .08em; }
.app-promo-desc { margin: 6px 0 0; color: #c3cde0; font-size: 14px; line-height: 1.7; }
.app-promo-actions { position: relative; display: flex; flex-direction: column; gap: 10px; }
.app-shell .store-btn {
  display: inline-flex; align-items: center; gap: 10px; min-width: 196px; padding: 8px 18px 8px 14px;
  border: 1px solid rgba(220, 189, 124, .55); border-radius: 12px; background: rgba(255, 255, 255, .04);
  color: #fff; text-decoration: none; transition: background .15s, border-color .15s;
}
.app-shell .store-btn:hover { border-color: var(--g); background: rgba(220, 189, 124, .14); text-decoration: none; }
.app-shell .store-btn:focus-visible { outline: 2px solid var(--g); outline-offset: 2px; }
.app-shell .store-btn.is-mine { border-color: var(--g); background: var(--g); color: var(--app-navy); }
.store-btn svg { flex: 0 0 auto; width: 24px; height: 24px; }
.store-btn span { display: flex; flex-direction: column; line-height: 1.25; }
.store-btn small { font-size: 11px; opacity: .8; letter-spacing: .06em; }
.store-btn b { font-size: 16px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
@media (max-width: 760px) {
  .app-promo { grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; padding: 20px 18px; }
  .app-promo { align-items: start; }
  .app-promo-icon { width: 64px; height: 64px; border-radius: 16px; }
  .app-shell .app-promo-title { font-size: 19px; letter-spacing: .04em; }
  .app-promo-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .app-shell .store-btn { flex: 1 1 100%; min-width: 0; justify-content: center; }
}
@media print {
  .app-promo { display: none !important; }
}
