/* Site chrome uses independent theme surfaces. The original engine owns each
   palace, five-element colour, selection marker, animal and calendrical table. */
:root {
  --cx-paper:#e1ceb2; --cx-surface:#f2e5cf; --cx-ink:#39271e; --cx-muted:#604633;
  --cx-accent:#65402c; --cx-on:#fff4df; --cx-dial:#493126; --cx-etch:#efd6aa;
  --cx-font:"PingFang SC","Microsoft YaHei","Noto Sans CJK SC","Noto Sans SC",system-ui,"Xuanyi Rare Han",sans-serif;
  --cx-gutter:clamp(16px,3.8vw,56px); --cx-width:1240px;
}
/* Keep the three extension characters available on devices without a local glyph. */
@font-face {
  font-family:"Xuanyi Rare Han";
  src:url("../classics-song-rare.d4ccab09207e.woff2") format("woff2");
  unicode-range:U+23698,U+25FC9,U+262EF;
  font-display:swap;
}

/* The legacy skins use important font shorthands. A layer gives only the family
   precedence, leaving size, weight, line height and tabular figures to each component. */
@layer typography {
  :where(body[data-cx],body[data-cx] *),
  :where(body[data-cx] *)::before,
  :where(body[data-cx] *)::after,
  :where(body[data-cx] *)::marker,
  :where(body[data-cx] input,body[data-cx] textarea)::placeholder {
    font-family:var(--cx-font) !important;
  }
}
:root:is([data-skin="antique"],[data-theme="antique"]) {
  --theme-board:#e9d7bc; --theme-palace:#efdfc4; --theme-palace-alt:#e6d2b3;
  --theme-palace-head:#e4ceb0; --theme-palace-name:var(--cx-accent);
  --theme-board-ink:var(--cx-ink); --theme-board-muted:var(--cx-muted);
  --theme-board-rule:#aa8968; --theme-grid:#997756;
  --cx-nav-active:var(--cx-accent); --cx-nav-active-ink:var(--cx-on);
}
:root:is([data-skin="crimson"],[data-theme="crimson"]) {
  --cx-paper:#261b21; --cx-surface:#37252e; --cx-ink:#f9eeec; --cx-muted:#cfb9be;
  --cx-accent:#f5c4ac; --cx-on:#35232a; --cx-dial:#522a36; --cx-etch:#e6c39b;
}
:root:is([data-skin="wood"],[data-theme="wood"]) {
  --cx-paper:#221f1c; --cx-surface:#302b26; --cx-ink:#f5efe4; --cx-muted:#cdbfb0;
  --cx-accent:#e2c18c; --cx-on:#30271c; --cx-dial:#352a21; --cx-etch:#dfbb80;
}
:root:is([data-skin="song"],[data-theme="song"]) {
  --cx-paper:#f1f5f1; --cx-surface:#fcfdf8; --cx-ink:#24382e; --cx-muted:#53675c;
  --cx-accent:#315849; --cx-on:#f8fff7; --cx-dial:#25463b; --cx-etch:#d4dfbc;
}
:root:is([data-skin="pine"],[data-theme="pine"]) {
  --cx-paper:#132821; --cx-surface:#1c372e; --cx-ink:#f1f5e9; --cx-muted:#b7cebf;
  --cx-accent:#d7d6a0; --cx-on:#233729; --cx-dial:#183e33; --cx-etch:#dace9a;
}
:root:is([data-skin="indigo"],[data-theme="indigo"]) {
  --cx-paper:#172331; --cx-surface:#233246; --cx-ink:#eff4fa; --cx-muted:#bdcadd;
  --cx-accent:#bdd7ef; --cx-on:#172a40; --cx-dial:#22334d; --cx-etch:#c6d9e5;
}
body[data-cx] {
  --cx-rule:color-mix(in srgb,var(--cx-ink) 17%,var(--cx-surface));
  --cx-soft:color-mix(in srgb,var(--cx-accent) 7%,var(--cx-surface));
  --cx-edge:color-mix(in srgb,var(--cx-ink) 46%,var(--cx-surface));
  --theme-ink:var(--cx-ink); --theme-muted:var(--cx-muted); --theme-heading:var(--cx-ink);
  --theme-field:var(--cx-surface); --theme-paper:var(--cx-surface); --theme-back:var(--cx-paper);
  --theme-soft:var(--cx-soft); --theme-line:var(--cx-rule); --theme-edge:var(--cx-edge);
  --theme-accent:var(--cx-accent); --theme-button:var(--cx-accent); --theme-button-ink:var(--cx-on);
  --theme-hover:color-mix(in srgb,var(--cx-ink) 20%,var(--cx-accent)); --theme-ground:none;
  --d-panel:var(--cx-surface); --d-ground:var(--cx-paper); --d-page:var(--cx-paper); --d-ink:var(--cx-ink);
  --d-muted:var(--cx-muted); --d-accent:var(--cx-accent); --d-rule:var(--cx-rule); --d-tint:var(--cx-soft);
  --utility-muted:var(--cx-muted); --cx-shadow:0 5px 24px -15px color-mix(in srgb,var(--cx-ink) 26%,transparent);
  --serif:var(--cx-font); --gutter:var(--cx-gutter);
  accent-color:var(--cx-accent); color:var(--cx-ink); background:var(--cx-paper); margin:0;
  font-family:var(--cx-font); -webkit-text-size-adjust:100%;
}
#bk[data-cx="xuanyi"],body[data-cx].chart-workspace-qm {
  --xy-gutter:var(--cx-gutter); --qm-gutter:var(--cx-gutter);
  --d-sans:var(--cx-font); --d-serif:var(--cx-font); --d-ground:var(--cx-paper);
  background:var(--cx-paper); font-family:var(--cx-font);
}
body[data-cx] #chart-shell {background:var(--cx-paper);}
body[data-cx] :focus-visible {outline:3px solid var(--cx-accent);outline-offset:3px;}
body[data-cx] :is(.tool-footer,.site-footer,.utility-site-footer) {
  color:var(--cx-muted);background:transparent;border:0;border-top:1px solid var(--cx-rule);
  font:400 .8rem/1.7 var(--cx-font);text-align:start;box-shadow:none;
}
body[data-cx] .tool-footer-site {border:0;background:transparent;}

