* {
    box-sizing: border-box;
}

:root {
    --ink: #18202b;
    --muted: #68717f;
    --paper: #f7f0df;
    --paper-deep: #eadfca;
    --line: rgba(24, 32, 43, 0.14);
    --cinnabar: #b5362d;
    --jade: #1f7a69;
    --indigo: #233a5e;
    --surface: rgba(255, 252, 243, 0.88);
    --song: "Songti SC", "STSong", "SimSun", serif;
}

body {
    margin: 0;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(24, 32, 43, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(24, 32, 43, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 14% 16%, rgba(181, 54, 45, 0.12), transparent 28%),
        radial-gradient(circle at 88% 12%, rgba(31, 122, 105, 0.12), transparent 25%),
        #f3ead8;
    background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

.bazi-app {
    width: 100%;
    height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-rows: 72px minmax(0, 1fr);
}

main {
    min-height: 0;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 10;
    background: rgba(255, 252, 243, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    width: min(1720px, calc(100% - 48px));
    min-height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-weight: 800;
    font-size: 16px;
    color: var(--ink);
}

.tagline {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.topnav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topnav a,
.ghost-button,
.primary-button,
.chapter-nav button {
    min-height: 38px;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.topnav a {
    padding: 0 12px;
    color: var(--ink);
    background: rgba(255, 252, 243, 0.72);
    font-size: 13px;
}

.hero {
    display: none;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 36px;
    align-items: center;
    padding: 44px 0 34px;
    border-bottom: 1px solid var(--line);
}

.kicker {
    margin: 0 0 10px;
    color: var(--cinnabar);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.hero h1 {
    margin: 0;
    max-width: 760px;
    font-size: 44px;
    line-height: 1.12;
    letter-spacing: 0;
}

.hero p {
    max-width: 690px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.85;
}

.hero-card {
    border: 1px solid rgba(24, 32, 43, 0.18);
    background: rgba(255, 252, 243, 0.56);
    padding: 12px;
    box-shadow: 0 22px 54px rgba(24, 32, 43, 0.12);
}

.hero-card canvas {
    width: 100%;
    display: block;
    background: var(--paper);
}

.workspace {
    display: grid;
    grid-template-columns: 392px minmax(0, 1fr);
    gap: 0;
    height: calc(100vh - 72px);
    min-height: 0;
    padding: 0;
    overflow: hidden;
    align-items: stretch;
}

.input-panel,
.report-panel {
    border: 0;
    box-shadow: none;
}

.input-panel {
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    padding: 28px 28px 36px;
    display: grid;
    gap: 15px;
    align-content: start;
    background: rgba(255, 252, 243, 0.84);
    border-right: 1px solid var(--line);
}

.panel-head h2,
.report-head h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.panel-head p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

label {
    display: grid;
    gap: 7px;
}

label span {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.place-search-wrap {
    position: relative;
}

.place-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    display: none;
    max-height: 220px;
    overflow: auto;
    border: 1px solid rgba(24, 32, 43, 0.16);
    border-radius: 6px;
    background: #fffdf7;
    box-shadow: 0 14px 30px rgba(24, 32, 43, 0.14);
}

.place-search-results.active {
    display: block;
}

.place-option {
    padding: 10px 11px;
    cursor: pointer;
    color: var(--ink);
    border-bottom: 1px solid rgba(24, 32, 43, 0.08);
    font-size: 14px;
}

.place-option:last-child {
    border-bottom: none;
}

.place-option:hover,
.place-option.active {
    background: rgba(181, 54, 45, 0.08);
    color: var(--cinnabar);
}

.place-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(24, 32, 43, 0.16);
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    border-radius: 6px;
    padding: 10px 11px;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(181, 54, 45, 0.55);
    box-shadow: 0 0 0 3px rgba(181, 54, 45, 0.1);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.primary-button {
    width: 100%;
    border-color: var(--ink);
    background: var(--ink);
    color: #fffaf0;
    font-weight: 800;
}

.ghost-button {
    padding: 0 13px;
    background: rgba(255, 255, 255, 0.55);
    color: var(--ink);
    font-weight: 700;
}

.ghost-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.report-panel {
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    padding: 0;
    background: #fbf7ec;
}

.report-head {
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 24px 48px 18px;
    border-bottom: 1px solid rgba(24, 32, 43, 0.1);
    background: rgba(251, 247, 236, 0.96);
    backdrop-filter: blur(14px);
}

.report-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chapter-nav {
    position: sticky;
    top: 91px;
    z-index: 7;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0;
    padding: 14px 48px;
    border-bottom: 1px solid rgba(24, 32, 43, 0.08);
    background: rgba(251, 247, 236, 0.94);
    backdrop-filter: blur(14px);
    scrollbar-width: none;
}

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

.chapter-nav button {
    flex: 0 0 auto;
    padding: 0 11px;
    background: rgba(255, 255, 255, 0.54);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.chapter-nav button.active {
    border-color: rgba(181, 54, 45, 0.52);
    background: rgba(181, 54, 45, 0.1);
    color: var(--cinnabar);
}

.report-stage {
    display: grid;
    gap: 34px;
    width: min(980px, calc(100% - 96px));
    margin: 34px auto 72px;
}

.long-report-chapter {
    scroll-margin-top: 168px;
    padding: 50px 58px;
    border: 1px solid rgba(24, 32, 43, 0.1);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(181, 54, 45, 0.2) 3px, transparent 3px) left top / 3px 100% no-repeat,
        linear-gradient(180deg, rgba(181, 54, 45, 0.035), transparent 220px),
        #fffdf8;
    box-shadow: 0 18px 42px rgba(24, 32, 43, 0.055);
}

.long-report-heading {
    display: grid;
    gap: 8px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(24, 32, 43, 0.12);
}

.long-report-heading span {
    color: var(--cinnabar);
    font-size: 18px;
    font-weight: 900;
}

.long-report-heading h3 {
    margin: 0;
    color: var(--ink);
    font-family: var(--song);
    font-size: 40px;
    font-weight: 800;
    line-height: 1.16;
    letter-spacing: 0;
}

.long-report-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.profile-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 22px;
}

.profile-summary div {
    min-height: 86px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(24, 32, 43, 0.14);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(247, 240, 223, 0.36));
}

.profile-summary span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.profile-summary strong {
    display: block;
    font-family: var(--song);
    font-size: 34px;
    line-height: 1;
}

.long-report-block {
    max-width: 800px;
    margin: 0 auto 34px;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(24, 32, 43, 0.08);
}

.long-report-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.long-report-block h4 {
    margin: 0 0 18px;
    color: var(--cinnabar);
    font-family: var(--song);
    font-size: 24px;
    font-weight: 800;
    line-height: 1.35;
}

.long-report-block p {
    margin: 0 0 19px;
    color: #202b39;
    font-size: 18px;
    line-height: 2.08;
    text-align: justify;
}

.long-report-block p:last-child {
    margin-bottom: 0;
}

.empty-state {
    min-height: 360px;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(24, 32, 43, 0.22);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.35);
}

.share-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(24, 32, 43, 0.36);
}

.share-modal.active {
    display: grid;
}

.share-card {
    position: relative;
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid rgba(24, 32, 43, 0.14);
    border-radius: 8px;
    background: #fffdf7;
    box-shadow: 0 24px 70px rgba(24, 32, 43, 0.2);
}

.share-card h2 {
    margin: 0 0 18px;
    font-size: 24px;
    line-height: 1.3;
}

.share-card img {
    width: 220px;
    height: 220px;
    display: block;
    margin: 0 auto 18px;
    border: 12px solid #fff;
    background: #fff;
}

.share-card input {
    margin-bottom: 12px;
    font-size: 13px;
}

.share-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink);
    cursor: pointer;
}

