.lab[data-ziwei-workspace="true"] .workspace { grid-template-columns: minmax(0, 1fr); }
.lab[data-ziwei-workspace="true"] #history-panel,
.lab[data-ziwei-workspace="true"] #quota-strip,
.lab[data-ziwei-workspace="true"] #sidebar-toggle { display: none; }
#panel-ziwei { --zw-ink: #302b38; --zw-line: #e4dfe8; padding: 20px; color: var(--zw-ink); background: #faf9f6; }
#panel-ziwei [hidden] { display: none !important; }
#panel-ziwei .panel-heading { margin-bottom: 12px; }
#panel-ziwei .eyebrow { color: #82718c; letter-spacing: .12em; font-size: 11px; }
#panel-ziwei h1 { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 23px; letter-spacing: .06em; }
.ziwei-library { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#ziwei-saved-tabs { display: flex; gap: 8px; min-width: 0; overflow-x: auto; padding: 4px 2px 8px; }
.ziwei-saved-tab { flex: 0 0 auto; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--zw-line); border-radius: 9px; padding: 11px 16px; background: #ffffffb8; color: #706677; font: inherit; cursor: pointer; }
.ziwei-saved-tab[aria-pressed="true"] { background: #685080; color: #fff; border-color: #685080; box-shadow: 0 3px 9px #68508024; }
#ziwei-new-chart { flex-shrink: 0; border-style: dashed; }
#ziwei-save-status { margin: 0 0 0 auto; font-size: 11px; }
#ziwei-label-editor { margin: 0 0 8px; font-size: 12px; color: #625769; }
#ziwei-label-editor > summary { cursor: pointer; width: fit-content; padding: 4px 0; }
.ziwei-controls { display: flex; align-items: start; gap: 12px; }
.ziwei-controls:has(details[open]) { flex-wrap: wrap; }
.ziwei-controls > details { flex: 1; min-width: 0; }
.ziwei-controls > details[open] { flex-basis: 100%; }
#ziwei-label-form { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
#ziwei-label-form label { font-size: 12px; color: #776b80; }
#ziwei-label { width: min(260px, 45%); min-width: 0; padding: 9px 12px; border: 1px solid var(--zw-line); border-radius: 8px; background: #ffffffba; color: var(--zw-ink); font: inherit; }
#ziwei-label-form .button { font-size: 12px; padding: 8px 12px; min-height: 38px; }
#ziwei-archive { margin-left: auto; }
#ziwei-birth-editor { padding: 14px 18px; border: 1px solid var(--zw-line); border-radius: 12px; background: #ffffffa6; }
#ziwei-birth-summary { cursor: pointer; line-height: 1.8; font-size: 13px; color: #655b6b; }
.ziwei-birth-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin: 20px 0 12px; }
.ziwei-birth-form label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.ziwei-birth-form input, .ziwei-birth-form select { min-height: 44px; padding: 8px 12px; border: 1px solid var(--zw-line); border-radius: 8px; background: white; color: var(--zw-ink); font: inherit; max-width: 100%; }
.ziwei-note { font-size: 12px; color: #776f7d; line-height: 1.7; }
#ziwei-status, .ziwei-answer-status { margin: 12px 0; font-size: 13px; line-height: 1.7; }
#ziwei-status:empty { margin: 8px 0; }
#ziwei-view-switch { display: flex; flex-shrink: 0; gap: 5px; padding: 4px; margin: 0; background: #eee9f1; border-radius: 10px; width: fit-content; }
#ziwei-view-switch button { border: 0; background: transparent; color: #75687e; min-width: 120px; }
#ziwei-view-switch button[aria-pressed="true"] { background: white; color: #5c4276; box-shadow: 0 1px 5px #39334714; }
.ziwei-chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0; }
.ziwei-chart-heading .eyebrow { display: none; }
.ziwei-chart-heading .eyebrow { margin: 0 0 6px; }
#ziwei-summary { font-size: 18px; font-weight: 500; letter-spacing: .06em; line-height: 1.7; margin: 0; }
.ziwei-legend { flex-shrink: 0; text-align: right; font-size: 11px; line-height: 1.8; color: #8c7e93; }
.ziwei-palaces { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; padding: 1px; margin: 0 0 28px; border: 1px solid #d4c9dc; border-radius: 16px; background: #ded5e5; overflow: hidden; box-shadow: 0 12px 40px #49335809; }
.ziwei-palace { grid-row: var(--palace-row); grid-column: var(--palace-column); position: relative; padding: 13px 15px 10px; background: #fffefa; min-width: 0; display: flex; flex-direction: column; transition: background .15s; }
.ziwei-palace:hover { background: #fcf9ff; }
.ziwei-palace[data-palace="命宫"] { background: #f5f0fa; box-shadow: inset 3px 0 #826299; }
.ziwei-palace:has([aria-expanded="true"]) { background: #ebe2f4; box-shadow: inset 0 0 0 2px #826299; }
.ziwei-palace-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 0 0 11px; margin-bottom: 10px; border: 0; border-bottom: 1px solid #eee8f1; background: none; text-align: left; font: inherit; cursor: pointer; color: #463350; }
.ziwei-palace-heading strong { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 19px; letter-spacing: .06em; }
.ziwei-palace-branch { font-size: 12px; color: #73627f; text-align: right; }
.ziwei-stars { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; line-height: 1.8; margin-bottom: 6px; }
.ziwei-star { display: inline-flex; flex-wrap: wrap; align-items: baseline; }
.ziwei-stars.major_stars { min-height: 32px; color: #55326f; font-weight: 700; font-size: 20px; margin-bottom: 7px; }
.ziwei-brightness { font-size: 12px; font-weight: 400; color: #73627f; }
.ziwei-stars.minor_stars { color: #675545; }
.ziwei-stars.adjective_stars { color: #625e68; font-size: 13px; }
.ziwei-mutagen { font-size: 11px; font-weight: 600; padding: 0 4px; margin-left: 3px; color: #80502f; background: #f5e8d7; border-radius: 4px; white-space: nowrap; }
.ziwei-mutagen[data-mutagen="忌"] { color: #93566a; background: #f5e4ea; }
.ziwei-mutagen[data-mutagen="科"] { color: #426e78; background: #e4eff1; }
.ziwei-mutagen[data-mutagen="禄"] { color: #4d7860; background: #e5eee5; }
.ziwei-empty-stars { font-size: 12px; font-weight: 400; color: #77717c; }
.ziwei-palace > .ziwei-note { margin: auto 0 0; padding-top: 10px; font-size: 11px; color: #776a7d; }
.ziwei-center { grid-row: 2 / 4; grid-column: 2 / 4; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; padding: 22px; text-align: center; background: linear-gradient(150deg, #fcfaf6, #f3eff6); overflow: hidden; }
.ziwei-center > * { position: relative; }
.ziwei-center-kicker { font-size: 12px; letter-spacing: .35em; color: #9986a4; }
.ziwei-center h3 { font-family: "Noto Serif SC", "Songti SC", serif; font-weight: 600; font-size: 26px; letter-spacing: .04em; margin: 12px 0; color: #47344f; max-width: 100%; overflow-wrap: anywhere; }
.ziwei-center p { font-size: 13px; line-height: 1.8; color: #6e6276; margin: 2px 0; }
.ziwei-pillars { display: grid; grid-template-columns: repeat(4, 1fr); width: min(100%, 360px); gap: 8px; margin: 20px 0; }
.ziwei-pillars > div { padding: 10px 2px; background: #ffffffa8; border: 1px solid #e5deea; border-radius: 8px; }
.ziwei-pillars span { display: block; font-size: 11px; color: #776582; margin-bottom: 6px; }
.ziwei-pillars strong { font-size: 23px; font-weight: 500; color: #55326f; }
.ziwei-center-facts { display: grid; grid-template-columns: repeat(2, 1fr); width: min(100%, 360px); gap: 12px 20px; margin: 0; text-align: left; }
.ziwei-center-facts > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ziwei-center-facts dt { font-size: 11px; color: #76677e; }
.ziwei-center-facts dd { margin: 0; font-size: 13px; font-weight: 600; }
.ziwei-explorer { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 16px; }
.ziwei-explorer:has(dialog[open]) { grid-template-columns: minmax(0, 1fr) 290px; }
#ziwei-chart { min-width: 0; }
#ziwei-palace-dialog { position: sticky; top: 16px; margin: 12px 0 0; width: 100%; min-width: 0; max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid #ddd1e4; border-radius: 12px; background: #fffdfa; color: #493a53; padding: 18px; box-shadow: 0 8px 24px #2210300c; }
.ziwei-palace-navigation { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 16px; }
.ziwei-palace-navigation button { flex: 1; border: 1px solid #ded5e5; border-radius: 6px; padding: 9px; color: #604c70; background: #f7f3fa; cursor: pointer; }
#ziwei-palace-dialog::backdrop { background: #22192c75; backdrop-filter: blur(3px); }
.ziwei-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ziwei-dialog-heading h2 { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 24px; }
#ziwei-palace-detail h3 { margin: 20px 0 6px; font-size: 12px; color: #a080ac; }
#ziwei-palace-detail p { font-size: 14px; line-height: 1.9; }
#ziwei-ask-palace { margin-top: 16px; width: 100%; }
#ziwei-reading { max-width: 860px; margin: 0 auto; width: 100%; }
#ziwei-reading h2 { font-size: 21px; }
.ziwei-prompts { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 12px; }
.ziwei-prompts button { border: 1px solid var(--zw-line); background: #fffdfa; color: #735c82; border-radius: 20px; padding: 10px 15px; font: inherit; cursor: pointer; }
#ziwei-question-form { display: flex; flex-direction: column; align-items: stretch; padding: 14px; margin: 16px 0; border: 1px solid var(--zw-line); border-radius: 14px; background: white; }
#ziwei-question-form textarea { width: 100%; min-height: 110px; resize: vertical; border: none; background: transparent; padding: 8px; font: inherit; line-height: 1.7; }
#ziwei-question-form button { align-self: flex-end; min-width: 100px; }
.ziwei-answer { overflow-wrap: anywhere; line-height: 1.9; padding: 16px 0; }
#panel-ziwei .button-primary { background: #685080; border-color: #685080; }
#panel-ziwei button:focus-visible, #panel-ziwei summary:focus-visible, #panel-ziwei input:focus-visible { outline: 2px solid #85639c; outline-offset: 3px; }
#panel-ziwei button:disabled { opacity: .55; cursor: wait; }
@media (max-width: 760px) {
  #panel-ziwei { padding: 16px 12px; }
  #panel-ziwei h1 { font-size: 25px; }
  .ziwei-library { flex-wrap: wrap; gap: 5px 8px; }
  #ziwei-saved-tabs { width: 100%; }
  #ziwei-label-form { flex-wrap: wrap; gap: 7px; }
  #ziwei-label { flex: 1; }
  #ziwei-label-form label { display: none; }
  .ziwei-palaces { grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 12px; }
  .ziwei-palace { grid-row: auto; grid-column: auto; padding: 13px 11px 10px; }
  .ziwei-palace[data-palace="命宫"] { order: -1; }
  .ziwei-palace-heading strong { font-size: 17px; }
  .ziwei-center { grid-row: 1; grid-column: 1 / -1; padding: 22px 10px; }
  .ziwei-center h3 { font-size: 23px; margin: 10px 0; }
  .ziwei-center-kicker { font-size: 10px; }
  .ziwei-center p { font-size: 12px; line-height: 1.6; margin: 2px 0; }
  .ziwei-stars.major_stars { font-size: 18px; }
  .ziwei-stars { gap: 3px 7px; }
  .ziwei-birth-form { gap: 12px; }
  .ziwei-birth-form label { flex: 1 1 135px; min-width: 0; }
  .ziwei-birth-form > button { width: 100%; }
  #ziwei-summary { font-size: 14px; letter-spacing: 0; }
  .ziwei-legend { font-size: 10px; }
  #ziwei-birth-editor { padding: 12px; }
  .ziwei-controls { flex-wrap: wrap; }
  .ziwei-controls > details { flex-basis: 100%; }
  #ziwei-view-switch { width: 100%; }
  #ziwei-view-switch button { flex: 1; min-width: 0; }
  .ziwei-explorer:has(dialog[open]) { grid-template-columns: minmax(0, 1fr); }
  #ziwei-palace-dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: 100%; margin: 0; border-radius: 20px 20px 0 0; max-height: 80dvh; padding: 18px 20px max(20px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px #22103025; }
  #ziwei-save-status { width: 100%; margin: 4px 0; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .ziwei-explorer:has(dialog[open]) { grid-template-columns: minmax(0, 1fr); }
  #ziwei-palace-dialog { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(620px, 100%); max-height: 80dvh; border-radius: 20px 20px 0 0; }
}
@media (prefers-reduced-motion: reduce) { .ziwei-palace { transition: none; } }

/* 星曜分组与玄幻星图主题。色彩只表达星曜分类，庙旺与四化以原始文字为准。 */
body:has(.lab[data-ziwei-workspace="true"]) { background: #10121c; }
.lab[data-ziwei-workspace="true"] { --surface: #191c2b; --ink: #e9e3f1; --muted: #a99dbb; --line: #3d3851; color: #e9e3f1; }
.lab[data-ziwei-workspace="true"] .domain-tab.is-active { background: #332a45; color: #f0d9ab; border-bottom-color: #c7a775; }
.lab[data-ziwei-workspace="true"] .workspace { border-color: #4f435d; }
#panel-ziwei { --zw-ink: #e9e5f3; --zw-line: #3d3857; color-scheme: dark; color: var(--zw-ink); background: radial-gradient(ellipse at 45% 0, #2b2344 0, transparent 55%), #121420; }
#panel-ziwei h1 { color: #f2dfb5; text-shadow: 0 0 24px #c5a07130; }
#panel-ziwei .eyebrow, #panel-ziwei .ziwei-note, #ziwei-save-status, #ziwei-label-editor { color: #aaa3bf; }
#panel-ziwei .button-outline { border-color: #514666; background: #211f32; color: #ddd2e9; }
#panel-ziwei .button-primary { border-color: #b69a69; background: linear-gradient(135deg, #8b6940, #625080); color: #fff5de; }
.ziwei-saved-tab { background: #211e32; color: #c6bdd8; border-color: #49405e; }
.ziwei-saved-tab[aria-pressed="true"] { background: linear-gradient(120deg, #554069, #352d49); border-color: #bc9a63; color: #f4dfb4; box-shadow: inset 0 1px #f7dfac24; }
#ziwei-birth-editor, #ziwei-label { background: #1c1c2c; border-color: #40384f; color: #d6cde3; }
#ziwei-birth-summary { color: #c7bfd3; }
.ziwei-birth-form input, .ziwei-birth-form select { background: #141724; color: #eee7f6; border-color: #514566; }
#ziwei-view-switch { background: #1b1b2a; border: 1px solid #40374f; }
#ziwei-view-switch button { color: #b0a6c2; }
#ziwei-view-switch button[aria-pressed="true"] { background: #3b304e; color: #f4dfb4; }
.ziwei-legend { color: #b8a6c7; }
.ziwei-palaces { background: #51445f; border-color: #8a735b; border-radius: 12px; box-shadow: 0 16px 50px #0005, 0 0 24px #bb8fea0b; }
.ziwei-palace { background: linear-gradient(145deg, #242238, #191c2b); padding: 13px; }
.ziwei-palace:hover { background: linear-gradient(145deg, #302941, #1d2031); }
.ziwei-palace[data-palace="命宫"] { background: linear-gradient(145deg, #3b2d4e, #252236); box-shadow: inset 3px 0 #ccad76; }
.ziwei-palace:has([aria-expanded="true"]) { background: #392e4a; box-shadow: inset 0 0 0 2px #d5b783, inset 0 0 28px #bd965510; }
.ziwei-palace-heading { border-bottom-color: #76608045; color: #ecdbb7; }
.ziwei-palace-heading strong { font-weight: 600; }
.ziwei-palace-branch { color: #bca9c7; }
.ziwei-star-group { margin: 0 0 11px; }
.ziwei-group-label { display: flex; align-items: center; gap: 7px; margin: 0 0 7px; color: #aaa3bf; font-size: 10px; font-weight: 500; letter-spacing: .12em; }
.ziwei-group-label::before { content: ""; width: 5px; height: 5px; transform: rotate(45deg); background: #9b90b3; }
.major_stars > .ziwei-group-label { color: #d6b881; }
.major_stars > .ziwei-group-label::before { background: #d6b881; box-shadow: 0 0 8px #d6b88150; }
.minor_stars > .ziwei-group-label { color: #85c9c7; }
.minor_stars > .ziwei-group-label::before { background: #85c9c7; }
.ziwei-stars { gap: 6px; margin: 0; }
.ziwei-star { gap: 0; padding: 3px 6px; border: 1px solid #6f64833d; border-radius: 5px; background: #aaa0c20b; color: #c5bdd4; }
.ziwei-stars.major_stars { font-size: 19px; margin: 0; min-height: 0; }
.major_stars .ziwei-star { padding: 5px 8px; background: linear-gradient(135deg, #8c693323, #393044); border-color: #bb97655c; color: #f1d59b; box-shadow: inset 0 1px #e8c59013; }
.ziwei-brightness { color: #aea4bf; font-size: 11px; }
.major_stars .ziwei-brightness { color: #c7b799; }
.ziwei-stars.minor_stars { font-size: 14px; }
.ziwei-star[data-star-type="soft"], .ziwei-star[data-star-type="lucun"], .ziwei-star[data-star-type="tianma"] { background: #1c444333; border-color: #63b6b750; color: #a6dfd9; }
.ziwei-star[data-star-type="tough"] { background: #6e34422b; border-color: #ba738054; color: #edb1b4; }
.ziwei-star[data-star-type="flower"] { color: #d7b4de; border-color: #b385c154; }
.ziwei-star-kind { font-size: 9px; border-left: 1px solid #b4a4c330; margin-left: 4px; padding-left: 4px; opacity: .85; font-weight: 400; }
.ziwei-stars.adjective_stars { font-size: 12px; }
.ziwei-mutagen { font-size: 10px; background: #ad80372e; border: 1px solid #c89b4954; color: #f7d794; }
.ziwei-mutagen[data-mutagen="禄"] { background: #24533c; color: #b0e2bf; }
.ziwei-mutagen[data-mutagen="科"] { background: #274b5c; color: #bbdfef; }
.ziwei-mutagen[data-mutagen="忌"] { background: #65344b; color: #f4c0d0; }
.ziwei-empty-stars { color: #9e95b0; padding: 2px 0; }
.ziwei-palace > .ziwei-note { color: #a99eb9; border-top: 1px solid #6f648328; padding-top: 8px; }
.ziwei-center { background: radial-gradient(ellipse at center, #3b2c48, #1c1e2e 85%); }
.ziwei-center::before { content: ""; position: absolute; width: min(78%, 360px); aspect-ratio: 1; border: 1px solid #c1a07718; border-radius: 50%; box-shadow: 0 0 0 18px #c1a07705, 0 0 0 19px #c1a0770b; pointer-events: none; }
.ziwei-center h3 { color: #f0d8aa; text-shadow: 0 0 25px #d5ad6825; }
.ziwei-center-kicker { color: #c1a880; }
.ziwei-center p { color: #bfb1cf; }
.ziwei-pillars > div { background: linear-gradient(#302c43, #252536); border-color: #aa8a565c; box-shadow: inset 0 1px #dec1951c; }
.ziwei-pillars span, .ziwei-center-facts dt { color: #b8a8c5; }
.ziwei-pillars strong { color: #efcc93; }
.ziwei-center-facts dd { color: #e6dcec; }
#ziwei-palace-dialog { background: linear-gradient(155deg, #2d263c, #191d2a); color: #ded4e9; border-color: #8c7458; box-shadow: 0 15px 45px #0005; }
.ziwei-dialog-heading h2 { color: #eed7ac; }
.ziwei-palace-navigation button { border-color: #635073; background: #30283f; color: #d6c5e7; }
#ziwei-palace-detail > .ziwei-star-group { margin: 20px 0; }
#ziwei-palace-detail p { color: #c4b8d1; }
.ziwei-prompts button { background: #262337; border-color: #574764; color: #d6c2e7; }
#ziwei-question-form { background: #1b1d2b; border-color: #685274; }
#ziwei-question-form textarea { color: #e9e0f1; }
#ziwei-question-form textarea::placeholder { color: #a69ab7; }
#panel-ziwei button:focus-visible, #panel-ziwei input:focus-visible, #panel-ziwei summary:focus-visible { outline-color: #e1bd80; }
@media (max-width: 760px) {
  .ziwei-palace { padding: 11px 9px; }
  .ziwei-stars.major_stars { font-size: 17px; }
  .major_stars .ziwei-star { padding: 4px 6px; }
  .ziwei-stars { gap: 5px; }
  .ziwei-star-kind { font-size: 9px; }
}

/* 主星以五行着色，阴阳与吉凶星性使用独立文字徽记。 */
.ziwei-workspace-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.ziwei-workspace-body > * { min-width: 0; }
.ziwei-workspace-body #ziwei-reading { position: static; padding: 20px; border: 1px solid #574764; border-radius: 14px; background: #1b1b2a; max-height: none; overflow: visible; }
.ziwei-workspace-body #ziwei-reading h2 { margin: 0; color: #efd7ad; }
.ziwei-workspace-body .ziwei-prompts { margin-top: 14px; gap: 6px; }
.ziwei-workspace-body .ziwei-prompts button { padding: 8px 10px; font-size: 12px; }
.ziwei-workspace-body #ziwei-question-form { position: static; margin-top: 18px; box-shadow: none; }
.ziwei-turns { display: grid; gap: 24px; margin-top: 18px; }
.ziwei-turn { min-width: 0; padding-top: 24px; border-top: 1px solid #4b415a; }
.ziwei-turn:first-child { padding-top: 0; border-top: 0; }
.ziwei-last-question { margin: 18px 0; padding: 12px 16px; border-radius: 12px 12px 3px 12px; background: #3b304e; color: #f0e3fa; white-space: pre-wrap; overflow-wrap: anywhere; }
.ziwei-process { margin: 18px 0 10px; border-top: 1px solid #574c68; border-bottom: 1px solid #40374f; color: #d8cee3; }
.ziwei-process > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 2px; color: #cfc1da; font-size: 13px; cursor: pointer; }
.ziwei-process-state { color: #a99dbb; font-size: 11px; font-weight: 400; }
.ziwei-process[data-state="running"] .ziwei-process-state { color: #e6c78f; }
.ziwei-process[data-state="error"] .ziwei-process-state { color: #e8a9b5; }
.ziwei-process-steps { display: grid; gap: 2px; margin: 0; padding: 2px 0 14px; list-style: none; }
.ziwei-process-step { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: start; gap: 9px; min-height: 34px; padding: 7px 2px; }
.ziwei-process-marker { width: 8px; height: 8px; margin-top: 6px; border: 2px solid #8c7b9d; border-radius: 50%; }
.ziwei-process-step[data-status="running"] .ziwei-process-marker { border-color: #d2aa69; box-shadow: 0 0 0 3px #d2aa691a; }
.ziwei-process-step[data-status="done"] .ziwei-process-marker,
.ziwei-process-step[data-status="available"] .ziwei-process-marker { border-color: #80bfa8; background: #80bfa8; }
.ziwei-process-step[data-status="disabled"] .ziwei-process-marker,
.ziwei-process-step[data-status="empty"] .ziwei-process-marker,
.ziwei-process-step[data-status="unavailable"] .ziwei-process-marker,
.ziwei-process-step[data-status="skipped"] .ziwei-process-marker { border-color: #777080; background: #777080; }
.ziwei-process-body { min-width: 0; }
.ziwei-process-label { display: block; color: #ded3e7; font-size: 13px; font-weight: 500; line-height: 1.55; overflow-wrap: anywhere; }
.ziwei-process-detail { display: block; color: #9f95ad; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.ziwei-process-step-status { color: #a99dbb; font-size: 11px; line-height: 1.7; white-space: nowrap; }
.ziwei-answer { min-width: 0; overflow-wrap: anywhere; white-space: normal; font-size: 16px; font-weight: 400; line-height: 1.9; padding: 14px 0 8px; }
.ziwei-answer > :first-child { margin-top: 0; }
.ziwei-answer > :last-child { margin-bottom: 0; }
.ziwei-answer h3, .ziwei-answer h4, .ziwei-answer h5 { margin: 1.55em 0 .65em; color: #efd8ae; font-family: "Noto Serif SC", "Songti SC", serif; font-weight: 600; line-height: 1.45; letter-spacing: 0; }
.ziwei-answer h3 { font-size: 20px; }
.ziwei-answer h4 { font-size: 17px; }
.ziwei-answer h5 { font-size: 15px; }
.ziwei-answer p { margin: 0 0 1.05em; color: #ddd4e6; white-space: pre-wrap; }
.ziwei-answer ul, .ziwei-answer ol { margin: .35em 0 1.15em; padding-left: 1.5em; color: #ddd4e6; }
.ziwei-answer li { margin: .42em 0; padding-left: .2em; }
.ziwei-answer strong { color: #f0d4a3; font-weight: 650; }
.ziwei-turn-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.ziwei-answer-status { flex: 1; min-width: 0; margin: 8px 0 0; color: #aaa3bf; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.ziwei-turn[data-state="error"] .ziwei-answer-status { color: #e8a9b5; }
.ziwei-turn-references { flex: 0 0 auto; margin-top: 8px; }
#ziwei-compact-palaces { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, 66px); gap: 1px; padding: 1px; border: 1px solid #8a735b; border-radius: 14px; overflow: hidden; background: #65516c55; box-shadow: 0 16px 40px #0003; }
.ziwei-palace-shortcut { grid-row: var(--palace-row); grid-column: var(--palace-column); min-width: 0; border: 0; padding: 8px 3px; color: #e1cee9; background: #222236; cursor: pointer; font: inherit; text-align: center; }
.ziwei-palace-shortcut strong { display: block; color: #d9c8ac; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 13px; font-weight: 500; }
.ziwei-palace-shortcut > span { display: block; margin-top: 5px; color: #d1c6de; font-size: 12px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.ziwei-palace-shortcut[data-mini-palace="命宫"] { background: #44334e; box-shadow: inset 2px 0 #d5b783; }
.ziwei-palace-shortcut:hover, .ziwei-palace-shortcut:focus-visible { background: #493b56; }
.ziwei-mini-center { grid-row: 2 / 4; grid-column: 2 / 4; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 9px; background: radial-gradient(ellipse at center, #41304d, #242235); }
.ziwei-mini-center > span { font-size: 10px; letter-spacing: .2em; color: #bfa786; }
.ziwei-mini-center > strong { font-family: "Noto Serif SC", "Songti SC", serif; font-weight: 500; font-size: 21px; color: #f0d5a6; }
.ziwei-mini-center > small { font-size: 10px; color: #b9abc4; }
.ziwei-mini-expand { border: 0; border-bottom: 1px solid #bfa78666; padding: 3px 0; background: transparent; color: #e6cda3; font: inherit; font-size: 11px; cursor: pointer; }
#panel-ziwei[data-chart-compact="true"] .ziwei-workspace-body { grid-template-columns: 310px minmax(0, 1fr); max-width: 1120px; margin: 0 auto; gap: 24px; }
#panel-ziwei[data-chart-compact="true"] .ziwei-explorer { position: sticky; top: 20px; }
#panel-ziwei[data-chart-compact="true"] .ziwei-chart-heading { margin: 0 0 12px; }
#panel-ziwei[data-chart-compact="true"] #ziwei-summary { font-size: 12px; letter-spacing: 0; color: #bfb1cf; }
#panel-ziwei[data-chart-compact="true"] .ziwei-explorer:has(dialog[open]) { grid-template-columns: minmax(0, 1fr); }
#panel-ziwei[data-chart-compact="true"] #ziwei-reading { position: static; max-height: none; max-width: none; }
#panel-ziwei[data-chart-compact="true"] .ziwei-legend { display: none; }
.ziwei-workspace-body:has(dialog[open]) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1250px) {
  .ziwei-workspace-body { grid-template-columns: minmax(0, 1fr); }
  .ziwei-workspace-body #ziwei-reading { position: static; max-height: none; max-width: none; }
}
@media (max-width: 760px) {
  .ziwei-workspace-body { gap: 12px; }
  .ziwei-workspace-body #ziwei-reading { padding: 14px; }
  .ziwei-turns { gap: 20px; }
  .ziwei-turn-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
  .ziwei-turn-references { margin-top: 0; }
  #ziwei-view-switch button { min-width: 0; flex: 1; padding: 10px 8px; }
  #panel-ziwei[data-chart-compact="true"] .ziwei-workspace-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  #panel-ziwei[data-chart-compact="true"] .ziwei-explorer { position: static; width: min(100%, 340px); margin: 0 auto; }
  #ziwei-compact-palaces { grid-template-rows: repeat(4, minmax(68px, auto)); }
  .ziwei-mini-center { gap: 6px; }
}
.ziwei-question-jump { display: none; }
@media (max-width: 760px) {
  #panel-ziwei { padding-bottom: calc(28px + env(safe-area-inset-bottom) + var(--ziwei-keyboard-inset, 0px)); }
  #panel-ziwei input, #panel-ziwei select, #ziwei-question-form textarea { font-size: 16px; }
  #ziwei-question-form { scroll-margin-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #ziwei-question-form textarea { min-height: 96px; max-height: 35dvh; }
  #ziwei-question-form > button { min-height: 44px; min-width: 96px; }
  .ziwei-mini-expand { min-height: 44px; padding: 10px 4px; font-size: 12px; }
  .ziwei-palace-shortcut strong { font-size: 14px; }
  .ziwei-question-jump:not([hidden]) { display: block; position: fixed; z-index: 20; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); min-height: 44px; padding: 10px 18px; border: 1px solid #c9ad80; border-radius: 24px; background: #332c44; color: #f0d5a6; box-shadow: 0 4px 18px #0006; font: inherit; font-size: 14px; cursor: pointer; }
}
.ziwei-stars.major_stars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.major_stars .ziwei-star { --star-color: #e7c58c; --star-tint: #957a4428; --star-border: #b99c6766; border-color: var(--star-border); border-top: 2px solid var(--star-color); color: var(--star-color); background: linear-gradient(145deg, var(--star-tint), #232338); align-content: start; max-width: 100%; }
.major_stars .ziwei-star[data-element="wood"], .major_stars .ziwei-star[data-element="wood-water"] { --star-color: #a6dcc0; --star-tint: #417a6530; --star-border: #71b49766; }
.major_stars .ziwei-star[data-element="fire"] { --star-color: #f0af96; --star-tint: #aa5b422c; --star-border: #cc8b6a66; }
.major_stars .ziwei-star[data-element="water"], .major_stars .ziwei-star[data-element="water-metal"] { --star-color: #a7cdeb; --star-tint: #416c9930; --star-border: #729fc966; }
.major_stars .ziwei-star[data-element="metal"], .major_stars .ziwei-star[data-element="metal-fire"] { --star-color: #e0d9ec; --star-tint: #9189982b; --star-border: #b6aec666; }
.major_stars .ziwei-star[data-element="wood-water"] { background: linear-gradient(130deg, #2a49433d, #273c573d); }
.major_stars .ziwei-star[data-element="metal-fire"] { background: linear-gradient(130deg, #78718024, #89473330); }
.ziwei-star-attributes { display: flex; flex-basis: 100%; flex-wrap: wrap; gap: 5px; margin-top: 5px; padding-top: 4px; border-top: 1px solid #a69ac220; font-weight: 400; line-height: 1.5; }
.ziwei-element-tag { font-size: 10px; color: var(--star-color); }
.ziwei-nature-tag { font-size: 10px; border-radius: 3px; padding: 0 4px; color: #d7cae9; background: #9280b325; }
[data-nature="吉性"] .ziwei-nature-tag { color: #a8dfc2; background: #51785c30; }
[data-nature="凶性"] .ziwei-nature-tag { color: #e8adb8; background: #9a536630; }
.ziwei-trait-sources { margin: 18px 0; padding: 12px; background: #b094cd0b; border: 1px solid #68567755; border-radius: 8px; }
.ziwei-trait-sources summary { cursor: pointer; font-size: 12px; color: #c5afd8; }
#ziwei-palace-detail .ziwei-trait-sources p { font-size: 12px; line-height: 1.8; }
.ziwei-trait-sources a { font-size: 12px; color: #a9cfe9; text-decoration: underline; }
@media (max-width: 760px) {
  #ziwei-palaces .ziwei-stars.major_stars { grid-template-columns: minmax(0, 1fr); }
}

/* HDSI-style conversation surface: one continuous thread, short bubbles,
   and an explicit mode switch that keeps the chart tools in the background. */
.ziwei-chat-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.ziwei-chat-heading .eyebrow { margin: 0 0 5px; }
.ziwei-chat-heading h2 { margin: 0; }
.ziwei-mode-switch { display: inline-flex; flex: 0 0 auto; gap: 3px; padding: 3px; border: 1px solid #635173; border-radius: 9px; background: #151724; }
.ziwei-mode-switch button { min-height: 34px; padding: 7px 12px; border: 0; border-radius: 6px; color: #aaa1b8; background: transparent; font: inherit; font-size: 12px; cursor: pointer; }
.ziwei-mode-switch button[aria-pressed="true"] { color: #f3dfb4; background: #493657; box-shadow: 0 1px 6px #0003; }
.ziwei-prompts-chat[hidden] { display: none !important; }
.ziwei-turns { gap: 18px; margin-top: 22px; }
.ziwei-turn { padding: 0; border: 0; }
.ziwei-message-row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.ziwei-message-row-user { justify-content: flex-end; }
.ziwei-message-row-user .ziwei-message-avatar { order: 2; color: #f5e4bc; background: #6b4b37; }
.ziwei-message-row-assistant { justify-content: flex-start; }
.ziwei-message-avatar { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; color: #ead9bb; background: #3b304c; font-size: 10px; line-height: 1; }
.ziwei-last-question { max-width: min(76%, 620px); margin: 0; padding: 10px 14px; border: 1px solid #72526b; border-radius: 16px 5px 16px 16px; background: #59405e; color: #f5eaf7; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.ziwei-message-row-assistant .ziwei-answer { max-width: min(82%, 700px); margin: 0; padding: 12px 16px; border: 1px solid #413b55; border-radius: 5px 16px 16px 16px; background: #242337; color: #e2d9ea; box-shadow: 0 4px 14px #00018; }
.ziwei-message-row-assistant .ziwei-answer-pending { color: #aaa3bf; }
.ziwei-message-row-assistant .ziwei-answer p { color: #e2d9ea; }
.ziwei-message-row-assistant .ziwei-answer strong { color: #f0d4a3; }
.ziwei-process { margin: 8px 42px 4px; border-color: #4b405b; }
.ziwei-turn-footer { padding-left: 42px; }
#ziwei-question-form { gap: 7px; position: sticky; bottom: 10px; z-index: 4; padding: 10px 12px 9px; border-color: #5d4c6c; border-radius: 13px; background: #181a28eF; box-shadow: 0 8px 28px #0004; backdrop-filter: blur(12px); }
#ziwei-question-form textarea { min-height: 54px; max-height: 180px; padding: 5px 7px; }
.ziwei-composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ziwei-composer-hint { color: #9288a1; font-size: 11px; }
.ziwei-send-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; min-width: 40px !important; height: 40px; min-height: 40px; padding: 0 !important; border-radius: 50% !important; font-size: 23px !important; line-height: 1; }
@media (max-width: 760px) {
  .ziwei-chat-heading { align-items: stretch; flex-direction: column; gap: 10px; }
  .ziwei-mode-switch { width: 100%; }
  .ziwei-mode-switch button { flex: 1; }
  .ziwei-message-avatar { width: 27px; height: 27px; border-radius: 8px; }
  .ziwei-last-question, .ziwei-message-row-assistant .ziwei-answer { max-width: calc(100% - 35px); }
  .ziwei-process { margin: 7px 0 3px; }
  .ziwei-turn-footer { padding-left: 35px; }
  #ziwei-question-form { bottom: calc(6px + env(safe-area-inset-bottom)); padding-bottom: max(9px, env(safe-area-inset-bottom)); }
  .ziwei-composer-hint { font-size: 10px; }
}