/* Three chart products share the same navigation, independent of the size of their charts. */
body[data-cx] :is(.tool-masthead,header.masthead) {background:none;border:0;box-shadow:none;}
body[data-cx] :is(.tool-head,.masthead-bar),body[data-cx].utility-page > .masthead {
  background:var(--cx-surface);border:0;border-bottom:1px solid var(--cx-rule);box-shadow:none;
}
body[data-cx] :is(.tool-head-inner,.masthead-inner),#bk[data-cx] .tool-head-inner,
body[data-cx].utility-page .mast-inner {
  box-sizing:border-box;width:100%;max-width:var(--cx-width);margin:auto;padding-inline:var(--cx-gutter);
  min-height:64px;height:auto;
}
body[data-cx] :is(.tool-brand,.masthead .brand),#bk[data-cx] .tool-brand {
  display:inline-flex;align-items:center;gap:9px;min-height:44px;border:0;padding:0;color:var(--cx-ink);
  font:650 1.1rem/1.3 var(--cx-font);letter-spacing:.04em;text-decoration:none;
}
body[data-cx] :is(.tool-brand,.masthead .brand)::before {
  content:"";flex:none;width:23px;height:23px;border-radius:7px;background-color:var(--cx-accent);
  mask:url("../xuanyi-mark.png") center / contain no-repeat;
}
body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav,
#bk[data-cx] .tool-masthead .tool-nav {gap:4px;}
body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav a,
#bk[data-cx] .tool-nav a {
  border:0;border-radius:9px;box-shadow:none;background:transparent;color:var(--cx-muted);gap:7px;
  padding:0 12px;font:550 .91rem/1.3 var(--cx-font);min-height:40px;
}
body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav a[aria-current],
#bk[data-cx] .tool-nav a[aria-current] {background:var(--cx-nav-active,var(--cx-soft));color:var(--cx-nav-active-ink,var(--cx-ink));box-shadow:none;}
body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav img {width:21px;height:21px;object-fit:contain;}
body[data-cx] :is(.tool-theme,.style-picker,.skin-choice) {color:var(--cx-muted);font-family:var(--cx-font);}
body[data-cx] :is(#skinChoice,#style-choice),#bk[data-cx] #skinChoice {
  border:1px solid var(--cx-rule);border-radius:10px;background-color:var(--cx-soft);
  color:var(--cx-ink);font:550 .875rem/1.2 var(--cx-font);padding-inline:10px;min-height:40px;
}
body[data-cx] :is(.tool-intro,.masthead .intro),#bk[data-cx] #chart-shell .tool-intro {
  box-sizing:border-box;width:100%;max-width:var(--cx-width);margin-inline:auto;padding:clamp(22px,3.1vw,42px) var(--cx-gutter) 22px;
  display:flex;align-items:baseline;justify-content:flex-start;gap:14px;background:none;
}
body[data-cx] :is(.tool-intro,.masthead .intro) h1,#bk[data-cx] .tool-intro h1,body[data-cx].utility-page main h1 {
  color:var(--cx-ink);font:600 clamp(2.05rem,3.6vw,3.25rem)/1.18 var(--cx-font);
  margin:0;letter-spacing:.015em;
}
body[data-cx] :is(.tool-intro,.masthead .intro) p,#bk[data-cx] .tool-intro p {
  color:var(--cx-muted);font:500 .91rem/1.5 var(--cx-font);margin:0;letter-spacing:.04em;
}
body[data-cx] :is(.tool-work,.workspace,.shell):not(.masthead-inner):not(.intro),#bk[data-cx] .tool-work {
  max-width:var(--cx-width);width:100%;box-sizing:border-box;padding-inline:var(--cx-gutter);margin-inline:auto;
}
#bk[data-cx] #divSettings,#bk[data-cx] #divMain,body[data-cx="jiugong"] .workspace > :is(.controls,.result),
body[data-cx="meihua"] :is(.input-panel,.chart-panel,.reading-section),body[data-cx].utility-page :is(.card,.panel,.tool-card) {
  border:1px solid var(--cx-rule);border-radius:18px;background:var(--cx-surface);color:var(--cx-ink);box-shadow:var(--cx-shadow);
}
#bk[data-cx] #divSettings {padding:clamp(15px,2.3vw,30px);}
#bk[data-cx] .tool-section {border:0;margin:0 0 10px;padding:0;}
#bk[data-cx] .tool-section h2,body[data-cx="meihua"] .input-panel > h2,body[data-cx="jiugong"] .settings-title {
  font:650 1.35rem/1.35 var(--cx-font);color:var(--cx-ink);letter-spacing:.005em;
}
#bk[data-cx] .tool-section h2::after,body[data-cx="meihua"] .input-panel > h2::after {display:none;}
#bk[data-cx] #frmUpInfoTbl {font-family:var(--cx-font);}
#bk[data-cx] #frmUpInfoTbl tr.time td {background:var(--cx-soft);border:0;padding-block:12px;}
#bk[data-cx] #frmUpInfoTbl tr.time td:first-child {border-radius:9px 0 0 9px;padding-left:8px;}
#bk[data-cx] #frmUpInfoTbl tr.time td:last-child {border-radius:0 9px 9px 0;}
#bk[data-cx] #spanNowTime {color:var(--cx-ink);font:650 .99rem/1.4 var(--cx-font);font-variant-numeric:tabular-nums;}
#bk[data-cx] #spanGanzhiTime {color:var(--cx-muted);font:450 .88rem/1.6 var(--cx-font);}
#bk[data-cx] #frmUpInfoTbl :is(select,input[type="text"],input[type="tel"],input[type="date"],input[type="button"],#btnAutoInput),
body[data-cx] :is(.input-panel,.controls,form) :is(input:not([type]),input[type="text"],input[type="number"],input[type="time"],input[type="date"],input[type="search"],select) {
  border:1px solid var(--cx-edge);border-radius:9px;color:var(--cx-ink);background-color:var(--cx-surface);box-shadow:none;
  font-family:var(--cx-font);max-width:100%;box-sizing:border-box;
}
#bk[data-cx] .time-mode-option label {border-radius:9px;font-family:var(--cx-font);}
#bk[data-cx] #frmUpInfoTbl .startlesson-button,#bk[data-cx] .chart-actions #btnReset,
body[data-cx] :is(#submit-chart,button.primary,button.solid,.submit-chart,.main-action,.go) {
  border:1px solid var(--cx-accent);border-radius:10px;background:var(--cx-accent);color:var(--cx-on);
  box-shadow:none;font-family:var(--cx-font);font-weight:650;letter-spacing:.04em;
}
#bk[data-cx] #frmUpInfoTbl .startlesson-button {min-height:46px;font-size:1rem;}
body[data-cx] :is(button,input,select):disabled {cursor:not-allowed;}
#bk[data-cx] .tool-work {gap:20px;}
#bk[data-cx] .chart-actions {gap:12px;flex-wrap:wrap;}
#bk[data-cx] .chart-actions label {font-family:var(--cx-font);}
#bk[data-cx] #divMain {padding:clamp(10px,1.8vw,24px);}
#bk[data-cx] #liugongTbls {margin:12px 0;box-shadow:none;}
#bk[data-cx] #liugongTbls td.main {border-color:var(--theme-board-rule);}
#bk[data-cx] #liugongTbls td.main:focus-visible {outline-offset:-4px;outline:3px solid var(--cx-accent);}
#bk[data-cx] .appendix-list {border-radius:12px;border:1px solid var(--cx-rule);overflow:visible;min-width:0;}
#bk[data-cx] .appendix-list > details {background:var(--cx-surface);border:0;border-bottom:1px solid var(--cx-rule);}
#bk[data-cx] .appendix-list > details:first-child {border-radius:12px 12px 0 0;}
#bk[data-cx] .appendix-list > details:last-child {border-bottom:0;border-radius:0 0 12px 12px;}
#bk[data-cx] .appendix-list > details > summary {border-radius:inherit;color:var(--cx-ink);font-family:var(--cx-font);padding:10px 12px;min-height:48px;}
#bk[data-cx] .appendix-number {color:var(--cx-muted);}
#bk[data-cx] .appendix-list details[open] > summary {background:var(--cx-soft);box-shadow:inset 3px 0 var(--cx-accent);}
#bk[data-cx] #divMain[style*="none"] ~ .aux-tools {padding:0;border:0;box-shadow:none;background:transparent;}
#bk[data-cx] .aux-tools h2 {margin:6px 0 12px;color:var(--cx-ink);font:650 1.3rem/1.4 var(--cx-font);}
#bk[data-cx] .aux-tools nav {grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;}
#bk[data-cx] .aux-tools a {display:flex;justify-content:flex-start;gap:12px;border:1px solid var(--cx-rule);border-radius:13px;
  min-height:62px;padding:10px 15px;background:var(--cx-surface);font:600 .99rem/1.4 var(--cx-font);color:var(--cx-ink);}
