/*
 * Luopan — visual system v2 (UI upgrade 2026-11-10).
 * The site is read like a feng shui compass: a dark lacquer base plate (header, hero, footer),
 * a brass-yellow dial face, two vermilion threads (天心十道) crossing at the centre.
 * Content sits on cool moon-white paper. Boldness is spent on the hero dial only.
 */
@font-face { font-family: "Spectral"; font-weight: 500; font-style: normal; font-display: swap; src: url("/assets/fonts/spectral-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-weight: 600; font-style: normal; font-display: swap; src: url("/assets/fonts/spectral-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/assets/fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/assets/fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/assets/fonts/public-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Noto Serif SC Subset"; font-weight: 400; font-style: normal; font-display: swap; src: url("/assets/fonts/noto-serif-sc-subset-400.woff2") format("woff2"); }
@font-face { font-family: "Noto Serif SC Subset"; font-weight: 600 700; font-style: normal; font-display: swap; src: url("/assets/fonts/noto-serif-sc-subset-600.woff2") format("woff2"); }

:root {
  /* Core palette */
  --lacquer: #3a1f18;      /* 漆木 base plate: header, hero, footer, result head */
  --lacquer-2: #4b2b22;    /* raised surfaces on lacquer */
  --face: #e6c97a;         /* 盘面 brass-yellow dial face; text on lacquer */
  --vermilion: #b5321e;    /* 天心十道 red thread: primary action, Kua numeral */
  --jade: #2b5b4e;         /* links, favorable */
  --paper: #eef1ec;        /* 月白 moon-white page */
  --ink: #221c18;
  /* Derived */
  --surface: #ffffff;
  --ink-soft: #5a524b;
  --line: #d3d0c6;
  --field: #8a8178;
  --brass: #a8843c;        /* decorative rules only, never text */
  --face-tint: #f5e7bf;    /* favorable fills, pending notes */
  --face-deep: #8a6a1e;    /* text on face-tint */
  --stone: #d9d2c8;        /* unfavorable fills */
  --jade-tint: #e1ebe5;
  --vermilion-tint: #f8e3dd;
  --on-lacquer-soft: #d9c7b4;
  --focus: #1f5fbf;
  --serif: "Spectral", "Iowan Old Style", Georgia, "Noto Serif SC Subset", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Serif SC Subset", sans-serif;
  --zh: "Noto Serif SC Subset", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --r-sm: 4px;
  --r-md: 8px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.65 var(--sans); font-kerning: normal; }
[lang="zh"] { font-family: var(--zh); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; color: var(--ink); letter-spacing: -0.005em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); line-height: 1.08; margin: 0 0 1rem; }
h2 { font-size: clamp(1.5rem, 2.6vw, 1.95rem); line-height: 1.2; margin: 3rem 0 .9rem; }
h3 { font-size: 1.3rem; line-height: 1.3; margin: 1.8rem 0 .5rem; }
h4 { font-size: 1.08rem; line-height: 1.35; margin: 1.4rem 0 .45rem; }
p, li { text-wrap: pretty; }
a { color: var(--jade); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--vermilion); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #e6e9e3; padding: .05em .35em; border-radius: var(--r-sm); font-size: .9em; }
strong { font-weight: 600; }
.muted { color: var(--ink-soft); }
.sub { display: block; font-size: .78em; font-weight: 400; color: var(--ink-soft); }
[hidden] { display: none !important; }

.wrap, .wrap-narrow { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow > * { max-width: 46rem; }
.wrap-narrow > .quick-panel { max-width: none; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--ink); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Lacquer band: header, breadcrumbs, hero ---------- */
.site-header, .breadcrumbs, .hero { background: var(--lacquer); color: var(--face); }
.site-header :focus-visible, .breadcrumbs :focus-visible, .hero-text :focus-visible, .site-footer :focus-visible { outline-color: var(--face); }
.site-header { border-bottom: 1px solid rgba(230, 201, 122, .22); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 2rem; padding-top: .8rem; padding-bottom: .8rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--serif); font-weight: 600; font-size: 1.08rem; color: var(--face); text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.nav { list-style: none; display: flex; flex-wrap: wrap; gap: .1rem 1.6rem; margin: 0; padding: 0; font-size: .95rem; }
.nav a { color: var(--on-lacquer-soft); text-decoration: none; display: inline-block; padding: .4rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: var(--face); border-bottom-color: var(--vermilion); }
.breadcrumbs { max-width: none; padding: 0; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; max-width: 1180px; margin: 0 auto; padding: .9rem 24px 0; font-size: .86rem; color: var(--on-lacquer-soft); }
.breadcrumbs a { color: var(--face); }
.breadcrumbs li + li::before { content: "/"; margin-right: .4rem; opacity: .6; }

.hero { position: relative; overflow: hidden; padding: 2.6rem 0 3.4rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 430px); grid-template-areas: "text dial" "form dial"; column-gap: 3.5rem; align-items: start; }
.hero-wide .hero-grid { grid-template-areas: "text dial" "form form"; }
.hero-text { grid-area: text; }
.hero-dial { grid-area: dial; position: relative; }
.hero-form { grid-area: form; min-width: 0; }
.hero h1 { color: var(--face); }
.h1-split .h1-name { display: block; }
.h1-split .h1-desc { display: block; margin-top: .45rem; font-family: var(--serif); font-weight: 500; font-size: .52em; line-height: 1.25; color: var(--on-lacquer-soft); letter-spacing: 0; }
.lede { font-size: 1.1rem; line-height: 1.6; max-width: 40rem; margin: 0 0 1.8rem; }
.hero .lede { color: #efe4d3; }
.hero .lede strong { color: #fff; font-weight: 600; }
.hero-wide .hero-form { margin-top: .4rem; }

/* Hero luopan */
.luopan { display: block; width: 100%; height: auto; overflow: visible; }
.luopan .lp-face { fill: var(--face); }
.luopan .lp-ring, .luopan .lp-sep { fill: none; stroke: var(--lacquer); stroke-width: 1.1; }
.luopan .lp-sep { stroke-width: .8; opacity: .55; }
.luopan .lp-tick { stroke: var(--lacquer); stroke-width: 1; opacity: .7; }
.luopan .lp-tick-major { stroke-width: 2; opacity: 1; }
.luopan .lp-zh { font-family: var(--zh); font-weight: 600; font-size: 19px; text-anchor: middle; dominant-baseline: central; fill: var(--lacquer); }
.luopan .lp-yao { fill: var(--lacquer); }
.luopan .lp-num { font-family: var(--serif); font-weight: 600; font-size: 20px; text-anchor: middle; dominant-baseline: central; fill: var(--vermilion); }
.luopan-zodiac .lp-stem, .luopan-zodiac .lp-gua, .luopan-zodiac .lp-yao, .luopan-zodiac .lp-num { opacity: .4; }
.luopan-zodiac .lp-branch { fill: var(--vermilion); font-size: 21px; }
.luopan .lp-pool { fill: var(--lacquer); }
.luopan .lp-pool-ring { fill: none; stroke: var(--brass); stroke-width: 1.2; }
.luopan .lp-needle-n { fill: var(--vermilion); }
.luopan .lp-needle-s { fill: var(--face); }
.luopan .lp-pivot { fill: var(--face); }
.luopan .lp-thread { stroke: #d2462e; stroke-width: 1.3; }
@media (prefers-reduced-motion: no-preference) {
  .luopan .lp-dial { transform-box: view-box; transform-origin: 50% 50%; animation: lp-settle 2.2s cubic-bezier(.16, .8, .2, 1) both; }
  .luopan .lp-needle { transform-box: view-box; transform-origin: 50% 50%; animation: lp-needle 2.6s ease-out both; }
}
@keyframes lp-settle { from { transform: rotate(-42deg); } to { transform: rotate(0); } }
@keyframes lp-needle { 0% { transform: rotate(58deg); } 30% { transform: rotate(-22deg); } 50% { transform: rotate(10deg); } 68% { transform: rotate(-4deg); } 84% { transform: rotate(1.5deg); } 100% { transform: rotate(0); } }

/* ---------- Calculator form: the light plate on the lacquer base ---------- */
.calc-card { background: var(--surface); color: var(--ink); border-radius: var(--r-md); padding: 1.4rem 1.5rem 1.5rem; max-width: 46rem; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 18px 40px -18px rgba(0, 0, 0, .55); }
.hero-wide .calc-card { max-width: none; }
fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; min-width: 0; }
legend { font-weight: 600; font-size: 1rem; margin-bottom: .45rem; padding: 0; }
.date-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: .65rem; }
.field label { display: block; font-size: .84rem; color: var(--ink-soft); margin-bottom: .2rem; }
input[type="text"], select { width: 100%; font: inherit; font-size: 1rem; padding: .6rem .7rem; border: 1px solid var(--field); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-height: 46px; }
input[type="text"]::placeholder { color: #736a62; }
input[type="text"]:hover, select:hover { border-color: var(--ink); }
[aria-invalid="true"], .has-error input[type="text"][aria-invalid="true"], .has-error select[aria-invalid="true"] { border: 2px solid var(--vermilion); background: #fff7f5; }
.gender-fs.has-error .radio-row, .sign-fs.has-error .sign-grid { outline: 2px solid var(--vermilion); outline-offset: 4px; border-radius: var(--r-sm); }
.radio-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.radio, .segmented label { display: inline-flex; align-items: center; gap: .5rem; min-height: 46px; padding: 0 1.1rem; border: 1px solid var(--field); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
.radio:has(input:checked), .segmented label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--face-tint); font-weight: 600; }
.radio input, .segmented input, .sign input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--vermilion); }
.hint { font-size: .84rem; color: var(--ink-soft); margin: .4rem 0 0; }
.field-error, .form-summary { color: var(--vermilion); font-weight: 600; margin: .45rem 0 0; }
.form-summary { background: var(--vermilion-tint); padding: .6rem .8rem; border-radius: var(--r-sm); }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .8rem; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: var(--r-sm); padding: .7rem 1.5rem; min-height: 48px; background: var(--vermilion); color: #fff; cursor: pointer; transition: background-color .15s ease; }
.btn:hover:not(:disabled) { background: #962816; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-loading { opacity: .8; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--face-tint); }
.btn-ghost { background: transparent; color: var(--jade); border: 1px solid var(--field); }
.btn-ghost:hover:not(:disabled) { background: var(--jade-tint); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: .5rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem; }
.sign-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.sign { display: flex; align-items: center; gap: .5rem; min-height: 46px; padding: 0 .55rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; font-size: .95rem; }
.sign:hover { border-color: var(--field); }
.sign input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sign:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.sign:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--face-tint); font-weight: 600; }
.sign:has(input:checked) .seal { background: var(--vermilion); color: #fff; border-color: var(--vermilion); }
.sign-zh { color: var(--ink-soft); font-weight: 400; margin-left: auto; }
.seal { display: inline-grid; place-items: center; flex: none; width: 1.9rem; height: 1.9rem; border: 1.5px solid var(--vermilion); border-radius: 3px; color: var(--vermilion); font-family: var(--zh); font-weight: 600; font-size: 1rem; line-height: 1; }
.seal-lg { width: 2.6rem; height: 2.6rem; font-size: 1.45rem; background: var(--vermilion); color: #fff; vertical-align: middle; margin-right: .3rem; }
.seal-sm { width: 1.5rem; height: 1.5rem; font-size: .85rem; vertical-align: middle; }

/* ---------- Notices ---------- */
.notice { background: var(--face-tint); color: var(--ink); border: 1px solid var(--brass); border-radius: var(--r-md); padding: .75rem 1rem; max-width: 46rem; }
.js-fallback { display: none; }
.calc-failed .js-fallback { display: block; margin-bottom: 1rem; }
.pending-box { background: var(--face-tint); border: 1px dashed var(--face-deep); border-radius: var(--r-md); padding: .8rem 1.1rem; margin: 1.2rem 0; }
.pending-box h4 { margin-top: 0; color: var(--face-deep); }
.note-box { background: var(--face-tint); border-left: 4px solid var(--face-deep); border-radius: var(--r-sm); padding: .8rem 1.1rem; margin: 1.2rem 0; }
.boundary { background: var(--jade-tint); border-left: 3px solid var(--jade); padding: .65rem 1rem; margin: 0 0 1.2rem; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.boundary-warn { background: var(--face-tint); border-left-color: var(--face-deep); }
.policy { font-size: .92rem; color: var(--ink-soft); margin: 0 0 .6rem; }
.std-compare { margin: -.4rem 0 1.4rem; padding-left: 1.2rem; }
.std-compare li { margin: .2rem 0; }
.result-comparison { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; }
.draft-note { font-size: .86rem; color: var(--ink-soft); margin-top: 1.6rem; }
.note { background: var(--face-tint); padding: .55rem .85rem; border-radius: var(--r-sm); }
.footnote { font-size: .86rem; color: var(--ink-soft); margin: 1rem 0 0; }

/* ---------- Result: an instrument reading ---------- */
.result { background: var(--surface); border-radius: var(--r-md); margin: -1.6rem 0 2.5rem; position: relative; box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.result:focus { outline: none; }
.result:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.result-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; background: var(--lacquer); padding: .9rem 1.4rem; }
.result-top h2 { margin: 0; color: var(--face); font-size: 1.4rem; }
.result-top .btn-ghost { color: var(--face); border-color: rgba(230, 201, 122, .55); min-height: 44px; }
.result-top .btn-ghost:hover { background: var(--lacquer-2); }
.result-top :focus-visible { outline-color: var(--face); }
.result > div[id$="-result-body"] { padding: 1.3rem 1.4rem 1.6rem; }
.result [id$="-result-body"] p, .relations li, .remedies li { max-width: 50rem; }
.result-block + .result-block { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; }
.cand-head { font-size: 1.2rem; margin-top: .4rem; }
.kua-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.6rem; margin: .4rem 0 1.2rem; }
.kua-num { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 124px; height: 124px; border-radius: 50%; background: var(--face); box-shadow: inset 0 0 0 2px var(--lacquer), inset 0 0 0 7px var(--face), inset 0 0 0 8px var(--lacquer); }
.kua-num .label { font-size: .78rem; color: var(--lacquer); margin-top: .2rem; }
.kua-num .num { font-family: var(--serif); font-weight: 600; font-size: 3.6rem; line-height: .95; color: var(--vermilion); }
.trigram, .group { margin: .2rem 0; }
.trigram .sym { font-size: 1.5rem; color: var(--ink); margin-right: .2rem; }
.group { font-size: 1.05rem; }
.steps { padding-left: 1.4rem; }
.steps li { margin-bottom: .55rem; }
.steps li::marker { font-family: var(--serif); font-weight: 600; color: var(--vermilion); }
.formula { font-size: .95rem; }
.dir-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 1.6rem; align-items: start; margin-top: 1rem; }
.compass { width: 100%; max-width: 320px; height: auto; }
.compass .rim { fill: var(--face); }
.compass .tick { stroke: var(--lacquer); stroke-width: 1; opacity: .6; }
.compass .tick.major { stroke-width: 2; opacity: 1; }
.compass .sector path { stroke: var(--surface); stroke-width: 2; }
.compass .fav path { fill: #fcf1d2; }
.compass .unfav path { fill: var(--stone); }
.compass text { text-anchor: middle; font-family: var(--sans); fill: var(--ink); }
.compass .dir { font-size: 15px; font-weight: 700; }
.compass .type { font-size: 9.5px; }
.compass .unfav text { fill: #4d4640; }
.compass .thread { stroke: #d2462e; stroke-width: 1.6; fill: none; }
.compass .hub { fill: var(--lacquer); }
.compass .hub-ring { fill: none; stroke: var(--brass); stroke-width: 1; }
.compass .hub-num { font-family: var(--serif); font-size: 30px; font-weight: 600; fill: var(--face); }
.compass .hub-sym { font-size: 15px; fill: var(--face); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; background: var(--surface); font-variant-numeric: tabular-nums; }
caption { text-align: left; font-family: var(--serif); font-weight: 600; font-size: 1.05rem; padding: .2rem 0 .45rem; color: var(--ink); }
th, td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
thead th { font-size: .82rem; font-weight: 600; color: var(--ink-soft); border-bottom: 2px solid var(--ink); background: transparent; }
tbody th { font-weight: 600; }
.dir-table { margin-bottom: 1.4rem; }
.dir-table caption::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .5rem; vertical-align: .05em; }
.dir-table.fav caption::before { background: #fbf3dc; box-shadow: inset 0 0 0 1px var(--face-deep); }
.dir-table.unfav caption::before { background: var(--stone); box-shadow: inset 0 0 0 1px #8b837a; }
.dir-table.fav tbody th { border-left: 3px solid var(--jade); }
.dir-table.unfav tbody th { border-left: 3px solid #9c948b; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; }
.overview-table td, .year-table td { text-align: center; }
.year-table { min-width: 560px; }
.overview-table { min-width: 720px; }
.formula-table td, .formula-table th { padding: .6rem .7rem; }
.advice { margin-top: 1.2rem; }

/* Kua quick switcher */
.quick-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .8rem 0 1.2rem; }
.quick-tab { font: inherit; font-weight: 600; min-width: 78px; min-height: 52px; padding: .35rem .7rem; border: 1px solid var(--field); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--ink); }
.quick-tab:hover { border-color: var(--ink); }
.quick-tab[aria-selected="true"] { background: var(--lacquer); color: var(--face); border-color: var(--lacquer); }
.quick-tab[aria-selected="true"] .sub { color: var(--on-lacquer-soft); }
.quick-panel { border-top: 2px solid var(--ink); padding-top: .6rem; }
.quick-panel h3 { margin-top: .6rem; }

/* Zodiac */
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch; margin: .4rem 0 1rem; }
.profile { background: var(--paper); border-radius: var(--r-md); padding: 1rem 1.1rem; }
.profile .who { margin: 0; font-size: .86rem; font-weight: 600; color: var(--ink-soft); }
.profile .animal { font-family: var(--serif); font-size: 1.45rem; margin: .35rem 0 .5rem; }
.profile .animal strong { font-weight: 600; }
.facts { margin: 0; padding-left: 1.1rem; font-size: .93rem; }
.vs { align-self: center; font-family: var(--serif); font-size: 2rem; color: var(--vermilion); }
.verdict { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); padding: 1rem 0; margin: 1rem 0; }
.relation-headline { margin: .55rem 0 .4rem; font-size: clamp(1.45rem, 3vw, 1.9rem); }
.tier-badge { display: inline-block; font-size: .82rem; font-weight: 600; padding: .2rem .7rem; border-radius: 999px; border: 1px solid; }
.tier-1 { background: #d3e5da; border-color: #6f9c84; color: #173d30; }
.tier-2 { background: #e5efe8; border-color: #9cbca8; color: #173d30; }
.tier-3 { background: #f0ece3; border-color: #c4b9a3; color: #4a4237; }
.tier-4 { background: var(--vermilion-tint); border-color: #d58c79; color: #7b2413; }
.tier-pending { background: var(--face-tint); border-color: var(--face-deep); color: #5e4711; }
.tier-note { font-size: .9rem; color: var(--ink-soft); margin: .2rem 0 0; }
.relations { padding-left: 1.1rem; }
.relations li { margin-bottom: .6rem; }
.rel-harmonious > strong { color: var(--jade); }
.rel-challenging > strong { color: var(--vermilion); }
.matrix { min-width: 880px; font-size: .78rem; }
.matrix th, .matrix td { text-align: center; padding: .4rem .25rem; border: 1px solid var(--surface); }
.matrix thead th, .matrix tbody th { background: var(--paper); white-space: nowrap; font-size: .8rem; color: var(--ink); border-bottom: 1px solid var(--surface); }
.matrix abbr { text-decoration: none; font-weight: 600; }
.mx-br { font-family: var(--zh); color: var(--vermilion); font-weight: 600; margin-right: .15rem; }
.legend { display: flex; flex-wrap: wrap; gap: .2rem 1.4rem; list-style: none; padding: 0; font-size: .86rem; }
.dims h3, .dims h4 { margin-top: 1.4rem; }
.dim-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.6rem; border-top: 1px solid var(--line); }
.dim-list li { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.dim-name { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.dim-status { display: inline-block; font-size: .78rem; font-weight: 600; color: #5e4711; background: var(--face-tint); border: 1px dashed var(--face-deep); border-radius: 999px; padding: 0 .55rem; margin: .25rem 0; }
.dim-list .muted { display: block; font-size: .86rem; }
.dim-note { display: block; margin: .2rem 0 .3rem; }
.remedies, .tip { background: var(--surface); border-top: 2px solid var(--ink); padding: .2rem 0 .4rem; margin: 1.6rem 0; }
.content .remedies { background: transparent; }
.remedies h3, .tip h4 { font-size: 1.2rem; }
.next-step { font-weight: 600; }

/* ---------- Content ---------- */
.content { padding-bottom: .5rem; }
.content > h2:first-child { margin-top: 3.2rem; }
.content li { margin-bottom: .35rem; }
.content details summary { cursor: pointer; font-weight: 600; color: var(--jade); min-height: 44px; display: flex; align-items: center; }
.prose { padding-top: 2.4rem; padding-bottom: 2.5rem; }
.prose h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.meta { color: var(--ink-soft); font-size: .9rem; }
.faq { margin-top: 3.2rem; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 1.12rem; padding: .9rem 2rem .9rem 0; min-height: 48px; list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: .2rem; top: .75rem; font-family: var(--sans); font-weight: 400; font-size: 1.4rem; color: var(--vermilion); line-height: 1.2; }
.faq details[open] summary::after { content: "−"; }
.faq-a { padding-bottom: .8rem; }
.faq-a p { margin-top: 0; }
.method-box { font-size: .9rem; color: var(--ink-soft); margin-top: 2.6rem; padding-bottom: 1.4rem; }
.method-box p { border-top: 1px solid var(--line); padding-top: .9rem; }

/* ---------- Footer: lacquer base plate ---------- */
.site-footer { background: var(--lacquer); color: var(--on-lacquer-soft); margin-top: 3rem; padding: 2.2rem 0 1.4rem; border-top: 3px solid var(--vermilion); }
.site-footer a { color: #f3ead9; }
.site-footer a:hover { color: var(--face); }
.site-footer h2 { color: var(--face); font-size: 1.05rem; margin: 0 0 .5rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .3rem 0; }
.footer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; }
.footer-note { font-size: .84rem; margin-top: 1.2rem; }
.footer-note p { border-top: 1px solid rgba(230, 201, 122, .2); padding-top: 1rem; margin: 0; }

/* ---------- Home imagery (hero photo, entry card, figure, footer entries) ---------- */
/* Hero photo: a full-bleed layer under the hero text. The H1, lede and form stay real text; a
   lacquer gradient on the text side keeps them readable (H1 face-on-lacquer 9.4:1 is preserved). */
.hero-photo .hero-grid { position: relative; z-index: 1; }
.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg picture, .hero-bg img { display: block; width: 100%; height: 100%; }
.hero-bg img { object-fit: cover; object-position: 0% 42%; }
.hero-bg::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(58, 31, 24, .95) 0%, rgba(58, 31, 24, .9) 42%, rgba(58, 31, 24, .5) 59%, rgba(58, 31, 24, .08) 76%, rgba(58, 31, 24, 0) 100%),
    linear-gradient(0deg, rgba(58, 31, 24, .55) 0%, rgba(58, 31, 24, 0) 28%); }
/* The decorative dial sits in the lower right of the hero (dial tweak 2026-11-11: 220px -> 440px,
   lifted 80px, slow spin). Absolutely placed in its grid area so it never resizes the grid rows;
   z-index -1 inside the hero-grid stacking context keeps it under the form card but above the
   photo; anything past the hero edge is clipped by .hero { overflow: hidden }. */
.hero-photo .hero-dial { position: absolute; right: 0; bottom: calc(.4rem + 80px); width: 440px; z-index: -1; pointer-events: none; opacity: .92; filter: drop-shadow(0 10px 22px rgba(30, 14, 10, .45)); }
@media (prefers-reduced-motion: no-preference) {
  /* Only the ring plate turns; face, pool, needle and the red cross-threads stay still. */
  /* fill-box: the ring group's bbox is centred on the pivot (Chromium resolves view-box origins
     against 0,0 rather than the -220 viewBox corner, which made the spin orbit off-centre). */
  .hero-photo .luopan .lp-dial { transform-box: fill-box; transform-origin: 50% 50%; animation: lp-settle 2.2s cubic-bezier(.16, .8, .2, 1) both, lp-spin 120s linear 2.2s infinite; }
}
@keyframes lp-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.content-figure { display: block; margin: 0 0 1.4rem; }
.content-figure img { display: block; width: 100%; height: auto; aspect-ratio: 1232 / 693; border-radius: var(--r-md); background: var(--stone); }

.entry-card { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.4rem; align-items: center; max-width: 46rem; }
.entry-card p { margin: 0; }
.entry-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 360 / 271; border-radius: var(--r-md); background: var(--stone); }

.foot-entry { display: flex; align-items: center; gap: .8rem; text-decoration: none; padding: .25rem 0; }
.foot-entry span { text-decoration: underline; text-underline-offset: .18em; }
.foot-thumb { flex: 0 0 auto; }
.foot-thumb img { display: block; width: 96px; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); box-shadow: 0 0 0 1px rgba(230, 201, 122, .35); }

@media (max-width: 960px) {
  /* Narrow: the gate crop is a band at the top of the hero, fading into the lacquer under the H1. */
  .hero.hero-photo { padding-top: min(52vw, 360px); }
  .hero-bg { bottom: auto; height: min(70vw, 480px); }
  .hero-bg img { object-position: 50% 30%; }
  .hero-bg::after { background: linear-gradient(180deg, rgba(58, 31, 24, 0) 0%, rgba(58, 31, 24, .12) 40%, rgba(58, 31, 24, .9) 70%, var(--lacquer) 88%); }
  .hero-photo .hero-dial { display: none; }
}
@media (max-width: 760px) {
  .entry-card { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .entry-thumb { max-width: 360px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .hero-wide .hero-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "form"; }
  .hero-text { position: relative; z-index: 1; }
  .hero-form { position: relative; z-index: 1; }
  .hero-dial { position: absolute; top: -40px; right: -170px; width: 360px; opacity: .14; pointer-events: none; z-index: 0; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .wrap, .wrap-narrow { padding: 0 16px; }
  .breadcrumbs ol { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 1.8rem 0 2.6rem; }
  .calc-card { padding: 1.1rem 1rem 1.2rem; }
  .two-col, .dir-layout, .footer-grid { grid-template-columns: 1fr; }
  .compass { max-width: 290px; margin: 0 auto; display: block; }
  .pair { grid-template-columns: 1fr; }
  .vs { justify-self: center; }
  .dim-list { grid-template-columns: 1fr; }
  .dir-table th:nth-child(3), .dir-table td:nth-child(3) { display: none; }
  .result-top, .result > div[id$="-result-body"] { padding-left: 1rem; padding-right: 1rem; }
  /* Compact header (FIX2 S10): brand on one line, the three nav links on one line (trailing words hidden). */
  .header-inner { gap: .1rem 1rem; padding-top: .55rem; padding-bottom: .35rem; }
  .brand { font-size: 1rem; gap: .5rem; }
  .brand-mark { width: 22px; height: 22px; }
  .nav { flex-wrap: nowrap; gap: 0 1.2rem; font-size: .92rem; white-space: nowrap; }
  .nav a { padding: .3rem 0; }
  .nav-tail { display: none; }
}
@media (max-width: 400px) {
  .date-row { grid-template-columns: 1fr 1fr; }
  .date-row .field:first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---------- Paid report (Kua & Eight Mansions Full Report) ---------- */
.report-wrap { margin: 0 0 2.5rem; }
.report-entry { background: var(--surface); border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--line); border-top: 4px solid var(--face); padding: 1.3rem 1.4rem 1.4rem; }
.report-entry h2 { margin: .1rem 0 .6rem; }
.report-entry > p { max-width: 50rem; }
.report-kicker { font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--face-deep); margin: 0; }
.report-contents { padding-left: 1.3rem; margin: .8rem 0; max-width: 50rem; }
.report-contents li { margin-bottom: .45rem; }
.report-contents li::marker { font-family: var(--serif); font-weight: 600; color: var(--vermilion); }
.free-tag, .lock-tag { display: inline-block; font-family: var(--sans); font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; vertical-align: .12em; }
.free-tag { background: var(--jade-tint); color: var(--jade); }
.lock-tag { background: var(--face-tint); color: var(--face-deep); border: 1px solid var(--face-deep); }
.report-status { background: var(--jade-tint); border-left: 3px solid var(--jade); padding: .5rem .8rem; border-radius: var(--r-sm); max-width: 50rem; }
.report-choose { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .6rem .9rem; margin: .8rem 0; }
.report-choose legend { font-size: .92rem; padding: 0 .3rem; }
.report-choose .radio { display: block; margin: .2rem 0; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
a.btn:hover { color: #fff; }
.report-config-note { margin-top: .6rem; }
.report-howto { max-width: 50rem; margin-top: .9rem; font-size: .9rem; color: var(--ink-soft); border-left: 3px solid var(--face); padding: .1rem 0 .1rem .9rem; }
.report-howto p { margin: 0 0 .2rem; color: var(--ink); }
.report-howto ul { margin: 0; padding-left: 1.1rem; }
.report-howto li { margin-bottom: .2rem; }
.sample-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: .7rem 1rem .4rem; margin: .8rem 0 .6rem; }
.sample-card .dir-card { margin: 0; }
.sample-tag { font-size: .88rem; font-weight: 600; margin: 0 0 .6rem; }
.sample-badge { display: inline-block; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; background: var(--vermilion); color: #fff; padding: .08rem .55rem; border-radius: 999px; margin-right: .4rem; vertical-align: .1em; }
.report-view { margin-top: 1.4rem; background: var(--surface); border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--line); padding: 1.4rem 1.6rem 1.6rem; }
.report-view:focus { outline: none; }
.report-head { border-bottom: 2px solid var(--lacquer); padding-bottom: .7rem; margin-bottom: 1rem; }
.report-for { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin: .1rem 0 .3rem; }
.report-disclaimer, .report-foot { font-size: .86rem; color: var(--ink-soft); }
.report-foot { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: .7rem; }
.report-toc { background: var(--paper); border-radius: var(--r-sm); padding: .6rem 1rem .7rem; max-width: 34rem; }
.report-toc h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.report-toc ol { margin: 0; padding-left: 1.3rem; }
.report-part { margin-top: 2rem; }
.report-part > h3 { border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.report-part.locked { border: 1px dashed var(--face-deep); background: var(--face-tint); border-radius: var(--r-md); padding: .2rem 1.1rem .6rem; }
.report-part.locked > h3 { border-bottom: 0; margin-top: .8rem; }
.report-unlock { margin-top: 1.6rem; border-top: 2px solid var(--face); padding-top: 1rem; }
.report-glance { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 1.4rem; align-items: center; }
.glance-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1.4rem; margin: 0; }
.glance-facts dt { font-size: .8rem; color: var(--ink-soft); }
.glance-facts dd { margin: 0; font-weight: 600; }
.glance-num { font-family: var(--serif); font-size: 2.4rem; line-height: 1; color: var(--vermilion); }
.glance-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem; }
.glance-list { list-style: none; padding: 0; margin: 0; }
.glance-list li { padding: .35rem 0 .35rem .7rem; border-left: 3px solid var(--jade); margin-bottom: .3rem; }
.glance-list.unfav li { border-left-color: #9c948b; }
.dir-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dir-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: .2rem 1rem .8rem; break-inside: avoid; }
.dir-card.fav { border-left: 4px solid var(--jade); }
.dir-card.unfav { border-left: 4px solid #9c948b; background: #faf8f5; }
.dir-card h4 { margin-top: .8rem; }
.dir-card h5 { font-size: .92rem; margin: .7rem 0 .2rem; }
.dir-card ul { padding-left: 1.2rem; margin: .2rem 0 .5rem; }
.dir-kind { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin: 0; }
.dir-kind.fav { color: var(--jade); }
.dir-kind.unfav { color: #6b625a; }
.annual-table td, .annual-table th, .element-table td, .element-table th { vertical-align: top; }
.annual-table tr.fav th { border-left: 3px solid var(--jade); }
.annual-table tr.unfav th { border-left: 3px solid #9c948b; }
.quick-card { border: 2px solid var(--lacquer); border-radius: var(--r-md); padding: .2rem 1.2rem 1rem; }
.quick-card > h3 { border-bottom-color: var(--brass); }
.card-id { font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.card-grid > div { background: var(--paper); border-radius: var(--r-sm); padding: .7rem .9rem; }
.card-grid dt { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--vermilion); }
.card-grid dd { margin: .2rem 0 0; font-weight: 600; }
.card-foot { font-size: .85rem; color: var(--ink-soft); }
@media (max-width: 760px) {
  .report-entry, .report-view { padding: 1rem; }
  .report-glance, .glance-lists, .dir-cards, .card-grid { grid-template-columns: 1fr; }
}

/* Print: "Print / save as PDF" prints only the report; "Print quick card only" prints only the card. */
@media print {
  html.print-report body > :not(main), html.print-report main > :not(.report-outer),
  html.print-report .report-entry, html.print-report .no-print { display: none !important; }
  html.print-report body { background: #fff; font-size: 11pt; }
  html.print-report .report-outer { padding: 0; max-width: none; }
  html.print-report .report-view { box-shadow: none; padding: 0; margin: 0; }
  html.print-report .report-part, html.print-report .dir-card, html.print-report tr { break-inside: avoid; }
  html.print-report .quick-card { break-before: page; }
  html.print-report a { color: inherit; text-decoration: none; }
  html.print-card .report-doc > :not(.quick-card):not(.report-foot) { display: none !important; }
  html.print-card .quick-card { break-before: auto; }
  html.print-report .table-scroll { overflow: visible; }
  @page { margin: 14mm; }
}

/* ---------- Art gallery (home preview strip + /art-gallery/ masonry) ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.art-preview { margin-top: 2.4rem; }
.art-preview > h2:first-child { margin-top: 0; }
.art-strip { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.art-strip li { margin: 0; }
.art-strip img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--stone); }
.art-more { margin: 1.2rem 0 0; }

.gallery-page { padding-top: 2rem; }
.gallery-page .lede { max-width: 46rem; }
.masonry { columns: 4; column-gap: 16px; margin-top: 1.6rem; }
.art-card { break-inside: avoid; page-break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.art-card a { display: block; color: inherit; }
.art-card img { display: block; width: 100%; height: auto; background: var(--stone); transition: opacity .15s ease; }
.art-card a:hover img { opacity: .9; }
.art-card a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.art-card figcaption { font-family: var(--serif); font-size: .92rem; line-height: 1.35; padding: .55rem .7rem .65rem; color: var(--ink); border-top: 2px solid var(--brass); }
.gallery-next { max-width: 46rem; margin: 1rem 0 2.5rem; font-size: 1.05rem; }
@media (max-width: 960px) { .masonry { columns: 3; } }
@media (max-width: 760px) {
  .masonry { columns: 2; column-gap: 12px; }
  .art-card { margin-bottom: 12px; }
  .art-card figcaption { font-size: .84rem; padding: .45rem .55rem .55rem; }
  .art-strip { gap: 8px; }
}

/* ---------- Guide pages (/feng-shui-directions/, /eight-mansions-feng-shui/, /feng-shui-faq/) ---------- */
.section-more { margin: 1.2rem 0 0; }
.faq .section-more { margin-top: 1.4rem; }
.guide-hero { margin: 1.2rem 0 1.6rem; }
.guide-hero img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: var(--r-md); background: var(--stone); }
/* Float against the 46rem text column, not the wider .wrap-narrow box. */
.guide-side { float: right; width: 240px; margin: .35rem max(0px, calc(100% - 46rem)) 1rem 1.6rem; }
.guide-side img { display: block; width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--stone); }
.guide h2, .guide h3 { clear: both; }
.guide h2 { margin-top: 2.4rem; }
.guide .notice, .guide .pending-box, .guide .note-box, .guide .table-scroll { clear: both; }
.guide .notice { margin: 1.2rem 0; }
.palace-table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.palace-table caption { text-align: left; font-size: .86rem; color: var(--ink-soft); padding-bottom: .4rem; }
.palace-table th, .palace-table td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
.palace-table thead th { font-size: .84rem; color: var(--ink-soft); font-weight: 600; }
.trigram-sym { font-size: 1.3rem; line-height: 1; margin-right: .2rem; }
.worked-example { background: var(--jade-tint); border-left: 3px solid var(--jade); padding: .65rem 1rem; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.faq-toc ol { padding-left: 1.4rem; margin: 0 0 1rem; }
.faq-toc li { margin-bottom: .3rem; }
.faq-item { border-top: 1px solid var(--line); padding-top: .2rem; }
.faq-item::after { content: ""; display: block; clear: both; }
.faq-item h2 { font-size: 1.25rem; margin: 1.2rem 0 .6rem; }
.guide-cta { clear: both; margin-top: 2.4rem; padding-top: 1.2rem; border-top: 2px solid var(--brass); font-weight: 500; }
@media (max-width: 760px) {
  .guide-side { float: none; width: min(100%, 320px); margin: .4rem auto 1.2rem; }
}
/* Split H1 on the light page background (the default descriptor colour is meant for the dark hero band). */
.guide .h1-split .h1-desc { color: var(--ink-soft); }
