/**
 * 星垣术苑 · 移动端 / 平板响应式补丁
 * 仅 @media screen and (max-width: 1024px) 生效，桌面端（>1024px）零影响。
 * 插入位置：各页面主样式 link 之后（style.css / fortune-topics.css 等之后）。
 */

@media screen and (max-width: 1024px) {

    /* ── 全局基础兼容 ── */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    html {
        overflow-x: hidden;
        max-width: 100vw;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    button,
    input,
    select,
    textarea {
        -webkit-appearance: none;
        appearance: none;
    }

    input[type='checkbox'],
    input[type='radio'] {
        -webkit-appearance: auto;
        appearance: auto;
    }

    /* rem 基准：手机略小，平板适中（仅小屏） */
    html {
        font-size: 14px;
    }

    /* ── iPad 平板 481px ~ 1024px ── */
    @media (min-width: 481px) {
        html {
            font-size: 15px;
        }
    }

    /* ── 手机竖屏 ≤480px ── */
    @media (max-width: 480px) {
        html {
            font-size: 14px;
        }
    }

    /* ── 992~1024 iPad：衔接 home-dashboard.mobile.css（991px 断点）── */
    .hd-mobile-only {
        display: block !important;
    }

    nav.hd-mobile-bottom-nav.hd-mobile-only,
    .hd-mobile-bottom-nav {
        display: flex !important;
    }

    /* 档案/命书/题库弹窗打开时隐藏底栏，弹窗才能真正上下居中与滚动 */
    body:has(#hdArchiveBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#hdArchiveBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#hdArchiveEditBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#hdArchiveEditBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#hdLifebookBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#hdLifebookBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#calcPaipanPromptBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#calcPaipanPromptBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#examFavoritesModalBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#examFavoritesModalBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body.hd-lifebook-modal-open nav.hd-mobile-bottom-nav.hd-mobile-only,
    body.hd-lifebook-modal-open .hd-mobile-bottom-nav,
    body.exam-favorites-modal-open nav.hd-mobile-bottom-nav.hd-mobile-only,
    body.exam-favorites-modal-open .hd-mobile-bottom-nav {
        display: none !important;
    }

    /* 题库答题时保留底栏（关闭走确认提示，不遮挡导航） */
    body.exam-bank-modal-open nav.hd-mobile-bottom-nav.hd-mobile-only,
    body.exam-bank-modal-open .hd-mobile-bottom-nav,
    body:has(#examBankModalBackdrop:not([hidden])) nav.hd-mobile-bottom-nav.hd-mobile-only,
    body:has(#examBankModalBackdrop:not([hidden])) .hd-mobile-bottom-nav {
        display: flex !important;
        z-index: 1200;
    }

    @media (max-width: 991px) {
        .hd-menu-toggle--me,
        .hd-menu-toggle--exam {
            display: inline-flex;
            flex-shrink: 0;
        }

        .exam-bank-modal__head {
            align-items: center;
        }

        .exam-bank-modal__head .hd-menu-toggle--exam {
            margin-top: 0;
            width: 2.2rem;
            height: 2.2rem;
        }

        .exam-bank-modal__head .hd-lifebook-close {
            margin-top: 0;
        }
    }

    .hd-topnav--mobile.hd-mobile-only {
        display: flex !important;
    }

    .hd-desktop-only {
        display: none !important;
    }

    .hd-badge.hd-desktop-only,
    .hd-hero h1.hd-desktop-only,
    .hd-lead.hd-desktop-only,
    .hd-hero-cta-row.hd-desktop-only {
        display: none !important;
    }

    body:has(.hd-mobile-bottom-nav) {
        padding-bottom: calc(4.6rem + env(safe-area-inset-bottom));
    }

    body:has(.hd-mobile-bottom-nav) .app-rail.app-rail--desktop-v2,
    body:has(.hd-mobile-bottom-nav) .app-rail {
        display: none !important;
    }

    body:has(.hd-mobile-bottom-nav) .app:has(> .app-rail) > .main,
    body:has(.hd-mobile-bottom-nav) .app:has(> .app-rail.app-rail--desktop-v2) > .main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }

    body:has(.hd-mobile-bottom-nav) .ask-human-teacher-fab {
        bottom: calc(4.75rem + env(safe-area-inset-bottom));
    }

    /* 底部四栏 Tab：通栏固定；图标在上、文字在下（勿依赖仅首页才加载的 home-dashboard.mobile.css） */
    .hd-mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1200;
        display: flex !important;
        align-items: stretch;
        justify-content: space-around;
        gap: 0.12rem;
        box-sizing: border-box;
        width: 100%;
        max-width: 100vw;
        margin: 0;
        padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom));
        background: #fffefb;
        border-top: 1px solid rgba(120, 108, 92, 0.16);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .hd-mobile-bottom-nav__btn {
        box-sizing: border-box;
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.14rem;
        min-height: 2.95rem;
        padding: 0.22rem 0.12rem;
        margin: 0;
        border: none;
        border-radius: 12px;
        background: transparent;
        color: #6b6154;
        font-size: 0.62rem !important;
        font-weight: 600;
        font-family: inherit;
        line-height: 1.2;
        text-align: center;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
    }

    .hd-mobile-bottom-nav__btn > span:not(.hd-mobile-bottom-nav__ico) {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: inherit;
        font-weight: inherit;
        line-height: inherit;
        color: inherit;
    }

    .hd-mobile-bottom-nav__ico {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 1.28rem;
        height: 1.28rem;
        font-size: 1.05rem;
        line-height: 1;
        opacity: 0.9;
    }

    .hd-mobile-bottom-nav__ico--taiji,
    .hd-mobile-bottom-nav__ico--fortune-topics {
        width: 1.28rem;
        height: 1.28rem;
    }

    .hd-mobile-bottom-nav__ico--taiji img,
    .hd-mobile-bottom-nav__ico--fortune-topics img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* 底栏勿复用侧栏 rail 图标尺寸，避免「题」字错位、挤掉文案 */
    .hd-mobile-bottom-nav .rail-nav-ico,
    .hd-mobile-bottom-nav .rail-nav-ico--exam-bank {
        width: 1.28rem !important;
        height: 1.28rem !important;
        min-width: 1.28rem;
        border-radius: 7px;
        background: rgba(232, 184, 106, 0.18);
        border: 1px solid rgba(126, 96, 58, 0.16);
        position: relative;
    }

    .hd-mobile-bottom-nav .rail-nav-ico--exam-bank::after {
        content: '题';
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        font-size: 0.72rem;
        font-weight: 700;
        color: #6b4a8a;
        line-height: 1;
    }

    .hd-mobile-bottom-nav a.hd-mobile-bottom-nav__btn {
        text-decoration: none;
        color: #6b6154;
    }

    .hd-mobile-bottom-nav__btn--active {
        color: #3a2f1f;
        background: rgba(232, 184, 106, 0.22);
    }

    .hd-mobile-bottom-nav__btn--active .hd-mobile-bottom-nav__ico {
        opacity: 1;
    }

    /* ── 排盘结果壳：手机通栏圆角卡片（电脑端不动）── */
    .main {
        padding: 0.35rem 0.4rem 0 !important;
        justify-content: stretch;
    }

    body:has(.hd-mobile-bottom-nav) .main {
        padding-bottom: 0 !important;
    }

    body:has(.main-inner.view-qimen.has-qimen-result) .main,
    body:has(.main-inner.view-liuren.has-liuren-result) .main,
    body:has(.main-inner.has-result) .main {
        padding: 0.35rem 0.4rem 0 !important;
    }

    /* 七政有结果：去掉 main 左右留白，盘可拉满屏宽 */
    body:has(.main-inner.view-qizheng.has-qizheng-result) .main {
        padding: 0.2rem 0 0 !important;
    }

    .main-inner {
        width: 100% !important;
        max-width: none !important;
        padding-left: 0;
        padding-right: 0;
        margin-inline: 0;
    }

    .content-grid {
        width: 100%;
        max-width: 100%;
        padding-inline: 0;
        gap: 0.55rem;
    }

    .form-shell,
    .result-shell,
    #caseDetailArea.result-shell,
    #unifiedPaipanShell.unified-paipan-shell,
    #qimenResultShell.result-shell,
    #liurenResultShell.result-shell,
    #qizhengResultShell.result-shell,
    .bazi-paipan-stack,
    #fortuneTopicsSection.fortune-topics-shell,
    .main-inner.has-result .form-shell,
    .main-inner.has-result #caseDetailArea.result-shell,
    .main-inner.view-qimen.has-qimen-result #qimenResultShell.result-shell,
    .main-inner.view-liuren.has-liuren-result #liurenResultShell.result-shell,
    .main-inner.view-qizheng.has-qizheng-result #qizhengResultShell.result-shell,
    .main-inner.view-qimen.has-qimen-result #unifiedPaipanShell,
    .main-inner.has-result #caseDetailArea.result-shell.result-mode--ziwei {
        width: 100% !important;
        max-width: none !important;
        margin-inline: 0 !important;
        box-sizing: border-box;
        border-radius: 18px !important;
        box-shadow:
            0 8px 28px rgba(42, 30, 18, 0.1),
            0 1px 0 rgba(255, 255, 255, 0.75) inset;
    }

    /* 有结果时：结果卡撑满可视高度（顶栏下到手机底栏上） */
    .main-inner.view-qimen.has-qimen-result #qimenResultShell.result-shell,
    .main-inner.view-liuren.has-liuren-result #liurenResultShell.result-shell,
    .main-inner.view-qizheng.has-qizheng-result #qizhengResultShell.result-shell,
    .main-inner.has-result #caseDetailArea.result-shell {
        min-height: calc(
            100dvh - 3.4rem - var(--ziwei-mobile-nav-h, 4.6rem) - env(safe-area-inset-bottom, 0px) - 0.7rem
        ) !important;
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .main-inner.view-qimen.has-qimen-result,
    .main-inner.view-liuren.has-liuren-result,
    .main-inner.view-qizheng.has-qizheng-result,
    .main-inner.has-result:has(#caseDetailArea.result-shell) {
        padding-bottom: calc(var(--ziwei-mobile-nav-h, 4.6rem) + env(safe-area-inset-bottom, 0px) + 0.35rem) !important;
    }

    @media (max-width: 480px) {
        .form-shell,
        .result-shell,
        #caseDetailArea.result-shell,
        #unifiedPaipanShell.unified-paipan-shell,
        #qimenResultShell.result-shell,
        #liurenResultShell.result-shell,
        #qizhengResultShell.result-shell,
        .bazi-paipan-stack,
        #fortuneTopicsSection.fortune-topics-shell {
            padding: clamp(0.72rem, 3vw, 0.95rem) clamp(0.58rem, 2.6vw, 0.85rem);
            border-radius: 16px !important;
        }

        /* 七政例外：盘区仍无左右内边距 */
        #qizhengResultShell.result-shell {
            padding-left: 0 !important;
            padding-right: 0 !important;
            border-radius: 0 !important;
        }
    }

    /* ── 奇门 / 大六壬：仅在对应主视图有结果时强制 flex，避免档案跳转时与八字壳叠层 ── */
    .main-inner.view-qimen.has-qimen-result #qimenResultShell.qimen-result-shell,
    .main-inner.view-liuren.has-liuren-result #liurenResultShell.liuren-result-shell {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
        overflow: visible;
        flex: 0 1 auto !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
    }

    .main-inner.view-qimen.has-qimen-result #baziPaipanStack,
    .main-inner.view-liuren.has-liuren-result #baziPaipanStack {
        flex: 0 1 auto;
        height: auto;
    }

    .qimen-result-shell__head,
    .liuren-result-shell__head {
        flex: 0 0 auto;
        margin-bottom: 0;
        padding-bottom: 0.3rem;
        width: 100%;
    }

    .qimen-result-shell__head-top {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .qimen-result-shell__head .result-shell-title,
    .liuren-result-shell__head .result-shell-title {
        font-size: clamp(0.95rem, 4.2vw, 1.15rem);
        line-height: 1.35;
    }

    .qimen-result-shell__pillars-panel,
    .liuren-result-shell__pillars-panel {
        margin-top: 0;
        margin-bottom: 0.55rem;
        width: 100%;
        flex: 0 0 auto;
    }

    .qimen-result-shell__meta {
        margin-bottom: 0.45rem;
        gap: 0.28rem;
        line-height: 1.45;
    }

    .qimen-result-when,
    .liuren-result-when {
        line-height: 1.45;
        word-break: break-word;
    }

    .qimen-result-pillars-row,
    .qizheng-result-pillars-row,
    .liuren-result-shell__pillars-row {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.35rem 0.4rem;
    }

    .qimen-result-fourpillars,
    .liuren-result-fourpillars,
    .qizheng-result-fourpillars {
        margin-top: 0.2rem;
    }

    .qimen-result-pillar-col,
    .liuren-result-pillar-col,
    .qizheng-result-pillar-col {
        gap: 0.32rem;
        min-height: 2.65rem;
    }

    .qimen-result-pillar-label,
    .liuren-result-pillar-label,
    .qizheng-result-pillar-label {
        line-height: 1.3;
    }

    .qimen-result-pillar-gz,
    .liuren-result-pillar-gz,
    .qizheng-result-pillar-gz {
        line-height: 1.35;
    }

    /* 四柱网格：间距缩小、文字换行 */
    .bazi-grid,
    .bazi-result-pillars-row .bazi-grid,
    .palace-grid,
    .qimen-result-fourpillars,
    .qizheng-result-fourpillars,
    .liuren-result-fourpillars {
        gap: clamp(0.15rem, 1.2vw, 0.45rem);
    }

    .bazi-item,
    .bazi-grid .bazi-item {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .bazi-item .pillar,
    .bazi-grid .bazi-item .pillar {
        font-size: clamp(1rem, 4.5vw, 1.65rem);
        overflow-wrap: anywhere;
    }

    .bazi-item .bazi-canggan,
    .bazi-grid .bazi-item .bazi-canggan {
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal;
    }

    .qimen-result-pillar-col,
    .qizheng-result-pillar-col,
    .liuren-result-pillar-col {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .qimen-result-pillar-gz,
    .qizheng-result-pillar-gz,
    .liuren-result-pillar-gz {
        font-size: clamp(0.95rem, 4vw, 1.45rem);
        overflow-wrap: anywhere;
    }

    /* 八字结果四柱行可纵向叠放；奇门/六壬/七政见上方专用规则保持横排 */
    .bazi-result-pillars-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
    }

    .bazi-result-pillars-row .bazi-grid,
    .qimen-result-pillars-row .qimen-result-fourpillars,
    .qizheng-result-pillars-row .qizheng-result-fourpillars {
        width: 100%;
    }

    /* 顶部「导出 / 复制给 AI」：同一行横排（各术数一致） */
    .result-shell-actions {
        display: inline-flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        width: auto;
        max-width: 100%;
        gap: 0.35rem;
    }

    /* 奇门 / 六壬 / 七政底部操作钮：手机两列两行，避免字重叠 */
    .qimen-result-actions,
    .liuren-result-actions,
    .qizheng-result-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
        width: 100% !important;
    }

    .qimen-result-actions .paipan-result-datetime-btn,
    .liuren-result-actions .paipan-result-datetime-btn,
    .qizheng-result-actions .paipan-result-datetime-btn,
    .qimen-result-actions .qimen-action-btn,
    .liuren-result-actions .qimen-action-btn,
    .qizheng-result-actions .qimen-action-btn,
    .qimen-result-actions .primary-btn,
    .liuren-result-actions .primary-btn,
    .qizheng-result-actions .primary-btn,
    .qimen-result-actions .qimen-sheet-btn {
        flex: 1 1 calc(50% - 0.2rem) !important;
        width: calc(50% - 0.2rem) !important;
        min-width: calc(50% - 0.2rem) !important;
        max-width: calc(50% - 0.2rem) !important;
        white-space: normal !important;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
        height: auto !important;
        line-height: 1.35 !important;
        font-size: 0.76rem !important;
        min-height: 2.7rem !important;
        padding: 0.65rem 0.5rem !important;
        border-radius: var(--btn-radius, 10px) !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }

    .result-shell-actions .result-copy-for-ai-btn,
    .result-shell-actions .result-export-facts-btn {
        width: auto;
        max-width: none;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        text-align: center;
        padding: 0.45rem 0.55rem;
        font-size: 0.72rem;
        line-height: 1.35;
        height: auto;
        min-height: 2.35rem;
    }

    .bazi-result-shell__pillar-actions .result-copy-for-ai-btn,
    .bazi-result-shell__pillar-actions .result-export-facts-btn,
    #baziZiweiCopyForAiBtn,
    #baziZiweiExportFactsBtn {
        width: 100%;
        max-width: none;
        white-space: normal;
        text-align: center;
        padding: 0.35rem 0.4rem;
        font-size: 0.68rem;
        line-height: 1.25;
    }

    #caseDetailArea.result-mode--ziwei .result-shell-actions,
    #caseDetailArea.result-mode--ziwei .result-shell-head--bazi-extra .result-shell-actions {
        display: inline-flex !important;
        flex-direction: row !important;
        align-items: center !important;
        width: auto !important;
        gap: 0.35rem !important;
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
    }

    #caseDetailArea.result-mode--ziwei #baziZiweiCopyForAiBtn,
    #caseDetailArea.result-mode--ziwei #baziZiweiExportFactsBtn,
    #caseDetailArea.result-mode--ziwei .result-copy-for-ai-btn,
    #caseDetailArea.result-mode--ziwei .result-export-facts-btn {
        width: 100% !important;
        max-width: none !important;
        white-space: normal !important;
        min-height: 2.35rem !important;
        padding: 0.35rem 0.4rem !important;
        font-size: 0.68rem !important;
        line-height: 1.25 !important;
    }

    #caseDetailArea.result-mode--ziwei .result-shell-head--bazi-extra {
        grid-template-columns: auto 1fr auto !important;
        row-gap: 0 !important;
    }

    /* 八字操作栏：手机两列；七政单独用 3+2 网格（见 style.css） */
    .qimen-result-shell__pillar-actions,
    .liuren-result-shell__pillar-actions,
    .bazi-result-shell__pillar-actions,
    .metaphysics-result-pillar-actions:not(.qizheng-result-shell__pillar-actions) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.35rem;
        width: 100%;
    }

    .qizheng-result-shell__pillar-actions,
    #qizhengResultShell .qizheng-result-shell__pillar-actions {
        display: grid !important;
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        gap: 0.4rem !important;
        width: 100%;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions .paipan-result-datetime-btn,
    #qizhengResultShell .qizheng-result-shell__pillar-actions .qizheng-repaipan-btn {
        grid-column: span 2 !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions .qizheng-pillar-action-btn {
        grid-column: span 3 !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions #qizhengExportFactsBtn {
        background: #fffdf8 !important;
        color: #5a4a34 !important;
        border: 1px solid rgba(160, 130, 80, 0.45) !important;
        box-shadow: none !important;
    }

    .paipan-result-calendar-wrap {
        min-width: 7.2rem;
        max-width: 100%;
    }

    .paipan-result-tools-col {
        min-width: 7.2rem;
        max-width: 11rem;
    }

    .paipan-result-calendar-panel {
        left: 0;
        right: auto;
        min-width: min(16.5rem, calc(100vw - 1.5rem));
    }

    .qimen-result-shell__pillar-actions .paipan-result-datetime-actions--pillars,
    .liuren-result-shell__pillar-actions .paipan-result-datetime-actions--pillars,
    .bazi-result-shell__pillar-actions .paipan-result-datetime-actions--pillars,
    .qizheng-result-shell__pillar-actions .paipan-result-datetime-actions--pillars,
    .metaphysics-result-pillar-actions .paipan-result-datetime-actions--pillars {
        display: contents;
    }

    .qimen-result-shell__pillar-actions .paipan-result-datetime-btn,
    .qimen-result-shell__pillar-actions .qimen-show-paipan-btn,
    .liuren-result-shell__pillar-actions .paipan-result-datetime-btn,
    .liuren-result-shell__pillar-actions .liuren-repaipan-btn,
    .bazi-result-shell__pillar-actions .paipan-result-datetime-btn,
    .bazi-result-shell__pillar-actions .bazi-repaipan-btn,
    .bazi-result-shell__pillar-actions .result-open-modal-btn,
    .qizheng-result-shell__pillar-actions .paipan-result-datetime-btn,
    .qizheng-result-shell__pillar-actions .qizheng-repaipan-btn,
    .qizheng-result-shell__pillar-actions .qizheng-pillar-action-btn {
        width: 100%;
        min-width: 0;
        padding: 0.36rem 0.22rem;
        font-size: 0.68rem;
        white-space: normal;
        text-align: center;
        line-height: 1.3;
    }

    /* 未纳入三列工具栏时的旧 datetime 区仍可纵向 */
    .paipan-result-datetime-actions:not(.paipan-result-datetime-actions--pillars) {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        gap: 0.32rem;
    }

    .result-shell-head--bazi-extra {
        grid-template-columns: 1fr;
        row-gap: 0.45rem;
    }

    .result-shell-head--bazi-extra .result-shell-title,
    .result-shell-head--bazi-extra .bazi-extra-charts--in-head,
    .result-shell-head--bazi-extra .result-shell-actions {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
        justify-self: stretch;
    }

    .result-shell-head--bazi-extra .bazi-extra-charts__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.28rem;
    }

    .result-shell-head--bazi-extra .bazi-extra-charts__btn {
        min-height: 2.35rem;
        padding: 0.28rem 0.12rem;
        font-size: 0.62rem;
    }

    /* 档案信息、宫位切换标签：窄屏缩小内边距 */
    .tabs {
        margin-bottom: 1rem;
    }

    .tab {
        padding: 0.62rem 0.55rem;
        font-size: 0.78rem;
        line-height: 1.3;
    }

    .bazi-overview {
        padding: 0.58rem 0.65rem;
        gap: 0.55rem;
    }

    .bazi-extra-charts__btn {
        padding: 0.32rem 0.22rem;
        font-size: 0.64rem;
    }

    .fortune-topics-selected-profile {
        padding: 0.62rem 0.72rem;
    }

    .fortune-topics-selected-profile__line {
        font-size: 0.78rem;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .case-archive-view__head,
    .case-archive-view__search {
        padding-inline: 0.65rem;
    }

    .case-archive-view {
        width: 95vw;
        max-width: min(680px, 95vw);
        margin-inline: auto;
    }

    /* ── 运势专题（calculator 内嵌 + 通用卡片）── */
    .fortune-topic-cards {
        width: 100%;
        max-width: 100%;
        gap: 0.65rem;
        --fortune-topic-sections-h: auto;
    }

    /* 双栏改单栏：覆盖桌面 min-width:1025px 栅格 */
    .fortune-topic-card {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        grid-template-areas: unset !important;
        width: 100%;
        max-width: 100%;
    }

    .fortune-topic-card__main {
        width: 100%;
        padding: 0.62rem 0.75rem 0.35rem;
        min-height: auto;
    }

    .fortune-topic-card__dropdown {
        grid-template-columns: 1fr !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        width: calc(100% - 1.16rem);
        margin: 0 0.58rem 0.45rem;
        overflow-wrap: anywhere;
    }

    .fortune-topic-card__method-panel {
        position: static;
        width: calc(100% - 1.16rem);
        margin: 0 0.58rem 0.45rem;
        align-self: stretch;
        min-height: 0;
    }

    .fortune-topic-card__method-item {
        flex-wrap: wrap;
        font-size: 0.86rem;
        gap: 0.38rem 0.5rem;
        overflow-wrap: anywhere;
    }

    .fortune-topic-card__method-panel .fortune-topic-card__copy-ai-btn {
        width: 100%;
        max-width: none;
        margin-top: 0.35rem;
        padding: 0.55rem 0.75rem;
        font-size: 0.88rem;
        border-radius: 12px;
    }

    .pro-reading-bundle__panel {
        padding: 0.42rem 0.35rem 0.5rem;
    }

    /* ── 运势专题独立页 fortune-topics.html ── */
    .ft-main {
        width: 100%;
        max-width: min(640px, 95vw);
        padding-inline: clamp(0.55rem, 2.5vw, 0.85rem);
    }

    .ft-topic-list {
        gap: 0.65rem;
    }

    .ft-topic-card {
        width: 100%;
        max-width: 100%;
        padding: 0.72rem 0.72rem 0.65rem;
        min-height: 0;
    }

    .ft-topic-card__grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(5.2rem, max-content) !important;
        grid-template-rows: auto auto auto !important;
        gap: 0.45rem 0.4rem;
    }

    .ft-topic-card__main {
        grid-column: 1;
        grid-row: 1;
        max-height: none;
        overflow: visible;
    }

    .ft-topic-card__methods {
        grid-column: 2;
        grid-row: 1;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-end;
        justify-self: end;
        align-self: start;
        min-width: 5.2rem;
        max-width: min(11rem, 46%);
        width: max-content;
        gap: 0.28rem;
        text-align: right;
    }

    .ft-method-item {
        flex: 0 1 auto;
        max-width: 100%;
        font-size: 0.66rem;
        word-break: keep-all;
        justify-content: flex-end;
    }

    .ft-topic-card__copy {
        width: 100%;
        max-width: none;
        margin-left: 0;
        margin-top: 0.45rem;
        padding: 0.52rem 0.75rem;
        border-radius: 12px;
        font-size: 0.78rem;
    }

    .ft-profile-card {
        width: 100%;
        padding: 0.72rem 0.78rem;
    }

    /* ── Capacitor / 安卓 WebView / iOS WKWebView 触摸设备 ── */
    @media (hover: none) and (pointer: coarse) {
        html {
            font-size: 15px;
        }

        body {
            min-height: 100vh;
            min-height: -webkit-fill-available;
        }

        .form-shell,
        .result-shell,
        .ft-main,
        .ft-topic-card,
        .fortune-topic-card {
            font-size: 1rem;
        }

        .tab,
        .primary-btn,
        .paipan-result-datetime-btn,
        .result-copy-for-ai-btn,
        .fortune-topic-card__method-panel .fortune-topic-card__copy-ai-btn,
        .ft-topic-card__copy {
            min-height: 2.75rem;
        }

        .bazi-item .pillar,
        .bazi-grid .bazi-item .pillar {
            font-size: clamp(1.05rem, 4.8vw, 1.72rem);
        }

        .hd-mobile-bottom-nav__btn {
            font-size: 0.6rem;
        }
    }

    /* 注册命书 / 档案编辑弹窗：手机端底部 sheet 布局 */
    .register-lifebook-overlay.is-open,
    .archive-edit-overlay.is-open {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
    }

    .register-lifebook-modal,
    .archive-edit-modal {
        width: 100%;
        max-width: 100%;
        max-height: min(88dvh, 720px);
        margin: 0;
        border-radius: 18px 18px 0 0;
    }

    .register-lifebook-head,
    .archive-edit-modal .bazi-modal-head {
        padding: 0.45rem 0.85rem 0.35rem;
    }

    .register-lifebook-head .bazi-modal-title,
    .archive-edit-modal .bazi-modal-title {
        font-size: 0.95rem;
        line-height: 1.25;
    }

    .register-lifebook-hint {
        font-size: 0.66rem;
        line-height: 1.35;
        margin: 0.12rem 0 0;
    }

    .register-lifebook-mount,
    .archive-edit-mount {
        max-height: calc(88dvh - 148px);
        padding-bottom: 0.35rem;
    }

    .register-lifebook-mount .unified-paipan-shell,
    .register-lifebook-mount .form-shell,
    .archive-edit-mount .unified-paipan-shell,
    .archive-edit-mount .form-shell {
        width: 100% !important;
        max-width: 100% !important;
        padding-inline: 0 !important;
    }

    .register-lifebook-mount .datetime-wheel-wrap,
    .archive-edit-mount .datetime-wheel-wrap {
        width: 100%;
        max-width: 100%;
    }

    .register-lifebook-mount .wheel-col,
    .archive-edit-mount .wheel-col {
        min-width: 0;
        flex: 1 1 0;
    }

    .register-lifebook-actions,
    .archive-edit-actions {
        padding: 0.75rem 1rem max(0.85rem, env(safe-area-inset-bottom, 0px));
        background: linear-gradient(180deg, rgba(250, 245, 236, 0.94), rgba(245, 236, 220, 0.98));
    }
}

