/* Flat chart surface: one header, twelve palaces, attached time ruler, one command row. */
body.zw-focus-page .chart-shell.chart-workbench{padding:0 6px;max-width:1180px;width:100%;box-sizing:border-box}
body.zw-focus-page .chart-shell.chart-workbench .result-panel{padding:0!important;margin:0!important;max-width:none;width:100%;height:100dvh;min-height:0;overflow:hidden;display:flex;flex-direction:column}
body.zw-focus-page .result-panel>.panel-heading,body.zw-focus-page .chart-intro,body.zw-focus-page .chart-footer{display:none!important}
body .chart-shell #result-content.ziwei-workspace{display:flex;flex:1;flex-direction:column;min-height:0;overflow:hidden}
body .chart-shell .ziwei-workspace>.result-tabs,body .chart-shell .ziwei-workspace>.result-meta,body .chart-shell .ziwei-workspace>.chart-birth-summary,body .chart-shell .ziwei-workspace>.chart-workbench-tools,body .chart-shell .ziwei-workspace .chart-layer-legend{display:none!important}
body .chart-shell .ziwei-workspace .chart-pane-grid{display:contents!important}
body .chart-shell .ziwei-workspace .chart-reading-pane{display:none!important}
body .chart-shell #result-content.ziwei-workspace .ziwei-plate{display:flex!important;flex:1;flex-direction:column;min-height:0;margin:0;padding:0;overflow:hidden!important;border:0}
body .chart-shell .ziwei-workspace .main-plate>h3{display:none}
.zw-toolbar{display:flex;align-items:center;justify-content:space-between;position:relative;flex:0 0 42px;gap:10px;padding:0 8px;border-bottom:1px solid var(--line);color:var(--ink)}
.zw-chart-title{position:absolute;left:50%;transform:translateX(-50%);font:500 17px/1.5 var(--serif);pointer-events:none;white-space:nowrap}
.zw-status{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap;pointer-events:none}
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{flex:1 1 0;min-height:0;height:auto;overflow:hidden;width:100%;margin:0}
body .chart-shell #result-content.ziwei-workspace .palace-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:repeat(4,minmax(0,1fr));width:100%;height:100%;min-height:0;max-height:none;aspect-ratio:auto;margin:0;position:relative}
body .chart-shell .ziwei-workspace .palace-card{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:minmax(0,1fr) auto auto auto;grid-template-areas:'stars stars' 'layers layers' 'triad triad' 'title branch';gap:2px 3px;padding:6px 4px;min-width:0;min-height:0;overflow:visible;line-height:1.15;position:relative}
body .chart-shell .ziwei-workspace .palace-title{grid-area:title;font:500 14px/1.2 var(--serif);color:var(--accent);padding:0;align-self:end;display:flex;align-items:center;gap:3px}
body .chart-shell .ziwei-workspace .palace-title small{font-size:8px}
body .chart-shell .ziwei-workspace .palace-branch{grid-area:branch;position:static;margin:0;font:11px/1.2 var(--serif);display:grid;justify-items:end;gap:3px;align-self:end}
body .chart-shell .ziwei-workspace .palace-branch small{font-size:9px;line-height:1.2}
body .chart-shell .ziwei-workspace .palace-star-columns{grid-area:stars;display:grid;grid-template-columns:repeat(var(--zw-count,8),minmax(0,1fr));align-items:start;align-content:start;align-self:stretch;gap:0;margin:0;min-height:0;min-width:0;width:100%;height:auto;overflow:visible;scrollbar-width:none;flex:none}
body .chart-shell .ziwei-workspace .ziwei-star-column{display:flex;align-items:center;flex-direction:column;justify-self:start;font-size:clamp(9px,calc((100vw - 24px)/4/var(--zw-count,8) - 1px),14px);min-width:0;width:auto;max-width:none;flex:none;line-height:1.1;padding:0}
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-weight:500;color:#88513d;min-width:0;width:auto;flex:none}
body .chart-shell .ziwei-workspace .ziwei-star-column>b{font-size:inherit;display:block;width:1em;word-break:break-all;letter-spacing:0;line-height:1.08;flex-shrink:0}
body .chart-shell .ziwei-workspace .ziwei-star-column small{font-size:8px;line-height:1.1;margin-top:3px}
body .chart-shell .ziwei-workspace .ziwei-star-column em{font-size:9px;line-height:1.1;margin-top:2px}
body .chart-shell .ziwei-workspace .scope-mutagen{font-size:7px;line-height:1.1;margin-top:2px}
body .chart-shell .ziwei-workspace .palace-dynamic-layers{grid-area:layers;display:flex;flex-wrap:wrap;gap:1px 5px;margin:0}
body .chart-shell .ziwei-workspace .palace-dynamic-panel{min-height:0;display:flex;font:9px/1.2 var(--serif);padding:0;gap:2px}
body .chart-shell .ziwei-workspace .palace-dynamic-panel .dynamic-label{white-space:nowrap;color:#8c6446}
body .chart-shell .ziwei-workspace .palace-dynamic-panel .dynamic-stars{display:none}
body .chart-shell .ziwei-workspace .palace-triad{grid-area:triad;display:flex;flex-wrap:wrap;justify-content:space-between;gap:1px 3px;min-height:0;padding:0;margin:0;font:8px/1.1 var(--serif)}
body .chart-shell .ziwei-workspace[data-ziwei-density=basic] [data-star-family=adjective],body .chart-shell .ziwei-workspace[data-ziwei-density=basic] .palace-triad{display:none}
body .chart-shell .ziwei-workspace[data-ziwei-density=basic] .palace-card{grid-template-rows:minmax(0,1fr) auto auto;grid-template-areas:'stars stars' 'layers layers' 'title branch'}
.zw-navigation{flex:0 0 auto;border-inline:1px solid var(--line);border-bottom:1px solid var(--line);background:var(--desk,#eeece4)}
.zw-period-summary{display:none!important}.zw-period-panel{overflow:hidden;margin:0;border:0;max-height:240px}.zw-period-panel[hidden]{display:none}
.ziwei-workspace .zw-navigation .ziwei-timeline{border:0;margin:0}
.ziwei-workspace .zw-navigation .ziwei-time-row{border-bottom:1px solid var(--line);min-height:0}
.ziwei-workspace .zw-navigation .ziwei-time-options button{min-height:38px;padding:3px 5px;gap:1px;min-width:56px;font:12px/1.25 var(--serif)}
.ziwei-workspace .zw-navigation .ziwei-time-options button small{font-size:9px;line-height:1.2}
.ziwei-workspace .zw-navigation .ziwei-time-row>b{font:11px var(--serif);flex:0 0 32px}
.ziwei-workspace .ziwei-plate:not(.zw-periods-open) .ziwei-fine-time{display:none}
.ziwei-workspace .ziwei-plate.zw-periods-open .zw-period-panel{overflow:auto;max-height:28dvh}
.ziwei-workspace .zw-query-source{padding:5px;margin:5px 0 0;border:0;border-top:1px solid var(--line);background:none}
.ziwei-workspace .zw-query-source .chart-plate-tools{display:none!important}.ziwei-workspace .zw-query-source .chart-query-time{gap:5px}.ziwei-workspace .zw-query-source input{max-width:130px}
.zw-command-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex:0 0 42px;padding:0 8px;border-bottom:1px solid var(--line);background:var(--desk,#eeece4)}
.zw-command-bar>button{display:flex;align-items:center;gap:5px;background:none;border:0;font:12px var(--serif);color:var(--accent);padding:8px 0;cursor:pointer}
.zw-selection{position:absolute;left:5%;right:5%;bottom:5%;margin:0;padding:0;border:0;z-index:6;color:var(--ink)}.zw-selection[hidden]{display:none}
.zw-selection-head{display:flex;align-items:center;gap:7px;margin-bottom:6px}.zw-selection-head strong{font:13px var(--serif);margin-right:auto}.zw-selection-head strong small{display:none}
.zw-selection-head button{border:0;background:none;font:10px var(--serif);color:var(--accent);padding:4px 0;cursor:pointer}.zw-selection-head [data-zw-unselect]{font-size:19px;color:var(--muted);min-width:20px}
.zw-four-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:3px}
.zw-four-options button{display:grid;gap:3px;align-content:start;min-width:0;min-height:48px;padding:5px 3px;border:1px solid var(--line);background:var(--desk,#eeece4);color:var(--ink);font:10px/1.3 var(--serif);cursor:pointer;text-align:left}
.zw-four-options b{font-weight:400;color:var(--accent)}.zw-four-options span{display:grid}.zw-four-options small{font-size:8px;color:var(--muted)}.zw-four-options button[aria-pressed=true]{border-color:var(--accent);background:#e7ddcb}
body .chart-shell .ziwei-workspace .palace-card.is-selected{box-shadow:inset 0 0 0 2px #8c533b;background:#eee6d8}
body .chart-shell .ziwei-workspace .palace-card.zw-palace-target{outline:2px solid #946f43;outline-offset:-3px;background:#e8dfcd}
.zw-relation-lines{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:4;overflow:visible}
.zw-relation-path{fill:none;stroke:#946f43;stroke-width:2;stroke-dasharray:6 5;vector-effect:non-scaling-stroke}.zw-source-dot{fill:#946f43}.zw-relation-lines marker path{fill:#946f43}
.ziwei-workspace .palace-center{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:10px 6px}
.zw-has-selection .palace-center>.ziwei-transformations,.zw-has-selection .palace-center>.center-facts,.zw-has-selection .palace-center>strong{display:none}
.zw-center-relation{position:absolute;inset:12% 5% auto;display:grid;gap:6px;justify-items:center;text-align:center;pointer-events:none;z-index:5}
.zw-center-relation small{font:10px var(--serif);color:var(--muted)}.zw-center-relation strong{font:17px var(--serif)}.zw-center-relation span{font:12px var(--serif);color:var(--accent)}.zw-center-relation b{font:11px var(--serif)}
.ziwei-workspace.zw-private .center-facts,.ziwei-workspace.zw-private .palace-center>strong{visibility:hidden}
@media(min-width:801px){body.zw-focus-page .chart-shell.chart-workbench{max-width:1000px}body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:100dvh}body .chart-shell .ziwei-workspace .ziwei-star-column{font-size:16px}body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-size:18px}.zw-selection{left:10%;right:10%}.zw-four-options button{font-size:12px;min-height:58px}.zw-four-options small{font-size:10px}}
@media(max-width:800px){
 body.zw-focus-page .chart-shell.chart-workbench{padding:0 3px}
 body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:calc(100dvh - 66px - env(safe-area-inset-bottom,0px))}
 html[data-native-chart=true] body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:100dvh}
 .zw-toolbar{flex-basis:40px;padding-inline:6px}.zw-chart-title{font-size:16px}
 body .chart-shell .ziwei-workspace .palace-title{font-size:12px}body .chart-shell .ziwei-workspace .palace-branch{font-size:10px}body .chart-shell .ziwei-workspace .palace-branch small{font-size:8px}
 body .chart-shell .ziwei-workspace .palace-card{padding:5px 3px;gap:2px}
 body .chart-shell .ziwei-workspace .palace-dynamic-panel{font-size:8px}
 body .chart-shell .ziwei-workspace .palace-triad{font-size:7px}
 .zw-command-bar{flex-basis:40px;padding-inline:6px;gap:6px}.zw-command-bar>button{font-size:11px}
 .zw-selection{bottom:4%;left:4%;right:4%}.zw-selection-head{gap:3px}.zw-selection-head strong{font-size:11px}.zw-selection-head button{font-size:9px}.zw-four-options button{font-size:9px;padding:4px 2px;min-height:44px}.zw-four-options small{font-size:7px}
 .zw-center-relation{inset:9% 3% auto;gap:4px}.zw-center-relation strong{font-size:14px}.zw-center-relation span{font-size:10px}.zw-center-relation small,.zw-center-relation b{font-size:9px}
}
@media(prefers-reduced-motion:reduce){.zw-relation-path{stroke-dasharray:none}}
/* Star columns stay grouped at the upper left; dense columns may wrap, never scroll. */
body .chart-shell .ziwei-workspace .palace-star-columns{display:flex;flex-wrap:wrap;gap:2px;align-content:flex-start;align-items:flex-start;justify-content:flex-start;overflow:visible}
body .chart-shell .ziwei-workspace .ziwei-star-column{width:1em;min-width:1em;max-width:1em;flex:0 0 1em;font-size:clamp(8px,calc((100vw - 32px)/4/var(--zw-count,8) - 2px),14px)}
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{width:1em;min-width:1em;max-width:1em;flex:0 0 1em}
@media(min-width:801px){body .chart-shell .ziwei-workspace .ziwei-star-column{font-size:16px}body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-size:18px}}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column,
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column.major-star{font-size:clamp(8px,calc((100vw - 32px)/4/var(--zw-count,8) - 2.2px),14px)}
}

/* Reading modes share one geometry and one snapshot. */
.zw-toolbar [hidden]{display:none!important}.zw-toolbar [data-zw-reset]{margin-left:auto;font-size:11px}
.zw-toolbar-tools{display:flex;align-items:center;gap:12px;margin-left:auto}
.zw-help{font:14px/1.7 var(--serif);color:var(--ink)}.zw-help h3{margin:0 0 10px;font-weight:500}.zw-help p{margin:0 0 12px}.zw-help details{padding-block:10px;border-top:1px solid var(--line)}.zw-help summary{cursor:pointer;color:var(--accent)}.zw-help details[open]>summary{margin-bottom:10px}
.zw-star-toggle{display:flex;align-items:center;gap:4px;color:var(--muted);font:11px var(--serif);white-space:nowrap;cursor:pointer}
.zw-star-toggle input{width:13px;height:13px;margin:0;accent-color:#89654b}
.zw-modes{display:flex;border:1px solid #b9b19f;border-radius:3px;overflow:hidden;flex-shrink:0}
.zw-modes button{padding:6px 14px;border:0;border-right:1px solid #d5cdbf;background:none;font:13px var(--serif);color:var(--muted);cursor:pointer;min-height:30px}
.zw-modes button:last-child{border-right:0}.zw-modes button[aria-pressed=true]{background:#8b6b52;color:#faf9f3}
.zw-command-bar{gap:6px}
body .chart-shell .ziwei-workspace .zw-privacy{position:absolute;right:7px;top:6px;z-index:8;background:none;border:0;color:var(--muted);font:10px var(--serif);padding:6px 0;cursor:pointer}
.ziwei-workspace .ziwei-plate:not(.zw-periods-open) .zw-query-source{display:none!important}
.ziwei-workspace .zw-query-source .chart-query-time{display:flex;align-items:center;flex-wrap:wrap;font-size:11px}
.ziwei-workspace .zw-query-source .chart-query-time input{font-size:12px;min-height:30px}
.ziwei-workspace .zw-query-source .chart-query-time button{font-size:11px;padding:4px 6px}
.ziwei-workspace .zw-query-source .chart-basis-summary{display:none}
.zw-selection-head strong small{display:block;font:9px var(--serif);color:var(--muted);margin-top:3px}
.zw-triad-key{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 10px;font:11px var(--serif)}
.zw-triad-key span{display:grid;gap:2px}.zw-triad-key small{color:var(--muted);font-size:9px}
.zw-four-options b{color:var(--mutagen-color,var(--accent))}
.zw-all-four{background:none;border:0;border-bottom:1px solid var(--line);font:10px var(--serif);padding:4px 0;color:var(--accent);float:right;cursor:pointer}
.zw-triad-path{fill:none;stroke:#958c79;stroke-width:1;stroke-dasharray:5 5;vector-effect:non-scaling-stroke}.zw-opposite-path{stroke-dasharray:3 5}
.zw-relation-path{stroke-width:1.2;stroke-dasharray:none}
.zw-flight-code{display:block;position:static;flex-shrink:0;align-self:center;font:500 10px/1 var(--serif);color:var(--flight-color);margin-top:2px;min-height:10px;letter-spacing:0}
.ziwei-workspace[data-ziwei-mode=flying] .ziwei-star-column>small,.ziwei-workspace[data-ziwei-mode=sihua] .ziwei-star-column>small{display:none}
.ziwei-workspace[data-ziwei-mode=sihua] .ziwei-star-column>b{color:var(--ink)}
.ziwei-workspace:not([data-ziwei-mode=sanhe]) .palace-triad{display:none!important}

@media(max-width:800px){.zw-modes button{padding:5px 10px;font-size:12px;min-height:29px}.zw-star-toggle{font-size:10px;gap:3px}.zw-selection{bottom:5%}.zw-triad-key{font-size:10px;gap:5px}.zw-selection-head strong small{font-size:8px}.zw-mutagen-marks>b{font-size:19px}.zw-mutagen-marks{left:4px}.zw-privacy{font-size:9px!important}}

.zw-triad-key span{background:var(--desk,#eeece4)}

/* Selected palace flying transformations color the stars, distinct from natal/scope stamps. */
body .chart-shell .ziwei-workspace .ziwei-star-column.zw-flight-star>b{color:var(--flight-color)!important;background:color-mix(in srgb,var(--flight-color) 9%,transparent);border-radius:1px}
body .chart-shell .ziwei-workspace .ziwei-star-column.zw-flight-focused>b{outline:1px solid var(--flight-color);outline-offset:1px}
body .chart-shell .ziwei-workspace[data-ziwei-mode=flying] .zw-has-selection .ziwei-star-column:not(.zw-flight-star)>b{color:var(--ink)}

/* Fine flight guides and independent directional edge marks. */
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{box-sizing:border-box;padding:8px}
.zw-relation-path{stroke-width:.75;stroke-dasharray:3 4;opacity:.65;stroke-linecap:round}
.zw-self-arrow{fill:none;stroke-width:1.35;stroke-linecap:round;vector-effect:non-scaling-stroke;pointer-events:stroke}
.zw-self-key{position:absolute;left:6px;right:6px;bottom:8px;display:flex;justify-content:center;gap:10px;font:9px/1.3 var(--serif);color:var(--muted);background:var(--desk,#eeece4);z-index:5}
.zw-self-key i{font:13px var(--serif);color:var(--ink);font-style:normal}.zw-self-key b{font-weight:400}
.zw-has-selection .zw-self-key{display:none}
@media(min-width:801px){.zw-self-key{font-size:11px;gap:18px}.zw-self-key i{font-size:15px}}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace .palace-star-columns{gap:1px}
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column,
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column.major-star{font-size:clamp(8px,calc((100vw - 48px)/4/var(--zw-count,8) - 2.2px),14px)}
}
/* Vertical and horizontal scales differ; reserve edge room in both axes. */
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding:max(12px,2dvh) max(8px,1.6dvw)}
@media(max-width:800px){.ziwei-workspace .ziwei-plate.zw-periods-open .zw-period-panel{max-height:20dvh}}

/* No selection panels or extra palace frames over the relationship drawing. */
body .chart-shell .ziwei-workspace .zw-selection{position:static;display:flex;justify-content:center;gap:9px;background:none;padding:0;width:100%;margin:8px 0 0;z-index:6}
body .chart-shell .ziwei-workspace .zw-selection[hidden]{display:none}
.zw-selection>button{font:10px var(--serif);color:var(--muted);background:none;border:0;padding:5px 0;cursor:pointer}
body .chart-shell .ziwei-workspace .palace-card{box-shadow:none!important;outline:none;background:transparent}
body .chart-shell .ziwei-workspace .palace-card.is-selected{box-shadow:none!important;outline:none;background:#e4dccb}
body .chart-shell .ziwei-workspace .palace-card:focus-visible{outline:1px dotted var(--accent);outline-offset:-3px}
body .chart-shell .ziwei-workspace .palace-card:focus:not(:focus-visible){outline:none}
.zw-relation-path{pointer-events:stroke;cursor:pointer}
body .chart-shell .ziwei-workspace .ziwei-time-options{overflow-x:auto;overflow-y:hidden;touch-action:pan-x;overscroll-behavior-x:contain;scrollbar-width:none;cursor:grab;user-select:none;min-width:0}
.ziwei-workspace .ziwei-time-options::-webkit-scrollbar{display:none}
.ziwei-workspace .ziwei-time-options.is-dragging{cursor:grabbing}
.ziwei-workspace .ziwei-time-options button{flex-shrink:0;touch-action:pan-x}
body .chart-shell .ziwei-workspace .ziwei-time-options button:focus:not(:focus-visible){outline:none}

/* Birth facts keep a narrow, quiet column; the full comparison opens on demand. */
body .chart-shell .ziwei-workspace .palace-center{padding:30px 12px 10px;gap:8px;justify-content:center}
body .chart-shell .ziwei-workspace .palace-center>strong{font:500 21px/1.45 var(--serif);max-width:100%;overflow-wrap:anywhere;display:block;padding-block:2px 4px;overflow:visible;flex-shrink:0}
body .chart-shell .ziwei-workspace .center-facts.zw-birth-summary{display:block;width:max-content;max-width:100%;margin:0;font:12px/1.5 var(--serif);text-align:left}
.zw-self-key{position:static;flex-shrink:0;margin-top:5px;background:none}
.zw-birth-summary p,.zw-birth-detail p{margin:0}
.zw-identity{text-align:center;color:var(--muted);margin-bottom:10px!important}
.zw-identity>small{display:block;font:9px/1.5 var(--serif);margin-top:2px;color:var(--accent)}
body .chart-shell .ziwei-workspace .palace-center>.ziwei-transformations{display:none}
.zw-natal-changes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 10px;margin-top:8px;font:9px/1.4 var(--serif);color:var(--muted)}
.zw-natal-changes i{font-style:normal;margin-right:4px}
.zw-clock-pair{margin:0;display:grid;gap:4px;font-variant-numeric:tabular-nums}
.zw-clock-pair>div{display:grid;grid-template-columns:76px minmax(0,1fr);gap:10px;align-items:baseline}
.zw-clock-pair dt{color:var(--muted);white-space:nowrap;font-size:11px}
.zw-clock-pair dt i{font-style:normal;font-size:8px;margin-left:4px;color:var(--accent)}
.zw-clock-pair dd{margin:0;font-size:12px;white-space:nowrap}
.zw-clock-pair .is-used dd{color:var(--ink)}
.zw-lunar{font-size:11px;color:var(--muted);margin-top:6px!important}
.zw-pillar-group{margin:12px 0 10px}
.zw-pillar-group>small{display:block;color:var(--muted);font-size:10px;margin-bottom:4px}
.zw-pillars{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.zw-pillars>div{display:grid;justify-items:center;gap:2px}
.zw-pillars small{font:10px/1.2 var(--serif);color:var(--muted);margin-bottom:2px}
.zw-pillars b{font:500 22px/1.1 var(--serif)}
.zw-masters{display:flex;justify-content:space-between;gap:10px;font-size:11px}
.zw-bazi-start{display:grid;gap:2px;font-size:11px;margin-top:10px;color:var(--muted)}
.zw-bazi-start>small{font-size:10px;color:var(--accent)}
.zw-birth-tools{margin:0;z-index:6;flex-shrink:0}
.zw-birth-tools[hidden]{display:none!important}
.zw-birth-tools button{display:inline-flex;align-items:center;min-height:0;height:auto;border:0;background:none;color:var(--accent);font:11px/1.3 var(--serif);padding:3px 0;cursor:pointer}
.zw-birth-tools button span{margin-left:9px;font-size:15px}
.zw-has-selection .zw-birth-tools{display:none;pointer-events:none}
.zw-private .zw-birth-summary{visibility:hidden}
.zw-birth-dialog{box-sizing:border-box;width:min(540px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:0;border:1px solid var(--line,#cfc8b9);border-radius:3px;background:var(--desk,#eeece4);color:var(--ink,#303229);font:14px/1.5 var(--serif,serif);overflow:hidden}
.zw-birth-dialog::backdrop{background:rgb(35 34 29 / .32)}
.zw-birth-dialog[open]{display:flex;flex-direction:column}
.zw-birth-dialog>header{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:15px 22px;border-bottom:1px solid var(--line,#cfc8b9);flex-shrink:0}
.zw-birth-dialog h2{font:500 19px/1.4 var(--serif,serif);margin:0;flex:1;white-space:nowrap}
.zw-birth-dialog header button{width:30px;min-width:30px;min-height:32px;flex:0 0 30px;background:none;border:0;padding:0;color:var(--muted,#777365);font-size:25px;cursor:pointer}
.zw-birth-dialog-body{overflow:auto;padding:18px 22px 24px;overscroll-behavior:contain}
.zw-birth-detail .zw-identity{text-align:left}
.zw-birth-detail .zw-clock-pair{gap:6px}
.zw-birth-detail .zw-clock-pair dt,.zw-birth-detail .zw-clock-pair dd{font-size:13px}
.zw-birth-detail .zw-pillar-group{margin:20px 0}
.zw-birth-detail .zw-pillars b{font-size:25px}
.zw-birth-detail .zw-masters{font-size:12px}
.zw-birth-detail .zw-bazi-start{font-size:13px;margin-top:20px}
.zw-bazi-cycles h3{font:500 15px/1.5 var(--serif);margin:20px 0 10px}
.zw-cycle-list{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(78px,1fr);overflow-x:auto;overscroll-behavior-x:contain;border-top:1px solid var(--line,#cfc8b9)}
.zw-cycle-list>div{display:grid;gap:2px;justify-items:center;align-content:start;padding:12px 3px;border-bottom:1px solid var(--line,#cfc8b9)}
.zw-cycle-list strong{font-size:18px;font-weight:500;writing-mode:vertical-rl;letter-spacing:3px}
.zw-cycle-list span{font-size:11px}.zw-cycle-list small{font-size:10px;color:var(--muted,#777365)}
.zw-reference-missing{margin-top:18px!important;color:var(--muted);font-size:12px}
.zw-center-no-start .zw-start-preview{display:none}
.zw-center-compact .zw-birth-summary .zw-natal-changes,.zw-center-compact .zw-birth-summary .zw-lunar,.zw-center-compact .zw-birth-summary .zw-clock-pair>div:not(.is-used){display:none}
.zw-center-tight .zw-birth-summary .zw-pillar-group{display:none}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace .palace-center{padding:26px 7px 10px;gap:4px}
 body .chart-shell .ziwei-workspace .palace-center>strong{font-size:16px}
 body .chart-shell .ziwei-workspace .center-facts.zw-birth-summary{font-size:10px}
 .zw-birth-summary .zw-identity{margin-bottom:6px!important;font-size:9px;line-height:1.4}
 .zw-birth-summary .zw-identity>small{display:inline;font-size:9px;margin:0}
 .zw-birth-summary .zw-identity>small::before{content:' · ';color:var(--muted)}
 .zw-birth-summary .zw-clock-pair{gap:3px}
 .zw-birth-summary .zw-clock-pair>div{grid-template-columns:46px minmax(0,1fr);gap:3px}
 .zw-birth-summary .zw-clock-pair dt{font-size:9px;position:relative}
 .zw-birth-summary .zw-clock-pair dt i{position:absolute;left:0;bottom:100%;font-size:7px;margin:0;display:none}
 .zw-birth-summary .zw-clock-pair .is-used dt{color:var(--accent)}
 .zw-birth-summary .zw-clock-pair dd{font-size:9px}
 .zw-birth-summary .zw-lunar{font-size:9px;margin-top:5px!important}
 .zw-birth-summary .zw-pillar-group{margin:4px 0}
 .zw-birth-summary .zw-pillars{gap:6px}.zw-birth-summary .zw-pillars>div{gap:0}.zw-birth-summary .zw-pillars b{font-size:18px}
 .zw-birth-summary .zw-pillar-group>small,.zw-birth-summary .zw-pillars small{font-size:8px}
 .zw-birth-summary .zw-masters{font-size:9px;gap:8px}
 .zw-birth-summary .zw-natal-changes{font-size:8px;gap:1px 8px;margin-top:6px}
 .zw-start-preview{display:none}
 .zw-birth-tools button{font-size:10px;padding:2px 0}
 .zw-birth-tools button span{font-size:12px}
 .zw-self-key{margin-top:2px}
 .zw-birth-dialog{width:calc(100vw - 24px);max-height:calc(100dvh - 32px)}
 .zw-birth-dialog>header{padding:12px 18px}.zw-birth-dialog-body{padding:16px 18px 20px}
}
@media(max-height:760px) and (min-width:801px){.zw-start-preview{display:none}}
@media(max-height:720px) and (max-width:800px){
 body .chart-shell .ziwei-workspace .palace-center{padding-block:26px 10px;gap:3px}
 .zw-birth-summary .zw-pillar-group{margin:5px 0}.zw-birth-summary .zw-pillars b{font-size:16px}
}

/* Date jumping is deliberate; the time ruler remains the primary navigation. */
.zw-date-tools{display:flex;align-items:center;gap:10px;padding:0 8px;min-height:40px;border-top:1px solid var(--line)}
.zw-date-tools>span{font:11px var(--serif);color:var(--muted);font-variant-numeric:tabular-nums}
.zw-date-tools .zw-date-label{color:var(--accent);white-space:nowrap}
.zw-date-tools .zw-date-value{margin-right:auto}
.zw-date-tools button{border:0;background:none;color:var(--accent);font:12px var(--serif);padding:10px 0;cursor:pointer}
.ziwei-plate:not(.zw-periods-open) .zw-date-tools{display:none}
.zw-date-dialog .zw-query-source{display:block!important;padding:0;margin:0;border:0;background:none}
.zw-date-dialog .chart-plate-tools,.zw-date-dialog [data-query-step]{display:none!important}
.zw-date-dialog .chart-query-time{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:18px 12px;font:13px var(--serif);align-items:end}
.zw-date-dialog .chart-query-time label{display:grid;gap:6px;min-width:0}
.zw-date-dialog .chart-query-time input{width:100%;max-width:none;min-width:0;min-height:44px;box-sizing:border-box;font:15px var(--serif);color:var(--ink);background:transparent;border:0;border-bottom:1px solid var(--line);border-radius:0;padding:5px 0}
.zw-date-dialog .chart-query-time button{width:auto;min-width:0;min-height:42px;padding:7px 12px;font:14px var(--serif);cursor:pointer}
.zw-date-dialog .chart-query-time [data-query-today]{background:none;border:0;color:var(--accent)}
.zw-date-feedback{margin:16px 0 0;color:var(--accent);font:12px/1.5 var(--serif)}.zw-date-feedback[hidden]{display:none}
.zw-relation-dialog{width:min(390px,calc(100vw - 24px))}
.zw-relation-dialog .zw-birth-dialog-body{font:15px/1.8 var(--serif);padding-block:22px}
/* A thin visible guide with a wider, invisible interactive stroke. */
.zw-flight-hit,.zw-self-hit{fill:none;stroke:transparent;stroke-width:18px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}
.zw-flight-hit{clip-path:polygon(25.5% 25.5%,74.5% 25.5%,74.5% 74.5%,25.5% 74.5%)}
.zw-self-hit{stroke-width:18px}
.zw-self-arrow{pointer-events:none}
.zw-flight-hit:focus-visible,.zw-self-hit:focus-visible{stroke:rgb(140 100 70 / .12);outline:none}
/* Keep fine labels, but give controls enough room for a fingertip. */
.zw-selection>button{min-width:40px;min-height:40px;padding:8px 0}
.zw-selection>button:first-child{min-width:56px}
body .chart-shell .ziwei-workspace .zw-selection{gap:2px}
body .chart-shell .ziwei-workspace .zw-privacy{min-height:40px;min-width:56px;padding:8px 0;top:0}
.zw-birth-tools button{position:relative}
.zw-birth-tools button::before{content:'';position:absolute;inset:-10px -8px}
.zw-birth-dialog header button{min-height:40px;min-width:40px;flex-basis:40px}
@media(max-width:800px){
 .zw-modes button{min-height:38px}
 .zw-star-toggle,.zw-command-bar>button{min-height:40px}
 .zw-date-tools{gap:8px;padding-inline:6px}
 .zw-date-tools>span{font-size:10px}
 .zw-date-tools button{font-size:11px;min-height:40px}
 .zw-birth-dialog{width:calc(100vw - 20px);border-radius:12px 12px 0 0;margin: auto auto 0;max-height:calc(100dvh - 40px)}
 .zw-date-dialog,.zw-relation-dialog{margin:auto;border-radius:4px}
}
/* Desktop and tablets use their available width for legible annotation. */
@media(min-width:801px) and (min-height:600px){
 body .chart-shell .ziwei-workspace .palace-card{padding-block:4px;row-gap:1px}
 body .chart-shell .ziwei-workspace .palace-title{font-size:15px}
 body .chart-shell .ziwei-workspace .palace-branch small{font-size:11px}
 body .chart-shell .ziwei-workspace .palace-dynamic-panel{font-size:11px}
 body .chart-shell .ziwei-workspace .palace-triad{font-size:10px}
 .ziwei-workspace .zw-navigation .ziwei-time-options button small{font-size:11px}
}
@media(min-width:600px) and (max-width:800px) and (min-height:600px){
 body .chart-shell .ziwei-workspace .palace-title{font-size:14px}
 body .chart-shell .ziwei-workspace .palace-branch small{font-size:10px}
 body .chart-shell .ziwei-workspace .palace-dynamic-panel{font-size:10px}
 body .chart-shell .ziwei-workspace .palace-triad{font-size:9px}
}
@media(min-width:760px) and (max-width:800px){
 body.zw-focus-page[data-global-page]{padding-left:0;padding-bottom:calc(66px + env(safe-area-inset-bottom,0px))}
 body.zw-focus-page .global-navigation{inset:auto 0 0;width:auto;height:auto;min-height:calc(66px + env(safe-area-inset-bottom,0px));padding:0 8px env(safe-area-inset-bottom,0px);border-right:0;border-top:1px solid #d5cdbd;gap:0;flex-direction:row}
 body.zw-focus-page .global-navigation a{flex:1;justify-content:center;min-width:0;min-height:65px;padding-left:0}
 body.zw-focus-page .global-navigation a[aria-current]{background:none;border-left:0;box-shadow:inset 0 2px #93543b}
}
/* The mode control sits within its own breathing room, below the ruler line. */
.zw-command-bar{box-sizing:border-box;flex:0 0 54px;min-height:54px;padding:6px 8px;border-bottom:0}
.zw-modes{align-self:center}
body .chart-shell .ziwei-workspace .ziwei-star-column>.zw-flight-code{position:static;display:block;font:500 10px/1 var(--serif);margin:2px 0 0;min-height:10px;letter-spacing:0;transform:none}
/* Scope stamps stay within the carrier's column, including dense full-star views. */
body .chart-shell .ziwei-workspace .ziwei-star-column>.scope-mutagen{writing-mode:vertical-rl;text-orientation:upright;white-space:nowrap;font-size:7px;line-height:1;margin-top:2px;max-width:1em;flex-shrink:0}
body .chart-shell .ziwei-workspace .ziwei-star-column>em{box-sizing:border-box;font-size:min(9px,1em);line-height:1.1;padding:0;width:1em;max-width:1em;min-width:0;flex-shrink:0;text-align:center}
/* One scrolling board, with the ruler and reading controls in reserved space. */
body.zw-focus-page{height:100dvh;overflow:hidden}
body.zw-focus-page .chart-shell.chart-workbench{position:relative!important;inset:auto!important;height:auto!important;min-height:0;overflow:hidden!important}
body.zw-focus-page .chart-shell.chart-workbench .chart-layout{height:100%;margin:0;overflow:hidden}
body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:100dvh!important;min-height:0;overflow:hidden}
body .chart-shell #result-content.ziwei-workspace .ziwei-plate{flex:1;min-height:0;overflow:hidden!important}
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{flex:1 1 0;min-height:0;height:auto;overflow-x:hidden;overflow-y:auto;overscroll-behavior-y:contain;scrollbar-width:thin;scrollbar-color:#c8c0af transparent}
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport.is-zoomed{overflow:hidden}
body .chart-shell #result-content.ziwei-workspace .palace-grid{height:100%;min-height:var(--zw-board-content-height,540px)}
body .chart-shell .ziwei-workspace .palace-star-columns{grid-template-columns:repeat(auto-fit,minmax(18px,1fr));gap:4px 2px}
body .chart-shell .ziwei-workspace .ziwei-star-column{font-size:17px}
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-size:20px}
body .chart-shell .ziwei-workspace .ziwei-star-column>.scope-mutagen{font-size:11px;line-height:1.05;margin-top:4px;color:var(--accent)}
body .chart-shell .ziwei-workspace .ziwei-star-column>em{font-size:11px}
body .chart-shell .ziwei-workspace [data-ziwei-scope][hidden],body .chart-shell .ziwei-workspace [data-ziwei-scope-panel][hidden]{display:none!important}
body .chart-shell .ziwei-workspace .palace-dynamic-panel{font-size:11px}
body .chart-shell .ziwei-workspace .palace-dynamic-panel:not(.is-current-scope) .dynamic-label{color:#827c6d}
body .chart-shell .ziwei-workspace .is-current-scope .dynamic-label{color:var(--accent);font-weight:600}
.zw-navigation .ziwei-time-row>[data-zw-scope]{flex:0 0 38px;align-self:stretch;padding:0 2px;background:none;border:0;border-right:1px solid var(--line);color:var(--muted);font:12px/1 var(--serif);cursor:pointer;min-width:0;white-space:nowrap;display:flex;align-items:center;justify-content:center}
.zw-navigation .ziwei-time-row>[data-zw-scope][aria-pressed=true]{color:var(--accent);font-weight:600;background:#e4dccb}
.zw-year-scope-wrap{position:relative;flex:0 0 38px;align-self:stretch;display:flex;border-right:1px solid var(--line);font:12px/1 var(--serif);color:var(--muted)}
.zw-year-scope-wrap::after{content:'⌄';position:absolute;right:1px;top:50%;transform:translateY(-50%);font-size:8px;pointer-events:none}
.zw-year-scope-wrap select{appearance:none;-webkit-appearance:none;width:100%;min-width:0;padding:0 7px 0 0;border:0;border-radius:0;background:transparent;color:inherit;font:inherit;cursor:pointer;text-align:center;text-align-last:center}
.zw-year-scope-wrap.is-current-scope{color:var(--accent);font-weight:600;background:#e4dccb}
@media(max-width:800px){.zw-year-scope-wrap{flex-basis:32px;font-size:11px}}
.ziwei-workspace .ziwei-plate.zw-periods-open .zw-period-panel{max-height:min(28dvh,240px);overflow:auto}
.zw-has-selection .zw-self-key{display:flex;position:absolute;left:6px;right:6px;bottom:10px;margin:0;pointer-events:none;white-space:nowrap}
.zw-has-selection .zw-key-self{display:none}
body .chart-shell .ziwei-workspace .zw-selection{top:40px;right:8px}
.zw-selection>button{font-size:12px}
.zw-ruler-row{position:relative;padding-right:12px}
.zw-ruler-more{position:absolute;right:0;top:0;bottom:0;width:12px;display:flex;align-items:center;justify-content:center;color:var(--muted);font:15px var(--serif);pointer-events:none}
.zw-ruler-more[hidden]{display:none}
@media(max-width:800px){
 body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:calc(100dvh - 66px - env(safe-area-inset-bottom,0px))!important}
 html[data-native-chart=true] body.zw-focus-page .chart-shell.chart-workbench .result-panel{height:100dvh!important}
 body .chart-shell .ziwei-workspace .palace-star-columns{grid-template-columns:repeat(auto-fit,minmax(14px,1fr));gap:3px 1px}
 body .chart-shell .ziwei-workspace .ziwei-star-column{font-size:13px}
 body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-size:15px}
 body .chart-shell .ziwei-workspace .ziwei-star-column>.scope-mutagen,body .chart-shell .ziwei-workspace .ziwei-star-column>em{font-size:9px}
 body .chart-shell .ziwei-workspace .palace-dynamic-panel{font-size:9px;line-height:1.25}
 body .chart-shell .ziwei-workspace .palace-branch small{font-size:9px}
 .zw-selection>button{font-size:10px}
 .zw-navigation .ziwei-time-row>[data-zw-scope]{flex-basis:32px;font-size:11px}
 .zw-has-selection .zw-self-key{font-size:9px;bottom:6px}
 .zw-command-bar{min-height:50px;flex-basis:50px;padding-block:5px}
}
/* Palace details share the same paper surface; wide screens gain two reading columns. */
.chart-dialog.zw-palace-dialog{box-sizing:border-box;width:min(760px,calc(100vw - 48px));max-width:760px;max-height:calc(100dvh - 48px);padding:0;border:1px solid var(--line,#cfc8b9);border-radius:4px;background:var(--desk,#eeece4);color:var(--ink,#303229);overflow:hidden}
.chart-dialog.zw-palace-dialog[open]{display:flex;flex-direction:column}
.zw-palace-dialog .dialog-heading{padding:14px 24px;margin:0;border-bottom:1px solid var(--line);flex-shrink:0;align-items:center}
.zw-palace-dialog .dialog-heading h2{font:500 20px/1.4 var(--serif);margin:0}
.zw-palace-dialog .dialog-heading button{min-width:40px;min-height:40px;font-size:26px;color:var(--muted);border:0;background:none}
.chart-dialog.zw-palace-dialog .dialog-content{padding:20px 24px 24px;max-height:none;overflow:auto;overscroll-behavior:contain;font:14px/1.6 var(--serif)}
.zw-reading-columns{display:grid;grid-template-columns:1fr 1fr;gap:28px}
.zw-palace-reading h3{font:500 15px/1.5 var(--serif);margin:0 0 14px}
.zw-palace-reading h3 small{display:block;font-size:11px;font-weight:400;color:var(--muted);margin-top:4px}
.zw-palace-reading h4{font-size:13px;font-weight:500;margin:16px 0 6px}
.zw-palace-reading section{min-width:0}
.zw-palace-reading .fact-list{margin:0}
.zw-palace-reading details{margin-top:14px;border-top:1px solid var(--line);padding-top:6px}
.zw-palace-reading summary{color:var(--muted);cursor:pointer;padding:8px 0;font-size:12px}
.zw-palace-reading .palace-star-group{margin-bottom:14px}
.zw-reading-flights{margin-top:24px;padding-top:20px;border-top:1px solid var(--line)}
.zw-reading-relation{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:16px;align-items:center;padding:10px 0;border-top:1px solid var(--line);font-size:14px}
.zw-reading-relation span>b{font-weight:500;margin-right:5px}
.zw-reading-relation small{display:block;font-size:11px;color:var(--muted);margin-top:3px}
.zw-reading-relation button,.zw-reading-return{background:none;border:0;color:var(--accent);font:12px var(--serif);padding:10px 0;min-height:40px;cursor:pointer}
.zw-reading-return{margin:0 0 16px}
.zw-reading-surroundings p{font-size:13px}
@media(max-width:800px){
 .chart-dialog.zw-palace-dialog{inset:auto 0 0;margin:auto auto 0;width:calc(100vw - 20px);max-height:calc(100dvh - 40px);border-radius:12px 12px 0 0}
 .zw-palace-dialog .dialog-heading{padding:10px 18px}
 .chart-dialog.zw-palace-dialog .dialog-content{padding:18px}
 .zw-reading-columns{grid-template-columns:1fr;gap:20px}
 .zw-reading-scope{border-top:1px solid var(--line);padding-top:18px}
 .zw-reading-relation{gap:12px;font-size:13px}
}
.zw-palace-reading .chart-facts{margin:0;font-size:13px}
.zw-palace-reading .chart-facts>div{display:grid;grid-template-columns:64px minmax(0,1fr);gap:12px;border:0;padding:6px 0}
.zw-palace-reading .chart-facts dd{min-width:0;overflow-wrap:anywhere}
/* Keep the selected layer's stamp together beneath its carrier star. */
body .chart-shell .ziwei-workspace .palace-star-columns{grid-template-columns:repeat(auto-fit,minmax(22px,1fr))}
body .chart-shell .ziwei-workspace .ziwei-star-column>.scope-mutagen{writing-mode:horizontal-tb;text-orientation:mixed;white-space:nowrap;width:auto;max-width:none;line-height:1.1}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace .palace-star-columns{grid-template-columns:repeat(auto-fit,minmax(18px,1fr))}
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column{font-size:13px}
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column.major-star{font-size:15px}
}
/* Equal compact ruler tracks; reserve space for the board, including iOS webviews. */
body.zw-focus-page{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button{box-sizing:border-box;height:36px;min-height:36px;padding:3px 4px;grid-template-rows:15px 12px;align-content:center;gap:1px;white-space:nowrap;line-height:15px}
body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button small{font-size:10px;line-height:12px}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button{height:32px;min-height:32px;padding-block:1px}
 body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding:9px 6px}
}

/* Give the reading controls a balanced shelf, without boxing in the modes. */
body .chart-shell .ziwei-workspace .zw-command-bar{flex:0 0 48px;min-height:48px;padding:4px 8px;gap:8px}
body .chart-shell .ziwei-workspace .zw-modes{border:0;border-radius:0;overflow:visible;gap:4px}
body .chart-shell .ziwei-workspace .zw-modes button{position:relative;border:0;background:none;color:var(--muted);padding:5px 14px;min-height:34px;line-height:1.4;white-space:nowrap}
body .chart-shell .ziwei-workspace .zw-modes button[aria-pressed=true]{color:var(--accent);background:#e4dccb}
body .chart-shell .ziwei-workspace .zw-modes button[aria-pressed=true]::after{content:none}
@media(max-width:800px){body .chart-shell .ziwei-workspace .zw-command-bar{flex-basis:46px;min-height:46px;padding-block:3px}.zw-date-tools{gap:8px;padding-inline:6px}.zw-date-tools button{font-size:11px;min-height:36px;padding-block:8px}}
@media(max-width:380px){body .chart-shell .ziwei-workspace .zw-command-bar{padding-inline:4px;gap:4px}body .chart-shell .ziwei-workspace .zw-modes{gap:0}body .chart-shell .ziwei-workspace .zw-modes button{padding-inline:10px}}

/* The selected-palace action stays in the center flow; it must not float over
   the birth facts or make the relationship state appear in another section. */
body .chart-shell .ziwei-workspace .zw-selection{position:static;inset:auto!important;right:auto!important;bottom:auto!important;left:auto!important}

/* The toolbar already has hierarchy from its whitespace and title; keep the navigation divider below it. */
body .chart-shell .ziwei-workspace .zw-toolbar{border-bottom:0}

/* Short mobile viewports reserve the full board before the optional detail layers. */
@media(max-width:800px) and (max-height:740px){
 body .chart-shell .ziwei-workspace .palace-card{padding-block:3px;row-gap:1px}
 body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding-block:4px}
 body .chart-shell .ziwei-workspace .zw-command-bar{flex-basis:40px;min-height:40px;padding-block:0}
}

/* Edge arrows extend outside the palace grid; their gutter belongs to the board. */
body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding:clamp(14px,2.5dvh,22px) 13px}
@media(max-width:800px) and (max-height:740px){
 body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding-block:14px}
 body .chart-shell .ziwei-workspace .palace-card{padding-block:1px;row-gap:0}
}

/* Report-style palace footer: one line for identity, one for stem and age. */
body .chart-shell .ziwei-workspace .palace-card{grid-template-areas:'stars stars' 'layers layers' 'triad triad' 'branch branch' 'title title';grid-template-rows:minmax(0,1fr) auto auto auto auto}
body .chart-shell .ziwei-workspace[data-ziwei-density=basic] .palace-card{grid-template-areas:'stars stars' 'layers layers' 'branch branch' 'title title';grid-template-rows:minmax(0,1fr) auto auto auto}
body .chart-shell .ziwei-workspace .palace-title{white-space:nowrap;min-width:0;justify-content:space-between}
body .chart-shell .ziwei-workspace .palace-title b{white-space:nowrap}
body .chart-shell .ziwei-workspace .palace-branch{display:flex;justify-content:space-between;align-items:baseline;gap:2px;white-space:nowrap}
body .chart-shell .ziwei-workspace .zw-navigation{border-top:1px solid var(--line)}
@media(max-width:800px){
 body.zw-focus-page .chart-shell.chart-workbench{padding-inline:0!important}
 body .chart-shell .ziwei-workspace .zw-navigation{margin-inline:0;width:100%;box-sizing:border-box}
}

@media(max-width:800px){
 body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding-inline:11px}
 body .chart-shell .ziwei-workspace .zw-navigation{padding-inline:0;margin-inline:0;border-left:0;border-right:0}
}

/* All star families share the secondary-star size; legends keep semantic groups intact. */
body .chart-shell .ziwei-workspace .ziwei-star-column,
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{font-size:17px}
body .chart-shell .ziwei-workspace .zw-self-key{flex-wrap:wrap;gap:3px 8px;align-items:center}
body .chart-shell .ziwei-workspace .zw-self-key>span{flex:none;white-space:nowrap}
body .chart-shell .ziwei-workspace .zw-self-key i{font-size:11px;white-space:nowrap}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column,
 body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column.major-star{font-size:13px}
 body .chart-shell .ziwei-workspace .palace-star-columns{gap:2px 1px}
 body .chart-shell #result-content.ziwei-workspace .ziwei-viewport{padding-inline:10px}
}

body .chart-shell .ziwei-workspace .palace-star-columns{display:grid;grid-auto-flow:row dense;grid-auto-rows:1px;grid-template-columns:repeat(auto-fit,minmax(17px,1fr));gap:0 1px;align-self:start}
body .chart-shell .ziwei-workspace .ziwei-star-column{align-self:start;justify-self:start}
body .chart-shell .ziwei-workspace .ziwei-star-column>small[hidden]{display:none}
@media(max-width:800px){body .chart-shell .ziwei-workspace .palace-star-columns{grid-template-columns:repeat(auto-fit,minmax(13px,1fr))}}

body .chart-shell .ziwei-workspace .palace-star-columns{column-gap:0}
body .chart-shell .ziwei-workspace .ziwei-star-column,
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star{width:max-content;max-width:none}

/* One top-aligned band of star columns; a common size follows the densest palace. */
body .chart-shell .ziwei-workspace .palace-star-columns{display:grid;grid-auto-flow:row;grid-auto-rows:auto;gap:0;align-content:start}
body .chart-shell .ziwei-workspace .ziwei-star-column,
body .chart-shell .ziwei-workspace .ziwei-star-column.major-star,
body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column,
body .chart-shell .ziwei-workspace[data-ziwei-density] .ziwei-star-column.major-star{font-size:var(--zw-uniform-star-size,11px);width:auto;min-width:0;max-width:100%;justify-self:start}
body .chart-shell .ziwei-workspace .ziwei-star-column>.scope-mutagen{writing-mode:vertical-rl;text-orientation:upright;white-space:nowrap;font-size:8px;line-height:1.05;width:1em;max-width:1em;margin-top:2px}
body .chart-shell .ziwei-workspace .ziwei-star-column>small{font-size:8px;line-height:1.1;margin-top:2px}
body .chart-shell .ziwei-workspace .ziwei-star-column>em{font-size:8px;line-height:1.1;margin-top:2px}

@media(max-width:800px){body .chart-shell .ziwei-workspace .palace-card{padding-inline:1px}}

/* Sparse palaces retain the same tight column rhythm as dense palaces. */
body .chart-shell .ziwei-workspace .palace-star-columns{justify-content:start;column-gap:.5px}

/* Selected periods use the paper tint and ink, without a second underline. */
body .chart-shell .ziwei-workspace .ziwei-time-options button[aria-pressed=true]{background:#e4dccb;color:var(--accent);box-shadow:none}
body .chart-shell .ziwei-workspace .ziwei-time-options button[aria-pressed=true] small{color:var(--accent)}

/* The ruler stays in one table; the global navigation owns the closing rule. */
body .chart-shell .ziwei-workspace .zw-navigation{border-bottom:0;--line:#d6d1c5}
body .chart-shell .ziwei-workspace .zw-navigation .ziwei-timeline{border:0}
body .chart-shell .ziwei-workspace .zw-navigation .zw-period-panel,
body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .zw-period-panel{max-height:none;overflow:visible}
body .chart-shell .ziwei-workspace .ziwei-fine-time>summary{display:none}
body .chart-shell .ziwei-workspace .zw-date-tools{border-top:0;border-bottom:0;min-height:28px}
body .chart-shell .ziwei-workspace .zw-date-tools button{min-height:28px;padding-block:3px}
body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button{flex-basis:60px;min-width:max-content;padding-inline:3px}
body .chart-shell .ziwei-workspace .zw-navigation [data-time-row=years] button{padding-inline:2px}
body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button>span{white-space:nowrap}
body .chart-shell .ziwei-workspace .ziwei-plate:not(.zw-periods-open) .ziwei-timeline>.ziwei-time-row:last-of-type{border-bottom:0}
@media(max-width:800px){
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-card{padding-block:1px;row-gap:0}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .ziwei-viewport{padding-block:12px}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .zw-command-bar{flex-basis:40px;min-height:40px;padding-block:0}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .ziwei-time-options button{height:28px;min-height:28px;padding-block:0}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .zw-date-tools{min-height:22px;gap:6px}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .zw-date-tools button{min-height:22px;padding-block:2px}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .zw-date-tools>span{font-size:9px}
}
@media(max-width:800px){
 body .chart-shell #result-content.ziwei-workspace .ziwei-plate.zw-periods-open .ziwei-viewport{padding-block:12px}
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-title,
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-branch,
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-branch small,
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-dynamic-panel,
 body .chart-shell .ziwei-workspace .ziwei-plate.zw-periods-open .palace-triad{line-height:1;min-height:0}
}
/* Expanded controls also use the available desktop height before adding scroll. */
body .chart-shell #result-content.ziwei-workspace .ziwei-plate.zw-periods-open .ziwei-viewport{padding-block:12px}

@media(max-width:800px){body .chart-shell .ziwei-workspace .zw-navigation .ziwei-time-options button{flex-basis:50px}}
