*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background: #f9eee4;
    color: #2b2118;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding-bottom: 160px;
}

.app-nav {
    width: 100%;
    background: rgba(250, 229, 166, 0.96);
    border-bottom: 1px solid rgba(165, 108, 28, 0.22);
    padding: 0.82rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(91, 54, 18, 0.08);
}

.app-nav-inner {
    max-width: 80rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.brand-mark .symbol {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 999px;
    background: #fff9ed;
    border: 2px solid rgba(180, 119, 27, 0.28);
    box-shadow: 0 6px 16px rgba(91, 54, 18, 0.12);
}

.brand-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 32%;
    display: block;
}

.brand-mark .name {
    color: #3b2a1a;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0;
}

.template-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-nav a {
    color: #5c4631;
    border: 1px solid rgba(180, 119, 27, 0.22);
    background: rgba(255, 249, 237, 0.7);
    border-radius: 999px;
    padding: 0.46rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

.template-nav a:hover,
.template-nav a.active {
    color: #2b2118;
    background: #fff;
    border-color: rgba(180, 119, 27, 0.42);
    box-shadow: 0 5px 14px rgba(91, 54, 18, 0.1);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-actions.inline {
    justify-content: flex-start;
    margin: 1rem 0 0;
}

.page-actions-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.action-link,
.action-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 0.62rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 900;
    text-decoration: none;
    border: 1px solid rgba(180, 119, 27, 0.22);
    background: #fff9ed;
    color: #5c4631;
    transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.action-link:hover,
.action-button:hover {
    border-color: rgba(180, 119, 27, 0.5);
    color: #9a5d0a;
    transform: translateY(-1px);
}

.action-button.primary {
    color: #2b2118;
    background: #d99a21;
    border-color: #d99a21;
}

.action-button.primary:hover {
    color: #2b2118;
    opacity: 0.92;
}

.action-button {
    cursor: pointer;
}

.sponsor-float {
    position: fixed;
    z-index: 45;
    width: var(--sponsor-width, 160px);
    display: block;
    filter: drop-shadow(0 16px 28px rgba(91, 54, 18, 0.22));
    transition: transform 0.18s ease, opacity 0.18s ease, width 0.18s ease;
    text-decoration: none;
    pointer-events: auto;
}

.sponsor-float[data-side="right"] {
    right: 22px;
    bottom: 22px;
}

.sponsor-float[data-side="left"] {
    left: 18px;
    top: calc(154px + (var(--sponsor-order, 0) * 188px));
}

.sponsor-float[data-position="left-lower"] {
    top: 344px;
}

.sponsor-float[data-position="left-bottom"] {
    top: 524px;
}

.sponsor-float:hover {
    transform: translateY(-3px);
}

.sponsor-media {
    display: block;
    text-decoration: none;
}

.sponsor-float img {
    display: block;
    width: 100%;
    height: auto;
}

.sponsor-controls {
    position: absolute;
    top: -12px;
    right: -8px;
    display: none;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.sponsor-float:hover .sponsor-controls,
.sponsor-float:focus-within .sponsor-controls,
.sponsor-float.is-collapsed .sponsor-controls {
    opacity: 1;
    transform: translateY(0);
}

.sponsor-toggle,
.sponsor-close {
    min-width: 28px;
    height: 28px;
    border: 1px solid rgba(180, 119, 27, 0.32);
    border-radius: 999px;
    background: rgba(255, 249, 237, 0.96);
    color: #5c3808;
    box-shadow: 0 8px 18px rgba(91, 54, 18, 0.16);
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.sponsor-toggle {
    padding: 0 9px;
    min-width: 46px;
}

.sponsor-close {
    font-size: 18px;
    padding-bottom: 2px;
}

.sponsor-toggle:hover,
.sponsor-close:hover {
    background: #d99a21;
    color: #2b2118;
}

.sponsor-float.is-collapsed {
    width: var(--sponsor-collapsed-width, 68px);
    filter: drop-shadow(0 10px 18px rgba(91, 54, 18, 0.18));
}

.sponsor-float.is-collapsed .sponsor-media {
    border-radius: 999px;
    overflow: hidden;
    background: #fff9ed;
    border: 2px solid rgba(217, 154, 33, 0.32);
}

.sponsor-float.is-collapsed img {
    aspect-ratio: 1;
    object-fit: cover;
    object-position: top center;
}

.sponsor-float.is-collapsed .sponsor-toggle {
    min-width: 36px;
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
}

@media (min-width: 1181px) and (max-width: 1500px) {
    body.has-expanded-right-sponsor main {
        padding-right: var(--sponsor-right-space, 0px) !important;
    }

    body.has-expanded-left-sponsor main {
        padding-left: min(var(--sponsor-left-space, 0px), 190px) !important;
    }
}

@media (min-width: 1501px) {
    body.has-expanded-right-sponsor main {
        padding-right: min(var(--sponsor-right-space, 0px), 280px) !important;
    }

    body.has-expanded-left-sponsor main {
        padding-left: min(var(--sponsor-left-space, 0px), 220px) !important;
    }
}

.footer-contact,
.footer-legal {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    color: #5c4631;
    font-size: 0.82rem;
    font-weight: 800;
}

.footer-legal {
    margin-top: 10px;
}

.footer-legal a,
.footer-contact a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #5c4631;
    text-decoration: none;
}

.footer-legal a {
    border-bottom: 1px solid rgba(92, 70, 49, 0.22);
}

.footer-legal span {
    color: rgba(92, 70, 49, 0.42);
}

.footer-legal a:hover,
.footer-contact a:hover {
    color: #9a5d0a;
}

.footer-contact img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    height: 4px;
    background: rgba(255, 249, 237, 0.68);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.reading-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 0 999px 999px 0;
    background: linear-gradient(90deg, #d99a21, #c0392b, #2f7d57);
    box-shadow: 0 0 14px rgba(217, 154, 33, 0.4);
}

.reading-progress.is-hidden {
    opacity: 0;
}

.reading-top-button {
    position: fixed;
    left: 18px;
    bottom: 22px;
    z-index: 46;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(180, 119, 27, 0.28);
    border-radius: 999px;
    background: rgba(255, 249, 237, 0.96);
    color: #5c3808;
    box-shadow: 0 12px 26px rgba(91, 54, 18, 0.16);
    cursor: pointer;
    font-size: 1.35rem;
    font-weight: 950;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.reading-top-button.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.reading-top-button:hover {
    background: #d99a21;
    color: #2b2118;
}

.animated-gradient-title {
    display: inline-block;
    color: transparent !important;
    background-image: linear-gradient(100deg, #8a520c 0%, #d99a21 32%, #c0392b 58%, #2f7d57 82%, #8a520c 100%);
    background-size: 240% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: titleGradientFlow 4.6s ease-in-out infinite;
}

@keyframes titleGradientFlow {
    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@media (max-width: 640px) {
    body {
        padding-bottom: 132px;
    }

    .app-nav {
        padding: 0.68rem 0.85rem;
    }

    .app-nav-inner {
        gap: 0.55rem;
    }

    .template-nav {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .template-nav::-webkit-scrollbar {
        display: none;
    }

    .template-nav a {
        flex: 0 0 auto;
        text-align: center;
        white-space: nowrap;
        padding: 0.42rem 0.72rem;
        font-size: 0.78rem;
    }

    .brand-mark .symbol {
        width: 36px;
        height: 36px;
    }

    .brand-mark .name {
        font-size: 0.9rem;
    }

    .page-actions,
    .page-actions-group {
        width: 100%;
    }

    .action-link,
    .action-button {
        flex: 1;
        min-width: 0;
        min-height: 42px;
        padding: 0.6rem 0.65rem;
        font-size: 0.8rem;
    }

    .sponsor-float {
        display: none !important;
    }

    .sponsor-float[data-mobile="show"] {
        display: block !important;
    }

    .sponsor-float[data-side="right"] {
        right: 8px;
        bottom: 8px;
        width: var(--sponsor-mobile-width, 128px);
    }

    .sponsor-float[data-side="right"]:not(.is-collapsed) {
        width: min(var(--sponsor-mobile-width, 128px), 30vw);
    }

    .sponsor-float[data-side="left"] {
        display: none;
    }

    .sponsor-float.is-collapsed {
        width: var(--sponsor-mobile-collapsed-width, 48px);
    }

    .sponsor-controls {
        opacity: 1;
        top: -10px;
        right: -7px;
    }

    .sponsor-toggle {
        min-width: 38px;
        height: 24px;
        padding: 0 6px;
        font-size: 11px;
    }

    .sponsor-close {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }

    .reading-progress {
        height: 3px;
    }

    .reading-top-button {
        left: 10px;
        bottom: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
    }

}

@media (min-width: 641px) and (max-width: 1180px) {
    .sponsor-float[data-side="left"] {
        display: none;
    }
}

@media print {
    @page {
        size: A4;
        margin: 12mm 10mm;
    }

    html,
    body {
        width: auto !important;
        min-height: auto !important;
        background: #fff !important;
        color: #000 !important;
        font-size: 10.5pt !important;
        line-height: 1.45 !important;
        padding-bottom: 0 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .no-print,
    .app-nav {
        display: none !important;
    }

    main {
        max-width: none !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    footer {
        display: none !important;
    }

    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    h1,
    h2,
    h3,
    h4 {
        color: #000 !important;
        break-after: avoid;
        page-break-after: avoid;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    img,
    table,
    pre,
    blockquote {
        max-width: 100% !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    table {
        border-collapse: collapse !important;
    }

    section,
    article,
    .print-card,
    .report-card,
    .qimen-card,
    .zodiac-brief-card,
    .template-card,
    .dimension-card,
    .month-card,
    .analysis-card,
    .strategy-card,
    .practical-panel,
    .practical-section,
    .front-summary,
    .ziwei-detail-card,
    .unknown-hour-card {
        box-shadow: none !important;
        text-shadow: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .print-card,
    .qimen-card,
    .zodiac-brief-card,
    .overview-card,
    .report-card,
    .template-card,
    .dimension-card,
    .quarter-card,
    .month-card,
    .analysis-card,
    .strategy-card,
    .profile-mini,
    .practical-grid > div,
    .do-card,
    .dont-card,
    .mini-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .grid,
    .qimen-grid,
    .top-hours,
    .compare-grid,
    .zodiac-brief-grid,
    .template-grid,
    .workflow-grid,
    .health-season-grid,
    .wuge-grid,
    .ziwei-palace-cards,
    .practical-grid,
    .do-dont-grid {
        gap: 8px !important;
    }
}
