:root {
    --bg: #f3f3f3;
    --panel: #ffffff;
    --panel-soft: #fafafa;
    --line: #e9e9e9;
    --text: #2b2b2b;
    --muted: #8f8f8f;
    --gold: #b69455;
    --gold-deep: #8c6b30;
    --red: #ee5d4d;
    --blue: #4c82ff;
    --orange: #e4932f;
    --black: #121212;
    --shadow: 0 18px 34px rgba(17, 17, 17, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #f7f7f7 0%, #efefef 100%);
    color: var(--text);
    font-family: "Noto Sans SC", sans-serif;
}

body {
    min-height: 100vh;
}

.page-shell {
    display: flex;
    justify-content: center;
    padding: 18px 12px 40px;
}

.app-shell {
    width: min(100%, 430px);
    display: grid;
    gap: 10px;
}

.mobile-appbar {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    height: 44px;
    color: var(--black);
    font-size: 15px;
    font-weight: 700;
}

.mobile-appbar strong {
    justify-self: center;
}

.appbar-side {
    color: #616161;
    font-size: 18px;
    text-align: center;
}

.tab-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    background: var(--black);
    padding: 6px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.tab-pill {
    border: 0;
    border-radius: 10px;
    padding: 8px 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.64);
    font-size: 11px;
    font-weight: 600;
}

.tab-pill.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-form {
    padding: 16px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.panel-head.compact {
    margin-bottom: 10px;
}

.panel-kicker {
    margin: 0 0 2px;
    color: var(--gold-deep);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.panel-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.panel-note {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
    max-width: 180px;
    text-align: right;
}

.chart-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chart-form label {
    display: grid;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
}

.chart-form input,
.chart-form select,
.primary-button,
.secondary-button,
.ghost-button,
#masterPrompt {
    font: inherit;
}

.chart-form input,
.chart-form select,
#masterPrompt {
    width: 100%;
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid #dedede;
    background: #fcfcfc;
    color: var(--text);
}

.primary-button,
.secondary-button,
.ghost-button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.primary-button {
    grid-column: 1 / -1;
    margin-top: 2px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
    color: #fff;
    font-weight: 700;
}

.secondary-button {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1f1f1f 0%, #343434 100%);
    color: #fff;
    font-weight: 600;
}

.ghost-button {
    padding: 8px 12px;
    background: rgba(182, 148, 85, 0.12);
    color: var(--gold-deep);
    font-size: 12px;
    font-weight: 700;
}

.ghost-button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.hidden {
    display: none;
}

.result-stack {
    display: grid;
    gap: 10px;
}

.chart-summary {
    display: grid;
    grid-template-columns: 110px 1fr;
    background:
        linear-gradient(135deg, rgba(18, 18, 18, 0.98), rgba(38, 32, 24, 0.94)),
        radial-gradient(circle at right top, rgba(182, 148, 85, 0.18), transparent 30%);
    color: #fff8ee;
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.summary-title {
    padding: 18px 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-title .eyebrow {
    margin: 0 0 8px;
    color: rgba(255, 248, 238, 0.68);
    font-size: 11px;
}

.summary-title h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1;
}

.summary-title-copy {
    margin: 8px 0 0;
    color: rgba(255, 248, 238, 0.72);
    font-size: 11px;
}

.summary-meta {
    display: grid;
    gap: 6px;
    padding: 16px 14px;
}

.summary-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    line-height: 1.5;
}

.summary-meta-row span:first-child {
    color: rgba(255, 248, 238, 0.62);
    flex: 0 0 auto;
}

.panel-chart,
.panel-fortune,
.panel-shensha,
.panel-license {
    padding: 14px;
}

.table-wrap {
    overflow-x: auto;
}

.mingpan-table {
    width: 100%;
    min-width: 390px;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--panel);
}

.mingpan-table th,
.mingpan-table td {
    padding: 8px 4px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
    vertical-align: top;
}

.mingpan-table thead th {
    color: #9a9a9a;
    font-size: 10px;
    font-weight: 600;
    background: #fcfcfc;
}

.mingpan-table tbody th {
    color: #a1a1a1;
    background: #fafafa;
    font-size: 10px;
    font-weight: 600;
    width: 42px;
}

.pillars-main,
.pillars-hero,
.pillars-earth {
    font-size: 12px;
    font-weight: 700;
}