#bk[data-cx] .aux-tools .cx-tool-icon {width:25px;height:25px;padding:6px;box-sizing:content-box;border-radius:10px;background:var(--cx-soft);color:var(--cx-accent);flex:none;}
#bk[data-cx] .aux-tools a > span:last-child {margin-inline-start:auto;color:var(--cx-muted);}
#bk[data-cx] #divMain[style*="none"] ~ .homepage-classic:not([hidden]) {grid-column:1/-1;max-width:100%;border:0;border-inline-start:2px solid var(--cx-accent);padding:10px 18px;background:transparent;box-sizing:border-box;}
#bk[data-cx] .homepage-classic :is(cite,figcaption) {color:var(--cx-muted);}
/* Reference plates show fixed positions only, and leave the workspace when a real chart exists. */
body[data-cx] .cx-atlas,#bk[data-cx] .cx-atlas {display:none;}
body[data-cx="jiugong"] .workspace:has(> #result[hidden]) .cx-atlas,
body[data-cx="meihua"] .chart-layout:has(> #result[hidden]) .cx-atlas,
#bk[data-cx] #divMain[style*="none"] + .cx-atlas {
  position:relative;isolation:isolate;overflow:hidden;display:grid;align-self:stretch;align-content:space-between;
  justify-items:start;box-sizing:border-box;min-width:0;min-height:300px;gap:12px;
  padding:clamp(18px,2.3vw,32px);border:1px solid color-mix(in srgb,var(--cx-etch) 25%,var(--cx-dial));
  border-radius:18px;text-align:start;color:var(--cx-etch);box-shadow:var(--cx-shadow);
  background:radial-gradient(ellipse at 76% 70%,color-mix(in srgb,var(--cx-etch) 12%,var(--cx-dial)),var(--cx-dial) 74%);
}
body[data-cx] .cx-atlas::before {
  content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;
  background-image:linear-gradient(to right,color-mix(in srgb,var(--cx-etch) 5%,transparent) 1px,transparent 1px),
    linear-gradient(to bottom,color-mix(in srgb,var(--cx-etch) 5%,transparent) 1px,transparent 1px);
  background-size:28px 28px;
}
body[data-cx] .cx-plate-copy {align-self:start;}
body[data-cx] .cx-plate-copy h2 {margin:0;color:inherit;font:550 clamp(1.25rem,2.1vw,1.7rem)/1.4 var(--cx-font);letter-spacing:.13em;}
body[data-cx] .cx-plate-copy p {margin:5px 0 0;max-width:28em;color:inherit;font:450 .87rem/1.6 var(--cx-font);letter-spacing:.035em;}
body[data-cx] .cx-wheel {display:block;align-self:center;justify-self:center;width:min(100%,285px);height:auto;overflow:visible;}
.cx-wheel .cx-engraving,.cx-wheel .cx-crosshair {fill:none;stroke:currentColor;stroke-width:.8;opacity:.65;}
.cx-wheel .cx-crosshair {opacity:.34;}
.cx-wheel text {fill:currentColor;}
.cx-wheel .cx-palace {font:550 17px var(--cx-font);letter-spacing:1.5px;}
.cx-wheel .cx-bearing {font:450 12px var(--cx-font);}
.cx-wheel .cx-dial-center {font:500 59px var(--cx-font);}
body[data-cx] .cx-nine {
  display:grid;grid-template-columns:repeat(3,1fr);gap:2px;list-style:none;padding:7px;margin:8px auto 0;
  border:1px solid currentColor;outline:1px solid color-mix(in srgb,currentColor 40%,transparent);outline-offset:4px;
  width:min(100%,218px);aspect-ratio:1;box-sizing:border-box;
}
body[data-cx] .cx-nine li {display:flex;align-items:center;justify-content:center;gap:4px;border:1px solid color-mix(in srgb,currentColor 55%,transparent);}
.cx-nine b {font:500 1.55rem var(--cx-font);}
.cx-nine span {font:.82rem var(--cx-font);}
body[data-cx] .cx-lines {display:grid;grid-template-columns:auto 1fr 1fr;align-items:center;gap:12px 18px;justify-self:center;
  width:min(100%,290px);margin:10px 0;padding:10px 0;font:500 .9rem/1.3 var(--cx-font);}
.cx-lines b {font-weight:600;text-align:center;}
.cx-lines i {height:6px;background:color-mix(in srgb,currentColor 12%,transparent);border-radius:2px;}
.cx-lines .cx-line-on {background:currentColor;}
@media(min-width:840px) {
  #bk[data-cx] .tool-work:has(> #divMain[style*="none"]),
  body[data-cx="jiugong"] .workspace:has(> #result[hidden]),
  body[data-cx="meihua"] .chart-layout:has(> #result[hidden]) {
    grid-template-columns:minmax(0,1.19fr) minmax(0,.95fr);max-width:var(--cx-width);width:100%;gap:22px;
  }
  #bk[data-cx] .tool-work:has(> #divMain[style*="none"]) {grid-template-areas:"form plate" "tools tools" "quote quote";}
  #bk[data-cx] .tool-work:has(> #divMain[style*="none"]) > #divSettings {grid-area:form;}
  #bk[data-cx] .cx-atlas {grid-area:plate;}
  #bk[data-cx] .aux-tools {grid-area:tools;}
  #bk[data-cx] .homepage-classic {grid-area:quote;}
  body[data-cx="meihua"] .chart-layout:has(> #result[hidden]) {margin-inline:0;}
  body[data-cx="jiugong"] .workspace:has(> #result[hidden]) .controls,
  body[data-cx="meihua"] .chart-layout:has(> #result[hidden]) .input-panel {padding:clamp(20px,2.5vw,32px);}
}
@media(min-width:1100px) {
  #bk[data-cx] .tool-work:has(> #divMain:not([style*="none"])) {grid-template-columns:minmax(0,1fr);}
  #bk[data-cx] #divMain:not([style*="none"]) {
    display:grid;grid-template-columns:minmax(0,1.55fr) minmax(285px,1fr);grid-template-rows:auto auto 1fr;
    gap:4px 28px;align-items:start;order:-1;
  }
  #bk[data-cx] #divMain > :is(#divLesson,.lesson-board-area,.chart-actions) {grid-column:1;}
  #bk[data-cx] #divMain .appendix-list {grid-area:1/2/4/3;margin:0;}
  #bk[data-cx] .tool-work:has(> #divMain:not([style*="none"])) #divSettings {max-width:700px;}
}
body[data-cx="meihua"] {--ink:var(--cx-ink);--muted:var(--cx-muted);--accent:var(--cx-accent);--panel:var(--cx-surface);--rule:var(--cx-rule);}
body[data-cx="meihua"] :is(.mode-picker,.field input,.field select,.era-picker,.chart-submit) {border-radius:10px;}
body[data-cx="jiugong"] .result-heading,body[data-cx="meihua"] .board-heading {border-color:var(--cx-rule);}
body[data-cx="jiugong"] :is(.controls form,.settings-summary,.year-controls,.result-heading),body[data-cx="meihua"] :is(.field,.mode-picker,.form-row,.board-heading,.style-picker){font-family:var(--cx-font);}
body[data-cx="jiugong"] .board-frame {border-radius:12px;}
body[data-cx="jiugong"] .workspace > .result,body[data-cx="meihua"] .result {min-width:0;}
body[data-cx="help"] {padding:var(--cx-gutter);line-height:1.8;}
body[data-cx="help"] .help-page {width:min(100%,78ch);box-sizing:border-box;margin:0 auto;padding:clamp(20px,5vw,64px);
  background:var(--cx-surface);color:var(--cx-ink);border:1px solid var(--cx-rule);border-radius:18px;}
body[data-cx="help"] .help-page h1 {font:600 clamp(1.8rem,3.9vw,2.8rem)/1.3 var(--cx-font);}
body[data-cx="help"] .help-page h2 {font:650 1.25rem/1.5 var(--cx-font);margin-top:2.1em;padding-top:.7em;border-top:1px solid var(--cx-rule);}
body[data-cx="help"] .help-page a {color:var(--cx-accent);}
body[data-cx].utility-page {--utility-width:var(--cx-width);--utility-gutter:var(--cx-gutter);--utility-muted:var(--cx-muted);font-family:var(--cx-font);}
body[data-cx].utility-page .mast-inner {padding-inline:var(--cx-gutter);min-height:64px;}
body[data-cx].utility-page .mast-inner .brand {font:650 1.1rem/1.3 var(--cx-font) !important;}
body[data-cx].utility-page .mast-inner a:where(:not(.brand)) {color:var(--cx-accent);font:600 .9rem/1.5 var(--cx-font);min-height:44px;}
body[data-cx].utility-page > main {
  box-sizing:border-box;width:100%;max-width:var(--cx-width);padding:clamp(22px,3.2vw,42px) var(--cx-gutter) 38px;margin-inline:auto;
}
body[data-cx].utility-page main h1 {font-family:var(--cx-font) !important;margin:0 0 .48em;line-height:1.2;}
body[data-cx].utility-page :is(.tabs,.lookup-modes,.purpose-list,.tool-nav) {gap:6px;}
body[data-cx].utility-page :is(.tabs,.lookup-modes,.purpose-list,.tool-nav) button {
  border-radius:9px;padding-inline:12px;min-height:42px;box-sizing:border-box;
}
body[data-cx].utility-page :is(h2,.clock-heading h2) {font-weight:650;letter-spacing:.01em;}
body[data-cx].utility-page :is(.card,.tool-card,.panel){min-width:0;}
body[data-cx].utility-page .clocks .primary {
  color:var(--cx-etch);background:var(--cx-dial);border-color:var(--cx-dial);
}
body[data-cx].solar-calculator .clocks .primary :is(h2,.time,.date,.note,.range,.detail) {color:var(--cx-etch);}
body[data-cx].solar-calculator .primary #graphButton {border:1px solid currentColor;color:var(--cx-etch);background:transparent;border-radius:9px;}
body[data-cx].solar-calculator .clocks .time {font-variant-numeric:tabular-nums;letter-spacing:-.04em;}
body[data-cx].luban-ruler .ruler-card {border-top:3px solid var(--cx-accent);}
body[data-cx].utility-page .utility-site-footer {width:100%;text-align:center;padding:16px var(--cx-gutter);max-width:var(--cx-width);margin:0 auto;box-sizing:border-box;}
@media (max-width:839px) {
  #bk[data-cx] .tool-work:has(> #divMain[style*="none"]) {max-width:var(--cx-width);grid-template-columns:minmax(0,1fr);}
  #bk[data-cx] .aux-tools {order:1;}
  #bk[data-cx] .cx-atlas {order:2;}
  #bk[data-cx] .homepage-classic {order:3;}
  body[data-cx] .chart-layout:has(> #result[hidden]) {width:100%;}
  body[data-cx="jiugong"] .workspace:has(> #result[hidden]) .cx-atlas,
  body[data-cx="meihua"] .chart-layout:has(> #result[hidden]) .cx-atlas,
  #bk[data-cx] #divMain[style*="none"] + .cx-atlas {
    grid-template-columns:minmax(100px,1fr) minmax(155px,1.08fr);align-items:center;align-content:center;
    min-height:0;gap:10px;padding:18px 20px;
  }
  body[data-cx] .cx-plate-copy {align-self:center;}
  body[data-cx] .cx-wheel {max-width:255px;}
  body[data-cx] .cx-lines {gap:7px 9px;}
  body[data-cx] .cx-nine {max-width:155px;}
  body[data-cx].utility-page :is(.card,.tool-card,.panel) {border-radius:14px;}
}
/* The middle grid column can shrink below the total width of its links.
   Reserve the picker and navigation's natural widths and wrap whole groups. */
@media (min-width:751px) {
  body[data-cx] .tool-masthead .tool-head-inner,
  body[data-cx="meihua"] .masthead .masthead-inner {
    display:flex;flex-wrap:wrap;align-items:center;row-gap:.35rem;padding-block:.4rem;
  }
  body[data-cx] .tool-masthead .tool-head-inner .tool-nav,
  body[data-cx="meihua"] .masthead-inner .tool-nav {
    flex:0 1 auto;flex-wrap:wrap;max-width:100%;
  }
  body[data-cx] .tool-head-inner > .tool-theme,
  body[data-cx="meihua"] .masthead-inner > .style-picker {margin-inline-start:auto;}
}

@media(max-width:750px) {
  body[data-cx] {--cx-gutter:clamp(10px,3.8vw,22px);}
  body[data-cx] .tool-masthead,body[data-cx="meihua"] > .masthead,#bk[data-cx] .tool-masthead {display:block;}
  body[data-cx] :is(.tool-head,.masthead-bar),#bk[data-cx] .tool-head {display:block;}
  body[data-cx] :is(.tool-head-inner,.masthead-inner),#bk[data-cx] .tool-head-inner {
    display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:5px 8px;
    width:100%;max-width:none;margin:0;padding:9px var(--cx-gutter) 7px;height:auto;background:var(--cx-surface);
  }
  body[data-cx] :is(.tool-head-inner,.masthead-inner) .tool-links,#bk[data-cx] .tool-links {display:contents;}
  body[data-cx] :is(.tool-head-inner,.masthead-inner) :is(.brand,.tool-brand),#bk[data-cx] .tool-brand {
    grid-area:1/1;justify-self:start;padding:0;font-size:1.05rem;
  }
  body[data-cx] :is(.tool-head-inner,.masthead-inner) :is(.tool-theme,.style-picker),#bk[data-cx] .tool-theme {
    display:flex;grid-area:1/2;justify-self:end;align-items:center;margin:0;padding:0;font-size:.78rem;
  }
  body[data-cx] .tool-masthead .tool-nav,body[data-cx="meihua"] .masthead-inner .tool-nav,#bk[data-cx] .tool-nav {
    grid-area:2/1/3/-1;display:flex;width:100%;justify-content:space-between;gap:2px;overflow:visible;
  }
  body[data-cx] .tool-masthead .tool-nav a,body[data-cx="meihua"] .tool-nav a,#bk[data-cx] .tool-nav a {
    display:inline-flex;flex:1 1 auto;justify-content:center;gap:4px;padding:4px 3px;min-height:42px;font-size:clamp(.77rem,3.3vw,.94rem);
  }
  body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav img {width:18px;height:18px;}
  body[data-cx] :is(#skinChoice,#style-choice),#bk[data-cx] #skinChoice {min-height:40px;height:40px;}
  body[data-cx] :is(.tool-intro,.masthead .intro),#bk[data-cx] #chart-shell .tool-intro {max-width:none;gap:10px;padding:21px var(--cx-gutter) 17px;margin:0;flex-wrap:wrap;}
  body[data-cx] :is(.tool-intro,.masthead .intro) h1,#bk[data-cx] .tool-intro h1 {font-size:clamp(1.9rem,6.8vw,2.5rem);}
  body[data-cx] :is(.tool-intro,.masthead .intro) p,#bk[data-cx] .tool-intro p {font-size:.83rem;}
  #bk[data-cx] .tool-work {gap:15px;}
  #bk[data-cx] .aux-tools nav {grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;}
  #bk[data-cx] .aux-tools a {padding:8px;gap:7px;min-height:52px;font-size:.88rem;}
  #bk[data-cx] .aux-tools .cx-tool-icon {width:20px;height:20px;padding:4px;}
  #bk[data-cx] #divSettings,#bk[data-cx] #divMain {padding:clamp(8px,2.6vw,15px);border-radius:14px;}
  body[data-cx].utility-page .mast-inner {min-height:54px;}
}
@media (max-width:390px) {
  #bk[data-cx] #divMain {padding:6px;}
  #bk[data-cx] #frmUpInfoTbl > table td.title {width:68px;}
  #bk[data-cx] .lesson-question-fields {grid-template-columns:minmax(48px,.7fr) minmax(70px,1.3fr);}
  #bk[data-cx] .lesson-form-label {font-size:.88rem;}
  body[data-cx] .cx-nine b {font-size:1.1rem;}
}
@media (hover:hover) {
  body[data-cx] :is(.tool-masthead,.masthead-bar) .tool-nav a:hover,#bk[data-cx] .tool-nav a:hover {background:var(--cx-soft);color:var(--cx-ink);}
  #bk[data-cx] .aux-tools a:hover {color:var(--cx-accent);border-color:var(--cx-edge);background:var(--cx-soft);}
}
@media (prefers-reduced-motion:reduce) {
  body[data-cx] :is(.tool-nav a,.aux-tools a,button,summary){transition:none;scroll-behavior:auto;}
}
/* Archived entry pages keep their original tables and event targets. */
body[data-cx="legacy"]#bk {min-width:0;padding:clamp(8px,3vw,28px);background:var(--cx-paper);font-family:var(--cx-font);color:var(--cx-ink);}
body[data-cx="legacy"]#bk > div:first-child {max-width:720px;margin:auto;}
body[data-cx="legacy"]#bk h1 {font:600 clamp(1.8rem,4vw,2.8rem)/1.3 var(--cx-font);color:var(--cx-ink);}
body[data-cx="legacy"]#bk :is(#divSettings,#divMain) {box-sizing:border-box;max-width:100%;overflow-x:auto;background:var(--cx-surface);border:1px solid var(--cx-rule);border-radius:14px;padding:12px;}
body[data-cx="legacy"]#bk :is(input,button,select){max-width:100%;font-family:var(--cx-font);}
/* The three destination marks already identify their tools; keep the wordmark typographic.
   This also respects the utilities' original image-source restrictions. */
body[data-cx] :is(.tool-brand,.masthead .brand)::before {content:none;mask:none;}
#bk[data-cx] #chart-shell:has(#divMain[style*="none"]) .tool-intro {max-width:var(--cx-width);padding-block:clamp(22px,3.1vw,42px) 22px;}
body[data-cx].solar-calculator .clocks .primary #trueDiff {color:var(--cx-etch);}
body[data-cx="jiugong"] {
  --muted:var(--cx-muted);--ink:var(--cx-ink);--paper:var(--cx-paper);--card:var(--cx-surface);
  --line:var(--cx-rule);--soft:var(--cx-soft);--green:var(--cx-accent);
  --theme-board-muted:color-mix(in srgb,var(--theme-board-ink) 85%,var(--theme-board));
}
body[data-cx="jiugong"] .year-card.selected :is(span,small) {color:var(--theme-board-ink);}
@media(max-width:750px) {
  body[data-cx="meihua"] .masthead .masthead-inner .tool-nav a {
    min-width:0;flex:1 1 auto;padding:4px 3px;gap:4px;font:550 clamp(.77rem,3.3vw,.94rem)/1.3 var(--cx-font);
  }
  body[data-cx="meihua"] .masthead .masthead-inner .tool-nav img {width:18px;height:18px;}
}
:root:is([data-skin="antique"],[data-theme="antique"]) body[data-cx],
body[data-cx="legacy"] {
  --cx-soft:#e5d0b2; --cx-rule:#bca183; --cx-edge:#927153;
}
:root[data-skin="antique"] #liugongTbls {--theme-palace-head:#d3b28b;}
:root[data-skin="antique"] #bk[data-cx] .tool-nav a[aria-current] {
  background:var(--cx-accent); color:var(--cx-on);
}
:root[data-skin="antique"] .tool-nav a[aria-current] .tool-logo-xuanyi {filter:brightness(0) invert(.96) sepia(.22);}
@media(max-width:750px) {
  body[data-cx] .tool-masthead .tool-head-inner .tool-nav,
  #bk[data-cx] .tool-masthead .tool-head-inner .tool-nav,
  body[data-cx="meihua"] .masthead .masthead-inner .tool-nav {
    display:grid;grid-template-columns:minmax(0,3.25fr) minmax(0,5.15fr) minmax(0,4.6fr);
    min-width:0;white-space:normal;
  }
  body[data-cx] .tool-masthead .tool-head-inner .tool-nav a,
  #bk[data-cx] .tool-masthead .tool-head-inner .tool-nav a,
  body[data-cx="meihua"] .masthead .masthead-inner .tool-nav a {
    min-height:44px;min-width:0;white-space:normal;overflow-wrap:anywhere;text-align:center;
    line-height:1.35;padding-inline:3px;
  }
  body[data-cx] .tool-nav a > span {min-width:0;}
}
@media (max-width:560px) {
  /* Give the engraved direction labels real reading space after the six tool links. */
  #bk[data-cx] #divMain[style*="none"] + .cx-compass {grid-template-columns:minmax(0,1fr);gap:10px;}
  #bk[data-cx] .cx-compass .cx-wheel {width:min(100%,280px);max-width:none;}
  .cx-wheel .cx-bearing {font-size:15px;}
}

/* All four chart interfaces use the reader's default rem. Older product sheets
   set their own 14px or 17px root, so the same rem used to render differently. */
:root:has(> body:is([data-cx="xuanyi"], [data-cx="jiugong"], [data-cx="meihua"], [data-cx="qimen-caiqi"])) {
  font-size:100%;
  --cx-page-title:2.5rem;
  --cx-result-title:1.5rem;
  --cx-section-title:1.375rem;
  --cx-subheading:1.125rem;
  --cx-body:1rem;
  --cx-label:.875rem;
  --cx-note:.8125rem;
  --cx-caption:.75rem;
  --cx-chart-value:1.25rem;
}
@media (max-width:750px) {
  :root:has(> body:is([data-cx="xuanyi"], [data-cx="jiugong"], [data-cx="meihua"], [data-cx="qimen-caiqi"])) {
    --cx-page-title:1.875rem;
    --cx-result-title:1.375rem;
    --cx-section-title:1.25rem;
    --cx-chart-value:1.125rem;
  }
}

/* The older styles contain important font shorthands. Only assign type roles to
   visible text and controls; the data grids keep their own layout and line rhythm. */
@layer typography {
  body:where([data-cx="xuanyi"], [data-cx="jiugong"], [data-cx="meihua"], [data-cx="qimen-caiqi"]) {
    font-size:var(--cx-body) !important;

    & :where(h1) {
      min-width:0;
      white-space:normal;
      overflow-wrap:anywhere;
      font-size:var(--cx-page-title) !important;
      line-height:1.2 !important;
    }
    & :where(.tool-brand, .masthead .brand) {
      font-size:var(--cx-subheading) !important;
    }
    & :where(.tool-nav a, .tool-nav a > span, .mast-inner nav a, .tool-intro p, .masthead .intro p, main > .intro) {
      font-size:var(--cx-label) !important;
      line-height:1.5 !important;
    }
    & :where(.skin-choice, .style-picker, .style-picker-label) {
      font-size:var(--cx-note) !important;
    }
    & :where(#skinChoice, #style-choice) {
      height:max(40px,1.8em) !important;
      min-height:max(40px,1.8em) !important;
    }
    & :where(.tool-section h2, .aux-tools h2, .settings-title, .settings-summary b, #input-title, .cx-plate-copy h2, #results-title) {
      font-size:var(--cx-section-title) !important;
      line-height:1.35 !important;
    }
    & :where(#chart-title, #reading-title) {
      font-size:var(--cx-result-title) !important;
      line-height:1.35 !important;
    }
    & :where(.section-title h3, .reading-section h3, .reading-section h4, .reading-item h3,
             .synthesis-heading h3, .synthesis-article h4, #results h3) {
      font-size:var(--cx-subheading) !important;
      line-height:1.4 !important;
    }

    /* Labels, mode switches, entry fields and submit actions. */
    & :where(#frmUpInfoTbl .title, form label, form legend, .field > label, .segmented label span,
             .time-mode-option label, .mode-picker button, .mode-options label > span, .mode-options label,
             .strength-controls label, #annual-reading > label, .chart-actions label, .fields label > span) {
      font-size:var(--cx-label) !important;
    }
    & :where(input:not([type]), input:is([type="text"], [type="tel"], [type="date"], [type="time"], [type="number"]),
             select, select option, .startlesson-button, #submit-chart, #chart-form button.primary, #btnReset,
             #spanNowTime, .aux-tools a) {
      font-size:var(--cx-body) !important;
    }
    & :where(#btnSelectNumber, #btnAutoInput, .week-navigation button, #strength-restore, .name-guide summary,
             .control-footer a, .period-button strong, .year-card strong, .topic-options strong, .period-options strong) {
      font-size:var(--cx-label) !important;
    }
    & :where(.cx-plate-copy p, .field-hint, .input-hint, .strength-status, .decade-note, #spanGanzhiTime,
             #directionHint, #manualDateHint, .settings-toggle, #input-summary, .control-footer, #summary,
             .mode-options small, .section-title small, .reference-footnote, .reading-source, .footer-contact,
             .footer-registration, .site-version, .meta.date-status, #birth-caption, .board-hint, #chart-moving) {
      font-size:var(--cx-note) !important;
    }
    & :where(.settings-content > .intro, .name-guide li, .reference-content .guide-content :is(p, li),
             .reference-intro, .synthesis-article p, .reading-section p:not(.reading-source, .strength-status, .decade-note),
             #annual-comparison li, #annual-answer li, .reading-item p, .reading-item p span,
             .reading-section h5, .appendix-title, .reference-toggle, .reading summary, .reading > p,
             .result .action, .result .travel, .homepage-classic blockquote p, #topic-evidence li,
             .lesson-general-name, .lesson-general-name strong, .lesson-general-reading, .lesson-general-reading > span) {
      font-size:var(--cx-body) !important;
      line-height:1.6 !important;
    }
    & :where(.tool-lesson-meta p, .tool-lesson-meta b, .reading-meta, .appendix-number, .appendix-order, .appendix-scroll-hint, .homepage-classic cite,
             .homepage-classic figcaption, .synthesis-basis, .board-legend, .reference-toggle > span) {
      font-size:var(--cx-note) !important;
    }
    /* Only the principal names use the larger size inside a three-column chart. */
    & :where(.tdLiugongName, .door-name, .star-name, .hexagram-caption h3) {
      font-size:var(--cx-chart-value) !important;
    }
    & :where(.palace-title, .hexagram-palace, .board-stage-name) {
      font-size:var(--cx-caption) !important;
    }
    & :where(.palace-element-suffix, .pillar-palace-stage, .pillar-palace-tag, .stem-flags, .door-pressure) {
      font-size:var(--cx-caption) !important;
    }
  }
}

#bk[data-cx="xuanyi"] .lesson-general-reading > span {white-space:normal;overflow-wrap:anywhere;}
#bk[data-cx="xuanyi"] #divSettings {container:lesson-form / inline-size;}
/* Stack the two compound fields when the card has little room per character. */
@container lesson-form (max-width:18rem) {
  #bk[data-cx="xuanyi"] #frmUpInfoTbl > table,
  #bk[data-cx="xuanyi"] #frmUpInfoTbl > table > tbody {display:grid;width:100%;gap:.55rem;}
  #bk[data-cx="xuanyi"] #frmUpInfoTbl > table > tbody > tr > td {display:block;width:auto;max-width:100%;}
  #bk[data-cx="xuanyi"] .lesson-form-label {min-height:0;margin-bottom:.3rem;}
  #bk[data-cx="xuanyi"] #divSettings .lesson-question-fields,
  #bk[data-cx="xuanyi"] #divSettings .lesson-number-fields {grid-template-columns:minmax(0,1fr);gap:.3rem;}
  #bk[data-cx="xuanyi"] #frmUpInfoTbl :is(#selType,#txtContent,#btnSelectNumber,#startNum) {
    width:100%;min-height:max(44px,1.8em);height:auto;
  }
  #bk[data-cx="xuanyi"] #frmUpInfoTbl #startNum {min-height:max(44px,2.8em);}
}
body[data-cx="jiugong"] .tool-intro h1 {min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
body[data-cx="jiugong"] .period-section {container:period-section / inline-size;}
@container period-section (max-width:34rem) {
  body[data-cx="jiugong"] #periods {grid-template-columns:repeat(auto-fit,minmax(min(100%,5.5rem),1fr));}
  body[data-cx="jiugong"] #periods .period-button {border:0;box-shadow:inset 0 0 0 .5px var(--cx-rule);}
}

#bk[data-cx] #lesson-settings-disclosure > summary {
  color:var(--cx-ink);cursor:pointer;font-size:var(--cx-body);font-weight:600;line-height:1.5;
}
#bk[data-cx] #lesson-settings-disclosure > summary[hidden],
#bk[data-cx] #lesson-settings-disclosure:has(> summary:not([hidden])) .tool-section {display:none;}
#bk[data-cx] #divSettings:has(#lesson-settings-disclosure:not([open])) {padding:.75rem 1rem;align-self:start;}
#bk[data-cx] #lesson-settings-disclosure[open] > summary:not([hidden]) {margin-bottom:.75rem;}
#bk[data-cx] .lesson-board-area {min-width:0;container:lesson-board / inline-size;}
#bk[data-cx] .lesson-board-scroll {max-width:100%;overflow-x:auto;}
#bk[data-cx] :is(.appendix-scroll-hint,.board-scroll-hint) {
  display:block;margin:.4rem 0;font-size:var(--cx-note);color:var(--cx-muted);
}
#bk[data-cx] :is(.appendix-scroll-hint,.board-scroll-hint)[hidden] {display:none;}
#bk[data-cx] .palace-selection {display:none;}
#bk[data-cx] #palace-relationships {scroll-margin-top:1rem;}
@media (max-width:1099px) {
  #bk[data-cx] .palace-selection:not([hidden]) {
    position:sticky;bottom:0;z-index:2;display:flex;align-items:center;justify-content:space-between;
    flex-wrap:wrap;gap:.15rem .6rem;padding:.15rem .6rem;background:var(--cx-surface);
    border:1px solid var(--cx-rule);border-radius:8px;font-size:var(--cx-label);
  }
  #bk[data-cx] .palace-selection a {display:inline-flex;align-items:center;min-height:44px;color:var(--cx-accent);font-weight:600;}
}
@media (min-width:1100px) {
  #bk[data-cx] #divMain .appendix-list:has(> :is(#appendix-一,#appendix-三)[open]) {grid-area:4/1/5/-1;}
}
#bk[data-cx] #liugongTbls .pillar-palace-tag {
  inline-size:max-content;max-width:none;
  color:var(--cx-ink);background-color:var(--cx-surface);border-radius:.15em;
}
#bk[data-cx] #liugongTbls .palace-force {
  inline-size:1.35em;block-size:1.35em;line-height:1.35;
}
@layer typography {
  #bk[data-cx="xuanyi"] :where(.pillar-control, #bazi-caption, .tdLiuqin, .tdWuxing, .liushen) {
    font-size:var(--cx-label) !important;
  }
  #bk[data-cx="xuanyi"] :where(.ganzhi tr:not(:first-child) td, .pillar-palace-stem-name, .pillar-palace-branch-name) {
    font-size:var(--cx-chart-value) !important;
  }
  #bk[data-cx="xuanyi"] :where(.palace-element, .palace-force, .tdRishi, .pattern-inline) {
    font-size:var(--cx-caption) !important;
  }
}
/* At large text sizes keep the three-by-two spatial arrangement and let the
   reader pan this board independently, including by keyboard. */
