/* 紫微斗數 — minimal, mobile-first. No build step, no external requests. */

:root {
  --bg: #fcfcfb;
  --surface: #ffffff;
  --ink: #1c1b19;
  --ink-2: #57554f;
  --ink-3: #949089;
  --line: #e6e4df;
  --line-strong: #d3d0c9;
  --accent: #a13d2d;
  --life-tint: #fdf6f4;
  --star-good: #2c7a52;
  --star-bad: #b3392b;
  --pal-self: #a13d2d;
  --pal-kin: #2b5f9e;
  --pal-fortune: #8a6516;
  --pal-outer: #2b7d78;
  --tint-good: #eef6f1;
  --tint-bad: #fbeeec;
  --tint-row: #f7f6f3;
  --lu: #2f7a4f;
  --quan: #2b5f9e;
  --ke: #6a4a9c;
  --ji: #a13d2d;
  --radius: 10px;
  --pad: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1b1a18;
    --ink: #eceae5;
    --ink-2: #aaa79f;
    --ink-3: #77746d;
    --line: #2c2a26;
    --line-strong: #3b3833;
    --accent: #d98b6f;
    --life-tint: #221d1a;
    --star-good: #6bbd8c;
    --star-bad: #e28073;
    --pal-self: #d98b6f;
    --pal-kin: #7aa9dd;
    --pal-fortune: #d0a44f;
    --pal-outer: #63bdb6;
    --tint-good: #16241c;
    --tint-bad: #2a1a17;
    --tint-row: #201f1c;
    --lu: #6bbd8c;
    --quan: #7aa9dd;
    --ke: #ab95da;
    --ji: #e08573;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC",
    "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px var(--pad) 72px;
}

/* ---------- type ---------- */

.masthead { text-align: center; margin-bottom: 32px; }

.masthead h1 {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 30px;
  letter-spacing: 0.22em;
  font-weight: 500;
  margin: 0 0 6px;
  text-indent: 0.22em;
}

.masthead p { margin: 0; color: var(--ink-3); font-size: 13px; letter-spacing: 0.08em; }

h2 {
  font-size: 14px;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--ink-2);
  margin: 40px 0 14px;
  text-indent: 0.14em;
}

.hint { color: var(--ink-3); font-size: 13px; line-height: 1.7; }

/* ---------- form ---------- */

.field { margin-bottom: 22px; }

.field > label,
.field > .label {
  display: block;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.seg { display: flex; gap: 8px; }

.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg label {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.seg input:checked + label {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

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

.row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }

select, input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="text"] { background-image: none; }

select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.check label { font-size: 14px; color: var(--ink-2); }

button.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  cursor: pointer;
  margin-top: 8px;
}

button.primary:active { opacity: .85; }

.errors {
  border: 1px solid var(--ji);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 22px;
  color: var(--ji);
  font-size: 14px;
}

.errors ul { margin: 0; padding-left: 18px; }

/* ---------- summary ---------- */

.summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  margin-bottom: 22px;
}

.summary .who { font-size: 17px; margin-bottom: 12px; letter-spacing: .05em; }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }

.facts div { font-size: 13px; line-height: 1.5; }

.facts dt { color: var(--ink-3); font-size: 11px; letter-spacing: .1em; }

.facts dd { margin: 2px 0 0; color: var(--ink); }

.note {
  border-left: 2px solid var(--accent);
  padding: 8px 0 8px 12px;
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
}

/* ---------- chart grid ---------- */