.pillars-hero {
    color: var(--blue);
}

.pillars-earth {
    color: var(--orange);
}

.stack-lines {
    display: grid;
    gap: 3px;
    justify-items: center;
    font-size: 10px;
    line-height: 1.25;
}

.fortune-panel {
    border-radius: 14px;
    background: var(--panel-soft);
    border: 1px solid #efefef;
    padding: 12px;
}

.fortune-overview {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.fortune-overview-item {
    border-radius: 14px;
    border: 1px solid #ededed;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 241, 0.98));
    padding: 10px 8px;
    text-align: center;
}

.fortune-overview-item span,
.fortune-overview-item small {
    display: block;
}

.fortune-overview-item span {
    color: #8c8c8c;
    font-size: 10px;
}

.fortune-overview-item strong {
    display: block;
    margin-top: 4px;
    color: var(--gold-deep);
    font-size: 15px;
}

.fortune-overview-item small {
    margin-top: 4px;
    color: #a2a2a2;
    font-size: 10px;
}

.fortune-panel + .fortune-panel {
    margin-top: 10px;
}

.fortune-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
    color: #7d7d7d;
    font-size: 10px;
}

.fortune-chip-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.fortune-chip {
    border-radius: 12px;
    border: 1px solid #ededed;
    background: #fff;
    padding: 8px 4px;
    text-align: center;
}

.fortune-chip.is-current,
.year-card.is-current {
    background: linear-gradient(180deg, rgba(182, 148, 85, 0.16), rgba(182, 148, 85, 0.04));
    border-color: rgba(182, 148, 85, 0.46);
}

.fortune-chip-years,
.year-card-year {
    color: #8d8d8d;
    font-size: 10px;
}

.fortune-chip-gz,
.year-card-gz {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--gold-deep);
}

.fortune-chip-age,
.year-card-age {
    margin-top: 4px;
    font-size: 10px;
    color: #8d8d8d;
}

.fortune-subhead {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    font-size: 11px;
    color: #8d8d8d;
}

.year-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.year-card {
    border-radius: 12px;
    border: 1px solid #ededed;
    background: #fff;
    padding: 8px 4px;
    text-align: center;
}

.flow-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.flow-pill {
    border-radius: 12px;
    background: #fff;
    border: 1px solid #ededed;
    padding: 10px 8px;
    text-align: center;
}

.flow-pill span {
    display: block;
    color: #9b9b9b;
    font-size: 10px;
}

.flow-pill strong {
    display: block;
    margin-top: 4px;
    color: var(--red);
    font-size: 16px;
}

.shensha-item + .shensha-item {
    margin-top: 8px;
}

.shensha-title {
    color: var(--gold-deep);
    font-size: 11px;
    font-weight: 700;
}

.shensha-list {
    margin-top: 4px;
    color: #757575;
    font-size: 11px;
    line-height: 1.7;
}

.license-layout {
    display: grid;
    gap: 10px;
}

.license-card,
.prompt-card {
    border-radius: 14px;
    border: 1px solid #efefef;
    background: var(--panel-soft);
    padding: 14px;
}

.license-title {
    margin: 0;
    color: #8f8f8f;
    font-size: 11px;
}

.license-price {
    margin: 6px 0 4px;
    font-size: 34px;
    font-weight: 800;
    color: var(--text);
}

.license-copy,
.license-hint {
    margin: 0 0 10px;
    color: #7d7d7d;
    font-size: 11px;
    line-height: 1.6;
}

.prompt-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.prompt-card-head h3 {
    margin: 0;
    font-size: 14px;
}

#masterPrompt {
    min-height: 240px;
    resize: vertical;
    line-height: 1.65;
    font-size: 11px;
}

@media (min-width: 900px) {
    .page-shell {
        padding: 28px 20px 60px;
    }

    .app-shell {
        width: min(100%, 980px);
    }

    .result-stack {
        grid-template-columns: 1.2fr 0.8fr;
        align-items: start;
    }

    .chart-summary,
    .panel-chart {
        grid-column: 1 / 2;
    }

    .panel-fortune,
    .panel-shensha,
    .panel-license {
        grid-column: 2 / 3;
    }

    .panel-form {
        grid-column: 1 / -1;
    }

    .chart-form {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .flow-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .fortune-overview {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