/* ── 七政四余 · 手机端专用（≤768，独立媒体查询，避免嵌套失效/被旧缓存挡住）── */
@media screen and (max-width: 768px) {
    /* 顶部大四柱整块隐藏，只留时间摘要行 */
    #qizhengResultShell .qizheng-result-shell__pillars-panel .qizheng-result-pillars-row,
    #qizhengResultShell .qizheng-result-shell__pillars-panel .qizheng-result-fourpillars,
    #qizhengResultShell .qizheng-result-shell__pillars-panel .qizheng-result-pillars-caption {
        display: none !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillars-panel {
        margin: 0 0 0.35rem !important;
        padding: 0.35rem 0.5rem !important;
        border-radius: 10px !important;
    }

    #qizhengResultShell .qizheng-result-head-row {
        margin-bottom: 0 !important;
    }

    #qizhengResultShell .qizheng-result-when,
    #qizhengResultShell .qizheng-result-place,
    #qizhengResultShell .qizheng-result-calc-line {
        font-size: 0.7rem !important;
        line-height: 1.35 !important;
    }

    #qizhengResultShell .result-shell-title {
        font-size: 0.92rem !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions .paipan-result-datetime-btn,
    #qizhengResultShell .qizheng-result-shell__pillar-actions .qizheng-repaipan-btn {
        grid-column: span 2 !important;
        font-size: 0.74rem !important;
        padding: 0.55rem 0.35rem !important;
        min-height: 2.65rem !important;
        line-height: 1.35 !important;
        border-radius: var(--btn-radius, 10px) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: none !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions .qizheng-pillar-action-btn {
        grid-column: span 3 !important;
        font-size: 0.74rem !important;
        padding: 0.55rem 0.5rem !important;
        min-height: 2.65rem !important;
        line-height: 1.35 !important;
        border-radius: var(--btn-radius, 10px) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: none !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #qizhengResultShell .qizheng-result-shell__pillar-actions #qizhengExportFactsBtn {
        background: #fffdf8 !important;
        color: #5a4a34 !important;
        border: 1px solid rgba(160, 130, 80, 0.45) !important;
        box-shadow: none !important;
    }

    /* 七政结果卡：水平无内边距，只留一个最大盘底框 */
    #qizhengResultShell.result-shell {
        padding-left: 0 !important;
        padding-right: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    #qizhengResultShell .qizheng-result-shell__head,
    #qizhengResultShell .qizheng-result-shell__pillar-actions,
    #qizhengResultShell .qizheng-meta-chips,
    #qizhengResultShell .qizheng-chart-info-card,
    #qizhengResultShell .qizheng-mingdu-row,
    #qizhengResultShell .qizheng-bottom-bar-mount {
        padding-left: 0.55rem !important;
        padding-right: 0.55rem !important;
        box-sizing: border-box !important;
    }

    #qizhengResultShell .qizheng-wheel-zoom-bar,
    #qizhengResultShell .qizheng-wheel-zoom-btn {
        display: none !important;
    }

    /* 唯一盘底框：整屏宽；盘面双指捏合放大 */
    #qizhengResultShell .qizheng-wheel-stage--moira {
        position: relative !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100vw !important;
        max-width: none !important;
        margin-left: calc(50% - 50vw) !important;
        background: radial-gradient(ellipse at 50% 42%, #faf6ee 0%, #f0e8d8 68%, #e8dcc8 100%) !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: hidden !important;
    }

    #qizhengResultShell .qizheng-wheel-zoom-viewport {
        width: 100% !important;
        height: 100vw !important;
        max-height: min(100vw, 92dvh) !important;
        overflow: hidden !important;
        overscroll-behavior: auto;
        /* 单指交给整页滚动；双指捏合由 JS 处理 */
        touch-action: pan-y !important;
        background: transparent !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    #qizhengResultShell .qizheng-wheel-zoom-viewport::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    #qizhengResultShell .qizheng-wheel-zoom-sizer {
        position: relative;
        margin: 0;
        padding: 0;
    }

    #qizhengResultShell .qizheng-wheel-zoom-inner {
        width: 100%;
        height: auto;
        min-height: 0;
        display: block;
        transform-origin: 0 0;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    #qizhengResultShell .qizheng-wheel-stage--moira .qizheng-wheel-svg {
        width: 100%;
        max-width: none !important;
        max-height: none !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        display: block !important;
        margin: 0 !important;
    }

    #qizhengResultShell .qizheng-mingdu-strip {
        padding: 0.3rem 0.45rem !important;
    }

    #qizhengResultShell .qizheng-mingdu-strip__label {
        font-size: 0.62rem !important;
    }

    #qizhengResultShell .qizheng-mingdu-strip__val {
        font-size: 0.72rem !important;
    }

    /* 盘面摘要与本命盘分离：去掉正方形底框，盘面拉满 */
    #qizhengResultShell .qizheng-pan-area {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    #qizhengResultShell .qizheng-chart-info-card {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        z-index: 2 !important;
        order: -1;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 0 0.25rem !important;
        font-size: 0.72rem !important;
        padding: 0.35rem 0.45rem !important;
        border: 1px solid rgba(160, 130, 80, 0.28) !important;
        border-radius: 10px !important;
        background: rgba(255, 252, 245, 0.96) !important;
        box-shadow: none !important;
    }

    #qizhengResultShell .qizheng-chart-info-card__pillars {
        font-size: 0.82rem !important;
        margin: 0 !important;
    }

    #qizhengResultShell .qizheng-pan-mount {
        position: relative !important;
        z-index: 0 !important;
        width: 100% !important;
        background: transparent !important;
    }

    #qizhengResultShell .qizheng-pan-layout--moira {
        gap: 0.35rem !important;
        background: transparent !important;
    }

    #qizhengResultShell .qizheng-mingdu-row {
        padding: 0 0.35rem 0.35rem !important;
    }

    #qizhengResultShell .qizheng-bottom-bar-mount {
        padding: 0 0.35rem 0.4rem !important;
        background: transparent !important;
    }

    /* 右上角：命盘信息 + 盘制设置同一行；子项点击展开 */
    #qizhengResultShell .qizheng-quick-bar--corner {
        top: 0.2rem !important;
        right: 0.2rem !important;
        max-width: min(11.5rem, 56%) !important;
        gap: 0.2rem !important;
        padding: 0.22rem 0.24rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        z-index: 8 !important;
    }

    #qizhengResultShell .qizheng-quick-top-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 0.2rem !important;
        width: 100% !important;
    }

    #qizhengResultShell .qizheng-quick-mobile-only {
        display: block !important;
    }

    #qizhengResultShell .qizheng-quick-info-menu {
        display: none !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.15rem !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0.15rem 0 0 !important;
        border-top: 1px solid rgba(160, 130, 80, 0.22);
    }

    #qizhengResultShell .qizheng-quick-info-menu.is-open {
        display: flex !important;
    }

    #qizhengResultShell .qizheng-quick-bar--corner .qizheng-quick-btn {
        display: block !important;
        width: 100% !important;
        font-size: 0.62rem !important;
        padding: 0.28rem 0.32rem !important;
        line-height: 1.3 !important;
        text-align: center !important;
    }

    #qizhengResultShell .qizheng-quick-top-row > .qizheng-quick-btn {
        flex: 1 1 0 !important;
        width: auto !important;
        min-width: 0 !important;
        font-size: 0.66rem !important;
        font-weight: 700 !important;
        padding: 0.34rem 0.28rem !important;
        white-space: nowrap !important;
    }

    #qizhengResultShell .qizheng-quick-btn--info-menu.is-open,
    #qizhengResultShell .qizheng-quick-btn--pan-opts.is-open {
        background: linear-gradient(180deg, #f0d49a, #e0b56a) !important;
        border-color: rgba(160, 120, 50, 0.55) !important;
        font-weight: 700 !important;
    }

    /* 盘制设置面板：挂在右上角快捷栏内，不盖住命盘中心 */
    #qizhengResultShell .qizheng-sidereal-corner.qizheng-sidereal-corner--panel,
    .qizheng-sidereal-corner.qizheng-sidereal-corner--panel {
        position: static !important;
        left: auto !important;
        bottom: auto !important;
        max-width: none !important;
        width: 100% !important;
        margin-top: 0.2rem !important;
        padding: 0.32rem 0.28rem !important;
        border: 1px solid rgba(160, 130, 80, 0.35) !important;
        border-radius: 8px !important;
        background: rgba(255, 252, 245, 0.98) !important;
        box-shadow: 0 4px 14px rgba(40, 28, 12, 0.12) !important;
        gap: 0.22rem !important;
    }

    #qizhengResultShell .qizheng-sidereal-corner.qizheng-sidereal-corner--panel:not(.is-open),
    .qizheng-sidereal-corner.qizheng-sidereal-corner--panel:not(.is-open) {
        display: none !important;
    }

    #qizhengResultShell .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__field,
    .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__field {
        width: 100% !important;
    }

    #qizhengResultShell .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__select,
    #qizhengResultShell .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__transit-btn,
    .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__select,
    .qizheng-sidereal-corner.qizheng-sidereal-corner--panel .qizheng-sidereal-corner__transit-btn {
        max-width: none !important;
        width: 100% !important;
    }

    /* 旧左下角浮层：手机端改为面板后不再叠在盘上 */
    #qizhengResultShell .qizheng-wheel-stage > .qizheng-sidereal-corner:not(.qizheng-sidereal-corner--panel) {
        display: none !important;
    }

    /* 底部微调（bar 可能挂在 pan-layout 内） */
    #qizhengFineTuneBar.qizheng-fine-tune--bottom,
    #qizhengBottomBarMount .qizheng-fine-tune--bottom {
        padding: 0.4rem 0.35rem !important;
        font-size: 0.75rem !important;
    }

    /* 流年时间 | 出生信息列（出生信息上、快速输入下）；真太阳时下一行 */
    #qizhengFineTuneBar .qizheng-time-stack,
    #qizhengBottomBarMount .qizheng-time-stack {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: flex-end !important;
        gap: 0.28rem 0.32rem !important;
        width: 100% !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--transit,
    #qizhengBottomBarMount .qizheng-time-col--transit {
        order: 1 !important;
        flex: 1 1 34% !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--birth,
    #qizhengBottomBarMount .qizheng-time-col--birth {
        order: 2 !important;
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 0.22rem !important;
        flex: 1 1 58% !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--loc,
    #qizhengBottomBarMount .qizheng-time-col--loc {
        order: 3 !important;
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0.1rem 0 0 !important;
        padding: 0.28rem 0 0 !important;
        border: none !important;
        border-top: 1px dashed rgba(160, 130, 80, 0.22) !important;
    }

    #qizhengFineTuneBar .qizheng-time-row--birth,
    #qizhengBottomBarMount .qizheng-time-row--birth,
    #qizhengFineTuneBar .qizheng-time-row--transit,
    #qizhengBottomBarMount .qizheng-time-row--transit {
        flex: 0 0 auto !important;
        flex-direction: column !important;
        align-items: stretch !important;
        min-width: 0 !important;
        width: 100% !important;
        gap: 0.12rem !important;
    }

    #qizhengFineTuneBar .qizheng-fine-tune__label,
    #qizhengBottomBarMount .qizheng-fine-tune__label,
    #qizhengFineTuneBar .qizheng-birth-quick__label,
    #qizhengBottomBarMount .qizheng-birth-quick__label {
        display: block !important;
        width: 100% !important;
        font-size: 0.58rem !important;
        font-weight: 700 !important;
        margin: 0 0 0.08rem !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }

    #qizhengFineTuneBar .qizheng-fine-tune__when--transit,
    #qizhengBottomBarMount .qizheng-fine-tune__when--transit {
        font-size: 0.62rem !important;
        line-height: 1.25 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    #qizhengFineTuneBar .qizheng-fine-tune__controls,
    #qizhengBottomBarMount .qizheng-fine-tune__controls,
    #qizhengFineTuneBar .qizheng-time-row--transit .qizheng-fine-tune__controls,
    #qizhengBottomBarMount .qizheng-time-row--transit .qizheng-fine-tune__controls {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.16rem !important;
        width: 100% !important;
    }

    #qizhengFineTuneBar .qizheng-fine-tune__step-btn,
    #qizhengBottomBarMount .qizheng-fine-tune__step-btn,
    #qizhengFineTuneBar .qizheng-fine-tune__action-btn,
    #qizhengBottomBarMount .qizheng-fine-tune__action-btn,
    #qizhengFineTuneBar .qizheng-birth-quick__btn,
    #qizhengBottomBarMount .qizheng-birth-quick__btn {
        min-height: 1.55rem !important;
        height: 1.55rem !important;
        padding: 0 0.28rem !important;
        font-size: 0.58rem !important;
        line-height: 1 !important;
        flex: 0 0 auto !important;
    }

    #qizhengFineTuneBar .qizheng-fine-tune__unit,
    #qizhengBottomBarMount .qizheng-fine-tune__unit {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        min-height: 1.55rem !important;
        height: 1.55rem !important;
        font-size: 0.58rem !important;
        padding: 0 0.15rem !important;
    }

    /* 出生信息：年月日时紧凑四列 */
    #qizhengFineTuneBar .qizheng-birth-datetime-selects,
    #qizhengBottomBarMount .qizheng-birth-datetime-selects {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0.14rem !important;
        width: 100% !important;
    }

    #qizhengFineTuneBar .qizheng-birth-select,
    #qizhengBottomBarMount .qizheng-birth-select {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        font-size: 0.58rem !important;
        min-height: 1.55rem !important;
        height: 1.55rem !important;
        padding: 0 0.08rem !important;
    }

    /* 快速输入：叠在出生信息下方同一列 */
    #qizhengFineTuneBar .qizheng-birth-quick,
    #qizhengBottomBarMount .qizheng-birth-quick {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        gap: 0.12rem !important;
    }

    #qizhengFineTuneBar .qizheng-birth-quick__row,
    #qizhengBottomBarMount .qizheng-birth-quick__row {
        width: 100% !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 0.14rem !important;
    }

    #qizhengFineTuneBar .qizheng-birth-quick__input,
    #qizhengBottomBarMount .qizheng-birth-quick__input {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        font-size: 0.58rem !important;
        min-height: 1.55rem !important;
        height: 1.55rem !important;
        padding: 0 0.2rem !important;
    }

    #qizhengFineTuneBar .qizheng-birth-quick__hint,
    #qizhengBottomBarMount .qizheng-birth-quick__hint {
        display: none !important;
    }

    /* 真太阳时：标签 + 省份 / 地区同一行 */
    #qizhengFineTuneBar .qizheng-time-col--loc,
    #qizhengBottomBarMount .qizheng-time-col--loc {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.28rem !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--loc > .qizheng-fine-tune__label,
    #qizhengBottomBarMount .qizheng-time-col--loc > .qizheng-fine-tune__label {
        flex: 0 0 auto !important;
        width: auto !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--loc .qizheng-time-col__loc-row,
    #qizhengBottomBarMount .qizheng-time-col--loc .qizheng-time-col__loc-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        flex: 1 1 auto !important;
        width: auto !important;
        max-width: none !important;
        gap: 0.28rem !important;
        min-width: 0 !important;
    }

    #qizhengFineTuneBar .qizheng-time-col--loc .qizheng-fine-tune__select,
    #qizhengBottomBarMount .qizheng-time-col--loc .qizheng-fine-tune__select {
        flex: 1 1 0 !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        font-size: 0.72rem !important;
        min-height: 2.05rem !important;
    }

    /* 流年时间：单独一块 */
    #qizhengFineTuneBar .qizheng-time-row--transit,
    #qizhengBottomBarMount .qizheng-time-row--transit {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 0.25rem !important;
    }

    #qizhengFineTuneBar .qizheng-time-row--transit .qizheng-fine-tune__controls,
    #qizhengBottomBarMount .qizheng-time-row--transit .qizheng-fine-tune__controls {
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    /* 宿度制等：手机端收入右上角盘制设置，避免盖住命盘 */
    #qizhengResultShell .qizheng-sidereal-corner:not(.qizheng-sidereal-corner--panel),
    .qizheng-sidereal-corner:not(.qizheng-sidereal-corner--panel) {
        display: none !important;
    }

    #qizhengResultShell .qizheng-sidereal-corner__select,
    .qizheng-sidereal-corner__select {
        min-width: 0 !important;
        max-width: 9.5rem !important;
        font-size: 0.68rem !important;
        min-height: 1.65rem !important;
        height: auto !important;
        padding: 0.18rem 0.35rem !important;
        line-height: 1.3 !important;
        color: #3a2f21 !important;
        -webkit-text-fill-color: #3a2f21 !important;
        background: #fffdf8 !important;
    }
}

