/* Combined BaZi + Zi Wei page. It reuses the shared Predict top bar and theme
   variables, but has a wider canvas so the twelve-palace chart stays legible. */

.bazi-shell { box-sizing: border-box; width: 100%; max-width: 980px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
body:has(.bazi-shell) > .topbar { max-width: 980px; }

.bazi-page-head { display: flex; align-items: center; gap: 14px; padding: 4px 2px 2px; }
.bazi-back {
    flex: 0 0 auto; display: grid; width: 40px; height: 40px; place-items: center;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
    color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.bazi-page-head span, .bazi-section-title > div > span, .bazi-result-kicker {
    color: #a67522; font-size: 9px; font-weight: 900; letter-spacing: .2em;
}
.bazi-page-head h1 { margin: 3px 0 2px; font-size: 22px; }
.bazi-page-head p { margin: 0; color: var(--text-soft); font-size: 12px; }

.bazi-form-card, .bazi-result-card, .bazi-result-hero, .bazi-history {
    border: 1px solid rgba(183, 134, 44, .22); border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 96%, #fff7df 4%);
    box-shadow: 0 14px 38px rgba(68, 46, 13, .09);
}
.bazi-form-card { box-sizing: border-box; width: min(100%, 600px); margin: 0 auto; padding: 26px 28px 24px; }
.bazi-form-card > h2 {
    margin: 0 0 18px; color: #8d672c; font-family: Georgia, "Times New Roman", serif;
    font-size: 17px; font-weight: 500; letter-spacing: .22em; text-align: center;
}
.bazi-form-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 22px; }
.bazi-form-progress i { height: 3px; border-radius: 999px; background: color-mix(in srgb, var(--line) 78%, transparent); transition: background .2s ease; }
.bazi-form-progress i.is-done { background: linear-gradient(90deg, #b47a1d, #dfbb69); }

.bazi-field, .bazi-fieldset { display: block; margin: 0 0 18px; }
.bazi-field > span, .bazi-fieldset > legend {
    display: block; margin-bottom: 8px; padding: 0; color: var(--text-soft);
    font-size: 13px; font-weight: 700; letter-spacing: .03em;
}
.bazi-fieldset { min-width: 0; padding: 0; border: 0; }
.bazi-field input, .bazi-fieldset input[type="text"], .bazi-fieldset input[type="number"], .bazi-fieldset select {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 48px; padding: 0 14px;
    border: 1px solid color-mix(in srgb, var(--line) 82%, #b88b39 18%); border-radius: 14px;
    outline: 0; background: color-mix(in srgb, var(--surface) 94%, #fff8e8 6%);
    color: var(--text); font: inherit; font-size: 14px;
}
.bazi-field input:focus, .bazi-fieldset input[type="text"]:focus, .bazi-fieldset input[type="number"]:focus, .bazi-fieldset select:focus {
    border-color: #ba8430; box-shadow: 0 0 0 3px rgba(186, 132, 48, .12);
}
.bazi-calendar-switch {
    display: grid; grid-template-columns: 1fr 1fr; width: 152px; margin: -38px 0 8px auto;
    padding: 4px; border-radius: 12px; background: var(--surface-soft);
}
.bazi-calendar-switch label, .bazi-gender-switch label { position: relative; cursor: pointer; }
.bazi-calendar-switch input, .bazi-gender-switch input { position: absolute; opacity: 0; pointer-events: none; }
.bazi-calendar-switch span, .bazi-gender-switch span {
    display: grid; min-height: 38px; place-items: center; border: 1px solid transparent;
    border-radius: 9px; color: var(--text-soft); font-size: 13px; font-weight: 800;
}
.bazi-calendar-switch input:checked + span {
    border-color: var(--line); background: var(--surface); color: var(--text); box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}
.bazi-date-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 9px; }
.bazi-leap-option, .bazi-check-row {
    display: flex; align-items: center; gap: 8px; margin-top: 9px;
    color: var(--text-soft); font-size: 12px; cursor: pointer;
}
.bazi-leap-option[hidden] { display: none; }
.bazi-leap-option input, .bazi-check-row input { width: 17px; height: 17px; accent-color: #9a6b22; }
.bazi-time-panel {
    padding: 12px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface-soft); transition: opacity .2s ease;
}
.bazi-time-panel.is-disabled { opacity: .42; }
.bazi-time-grid, .bazi-place-grid, .bazi-gender-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bazi-time-panel p, .bazi-field-note, .bazi-owner-note {
    margin: 8px 0 0; color: var(--text-soft); font-size: 11px; line-height: 1.45; text-align: center;
}
.bazi-field-note + .bazi-field-note { margin-top: 3px; }
.bazi-gender-switch span { min-height: 50px; border-color: var(--line); background: var(--surface); font-size: 15px; }
.bazi-gender-switch input:checked + span {
    border-color: #5886eb; background: rgba(70, 119, 235, .08); color: #356ce6;
    box-shadow: inset 0 0 0 1px rgba(70, 119, 235, .12);
}
.bazi-gender-switch label:last-child input:checked + span { border-color: #d66b8b; background: rgba(214, 107, 139, .08); color: #c55177; }
.bazi-submit {
    width: 100%; min-height: 56px; padding: 0 18px; border: 0; border-radius: 18px;
    background: linear-gradient(135deg, #33291d, #1f1a14); color: #fffaf0; cursor: pointer;
    box-shadow: 0 10px 24px rgba(36, 26, 16, .18); font-size: 15px; font-weight: 900; letter-spacing: .09em;
}
.bazi-submit:disabled { cursor: wait; opacity: .66; }
.bazi-message { margin-bottom: 16px; padding: 11px 13px; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.bazi-message.is-error { border: 1px solid rgba(201, 55, 55, .3); background: rgba(201, 55, 55, .08); color: #bd3535; }
.bazi-message.is-warning { border: 1px solid rgba(185, 123, 22, .3); background: rgba(214, 154, 47, .1); color: #916119; }

.bazi-results { display: grid; min-width: 0; gap: 16px; scroll-margin-top: 12px; outline: none; }
.bazi-result-hero {
    position: relative; overflow: hidden; display: flex; min-height: 150px; align-items: center;
    justify-content: space-between; padding: 24px 30px;
    background: radial-gradient(circle at 80% 30%, rgba(218, 176, 92, .28), transparent 32%),
        linear-gradient(120deg, color-mix(in srgb, var(--surface) 92%, #f7e7be 8%), var(--surface));
}
.bazi-result-hero h2 { margin: 6px 0; font-family: Georgia, "Times New Roman", serif; font-size: 26px; }
.bazi-result-hero p, .bazi-result-hero small { display: block; margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.6; }
.bazi-yinyang { color: #b58029; font-size: 82px; line-height: 1; opacity: .48; text-shadow: 0 10px 28px rgba(183, 128, 41, .22); }
.bazi-result-card, .bazi-history { box-sizing: border-box; min-width: 0; padding: 20px; }
.bazi-section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.bazi-section-title h2 { margin: 3px 0 0; font-size: 18px; }
.bazi-section-title > strong { color: #9d6d20; font-size: 12px; }

.bazi-pillars-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.bazi-pillar {
    display: grid; min-width: 0; overflow: hidden; justify-items: center; gap: 5px; padding: 12px 7px; border: 1px solid var(--line);
    border-radius: 14px; background: var(--surface-soft); text-align: center;
}
.bazi-pillar.is-day { border-color: rgba(189, 132, 39, .56); box-shadow: inset 0 0 0 1px rgba(189, 132, 39, .12); }
.bazi-pillar > span, .bazi-pillar em, .bazi-pillar small { color: var(--text-soft); font-size: 10px; font-style: normal; }
.bazi-pillar strong { color: #a66b18; font-family: Georgia, "Times New Roman", serif; font-size: 30px; line-height: 1; }
.bazi-pillar small { min-height: 26px; line-height: 1.3; overflow-wrap: anywhere; }
.bazi-mini-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.bazi-mini-meta span { padding: 5px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--text-soft); font-size: 10px; }

.bazi-element-bars { display: grid; gap: 9px; }
.bazi-element-bars > div { display: grid; grid-template-columns: 26px 1fr 38px; align-items: center; gap: 9px; font-size: 12px; }
.bazi-element-bars i { height: 9px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.bazi-element-bars b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b17924, #e8c476); }
.bazi-element-bars strong { color: var(--text-soft); text-align: right; }
.bazi-lucky-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
.bazi-lucky-block > span { color: var(--text-soft); font-size: 11px; font-weight: 800; }
.bazi-lucky-block > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 9px 0 7px; }
.bazi-lucky-block strong {
    padding: 10px 4px; border: 1px solid rgba(186, 128, 36, .3); border-radius: 11px;
    background: radial-gradient(circle at top, rgba(232, 195, 112, .18), transparent), var(--surface-soft);
    color: #a86d15; font-size: 21px; letter-spacing: .08em;
}
.bazi-lucky-block small { color: var(--text-soft); font-size: 10px; }

.ziwei-board {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(124px, auto));
    gap: 1px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--line) 72%, #b68636 28%);
    border-radius: 16px; background: color-mix(in srgb, var(--line) 72%, #b68636 28%);
}
.ziwei-palace, .ziwei-centre { min-width: 0; background: var(--surface); }
.ziwei-palace { display: flex; min-width: 0; overflow: hidden; flex-direction: column; padding: 8px; }
.ziwei-palace.is-ming { box-shadow: inset 0 0 0 2px rgba(45, 107, 222, .6); }
.ziwei-palace.is-current { background: color-mix(in srgb, var(--surface) 91%, #9b6bec 9%); }
.ziwei-palace header, .ziwei-palace footer { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.ziwei-palace header strong { color: #96631b; font-size: 11px; }
.ziwei-palace header span, .ziwei-palace footer span { color: var(--text-soft); font-size: 9px; }
.ziwei-stars { display: flex; flex: 1; flex-wrap: wrap; align-content: flex-start; gap: 4px 6px; padding: 9px 0 6px; }
.ziwei-stars > span { color: var(--text); font-size: 12px; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.ziwei-stars small { color: var(--text-soft); font-size: 9px; }
.ziwei-stars b, .ziwei-palace footer b {
    display: inline-grid; width: 16px; height: 16px; margin-left: 2px; place-items: center;
    border-radius: 4px; color: #fff; font-size: 9px;
}
.ziwei-stars .sihua-禄 { background: #23925d; }
.ziwei-stars .sihua-权 { background: #356fc7; }
.ziwei-stars .sihua-科 { background: #b28726; }
.ziwei-stars .sihua-忌 { background: #c14f4f; }
.ziwei-palace footer b { margin: 0 2px 0 0; background: #356fc7; }
.ziwei-centre {
    display: grid; grid-row: 2 / 4; grid-column: 2 / 4; align-content: center;
    justify-items: center; gap: 5px; padding: 16px; text-align: center;
}
.ziwei-centre > span { color: #b17a25; font-size: 48px; line-height: 1; opacity: .42; }
.ziwei-centre strong { color: #93601a; letter-spacing: .16em; }
.ziwei-centre small { color: var(--text-soft); font-size: 10px; }
.ziwei-centre em { color: #a56d1b; font-size: 11px; font-style: normal; }
.ziwei-legend { margin: 10px 0 0; color: var(--text-soft); font-size: 10px; text-align: center; }
.ziwei-legend span { margin: 0 2px; font-weight: 900; }
.ziwei-legend small { display: block; margin-top: 4px; font-size: 9px; }

.bazi-dayun-row { display: grid; grid-template-columns: repeat(8, minmax(74px, 1fr)); gap: 7px; overflow-x: auto; padding-bottom: 3px; }
.bazi-dayun-row > div {
    display: grid; gap: 3px; padding: 10px 7px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--surface-soft); text-align: center;
}
.bazi-dayun-row > div.is-current { border-color: #8b57d9; background: rgba(137, 84, 218, .08); }
.bazi-dayun-row strong { color: #99651b; font-size: 15px; }
.bazi-dayun-row span { color: var(--text-soft); font-size: 9px; }
.bazi-method-note {
    margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-soft);
    color: var(--text-soft); font-size: 10px; line-height: 1.55;
}
.bazi-cycle-note {
    margin-top: 12px; padding: 12px 14px; border: 1px solid rgba(132, 82, 207, .22);
    border-radius: 12px; background: color-mix(in srgb, var(--surface-soft) 88%, #eee4ff 12%);
}
.bazi-cycle-note strong { display: block; color: #7548b3; font-size: 12px; }
.bazi-cycle-note p { margin: 5px 0 0; color: var(--text-soft); font-size: 11px; line-height: 1.55; }
.bazi-highlights { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.bazi-highlights p {
    margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface-soft); color: var(--text-soft); font-size: 12px; line-height: 1.55;
}
.bazi-warnings { margin-top: 12px; color: var(--text-soft); font-size: 11px; }
.bazi-warnings summary { cursor: pointer; font-weight: 800; }
.bazi-warnings p { margin: 6px 0 0; }

.bazi-reading-intro {
    margin: -5px 0 15px; color: var(--text-soft); font-size: 11px; line-height: 1.6;
}
.bazi-reading-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.bazi-reading-section {
    min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 14px;
    background: var(--surface-soft);
}
.bazi-reading-section header { display: grid; gap: 4px; margin-bottom: 10px; }
.bazi-reading-section header span { color: #9e681b; font-size: 14px; font-weight: 900; }
.bazi-reading-section header strong { color: var(--text); font-size: 11px; line-height: 1.45; }
.bazi-reading-section ul { display: grid; gap: 8px; margin: 0; padding-left: 17px; }
.bazi-reading-section li { color: var(--text-soft); font-size: 11px; line-height: 1.58; }
.bazi-reading-section li::marker { color: #b27c27; }
.bazi-reading-cycles { grid-column: 1 / -1; }

.bazi-history-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.bazi-history-grid a {
    display: grid; gap: 4px; min-width: 0; padding: 12px; border: 1px solid var(--line);
    border-radius: 12px; background: var(--surface-soft); color: var(--text); text-decoration: none;
}
.bazi-history-grid a:hover { border-color: rgba(177, 120, 36, .55); }
.bazi-history-grid span, .bazi-history-grid small {
    overflow: hidden; color: var(--text-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap;
}
.bazi-history-grid strong { color: #9f6a1e; font-size: 13px; }
.bazi-disclaimer { margin: 0; color: var(--text-soft); font-size: 10px; line-height: 1.55; text-align: center; }

body.dark .bazi-form-card, body.dark .bazi-result-card, body.dark .bazi-result-hero, body.dark .bazi-history {
    border-color: rgba(207, 164, 76, .2); background: linear-gradient(145deg, rgba(15, 32, 53, .97), rgba(5, 17, 32, .98));
    box-shadow: 0 18px 42px rgba(0, 0, 0, .34);
}
body.dark .bazi-page-head span, body.dark .bazi-section-title > div > span,
body.dark .bazi-result-kicker, body.dark .bazi-section-title > strong, body.dark .bazi-pillar strong,
body.dark .bazi-lucky-block strong, body.dark .ziwei-palace header strong, body.dark .ziwei-centre strong,
body.dark .ziwei-centre em, body.dark .bazi-dayun-row strong,
body.dark .bazi-reading-section header span { color: #e2b75e; }
body.dark .bazi-cycle-note strong { color: #c9a7ff; }
body.dark .bazi-submit { background: linear-gradient(135deg, #b07a24, #e0bd68); color: #171006; }

@media (max-width: 700px) {
    .bazi-shell { padding-right: 10px; padding-left: 10px; }
    .bazi-form-card { padding: 22px 16px; border-radius: 18px; }
    .bazi-result-card, .bazi-history { padding: 14px; border-radius: 16px; }
    .bazi-result-hero { padding: 20px; border-radius: 16px; }
    .ziwei-board { grid-template-rows: repeat(4, minmax(110px, auto)); }
    .ziwei-palace { padding: 6px; }
    .ziwei-stars > span { font-size: 10px; }
    .ziwei-palace header strong, .ziwei-palace header span { font-size: 8px; }
    .bazi-highlights, .bazi-history-grid, .bazi-reading-grid { grid-template-columns: 1fr; }
    .bazi-reading-cycles { grid-column: auto; }
}

@media (max-width: 440px) {
    .bazi-page-head h1 { font-size: 19px; }
    .bazi-page-head p { font-size: 10px; }
    .bazi-date-grid { gap: 5px; }
    .bazi-field input, .bazi-fieldset input[type="text"], .bazi-fieldset input[type="number"], .bazi-fieldset select { min-height: 45px; padding: 0 9px; font-size: 12px; }
    .bazi-place-grid { grid-template-columns: 1fr; }
    .bazi-pillars-grid { gap: 5px; }
    .bazi-pillar { padding: 10px 3px; }
    .bazi-pillar strong { font-size: 25px; }
    .bazi-pillar small { font-size: 8px; }
    .bazi-lucky-block > div { gap: 5px; }
    .bazi-lucky-block strong { font-size: 16px; }
    .ziwei-board { grid-template-rows: repeat(4, minmax(96px, auto)); }
    .ziwei-palace { padding: 5px; }
    .ziwei-stars { gap: 2px 4px; padding: 5px 0 3px; }
    .ziwei-stars > span { font-size: 9px; }
    .ziwei-stars b { width: 13px; height: 13px; font-size: 7px; }
    .ziwei-centre { padding: 6px; }
    .ziwei-centre > span { font-size: 34px; }
    .ziwei-centre strong { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) { .bazi-form-progress i { transition: none; } }