@media (max-width: 920px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .bazi-app {
        height: auto;
        min-height: 100vh;
        display: block;
    }

    .hero,
    .workspace {
        grid-template-columns: 1fr;
    }

    .hero {
        display: none;
    }

    .workspace {
        height: auto;
        overflow: visible;
    }

    .hero-card {
        max-width: 360px;
    }

    .input-panel {
        position: static;
        height: auto;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .report-panel {
        height: auto;
        overflow: visible;
    }

    .report-head,
    .chapter-nav {
        position: static;
        padding-left: 20px;
        padding-right: 20px;
    }

    .report-stage {
        width: min(100% - 32px, 980px);
    }

    .report-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .bazi-app {
        width: min(100% - 20px, 1180px);
    }

    .topbar-inner,
    .report-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        padding-top: 28px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .long-report-chapter {
        padding: 22px 18px;
    }

    .long-report-heading h3 {
        font-size: 28px;
    }

    .profile-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .long-report-block p {
        font-size: 16px;
        line-height: 1.9;
        text-align: left;
    }
}

@media print {
    body {
        height: auto;
        overflow: visible;
        background: #fff;
    }

    .topbar,
    .input-panel,
    .report-head,
    .chapter-nav,
    .share-modal {
        display: none !important;
    }

    .bazi-app,
    main,
    .workspace,
    .report-panel {
        display: block;
        width: auto;
        height: auto;
        overflow: visible;
        background: #fff;
    }

    .report-stage {
        width: auto;
        margin: 0;
        gap: 0;
    }

    .long-report-chapter {
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 0 0 18mm;
        padding: 16mm;
        box-shadow: none;
        border-color: rgba(24, 32, 43, 0.18);
    }

    .long-report-block p {
        font-size: 12pt;
        line-height: 1.9;
    }
}
