@font-face {
    font-family: "FZ Material Symbols";
    src: url("/bazi/static/fonts/material-symbols-outlined-subset.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: block;
}

@font-face {
    font-family: "FZ Source Serif 4";
    src: url("/bazi/static/fonts/source-serif-4-latin.ttf") format("truetype");
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
}

.material-symbols-outlined {
    font-family: "FZ Material Symbols";
    font-weight: 400;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
}

.fz-mobile-app-header,
.fz-mobile-bottom-nav {
    display: none;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 768px) {
    :root {
        --fz-stitch-background: var(--fz-bg);
        --fz-stitch-surface: var(--fz-surface-1);
        --fz-stitch-surface-low: var(--fz-surface-2);
        --fz-stitch-surface-high: var(--fz-surface-3);
        --fz-stitch-text: var(--fz-text-strong);
        --fz-stitch-muted: var(--fz-text);
        --fz-stitch-border: var(--fz-line);
        --fz-stitch-primary: var(--fz-gold);
        --fz-stitch-primary-container: var(--fz-gold);
        --fz-stitch-gold: var(--fz-gold);
        --fz-stitch-nav-height: 64px;
        --fz-stitch-header-height: 64px;
    }

    html {
        width: 100%;
        min-width: 0;
        background: var(--fz-stitch-background);
    }

    body,
    body.light-theme {
        width: 100%;
        min-width: 0;
        min-height: 100dvh;
        margin: 0;
        overflow-x: hidden;
        background: var(--fz-stitch-background);
        color: var(--fz-stitch-text);
        font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    }

    body > .header,
    body > .mobile-nav-overlay,
    body > .mobile-nav-menu {
        display: none !important;
    }

    .fz-mobile-app-header {
        position: fixed;
        inset: 0 0 auto;
        z-index: 220;
        height: calc(var(--fz-stitch-header-height) + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 16px 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        border-bottom: 1px solid rgba(var(--fz-sheen-rgb), 0.7);
        background: rgba(var(--fz-surface-rgb), 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .fz-mobile-app-header h1 {
        margin: 0;
        color: var(--fz-stitch-primary);
        font-family: Georgia, "Times New Roman", "Songti SC", serif;
        font-size: 18px;
        font-weight: 600;
        line-height: 1;
        letter-spacing: -0.02em;
    }

    .fz-mobile-profile-link {
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--fz-gold-fill);
        color: var(--fz-on-fill);
        text-decoration: none;
    }

    .fz-mobile-profile-link .material-symbols-outlined {
        font-size: 22px;
    }

    body > .container {
        width: 100%;
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        padding: calc(var(--fz-stitch-header-height) + env(safe-area-inset-top, 0px)) 0
            calc(var(--fz-stitch-nav-height) + 28px + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    #page-home,
    #page-home .paipan-section {
        width: 100%;
        margin: 0;
    }

    #page-home .paipan-section {
        padding: 0 20px 24px;
        box-sizing: border-box;
        background: var(--fz-stitch-background);
    }

    #page-home .input-panel {
        width: 100%;
        max-width: none !important;
        margin: 0;
        padding: 16px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        box-sizing: border-box;
        border: 0;
        border-radius: 12px;
        background: transparent;
        box-shadow: none;
    }

    #page-home .input-panel > * {
        min-width: 0;
    }

    #page-home .input-panel > .input-row:has(.options-toggle-group) {
        grid-column: 1 / -1;
    }

    #page-home .input-panel > .panel-title,
    #page-home .input-panel > #datetimeRow,
    #page-home .input-panel > #pillarInputRow,
    #page-home .input-panel > #hourUnknownRow,
    #page-home .input-panel > #cityRow,
    #page-home .input-panel > .options-toggle-group,
    #page-home .input-panel > #trueSolarInfo,
    #page-home .input-panel > #categoryRow,
    #page-home .input-panel > .btn-paipan-large,
    #page-home .input-panel > select,
    #page-home .input-panel > input,
    #page-home .input-panel > button[style*="display:none"] {
        grid-column: 1 / -1;
    }

    #page-home .input-panel > .panel-title {
        margin: 0;
        color: var(--fz-stitch-gold);
        font-family: "Songti SC", "STSong", "SimSun", serif;
        font-size: 22px;
        font-weight: 700;
        line-height: 28px;
    }

    #page-home .input-row {
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    #page-home .input-row:first-of-type {
        grid-column: 1 / -1;
    }

    #page-home .input-row .row-label {
        min-width: 0;
        color: var(--fz-stitch-muted);
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
    }

    #page-home .input-row .row-content {
        width: 100%;
        min-width: 0;
    }

    #page-home .form-input {
        width: 100% !important;
        min-height: 44px;
        padding: 10px 12px;
        box-sizing: border-box;
        border: 1px solid var(--fz-stitch-border);
        border-radius: 8px;
        background: var(--fz-stitch-surface-low);
        color: var(--fz-stitch-text);
        font: inherit;
        font-size: 14px;
        box-shadow: none;
    }

    /* Keep the name field at iOS's non-zooming input size without changing other controls. */
    #page-home #inputName {
        font-size: 16px;
    }

    #page-home .form-input:focus {
        border-color: var(--fz-stitch-gold);
        box-shadow: 0 0 0 2px rgba(var(--fz-gold-rgb), 0.12);
        outline: 0;
    }

    #page-home .gender-radio {
        min-height: 34px;
        gap: 18px;
    }

    #page-home .gender-radio label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        color: var(--fz-stitch-text);
        font-size: 14px;
    }

    #page-home .gender-radio input[type="radio"] {
        width: 20px;
        height: 20px;
        margin: 0;
        border: 1px solid var(--fz-line-strong);
        background: var(--fz-surface-1);
        box-shadow: none;
    }

    #page-home .gender-radio input[type="radio"]:checked {
        border: 6px solid var(--fz-stitch-gold);
        background: var(--fz-surface-1);
    }

    #page-home .calendar-tabs {
        width: 100%;
        min-height: 34px;
        padding: 4px;
        gap: 2px;
        box-sizing: border-box;
        border: 0;
        border-radius: 8px;
        background: var(--fz-stitch-surface-low);
    }

    #page-home .calendar-tabs .tab-item {
        min-width: 0;
        min-height: 26px;
        padding: 4px 5px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        border: 0;
        border-radius: 6px;
        color: var(--fz-stitch-muted);
        font-size: 13px;
        line-height: 18px;
    }

    #page-home .calendar-tabs .tab-item.active {
        background: var(--fz-gold-fill-hi);
        color: var(--fz-on-fill);
        box-shadow: none;
    }

    #page-home .datetime-wheel-picker {
        --datetime-wheel-peek-row: 24px;
        --datetime-wheel-current-row: 36px;
        width: 100%;
        padding: 0;
        gap: 0;
        border: 0;
        background: transparent;
    }

    #page-home .datetime-wheel-picker::before {
        background:
            linear-gradient(90deg,
                transparent 0%, rgba(var(--fz-gold-rgb), 0.28) 5%,
                rgba(var(--fz-gold-rgb), 0.28) 95%, transparent 100%) top / 100% 1px no-repeat,
            linear-gradient(90deg,
                transparent 0%, rgba(var(--fz-gold-rgb), 0.28) 5%,
                rgba(var(--fz-gold-rgb), 0.28) 95%, transparent 100%) bottom / 100% 1px no-repeat,
            var(--fz-surface-1);
    }

    #page-home .datetime-wheel-picker::after {
        display: none;
    }

    #page-home .datetime-wheel-frame {
        background: transparent;
    }

    #page-home #datetimeWheelPicker .datetime-wheel-frame > .wheel-select {
        height: 36px;
        padding: 0 1px;
        border: 0;
        background: transparent;
        color: var(--fz-stitch-text);
        font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
        font-size: 13px;
        font-weight: 600;
        letter-spacing: .015em;
        line-height: 36px;
        box-shadow: none;
    }

    #page-home .datetime-wheel-peek {
        color: var(--fz-stitch-muted);
        font-family: "Segoe UI", sans-serif;
        font-size: 10px;
        opacity: 0.4;
    }

    #page-home .wheel-select-group::after {
        display: none;
    }

    #page-home .wheel-picker-help {
        display: none;
    }

    #page-home #hourUnknownRow .row-label {
        display: none;
    }

    #page-home #hourUnknownRow label {
        width: 100%;
        min-height: 44px;
        color: var(--fz-stitch-muted) !important;
        font-size: 0 !important;
    }

    #page-home #hourUnknownRow label::after {
        content: "出生时辰不详";
        font-size: 14px;
        line-height: 20px;
    }

    #page-home #hourUnknownRow input {
        width: 20px;
        height: 20px;
        margin: 0;
        accent-color: var(--fz-stitch-gold);
    }

    #page-home .city-search-wrap {
        position: relative;
    }

    #page-home #inputCity {
        padding-left: 38px;
    }

    #page-home .city-search-wrap::before {
        content: "search";
        position: absolute;
        z-index: 1;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--fz-stitch-muted);
        font-family: "FZ Material Symbols";
        font-size: 20px;
        font-feature-settings: "liga";
        pointer-events: none;
    }

    #page-home .options-toggle-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 12px;
    }

    #page-home .option-toggle,
    #page-home .option-toggle-with-help {
        min-width: 0;
    }

    #page-home .option-toggle {
        min-height: 44px;
        gap: 8px;
        color: var(--fz-stitch-text);
        font-size: 14px;
    }

    #page-home .toggle-switch {
        width: 40px;
        height: 20px;
        border: 0;
        background: var(--fz-stitch-surface-high);
        box-shadow: none;
    }

    #page-home .toggle-switch::after {
        width: 12px;
        height: 12px;
        top: 4px;
        left: 4px;
        background: var(--fz-surface-1);
        box-shadow: none;
    }

    #page-home .option-toggle-input:checked + .toggle-switch {
        background: var(--fz-gold-fill-hi);
    }

    #page-home .option-toggle-input:checked + .toggle-switch::after {
        left: 24px;
    }

    #page-home .option-help-trigger {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
        border-color: var(--fz-stitch-border);
        color: var(--fz-stitch-muted);
        font-size: 12px;
    }

    #page-home .true-solar-info {
        margin: -8px 0 0;
        padding: 0;
        border: 0;
        background: transparent;
    }

    #page-home .category-row {
        display: flex;
    }

    #page-home .category-chips {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    #page-home .category-chips::-webkit-scrollbar {
        display: none;
    }

    #page-home .category-chip {
        flex: 0 0 auto;
        padding: 5px 14px;
        border: 1px solid var(--fz-stitch-border);
        border-radius: 999px;
        background: var(--fz-surface-1);
        color: var(--fz-stitch-muted);
        font-size: 14px;
        line-height: 20px;
    }

    #page-home .category-chip.active {
        border-color: var(--fz-stitch-gold);
        background: rgba(var(--fz-gold-rgb), 0.1);
        color: var(--fz-stitch-gold);
    }

    #page-home .btn-paipan-large {
        width: 100%;
        min-height: 48px;
        margin: 2px 0 0;
        padding: 11px 18px;
        border: 0;
        border-radius: 999px;
        background: var(--fz-gold-fill);
        color: var(--fz-on-fill);
        font-family: "Songti SC", "STSong", "SimSun", serif;
        font-size: 18px;
        font-weight: 600;
        letter-spacing: 0;
        box-shadow: none;
    }

    #page-home .btn-paipan-large:hover,
    #page-home .btn-paipan-large:focus-visible {
        transform: none;
        background: var(--fz-gold-fill);
        box-shadow: 0 0 0 3px rgba(var(--fz-gold-rgb), 0.14);
    }

    .ai-fab {
        right: 16px;
        bottom: calc(var(--fz-stitch-nav-height) + 16px + env(safe-area-inset-bottom, 0px));
        z-index: 205;
        width: 64px;
        height: 64px;
        border: 0;
        border-radius: 50%;
        background: var(--fz-gold-fill-hi);
        color: var(--fz-on-fill);
        font-family: Georgia, "Times New Roman", serif;
        font-size: 18px;
        font-weight: 700;
        box-shadow: none;
    }

    .fz-mobile-bottom-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 210;
        height: calc(var(--fz-stitch-nav-height) + env(safe-area-inset-bottom, 0px));
        padding: 0 8px env(safe-area-inset-bottom, 0px);
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        box-sizing: border-box;
        border-top: 1px solid rgba(var(--fz-sheen-rgb), 0.75);
        background: rgba(var(--fz-surface-rgb), 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .fz-mobile-bottom-nav a {
        min-width: 0;
        height: var(--fz-stitch-nav-height);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--fz-text-2);
        font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
        font-size: 11px;
        font-weight: 500;
        line-height: 14px;
        text-decoration: none;
    }

    .fz-mobile-bottom-nav a.active {
        color: var(--fz-stitch-primary);
        font-weight: 700;
    }

    .fz-mobile-bottom-nav .material-symbols-outlined {
        font-size: 24px;
    }

    #historyCaseButton.fz-case-history-dock[hidden] {
        display: inline-flex !important;
    }

    .fz-case-history-dock {
        top: 50%;
        right: 0;
        width: 30px;
        min-height: 108px;
        padding: 12px 5px;
        flex-direction: column;
        gap: 7px;
        writing-mode: initial;
        text-orientation: mixed;
        border: 0;
        border-radius: 12px 0 0 12px;
        background: var(--fz-gold-fill);
        color: var(--fz-on-fill);
        font-size: 11px;
        font-weight: 600;
        line-height: 1;
        letter-spacing: 2px;
        box-shadow: none;
    }

    .fz-case-history-dock > span:last-child {
        writing-mode: vertical-rl;
    }

    .fz-case-history-dock .material-symbols-outlined {
        font-size: 19px;
        letter-spacing: 0;
    }

    body.light-theme .fz-case-history-dock,
    .fz-case-history-dock:hover,
    .fz-case-history-dock:focus-visible {
        background: var(--fz-gold-fill);
        color: var(--fz-on-fill);
        box-shadow: none;
        transform: translateY(-50%);
    }

    .modal-overlay.fz-case-history-overlay,
    body.light-theme .modal-overlay.fz-case-history-overlay {
        z-index: 10000;
        padding: 0;
        align-items: flex-start;
        justify-content: flex-end;
        background: rgba(var(--fz-veil-rgb), 0.24);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    .modal.fz-case-history-dialog,
    body.light-theme .modal.fz-case-history-dialog {
        top: calc(var(--fz-stitch-header-height) + env(safe-area-inset-top, 0px));
        right: 0;
        width: 80vw;
        height: calc(100dvh - var(--fz-stitch-header-height) - var(--fz-stitch-nav-height) - 64px -
            env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        max-width: 360px;
        max-height: none;
        border: 0;
        border-left: 1px solid var(--fz-stitch-border);
        border-radius: 0;
        background: var(--fz-stitch-background);
        box-shadow: none;
    }

    .modal.fz-case-history-dialog > .fz-case-history-dock {
        display: none !important;
    }

    .fz-case-history-shell {
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
        background: var(--fz-stitch-background);
        box-shadow: none;
        color: var(--fz-stitch-text);
    }

    .fz-case-history-header {
        min-height: 56px;
        padding: 8px 12px 8px 16px;
        border-bottom: 1px solid var(--fz-stitch-border);
        background: var(--fz-stitch-surface-low);
    }

    .fz-case-history-heading {
        color: var(--fz-stitch-text);
        font-family: "Songti SC", "STSong", "SimSun", serif;
        font-size: 18px;
        font-weight: 600;
        letter-spacing: 0;
    }

    .fz-case-history-close {
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 50%;
        background: transparent;
        color: var(--fz-stitch-text);
        font-size: 0;
    }

    .fz-case-history-close .material-symbols-outlined {
        font-size: 21px;
    }

    .fz-case-history-search-wrap {
        padding: 16px 16px 10px;
    }

    .fz-case-history-search-label,
    .fz-case-history-list-label {
        display: none;
    }

    .fz-case-history-search-wrap {
        position: relative;
    }

    .fz-case-history-search-wrap::before {
        content: "search";
        position: absolute;
        z-index: 1;
        left: 28px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--fz-stitch-muted);
        font-family: "FZ Material Symbols";
        font-size: 19px;
        font-feature-settings: "liga";
        pointer-events: none;
    }

    .fz-case-history-search {
        height: 42px;
        padding: 9px 12px 9px 38px;
        border: 1px solid var(--fz-stitch-border);
        border-radius: 8px;
        background: var(--fz-stitch-surface-low);
        color: var(--fz-stitch-text);
        /* iOS 聚焦小字号输入框时会放大视口，关闭键盘后可能不复原。 */
        font-size: 16px;
        box-shadow: none;
    }

    .fz-case-history-search:focus {
        border-color: var(--fz-stitch-gold);
        box-shadow: 0 0 0 2px rgba(var(--fz-gold-rgb), 0.12);
    }

    .fz-case-history-list {
        max-height: none;
        padding: 0 16px 16px;
        gap: 8px;
    }

    .fz-case-history-item {
        min-height: 70px;
        padding: 11px 12px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "name gender"
            "pillars pillars";
        gap: 7px 10px;
        border: 1px solid var(--fz-stitch-border);
        border-radius: 8px;
        background: var(--fz-stitch-background);
        color: var(--fz-stitch-text);
        box-shadow: none;
        transform: none;
    }

    .fz-case-history-name {
        grid-area: name;
        color: var(--fz-stitch-text);
        font-size: 14px;
        font-weight: 600;
        line-height: 20px;
    }

    .fz-case-history-gender {
        grid-area: gender;
        display: inline;
        color: var(--fz-stitch-muted);
        font-size: 11px;
        line-height: 20px;
    }

    .fz-case-history-pillars {
        grid-area: pillars;
        display: flex;
        gap: 10px;
        color: var(--fz-stitch-muted);
        font-family: "Songti SC", "STSong", "SimSun", serif;
        font-size: 12px;
        line-height: 18px;
    }

    .fz-case-history-calendar,
    .fz-case-history-date {
        display: none;
    }

    .fz-case-history-item:hover,
    .fz-case-history-item:focus-visible {
        border-color: var(--fz-stitch-primary);
        background: var(--fz-stitch-background);
        transform: none;
    }

    body.light-theme .fz-case-history-name,
    body.light-theme .fz-case-history-item:hover .fz-case-history-name,
    body.light-theme .fz-case-history-item:focus-visible .fz-case-history-name {
        color: var(--fz-stitch-text);
    }

    .fz-case-history-status {
        min-height: 120px;
        padding: 24px 12px;
        color: var(--fz-stitch-muted);
        font-size: 13px;
    }

    .modal-overlay.fz-case-history-overlay.fz-case-history-closing,
    body.light-theme .modal-overlay.fz-case-history-overlay.fz-case-history-closing {
        background: rgba(var(--fz-veil-rgb), 0);
        backdrop-filter: blur(0);
        -webkit-backdrop-filter: blur(0);
    }

    #page-home .input-panel > .panel-title {
        font-size: 14px;
        line-height: 20px;
    }

    #page-home #hourUnknownRow label {
        min-height: 20px;
    }

    #page-home .input-panel > .input-row:has(.options-toggle-group) {
        gap: 8px;
    }

    #page-home .options-toggle-group {
        row-gap: 16px;
    }

    #page-home .option-toggle,
    #page-home .option-toggle-with-help > .option-toggle {
        min-height: 20px;
    }

    #page-home .btn-paipan-large {
        min-height: 44px;
        margin-top: 8px;
        padding-top: 12px;
        padding-bottom: 12px;
        font-size: 14px;
        line-height: 20px;
    }
    .fz-mobile-app-header h1 {
        font-family: "FZ Source Serif 4", "Times New Roman", serif;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        letter-spacing: 0;
    }

    .fz-mobile-profile-link svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }

    #page-home .input-panel > .panel-title {
        font-family: "FZ Source Serif 4", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
    }

    #page-home .gender-radio input[type="radio"],
    #page-home .gender-radio input[type="radio"]:checked {
        border: 1px solid var(--fz-line-strong);
        background: var(--fz-surface-1);
        transition: none;
    }

    #page-home .gender-radio input[type="radio"]:checked::after {
        top: 4px;
        left: 4px;
        width: 10px;
        height: 10px;
        background: var(--fz-gold-fill-hi);
    }

    #page-home .btn-paipan-large {
        font-family: "FZ Source Serif 4", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
        font-weight: 600;
    }

    .ai-fab {
        font-family: "FZ Source Serif 4", "Times New Roman", serif;
        font-size: 20px;
    }

}