.chart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(108px, auto);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.cell {
  background: var(--surface);
  padding: 6px 6px 4px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.cell.is-life {
  background: var(--life-tint); /* fallback for browsers without color-mix() */
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.cell .stars { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 1px 5px; }

.cell .s { font-size: 12px; line-height: 1.45; white-space: nowrap; }

/* Two independent signals: weight/size says 主星 or 輔星, colour says 吉凶. */
.cell .s.main { font-weight: 600; }

.cell .s.lucky, .cell .s.malefic { font-size: 11px; }

.p-good { color: var(--star-good); }
.p-bad { color: var(--star-bad); }
.p-neutral { color: var(--ink); }
.cell .s.lucky.p-neutral, .cell .s.malefic.p-neutral { color: var(--ink-2); }

.hua {
  font-size: 9px;
  vertical-align: super;
  margin-left: 1px;
  font-weight: 700;
}

.hua-祿 { color: var(--lu); }
.hua-權 { color: var(--quan); }
.hua-科 { color: var(--ke); }
.hua-忌 { color: var(--ji); }

/* Two stacked rows: a 86px-wide phone cell cannot hold 大限, 宮名 and 干支
   side by side without clipping. */
.cell .foot {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dotted var(--line-strong);
  font-size: 10px;
  color: var(--ink-3);
}

.cell .foot-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.cell .daxian { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.cell .pname { font-size: 11px; letter-spacing: .04em; }

.cat-self { color: var(--pal-self); }
.cat-kin { color: var(--pal-kin); }
.cat-fortune { color: var(--pal-fortune); }
.cat-outer { color: var(--pal-outer); }

.cell.is-life .pname, .cell .pname.body { font-weight: 700; }

.center {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.center .big {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 17px;
  letter-spacing: .12em;
  text-indent: .12em;
}

.center .kv { font-size: 11px; color: var(--ink-3); line-height: 1.7; }

/* ---------- readings ---------- */

details.reading {
  border-bottom: 1px solid var(--line);
}

details.reading[open] { padding-bottom: 8px; }

details.reading summary {
  list-style: none;
  cursor: pointer;
  padding: 15px 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 24px;
}

details.reading summary::-webkit-details-marker { display: none; }

details.reading summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
}

details.reading[open] summary::after { content: "－"; }

.r-name { font-size: 15px; letter-spacing: .08em; min-width: 4.6em; }

.r-stars { font-size: 13px; color: var(--ink-2); }

.r-branch { font-size: 11px; color: var(--ink-3); }

.r-body { padding: 0 0 8px; }

.r-star-head {
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--accent);
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.r-body p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-2);
  text-align: justify;
}

.r-empty { font-size: 14px; color: var(--ink-3); padding: 0 0 12px; }

/* ---------- misc ---------- */

.actions { display: flex; gap: 10px; margin-top: 32px; }

.actions a {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 15px;
}

footer.src {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-3);
}

/* ---------- larger screens ---------- */