/* 命书 iframe：窄宽度也会命中上方 max-width:1024，此处强制压过底栏 display:flex */
html.embed-lifebook nav.hd-mobile-bottom-nav.hd-mobile-only,
html.embed-lifebook .hd-mobile-bottom-nav {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    padding: 0 !important;
    border: none !important;
}
/* === 手机端：奇门九宫放大可读 + 七政盘面拉满（去掉底框） === */
@media screen and (max-width: 991px) {
    /* —— 奇门：宫格加高、字号加大，避免挤糊裁切 —— */
    .main-inner.view-qimen.has-qimen-result #qimenResultShell,
    .main-inner.view-qimen.has-qimen-result .qimen-result-right,
    .main-inner.view-qimen.has-qimen-result .qimen-board-keying-row,
    .main-inner.view-qimen.has-qimen-result #qimenGridComposite,
    .main-inner.view-qimen.has-qimen-result .qimen-grid-composite-inner,
    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack {
        overflow: visible !important;
    }

    .main-inner.view-qimen.has-qimen-result #qimenGridComposite,
    .main-inner.view-qimen.has-qimen-result #qimenGridComposite.qimen-grid-composite--outer {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-grid {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
        margin-bottom: 0.35rem !important;
        border-radius: 10px !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell {
        font-size: 0.78rem !important;
        line-height: 1.2 !important;
        padding: 0.32rem 0.34rem 0.36rem !important;
        min-height: clamp(7.4rem, 28vw, 9.6rem) !important;
        overflow: visible !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__palace {
        font-size: 0.68rem !important;
        line-height: 1.15 !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__door,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__star,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__leftcol .qimen-palace-cell__door,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__leftcol .qimen-palace-cell__star {
        font-size: 1.05rem !important;
        line-height: 1.15 !important;
        font-weight: 800 !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__deity,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__deity.qimen-deity--text,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__deity--corner {
        font-size: 1.05rem !important;
        line-height: 1.15 !important;
        font-weight: 800 !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__stem,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__dig,
    .main-inner.view-qimen.has-qimen-result .qimen-palace-cell__centerStem,
    .main-inner.view-qimen.has-qimen-result .qimen-stem-row {
        font-size: 0.86rem !important;
        line-height: 1.12 !important;
    }

    .main-inner.view-qimen.has-qimen-result
        #qimenGridComposite:not(.qimen-grid-composite--outer)
        .qimen-palace-grid {
        grid-template-rows: repeat(3, minmax(clamp(7.4rem, 28vw, 9.6rem), auto)) !important;
        min-height: 0 !important;
    }

    .main-inner.view-qimen.has-qimen-result
        #qimenGridComposite:not(.qimen-grid-composite--outer)
        .qimen-palace-cell {
        min-height: clamp(7.4rem, 28vw, 9.6rem) !important;
    }

    /* 有六壬/建神外盘：加宽环带，取消 1:1 挤压，外圈字不被裁 */
    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack {
        --qimen-liuren-band: 2.85rem;
        --qimen-jianchu-band: 1.45rem;
        --qimen-core-max: 100vw;
        --qimen-core-max-vh: 72vh;
        width: 100% !important;
        max-width: 100% !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--liuren,
    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--jianchu {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: unset !important;
        height: auto !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--liuren .qimen-palace-grid,
    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--jianchu .qimen-palace-grid {
        min-height: clamp(7.2rem, 26vw, 9.2rem) !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--liuren .qimen-palace-cell,
    .main-inner.view-qimen.has-qimen-result .qimen-ring-stack--jianchu .qimen-palace-cell {
        min-height: clamp(7.2rem, 26vw, 9.2rem) !important;
        overflow: visible !important;
    }

    .main-inner.view-qimen.has-qimen-result .qimen-liuren-outer-cell,
    .main-inner.view-qimen.has-qimen-result .qimen-jianchu-outer-cell {
        font-size: 0.62rem !important;
        line-height: 1.1 !important;
        overflow: visible !important;
        white-space: nowrap !important;
    }

    /* —— 七政：单一最大底框 + SVG 满宽；字号随盘放大后略回调 —— */
    .main-inner.view-qizheng.has-qizheng-result .qizheng-pan-area {
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-pan-mount,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-pan-layout--moira,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-pan-main {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-stage--moira {
        position: relative !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100vw !important;
        max-width: none !important;
        margin-left: calc(50% - 50vw) !important;
        background: radial-gradient(ellipse at 50% 42%, #faf6ee 0%, #f0e8d8 68%, #e8dcc8 100%) !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-zoom-viewport {
        width: 100% !important;
        height: 100vw !important;
        max-height: min(100vw, 92dvh) !important;
        overflow: hidden !important;
        touch-action: pan-y !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-zoom-viewport::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-zoom-sizer {
        position: relative;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-zoom-inner {
        transform-origin: 0 0;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-stage--moira .qizheng-wheel-svg {
        width: 100%;
        max-width: none !important;
        max-height: none !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        display: block !important;
        margin: 0 !important;
    }

    /* 盘面字号：再加大，配合裁切 viewBox 后 1× 更满更清晰 */
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-branch-label {
        font-size: 20px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-zodiac-num {
        font-size: 21px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer1-branch {
        font-size: 16px !important;
        fill: #111111 !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer2-lord {
        font-size: 14px !important;
        fill: #8a8a8a !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-mansion-label {
        font-size: 14px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-zodiac-palace,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-zodiac-name,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-palace-name {
        font-size: 14px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-year-label {
        font-size: 14px !important;
        stroke-width: 2.4px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-year-label--current {
        font-size: 15px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-deg-label {
        font-size: 14px !important;
        stroke-width: 2.4px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-deg-label--current {
        font-size: 15px !important;
        stroke-width: 2.6px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-changsheng-label {
        font-size: 15px !important;
        stroke-width: 2.2px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-spirit-label {
        font-size: 16.5px !important;
        stroke-width: 2.6px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-spirit-label--mid {
        font-size: 15px !important;
        stroke-width: 2.3px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-spirit-label--dense {
        font-size: 13px !important;
        stroke-width: 2px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--annual-spirit .qz-spirit-label {
        font-size: 15px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--annual-spirit .qz-spirit-label--mid {
        font-size: 13.5px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--annual-spirit .qz-spirit-label--dense {
        font-size: 12px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--natal-spirit .qz-spirit-label {
        font-size: 15.5px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--natal-spirit .qz-spirit-label--mid {
        font-size: 14px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--natal-spirit .qz-spirit-label--dense {
        font-size: 12.5px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--natal-planet .qz-planet-char,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg .qz-planet-char {
        font-size: 22px !important;
        stroke-width: 2.7px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--transit-planet .qz-planet-char,
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-layer--transit-planet--l5 .qz-planet-char {
        font-size: 22px !important;
        stroke-width: 2.7px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-center-label {
        font-size: 14px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-center-sub {
        font-size: 15px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-center-deg {
        font-size: 12.5px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-palace-deg {
        font-size: 5px !important;
    }
    .main-inner.view-qizheng.has-qizheng-result .qizheng-wheel-svg--moira .qz-outer-palace-deg--cusp {
        font-size: 5.5px !important;
    }

    .qizheng-chart-info-card {
        font-size: 0.68rem;
        max-width: min(42%, 11rem);
    }
}