@media (max-width: 380px) {
    #page-home .paipan-section {
        padding-right: 16px;
        padding-left: 16px;
    }

    #page-home .input-panel {
        padding: 14px;
        gap: 14px 12px;
    }

    #page-home .calendar-tabs .tab-item {
        padding-right: 3px;
        padding-left: 3px;
        font-size: 12px;
    }

    #page-home .options-toggle-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fz-case-history-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

@media (min-width: 769px) {
    .fz-mobile-app-header,
    .fz-mobile-bottom-nav {
        display: none !important;
    }
}
/* 手机排盘输入页不提供 AI 咨询入口 */
@media (max-width: 768px) {
    body .ai-fab { display: none !important; }

    /* 历史档案在手机端保留右侧抽屉逻辑，同时让四角和右侧边界完整可见。 */
    .modal.fz-case-history-dialog,
    body.light-theme .modal.fz-case-history-dialog {
        right: 8px;
        border: 1px solid rgba(var(--fz-gold-rgb), 0.42);
        border-radius: 16px;
        overflow: hidden;
        clip-path: inset(0 round 16px);
    }
    .modal.fz-case-history-dialog .fz-case-history-shell {
        width: 100%;
        border: 0;
        border-radius: inherit;
        overflow: hidden;
    }
}

.fz-form-settings { display: none; }