@media (min-width: 600px) {
  .wrap { padding-top: 44px; }
  .masthead h1 { font-size: 34px; }
  .chart { grid-auto-rows: minmax(132px, auto); }
  .cell { padding: 9px; }
  .cell .s { font-size: 13px; }
  .cell .s.lucky, .cell .s.malefic { font-size: 12px; }
  .cell .foot { font-size: 11px; }
  .cell .pname { font-size: 12px; }
  .center .big { font-size: 20px; }
  .center .kv { font-size: 12px; }
  .facts { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- scores ---------- */

.scores {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.score + details.score { border-top: 1px solid var(--line); }

details.score > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 4.2em 1fr 2.1em 2.6em;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  min-height: 52px;
}

details.score > summary::-webkit-details-marker { display: none; }

.sc-label { font-size: 15px; letter-spacing: .06em; }

.sc-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.sc-bar i { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }

.sc-num {
  font-size: 17px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sc-grade { font-size: 11px; text-align: right; letter-spacing: .04em; }

i.g-強, i.g-偏強 { background: var(--lu); }
i.g-偏弱, i.g-弱 { background: var(--accent); }
.sc-grade.g-強, .sc-grade.g-偏強 { color: var(--lu); }
.sc-grade.g-平 { color: var(--ink-3); }
.sc-grade.g-偏弱, .sc-grade.g-弱 { color: var(--accent); }

.sc-body { padding: 0 14px 16px; }

.sc-basis, .sc-slots {
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
  margin: 0 0 10px;
}

.sc-slots { color: var(--ink-3); }

.sc-role { font-size: 11px; }

.sc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }

.sc-head {
  font-size: 11px;
  letter-spacing: .1em;
  padding-bottom: 5px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.sc-plus { color: var(--lu); }
.sc-minus { color: var(--accent); }

.sc-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
  line-height: 1.9;
  white-space: nowrap;
}

.sc-where { font-size: 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }

.sc-val { font-variant-numeric: tabular-nums; font-size: 11px; }

.sc-none { font-size: 12px; color: var(--ink-3); }

@media (min-width: 600px) {
  details.score > summary { grid-template-columns: 5em 1fr 2.4em 3em; padding: 16px 18px; }
  .sc-body { padding: 0 18px 20px; }
  .sc-item { font-size: 13px; }
}

/* ---------- nav & content pages ---------- */

.masthead h1 a { color: inherit; text-decoration: none; }

.nav {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* Each destination carries its own hue, drawn from the palette already used
   for palaces and stars, so the nav reads as a set rather than five identical
   pills. --nv is set per item below. */
.nav a {
  padding: 7px 14px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--nv);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: .06em;
  background: transparent;
  transition: background-color .15s, color .15s;
}

.nav a:hover,
.nav a:focus-visible {
  background: var(--nv);
  color: var(--surface);
}

.nav .nv-cast { --nv: var(--pal-self); }
.nav .nv-match { --nv: var(--pal-kin); }
.nav .nv-stars { --nv: var(--ke); }
.nav .nv-rank { --nv: var(--pal-fortune); }
.nav .nv-palaces { --nv: var(--pal-outer); }

.lede {
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-2);
  margin: 0 0 8px;
  text-align: justify;
}

.prose p {
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-2);
  margin: 0 0 14px;
  text-align: justify;
}

.cards { list-style: none; margin: 0; padding: 0; }

.cards li + li { margin-top: 8px; }

.cards a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}

.cards a:hover { border-color: var(--line-strong); }

.c-name {
  display: block;
  font-size: 16px;
  letter-spacing: .1em;
  margin-bottom: 3px;
}

.c-desc { display: block; font-size: 13px; color: var(--ink-3); line-height: 1.65; }

.deflist { margin: 0; }

.deflist > div {
  display: grid;
  grid-template-columns: 5.4em 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.deflist dt { font-size: 14px; letter-spacing: .06em; color: var(--ink); }

.deflist dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
}

@media (max-width: 420px) {
  .deflist > div { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- legend ---------- */

.legend {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-3);
}

.legend b { font-weight: 600; color: var(--ink-2); font-size: 11px; letter-spacing: .1em; }

.legend .swatches { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 8px; }

.legend .swatches:last-child { margin-bottom: 0; }

.legend .sw { white-space: nowrap; }

.legend .sw::before {
  content: "●";
  margin-right: 4px;
  font-size: 9px;
  vertical-align: 1px;
}

.sw-good::before { color: var(--star-good); }
.sw-bad::before { color: var(--star-bad); }
.sw-neutral::before { color: var(--ink-2); }
.sw-self::before { color: var(--pal-self); }
.sw-kin::before { color: var(--pal-kin); }
.sw-fortune::before { color: var(--pal-fortune); }
.sw-outer::before { color: var(--pal-outer); }

/* ---------- rank table ---------- */

.rank-tier {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: .08em;
}

.rank-note { font-size: 12px; color: var(--ink-3); margin: 0 0 10px; line-height: 1.7; }

.rank {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 26px;
  font-size: 13px;
}

.rank th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-3);
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.rank td {
  padding: 9px 8px 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-2);
  line-height: 1.7;
}

.rank td:first-child { white-space: nowrap; font-weight: 600; }

.rank .w {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 0;
}

.rank .grade { white-space: nowrap; font-size: 12px; }

@media (max-width: 480px) {
  .rank { font-size: 12px; }
  .rank .hide-sm { display: none; }
}

/* ---------- shared emphasis devices ---------- */