@container lesson-board (max-width:23rem) {
  #bk[data-cx] #liugongTbls td.main {padding-bottom:2.25rem;}
}
@container lesson-board (max-width:16rem) {
  #bk[data-cx] #liugongTbls {min-width:23rem;}
}
@media (min-width:420px) {
  @container lesson-board (max-width:23rem) {
    #bk[data-cx] #liugongTbls {min-width:23rem;}
  }
}
@media (max-width:750px) {
  body:is([data-cx="xuanyi"],[data-cx="jiugong"],[data-cx="meihua"]) :is(.tool-head,.masthead-bar) {
    container:chart-header / inline-size;
  }
  @container chart-header (max-width:18rem) {
    body[data-cx] :is(.tool-head-inner,.masthead-inner),#bk[data-cx] .tool-head-inner {grid-template-columns:minmax(0,1fr);}
    body[data-cx] :is(.tool-head-inner,.masthead-inner) :is(.tool-theme,.style-picker),#bk[data-cx] .tool-theme {
      grid-area:2/1;justify-self:start;flex-wrap:wrap;white-space:normal;
    }
    body[data-cx] .masthead .masthead-inner .tool-nav,
    body[data-cx] .tool-masthead .tool-head-inner .tool-nav,#bk[data-cx] .tool-masthead .tool-head-inner .tool-nav {
      grid-area:3/1;
    }
  }
}
body:is([data-cx="xuanyi"],[data-cx="jiugong"],[data-cx="meihua"]) :is(#skinChoice,#style-choice) {width:6.4em;max-width:none;}
body[data-cx="jiugong"] #flow-year {width:5.5em;min-width:5.5em;max-width:100%;}

/* Studio credit sits above the contact details on public pages. */
body[data-cx] footer .studio-signature {
  margin: 0 0 .4rem;
  text-align: center;
  color: var(--cx-ink);
  font: 600 1.0625rem/1.5 var(--cx-font);
  letter-spacing: .055em;
}
body[data-cx="help"] .studio-footer,
body[data-cx="legacy"] .studio-footer {
  text-align: center;
  margin: 1.5rem auto 0;
  padding: 1rem 0;
  color: var(--cx-muted);
  border-top: 1px solid var(--cx-rule);
}
body[data-cx="legacy"] .studio-footer p:not(.studio-signature) {margin: .15rem 0;}
