body {
            background-color: #FFFFFF; /* 改為純白 */
            font-family: 'PingFang TC', 'Microsoft JhengHei', sans-serif;
            overflow-x: hidden;
            color: #4A4542; 
        }

        /* 畫布模式防選取 */
        body.teaching-mode {
            user-select: none;
            -webkit-user-select: none;
        }

        /* 核心方陣排版 */
        .ziwei-board {
            --sscale: 1;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-template-rows: repeat(4, 1fr);
            gap: 1px;
            background-color: #D6CACA; /* 柔和的格線色 */
            border: 2px solid #C4B7B7;
            width: 100%;
            max-width: 680px; 
            aspect-ratio: 1 / 1;
            position: relative;
            margin: 0 auto;
            box-shadow: 0 8px 30px rgba(0,0,0,0.04);
            background-clip: padding-box;
        }

        .palace-cell {
            background-color: #FFFFFF;
            position: relative;
            /* 下緣列高只有一個來源，宮位列高與 footer 高度不可能對不上。
               所有尺寸一律乘 --sscale，匯出時整體等比放大，
               而不是只把盤面撐大、內容留在原尺寸。 */
            --frow: calc(17px * var(--sscale, 1));      /* 三列基準列高：流年／大限／本命 */
            --frow-top: calc(9px * var(--sscale, 1));   /* 最上方流月月干細列 */
            --footer-h: calc(var(--frow-top) + var(--frow) * 3);
            padding: calc(5px * var(--sscale, 1)) calc(6px * var(--sscale, 1));
            display: grid;
            grid-template-rows: minmax(0, 1fr) var(--footer-h);
            cursor: pointer;
            transition: all 0.2s ease;
            z-index: 10;
            overflow: hidden;
            min-height: 0;
            min-width: 0;
            box-sizing: border-box;
        }

        .palace-stars-area {
            width: 100%;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
            padding: 3px 0 1px;
            display: flex;
            justify-content: flex-end;
            align-items: flex-start;
            position: relative;
        }

        /* 來因宮／生肖／身宮／七星：統一放在星曜區最左側 */
        .palace-star-meta {
            position: absolute;
            left: 0;
            top: 3px;
            z-index: 6;
            width: calc(var(--metaw) - 3px);
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            pointer-events: none;
        }

        .palace-star-meta-tag {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: calc(29px * var(--sscale, 1));
            height: calc(15px * var(--sscale, 1));
            padding: 0 calc(3px * var(--sscale, 1));
            border-radius: 4px;
            border: 1px solid #E2DAD4;
            background: rgba(252, 251, 250, 0.94);
            font-size: calc(11px * var(--sscale, 1));
            font-weight: 700;
            line-height: 1;
            white-space: nowrap;
            box-sizing: border-box;
        }

        /* ═══ 宮位下緣：左資訊／中宮職／右干支 共用同一組列高，逐列對齊 ═══ */
        .palace-footer {
            width: 100%;
            min-width: 0;
            height: var(--footer-h);
            box-sizing: border-box;
            overflow: hidden;
            z-index: 20;
            border-top: 1px solid transparent;
            display: grid;
            grid-template-columns: calc(38px * var(--sscale, 1)) minmax(0, 1fr) calc(42px * var(--sscale, 1));
            grid-template-rows: var(--frow-top) var(--frow) var(--frow) var(--frow);
            column-gap: calc(1px * var(--sscale, 1));
            align-items: stretch;
        }
        .palace-footer > div { box-sizing: border-box; min-width: 0; }

        /* 左下：流月月干／流年歲數／西元／大限起歲 */
        .palace-age-block {
            position: static !important;
            grid-column: 1;
            grid-row: 1 / -1;
            width: 100%;
            min-width: 0;
            height: 100%;
            padding: 0 !important;
            margin: 0 !important;
            display: grid !important;
            grid-template-rows: var(--frow-top) var(--frow) var(--frow) var(--frow);
            align-items: stretch !important;
            justify-items: stretch !important;
            gap: 0 !important;
            overflow: hidden;
            line-height: 1 !important;
        }

        .palace-month-stem,
        .palace-current-age,
        .palace-current-year,
        .palace-decade-start-age {
            position: static !important;
            width: 100% !important;
            min-width: 0 !important;
            height: 100% !important;
            min-height: 0 !important;
            margin: 0 !important;
            padding: 0 1px !important;
            display: flex !important;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            line-height: 1 !important;
            text-align: center;
            box-sizing: border-box;
            overflow: hidden;
            border-radius: 3px;
            font-weight: 700 !important;
        }
        .palace-month-stem        { grid-row: 1 !important; font-size: calc(10px * var(--sscale, 1)) !important; color: #C58B3A !important; background: transparent; }
        .palace-current-age       { grid-row: 2 !important; font-size: calc(11px * var(--sscale, 1)) !important; color: #6A937C !important; background: transparent; }
        .palace-current-year      { grid-row: 3 !important; font-size: calc(11px * var(--sscale, 1)) !important; color: #8B6F47 !important; background: transparent; }
        .palace-decade-start-age  { grid-row: 4 !important; font-size: calc(14px * var(--sscale, 1)) !important; color: #61829E !important; background: transparent; letter-spacing: -0.02em; }

        /* 中欄宮職：左欄由下往上 本命→大限→流年，右欄由下往上 流月→流日→流時 */
        .palace-name-block {
            position: static !important;
            grid-column: 2;
            grid-row: 2 / -1;
            display: flex !important;
            flex-direction: row;
            align-items: stretch !important;
            justify-content: center !important;
            min-width: 0;
            padding: 0 !important;
            margin: 0 !important;
            overflow: hidden;
            line-height: 1 !important;
        }
        .palace-role-grid {
            display: grid;
            grid-template-columns: minmax(42px, 1fr) minmax(28px, .72fr);
            grid-template-rows: repeat(3, var(--frow));
            column-gap: 2px;
            row-gap: 0;
            align-items: center;
            justify-items: center;
            justify-content: center;
        }
        .palace-role-grid.role-single { grid-template-columns: minmax(44px, auto); width:auto; }
        .role-c1 { grid-column: 1 !important; }
        .role-c2 { grid-column: 2 !important; }
        .role-r1 { grid-row: 1 !important; }
        .role-r2 { grid-row: 2 !important; }
        .role-r3 { grid-row: 3 !important; }

        .palace-name-text {
            position: static !important;
            display: flex;
            align-items: center;
            justify-content: center;
            width: auto !important;
            min-width: 42px !important;
            height: auto !important;
            min-height: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            box-sizing: border-box;
            text-align: center;
            white-space: nowrap;
            overflow: visible;
            line-height: 1.08 !important;
            letter-spacing: 0 !important;
            font-size: calc(14.5px * var(--sscale, 1)) !important;
            z-index: 5;
            background: inherit;
        }
        .palace-layer-label {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: auto !important;
            min-width: calc(24px * var(--sscale, 1)) !important;
            max-width: calc(32px * var(--sscale, 1)) !important;
            height: auto !important;
            margin: 0 !important;
            padding: calc(1.5px * var(--sscale, 1)) calc(3px * var(--sscale, 1)) !important;
            border-radius: 3px;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            font-size: calc(11.5px * var(--sscale, 1)) !important;
            font-weight: 700 !important;
            line-height: 1 !important;
        }

        /* 右下：方位、納音、宮位干支依流年／大限／本命三列水平對齊 */
        .palace-meta {
            position: static !important;
            grid-column: 3;
            grid-row: 2 / -1;
            width: 100%;
            height: 100%;
            min-width: 0;
            padding: 0 !important;
            overflow: visible;
            display: block !important;
        }

        .palace-nayin-ganzhi {
            width: 100%;
            height: calc(var(--frow) * 3);
            display: grid;
            grid-template-rows: repeat(3, var(--frow));
            align-items: center;
            justify-items: end;
            overflow: visible;
            line-height: 1 !important;
            white-space: nowrap;
        }

        /* 第1列＝方位（對齊流年）；第2列＝納音（對齊大限）；第3列＝干支（對齊本命） */
        .palace-direction,
        .palace-nayin,
        .palace-ganzhi {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            width: 100%;
            min-width: 0;
            height: 100%;
            padding: 0 1px;
            box-sizing: border-box;
            font-weight: 700;
            white-space: nowrap;
            overflow: visible;
            text-align: right;
        }
        .palace-direction { grid-row: 1; font-size: calc(var(--frow) * 0.62); color: #7B8C83; }
        .palace-nayin     { grid-row: 2; font-size: calc(var(--frow) * 0.62); color: #9B938D; }
        .palace-ganzhi    { grid-row: 3; font-size: calc(var(--frow) * 0.96); color: #4A4542; }
        .palace-nayin-ganzhi.without-nayin .palace-direction { grid-row: 2; }

        .palace-cell:hover { background-color: #F4EFEB; box-shadow: inset 0 0 0 1px #D6CACA; }
        .palace-cell.active-source { background-color: #F8EBEB; box-shadow: inset 0 0 0 2px #CFA6A6; }
        .palace-cell.active-trine { background-color:#F4F0E8; box-shadow: inset 0 0 0 2px #C9B78E; }
        .palace-cell.active-opposite { background-color:#EDF2F5; box-shadow: inset 0 0 0 2px #9FB3C1; }
        .palace-cell.active-decade { background-color: #EFEBF4; box-shadow: inset 0 0 0 2px #BCABC4;}
        .palace-cell.active-liunian { background-color: #EBF4EE; box-shadow: inset 0 0 0 2px #A9C5B4;}

        /* 中宮設計 */
        .center-board {
            background-color: #FFFFFF; /* 改回純白 */
            grid-area: 2 / 2 / 4 / 4;
            display: flex;
            flex-direction: column;
            align-items: center;
            z-index: 5; /* 大幅增加 Padding，避免四化線條重疊 */
            border: 1px solid #D6CACA;
            overflow: hidden; /* 防止內容撐破網格 */
        }

        /* 中央八字與大運：統一格線、字級與留白 */
        #bazi-section, #xchexp-bazi-section {
            width: 100%;
            max-width: 310px;
            gap: 7px;
        }

        .bazi-grid {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            direction: ltr;
            justify-content: center;
            gap: 5px;
            width: 100%;
            margin-top: 4px;
            padding: 9px 8px;
            border: 1px solid #E4DEDA;
            border-radius: 7px;
            background: #FCFBFA;
            box-sizing: border-box;
        }
        .bazi-col {
            direction: ltr;
            height: 82px;
            display: grid;
            grid-template-rows: 18px 1fr;
            justify-items: center;
            align-items: center;
            gap: 3px;
            padding: 4px 3px;
            border-right: 0;
            border-left: 1px solid #EEE9E5;
            box-sizing: border-box;
        }
        .bazi-col:first-child { border-left: 0; }
        .bazi-col:last-child { border-right: 0 !important; }
        .bazi-title {
            font-size: 11px;
            line-height: 1;
            color: #9B938D;
            writing-mode: horizontal-tb;
            letter-spacing: 0.08em;
        }
        .bazi-text {
            min-height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            line-height: 1.15;
            font-weight: 700;
            color: #5C5551;
            letter-spacing: 3px;
            writing-mode: vertical-rl;
        }
        .bazi-gender-col .bazi-text {
            writing-mode: vertical-rl;
            letter-spacing: 3px;
            color: #8A6F5A;
            font-size: 16px;
        }


        .dayun-list {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            grid-auto-rows: 48px;
            gap: 5px;
            margin-top: 1px;
            width: 100%;
            padding: 0;
            align-items: stretch;
        }
        .dayun-item {
            box-sizing: border-box;
            width: 100%;
            min-width: 0;
            height: 48px;
            display: grid;
            grid-template-rows: 16px 24px;
            align-content: center;
            justify-items: center;
            border: 1px solid #E4DEDA;
            border-radius: 5px;
            background-color: #FCFBFA;
            padding: 3px 2px;
            text-align: center;
            overflow: hidden;
        }
        .dayun-item > span {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            margin: 0 !important;
            white-space: nowrap;
            line-height: 1;
        }

        /* 星曜欄寬／字級／四化大小，統一由 --sscale（盤面縮放）與宮內星數分級決定 */
        .palace-cell {
            /* 舒適閱讀版：星曜字級微幅放大，同步略增欄寬與間距，避免擠壓盤面 */
            --starw: calc(23px * var(--sscale, 1));
            --stargap: calc(3.75px * var(--sscale, 1));
            --starfs: calc(19.25px * var(--sscale, 1));
            --shb: calc(22px * var(--sscale, 1));   /* 本命四化 */
            --shs: calc(18px * var(--sscale, 1));   /* 其餘各層四化 */
            --shrow: calc(18px * var(--sscale, 1));
            --starrow: calc(40px * var(--sscale, 1));
            --metaw: calc(41px * var(--sscale, 1));
        }
        /* 6 顆以上的宮位自動縮排，避免星曜溢出宮位被裁掉 */
        .palace-cell.stars-d2 { --starw: calc(21px * var(--sscale,1)); --stargap: calc(2px * var(--sscale,1)); --starfs: calc(18px * var(--sscale,1)); --shb: calc(20px * var(--sscale,1)); --shs: calc(17px * var(--sscale,1)); }
        .palace-cell.stars-d3 { --starw: calc(19px * var(--sscale,1)); --stargap: calc(1.25px * var(--sscale,1)); --starfs: calc(16.25px * var(--sscale,1)); --shb: calc(18px * var(--sscale,1)); --shs: calc(16px * var(--sscale,1)); }
        .palace-cell.stars-d4 { --starw: calc(16.25px * var(--sscale,1)); --stargap: calc(0.75px * var(--sscale,1)); --starfs: calc(15px * var(--sscale,1)); --shb: calc(16px * var(--sscale,1)); --shs: calc(14px * var(--sscale,1)); }
        .palace-cell.stars-d5 { --starw: calc(14px * var(--sscale,1)); --stargap: calc(0.5px * var(--sscale,1)); --starfs: calc(12.75px * var(--sscale,1)); --shb: calc(14px * var(--sscale,1)); --shs: calc(12.25px * var(--sscale,1)); }
        /* 9 顆主要星曜專用超密集版型：四化仍收在各自星曜欄內，不增加橫向占位。 */
        .palace-cell.stars-d6 { --starw: calc(12px * var(--sscale,1)); --stargap: 0px; --starfs: calc(11.25px * var(--sscale,1)); --shb: calc(11.5px * var(--sscale,1)); --shs: calc(10.5px * var(--sscale,1)); --shrow: calc(14px * var(--sscale,1)); }
        .palace-cell.stars-runtime-overflow { --starw: calc(11px * var(--sscale,1)); --stargap: 0px; --starfs: calc(10.5px * var(--sscale,1)); --shb: calc(10.5px * var(--sscale,1)); --shs: calc(9.75px * var(--sscale,1)); --shrow: calc(13px * var(--sscale,1)); }

        .stars-container {
            display: flex;
            flex-direction: row-reverse;
            justify-content: flex-start;
            align-items: flex-start;
            gap: var(--stargap);
            width: 100%;
            height: 100%;
            min-height: 0;
            flex-wrap: nowrap;
            overflow: hidden;
            padding-left: var(--metaw);
            box-sizing: border-box;
        }

        .star-group {
            flex: 0 0 var(--starw);
            width: var(--starw);
            min-width: var(--starw);
            height: 100%;
            display: grid;
            /* 星名列可被壓縮，四化列高度固定保留，
               確保盤面縮小時第三層四化仍然完整顯示不被裁掉 */
            grid-template-rows: minmax(0, var(--starrow)) calc(var(--shrow) * 3 + 2px);
            justify-items: center;
            align-items: start;
            gap: 1px;
            overflow: visible;
        }
        .star-text {
            width: var(--starw);
            height: 100%;
            max-height: var(--starrow);
            writing-mode: horizontal-tb !important;
            text-orientation: upright;
            letter-spacing: 0;
            position: relative;
            display: flex !important;
            flex-direction: column !important;
            flex-wrap: nowrap !important;
            align-items: center;
            justify-content: flex-start;
            line-height: 1.05;
            white-space: nowrap;
            overflow: hidden;
            margin: 0 !important;
        }
        .star-text .star-char {
            display: block;
            flex: 0 0 auto;
            width: 1em;
            height: 1.05em;
            line-height: 1.05em;
            text-align: center;
        }
        .sihua-stack {
            display: grid;
            grid-template-rows: repeat(3, var(--shrow));
            row-gap: 1px;
            justify-items: center;
            align-items: center;
            width: var(--starw);
            min-height: calc(var(--shrow) * 3 + 2px);
        }
        .sihua-slot {
            display: flex;
            align-items: center;
            justify-content: center;
            width: var(--starw);
        }
        .sihua-slot.birth-slot { height: 20px; }
        .sihua-slot.decade-slot,
        .sihua-slot.liunian-slot { height: 18px; }

        /* 星辰大小與色彩統一規範 (大小一致，僅用顏色區分) */
        .main-star { font-weight: bold; font-size: var(--starfs); color: #4A4542; } /* 主星：深灰褐 */
        .aux-star { font-weight: bold; font-size: var(--starfs); color: #7B6882; } /* 輔星：莫蘭迪紫 */
        .small-star { font-weight: 600; font-size: var(--starfs); color: #9B938D; } /* 小星：淺灰褐 */

        /* 圖層控制 */
        /* 匯出副本的 id 會加上 xchexp- 命名空間（見 js__export__export-engine.js），以下同時保留兩種選擇器 */
        #svg-layer, #teaching-layer, #xchexp-svg-layer, #xchexp-teaching-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; }
        #svg-layer, #xchexp-svg-layer { pointer-events: none; z-index: 25; }
        #teaching-layer, #xchexp-teaching-layer { z-index: 30; pointer-events: none; cursor: crosshair; }
        body.teaching-mode #teaching-layer { pointer-events: auto; }

        /* 四化柔和色系基準 */
        .color-A { fill: #6A937C; color: #6A937C; } /* 祿：莫蘭迪綠 */
        .color-B { fill: #8B6F47; color: #8B6F47; } /* 權：咖啡 */
        .color-C { fill: #79AFCB; color: #79AFCB; } /* 科：淺藍 */
        .color-D { fill: #B86B67; color: #B86B67; } /* 忌：磚紅/豆沙紅 */

        /* 文墨天機短版飛化：不畫跨宮飛線，受化星曜以祿、權、科、忌改變字體底色 */
        .star-text.fly-star-A,
        .star-text.fly-star-B,
        .star-text.fly-star-C,
        .star-text.fly-star-D {
            /* 僅疊加四化底色；完全沿用 .star-text 原本的直排、尺寸與 flex 方向。 */
            border-radius: 2px;
            color: #FFFFFF !important;
            font-weight: 900 !important;
            box-decoration-break: clone;
            -webkit-box-decoration-break: clone;
        }
        .star-text.fly-star-A { background-color:#188E46 !important; }
        .star-text.fly-star-B { background-color:#7E2F9D !important; }
        .star-text.fly-star-C { background-color:#168BC4 !important; }
        .star-text.fly-star-D { background-color:#D43B32 !important; }
        
        /* 生年四化 (實心放大) */
        .birth-sihua {
            display: inline-flex; align-items: center; justify-content: center;
            width: var(--shb); height: var(--shb); border-radius: 4px; color: white; font-size: calc(var(--shb) * 0.64); font-weight: bold;
        }
        .bg-color-A { background-color: #6A937C; color: white;}
        .bg-color-B { background-color: #8B6F47; color: white;}
        .bg-color-C { background-color: #79AFCB; color: white;}
        .bg-color-D { background-color: #B86B67; color: white;}

        /* 大限四化 (空心框) */
        .decade-sihua {
            display: inline-flex; align-items: center; justify-content: center;
            width: var(--shs); height: var(--shs); border-radius: 3px; font-size: calc(var(--shs) * 0.7); font-weight: bold; background-color: #FCFBF9;
        }
        .dec-color-A { border: 1.5px solid #6A937C; color: #6A937C; }
        .dec-color-B { border: 1.5px solid #8B6F47; color: #8B6F47; }
        .dec-color-C { border: 1.5px solid #79AFCB; color: #79AFCB; }
        .dec-color-D { border: 1.5px solid #B86B67; color: #B86B67; }

        /* 流年四化 (圓形底) */
        .liunian-sihua {
            display: inline-flex; align-items: center; justify-content: center;
            width: var(--shs); height: var(--shs); border-radius: 50%; font-size: calc(var(--shs) * 0.7); font-weight: bold;
        }
        .ln-color-A { background-color: #E2ECE5; color: #6A937C; }
        .ln-color-B { background-color: #EFE7DC; color: #8B6F47; }
        .ln-color-C { background-color: #E7F3F8; color: #79AFCB; }
        .ln-color-D { background-color: #F4E6E5; color: #B86B67; }


        /* 四化標示統一：粗體、置中；同宮多組時依槽位排列，不互相覆蓋 */
        .birth-sihua, .decade-sihua, .liunian-sihua {
            font-weight: 800 !important;
            line-height: 1 !important;
            flex: 0 0 auto;
        }
        .sihua-stack { overflow: visible; }
        .sihua-slot { overflow: visible; flex-wrap: wrap; align-content: center; row-gap: 1px; }

        .tool-btn.active { background-color: #B86B67; color: white; border-color: #B86B67; }

        /* 控制面板的柔和樣式 */
        .ctrl-panel {
            background-color: #FFFFFF;
            border: 1px solid #EAE6E1;
            box-shadow: 0 4px 20px rgba(0,0,0,0.02);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 12px;
        }
        .ctrl-group {
            background-color: #FAF8F5;
            border: 1px solid #EAE6E1;
            border-radius: 6px;
            padding: 6px 12px;
        }
        .ctrl-label {
            font-size: 12px;
            font-weight: bold;
            color: #8A837E;
        }
        .ctrl-input {
            border: 1px solid #D6CACA;
            border-radius: 4px;
            padding: 2px 6px;
            font-size: 13px;
            color: #5C5551;
            background-color: #FFFFFF;
            font-weight: bold;
        }


        /* 八字區與命盤整體留白微調 */
        #bazi-section, #xchexp-bazi-section { margin-top: 5px !important; gap: 6px !important; }
        .bazi-grid { margin-top: 2px !important; padding: 8px 7px !important; gap: 7px !important; }
        .dayun-list { margin-top: 3px !important; gap: 4px !important; }
        .center-board > div { width: 100%; }


        /* 本命至流日四化：盤面固定最多三層 */
        .sihua-slot { min-height: var(--shrow); }
        .sihua-layer-mark { display:inline-flex; align-items:center; justify-content:center; font-weight:800; line-height:1; }
        .month-sihua { width:var(--shs); height:var(--shs); border-radius:4px; font-size:calc(var(--shs) * 0.7); border:1.5px dashed currentColor; background:#FFFFFF; }
        .day-sihua { width:var(--shs); height:var(--shs); border-radius:50%; font-size:calc(var(--shs) * 0.7); color:#FFFFFF !important; }
        .hour-sihua { width:var(--shs); height:var(--shs); border-radius:2px; font-size:calc(var(--shs) * 0.7); color:#FFFFFF !important; transform:rotate(45deg); }
        .hour-sihua > span { transform:rotate(-45deg); display:inline-flex; align-items:center; justify-content:center; }
        .day-bg-A{background:#6A937C}.day-bg-B{background:#8B6F47}.day-bg-C{background:#79AFCB}.day-bg-D{background:#B86B67}
        .hour-bg-A{background:#6A937C}.hour-bg-B{background:#8B6F47}.hour-bg-C{background:#79AFCB}.hour-bg-D{background:#B86B67}
        .fly-mode-btn.active { background:#61829E; color:#fff; border-color:#61829E; }
        .month-color-A{color:#6A937C}.month-color-B{color:#8B6F47}.month-color-C{color:#79AFCB}.month-color-D{color:#B86B67}
        #yun-start-info:empty, #xchexp-yun-start-info:empty { display:none; }
        .bazi-grid { direction:ltr !important; }

        /* 中宮資訊精簡，避免八字與大運區過度擁擠 */
        .center-board { padding: 20px 28px !important; }
        .center-board .center-summary { margin-bottom: 4px !important; gap: 2px !important; }
        #bazi-section, #xchexp-bazi-section { margin-top: 2px !important; gap: 4px !important; }
        .bazi-grid { padding: 6px !important; gap: 5px !important; }
        .bazi-col { height: 70px !important; grid-template-rows: 15px 1fr !important; padding: 2px !important; }
        .bazi-text { min-height: 42px !important; font-size: 16px !important; }
        #yun-start-info, #xchexp-yun-start-info { font-size: 9px !important; line-height: 1.25 !important; padding: 3px 6px !important; }
        .dayun-list { grid-auto-rows: 42px !important; gap: 3px !important; }
        .dayun-item { height: 42px !important; grid-template-rows: 14px 20px !important; padding: 2px !important; cursor: pointer; transition: .15s ease; }
        .dayun-item:hover { background:#F3EFEA; border-color:#CFC4BC; }
        .dayun-item.active { background:#EEE8F1; border-color:#9D879F; box-shadow: inset 0 0 0 1px #9D879F; }
        .fly-sihua-label { font-size: 14px; font-weight: 900; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }/* 年份欄靠右，國曆「1990年」與農曆「民79年」的「年」字才會上下對齊 */
        .center-date-row > span:nth-child(2) { text-align:right !important; padding-right:5px; }.center-date-row .date-year,
        .center-date-row .date-month,
        .center-date-row .date-day { display:flex; align-items:center; justify-content:flex-end; width:100%; box-sizing:border-box; }
        .center-date-row .date-month, .center-date-row .date-day { padding-right:4px; }/* fix33：第五欄（時間／時辰）三列左緣對齊。
           原本三列都是 text-align:center，但「05:32」是 5 個半形字（約 30px）、
           「午時」是 2 個全形字（約 24px），置中後兩者左右各差 3px，
           農曆那一列看起來就沒對齊。改為靠左並給同一組內距，三列由同一個 x 起排。 */
        .center-date-row > span:last-child {
            text-align: left !important;
            justify-content: flex-start;
            padding-left: 9px;
        }.center-date-row-truesolar .date-label {
            color: #8A6B49;
        }
        .center-date-row-truesolar { color: #8A6B49; }
        .center-date-row.is-hidden { display: none !important; }
        .center-date-row-truesolar .truesolar-time {
            display: inline-flex;
            align-items: baseline;
            justify-content: center;
            gap: 3px;
            white-space: nowrap;
        }
        .center-date-row-truesolar .truesolar-delta {
            font-size: 9px;
            font-style: normal;
            font-weight: 700;
            color: #A79A8C;
        }.center-hour-value { text-align:left; color:#5C7482; letter-spacing:.06em; }

        /* 匯出模式的宮位尺寸全部由 --sscale 推導（見 .ziwei-board.export-mode），
           這裡只保留 html2canvas 需要的防裁切設定。 */
        .ziwei-board.export-mode .palace-layer-label { overflow: visible !important; }


        /* Sprint 1：獨立匯出舞台。副本在畫面外以固定桌機尺寸排版，不再改動手機上的原始命盤。 */
        .xch-export-stage {
            position: fixed;
            left: 0;
            top: 0;
            width: 1280px;
            height: 1280px;
            overflow: visible;
            pointer-events: none;
            opacity: 1;
            z-index: -2147483647;
            background: #fff;
            /* 不再把匯出副本放到 -20000px。部分手機瀏覽器搭配 html2canvas
               會以視窗邊界裁切，導致右側第四欄及底列遺失。 */
            contain: none;
        }
        .xch-export-stage .ziwei-board.export-render-copy {
            box-sizing: border-box !important;
            font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif !important;
            font-stretch: normal !important;
            text-rendering: geometricPrecision;
            -webkit-font-smoothing: antialiased;
        }
        .xch-export-stage .ziwei-board.export-render-copy * {
            box-sizing: border-box;
            font-stretch: normal !important;
        }

        /* PNG 匯出模式：固定正方形高解析尺寸，避免文字與宮位資訊擠壓 */
        /* 匯出：盤面 1280px 是桌機 680px 的 1.892 倍，內容必須同倍率放大，
           否則字級停在原尺寸、資訊擠在四角、中間留下大片空白。 */
        .ziwei-board.export-mode {
            --sscale: 1.892;
            width: 1280px !important;
            max-width: none !important;
            height: 1280px !important;
            aspect-ratio: auto !important;
            box-shadow: none !important;
        }
        /* fix28：匯出時不再裁切宮格，並保留底部安全邊界。
           html2canvas 1.4.1 畫文字時用 fillText(text, bounds.left, bounds.top + fontMetrics.baseline)，
           而 fontMetrics 是用「沒有設定 line-height」的隱藏容器量出來的（等同 line-height: normal）。
           盤面下緣的欄位一律 line-height: 1，中日韓字型的 normal 行高約 1.4~1.5em，
           兩者的半行距差會讓每一行文字往下位移約 11px（1280px 版面），
           下緣最後一列（大限起歲／宮職／宮干支）因此落在 overflow: hidden 的裁切線上被切一半。
           行高改成 normal 沒有用（實測反而多切 4%），因為這些欄位是固定高的 flex 置中格子；
           唯一有效的做法是不要跟 html2canvas 的基線硬碰：解除裁切並預留底部空間。
           實測底部 60px 帶的墨量比：修正前 0.860（9/12 宮位缺墨）→ 修正後 1.038（0/12）。 */
        .ziwei-board.export-mode .palace-cell {
            overflow: visible !important;
            padding-bottom: calc(10px * var(--sscale, 1)) !important;
        }
        .ziwei-board.export-mode .palace-footer,
        .ziwei-board.export-mode .palace-age-block,
        .ziwei-board.export-mode .palace-name-block,
        .ziwei-board.export-mode .palace-role-grid,
        .ziwei-board.export-mode .palace-meta,
        .ziwei-board.export-mode .palace-nayin-ganzhi,
        .ziwei-board.export-mode .palace-month-stem,
        .ziwei-board.export-mode .palace-current-age,
        .ziwei-board.export-mode .palace-current-year,
        .ziwei-board.export-mode .palace-decade-start-age { overflow: visible !important; }

        /* fix29：宮職色籤（大限／流年／流月／流日／流時）內的白字置中。
           同樣是 html2canvas 的基線問題，但這裡不會被裁切，而是白字整體下移約
           8.5px（2048px 輸出），下半截落到彩色底之外的白色宮格上，看起來像被削掉。
           色籤是 inline-flex + align-items:center，把行高交還給 normal 後，
           文字框與 html2canvas 量測基線所用的模型一致，白字即回到正中央。
           實測白字中心偏移：+8.5px → +0.0px。
           代價是色籤高度由 43px 增為 54px（2048px 輸出），
           實測同欄相鄰色籤最小間隙仍為 6px，未產生重疊。
           注意：必須維持 height:auto，一旦把高度鎖回原尺寸，偏移會回到 +9.5px。 */
        .ziwei-board.export-mode .palace-layer-label {
            line-height: normal !important;
            overflow: visible !important;
        }
        .ziwei-board.export-mode .stars-container { overflow: visible !important; }
        .ziwei-board.export-mode .star-text,
        .ziwei-board.export-mode .star-char {
            line-height: 1.08 !important;
            letter-spacing: 0 !important;
        }
        .ziwei-board.export-mode .sihua-stack,
        .ziwei-board.export-mode .sihua-markers {
            gap: 1px !important;
        }
        .ziwei-board.export-mode .palace-meta { grid-row: 2 / -1; }
        .ziwei-board.export-mode .center-board {
            padding: calc(30px * var(--sscale)) calc(40px * var(--sscale)) !important;
        }
        /* ═══ fix40：匯出時色籤覆蓋本命宮職 ═══
           .palace-layer-label 的 min-width 是 calc(24px * sscale)，匯出放大後為 45.4px，
           但 role-grid 的第二欄只有 39.5px，色籤撐爆欄軌後往兩側各溢出約 7.6px，
           左側正好壓在本命宮職（夫妻／兄弟／命宮…）上，實測 12 宮共 24 處、最大覆蓋 5.7px。
           修法：匯出模式取消色籤的固定最小／最大寬，欄軌改為純比例分配，
           字級微收一級讓兩個全形字仍放得下。
           實測：覆蓋 24 → 0 處、色籤溢出欄軌 36 → 0 處、文字截斷 0 處。 */
        .ziwei-board.export-mode .palace-role-grid {
            grid-template-columns: minmax(0, 1fr) minmax(0, 0.86fr) !important;
            column-gap: calc(1px * var(--sscale, 1)) !important;
        }
        .ziwei-board.export-mode .palace-layer-label {
            min-width: 0 !important;
            max-width: 100% !important;
            padding-left: 0 !important;
            padding-right: 0 !important;
            font-size: calc(10.5px * var(--sscale, 1)) !important;
        }
        .ziwei-board.export-mode .palace-name-text { min-width: 0 !important; }

        .ziwei-board.export-mode .palace-footer .palace-nayin-ganzhi,
        .ziwei-board.export-mode .palace-footer .palace-name-block,
        .ziwei-board.export-mode .palace-footer .palace-layers {
            overflow: visible !important;
        }
    
        /* ═══ 命例查詢停靠面板：不覆蓋命盤，查資料時仍看得到盤 ═══ */
        .case-dock {
            position: fixed;
            right: 12px;
            bottom: 12px;
            z-index: 45;                 /* 低於 z-50 的個案／命例歷程視窗 */
            width: min(420px, calc(100vw - 24px));
            max-height: min(60vh, 520px);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background: #FFFFFF;
            border: 1px solid #E2DAD4;
            border-radius: 14px;
            box-shadow: 0 12px 32px rgba(60, 52, 46, .18);
        }
        .case-dock.hidden { display: none; }
        .case-dock-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 8px 10px 8px 14px;
            border-bottom: 1px solid #EDE7E2;
            background: #FBF9F7;
            cursor: default;
        }
        .case-dock-body {
            display: flex;
            flex-direction: column;
            min-height: 0;
            flex: 1;
        }
        .case-dock.is-collapsed { max-height: none; }
        .case-dock.is-collapsed .case-dock-body { display: none; }
        .case-dock.is-collapsed .case-dock-sub { display: none; }
        .case-dock.is-collapsed #case-search-collapse-icon { transform: rotate(180deg); }

        .case-dock-fab {
            position: fixed;
            right: 12px;
            bottom: 12px;
            z-index: 44;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 9px 14px;
            border: 1px solid #75627B;
            border-radius: 999px;
            background: #85708C;
            color: #FFFFFF;
            font-size: 12px;
            font-weight: 700;
            box-shadow: 0 6px 18px rgba(60, 52, 46, .22);
            cursor: pointer;
        }
        .case-dock-fab:hover { background: #75627B; }
        .case-dock-fab.hidden { display: none; }

        @media (max-width: 767px) {
            .case-dock {
                right: 6px;
                left: 6px;
                bottom: 6px;
                width: auto;
                max-height: 52vh;
            }
            .case-dock-fab { right: 8px; bottom: 8px; padding: 8px 12px; }
        }

        /* 面板展開時，底部留出空間，命盤仍可完整捲到可視範圍 */
        body.case-dock-open { padding-bottom: calc(min(60vh, 520px) + 24px) !important; }
        @media (max-width: 767px) { body.case-dock-open { padding-bottom: calc(52vh + 20px) !important; } }
        body.case-dock-open.case-dock-collapsed { padding-bottom: 84px !important; }

        /* 匯出、列印與教學模式時不顯示 */
        @media print { .case-dock, .case-dock-fab { display: none !important; } }
        body.teaching-mode .case-dock-fab { display: none !important; }

        /* 工具列一致化：性別直接點選、星系與四化橫向排列 */
        .gender-choice, .toolbar-choice {
            display:inline-flex; align-items:center; gap:4px; cursor:pointer;
            font-size:12px; line-height:1; font-weight:700; color:#5F5955; white-space:nowrap;
        }
        .gender-choice input, .toolbar-choice input { margin:0; accent-color:#8A837E; }
        .sihua-horizontal { display:flex; align-items:center; gap:6px; flex-wrap:nowrap; }
        .sihua-layer-choice input:disabled + span, .sihua-layer-choice.is-locked { opacity:.45; }
        #sihua-limit-hint {
            font-size:11px; font-weight:700; color:#B86B67; white-space:nowrap;
            opacity:0; transition:opacity .18s ease; margin-left:2px;
        }
        #sihua-limit-hint.show { opacity:1; }
        .decade-compact-group { gap:3px !important; padding-left:8px !important; padding-right:8px !important; }
        .decade-compact-group .decade-nav-btn { padding-left:5px !important; padding-right:5px !important; min-width:24px; }
        #input-decade { min-width:112px !important; width:112px; font-size:11px !important; }
        .three-four-toggle { white-space:nowrap; }
        /* 下拉選單統一為單一小箭頭，避免原生箭頭撐寬、破壞工具列排版 */
        select.ctrl-input {
            -webkit-appearance: none; -moz-appearance: none; appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23A39A94'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 5px center;
            padding-right: 16px !important;
            padding-left: 5px !important;
            text-align: left;
            text-align-last: left;
        }
        select.ctrl-input::-ms-expand { display: none; }
        select.ctrl-input.text-center { text-align: center; text-align-last: center; }
        .fly-mode-btn {
            height:24px; min-width:42px; padding:0 8px; border:1px solid #DED7D2; border-radius:5px;
            background:#F7F5F3; color:#625C58; font-size:12px; line-height:22px; font-weight:700;
            text-align:center; white-space:nowrap; transition:.15s ease;
        }
        .fly-mode-btn:hover { background:#EEE9E5; }
        .fly-mode-btn.active {
            background:#8A837E; border-color:#8A837E; color:#fff;
        }
        .toolbar-reset-btn {
            height:24px; padding:0 8px; border:1px solid #D8D0CA; border-radius:5px;
            background:#FFFFFF; color:#746C67; font-size:11px; line-height:22px; font-weight:700;
            display:inline-flex; align-items:center; justify-content:center; gap:4px;
            white-space:nowrap; transition:.15s ease;
        }
        .toolbar-reset-btn:hover { background:#F1EEEB; border-color:#BFB5AE; color:#5F5752; }
        .toolbar-reset-btn:active { transform:translateY(1px); }

        /* 視窗較窄時整體等比縮小：星曜、四化、宮職一起縮，確保不被裁切 */
        @media (max-width: 780px) {
            .ziwei-board { --sscale: 0.84; }
            .palace-cell { grid-template-rows: minmax(0, 1fr) 51px; padding: 4px 5px; }
            .palace-footer { height: 51px; --frow: 14px; --frow-top: 9px; grid-template-columns: 34px minmax(0, 1fr) 38px; }
            .palace-meta { grid-row: 2 / -1; }
            .palace-name-text { font-size: 11.5px !important; }
            .palace-layer-label { min-width: 21px !important; max-width: 28px !important; font-size: 9.5px !important; padding: 1px 2px !important; }
            .palace-decade-start-age { font-size: 11px !important; }
            .palace-current-age, .palace-current-year { font-size: 9px !important; }
            .palace-star-meta-tag { min-width: 24px; height: 13px; font-size: 8px; }
        }
        @media (max-width: 600px) {
            .ziwei-board { --sscale: 0.66; }
            .palace-cell { grid-template-rows: minmax(0, 1fr) 45px; padding: 3px 4px; }
            .palace-footer { height: 45px; --frow: 12px; --frow-top: 9px; grid-template-columns: 28px minmax(0, 1fr) 32px; }
            .palace-name-text { font-size: 10px !important; }
            .palace-layer-label { min-width: 18px !important; max-width: 24px !important; font-size: 8.5px !important; }
            .palace-decade-start-age { font-size: 9.5px !important; }
            .palace-star-meta-tag { min-width: 21px; height: 11px; font-size: 7px; }
        }


        /* 宮位星曜／四化防裁切：保留放大字級，但壓縮欄寬、間距與四化尺寸 */
        .palace-cell {
            --starw: calc(21.5px * var(--sscale, 1));
            --stargap: calc(2.25px * var(--sscale, 1));
            --starfs: calc(18.75px * var(--sscale, 1));
            --shb: calc(20px * var(--sscale, 1));
            --shs: calc(16.5px * var(--sscale, 1));
            --shrow: calc(17px * var(--sscale, 1));
            --starrow: calc(42px * var(--sscale, 1));
        }
        .palace-cell.stars-d2 { --starw:calc(19.5px * var(--sscale,1)); --stargap:calc(1.5px * var(--sscale,1)); --starfs:calc(17.5px * var(--sscale,1)); --shb:calc(18.5px * var(--sscale,1)); --shs:calc(15.5px * var(--sscale,1)); }
        .palace-cell.stars-d3 { --starw:calc(17.5px * var(--sscale,1)); --stargap:calc(1px * var(--sscale,1)); --starfs:calc(15.75px * var(--sscale,1)); --shb:calc(17px * var(--sscale,1)); --shs:calc(14.5px * var(--sscale,1)); }
        .palace-cell.stars-d4 { --starw:calc(15.25px * var(--sscale,1)); --stargap:calc(.5px * var(--sscale,1)); --starfs:calc(14.25px * var(--sscale,1)); --shb:calc(15px * var(--sscale,1)); --shs:calc(13px * var(--sscale,1)); }
        .palace-cell.stars-d5 { --starw:calc(13px * var(--sscale,1)); --stargap:0px; --starfs:calc(12px * var(--sscale,1)); --shb:calc(13px * var(--sscale,1)); --shs:calc(11.5px * var(--sscale,1)); }
        .palace-cell.stars-d6 { --starw:calc(11px * var(--sscale,1)); --stargap:0px; --starfs:calc(10.5px * var(--sscale,1)); --shb:calc(10.5px * var(--sscale,1)); --shs:calc(9.75px * var(--sscale,1)); --shrow:calc(13px * var(--sscale,1)); }
        .palace-cell.stars-runtime-overflow { --starw:calc(10px * var(--sscale,1)); --stargap:0px; --starfs:calc(9.75px * var(--sscale,1)); --shb:calc(9.75px * var(--sscale,1)); --shs:calc(9px * var(--sscale,1)); --shrow:calc(12px * var(--sscale,1)); }
        .palace-stars-area { padding-right:2px; }
        .stars-container { padding-left:calc(var(--metaw) - 2px); padding-right:1px; }
        .star-text { max-height:none; overflow:visible; }
        .sihua-stack { row-gap:0; }
        .sihua-slot { row-gap:0; column-gap:0; }
        .birth-sihua, .decade-sihua, .liunian-sihua, .sihua-layer-mark { box-sizing:border-box; }

        /* 2026-07-26：星曜與四化完整收納於宮格，避免貼邊或被裁切 */
        .palace-stars-area {
            padding: 2px 3px 2px 0 !important;
            overflow: hidden !important;
        }
        .stars-container {
            height: 100% !important;
            min-height: 0 !important;
            padding-right: 2px !important;
            overflow: hidden !important;
        }
        .star-group {
            height: 100% !important;
            min-height: 0 !important;
            grid-template-rows: minmax(0, 1fr) auto !important;
            overflow: hidden !important;
        }
        .star-text {
            max-height: 100% !important;
            min-height: 0 !important;
            overflow: hidden !important;
            padding-top: 1px;
            box-sizing: border-box;
        }
        .sihua-stack {
            min-height: 0 !important;
            max-height: calc(var(--shrow) * 3) !important;
            overflow: hidden !important;
            padding-bottom: 1px;
            box-sizing: border-box;
        }
        .sihua-slot {
            min-height: 0 !important;
            max-height: var(--shrow) !important;
            overflow: hidden !important;
        }

        /* 2026-07-26：本命四化固定顯示在各星曜名稱正下方 */
        .star-group {
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
            justify-content: flex-start !important;
        }
        .star-text {
            flex: 0 0 auto !important;
            width: var(--starw) !important;
            height: auto !important;
            min-height: 0 !important;
            max-height: none !important;
            overflow: visible !important;
        }
        .sihua-stack {
            flex: 0 0 auto !important;
            width: var(--starw) !important;
            margin-top: 2px !important;
            align-content: start !important;
        }
        .sihua-slot {
            flex: 0 0 var(--shrow) !important;
        }


/* V2.3.2-alpha.2 多胞胎排盤 */
.multiple-birth-settings { box-sizing: border-box; }
.multiple-birth-member-row { display:grid; grid-template-columns:72px 78px minmax(150px,220px); gap:8px; align-items:center; }
@media (max-width:600px){ .multiple-birth-member-row{grid-template-columns:56px 68px minmax(130px,1fr);} .multiple-birth-settings{padding:8px!important;} }


/* V2.3.2-alpha.3：農曆時辰、校時與主工具列收合 */
.toolbar-collapse-strip { display:flex; justify-content:flex-end; margin-bottom:4px; }
.toolbar-collapse-btn { border:1px solid #D6CECA; background:#F8F6F4; color:#6F6863; border-radius:8px; padding:5px 10px; font-size:11px; font-weight:700; display:flex; align-items:center; gap:6px; }
#main-control-panel.main-toolbar-collapsed { display:none !important; }
.calibration-panel { width:100%; margin-top:6px; padding-top:5px; border-top:1px solid #E4DEDA; }
.calibration-five-grid { width:100%; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px; align-items:stretch; }
.calibration-five-grid > * { min-width:0; min-height:24px; display:flex; align-items:center; justify-content:center; border:1px solid #D8CFCA; border-radius:4px; background:#FAF8F6; color:#625B57; font-size:10px; font-weight:700; padding:2px; }
.calibration-five-grid button:hover { background:#EEE8E4; }
.calibration-label { background:#85708C !important; color:#fff !important; border-color:#75627B !important; }
.calibration-status { margin-top:4px; text-align:center; font-size:8.5px; line-height:1.35; color:#756E69; }
.calibration-actions { display:flex; justify-content:center; margin-top:3px; }
.calibration-actions button { border:1px solid #CFC5BF; background:#fff; color:#756E69; border-radius:4px; padding:2px 9px; font-size:9px; font-weight:700; }
.ziwei-board.export-mode .calibration-panel { display:none !important; }

/* V2.3.2-alpha.3.2：多胞胎改為性別後方彈窗入口 */
.multiple-birth-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid #C9B08F;
    border-radius: 7px;
    background: #F8F3EC;
    color: #7A6043;
    font-size: 11px;
    font-weight: 700;
    transition: background-color .18s ease, border-color .18s ease;
}
.multiple-birth-open-btn:hover { background: #F1E7DA; border-color: #B08C62; }
.multiple-birth-modal-card { max-height: min(86vh, 760px); overflow-y: auto; }

/* 收合後保留展開鍵，控制面板確實退出版面。 */
#main-control-panel.main-toolbar-collapsed {
    display: none !important;
}
.toolbar-collapse-strip {
    position: relative;
    z-index: 35;
}
.toolbar-collapse-btn {
    cursor: pointer;
    user-select: none;
}

/* 校時面板開啟時明確顯示，避免被其他 hidden/display 規則覆蓋。 */
#calibration-panel:not(.hidden) {
    display: block !important;
}

/* V2.3.2-alpha.3.4：工具按鈕作用中狀態 */
#calibration-toolbar-toggle.is-active,
#client-toolbar-toggle.is-active,
#case-toolbar-toggle.is-active,
#case-search-toolbar-toggle.is-active {
    background: #85708C !important;
    border-color: #75627B !important;
    color: #fff !important;
    box-shadow: 0 1px 3px rgba(70, 55, 75, .24);
}

/* 讓作用中的工具按鈕保持在彈窗遮罩上方，可再次點擊關閉 */
#client-toolbar-toggle.is-active,
#case-toolbar-toggle.is-active {
    position: relative;
    z-index: 60;
}

/* V2.3.2-alpha.3.5：教學列可獨立收合 */
#teaching-toolbar { transition: padding .18s ease, border-radius .18s ease; }
#teaching-toolbar .teaching-toolbar-title { background: transparent; border: 0; cursor: pointer; }
#teaching-toolbar .teaching-toolbar-title:hover { opacity: .92; }
#teaching-toolbar.is-collapsed { padding-top: 6px; padding-bottom: 6px; }
#teaching-toolbar.is-collapsed .teaching-toolbar-header { min-height: 28px; }
#teaching-toolbar-options.hidden { display: none !important; }
@media (max-width: 767px) {
  #teaching-toolbar .teaching-toolbar-header { align-items: flex-start; }
  #teaching-toolbar .teaching-toolbar-title { text-align: left; }
}

/* V2.3.2-alpha.3.6-fix4：介面操作修正 */
#multiple-birth-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 70 !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-y: auto;
}
#multiple-birth-modal.hidden { display: none !important; }
#multiple-birth-modal.flex { display: flex !important; }
.multiple-birth-modal-card { margin: auto; }
.teaching-toolbar-single-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
}
.teaching-toolbar-single-row > button { flex: 0 0 auto; white-space: nowrap; }
.teaching-toolbar-label { white-space: nowrap; }


/* fix5：手機教學畫面鎖定，避免繪圖時頁面跟著滑動 */
body.teaching-screen-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
}
body.teaching-screen-locked #teaching-layer {
    touch-action: none;
}
body.teaching-screen-locked #teaching-toolbar,
body.teaching-screen-locked #teaching-toolbar button {
    touch-action: manipulation;
}
#teaching-screen-lock.is-locked {
    background: #4A4542 !important;
    border-color: #3E3A37 !important;
}


/* V2.3.2-alpha.3.6-fix16：校時還原狀態與介面修正 */
.calibration-five-grid {
  grid-template-columns: minmax(58px,.8fr) repeat(4,minmax(72px,1fr));
  gap: 6px;
}
.calibration-five-grid > * {
  min-height: 38px;
  font-size: 13px;
  border-radius: 7px;
  padding: 6px 8px;
  touch-action: manipulation;
}
.calibration-status {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.35;
}
.calibration-time-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 7px;
  border: 1px solid #E1D8D2;
  border-radius: 7px;
  background: #FCFAF8;
  white-space: nowrap;
}
.calibration-time-item span { color:#8A7D75; font-weight:700; }
.calibration-time-item strong { color:#5F5752; font-size:11.5px; }
#multiple-birth-modal {
  height: 100dvh !important;
  min-height: 100vh !important;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
  overflow: hidden !important;
}
#multiple-birth-modal.flex {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#multiple-birth-modal .multiple-birth-modal-card {
  margin: 0 auto !important;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 640px) {
  .calibration-panel { overflow-x:auto; }
  .calibration-five-grid { min-width: 390px; }
  .calibration-status { min-width: 390px; }
  .calibration-time-item strong { font-size: 11px; }
}


/* V2.3.2-alpha.3.6-fix16：還原按鈕依校正狀態啟用 */
#calibration-restore-button:disabled {
  opacity: .42;
  cursor: default;
  background: #F1EFED;
  color: #9C9692;
  border-color: #DED9D5;
  box-shadow: none;
}
#calibration-restore-button.is-enabled {
  opacity: 1;
  cursor: pointer;
  background: #FAF8F6;
  color: #625B57;
}

/* V2.3.2 Alpha 3.6-fix16：教學列與命盤等寬，並上移保留離心自化箭頭空間 */
:root {
    --ziwei-board-max-width: 680px;
}
#teaching-toolbar {
    width: min(var(--ziwei-board-max-width), 100%) !important;
    max-width: var(--ziwei-board-max-width) !important;
    margin-left: auto;
    margin-right: auto;
    transform: translateY(-10px);
    box-sizing: border-box;
}
#teaching-toolbar .teaching-toolbar-single-row {
    width: 100%;
    max-width: 100%;
}
.ziwei-board {
    width: min(var(--ziwei-board-max-width), 100%);
    max-width: var(--ziwei-board-max-width);
}


/* V2.3.2 Alpha 3.6-fix16：多胞胎視窗強制以瀏覽器視窗置中並放大 */
#multiple-birth-modal {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)) !important;
  box-sizing: border-box !important;
  z-index: 9999 !important;
  overflow: hidden !important;
  transform: none !important;
}
#multiple-birth-modal.flex {
  display: grid !important;
  place-items: center !important;
}
#multiple-birth-modal .multiple-birth-modal-card {
  position: relative !important;
  inset: auto !important;
  width: min(560px, calc(100vw - 36px)) !important;
  max-width: 560px !important;
  min-width: min(460px, calc(100vw - 36px)) !important;
  max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  margin: 0 !important;
  transform: none !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  font-size: 15px;
}
#multiple-birth-modal .multiple-birth-modal-card h2 { font-size: 18px; }
#multiple-birth-modal .multiple-birth-modal-card .ctrl-input { min-height: 42px; font-size: 14px; }
#multiple-birth-modal .multiple-birth-modal-card button { min-height: 40px; font-size: 13px; }
#multiple-birth-modal .multiple-birth-member-row { gap: 10px; }
@media (max-width: 640px) {
  #multiple-birth-modal { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) !important; }
  #multiple-birth-modal .multiple-birth-modal-card {
    width: calc(100vw - 20px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }
}

/* V2.3.2 Alpha 3.6-fix16：校時列切齊八字大運，展開時避免中宮文字被裁切 */
.center-board {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #D8CFCA transparent;
}
.center-board.calibration-open {
  justify-content: flex-start;
  padding-top: 18px;
}
#calibration-panel {
  width: 100%;
  max-width: 310px;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.calibration-five-grid {
  width: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  box-sizing: border-box;
}
.calibration-five-grid > * {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 5px 2px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
}
.calibration-status {
  width: 100%;
  max-width: 310px;
  box-sizing: border-box;
  gap: 5px;
}
.calibration-time-item {
  padding: 6px 4px;
  overflow: hidden;
}
.calibration-time-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .center-board.calibration-open {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .calibration-panel,
  .calibration-five-grid,
  .calibration-status {
    min-width: 0 !important;
    max-width: 310px;
    overflow: visible;
  }
  .calibration-five-grid > * {
    min-height: 34px;
    font-size: 11px;
    padding-left: 1px;
    padding-right: 1px;
  }
  .calibration-time-item {
    white-space: normal;
    line-height: 1.25;
  }
}

/* V2.3.2 Alpha 3.6-fix16：多胞胎視窗加大，文字與選項不裁切 */
#multiple-birth-modal .multiple-birth-modal-card {
  width: min(720px, calc(100vw - 40px)) !important;
  max-width: 720px !important;
  min-width: min(600px, calc(100vw - 40px)) !important;
  max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}
#multiple-birth-modal .multiple-birth-modal-card > :first-child,
#multiple-birth-modal .multiple-birth-modal-card > :last-child {
  flex: 0 0 auto;
}
#multiple-birth-modal .multiple-birth-modal-card > .space-y-3 {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px !important;
}
#multiple-birth-modal .multiple-birth-modal-card h2 {
  font-size: 20px;
  line-height: 1.35;
}
#multiple-birth-modal .multiple-birth-modal-card .text-\[11px\],
#multiple-birth-modal .multiple-birth-modal-card .text-\[10px\],
#multiple-birth-modal .multiple-birth-modal-card .text-\[12px\] {
  line-height: 1.55;
}
#multiple-birth-modal .multiple-birth-member-row {
  grid-template-columns: 78px 96px minmax(260px, 1fr);
  gap: 12px;
  min-height: 48px;
  align-items: center;
}
#multiple-birth-modal .multiple-birth-member-row > * {
  min-width: 0;
}
#multiple-birth-modal .multiple-birth-member-row .ctrl-input,
#multiple-birth-modal select.ctrl-input {
  width: 100%;
  min-height: 44px;
  height: auto;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: clip;
}
#multiple-birth-modal .multiple-birth-modal-card button {
  min-height: 42px;
  padding-top: 8px;
  padding-bottom: 8px;
  line-height: 1.25;
}
@media (max-width: 640px) {
  #multiple-birth-modal .multiple-birth-modal-card {
    width: calc(100vw - 16px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }
  #multiple-birth-modal .multiple-birth-modal-card > .space-y-3 {
    padding: 12px !important;
  }
  #multiple-birth-modal .multiple-birth-member-row {
    grid-template-columns: 58px 72px minmax(0, 1fr);
    gap: 7px;
    min-height: 46px;
  }
  #multiple-birth-modal .multiple-birth-member-row .ctrl-input,
  #multiple-birth-modal select.ctrl-input {
    min-height: 42px;
    padding: 7px 5px;
    font-size: 12px;
  }
}
@media (max-width: 390px) {
  #multiple-birth-modal .multiple-birth-member-row {
    grid-template-columns: 1fr 1fr;
  }
  #multiple-birth-modal .multiple-birth-member-row > span {
    grid-column: 1 / -1;
  }
  #multiple-birth-modal .multiple-birth-member-row > select:last-child {
    grid-column: 1 / -1;
  }
}

/* fix16 */
.multiple-birth-guidance{display:flex;flex-wrap:wrap;gap:.25rem;align-items:baseline}
.palace-cell.teaching-fly-source{outline:3px solid rgba(133,112,140,.75);outline-offset:-4px;box-shadow:inset 0 0 0 2px rgba(255,255,255,.8)}
#tool-flystar.active{background:#5F5365!important;border-color:#4E4353!important}
@media (min-width:700px){.multiple-birth-guidance{flex-wrap:nowrap}}


/* V2.3.2 Alpha 3.6-fix16：多胞胎、校時、飛星與顯示控制 */
#multiple-birth-modal .multiple-birth-modal-card { width:min(760px, calc(100vw - 28px)) !important; }
#multiple-birth-modal label[for="multiple-birth-count"],
#multiple-birth-modal .multiple-birth-count-label { writing-mode:horizontal-tb !important; white-space:nowrap; }
#multiple-birth-modal .space-y-3 > .flex.flex-wrap { flex-wrap:nowrap; align-items:center; }
#multiple-birth-modal .space-y-3 > .flex.flex-wrap > label { flex-direction:row; white-space:nowrap; }
.multiple-birth-guidance { font-size:12px; line-height:1.55; align-items:baseline; }
.calibration-time-item { display:grid; grid-template-columns:18px minmax(0,1fr); gap:3px; padding:6px 3px; }
.calibration-time-item span { text-align:center; font-size:12px; }
.calibration-time-item strong { font-size:11px; overflow:visible; text-overflow:clip; white-space:nowrap; letter-spacing:-.15px; }
#dynamic-layer path { vector-effect:non-scaling-stroke; }
@media (max-width:640px) {
  #multiple-birth-modal .space-y-3 > .flex.flex-wrap { flex-wrap:wrap; }
  #multiple-birth-modal .multiple-birth-modal-card { width:calc(100vw - 18px) !important; }
  .calibration-time-item strong { font-size:10.5px; }
}


/* V2.3.2 Alpha 3.6-fix16：多胞胎操作列、拆分顯示與教學工具 */
.multiple-birth-top-row{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.multiple-birth-selectors{display:flex;align-items:center;gap:12px;flex-wrap:wrap;min-width:0;flex:1}
.multiple-birth-count-label{display:flex;align-items:center;gap:8px;white-space:nowrap}
.multiple-birth-inline-actions{display:flex;align-items:center;gap:8px;margin-left:auto}
#tool-selfhua.active{background:#5C7482;border-color:#4F6571;box-shadow:inset 0 0 0 1px rgba(255,255,255,.18)}
#bazi-section{min-width:0}
#bazi-columns,#dayun-list{max-width:100%}
@media(max-width:640px){
  .multiple-birth-top-row{align-items:flex-start}
  .multiple-birth-inline-actions{width:100%;justify-content:flex-end;margin-left:0}
  .multiple-birth-selectors{width:100%}
}


/* V2.3.2 Alpha 3.6-fix16：多胞胎按鈕、八字大運連動與教學飛星辨識 */
#multiple-birth-cancel-btn{
  min-width:88px;
  padding-left:18px!important;
  padding-right:18px!important;
  white-space:nowrap;
  flex:0 0 auto;
}
#multiple-birth-apply-btn{
  min-width:118px;
  padding-left:20px!important;
  padding-right:20px!important;
  white-space:nowrap;
  flex:0 0 auto;
}
.multiple-birth-inline-actions{flex-wrap:nowrap;min-width:max-content}
#dynamic-layer text{pointer-events:none}
@media(max-width:640px){
  #multiple-birth-cancel-btn{min-width:82px;padding-left:14px!important;padding-right:14px!important}
  #multiple-birth-apply-btn{min-width:110px;padding-left:16px!important;padding-right:16px!important}
}

/* fix17：三方／四正分離與多胞胎表單向下延伸 */
.palace-cell.active-three-basis{box-shadow:inset 0 0 0 3px rgba(126,103,78,.58)}
#three-four-layer{pointer-events:none}
#multiple-birth-modal .multiple-birth-modal-card{overflow:hidden;display:flex;flex-direction:column;max-height:min(88vh,780px)}
#multiple-birth-modal .multiple-birth-modal-card>.space-y-3{overflow-y:auto;overscroll-behavior:contain;padding-top:12px!important;padding-bottom:18px!important}
#multiple-birth-modal .multiple-birth-top-row{position:sticky;top:-12px;z-index:4;background:#fff;padding-top:12px;padding-bottom:10px;margin-bottom:0}
#multiple-birth-modal .multiple-birth-selectors{align-items:center}
#multiple-birth-modal #multiple-birth-summary{min-height:0;margin-top:2px}
#multiple-birth-modal .rounded-lg.border{margin-top:4px}
#multiple-birth-cancel-btn,#multiple-birth-apply-btn{white-space:nowrap;flex:none}
@media (min-width:700px){
 #multiple-birth-modal .multiple-birth-top-row{flex-wrap:nowrap}
 #multiple-birth-modal .multiple-birth-inline-actions{width:auto;justify-content:flex-end}
}


/* V2.3.2 Alpha 3.6-fix18：多胞胎模組結構重整與取消四正 */
#multiple-birth-modal .multiple-birth-modal-card{
  width:min(780px,calc(100vw - 28px))!important;
  max-height:min(88vh,780px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
#multiple-birth-modal .multiple-birth-modal-header,
#multiple-birth-modal .multiple-birth-fixed-controls{flex:0 0 auto;background:#fff}
#multiple-birth-modal .multiple-birth-fixed-controls{border-bottom:1px solid #eee7df}
#multiple-birth-modal .multiple-birth-top-row{position:static!important;top:auto!important;padding:0!important;margin:0!important;display:flex;align-items:center;gap:12px;flex-wrap:nowrap}
#multiple-birth-modal .multiple-birth-selectors{display:flex;align-items:center;gap:10px;flex:1 1 auto;min-width:0;flex-wrap:wrap}
#multiple-birth-modal .multiple-birth-inline-actions{display:flex;align-items:center;gap:8px;flex:0 0 auto;margin-left:auto;white-space:nowrap}
#multiple-birth-modal #multiple-birth-summary{margin-top:6px;min-height:14px}
#multiple-birth-modal .multiple-birth-scroll-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-top:12px;padding-bottom:18px!important}
#multiple-birth-modal .multiple-birth-editor-panel{margin:0!important}
#multiple-birth-modal .multiple-birth-guidance{margin:0 0 10px 0!important}
#multiple-birth-modal #multiple-birth-member-editor{align-content:start}
#multiple-birth-modal .multiple-birth-member-row:last-child{margin-bottom:2px}
@media(max-width:699px){
  #multiple-birth-modal .multiple-birth-modal-card{width:calc(100vw - 18px)!important;max-height:92vh}
  #multiple-birth-modal .multiple-birth-top-row{flex-wrap:wrap}
  #multiple-birth-modal .multiple-birth-selectors{width:100%;flex-basis:100%}
  #multiple-birth-modal .multiple-birth-inline-actions{width:100%;justify-content:flex-end;margin-left:0}
}

/* ═══ fix27：淨空中宮 ═══
   只讓中宮的文字內容不可見，方框、格線與版面高度全部維持原狀。
   刻意使用 visibility 而非 display:none —— 中宮方框的實際矩形是
   向心自化夾制與箭頭端點的計算基準，用 display:none 會讓內容抽離
   而改變 .center-board 的量測結果。校時面板仍可正常開啟使用。 */
.ziwei-board.center-blank .center-board .center-summary,
.ziwei-board.center-blank .center-board #bazi-section,
.ziwei-board.center-blank .center-board #xchexp-bazi-section {
    visibility: hidden !important;
}

/* ═══ fix32：流運快選列（橫式、可鎖定置頂）═══
   主工具列位於頁面上方，切換流月／流日時必須往回捲，手機與平板尤其不便。
   這一列把五個流運選單以橫式排在最上方，每個都附上一步鍵；按「鎖定」後
   改為 position:fixed 常駐畫面頂端，並以等高佔位元素補回文件流高度。 */
.flow-dock {
    width: 100%;
    /* 快選列可比主面板略寬，桌機才不必橫捲 */
    max-width: min(64rem, calc(100vw - 16px));
    margin: 0 auto 6px;
    background: #FFFFFF;
    border: 1px solid #E7E2DD;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(120, 110, 100, 0.08);
    z-index: 45;
}
.flow-dock.is-locked {
    position: fixed;
    top: 4px;
    width: min(64rem, calc(100vw - 16px));
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 4px 14px rgba(120, 110, 100, 0.18);
}
.flow-dock-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding: 5px 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.flow-dock-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    padding-right: 4px;
    border-right: 1px solid #F0EBE6;
}
.flow-dock-group:last-of-type { border-right: none; }
.flow-dock-label {
    font-size: 11px;
    font-weight: 800;
    color: #8A837E;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.flow-dock-select {
    font-size: 12px;
    font-weight: 700;
    color: #6F6863;
    background: #FAF8F6;
    border: 1px solid #E7E2DD;
    border-radius: 6px;
    padding: 4px 2px;
    min-width: 54px;
    text-align: center;
    text-align-last: center;
}
.flow-dock-select-wide { min-width: 78px; }
.flow-dock-select:disabled { opacity: 0.45; }
/* 觸控目標維持 30px 以上，手機單手也點得到 */
.flow-dock-nav,
.flow-dock-btn {
    min-width: 28px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 4px;
    font-size: 12px;
    font-weight: 700;
    color: #6F6863;
    background: #F3EFEB;
    border: 1px solid #E7E2DD;
    border-radius: 6px;
    cursor: pointer;
}
.flow-dock-nav:hover,
.flow-dock-btn:hover { background: #E9E3DD; }
.flow-dock-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 6px;
}
.flow-dock-lock[aria-pressed="true"] {
    background: #6A937C;
    border-color: #5D8570;
    color: #FFFFFF;
}
#flow-dock-spacer { width: 100%; height: 0; }

@media (max-width: 780px) {
    .flow-dock { border-radius: 8px; margin-bottom: 4px; }
    .flow-dock.is-locked { top: 0; left: 0; transform: none; max-width: 100%; border-radius: 0; }
    .flow-dock-inner { gap: 4px; padding: 4px 6px; }
    .flow-dock-label { font-size: 10px; }
    .flow-dock-select { font-size: 11px; min-width: 54px; padding: 4px 2px; }
    .flow-dock-select-wide { min-width: 74px; }
    .flow-dock-actions { margin-left: 6px; }
}


/* V2.3.2 Alpha 3.6-fix34：日曆比較盤、星組與教學三合快捷列 */
.toolbar-collapse-strip{display:flex;gap:8px;align-items:center;justify-content:space-between}.compare-toolbar-actions{display:flex;gap:6px;flex-wrap:wrap}.compare-action-btn{width:auto;padding:6px 10px}.custom-star-panel{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px;padding:8px;border:1px solid #e7e5e4;border-radius:8px;background:#fafaf9}.custom-star-panel.hidden{display:none}.custom-star-panel label{font-size:11px;font-weight:700;color:#625b56;border:1px solid #ddd6d0;border-radius:6px;padding:4px 7px;background:white;white-space:nowrap}.compare-workspace{width:100%;max-width:1400px;display:flex;flex-direction:column;gap:10px;align-items:center}.compare-primary{min-width:0}.compare-secondary{width:100%;min-width:0;border:1px solid #d6d3d1;border-radius:10px;background:white;overflow:hidden}.compare-secondary-header{height:36px;display:flex;align-items:center;justify-content:space-between;padding:0 10px;background:#f5f5f4;color:#625b56;font-size:12px}.compare-secondary-header button{font-size:11px;font-weight:700}.compare-secondary iframe{display:block;width:100%;height:min(78vw,840px);border:0;background:white}.compare-workspace.is-side-by-side{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:start}.compare-workspace.is-side-by-side .compare-primary,.compare-workspace.is-side-by-side .compare-secondary{width:100%}.compare-workspace.layout-locked{touch-action:none;overscroll-behavior:contain}.calendar-compare-modal{position:fixed;inset:0;z-index:90;display:flex;align-items:flex-start;justify-content:center;padding:7vh 12px 12px;background:rgba(0,0,0,.42)}.calendar-compare-modal.hidden{display:none}.calendar-compare-card{width:min(620px,100%);border-radius:14px;background:white;box-shadow:0 18px 50px rgba(0,0,0,.3);overflow:hidden}.calendar-compare-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #e7e5e4;color:#625b56}.calendar-compare-header h2{font-weight:800}.calendar-compare-body{padding:14px}.calendar-compare-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.calendar-compare-fields label{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:700;color:#625b56}.calendar-compare-fields label.wide{grid-column:1/-1}.calendar-compare-fields input,.calendar-compare-fields select{min-width:0;flex:1;border:1px solid #d6d3d1;border-radius:6px;padding:7px;background:white}.calendar-compare-fields .check input{flex:0 0 auto}.calendar-compare-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}.calendar-compare-actions button{border:1px solid #a8a29e;border-radius:6px;padding:7px 12px;font-size:12px;font-weight:800;color:#625b56}.calendar-compare-actions button.primary{background:#6a937c;color:white;border-color:#6a937c}.compare-embedded{padding:4px!important}.compare-embedded #flow-dock,.compare-embedded #flow-dock-spacer,.compare-embedded .toolbar-collapse-strip,.compare-embedded #main-control-panel,.compare-embedded #teaching-toolbar,.compare-embedded #pinned-project-sidebar,.compare-embedded footer,.compare-embedded body>div[aria-label="網站品牌"],.compare-embedded .compare-toolbar-actions{display:none!important}.compare-embedded #capture-area{margin-top:0!important}.compare-embedded #ziwei-board{max-width:100%!important}
@media(max-width:900px){.compare-workspace.is-side-by-side{grid-template-columns:1fr}.compare-secondary iframe{height:900px}}
@media(max-width:560px){.toolbar-collapse-strip{align-items:stretch;flex-direction:column}.compare-toolbar-actions{width:100%}.compare-action-btn{flex:1}.calendar-compare-fields{grid-template-columns:1fr}.calendar-compare-fields label.wide{grid-column:auto}}

.compare-embedded > div[aria-label="網站品牌"]{display:none!important}
/* V2.3.2 Alpha 3.6-fix35：比較盤快速日期碼 */
.teaching-sanhe-wrap{position:relative;display:inline-flex}.compare-quick-label{display:block;font-size:12px;font-weight:800;color:#625b56;margin-bottom:6px}.compare-quick-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}.compare-quick-row input{min-width:0;border:2px solid #b9aea6;border-radius:8px;padding:11px 12px;font-size:18px;font-weight:800;letter-spacing:.08em;font-variant-numeric:tabular-nums}.compare-quick-row button,.compare-shortcuts button{border:1px solid #a8a29e;border-radius:7px;padding:8px 12px;font-size:12px;font-weight:800;color:#625b56;background:white}.compare-quick-row button.primary{background:#6a937c;color:white;border-color:#6a937c}.compare-quick-help{margin-top:6px;font-size:11px;line-height:1.5;color:#78716c}.compare-quick-error{margin-top:7px;padding:7px 9px;border:1px solid #efc7c5;border-radius:7px;background:#fdf5f5;color:#a9504c;font-size:12px;font-weight:700}.compare-shortcuts{display:flex;gap:7px;margin-top:11px}.compare-advanced{margin-top:12px;padding-top:12px;border-top:1px solid #e7e5e4}.compare-embedded #calendar-compare-modal,.compare-embedded #compare-secondary{display:none!important}.compare-embedded #compare-workspace{display:block!important}.compare-embedded #capture-area{width:100%!important}
@media(max-width:560px){.calendar-compare-modal{padding-top:3vh}.compare-quick-row{grid-template-columns:1fr}.compare-quick-row input{font-size:16px}.compare-quick-row button{width:100%}.compare-shortcuts button{flex:1}}

/* fix39：單盤工具列／命盤並排與可鎖定版面 */
.main-work-layout{width:100%;max-width:1400px;display:flex;flex-direction:column;align-items:center;gap:10px}
.work-layout-controls{width:100%;display:flex;flex-direction:column;align-items:center;min-width:0}
.work-layout-chart{width:100%;min-width:0}
.main-work-layout.is-side-layout .work-layout-controls>.max-w-4xl,.main-work-layout.is-side-layout #main-control-panel,.main-work-layout.is-side-layout #teaching-toolbar{max-width:none;width:100%}
.main-work-layout.is-side-layout .work-layout-chart{align-self:start}
.main-work-layout.is-side-layout.is-layout-locked .work-layout-controls{resize:none;overflow:hidden}
.main-work-layout.is-layout-locked{user-select:none}
#compare-layout-lock.active{background:#6a937c;color:#fff;border-color:#5c7d6a}

/* fix39：三合展開列，以畫圈至清除框線作為左右邊界 */


.teaching-flow-dock-host{width:100%}
.teaching-flow-dock-host .flow-dock{display:block!important;position:static!important;transform:none!important;left:auto!important;top:auto!important;width:100%;max-width:none;margin:0;border-radius:6px;box-shadow:none}
.teaching-flow-dock-host .flow-dock-inner{width:100%;justify-content:space-between;overflow-x:auto}
.teaching-sanhe-quick-row{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:4px;width:100%}
.teaching-sanhe-quick-row button{border:1px solid #a39a94;border-radius:5px;background:#f7f5f3;color:#5f5854;font-size:11px;font-weight:800;padding:5px 2px;white-space:nowrap}
#flow-dock:not(.inside-sanhe){display:none}
#flow-dock-spacer{display:none!important}

/* fix39：比較盤固定左右並列且上緣對齊 */
.compare-workspace.has-compare{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:start;gap:10px}
.compare-workspace.has-compare .compare-primary,.compare-workspace.has-compare .compare-secondary{width:100%;margin-top:0!important;align-self:start}
.compare-secondary{margin-top:0}
.compare-secondary iframe{height:min(70vw,820px)}

/* fix39：獨立日曆 */
.calendar-only-card{width:min(720px,100%)}
.calendar-query-row{display:grid;grid-template-columns:auto minmax(160px,1fr) auto;gap:8px;align-items:center;margin-bottom:10px}
.calendar-query-row button{border:1px solid #a8a29e;border-radius:6px;padding:7px 10px;font-size:12px;font-weight:800;color:#625b56;background:#fff}
.calendar-query-row input{border:1px solid #d6d3d1;border-radius:6px;padding:7px;background:#fff}
.calendar-query-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));border-top:1px solid #e7e5e4;border-left:1px solid #e7e5e4}
.calendar-query-grid .cal-head,.calendar-query-grid button{min-height:58px;border:0;border-right:1px solid #e7e5e4;border-bottom:1px solid #e7e5e4;background:#fff;padding:5px;text-align:left}
.calendar-query-grid .cal-head{min-height:auto;text-align:center;font-size:11px;font-weight:800;background:#f5f5f4;color:#625b56}
.calendar-query-grid button{font-size:12px;color:#4a4542;cursor:pointer}
.calendar-query-grid button:hover,.calendar-query-grid button.selected{background:#f0ebe6}
.calendar-query-grid button.other-month{opacity:.35}
.calendar-query-grid .lunar{display:block;margin-top:4px;font-size:10px;color:#85708c;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.calendar-selected-info{margin-top:10px;border-radius:8px;background:#fafaf9;border:1px solid #e7e5e4;padding:9px 10px;font-size:12px;color:#625b56;line-height:1.6}

/* fix39：比較盤各自宮職／四化切換工具列 */
.compare-pane{min-width:0}.compare-primary-pane{width:100%;min-width:0}.compare-pane-flowbar{box-sizing:border-box;width:100%;margin:0 0 6px;padding:6px;border:1px solid #d6d3d1;border-radius:9px;background:#fafaf9;box-shadow:0 2px 7px rgba(74,69,66,.08)}
.compare-pane-flowbar.hidden{display:none}.compare-layer-row{display:grid;grid-template-columns:52px repeat(5,minmax(0,1fr));gap:4px;margin-bottom:4px}.compare-layer-title,.compare-layer-row button{min-height:29px;display:flex;align-items:center;justify-content:center;border:1px solid #cfc8c3;border-radius:5px;font-size:11px;font-weight:800;color:#625b56;background:white}.compare-layer-title{background:#eee9e5;color:#514b47}.compare-layer-row button.is-active{border-color:#6a937c;background:#e9f2ed;color:#466a58;box-shadow:inset 0 0 0 1px #6a937c}.compare-layer-row button[data-kind="sihua"].is-active{border-color:#85708c;background:#f1edf3;color:#66536e;box-shadow:inset 0 0 0 1px #85708c}.compare-step-row{display:grid;grid-template-columns:42px minmax(0,1fr) 42px;gap:4px;margin-left:56px}.compare-step-row button,.compare-step-value{min-height:29px;display:flex;align-items:center;justify-content:center;border:1px solid #cfc8c3;border-radius:5px;background:white;color:#625b56;font-size:11px;font-weight:800}.compare-step-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 6px;background:#f7f5f3}.compare-secondary-header{border-radius:9px 9px 0 0}.compare-secondary iframe{border-top:1px solid #ebe7e4}.compare-workspace.has-compare .compare-primary-pane,.compare-workspace.has-compare .compare-secondary{align-self:start}.compare-workspace.has-compare #capture-area{margin-top:0!important}.compare-workspace.has-compare{align-items:start}.compare-workspace.has-compare .compare-primary-pane{display:flex;flex-direction:column}.compare-workspace.has-compare .compare-secondary{display:flex;flex-direction:column}.compare-embedded .compare-pane-flowbar{display:none!important}
@media(max-width:900px){.compare-layer-row{grid-template-columns:46px repeat(5,minmax(0,1fr));gap:3px}.compare-step-row{margin-left:49px}.compare-pane-flowbar{padding:5px}}

/* fix39：紫微＋八字比較盤 */
.compare-mode-switch{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;padding:4px;border:1px solid #ddd6d0;border-radius:9px;background:#f7f5f3}.compare-mode-switch button{border:1px solid transparent;border-radius:6px;padding:8px;font-size:12px;font-weight:800;color:#625b56}.compare-mode-switch button.is-active{border-color:#6a937c;background:#fff;color:#466a58;box-shadow:0 1px 5px rgba(74,69,66,.12)}.compare-bazi-note{margin:8px 0 12px;padding:10px;border:1px solid #d8e5dd;border-radius:8px;background:#f2f8f4;color:#52695b;font-size:12px;font-weight:700}.compare-bazi-panel{display:flex;flex-direction:column;gap:8px;width:100%;padding:10px;background:#fff;overflow:auto}.compare-bazi-panel.hidden{display:none}.compare-secondary.is-bazi #compare-secondary-flowbar,.compare-secondary.is-bazi #compare-chart-frame{display:none!important}.compare-secondary.is-bazi .compare-bazi-panel{display:flex}.bazi-compare-meta{display:flex;justify-content:space-between;gap:8px;align-items:center;padding:7px 9px;border:1px solid #ddd6d0;border-radius:7px;background:#fafaf9;color:#625b56;font-size:11px}.bazi-compare-table{display:grid;grid-template-columns:50px repeat(4,minmax(0,1fr));border-top:1px solid #cfc8c3;border-left:1px solid #cfc8c3}.bazi-compare-cell{min-height:34px;padding:5px 3px;border-right:1px solid #cfc8c3;border-bottom:1px solid #cfc8c3;display:flex;align-items:center;justify-content:center;text-align:center;font-size:11px;line-height:1.35;color:#514b47;background:#fff;word-break:break-word}.bazi-compare-cell.head,.bazi-compare-cell.label{background:#eee9e5;font-weight:800}.bazi-compare-cell.pillar{font-size:20px;font-weight:900;letter-spacing:.08em}.bazi-compare-cell.shensha{font-size:10px;align-items:flex-start;min-height:62px}.wx-wood{color:#2f8a4b!important}.wx-fire{color:#cf3f35!important}.wx-earth{color:#ad7627!important}.wx-metal{color:#8a7b55!important}.wx-water{color:#2671a8!important}.bazi-dayun-wrap{border:1px solid #d6d3d1;border-radius:8px;overflow:hidden}.bazi-dayun-title,.bazi-liunian-title{padding:7px 9px;background:#eee9e5;color:#514b47;font-size:12px;font-weight:900}.bazi-dayun-grid,.bazi-liunian-grid{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(58px,1fr);overflow-x:auto}.bazi-dayun-item,.bazi-liunian-item{display:grid;grid-template-rows:repeat(3,minmax(28px,auto));border-right:1px solid #ddd6d0;background:#fff;cursor:pointer}.bazi-dayun-item span,.bazi-liunian-item span{display:flex;align-items:center;justify-content:center;padding:4px 2px;border-bottom:1px solid #eee9e5;font-size:10px;white-space:nowrap}.bazi-dayun-item span:first-child,.bazi-liunian-item span:first-child{font-size:15px;font-weight:900}.bazi-dayun-item.is-active,.bazi-liunian-item.is-active{background:#eaf3ed;box-shadow:inset 0 0 0 2px #6a937c}.bazi-liunian-wrap{border-top:1px solid #d6d3d1}.bazi-liunian-grid{grid-auto-columns:minmax(56px,1fr)}@media(max-width:900px){.compare-workspace.has-compare{grid-template-columns:1fr}.compare-bazi-panel{max-height:none}.bazi-compare-cell{font-size:10px}.bazi-compare-cell.pillar{font-size:18px}}


/* fix39：並排自適應、橫式收合、工具列與盤面同步 */
.main-work-layout.is-side-layout{grid-template-columns:clamp(280px,26vw,380px) 0 minmax(0,1fr)!important;gap:10px!important}
.main-work-layout.is-side-layout .work-layout-controls{width:auto!important;min-width:0!important;max-width:none!important;resize:none!important;overflow:auto!important}
.main-work-layout.is-side-layout .work-layout-divider{display:none!important}
.work-controls-collapse{display:none;position:sticky;top:8px;z-index:81;width:22px;height:54px;align-self:start;border:1px solid #cfc8c3;border-radius:0 7px 7px 0;background:#fff;color:#625b56;font-weight:900;box-shadow:0 2px 8px rgba(0,0,0,.12)}
.main-work-layout.is-side-layout>.work-controls-collapse{display:block;margin-left:-10px}
.main-work-layout.is-side-layout.controls-collapsed{grid-template-columns:0 22px minmax(0,1fr)!important;gap:0!important}
.main-work-layout.is-side-layout.controls-collapsed .work-layout-controls{width:0!important;min-width:0!important;overflow:hidden!important;visibility:hidden}
.main-work-layout.is-side-layout #teaching-toolbar{width:100%;max-width:none;margin:0 0 7px!important}
/* fix49：改為上下兩層，原單排橫捲規則停用 */
.teaching-toolbar-single-row>*{flex:0 0 auto}

.teaching-flow-dock-host .flow-dock-inner{overflow-x:hidden!important;gap:2px}
.teaching-flow-dock-host .flow-dock-label{display:none!important}
.teaching-flow-dock-host .flow-dock-group{min-width:0!important;gap:1px!important}
.teaching-flow-dock-host .flow-dock-select{font-size:10px!important;padding:3px 1px!important;min-width:0!important}
.teaching-flow-dock-host .flow-dock-nav{width:20px!important;min-width:20px!important;padding:0!important}
.compare-workspace.has-compare{grid-template-columns:minmax(0,65fr) minmax(300px,35fr)!important;gap:8px!important}
.compare-workspace.has-compare #capture-area{width:100%!important;max-width:100%!important;transform:none!important;margin-left:0!important;margin-right:0!important}
.compare-secondary.is-bazi{min-width:0}
.bazi-compare-cell.pillar,.gz-stack{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;gap:1px}
.bazi-compare-cell.pillar .gz-gan,.bazi-compare-cell.pillar .gz-zhi,.gz-stack .gz-gan,.gz-stack .gz-zhi{font-size:20px!important;line-height:1.05!important;font-weight:900!important}
.bazi-dayun-item,.bazi-liunian-item{grid-template-rows:minmax(48px,auto) minmax(26px,auto) minmax(26px,auto)!important}
.bazi-dayun-item span:first-child,.bazi-liunian-item span:first-child{font-size:inherit!important}
.calendar-query-row-v39{grid-template-columns:repeat(6,auto) minmax(95px,1fr) minmax(78px,.7fr) auto!important}
.calendar-picker{display:grid;grid-template-columns:repeat(4,1fr);gap:5px;margin:-3px 0 10px;padding:8px;border:1px solid #d6d3d1;border-radius:7px;background:#fafaf9}
.calendar-picker.hidden{display:none}.calendar-picker button{border:1px solid #cfc8c3;border-radius:5px;background:#fff;padding:6px;font-size:11px;font-weight:800}
@media(max-width:900px) and (orientation:landscape){.main-work-layout.is-side-layout{grid-template-columns:34vw 0 minmax(0,1fr)!important}.compare-workspace.has-compare{grid-template-columns:minmax(0,62fr) minmax(260px,38fr)!important}}
@media(max-width:700px) and (orientation:portrait){.main-work-layout.is-side-layout{grid-template-columns:1fr!important}.work-controls-collapse{display:none!important}.compare-workspace.has-compare{grid-template-columns:1fr!important}.calendar-query-row-v39{grid-template-columns:repeat(3,1fr)!important}}

/* ===== fix43 consolidated layout rules ===== */
/* fix49：改為上下兩層，原單排橫捲規則停用 */

#main-work-layout.is-side-layout{grid-template-columns:minmax(240px,25%) 22px minmax(0,75%)!important}#main-work-layout.is-side-layout.controls-collapsed{grid-template-columns:0 22px minmax(0,1fr)!important}
.bazi-section-head,.bazi-dayun-wrap>.bazi-dayun-title+#bazi-dayun-pager{display:flex;align-items:center;justify-content:space-between}.bazi-dayun-wrap>.bazi-dayun-title{display:inline-flex}.bazi-dayun-wrap{position:relative}.bazi-dayun-wrap>#bazi-dayun-pager{position:absolute;right:6px;top:4px}
.bazi-pager{display:flex;align-items:center;gap:5px;font-size:10px;font-weight:800}.bazi-pager button{min-width:26px;border:1px solid #cfc8c3;border-radius:5px;background:#fff;padding:3px}.bazi-pager button:disabled{opacity:.35}
.bazi-dayun-grid,.bazi-liunian-grid{grid-auto-flow:unset!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;overflow:visible!important}.bazi-dayun-item,.bazi-liunian-item{min-width:0}.gz-stack{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important}.gz-gan,.gz-zhi{font-size:18px!important;line-height:1.15!important;font-weight:900!important}
.compare-workspace.has-compare{display:grid;grid-template-columns:minmax(0,65fr) minmax(300px,35fr);align-items:start}.compare-workspace.has-compare .compare-primary,.compare-workspace.has-compare .compare-secondary{width:100%;min-width:0}
@media(max-width:1199px){#main-work-layout.is-side-layout{grid-template-columns:34px minmax(0,1fr)!important}.compare-workspace.has-compare{grid-template-columns:minmax(0,64fr) minmax(280px,36fr)}}
@media(max-width:899px){.compare-workspace.has-compare{grid-template-columns:1fr!important}}


/* fix43 canonical teaching sanhe layout */
.teaching-sanhe-panel {
    position: static;
    inset: auto;
    transform: none;
    z-index: auto;
    display: grid;
    grid-template-columns: repeat(8, minmax(38px, 1fr));
    gap: 4px;
    width: 100%;
    max-width: none;
    margin: 5px 0 0;
    padding: 5px;
    border-radius: 8px;
    background: rgba(74, 69, 66, .98);
    box-shadow: none;
}
.teaching-sanhe-panel.hidden { display: none; }
.teaching-sanhe-panel button {
    min-width: 0;
    border: 1px solid #a39a94;
    border-radius: 5px;
    background: #f7f5f3;
    color: #5f5854;
    font-size: 11px;
    font-weight: 800;
    padding: 5px 3px;
}
@media (max-width: 899px) {
    .teaching-sanhe-panel { grid-template-columns: repeat(4, minmax(42px, 1fr)); }
}

/* fix44：向心自化飛星短線模式 */
.self-flystar-mode-button.is-active{background:#766e6a!important;color:#fff!important;border-color:#5f5752!important;box-shadow:inset 0 0 0 1px rgba(255,255,255,.18)}

/* fix44 第一階段：並排、三合浮動、比較盤、日曆與八字版面 */
#main-work-layout.is-side-layout{display:grid!important;grid-template-columns:clamp(280px,28vw,390px) 22px minmax(0,1fr)!important;align-items:start!important;gap:8px!important;max-width:1500px}
#main-work-layout.is-side-layout .work-layout-controls{width:100%!important;min-width:0!important;max-width:none!important;overflow:auto!important;resize:none!important}
#main-work-layout.is-side-layout .work-layout-chart{min-width:0;width:100%;align-self:start}
#main-work-layout.is-side-layout.controls-collapsed{grid-template-columns:0 22px minmax(0,1fr)!important;gap:0!important}
#main-work-layout.is-side-layout.controls-collapsed .work-layout-controls{width:0!important;visibility:hidden;overflow:hidden!important}
#main-work-layout.is-side-layout .work-layout-divider{display:none!important}
#main-work-layout.is-side-layout>.work-controls-collapse{display:block!important}
@media(max-width:700px) and (orientation:portrait){#main-work-layout.is-side-layout,#main-work-layout.is-side-layout.controls-collapsed{display:flex!important;flex-direction:column!important;gap:10px!important}#main-work-layout.is-side-layout .work-layout-controls,#main-work-layout.is-side-layout.controls-collapsed .work-layout-controls{width:100%!important;visibility:visible!important;overflow:visible!important}.work-controls-collapse{display:none!important}}

#teaching-toolbar{position:relative;z-index:45}
.teaching-sanhe-panel{position:absolute!important;left:0!important;right:0!important;bottom:calc(100% + 8px)!important;top:auto!important;width:100%!important;max-width:none!important;z-index:70!important;display:grid;grid-template-columns:1fr;gap:8px;padding:10px;border:1px solid #a39a94;border-radius:10px;background:#fff;box-shadow:0 12px 28px rgba(61,54,50,.24)}
.teaching-sanhe-panel.hidden{display:none!important}
.teaching-sanhe-panel-head{display:flex;align-items:center;justify-content:space-between;color:#5f5854;font-size:12px}.teaching-sanhe-panel-head button{width:28px;height:28px;border:1px solid #cfc8c3;border-radius:6px;background:#f7f5f3}
.teaching-sanhe-quick-row{grid-template-columns:repeat(8,minmax(42px,1fr))!important}

.compare-workspace.has-compare.is-ziwei-compare{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
.compare-workspace.has-compare.is-ziwei-compare .compare-primary-pane,.compare-workspace.has-compare.is-ziwei-compare .compare-secondary{width:100%!important;min-width:0!important}
.compare-workspace.has-compare.is-ziwei-compare #capture-area{width:100%!important;max-width:none!important}
.compare-secondary-header{height:auto!important;min-height:38px;gap:8px;flex-wrap:wrap;padding:5px 8px!important}
.compare-secondary-actions{display:flex;align-items:center;justify-content:flex-end;gap:4px;flex-wrap:wrap}.compare-secondary-actions button{padding:4px 7px;border:1px solid #cfc8c3;border-radius:5px;background:#fff;color:#625b56;font-size:10px;font-weight:800}.compare-secondary-actions button.is-active{border-color:#6a937c;background:#e9f2ed;color:#466a58}.compare-secondary-actions button:disabled{opacity:.45;cursor:not-allowed}.compare-secondary-actions .compare-close{border-color:#d8aaa7;color:#9c4f4b}
@media(max-width:700px) and (orientation:portrait){.compare-workspace.has-compare.is-ziwei-compare{grid-template-columns:1fr!important}}

.calendar-query-row-v44{display:grid;grid-template-columns:1fr;gap:8px}.calendar-step-group{display:grid;grid-template-columns:72px minmax(0,1fr) 72px;gap:6px}.calendar-step-group button,.calendar-step-group input,.calendar-jump-group button,.calendar-jump-group input{min-height:34px;border:1px solid #cfc8c3;border-radius:6px;background:#fff;padding:5px 8px;font-size:12px;font-weight:700;color:#625b56}.calendar-step-group button:nth-child(2){font-size:14px}.calendar-jump-group{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px}.calendar-input-error{padding:7px 9px;border:1px solid #efc7c5;border-radius:6px;background:#fdf5f5;color:#a9504c;font-size:11px;font-weight:700}.calendar-input-error.hidden{display:none}.calendar-jump-group input.is-error{border-color:#c45b56;box-shadow:0 0 0 1px #c45b56}

.compare-bazi-panel{overflow:visible!important}.bazi-column-labels{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;font-size:9px;color:#7c736d;text-align:center}.bazi-pillar-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid #cfc8c3;border-radius:8px;overflow:hidden}.bazi-pillar-card{display:grid;grid-template-rows:30px 50px 72px 58px minmax(92px,auto) minmax(54px,auto) 36px 34px;align-items:stretch;text-align:center;border-right:1px solid #cfc8c3;background:#fff;min-width:0}.bazi-pillar-card:last-child{border-right:0}.bazi-pillar-card>div{display:flex;align-items:center;justify-content:center;padding:4px 2px;border-bottom:1px solid #e7e5e4;min-width:0}.bazi-pillar-card>div:last-child{border-bottom:0}.bazi-pillar-name{background:#eee9e5;font-size:12px;font-weight:900;color:#514b47}.bazi-ten-vertical{display:inline-flex!important;flex-direction:column;line-height:1.05;font-size:12px;font-weight:800;color:#625b56}.bazi-ten-vertical.small{font-size:10px;min-width:18px}.bazi-main-gz{flex-direction:column;font-size:20px;font-weight:900;line-height:1.25}.bazi-zhi-ten-list{display:flex!important;align-items:center!important;gap:4px!important}.bazi-hidden-list{display:flex!important;flex-direction:column;gap:3px}.bazi-hidden-pair{display:grid;grid-template-columns:22px minmax(0,1fr);align-items:center;gap:4px;width:100%;font-size:10px}.bazi-hidden-gan{font-size:13px;font-weight:900}.bazi-hidden-ten{color:#625b56}.bazi-shensha-list{display:flex!important;flex-direction:column;align-items:center!important;justify-content:flex-start!important;gap:2px;font-size:10px;line-height:1.25;overflow-wrap:anywhere}.bazi-nayin,.bazi-kong{font-size:11px;font-weight:700}.bazi-empty{color:#aaa29c;font-weight:400}.bazi-section-head{display:flex;align-items:center;justify-content:space-between;min-height:38px;padding:0 8px;background:#eee9e5}.bazi-section-head .bazi-dayun-title,.bazi-section-head .bazi-liunian-title{padding:0!important;background:none!important}.bazi-dayun-grid{grid-template-columns:repeat(5,minmax(0,1fr));grid-auto-flow:row!important;grid-auto-columns:auto!important;overflow:hidden!important}.bazi-liunian-grid{grid-template-columns:repeat(10,minmax(54px,1fr));grid-auto-flow:row!important;grid-auto-columns:auto!important;overflow-x:auto!important}.bazi-dayun-item,.bazi-liunian-item{grid-template-rows:minmax(54px,auto) 28px 28px!important}.bazi-dayun-item span:first-child,.bazi-liunian-item span:first-child{font-size:20px!important}.gz-stack{display:flex!important;flex-direction:column!important;line-height:1.1}.bazi-liunian-count{font-size:10px;font-weight:700;color:#78716c}
@media(max-width:700px){.bazi-pillar-card{grid-template-rows:28px 46px 68px 54px minmax(88px,auto) minmax(50px,auto) 34px 32px}.bazi-dayun-item span:first-child,.bazi-liunian-item span:first-child{font-size:18px!important}.bazi-liunian-grid{grid-template-columns:repeat(10,minmax(50px,1fr))}}

/* fix44：八字神煞橫式分層顯示。四柱以實際最大命中數補齊空列，確保納音與空亡對齊。 */
.bazi-shensha-list{font-size:11px!important;line-height:1.35!important;gap:3px!important;padding-top:6px!important;padding-bottom:6px!important}
.bazi-shensha-item,.bazi-shensha-placeholder{display:block;width:100%;min-height:15px;text-align:center;white-space:nowrap;font-weight:700}
.bazi-shensha-item.level-blue{color:#2875a8}
.bazi-shensha-item.level-red{color:#c4473e}
.bazi-shensha-item.level-plain{color:#625b56}
.bazi-shensha-placeholder{visibility:hidden}

/* fix44：匯出前依宮內負載切換密度，底欄保持固定，不讓星曜與四化侵入。 */
/* fix49：匯出宮格不可裁切。
   html2canvas 1.4.1 的基線比瀏覽器低約 11px（1280px 版面），底欄最後一列
   （大限起歲／宮職／宮干支）會被推到宮格邊界外；一旦 overflow:hidden，
   那一列就被切掉。實測末列文字帶只剩 26px，完整應為 42px。
   fix28 已將此處改為 visible，但 fix46 這行 !important 又把它蓋回去。
   宮格另有 padding-bottom: calc(10px * --sscale) 的安全邊界，不會溢出到隔壁宮。 */
.ziwei-board.export-mode .palace-cell{overflow:visible!important}
.ziwei-board.export-mode .palace-stars-area{box-sizing:border-box;overflow:hidden!important;padding-bottom:52px!important}
/* fix49：匯出時底欄高度不可寫死。
   原本 height:50px!important 是未經縮放的螢幕值，但匯出模式 --sscale=1.892，
   底欄自身的格線需要 calc(9px+17px*3)*1.892 = 113.5px。
   結果底欄盒子只有 50px、內容溢出 64px 掉到宮格外面，
   匯出圖上宮職與宮干支整排消失（實測宮職落在 y=352，而宮格底部在 318）。
   改為跟著 --footer-h 走，並保留原本的絕對定位與白底。 */
.ziwei-board.export-mode .palace-footer{position:absolute!important;left:0!important;right:0!important;bottom:calc(11px * var(--sscale,1))!important;height:var(--footer-h)!important;min-height:var(--footer-h)!important;z-index:8!important;background:#fff!important;overflow:visible!important}
.ziwei-board.export-mode .palace-cell.export-density-standard .star-text{font-size:inherit}
.ziwei-board.export-mode .palace-cell.export-density-dense .star-text{font-size:92%!important;line-height:1.08!important}
.ziwei-board.export-mode .palace-cell.export-density-ultra .star-text{font-size:84%!important;line-height:1.02!important;letter-spacing:-.03em!important}
.ziwei-board.export-mode .palace-cell.export-density-dense .sihua-badge,
.ziwei-board.export-mode .palace-cell.export-density-dense .sihua-marker,
.ziwei-board.export-mode .palace-cell.export-density-dense .transform-marker{transform:scale(.9);transform-origin:center}
.ziwei-board.export-mode .palace-cell.export-density-ultra .sihua-badge,
.ziwei-board.export-mode .palace-cell.export-density-ultra .sihua-marker,
.ziwei-board.export-mode .palace-cell.export-density-ultra .transform-marker{transform:scale(.8);transform-origin:center}
.ziwei-board.export-mode .sihua-slot{display:flex!important;flex-wrap:wrap!important;align-content:flex-start!important;justify-content:center!important;gap:1px!important;max-width:100%!important}
.ziwei-board.export-mode .sihua-slot>*{flex:0 0 auto!important}

/* fix44：自訂星系可由同一按鈕展開／收合 */
.custom-star-toggle{cursor:pointer;user-select:none}
.custom-star-chevron{display:inline-block;margin-left:2px;font-size:10px;line-height:1;transition:transform .18s ease}
.custom-star-toggle.is-open .custom-star-chevron{transform:rotate(180deg)}

/* fix44 第二階段：主要星曜／輔雜曜分區 */
.palace-stars-area{position:relative}
.minor-stars-container{
    position:absolute;
    left:calc(var(--metaw) + 2px);
    right:3px;
    top:58%;
    bottom:3px;
    display:flex;
    flex-direction:row-reverse;
    align-content:flex-start;
    justify-content:flex-start;
    flex-wrap:wrap;
    gap:calc(2px * var(--sscale,1)) calc(4px * var(--sscale,1));
    overflow:hidden;
    pointer-events:none;
}
.minor-star-item{
    display:inline-flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    flex:0 0 calc(11px * var(--sscale,1));
    width:calc(11px * var(--sscale,1));
    font-size:calc(10px * var(--sscale,1));
    line-height:1.05;
    font-weight:600;
    color:#8f8781;
    writing-mode:horizontal-tb;
}
.palace-cell.stars-demoted .minor-star-item{font-weight:700}
.ziwei-board.export-mode .minor-stars-container{overflow:hidden!important}

/* fix44 第二階段：雜曜模式重新納入長生十二神。一般雜曜保留兩列空間，長生曜獨立固定於底欄上方。 */
.minor-stars-container{bottom:calc(20px * var(--sscale,1))}
/* fix44：依實際雜曜數量增加雙列可用高度，避免一般畫面只在匯出模式才不溢位。 */
.palace-cell.minor-stars-medium .minor-stars-container{top:52%}
.palace-cell.minor-stars-dense .minor-stars-container{top:45%}
@media (max-width:780px){
  .palace-cell.minor-stars-medium .minor-stars-container{top:48%}
  .palace-cell.minor-stars-dense .minor-stars-container{top:38%}
}
@media (max-width:600px){
  .palace-cell.minor-stars-medium .minor-stars-container{top:43%}
  .palace-cell.minor-stars-dense .minor-stars-container{top:31%}
}
.long-life-star-container{
    position:absolute;
    left:calc(var(--metaw) + 2px);
    right:3px;
    bottom:calc(3px * var(--sscale,1));
    height:calc(15px * var(--sscale,1));
    display:flex;
    flex-direction:row-reverse;
    align-items:flex-end;
    justify-content:flex-start;
    overflow:hidden;
    pointer-events:none;
}
.long-life-star-item{
    display:inline-flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-end;
    flex:0 0 calc(11px * var(--sscale,1));
    width:calc(11px * var(--sscale,1));
    font-size:calc(9.5px * var(--sscale,1));
    line-height:1;
    font-weight:700;
    color:#8a6f55;
}
.ziwei-board.export-mode .long-life-star-container{overflow:hidden!important}

/* fix44 第二階段：一般畫面雜曜實際溢位時的緊縮備援。
   僅在 DOM 稽核確認溢位時套用，不影響一般宮位。 */
.palace-cell.minor-runtime-overflow .minor-stars-container{
    top:35%;
    bottom:calc(22px * var(--sscale,1));
    gap:calc(1px * var(--sscale,1)) calc(2px * var(--sscale,1));
}
.palace-cell.minor-runtime-overflow .minor-star-item{
    width:calc(9px * var(--sscale,1));
    flex-basis:calc(9px * var(--sscale,1));
    font-size:calc(8.25px * var(--sscale,1));
    line-height:.98;
}


/* fix44 第二階段：四化標記必須完全收在星曜單元內，尤其是 18／9 顆密集宮位。 */
.star-group{contain:layout paint;overflow:hidden!important}
.sihua-stack,.sihua-slot{max-width:var(--starw)!important;overflow:hidden!important}
.sihua-layer-mark{max-width:var(--starw)!important;box-sizing:border-box!important}
.palace-cell.stars-d6 .star-group,
.palace-cell.stars-runtime-overflow .star-group{grid-template-rows:minmax(0,var(--starrow)) calc(var(--shrow)*3 + 2px)}
.palace-cell.stars-d6 .sihua-layer-mark,
.palace-cell.stars-runtime-overflow .sihua-layer-mark{border-width:1px!important}
.palace-cell.stars-d6 .hour-sihua,
.palace-cell.stars-runtime-overflow .hour-sihua{transform:rotate(45deg) scale(.88)}

/* 匯出時沿用 9 顆與緊急版型，避免網頁正常、輸出圖卻回復擁擠。 */
.ziwei-board.export-mode .palace-cell.stars-d6{--starw:12px;--stargap:0px;--starfs:11.25px;--shb:11.5px;--shs:10.5px;--shrow:14px}
.ziwei-board.export-mode .palace-cell.export-density-emergency{--starw:10.5px!important;--stargap:0px!important;--starfs:9.75px!important;--shb:10px!important;--shs:9px!important;--shrow:12px!important}
.ziwei-board.export-mode .palace-cell.export-density-emergency .minor-star-item{font-size:9px!important;width:10px!important;flex-basis:10px!important}


/* fix44 第二階段：匯出第二級自動改排。第一級緊急縮排仍碰撞時才啟用。 */
.ziwei-board.export-mode .palace-cell.export-density-reflow .palace-stars-area{
    padding-bottom:52px!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .minor-stars-container{
    left:calc(var(--metaw) + 1px)!important;
    right:2px!important;
    top:55%!important;
    bottom:18px!important;
    gap:1px 2px!important;
    align-content:flex-start!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .minor-star-item{
    width:9px!important;
    flex-basis:9px!important;
    font-size:8.25px!important;
    line-height:.98!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .long-life-star-container{
    left:calc(var(--metaw) + 1px)!important;
    right:2px!important;
    bottom:2px!important;
    height:13px!important;
    display:block!important;
    text-align:right!important;
    white-space:nowrap!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .long-life-star-item{
    display:inline-block!important;
    width:auto!important;
    font-size:8.5px!important;
    line-height:13px!important;
    letter-spacing:0!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .long-life-star-item>span{
    display:inline!important;
}
.ziwei-board.export-mode .palace-cell.export-density-reflow .sihua-layer-mark{
    transform:scale(.82)!important;
    transform-origin:center top!important;
}


/* fix44 phase2: export final fallback after emergency + reflow.
   Only activates on palaces that still fail the DOM collision audit. */
.ziwei-board.export-mode .palace-cell.export-density-fallback{
  --starw:9.5px!important;--stargap:0!important;--starfs:8.75px!important;
  --shb:9px!important;--shs:8px!important;--shrow:10px!important;
}
.ziwei-board.export-mode .palace-cell.export-density-fallback .minor-stars-container{
  column-gap:0!important;row-gap:0!important;
}
.ziwei-board.export-mode .palace-cell.export-density-fallback .minor-star-item{
  font-size:7.5px!important;width:8px!important;flex-basis:8px!important;line-height:1.02!important;
}
.ziwei-board.export-mode .palace-cell.export-density-fallback .long-life-star-container{
  min-height:10px!important;height:10px!important;line-height:10px!important;
}
.ziwei-board.export-mode .palace-cell.export-density-fallback .long-life-star-item{
  font-size:7.5px!important;line-height:10px!important;
}
.ziwei-board.export-mode .palace-cell.export-density-fallback .sihua-layer-mark,
.ziwei-board.export-mode .palace-cell.export-density-fallback .sihua-badge,
.ziwei-board.export-mode .palace-cell.export-density-fallback .sihua-marker,
.ziwei-board.export-mode .palace-cell.export-density-fallback .transform-marker{
  transform:scale(.78)!important;transform-origin:center top!important;
}

/* fix45 rebuild：八字五欄七層表格，藏干採本氣｜中氣｜餘氣橫排 */
.bazi-chart-table{border:1px solid #cfc8c3;border-radius:8px;overflow:hidden;background:#fff}
.bazi-table-row{display:grid;grid-template-columns:minmax(48px,.62fr) repeat(4,minmax(0,1fr));align-items:stretch}
.bazi-table-row+.bazi-table-row{border-top:1px solid #d8d2cd}
.bazi-table-cell{min-width:0;padding:5px 3px;display:flex;align-items:center;justify-content:center;text-align:center;border-left:1px solid #e1dcd8;color:#514b47}
.bazi-table-cell:first-child{border-left:0}
.bazi-table-header{background:#eee9e5;font-weight:900;font-size:12px}
.bazi-row-label{background:#f5f1ee;font-size:11px;font-weight:900;color:#6f6863}
.bazi-ten-gan{min-height:42px;font-size:12px;font-weight:800}
.bazi-main-gz{min-height:66px;flex-direction:column;font-size:20px;font-weight:900;line-height:1.22}
.bazi-hidden-row,.bazi-hidden-ten-row{min-height:44px;padding-left:2px;padding-right:2px}
.bazi-hidden-slots{width:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center}
.bazi-hidden-slot{min-width:0;min-height:25px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:900;white-space:nowrap}
.bazi-hidden-ten-row .bazi-hidden-slot{font-size:10px;font-weight:700;color:#625b56}
.bazi-hidden-slot.slot-2{justify-self:stretch;text-align:center} /* 中氣固定中央槽，對齊地支中心 */
.bazi-shensha-cell{min-height:78px;align-items:flex-start;padding-top:6px}
.bazi-shensha-list{display:flex;flex-direction:column;align-items:center;gap:2px;font-size:10px;line-height:1.25}
.bazi-nayin,.bazi-kong{min-height:34px;font-size:11px;font-weight:700}
@media(max-width:700px){
 .bazi-table-row{grid-template-columns:minmax(40px,.56fr) repeat(4,minmax(0,1fr))}
 .bazi-table-cell{padding:4px 1px}
 .bazi-table-header,.bazi-row-label{font-size:10px}
 .bazi-main-gz{font-size:18px;min-height:60px}
 .bazi-hidden-slot{font-size:11px}
 .bazi-hidden-ten-row .bazi-hidden-slot{font-size:9px}
}

/* ═══ 本機儲存提醒 ═══
   資料只存在瀏覽器，沒有雲端。首次開啟說明一次，之後在資料累積且久未備份時提醒。
   固定在右下角，不遮擋命盤；手機改為貼齊底部橫向滿版。 */
.storage-notice {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100000;
    width: min(340px, calc(100vw - 32px));
    background: #FFFDFB;
    border: 1px solid #D9D0C7;
    border-left: 4px solid #A3856B;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(60, 50, 42, 0.16);
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #5A524C;
}
.storage-notice-title { font-weight: 800; font-size: 14px; color: #6B4F35; margin-bottom: 6px; }
.storage-notice-body b { color: #6B4F35; }
.storage-notice-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.storage-notice-actions button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #D9D0C7;
    background: #F5F1EC;
    font-size: 12px;
    font-weight: 700;
    color: #6F6863;
    cursor: pointer;
}
.storage-notice-actions button:hover { background: #EBE5DD; }
.storage-notice-actions button.is-primary { background: #8A6B49; border-color: #8A6B49; color: #FFF; }
.storage-notice-actions button.is-primary:hover { background: #765A3C; }
@media (max-width: 600px) {
    .storage-notice { right: 8px; left: 8px; bottom: 8px; width: auto; font-size: 12.5px; }
}
/* 比較盤 iframe 內不顯示，避免兩層提醒 */
.compare-embedded .storage-notice { display: none !important; }

/* 第一階段：自訂星曜面板的全選／取消 */
.custom-star-bulk {
    display: flex; align-items: center; gap: 6px;
    width: 100%; margin-bottom: 6px;
    padding-bottom: 6px; border-bottom: 1px solid #E3DCD4;
}
.custom-star-bulk button {
    padding: 3px 12px; border-radius: 5px;
    border: 1px solid #C9BFB4; background: #F7F3EE;
    font-size: 11px; font-weight: 700; color: #6F6863; cursor: pointer;
}
.custom-star-bulk button:hover { background: #EDE6DD; }
.custom-star-hint { margin-left: auto; font-size: 10.5px; color: #9A928B; font-weight: 700; }

/* 第一階段：日曆查詢結果改為三個等寬區塊（西元｜農曆｜干支），手機三列堆疊 */
.calendar-result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
}
.calendar-result-block {
    min-width: 0;
    border: 1px solid #E7E5E4;
    border-radius: 6px;
    background: #FFF;
    padding: 6px 8px;
    text-align: center;
}
.calendar-result-title {
    font-size: 10.5px; font-weight: 800; color: #8A837E;
    letter-spacing: .06em; margin-bottom: 3px;
}
.calendar-result-body { display: flex; flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.5; }
.calendar-result-body b { font-weight: 800; color: #4F4844; }
.calendar-result-body span { color: #6B645F; }
/* 干支四柱在區塊內排成 2×2，避免橫向擠壓 */
.calendar-result-gz {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px 6px; font-size: 11.5px;
}
@media (max-width: 700px) {
    .calendar-result-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .calendar-result-gz { grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 11px; }
}

/* ═══ 第一階段：教學工具列固定上下兩層 ═══
   舊版是單排 flex-wrap:nowrap + overflow-x:auto，桌機要橫向拖曳才點得到後面的按鈕。
   改為固定兩層：
     第一層 工具｜畫圈｜箭頭｜虛箭｜飛星｜自化
     第二層 三合｜鎖定｜清除｜結束
   兩層都允許換行，不使用水平捲動。三合功能區維持獨立的下一層。 */
.teaching-toolbar-row {
    display: flex !important;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap !important;
    overflow-x: visible !important;
}
.teaching-toolbar-row > * { flex: 0 0 auto; }
.teaching-toolbar-row-2 { margin-top: 5px; padding-top: 5px; border-top: 1px solid rgba(255,255,255,.18); }

@media (max-width: 700px) {
    /* 手機改為等寬分欄，按鈕自動填滿可用寬度，不靠水平捲動 */
    .teaching-toolbar-row {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }
    .teaching-toolbar-row > * { width: 100%; }
    .teaching-toolbar-row .teaching-toolbar-label { grid-column: 1 / -1; justify-content: center; }
    .teaching-toolbar-row button { padding-left: 4px !important; padding-right: 4px !important; font-size: 10.5px !important; }
    .teaching-toolbar-row-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
    .teaching-toolbar-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .teaching-toolbar-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ═══ fix49：雜曜左側分區 ═══
   規格：左側依序 固定標籤 → 雜曜 → 長生十二神 → （下接宮位底欄）。
   舊版三者各自絕對定位，雜曜靠 top:58%/52%/45% 推擠，壓在主星與四化下方，
   星數一多就互相重疊。改為單一 flex 直欄，順序由文件流決定，不需要百分比。
   實測最壞情況：單宮主星 6、雜曜 4、長生 1；左欄可用高 48px、每列 3 個，容量 6。 */
.palace-side-column {
    position: absolute;
    left: 3px;
    top: 3px;
    bottom: calc(3px * var(--sscale, 1));
    width: calc(var(--metaw) - 6px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(2px * var(--sscale, 1));
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
}
/* 三個子區塊改為文件流，覆蓋原本的絕對定位 */
.palace-side-column .palace-star-meta,
.palace-side-column .minor-stars-container,
.palace-side-column .long-life-star-container {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: 100% !important;
}
.palace-side-column .palace-star-meta { flex: 0 0 auto; }
.palace-side-column .minor-stars-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    flex-direction: row !important;      /* 左欄由左至右讀，不再 row-reverse */
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    margin-top: calc(2px * var(--sscale, 1));
}
/* 長生十二神固定貼在左欄最下緣，緊鄰宮位底欄 */
.palace-side-column .long-life-star-container {
    flex: 0 0 auto;
    margin-top: auto;
    /* 高度必須跟著內容走：長生十二神多為兩個字直排，
       小螢幕上寫死 15px×sscale（390px 時僅 9.9px）會讓字往上竄進雜曜區。 */
    height: auto !important;
    min-height: calc(15px * var(--sscale, 1));
    align-items: flex-end;
    flex-direction: row !important;
    justify-content: flex-start;
}
/* 主星區起點維持不變，左欄寬度沒有改動 */
.palace-side-column ~ .stars-container { padding-left: calc(var(--metaw) - 2px); }

/* 容量分級：雜曜較多時縮小單顆寬度與字級，讓同一列多放一顆，
   而不是往下溢出去撞長生十二神。門檻依實測最壞值 4 顆保留餘裕。 */
.palace-cell.minor-stars-medium .palace-side-column .minor-star-item {
    flex-basis: calc(10px * var(--sscale, 1));
    width: calc(10px * var(--sscale, 1));
    font-size: calc(9.2px * var(--sscale, 1));
}
.palace-cell.minor-stars-dense .palace-side-column .minor-star-item {
    flex-basis: calc(9px * var(--sscale, 1));
    width: calc(9px * var(--sscale, 1));
    font-size: calc(8.4px * var(--sscale, 1));
}
/* fix49：舊版依百分比推擠的規則在左欄模式下一律失效。
   注意這裡不能再寫 top:auto，否則會蓋掉「雜曜與生年四化齊平」的 top:var(--starrow)。 */
.palace-cell.minor-stars-medium .palace-side-column .minor-stars-container,
.palace-cell.minor-stars-dense .palace-side-column .minor-stars-container { top: var(--starrow) !important; }

/* fix49：小螢幕左欄極窄（390px 時僅 21px），密集時再收一級，
   確保每列放得下 3 顆、兩列內排完，不會往下撞長生十二神。 */
@media (max-width: 780px) {
    .palace-cell.minor-stars-medium .palace-side-column .minor-star-item {
        flex-basis: calc(9px * var(--sscale, 1));
        width: calc(9px * var(--sscale, 1));
        font-size: calc(8.6px * var(--sscale, 1));
    }
    .palace-cell.minor-stars-dense .palace-side-column .minor-star-item {
        flex-basis: calc(8.4px * var(--sscale, 1));
        width: calc(8.4px * var(--sscale, 1));
        font-size: calc(8px * var(--sscale, 1));
        line-height: 1;
    }
    .palace-side-column .minor-stars-container { gap: 1px 0.5px; }
}

/* ═══ fix49：小螢幕的左欄容量 ═══
   實測（自訂全選、最壞情況）：480px 以上左欄高 59px 起，
   標籤＋雜曜＋長生放得下，碰撞 0；430px 以下左欄僅 47px、37px，
   而三個區塊合計需要約 48px，物理上放不下。
   此處讓長生十二神優先保住空間（每宮僅一顆、資訊密度最高），
   雜曜再收一級並允許容器內裁切，避免直接壓在長生的字上。 */
@media (max-width: 459px) {
    .palace-side-column .minor-stars-container {
        overflow: hidden;
        flex: 1 1 auto;
        min-height: 0;
    }
    .palace-side-column .minor-star-item {
        flex-basis: calc(8px * var(--sscale, 1));
        width: calc(8px * var(--sscale, 1));
        font-size: calc(7.6px * var(--sscale, 1));
        line-height: 1;
    }
    .palace-side-column .long-life-star-container { flex: 0 0 auto; }
}

/* fix45：本命命宮宮干四化固定在生年四化下方一格 */
.birth-sihua-pair{display:inline-flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:1px;line-height:1}
.sihua-layer-placeholder{width:var(--shb);height:var(--shb);flex:0 0 auto}
.natal-palace-sihua{width:var(--shs);height:var(--shs);border-radius:3px;font-size:calc(var(--shs) * .7);background:#FCFBF9;flex:0 0 auto}
.natal-outline-A{border:1.5px solid #6A937C;color:#6A937C}
.natal-outline-B{border:1.5px solid #8B6F47;color:#8B6F47}
.natal-outline-C{border:1.5px solid #79AFCB;color:#79AFCB}
.natal-outline-D{border:1.5px solid #B86B67;color:#B86B67}

/* ═══ fix51：命盤宮內標籤恢復直排 ═══
   工具列的「方位、身宮、生肖、七星」維持原本橫向選項，不做直排。
   只有命盤宮格內的來因宮、生肖、七星、身宮採由上而下直排；
   同宮出現時固定順序為：來因宮 → 生肖 → 七星 → 身宮。 */
.palace-side-column {
    width: auto !important;
    right: 3px;
    overflow: visible;
}
.palace-side-column .palace-star-meta {
    width: calc(var(--metaw) - 3px) !important;
    flex: 0 0 auto;
    flex-direction: column !important;
    flex-wrap: nowrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: calc(2px * var(--sscale, 1));
    min-height: calc(66px * var(--sscale, 1));
}
.palace-star-meta-tag {
    white-space: nowrap;
    flex: 0 0 auto;
}
/* fix49：雜曜文字與生年四化齊平。
   四化第一列（生年）位於星名列之下，起點為 --starrow；
   雜曜原本緊貼標籤下方（top 27px），與四化（top 36~54px）不齊。
   改為以絕對定位固定在 --starrow 的高度，左右仍可用滿寬。
   標籤區保留在上方，min-height 已足夠容納兩列標籤而不與雜曜相撞。 */
.palace-side-column .minor-stars-container {
    position: absolute !important;
    top: var(--starrow) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    margin-top: 0 !important;
    width: 100% !important;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: calc(2px * var(--sscale, 1));
    flex-direction: row !important;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    overflow: visible;
}
/* 取消長生十二神後，左欄不再需要為它保留底部空間 */
.palace-side-column .long-life-star-container { display: none !important; }.compare-case-library-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;margin:8px 0;padding:8px;border:1px solid #ddd6d0;border-radius:8px;background:#fafaf9}
.compare-case-library-row label{font-size:12px;font-weight:800;color:#625b56}.compare-case-library-row select,.compare-case-library-row button{min-height:34px;border:1px solid #d6d3d1;border-radius:6px;background:#fff;padding:4px 8px;font-size:12px}.compare-case-library-row button{font-weight:800;color:#625b56}
.compare-secondary{width:100%!important;max-width:none!important}.compare-secondary-header,.compare-secondary-flowbar{width:100%!important;box-sizing:border-box}.compare-secondary-actions{max-width:100%;flex-wrap:wrap}
.minor-star-item{font-size:var(--nayinfs,12px)!important;line-height:1.12!important}
.bazi-hidden-slot,.bazi-hidden-ten-row .bazi-hidden-slot{font-size:14px!important;font-weight:900!important;line-height:1.15!important}
.bazi-nayin,.bazi-kong{font-size:13px!important;font-weight:800!important}
.bazi-dayun-item span:nth-child(2),.bazi-dayun-item span:nth-child(3),.bazi-liunian-item span:nth-child(2),.bazi-liunian-item span:nth-child(3){font-size:13px!important;font-weight:800!important}
.teaching-fly-line-decade{filter:drop-shadow(0 0 1px rgba(255,255,255,.9))}.teaching-fly-line-year{stroke-dasharray:9 6!important}

/* fix51：干支排盤／四柱反查 */
.ganzhi-reverse-open-btn{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 12px;border:1px solid #cfc6bd;border-radius:8px;background:#fff;color:#76685e;font-size:12px;font-weight:800}
.ganzhi-reverse-modal{position:fixed;inset:0;z-index:95;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(35,30,27,.48)}
.ganzhi-reverse-modal.hidden{display:none}
.ganzhi-reverse-card{width:min(760px,100%);max-height:88vh;overflow:auto;border-radius:16px;background:#fff;box-shadow:0 24px 70px rgba(0,0,0,.24);padding:18px}
.ganzhi-reverse-header{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;border-bottom:1px solid #e7e1dc;padding-bottom:12px}.ganzhi-reverse-header h2{font-size:18px;font-weight:900;color:#6f5942}.ganzhi-reverse-header p{font-size:11px;color:#8a837e;margin-top:3px}.ganzhi-reverse-header button{width:32px;height:32px;border-radius:8px;color:#777;background:#f5f3f1}
.ganzhi-reverse-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:14px}.ganzhi-reverse-grid label,.ganzhi-reverse-actions label{display:grid;gap:5px;font-size:12px;font-weight:800;color:#6e6661}.ganzhi-reverse-grid select,.ganzhi-reverse-actions select{height:36px;border:1px solid #d7d0ca;border-radius:8px;padding:0 8px;background:#fff;text-align:center}
.ganzhi-reverse-actions{display:flex;align-items:end;justify-content:space-between;gap:12px;margin-top:12px}.ganzhi-reverse-actions button{height:36px;border-radius:8px;padding:0 16px;background:#85708c;color:#fff;font-size:12px;font-weight:900}.ganzhi-reverse-status{margin-top:14px;padding:10px;border-radius:8px;background:#f7f5f3;color:#746b65;font-size:12px;font-weight:700}.ganzhi-reverse-results{display:grid;gap:8px;margin-top:10px}.ganzhi-result-item{display:flex;justify-content:space-between;gap:10px;text-align:left;border:1px solid #ded7d1;border-radius:9px;padding:10px 12px;background:#fff}.ganzhi-result-item:hover{background:#faf8f6}.ganzhi-result-item strong{font-size:12px;color:#65594f}.ganzhi-result-item span{font-size:11px;color:#8a837e}
@media(max-width:600px){.ganzhi-reverse-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.ganzhi-reverse-actions{align-items:stretch;flex-direction:column}.ganzhi-reverse-actions label,.ganzhi-reverse-actions button{width:100%}.ganzhi-result-item{flex-direction:column}}


/* fix51 final layout corrections */
#teaching-toolbar{
  width:100%!important;max-width:none!important;display:flex;align-items:center;gap:5px;
  flex-wrap:nowrap!important;overflow-x:auto!important;overflow-y:visible!important;position:relative;
}
#teaching-toolbar.hidden{display:none!important}
#teaching-toolbar .teaching-toolbar-row{display:contents!important}
#teaching-toolbar .teaching-toolbar-row-2{margin:0!important;padding:0!important;border:0!important}
#teaching-toolbar button{flex:0 0 auto;white-space:nowrap}
#teaching-sanhe-panel{position:absolute;left:0;right:0;top:calc(100% + 4px);z-index:70}
.teaching-flystar-flow-controls{display:none!important}
body.self-flystar-active .teaching-flystar-flow-controls{display:inline-flex!important;align-items:center;gap:4px}
.natal-palace-sihua{display:none!important}
body.self-flystar-active .natal-palace-sihua{display:inline-flex!important}
.center-date-row{max-width:100%;}.ganzhi-reverse-grid input,.ganzhi-reverse-range input{height:34px;border:1px solid #d7d0ca;border-radius:8px;padding:0 8px;text-align:center}
.ganzhi-reverse-range{display:grid;grid-template-columns:1fr 1fr auto;gap:10px;align-items:end;margin-top:12px}.ganzhi-reverse-range label{display:grid;gap:5px;font-size:12px;font-weight:800;color:#6e6661}.ganzhi-reverse-range button{height:36px;border:1px solid #85708c;border-radius:8px;padding:0 12px;background:#fff;color:#6d5b73;font-size:12px;font-weight:900}
.compare-workspace.has-compare{align-items:stretch!important;overflow:visible!important}
.compare-workspace.has-compare #teaching-toolbar{grid-column:1/-1;order:-10;width:100%!important}
.compare-workspace.has-compare .compare-primary-pane,.compare-workspace.has-compare .compare-secondary{overflow:visible!important;min-height:0}
.compare-workspace.has-compare .compare-secondary{min-width:360px!important}
.compare-workspace.has-compare .compare-secondary-header,.compare-workspace.has-compare .compare-secondary-flowbar{min-width:360px}
.compare-chart-frame{overflow:visible!important;padding-bottom:42px!important}
.compare-primary-pane #capture-area,.compare-secondary #capture-area{overflow:visible!important}
.bazi-hidden-ten-row .bazi-hidden-slot,.bazi-ten-gan{font-size:14px!important;font-weight:900!important}
.bazi-dayun-item span:first-child,.bazi-liunian-item span:first-child{font-size:20px!important;line-height:1.08!important}
@media(max-width:700px){
 #teaching-toolbar{padding:6px!important;gap:3px!important}
 #teaching-toolbar button{width:auto!important;min-height:34px!important;font-size:10px!important;padding-left:5px!important;padding-right:5px!important}.ganzhi-reverse-range{grid-template-columns:1fr 1fr}.ganzhi-reverse-range button{grid-column:1/-1}
}


/* fix52: calendar, compare layout and flystar visibility corrections */
#calendar-time-jump,
#calendar-date-jump{
  text-align:center!important;
  text-align-last:center!important;
}
#calendar-time-jump::placeholder,
#calendar-date-jump::placeholder{ text-align:center!important; }
.calendar-result-gz span{ text-align:center; white-space:nowrap; }

/* 教學工具列固定為單排；比較盤時置於兩盤功能列之上 */
#teaching-toolbar,
#teaching-toolbar .teaching-toolbar-single-row{
  display:flex!important;
  flex-direction:row!important;
  flex-wrap:nowrap!important;
  align-items:center!important;
}
#teaching-toolbar{overflow-x:auto!important;overflow-y:visible!important}
.compare-workspace.has-compare{display:grid!important;grid-template-columns:minmax(520px,1fr) minmax(420px,1fr)!important;column-gap:14px!important;row-gap:8px!important}
.compare-workspace.has-compare>#teaching-toolbar{grid-column:1/-1!important;grid-row:1!important;order:-100!important;width:100%!important;max-width:none!important}
.compare-workspace.has-compare>.compare-primary-pane{grid-column:1!important;grid-row:2!important}
.compare-workspace.has-compare>.compare-secondary{grid-column:2!important;grid-row:2!important;min-width:420px!important}
.compare-workspace.has-compare .compare-pane-flowbar{
  min-width:420px!important;
  width:100%!important;
  overflow:visible!important;
  max-height:none!important;
}
.compare-workspace.has-compare .compare-layer-row,
.compare-workspace.has-compare .compare-step-row{grid-template-columns:68px repeat(5,minmax(58px,1fr))!important}
.compare-workspace.has-compare .compare-secondary,
.compare-workspace.has-compare .compare-primary-pane,
.compare-workspace.has-compare iframe{overflow:visible!important}
#compare-chart-frame{padding-bottom:72px!important;box-sizing:border-box!important}

/* 命宮宮干四化只在飛星模式顯示，並避免遮住星曜 */
.natal-palace-sihua{display:none!important}
body.self-flystar-active .natal-palace-sihua{
  display:inline-flex!important;
  position:relative!important;
  z-index:3!important;
  margin-top:2px!important;
  max-width:100%!important;
  gap:1px!important;
  flex-wrap:nowrap!important;
}
body.self-flystar-active .sihua-stack{row-gap:1px!important}
body.self-flystar-active .star-group{overflow:visible!important}

@media(max-width:1100px){
 .compare-workspace.has-compare{grid-template-columns:minmax(460px,1fr) minmax(400px,1fr)!important}
 .compare-workspace.has-compare>.compare-secondary{min-width:400px!important}
 .compare-workspace.has-compare .compare-pane-flowbar{min-width:400px!important}
}
@media(max-width:820px){
 .compare-workspace.has-compare{display:block!important}
 .compare-workspace.has-compare>#teaching-toolbar{width:100%!important;margin-bottom:8px!important}
 .compare-workspace.has-compare>.compare-secondary{min-width:0!important}
 .compare-workspace.has-compare .compare-pane-flowbar{min-width:0!important;width:100%!important}
}


/* ═══ fix53 authoritative corrections ═══ */
#main-work-layout.is-side-layout{grid-template-columns:clamp(360px,32vw,480px) 22px minmax(0,1fr)!important;align-items:start!important}
#main-work-layout.is-side-layout .work-layout-controls{width:100%!important;max-width:none!important;min-width:360px!important;overflow:visible!important;max-height:none!important;height:auto!important}
#main-work-layout.is-side-layout #main-control-panel,#main-work-layout.is-side-layout .ctrl-panel{overflow:visible!important;max-height:none!important;height:auto!important}
@media(max-width:1199px) and (min-width:701px){#main-work-layout.is-side-layout{grid-template-columns:minmax(340px,38vw) 22px minmax(0,1fr)!important}#main-work-layout.is-side-layout .work-layout-controls{min-width:340px!important}}
@media(max-width:700px){#main-work-layout.is-side-layout{display:flex!important;flex-direction:column!important}#main-work-layout.is-side-layout .work-layout-controls{min-width:0!important;width:100%!important;overflow:visible!important}}
#teaching-toolbar{width:min(var(--ziwei-board-max-width),100%)!important;max-width:var(--ziwei-board-max-width)!important;overflow-x:auto!important;overflow-y:visible!important;flex-wrap:nowrap!important}
#teaching-toolbar .teaching-toolbar-row{display:contents!important}
.compare-workspace.has-compare{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;align-items:start!important;overflow:visible!important}
.compare-workspace.has-compare>#teaching-toolbar{grid-column:1/-1!important;grid-row:1!important;order:-999!important;margin:0 0 8px!important;position:relative!important;z-index:80!important}
.compare-workspace.has-compare>#teaching-toolbar{width:100%!important;max-width:none!important}
.compare-workspace.has-compare>.compare-primary-pane{grid-column:1!important;grid-row:2!important}.compare-workspace.has-compare>.compare-secondary{grid-column:2!important;grid-row:2!important}
@media(max-width:820px){.compare-workspace.has-compare{grid-template-columns:1fr!important}.compare-workspace.has-compare>.compare-primary-pane,.compare-workspace.has-compare>.compare-secondary{grid-column:1!important}.compare-workspace.has-compare>.compare-primary-pane{grid-row:2!important}.compare-workspace.has-compare>.compare-secondary{grid-row:3!important}}
.compare-secondary{overflow:visible!important}.compare-secondary iframe,#compare-chart-frame{overflow:hidden!important;border:0!important;display:block!important;width:100%!important;max-height:none!important}.compare-primary-pane,.compare-secondary,.compare-chart-frame,#compare-chart-frame{max-height:none!important}.compare-primary-pane #capture-area,#compare-chart-frame{overflow:visible!important}
.compare-case-library-row{display:grid!important;grid-template-columns:auto minmax(0,1fr) auto!important}
.bazi-dayun-item .gz-stack,.bazi-liunian-item .gz-stack{font-size:20px!important;line-height:1.08!important;min-height:54px!important}.bazi-dayun-item .gz-stack .gz-gan,.bazi-dayun-item .gz-stack .gz-zhi,.bazi-liunian-item .gz-stack .gz-gan,.bazi-liunian-item .gz-stack .gz-zhi{font-size:20px!important;line-height:1.08!important;font-weight:900!important}
.natal-palace-sihua{display:none!important}body.self-flystar-active .natal-palace-sihua{display:inline-flex!important}body.self-flystar-active .birth-sihua-pair{display:grid!important;grid-template-rows:var(--shb) var(--shs)!important;gap:2px!important;align-items:center!important;justify-items:center!important;min-height:calc(var(--shb) + var(--shs) + 2px)!important}body.self-flystar-active .sihua-stack{grid-template-rows:auto repeat(2,var(--shrow))!important;max-height:none!important;overflow:visible!important;min-height:calc(var(--shb) + var(--shs) + var(--shrow) * 2 + 4px)!important}body.self-flystar-active .sihua-slot:first-child{max-height:none!important;overflow:visible!important;height:auto!important}body.self-flystar-active .star-group,body.self-flystar-active .stars-container,body.self-flystar-active .palace-stars-area{overflow:visible!important}/* fix55 final verified overrides */
.compare-workspace.has-compare.is-ziwei-compare{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:48px!important;
  align-items:start!important;
  overflow:visible!important;
}
.compare-workspace.has-compare.is-ziwei-compare .compare-primary-pane,
.compare-workspace.has-compare.is-ziwei-compare .compare-secondary{
  min-width:0!important;width:100%!important;overflow:visible!important;
}
.compare-workspace.has-compare.is-ziwei-compare .compare-pane-flowbar{
  display:none!important;
}
.compare-workspace.has-compare.is-ziwei-compare #capture-area,
.compare-workspace.has-compare.is-ziwei-compare #ziwei-board{
  width:100%!important;max-width:none!important;overflow:visible!important;
}
.compare-workspace.has-compare.is-ziwei-compare #ziwei-board{aspect-ratio:1/1!important;height:auto!important}
#compare-chart-frame{display:block!important;width:100%!important;border:0!important;overflow:hidden!important;padding-bottom:0!important}
.compare-secondary{overflow:visible!important}
@media(max-width:980px){.compare-workspace.has-compare.is-ziwei-compare{gap:28px!important}}
@media(max-width:820px){.compare-workspace.has-compare.is-ziwei-compare{grid-template-columns:1fr!important;gap:20px!important}}

/* 神煞與納音採相同閱讀字級 */
.bazi-shensha-list,.bazi-shensha-item,.bazi-nayin{font-size:13px!important;line-height:1.35!important;font-weight:700!important}

/* 中宮日期表由 JS 精準定位到「性」字中心與「柱」字中心 */
.center-date-table{margin-left:0!important;margin-right:0!important;box-sizing:border-box!important;}/* ═══ fix58：自化分流與中宮時間精準對齊 ═══ */
.center-board{position:relative!important}
.center-date-table{
  overflow:visible!important;
  z-index:8!important;
}@media(max-width:700px){
 .center-date-row{grid-template-columns:48px minmax(0,1fr)!important}}

/* ═══ fix58：窄螢幕的中宮時間欄位 ═══
   .center-date-row 的標籤欄固定 54px，.date-parts 內含 4 個固定 13px 分隔
   與 minmax(40/20/20/46px) 的欄位，內容最小寬約 232px。
   600px 以下「性」到「柱」的實際跨距小於此值，表格被內容撐開，
   左右各溢出一半（實測 600px 左 −16.2px、右 +15.7px）。
   此處讓各欄可壓縮，表格才跟得上量到的跨距。 */
@media (max-width: 800px) {
    .center-date-row {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 3fr) !important;
        column-gap: 2px !important;
    }.center-date-table { min-width: 0 !important; }
    .center-date-row > * { min-width: 0 !important; }
}


/* ═══ fix59：主星字級固定，不隨宮內星曜密度縮小 ═══ */
.palace-cell .main-star{
  font-size:calc(18.75px * var(--sscale,1))!important;
  line-height:1.05!important;
}
.ziwei-board.export-mode .palace-cell .main-star{
  font-size:calc(18.75px * var(--sscale,1))!important;
}.center-summary{width:100%!important}
.center-summary > .w-full.flex{
  width:var(--center-info-width)!important;
  max-width:var(--center-info-width)!important;
  display:block!important;
  margin-left:auto!important;
  margin-right:auto!important;
}
.center-date-table{
  width:var(--center-info-width)!important;
  max-width:var(--center-info-width)!important;
  min-width:0!important;
  margin:0 auto!important;
  align-self:center!important;
  position:relative!important;
  display:flex!important;
  flex-direction:column!important;
  gap:3px!important;
}
.center-date-row{
  display:grid!important;
  grid-template-columns:var(--center-info-columns)!important;
  align-items:center!important;
  column-gap:0!important;
  width:100%!important;
  min-width:0!important;
  white-space:nowrap!important;
}
.center-date-row > span{
  min-width:0!important;
  box-sizing:border-box!important;
  display:flex!important;
  align-items:center!important;
  font-variant-numeric:tabular-nums!important;
}
.center-date-row .date-label{
  text-align-last:auto!important;
  color:#8A837E!important;
}#bazi-section{
  width:var(--center-info-width)!important;
  max-width:var(--center-info-width)!important;
}
#bazi-grid{
  width:100%!important;
  grid-template-columns:var(--center-info-columns)!important;
  gap:0!important;
  padding:9px 0!important;
}
#bazi-grid .bazi-col{
  padding-left:3px!important;
  padding-right:3px!important;
}
@media(max-width:700px){
  .center-summary,#bazi-section{--center-info-width:min(290px, 100%)}
  .center-date-row{font-size:10px!important}
  .center-date-row > span{padding-left:1px!important;padding-right:1px!important}
}


/* fix61：圖片匯出凍結螢幕版面，只允許等比例高解析縮放。 */
.export-render-copy.export-layout-frozen{
  max-width:none!important;
  max-height:none!important;
}.center-date-table,
#bazi-section{
  width:var(--center-info-width)!important;
  max-width:var(--center-info-width)!important;
  margin-left:auto!important;
  margin-right:auto!important;
}
.center-date-row,
#bazi-grid{
  grid-template-columns:var(--center-info-columns)!important;
}
.center-date-row > span,
#bazi-grid > *{
  box-sizing:border-box!important;
  min-width:0!important;
  justify-content:center!important;
  text-align:center!important;
}
.center-date-row .date-time{
  padding-left:0!important;
  padding-right:0!important;
}

/* 主星、輔星、小星統一從同一上緣開始，禁止個別字級或標記造成上下漂移。 */
.stars-container{
  align-items:flex-start!important;
}
.star-group{
  align-self:flex-start!important;
  justify-content:flex-start!important;
  padding-top:0!important;
}
.star-text,
.main-star,
.aux-star,
.small-star{
  margin-top:0!important;
  padding-top:0!important;
  vertical-align:top!important;
}
.palace-cell .main-star,
.palace-cell .aux-star{
  font-size:calc(18.75px * var(--sscale,1))!important;
  line-height:1.05!important;
}

/* 雜曜改貼近宮位底欄／月份列上方；標籤區仍固定在上方。
   上界由標籤區底部限制，下界由宮位底欄限制；極端數量採兩列緊密排版。 */
.palace-side-column{
  bottom:calc(var(--footer-h) + 2px)!important;
}
.palace-side-column .minor-stars-container{
  top:auto!important;
  bottom:0!important;
  min-height:0!important;
  max-height:calc(34px * var(--sscale,1))!important;
  margin:0!important;
  align-content:flex-end!important;
  align-items:flex-start!important;
  overflow:hidden!important;
}
.palace-side-column .palace-star-meta{
  min-height:0!important;
  max-height:calc(64px * var(--sscale,1))!important;
}
.palace-cell.minor-stars-medium .palace-side-column .minor-stars-container,
.palace-cell.minor-stars-dense .palace-side-column .minor-stars-container{
  top:auto!important;
  bottom:0!important;
}
.palace-cell.minor-stars-dense .palace-side-column .minor-stars-container{
  max-height:calc(38px * var(--sscale,1))!important;
}
.ziwei-board.export-mode .palace-side-column .minor-stars-container{
  top:auto!important;
  bottom:0!important;
}

/* 畫面與輸出使用同一版面，不在匯出模式縮小主輔星。 */
.ziwei-board.export-mode .palace-cell .main-star,
.ziwei-board.export-mode .palace-cell .aux-star{
  font-size:calc(18.75px * var(--sscale,1))!important;
}


/* ═══ fix64：中宮日期三列以「單位字」為對齊錨點 ═══
   fix63 對 .center-date-row > span 下了 justify-content:center!important，
   把 fix33／fix61 刻意設定的靠右錨點整組蓋掉，導致：
     2026年 / 丙午年 各自置中 →「年」字不同 x
     7月   / 六月   各自置中 →「月」字不同 x
     14:11時 / 未時 各自置中 →「時」字不同 x
   半形數字與全形漢字寬度差近一倍，置中必然參差。
   本層恢復四個資料欄一律靠右，三列在年／月／日／時四個單位字上垂直對齊。 */
.center-board{
  --center-info-width:min(286px, 100%);
  /* 標籤 年 月 日 時；合計 286px。日欄放大到 56px 以容納「二十九日」四字。 */
  --center-info-columns:52px 60px 44px 56px 74px;
}
.center-summary,
#bazi-section{
  --center-info-width:inherit;
  --center-info-columns:inherit;
}

.center-date-row > span{
  justify-content:flex-end!important;
  text-align:right!important;
  padding:0 3px!important;
  overflow:hidden!important;
  white-space:nowrap!important;
}
.center-date-row .date-label{
  justify-content:flex-end!important;
  text-align:right!important;
}
.center-date-row .date-time{
  grid-column:5!important;
  justify-content:flex-end!important;
  text-align:right!important;
  padding:0 3px!important;
}
.center-date-row .date-fallback{
  grid-column:2 / 6!important;
  justify-content:flex-end!important;
  text-align:right!important;
}

/* 八字列吃同一組軌道，卡片填滿欄寬、內容維持置中。 */
#bazi-grid > .bazi-col{
  width:100%!important;
  min-width:0!important;
  box-sizing:border-box!important;
  justify-content:center!important;
  text-align:center!important;
}

/* flex 置中 + overflow 會把超出的上緣吃掉且捲不回來，
   safe center 在內容超高時自動退回起點對齊，中宮最上一列不再只露半截。 */
.center-board{
  justify-content:flex-start!important;
  justify-content:safe center!important;
}
.center-board.calibration-open{
  padding-bottom:22px!important;
}
.calibration-status{
  overflow:visible!important;
}

@media(max-width:700px){
  .center-board{--center-info-width:min(272px, 100%);--center-info-columns:50px 58px 42px 52px 70px}
  .center-date-row > span{padding:0 2px!important}
}