/* A pill carrying the grade or category. Colour comes from a p-*/cat-* class
   on the same element, so one rule covers every palette. */
.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1.7;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: .04em;
  vertical-align: 1px;
}

/* Left colour bar — the fastest thing to scan down a long list. */
.bar { border-left: 3px solid var(--line-strong); padding-left: 11px; }
.bar.p-good { border-left-color: var(--star-good); }
.bar.p-bad { border-left-color: var(--star-bad); }
.bar.p-neutral { border-left-color: var(--ink-3); }
.bar.cat-self { border-left-color: var(--pal-self); }
.bar.cat-kin { border-left-color: var(--pal-kin); }
.bar.cat-fortune { border-left-color: var(--pal-fortune); }
.bar.cat-outer { border-left-color: var(--pal-outer); }

/* ---------- rank table emphasis ---------- */

.rank td:first-child {
  border-left: 3px solid var(--line-strong);
  padding-left: 11px;
}

.rank tr.t-good td:first-child { border-left-color: var(--star-good); }
.rank tr.t-bad td:first-child { border-left-color: var(--star-bad); }
.rank tr.t-neutral td:first-child { border-left-color: var(--ink-3); }

/* Only the extremes get a wash, so they read as the headline rows. */
.rank tr.t-peak td { background: var(--tint-good); }
.rank tr.t-trough td { background: var(--tint-bad); }

.rank .w { font-weight: 600; }
.rank tr.t-good .w { color: var(--star-good); }
.rank tr.t-bad .w { color: var(--star-bad); }
.rank tr.t-neutral .w { color: var(--ink-3); }

.rank td:first-child a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }

/* ---------- star index cards ---------- */

.cards a { border-left-width: 3px; }
.cards a.p-good { border-left-color: var(--star-good); }
.cards a.p-bad { border-left-color: var(--star-bad); }
.cards a.p-neutral { border-left-color: var(--ink-3); }

.c-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }

.c-head .c-name { margin: 0; font-weight: 600; }

.c-meta { margin-left: auto; font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ---------- definition lists with a category bar ---------- */

.deflist.keyed > div {
  border-left: 3px solid var(--line-strong);
  padding-left: 11px;
  border-bottom: 1px solid var(--line);
}

.deflist.keyed > div.cat-self { border-left-color: var(--pal-self); }
.deflist.keyed > div.cat-kin { border-left-color: var(--pal-kin); }
.deflist.keyed > div.cat-fortune { border-left-color: var(--pal-fortune); }
.deflist.keyed > div.cat-outer { border-left-color: var(--pal-outer); }

.deflist.keyed dt { font-weight: 600; }

.axis-pair { font-size: 14px; }

.axis-pair .sep { color: var(--ink-3); margin: 0 6px; }

/* ---------- cast counter ---------- */

.counter {
  text-align: center;
  padding: 18px 16px 20px;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.counter .count {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.counter .count-label {
  font-size: 13px;
  letter-spacing: .16em;
  text-indent: .16em;
  color: var(--ink-2);
  margin-top: 4px;
}

.counter .count-sub {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin-top: 6px;
}

@media (min-width: 600px) {
  .counter .count { font-size: 46px; }
}

/* ---------- transit period ---------- */

.transit-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 16px 18px;
  margin-bottom: 22px;
}

.transit-form .field:last-of-type { margin-bottom: 14px; }

.transit-head {
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--tint-row);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 14px;
}

.th-title { font-size: 16px; letter-spacing: .06em; }

.th-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.8; }

.layers { margin-bottom: 16px; }

