/**
 * 首页移动端 App 皮肤（≤991px）
 * 桌面端（≥992px）不加载任何覆盖，保持 home-dashboard.css 原样。
 */
@media (min-width: 992px) {
    .hd-mobile-only {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .hd-desktop-only {
        display: none !important;
    }

    .hd-guofeng-decor,
    .hd-ddj,
    .hd-jieqi-mark {
        display: none !important;
    }

    body:has(#examFavoritesModalBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body.exam-favorites-modal-open .hd-mobile-bottom-nav,
    body.hd-lifebook-modal-open .hd-mobile-bottom-nav,
    body:has(#hdLifebookBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#hdArchiveBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#hdArchiveEditBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body:has(#calcPaipanPromptBackdrop:not([hidden])) .hd-mobile-bottom-nav,
    body.hd-side-drawer-open .hd-mobile-bottom-nav {
        display: none !important;
    }

    /* 题库答题时保留底栏 */
    body.exam-bank-modal-open .hd-mobile-bottom-nav,
    body:has(#examBankModalBackdrop:not([hidden])) .hd-mobile-bottom-nav {
        display: flex !important;
        z-index: 1200;
    }

    .hd-body {
        /* 底栏留白仅由 mobile-responsive.css body:has(.hd-mobile-bottom-nav) 负责，避免双重 padding 把主区挤乱 */
        background:
            radial-gradient(120% 70% at 50% -8%, rgba(248, 208, 142, 0.28), transparent 52%),
            linear-gradient(180deg, #fbf6ec 0%, #f5efe3 48%, #f0e8da 100%);
    }

    body.hd-lifebook-modal-open {
        overflow: hidden;
        touch-action: none;
    }

    /* ── 顶栏 App 化 ── */
    .hd-topbar {
        padding: 0.45rem 0.85rem;
        padding-top: calc(0.45rem + env(safe-area-inset-top));
        gap: 0.55rem;
    }

    .hd-topbar-start {
        gap: 0.35rem;
        flex: 1 1 auto;
        min-width: 0;
    }

    .hd-menu-toggle {
        width: 2.2rem;
        height: 2.2rem;
        border-radius: 9px;
    }

    .hd-brand {
        min-width: 0;
    }

    .hd-brand img {
        width: 40px;
        height: 40px;
    }

    .hd-brand-cn {
        font-size: 1.15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hd-brand-sub {
        display: none;
    }

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

    .hd-topnav--mobile {
        display: flex;
        align-items: center;
        gap: 0.2rem;
    }

    .hd-topnav--mobile .hd-topnav-link {
        font-size: 0.78rem;
        letter-spacing: 0.08em;
        padding: 0.22rem 0.38rem;
    }

    .hd-topnav-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.35rem;
        height: 2.35rem;
        border-radius: 50%;
        border: 1px solid var(--hd-line);
        background: rgba(255, 255, 255, 0.65);
        color: #4a4034;
        font-size: 1rem;
        line-height: 1;
        cursor: pointer;
        padding: 0;
    }

    .hd-topnav-icon:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

    .hd-topnav-logout {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2.75rem;
        height: 2.35rem;
        padding: 0 0.7rem;
        border-radius: 999px;
        border: 1px solid rgba(196, 146, 62, 0.45);
        background: rgba(255, 252, 247, 0.92);
        color: #6b4e32;
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        line-height: 1;
        cursor: pointer;
        white-space: nowrap;
    }

    .hd-topnav-logout[hidden] {
        display: none !important;
    }

    .hd-topnav-logout:active {
        background: rgba(232, 184, 106, 0.22);
    }

    /* ── 主内容单列 ── */
    .hd-main {
        padding: 0.45rem 0.55rem 0.75rem;
        max-width: none;
        width: 100%;
        box-sizing: border-box;
    }

    .hd-hero {
        grid-template-columns: 1fr;
        gap: 0.35rem;
        margin-bottom: 0;
    }

    .hd-hero-chart {
        order: 0;
        padding: 0.15rem 0 0.35rem;
    }

    .hd-radar-wrap {
        width: min(100%, 22.5rem);
        max-width: none;
    }

    .hd-radar-node {
        min-width: 4.4rem;
        padding: 0.22rem 0.48rem;
        font-size: 0.7rem;
        letter-spacing: 0.04em;
        top: 2.2%;
    }

    .hd-chart-caption {
        font-size: 1.05rem;
        letter-spacing: 0.2em;
        margin-top: 0;
    }

    .hd-hero-info {
        min-width: 0;
        max-width: none;
    }

    .hd-hero-right {
        display: none;
    }

    .hd-badge {
        font-size: 0.72rem;
        margin-bottom: 0.25rem;
    }

    .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;
    }

    .hd-hero h1 {
        font-size: 1.65rem;
        margin-bottom: 0.35rem;
    }

    .hd-lead {
        font-size: 0.84rem;
        line-height: 1.5;
        margin-bottom: 0.75rem;
    }

    .hd-cta--mobile-pro {
        box-sizing: border-box;
        margin-bottom: 0;
    }

    .hd-hero-left > .hd-cta {
        display: flex;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 0.85rem;
        padding: 0.62rem 1rem;
        font-size: 0.92rem;
    }

    /* ── 仪表盘卡片 ── */
    .hd-dash-card {
        border-radius: 18px;
        padding: 0.75rem 0.72rem 0.8rem;
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.75) inset,
            0 8px 24px rgba(42, 30, 18, 0.08);
        border: 1px solid rgba(196, 146, 62, 0.18);
        background: linear-gradient(165deg, #fffefb 0%, #fffaf3 55%, #faf4ea 100%);
    }

    .hd-subsec {
        font-size: 0.86rem;
        margin-top: 0.42rem;
        margin-bottom: 0.28rem;
    }

    .hd-subsec--tight {
        margin-top: 0.55rem;
    }

    .hd-subsec:first-child {
        margin-top: 0;
    }

    .hd-watch-head {
        margin-bottom: 0.35rem;
    }

    .hd-watch-toolbar {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.4rem;
    }

    .hd-watch-calendar-wrap {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        min-height: 0;
    }

    .hd-watch-calendar-btn {
        padding: 0.4rem 0.48rem;
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hd-watch-now-btn {
        flex: 0 0 auto;
        width: auto;
        max-width: 42%;
        text-align: center;
        padding: 0.4rem 0.55rem;
        font-size: 0.72rem;
        white-space: nowrap;
    }

    .hd-watch-pillar-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        margin-top: 0.25rem;
    }

    .hd-pillar-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.3rem;
    }

    .hd-pillar {
        padding: 0.36rem 0.2rem 0.4rem;
        border-radius: 11px;
    }

    .hd-pillar-k {
        font-size: 0.6rem;
    }

    .hd-pillar-v {
        font-size: 0.92rem;
    }

    .hd-user-bazi {
        margin-bottom: 0.15rem;
    }

    /* 原「档案 / 报告 / 题库 / 排盘」快捷行已移除，改由底栏与左侧菜单进入 */
    .hd-lifebook-actions,
    .hd-lifebook-actions--after-gauges {
        display: none !important;
    }

    #hdSummary {
        display: none !important;
    }

    body.hd-home-page .site-compliance-strip {
        display: none !important;
    }

    .hd-mobile-pro-row {
        display: none !important;
    }

    .hd-lifebook-actions .hd-cta--small {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        justify-content: center;
        align-items: center;
        padding: 0.42rem 0.12rem;
        font-size: 0.72rem;
        font-weight: 700;
        line-height: 1.15;
        margin: 0;
        white-space: nowrap;
        text-align: center;
    }

    .hd-placeholder {
        flex-direction: column;
        text-align: center;
        font-size: 0.76rem;
        padding: 0.75rem;
    }

    .hd-placeholder svg {
        display: none;
    }

    .hd-mood {
        gap: 0.45rem 0.55rem;
        min-height: 0;
        padding: 0.2rem 0 0.05rem;
        align-items: flex-end;
    }

    .hd-mood-left {
        flex: 0 1 32%;
        min-width: 5.2rem;
        max-width: 7.6rem;
    }

    .hd-mood-title {
        font-size: 0.82rem;
    }

    .hd-mood-num {
        font-size: 2.05rem;
    }

    .hd-mood-unit {
        font-size: 0.8rem;
    }

    .hd-mood-blurb {
        font-size: 0.64rem;
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .hd-mood-bars {
        gap: 0.1rem;
        flex: 1 1 auto;
        min-width: 0;
    }

    .hd-vbar-track {
        width: 0.52rem;
        height: 4.4rem;
    }

    .hd-vbar-num {
        font-size: 0.66rem;
    }

    .hd-vbar-k {
        font-size: 0.54rem;
    }

    .hd-summary {
        font-size: 0.76rem;
        line-height: 1.5;
    }

    .hd-mobile-lifebook-link {
        display: block;
        margin: 0.35rem 0 0;
        text-align: center;
        font-size: 0.74rem;
        color: var(--hd-gold-deep);
        text-decoration: underline;
        text-underline-offset: 2px;
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
        font-family: inherit;
    }

    /* ── 今日宜忌（收入主卡，消除主卡下方空洞） ── */
    .hd-yi-ji-strip--in-card {
        margin-top: 0.55rem;
        margin-bottom: 0.35rem;
        padding-top: 0.55rem;
        border-top: 1px solid rgba(196, 146, 62, 0.2);
    }

    .hd-yi-ji-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem;
        margin-bottom: 0;
    }

    .hd-yi-ji-strip .hd-card--yi-ji {
        min-height: 0;
        padding: 0.5rem 0.48rem 0.55rem;
        border-radius: 12px;
        background: rgba(255, 252, 246, 0.92);
        border: 1px solid rgba(196, 146, 62, 0.22);
        box-shadow: none;
    }

    .hd-yi-ji-strip .hd-card--yi-ji h3 {
        font-size: 0.74rem;
        margin-bottom: 0.28rem;
        letter-spacing: 0.04em;
    }

    .hd-yi-ji-strip .hd-icon-grid {
        gap: 0.28rem;
        font-size: 0.68rem;
    }

    .hd-yi-ji-strip .hd-icon-cell {
        padding: 0.24rem 0.1rem;
        border-radius: 7px;
    }

    .hd-icon-grid {
        gap: 0.28rem 0.35rem;
    }

    .hd-icon-grid .hd-icon-chip {
        font-size: 0.68rem;
        padding: 0.18rem 0.38rem;
    }

    /* ── 择吉事项 ── */
    .hd-scenario-strip {
        margin-bottom: 0.75rem;
        padding: 0.65rem 0.75rem;
        border-radius: 14px;
        overflow: visible;
    }

    .hd-scenario-strip__lead {
        font-size: 0.84rem;
        margin-bottom: 0.55rem;
    }

    .hd-scenario-bar.hd-scenario-bar--top {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .hd-scenario-bar--top .hd-scenario-btn {
        flex: 0 1 auto;
        font-size: 0.76rem;
        padding: 0.32rem 0.72rem;
        border-radius: 999px;
    }

    /* ── 六壬 / 奇门 / 断语 ── */
    .hd-grid6 {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .hd-card {
        border-radius: 16px;
        padding: 0.85rem 0.85rem 0.9rem;
    }

    .hd-qimen-travel {
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 1rem;
    }

    .hd-qimen-travel__shichen-panel,
    .hd-qimen-travel__pan-panel {
        min-width: 0;
    }

    .hd-qimen-travel__shichen-panel {
        margin-bottom: 0.15rem;
    }

    .hd-scenario-guide {
        font-size: 0.68rem;
        line-height: 1.45;
        padding: 0.4rem 0.5rem;
        margin-bottom: 0.35rem;
    }

    .hd-scenario-dynamic-tip {
        font-size: 0.64rem;
        line-height: 1.4;
        margin-bottom: 0.35rem;
    }

    .hd-qimen-travel__sub,
    .hd-qimen-dir-title {
        font-size: 0.82rem;
        font-weight: 700;
        letter-spacing: 0.01em;
    }

    .hd-qimen-meta-line {
        font-size: 0.62rem;
        line-height: 1.35;
    }

    /* 标题与「查看…」按钮上下排布，避免手机窄屏挤成一行 */
    .hd-qimen-travel__panel-head {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 0.45rem;
        margin-bottom: 0.4rem;
    }

    .hd-qimen-travel__panel-head .hd-qimen-travel__sub {
        flex: none;
        width: 100%;
        margin: 0;
        line-height: 1.35;
    }

    .hd-qimen-dir-head {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            'ico text'
            'link link';
        column-gap: 0.45rem;
        row-gap: 0.45rem;
        align-items: start;
        margin-bottom: 0.45rem;
    }

    .hd-qimen-dir-ico {
        grid-area: ico;
        width: 1.35rem;
        height: 1.35rem;
        font-size: 0.72rem;
        margin-top: 0.1rem;
    }

    .hd-qimen-dir-head__text {
        grid-area: text;
        min-width: 0;
    }

    .hd-qimen-dir-head .hd-qimen-travel__pro-link {
        grid-area: link;
        margin-left: 0;
        align-self: stretch;
    }

    .hd-qimen-travel__pro-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        align-self: stretch;
        margin: 0;
        font-size: 0.72rem;
        font-weight: 700;
        padding: 0.42rem 0.7rem;
        line-height: 1.3;
        white-space: nowrap;
        text-align: center;
    }

    .hd-qimen-travel__pro-link-full {
        display: none;
    }

    .hd-qimen-travel__pro-link-short {
        display: inline;
    }

    .hd-shichen.hd-shichen--elevated {
        flex: none;
        min-height: 10.5rem;
        max-height: min(22rem, 52vh);
        gap: 0.38rem;
        padding: 0.45rem 0.4rem 0.85rem 0.5rem;
    }

    .hd-shichen--pick .hd-shichen-row {
        padding: 0.48rem 0.55rem;
        min-height: 2.85rem;
    }

    .hd-shichen-row__main {
        gap: 0.24rem;
    }

    .hd-qimen-dir-grid {
        gap: 0.28rem;
    }

    .hd-qdir-cell {
        padding: 0.32rem 0.2rem;
        min-height: 2.35rem;
    }

    .hd-qdir-cell__dir {
        font-size: 0.72rem;
    }

    .hd-qdir-cell__luck {
        font-size: 0.58rem;
    }

    .hd-shichen-row__name {
        font-size: 0.78rem;
        line-height: 1.38;
        letter-spacing: 0.03em;
    }

    .hd-shichen-row__range {
        font-size: 0.64rem;
        line-height: 1.42;
    }

    .hd-shichen-pill {
        font-size: 0.58rem;
        padding: 0.08rem 0.28rem;
    }

    .hd-card--chuanren-span h3 {
        font-size: 0.82rem;
        margin-bottom: 0.35rem;
    }

    .hd-mobile-ask-teacher {
        max-width: none;
        width: 100%;
        margin: 0.45rem 0 0;
        padding: 0.45rem 0 0;
        border-top: 1px dashed rgba(196, 146, 62, 0.28);
        text-align: center;
    }

    .hd-cta--ask-compact {
        display: inline-flex;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 0.22rem;
        padding: 0.52rem 0.85rem;
        font-size: 0.84rem;
        font-weight: 700;
        justify-content: center;
        border-radius: 999px;
        background: linear-gradient(180deg, #fff8ea 0%, #f3e4cc 100%);
        border-color: rgba(196, 146, 62, 0.45);
    }

    .hd-mobile-ask-teacher__hint {
        margin: 0;
        font-size: 0.64rem;
        line-height: 1.4;
        color: var(--hd-muted);
    }

    .hd-chuanren-body {
        font-size: 0.76rem;
        line-height: 1.62;
    }

    /* ── 页脚：手机只保留「添加到桌面」── */
    .hd-footer {
        display: block;
        padding: 0.85rem 1rem calc(4.75rem + env(safe-area-inset-bottom));
        border-top: none;
        max-width: none;
    }

    .hd-footer__grid {
        display: none;
    }

    .hd-footer__col,
    .hd-footer__about,
    .hd-footer__why,
    .hd-footer__nav-cols,
    .hd-footer__brand,
    .hd-footer__legal {
        display: none;
    }

    .hd-footer__mobile-pwa {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .hd-footer__pwa-btn {
        font-size: 0.78rem;
        padding: 0.48rem 0.95rem;
    }

    /* ── 底部 Tab ── */
    .hd-mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1200;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        gap: 0.15rem;
        padding: 0.35rem 0.5rem 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 {
        flex: 1 1 0;
        min-width: 0;
        max-width: 25%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.12rem;
        min-height: 3rem;
        padding: 0.2rem 0.15rem;
        border: none;
        border-radius: 12px;
        background: transparent;
        color: #6b6154;
        font-size: 0.62rem;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
    }

    .hd-mobile-bottom-nav__ico {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.35rem;
        height: 1.35rem;
        font-size: 1.05rem;
        line-height: 1;
        opacity: 0.85;
    }

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

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

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

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

    .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;
    }

    /* ── 档案弹窗：整屏上下居中 ── */
    #hdArchiveBackdrop.hd-modal-backdrop,
    #hdArchiveEditBackdrop.hd-modal-backdrop {
        display: grid;
        place-items: center;
        align-items: center;
        justify-items: center;
        padding: max(0.75rem, env(safe-area-inset-top, 0px)) 0.75rem
            max(0.75rem, env(safe-area-inset-bottom, 0px));
    }

    .hd-modal--archive {
        width: min(96vw, 480px);
        max-height: min(84dvh, 640px);
        margin: 0 auto;
        align-self: center;
    }

    .hd-modal--archive-edit {
        width: min(96vw, 100%);
        max-height: min(90dvh, 820px);
        margin: 0 auto;
        align-self: center;
    }

    .hd-archive-edit-frame {
        height: min(72dvh, 640px);
    }

    /* ── 命书 / 邀请码弹窗：近全屏底部 sheet（避免半截贴底、上方大片空白）── */
    .hd-modal-backdrop--sheet {
        align-items: flex-end;
        justify-content: center;
        padding: max(0.45rem, env(safe-area-inset-top, 0px)) 0 0;
    }

    .hd-modal-backdrop--sheet .hd-modal-sheet-handle {
        display: block;
    }

    .hd-modal--lifebook,
    .hd-modal--invite {
        width: 100%;
        max-width: 100%;
        height: min(94dvh, 860px);
        max-height: min(94dvh, 860px);
        margin: 0;
        border-radius: 18px 18px 0 0;
        padding: 0.35rem 0.65rem max(0.55rem, env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -8px 32px rgba(42, 30, 18, 0.14);
    }

    .hd-modal--lifebook .hd-lifebook-head,
    .hd-modal--invite .hd-lifebook-head {
        margin-bottom: 0.35rem;
        padding-bottom: 0.38rem;
        align-items: center;
    }

    .hd-modal--lifebook .hd-lifebook-title,
    .hd-modal--invite .hd-lifebook-title {
        font-size: 0.92rem;
        line-height: 1.25;
    }

    .hd-modal--lifebook .hd-lifebook-hint,
    .hd-modal--invite .hd-lifebook-hint {
        font-size: 0.66rem;
        line-height: 1.35;
        margin-top: 0.1rem;
    }

    .hd-modal--lifebook .hd-lifebook-close {
        width: 2rem;
        height: 2rem;
        font-size: 1.2rem;
        border-radius: 8px;
    }

    .hd-modal--lifebook .hd-lifebook-frame {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        height: auto;
        border-radius: 10px;
    }

    .hd-modal--invite {
        height: auto;
        max-height: min(94dvh, 860px);
    }

    .hd-modal--invite .hd-invite-form {
        gap: 0.45rem;
    }

    .hd-modal--invite .hd-invite-form label {
        font-size: 0.8rem;
    }

    .hd-modal--invite .hd-invite-form input {
        padding: 0.48rem 0.6rem;
        font-size: 0.88rem;
    }

    .hd-modal--archive {
        width: min(96vw, 480px);
        max-height: min(84dvh, 640px);
        border-radius: 16px;
    }

    .hd-modal-backdrop:not(.hd-modal-backdrop--sheet):not(#hdArchiveBackdrop):not(#hdArchiveEditBackdrop) {
        padding: 0.5rem;
    }
}