/* 手机首页的两个入口共用一份表单和画布，切换时保留录入状态。 */
@media (max-width: 768px) {
    html[data-home-view] {
        --fz-stitch-header-height: 68px;
        --fz-home-height: calc(100dvh - var(--fz-stitch-header-height) - var(--fz-stitch-nav-height)
            - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        --fz-home-gap: clamp(6px, 1.6vw, 12px);
        --fz-solar-height: min(108vw, calc(var(--fz-home-height) * .56), 510px);
    }
    body.fz-brand-paipan { overflow-x: clip; }
    html[data-home-view="paipan"]:has(#inputName:focus, #inputCity:focus) {
        --fz-solar-height: min(25dvh, 180px);
    }

    #page-home .paipan-section {
        gap: var(--fz-home-gap);
        padding: var(--fz-home-gap);
    }

    html:not([data-home-view="paipan"]) #page-home .input-panel,
    html:not([data-home-view="paipan"]) #page-home .fz-solar,
    html[data-home-view="paipan"] #page-home .instant-panel.fz-fate-panel {
        display: none;
    }

    html[data-home-view="paipan"] {
        scroll-padding-top: calc(var(--fz-stitch-header-height) + env(safe-area-inset-top, 0px)
            + var(--fz-solar-height) + var(--fz-home-gap));
        scroll-padding-bottom: calc(var(--fz-stitch-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
    }

    #page-home .input-panel {
        grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr);
        gap: 6px 12px;
        padding: 8px clamp(10px, 3vw, 18px) 10px;
    }

    #page-home .input-panel > .panel-title { padding-right: 96px; }
    #page-home #historyCaseButton {
        position: absolute;
        inset: 5px 12px auto auto;
        z-index: 3;
        width: auto;
        min-height: 32px;
        padding: 4px 6px;
        flex-direction: row;
        gap: 5px;
        border-radius: var(--fz-radius-pill);
        background: transparent;
        color: var(--fz-gold);
        font-size: 12px;
        letter-spacing: 0;
        transform: none;
    }
    #page-home #historyCaseButton > span:last-child { writing-mode: horizontal-tb; font-weight: 500; }
    #page-home #historyCaseButton .material-symbols-outlined { font-size: 16px; }

    #page-home .input-panel > .fz-row-name,
    #page-home .input-panel > .fz-row-calendar { grid-column: 1; }
    #page-home .input-panel > .fz-row-gender,
    #page-home .input-panel > #hourUnknownRow { grid-column: 2; }
    #page-home .input-panel > :is(.fz-row-name, .fz-row-gender, .fz-row-calendar, #hourUnknownRow, #cityRow) {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        min-height: 0;
    }
    #page-home .input-panel > .fz-row-calendar .row-label,
    #page-home .input-panel > .fz-row-gender .row-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    #page-home .input-panel .row-label {
        flex: none;
        font-size: 12px;
        line-height: 16px;
    }
    #page-home :is(.fz-row-name, #cityRow) > .row-label {
        flex-basis: 4.2em;
        letter-spacing: 0;
    }
    #page-home .fz-row-calendar .tab-item { min-height: 30px; font-size: 12px; }
    #page-home .fz-row-gender .row-content { justify-content: flex-end; }
    #page-home .gender-radio {
        justify-content: flex-end;
        gap: clamp(7px, 2.8vw, 15px);
    }
    #page-home .gender-radio label { min-width: 38px; min-height: 38px; gap: 5px; font-size: 13px; }
    #page-home #hourUnknownRow label {
        justify-content: flex-end;
        min-height: 36px;
    }
    #page-home #hourUnknownRow label::after { content: "时辰不详"; font-size: 12px; }
    #page-home :is(#inputName, #inputCity) {
        min-height: 38px;
        height: 38px;
        padding-block: 6px;
        font-size: 16px;
    }
    #page-home :is(#inputName, #inputCity)::placeholder { font-size: 13px; }
    #page-home .city-search-wrap::before { left: 10px; font-size: 17px; }
    #page-home #inputCity { padding-left: 32px; }
    #page-home .fz-bp-open { font-size: 12px; }
    #page-home :is(#datetimeRow, #pillarInputRow) { gap: 2px; }
    #page-home .datetime-wheel-picker { --datetime-wheel-peek-row: 12px; }
    #page-home .input-panel > .fz-form-settings {
        display: inline-flex;
        align-items: center;
        justify-content: start;
        gap: 8px;
        padding: 0;
        min-height: 42px;
        border: 0;
        background: transparent;
        color: var(--fz-text-2);
        font: inherit;
        font-size: 13px;
        cursor: pointer;
    }
    .fz-form-settings::after {
        content: "";
        width: 6px;
        height: 6px;
        border: solid currentColor;
        border-width: 0 1px 1px 0;
        transform: translateY(-2px) rotate(45deg);
    }
    .fz-form-settings[aria-expanded="true"]::after { transform: rotate(225deg); }
    #page-home .fz-form-settings[aria-expanded="false"] ~ :is(#paipanOptions, #trueSolarInfo, #categoryRow) {
        display: none !important;
    }
    #page-home .fz-form-settings[aria-expanded="false"] ~ .btn-paipan-large {
        grid-column: 2;
        min-height: 42px;
        margin: 0;
        padding: 6px 12px;
    }
    #page-home .input-panel > #categoryRow:not(.show) { display: none; }
}

@media (max-width: 768px) and (max-height: 480px) {
    html[data-home-view] { --fz-solar-height: min(34dvh, 145px); }
}