.layer {
  display: grid;
  grid-template-columns: 3.4em 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.ly-name { font-size: 13px; letter-spacing: .06em; color: var(--ink); }

.ly-cap { color: var(--ink-2); }

.ly-w { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.layer-table { margin-bottom: 16px; font-size: 12px; }

.layer-table td { padding: 6px 8px 6px 0; }

.layer-table td:first-child { padding-left: 9px; }

@media (max-width: 420px) {
  .layer { grid-template-columns: 3.2em 1fr; }
  .ly-w { grid-column: 2; color: var(--ink-3); }
}

/* ---------- dimension groups ---------- */

.group-head {
  font-size: 12px;
  letter-spacing: .14em;
  text-indent: .14em;
  font-weight: 600;
  margin: 22px 0 8px;
  padding-left: 11px;
  border-left: 3px solid var(--line-strong);
}

.group-head.cat-self { border-left-color: var(--pal-self); }
.group-head.cat-kin { border-left-color: var(--pal-kin); }
.group-head.cat-fortune { border-left-color: var(--pal-fortune); }
.group-head.cat-outer { border-left-color: var(--pal-outer); }

h2 + .group-head { margin-top: 10px; }

/* Land clear of the sticky-free top edge when jumped to via #transit. */
[id="transit"] { scroll-margin-top: 12px; }

/* ---------- FAQ accordion ---------- */

.faq {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.faq-item + details.faq-item { border-top: 1px solid var(--line); }

details.faq-item > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 15px 16px;
  min-height: 52px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}

details.faq-item > summary::-webkit-details-marker { display: none; }

details.faq-item > summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
  flex: none;
}

details.faq-item[open] > summary { color: var(--accent); }

details.faq-item[open] > summary::after { content: "－"; color: var(--accent); }

details.faq-item > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.faq-answer { padding: 0 16px 16px; }

.faq-answer p {
  margin: 0;
  font-size: 14px;
  line-height: 1.95;
  color: var(--ink-2);
  text-align: justify;
}

/* ---------- footer copyright ---------- */

footer.src p { margin: 0 0 10px; }

footer.src p:last-child { margin-bottom: 0; }

footer.src .copyright {
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: .06em;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

footer.src .contact {
  color: var(--ink-2);
  padding-top: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

footer.src .contact a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

footer.src .contact a:hover { color: var(--ink); }

/* ---------- pairing ---------- */

fieldset.person {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 16px 4px;
  margin: 0 0 18px;
}

fieldset.person legend {
  padding: 0 8px;
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--accent);
}

.verdict {
  text-align: center;
  padding: 24px 16px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 18px;
}

.vd-pair { font-size: 15px; letter-spacing: .08em; color: var(--ink-2); }

.vd-score {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 52px;
  line-height: 1.1;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}

.vd-grade { font-size: 17px; letter-spacing: .2em; text-indent: .2em; color: var(--accent); }

.vd-sub { font-size: 12px; color: var(--ink-3); margin-top: 8px; letter-spacing: .06em; }

.pair-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

.pc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
}

.pc-name { font-size: 15px; letter-spacing: .06em; margin-bottom: 5px; }

.pc-meta { font-size: 11px; line-height: 1.8; color: var(--ink-3); }

.checks {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.check-row {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 13px 14px;
  border-left: 3px solid var(--line-strong);
}

.check-row + .check-row { border-top: 1px solid var(--line); }

.check-row.hit { border-left-color: var(--star-good); }
.check-row.miss { border-left-color: var(--line-strong); }

.ck-mark { font-size: 13px; color: var(--ink-3); text-align: center; line-height: 1.6; }

.check-row.hit .ck-mark { color: var(--star-good); }

.ck-label { font-size: 14px; line-height: 1.7; }

.check-row.miss .ck-label { color: var(--ink-2); }

.ck-detail { font-size: 12px; line-height: 1.8; color: var(--ink-3); margin-top: 3px; }

.ck-val {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  white-space: nowrap;
  line-height: 1.7;
}

.check-row.hit .ck-val { color: var(--star-good); font-weight: 600; }
.check-row.miss .ck-val { color: var(--ink-3); }

[id="verdict"], [id="form"] { scroll-margin-top: 12px; }

@media (max-width: 420px) {
  .pair-charts { grid-template-columns: 1fr; }
  .check-row { grid-template-columns: 1.8em 1fr auto; padding: 12px 10px; }
}
