/* BaziCalculator.wiki — single stylesheet, no framework */
:root {
  --paper: #faf7f2;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6b625a;
  --line: #e7dfd3;
  --soft: #f3ede4;
  --accent: #a8321d;
  --accent-dark: #86281a;
  --gold: #a07a32;
  --wood: #2e7a4d;
  --fire: #c0392b;
  --earth: #9a6a26;
  --metal: #6d7480;
  --water: #275d8c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 26, 23, .06), 0 6px 20px rgba(31, 26, 23, .06);
  --serif: Georgia, "Times New Roman", serif;
  --cjk: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.65 var(--sans); }
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
.container { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[lang="zh"], .zh { font-family: var(--cjk); }

/* header */
.site-header { background: var(--ink); color: #fff; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 8px; }
.logo:hover { color: #fff; }
.logo-mark { font-family: var(--cjk); background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 6px; font-size: .95rem; }
.logo-tld { color: #d9b77a; font-weight: 400; }
.site-nav { display: flex; gap: 18px; font-size: .92rem; }
.site-nav a { color: #e9e3da; text-decoration: none; }
.site-nav a:hover { color: #fff; text-decoration: underline; }

/* hero + tool */
.hero { padding: 32px 0 24px; background: linear-gradient(180deg, #f4ece0 0%, var(--paper) 100%); }
h1 { font-family: var(--serif); font-size: clamp(1.75rem, 4.2vw, 2.6rem); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.3px; }
.h1-sub { display: block; font-size: .55em; color: var(--muted); font-weight: 400; margin-top: 4px; }
.lead { font-size: 1.05rem; color: #3a332d; max-width: 760px; margin: 0 0 20px; }
.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin-bottom: 16px; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.field legend, .label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; padding: 0; }
.label.small { font-size: .85rem; font-weight: 500; margin: 10px 0 4px; color: var(--muted); }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.colon { font-weight: 700; }
select, input[type="number"] {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff; border: 1px solid #cfc5b7; border-radius: 8px;
  padding: 9px 10px; min-height: 44px; max-width: 100%;
}
#f-city, #f-offset, #f-lon { width: 100%; }
select:focus, input:focus, button:focus-visible, summary:focus-visible { outline: 3px solid rgba(168, 50, 29, .35); outline-offset: 1px; border-color: var(--accent); }
select:disabled { opacity: .45; }
.check, .radio { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .95rem; cursor: pointer; }
.inline .radio { margin-top: 0; margin-right: 12px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.custom-place { margin-top: 4px; }
.advanced { border-top: 1px dashed var(--line); padding-top: 12px; margin-bottom: 16px; }
.advanced summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: .95rem; }
.advanced .field { margin-top: 10px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 12px 20px; min-height: 46px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: #cfc5b7; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.form-error { color: var(--accent-dark); background: #fbeae6; border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; }
.trust { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .9rem; color: var(--muted); }
.trust li::before { content: "✓ "; color: var(--wood); font-weight: 700; }

/* result */
.result:empty { display: none; }
.result { margin-top: 24px; scroll-margin-top: 12px; }
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.result-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; }
.eyebrow { margin: 0; color: var(--muted); font-size: .9rem; }
.eight { font-family: var(--cjk); font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 4px 0 0; letter-spacing: 4px; }
.eight span { display: inline-block; width: .5em; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.summary-item { background: var(--soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.summary-item .k { font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.summary-item .v { font-size: 1.1rem; font-weight: 600; }
.summary-item .v b { font-family: var(--cjk); font-size: 1.3rem; }
.summary-item .d { font-size: .88rem; color: #4a423b; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
thead th { font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--soft); }
.pillars th[scope="row"] { font-size: .8rem; color: var(--muted); font-weight: 600; width: 92px; }
.pillars td { text-align: center; }
.pillars thead th { text-align: center; }
.pillars .gz { display: block; font-family: var(--cjk); font-size: 2.4rem; line-height: 1.15; font-weight: 700; }
.pillars .sub, .sub { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.zh-small { font-size: .85rem; color: var(--muted); }
.hidden-cell { font-size: .82rem; }
.hidden-stem { display: block; white-space: nowrap; }
.hidden-stem b { font-family: var(--cjk); font-size: 1.05rem; }
.unknown { font-size: 2rem; color: #c9bfb1; }
.note-inline { font-size: .88rem; color: var(--muted); }
.result-h { font-family: var(--serif); font-size: 1.2rem; margin: 22px 0 10px; }
.h-note { font-family: var(--sans); font-size: .85rem; font-weight: 400; color: var(--muted); }
.bars { display: grid; gap: 6px; max-width: 520px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 24px; align-items: center; gap: 10px; font-size: .92rem; }
.bar-track { background: var(--soft); border-radius: 6px; height: 14px; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.bar-num { text-align: right; font-weight: 600; }
.luck-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.luck { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; }
.luck li { flex: 0 0 auto; width: 92px; background: var(--soft); border-radius: 10px; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.luck .age { font-size: .8rem; color: var(--muted); }
.luck .gz-pair { font-family: var(--cjk); font-size: 1.6rem; line-height: 1.2; font-weight: 700; display: flex; flex-direction: column; }
.luck .tg { font-size: .74rem; line-height: 1.25; }
.luck .yr { font-size: .78rem; color: var(--muted); }
.notices { padding-left: 20px; margin: 0; }
.notices li { margin-bottom: 8px; font-size: .95rem; }
.calc-details { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; font-size: .9rem; }
.calc-details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.calc-details dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; margin: 12px 0 0; }
.calc-details dt { color: var(--muted); }
.calc-details dd { margin: 0; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* element colours */
.el-wood { color: var(--wood); } .el-fire { color: var(--fire); } .el-earth { color: var(--earth); } .el-metal { color: var(--metal); } .el-water { color: var(--water); }
.el-wood-bg { background: var(--wood); } .el-fire-bg { background: var(--fire); } .el-earth-bg { background: var(--earth); } .el-metal-bg { background: var(--metal); } .el-water-bg { background: var(--water); }

/* content */
.content { padding-top: 24px; padding-bottom: 32px; }
.content section { padding: 20px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 12px; }
.content section:last-child { border-bottom: 0; }
.content h2 { font-family: var(--serif); font-size: clamp(1.4rem, 3vw, 1.8rem); line-height: 1.25; margin: 0 0 12px; }
.content h3 { font-size: 1.1rem; margin: 22px 0 6px; }
.content p, .content li { max-width: 780px; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin-bottom: 6px; }
.steps li { margin-bottom: 10px; }
.content td.zh { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.cases td:first-child { white-space: nowrap; }
.example-figure { margin: 8px 0 16px; }
.example-figure img { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.example-figure figcaption { font-size: .88rem; color: var(--muted); margin-top: 6px; }
.faq h3 { margin-top: 18px; }
.meta { font-size: .88rem; color: var(--muted); }
.cta-end { text-align: center; }
.cta-end p { margin-left: auto; margin-right: auto; }

/* inner pages */
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.facts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 20px; }
.facts dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; margin: 0; }
.facts dl > div { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.tool-compact .tool-title { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 10px; }
.z27-result:empty { display: none; }
.z27-result { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.z27-result p { margin: 0 0 10px; }
.z27-sign { font-size: 1.25rem; }
.z27-sign [lang="zh"] { font-size: 1.4rem; margin-left: 4px; }
.z27-meta, .z27-note { color: #4a423b; font-size: .95rem; }
.tag { display: inline-block; font-size: .82rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag-good { background: #e3f1e8; color: #1f6a3e; }
.tag-warn { background: #fbf0dc; color: #8a5a12; }
.tag-bad { background: #fbe4df; color: #9b2a17; }
.signs td:first-child { white-space: nowrap; font-weight: 600; }
.row-now td { background: #fbf3e8; }

/* footer */
.site-footer { background: var(--ink); color: #cfc7bc; font-size: .88rem; padding: 20px 0; }
.site-footer p { margin: 4px 0; }
.site-footer strong { color: #fff; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .site-nav { gap: 14px; font-size: .85rem; padding-bottom: 10px; }
  .header-inner { gap: 4px 16px; padding-top: 8px; }
  .field-row { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .tool, .result-card { padding: 16px; }
  .pillars th[scope="row"] { width: 64px; font-size: .72rem; padding: 6px 4px; }
  .pillars td { padding: 6px 2px; }
  .pillars .gz { font-size: 1.9rem; }
  .pillars .sub { font-size: .72rem; }
  .hidden-cell { font-size: .7rem; }
  .hidden-stem { white-space: normal; }
  .calc-details dl { grid-template-columns: 1fr; gap: 2px; }
  .calc-details dd { margin-bottom: 6px; }
  .cases td:first-child { white-space: normal; }
  .facts dl { grid-template-columns: 1fr; }
  .signs td:first-child { white-space: normal; }
}
.site-footer a { color: #e9d3b0; }
@media print {
  .site-header, .site-footer, .tool, .trust, .content, .result-actions, .lead, h1 { display: none !important; }
  .hero { background: none; padding: 0; }
  .result-card { box-shadow: none; border: 0; }
  .calc-details { display: block; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.facts-title { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; margin: 0 0 10px; }
.tool-compact + .facts { margin-top: 20px; }
.animals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 24px; }
.animals h3 { margin: 12px 0 2px; }
.animals p { margin: 0; font-size: .95rem; }
.zs-element { font-size: 1.05rem; }
.zs-facts { padding-left: 20px; margin: 0 0 10px; }
.zs-facts li { margin-bottom: 4px; }
@media (max-width: 720px) { .animals { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .animals { grid-template-columns: 1fr; } }
.site-nav a[aria-current="page"] { color: #fff; font-weight: 600; }

/* I Ching */
#ic-q { width: 100%; font: inherit; font-size: 1rem; border: 1px solid #cfc5b7; border-radius: 8px; padding: 10px; resize: vertical; margin-bottom: 14px; }
.ic-stage { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; margin-bottom: 8px; }
.ic-coins { display: flex; gap: 10px; }
.coin { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: #e9dcc6; color: #7a5a22; border: 3px solid #c9ad7c; box-shadow: inset 0 0 0 6px #f3e8d4; }
.coin.heads { background: #c9a14e; color: #fff; border-color: #a07a32; box-shadow: inset 0 0 0 6px #d8b569; }
.coin.yarrow { width: auto; padding: 0 16px; border-radius: 12px; }
.ic-coins.flip .coin { animation: icflip .45s ease; }
@keyframes icflip { 0% { transform: rotateY(0) scale(.9); } 50% { transform: rotateY(90deg) scale(1.05); } 100% { transform: rotateY(0) scale(1); } }
.ic-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 6px; min-height: 40px; }
.ic-lines li { display: flex; align-items: center; gap: 12px; font-size: .88rem; color: var(--muted); }
.ic-line { position: relative; display: inline-flex; justify-content: space-between; width: 96px; height: 12px; flex: 0 0 auto; }
.ic-line i { display: block; height: 100%; background: var(--ink); border-radius: 2px; }
.ic-line.yang i:first-child { width: 100%; } .ic-line.yang i:last-child { display: none; }
.ic-line.yin i { width: 42%; }
.ic-line.changing i { background: var(--accent); }
.ic-line b { position: absolute; right: -22px; top: -5px; color: var(--accent); font-size: .95rem; }
.ic-status { color: var(--muted); font-size: .95rem; margin: 6px 0 14px; }
.ic-manual { display: grid; gap: 6px; margin-bottom: 10px; }
.ic-manual-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; font-size: .9rem; }
.ic-question { font-family: var(--serif); font-size: 1.15rem; font-style: italic; margin: 0 0 14px; }
.ic-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ic-card { background: var(--soft); border-radius: 10px; padding: 14px 16px; }
.ic-card .eyebrow { margin-bottom: 8px; }
.ic-card-body { display: flex; gap: 22px; align-items: center; margin-bottom: 8px; }
.ic-hex { display: flex; flex-direction: column; gap: 6px; }
.ic-hex .ic-line { width: 84px; height: 11px; }
.ic-name { margin: 0; font-size: 1.15rem; font-weight: 700; }
.ic-name [lang="zh"] { font-size: 1.4rem; }
.ic-num { display: inline-block; min-width: 28px; text-align: center; background: var(--ink); color: #fff; border-radius: 6px; font-size: .85rem; padding: 1px 6px; }
.ic-en { margin: 2px 0; font-family: var(--serif); font-size: 1.1rem; }
.ic-tris { margin: 0; color: var(--muted); font-size: .9rem; }
.ic-changing { padding-left: 20px; }
.ic-changing li { margin-bottom: 6px; }
.ic-changing li.key { font-weight: 500; }
.ic-mini { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
.ic-tri { font-size: 1.6rem; line-height: 1; }
.hex-table td { vertical-align: middle; }
.hex-svg { fill: var(--ink); vertical-align: middle; }
.hex-zh { font-size: 1.15rem; margin-left: 6px; }
.hex-table td:nth-child(2), .hex-table td:nth-child(4) { white-space: nowrap; }
@media (max-width: 720px) {
  .ic-stage { grid-template-columns: 1fr; gap: 12px; }
  .ic-pair { grid-template-columns: 1fr; }
  .ic-manual-row { grid-template-columns: 1fr; gap: 2px; }
  .hex-table td:nth-child(4) { display: none; }
  .hex-table th:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ic-coins.flip .coin { animation: none; } }
.ic-lines .ic-line { margin-right: 22px; }
