html[data-q-app="ming"][data-theme] {
  --base: var(--df-bg);
  --paper: var(--df-surface);
  --ink: var(--df-text);
  --muted: var(--df-muted);
  --teal: var(--df-primary);
  --accent: var(--df-primary);
  --dark: var(--df-text);
  --jade: var(--df-secondary);
  --line: var(--df-border);
  --border: var(--df-border);
  --element-wood: #226644;
  --element-fire: #ae3529;
  --element-earth: #79553b;
  --element-metal: #8c6203;
  --element-water: #275f91;
  --study-danger: light-dark(#a0352b, #ffad9e);
  color: var(--df-text);
}
html[data-q-app="ming"][data-theme="dark"] {
  --element-wood: #98c9a2;
  --element-fire: #ff9d87;
  --element-earth: #d5ae8e;
  --element-metal: #f5c353;
  --element-water: #96c5f0;
  --major: #ffa28b;
  --lucky: #8bc5e6;
  --sha: #e6a6ea;
  --minor: #acbdcf;
}
html[data-q-app="ming"][data-theme] .compact-workspace-toolbar>.ming-theme-toggle {
  grid-column: 1; grid-row: 1; justify-self: start; font-size: 0; padding: 0;
}
html[data-q-app="ming"][data-theme] {
  & body, & .app-shell { background: var(--df-bg); color: var(--df-text); }
  & :is(.sidebar,.paper,.workspace-header,.identity-panel,.reference-chart-panel,.classic-reading,.modal,.modal>header,.local-select-panel,.luck-selection-panel,.ziwei-wrap,.chart-actions-rail,.chart-side-rails .chart-toolbar) {
    background: var(--df-surface); color: var(--df-text); border-color: var(--df-border);
  }
  & :is(.sidebar .brand h1,.workspace h2,.workspace h3,.modal h2,.welcome-symbol,.ziwei-rail-name,.key-finding,.relations b) { color: var(--df-primary); }
  & :is(.workspace h4,.toolbar b,.classic-text,.energy-legend-name,.compact-basic-facts dd,.compact-pattern dd,.overview-pattern dd,.chart-explanation) { color: var(--df-text); }
  & :is(label,small,.muted,.empty,.fineprint,.birth-form .birth-grid>label,.birth-form .four-input>label,.local-select,.select-chevron,.sidebar footer span,.sidebar .brand span,.basic-fields dt,.compact-pattern dt,.overview-pattern dt,.luck-selection-panel>p,.bone-total,.energy-legend small,.seasonal-elements p,.trend-period-meta,.reference-chart-panel>.section-bar small) { color: var(--df-muted); }
  & .birth-drawer-anchor>.birth-editor { background: var(--df-surface); border: 1px solid var(--df-border); border-top: 2px solid var(--df-gold); }
  & :is(input,textarea,select,.local-select-trigger,.birth-form .birth-grid>label>input,.birth-form .four-input>label>input), & select:not(.ziwei-host select) {
    color: var(--df-text); background-color: var(--df-surface); border-color: var(--df-input-line); accent-color: var(--df-primary);
  }
  & select:not(.ziwei-host select) { appearance: auto; background-image: none; padding-right: 6px; }
  & :is(.mode-switch,.segments,.basic-fields dt,.subject-strip,.busy-strip,.template-results article,.trend-advice,.ai-preview,.notice,.bone-components>div,.natal-attention) { background: var(--df-sand); color: var(--df-text); border-color: var(--df-border); }
  & button:not(.board-grid *,[data-danfeng-toggle],.sidebar-shade,.pillar-value,.energy-legend button) {
    color: var(--df-secondary); background-color: var(--df-surface); border-color: var(--df-border);
  }
  & :is(.file-button,button.primary,.segments button.active,.native-four-pillars .segments button[aria-pressed=true],.chart-toolbar .mode-tabs button.active) {
    color: var(--df-on-primary)!important; background-color: var(--df-primary)!important; border-color: var(--df-primary)!important;
  }
  & :is(button[aria-selected=true],button[aria-pressed=true],button.active,.sidebar nav button.active):not(.board-grid *,[data-danfeng-toggle],.sidebar-shade,.pillar-value) {
    background-color: var(--df-tint); color: var(--df-hover);
  }
  & :is(.compact-workspace-toolbar>.edit-birth,.compact-workspace-toolbar>.edit-birth[aria-expanded=true]) { color: var(--df-hover); background: var(--df-tint); border: 1px solid var(--df-primary); }
  & .modal, & .paper { border-top: 2px solid var(--df-gold); }
  & :is(.modal>header,.paper>h2,.birth-form footer,.classic-tabs,.pillar-scroll,.luck-summary,.bone-components,.basic-fields dl>div) { border-color: var(--df-border); }
  & .reference-pillar-table, & .reference-pillar-table .pillar-value { color: var(--df-text); }
  & :is(.reference-pillar-table th,.reference-pillar-table td,.data-table td), & .reference-pillar-table thead th { background: var(--df-surface); border-color: var(--df-border); }
  & .reference-pillar-table tbody tr:nth-child(odd)>*, & th { background: var(--df-sand); }
  & th { color: var(--df-muted); }
  & .luck-meta > span:nth-child(2) { color: var(--df-secondary); }
  & .reference-chart-panel .reference-pillar-table th, & .reference-chart-panel .reference-pillar-table thead th { color: var(--df-muted); }
  & .reference-pillar-table button.pillar-value:is(:hover,:focus-visible), & .interactive-table tbody tr.row-hoverable:hover td { background: var(--df-action-hover-tint); }
  & .interactive-table tbody tr.row-hoverable:hover td:first-child { box-shadow: inset 3px 0 var(--df-action-hover-border); }
  & .select-cell:hover { background: var(--df-action-hover-tint)!important; }
  & .reference-pillar-table .natal-divider { border-left-color: var(--df-gold)!important; }
  & :is(.energy-floating-note,.floating-pattern-note,.energy-tooltip) { background: var(--df-surface); color: var(--df-text); border-color: var(--df-border); }
  & .energy-legend button:is(:hover,:focus-visible) { background: var(--df-action-hover-tint)!important; }
  & .energy-legend-name, & .energy-legend button strong { color: var(--df-text); }
  & .day-master-link { color: var(--df-primary)!important; }
  & .pattern-five-elements circle { fill: var(--df-surface); }
  & .pattern-five-elements>circle { fill: var(--df-sage); stroke: var(--df-secondary); }
  & .pattern-five-elements :is(text[fill="#385d65"],text[fill="#365e67"],text[fill="#506e75"]) { fill: var(--df-muted); }
  & .trend-topics-table td { color: var(--df-secondary); }
  & .trend-axis text, & .trend text { fill: var(--df-muted); }
  & .trend .trend-value { fill: var(--df-text); }
  & .trend line { stroke: var(--df-input-line); }
  & .trend line[stroke-dasharray] { stroke: var(--df-border); }
  & .trend polyline, & .trend .trend-point-ring { stroke: var(--df-secondary); }
  & .chart-toolbar-legend>span { color: var(--df-muted); }
  & select:not(.ziwei-host select):enabled:is(:hover,:focus-visible) { border-color: var(--df-action-hover-border); }
  & button:enabled:is(:hover,:focus-visible):not(.board-grid *,[data-danfeng-toggle],.sidebar-shade,.pillar-value,.energy-legend button,.danger,.clear-candidates-btn) {
    color: var(--df-action-hover-ink); background-color: var(--df-action-hover-tint); border-color: var(--df-action-hover-border); filter: none;
  }
  & .day-master-link:enabled:is(:hover,:focus-visible) { color: var(--df-action-hover-ink)!important; }
  & :is(button.danger,button.clear-candidates-btn) { color: var(--study-danger); }
  & :is(button.danger,button.clear-candidates-btn):enabled:is(:hover,:focus-visible) {
    color: var(--study-danger); border-color: var(--study-danger); background-color: color-mix(in srgb, var(--study-danger) 12%, var(--df-surface));
  }
  & .file-button:hover,
  & :is(button.primary,.segments button.active,.native-four-pillars .segments button[aria-pressed=true],.chart-toolbar .mode-tabs button.active):enabled:is(:hover,:focus-visible) {
    color: var(--df-action-hover-text)!important; background-color: var(--df-action-hover-bg)!important; border-color: var(--df-action-hover-bg)!important;
  }
}
html[data-q-app="ming"][data-theme] .board-grid {
  background: var(--df-surface);
  & .palace, & .chart-center { background: var(--df-surface); border-color: var(--df-input-line); }
  & .palace.related { background: var(--df-sage); }
  & .palace.current-decade, & .palace.hua-target { background: var(--df-sand); }
  & .palace.selected { background: var(--df-tint); box-shadow: inset 0 0 0 2px var(--df-primary); }
  & :is(.chart-center,.stem-branch,.decade-age,.center-pillars b,.center-detail b) { color: var(--df-text); }
  & :is(.palace-title,.sanhe-group span) { color: var(--df-primary); }
  & :is(.sanhe-group b,.flow-summary,.flow-summary>span,.palace-cycles>span:first-child,.flow-role,.transform-row strong) { color: var(--df-secondary); }
  & :is(.star .brightness,.palace-ages,.palace-cycles,.palace-changsheng,.center-heading>span,.center-birth>span,.center-effective,.center-pillars>span,.center-detail span,.selected-ages b,.selected-ages [data-full-age-kind],.age-note,.age-note>span,.sihua-columns h3,.flying-caption) { color: var(--df-muted); }
}
html[data-q-app="ming"][data-theme] .ming-entry {
  display: block;
  & .workspace {
    width: min(1120px, 100%); max-width: none; margin: 0 auto;
    padding: clamp(16px, 2vh, 24px) clamp(16px, 3vw, 32px);
  }
  & .ming-entry-header { position: relative; margin-bottom: 16px; }
  & .ming-entry-brand { display: flex; align-items: center; justify-content: center; gap: 16px; }
  & .ming-entry-brand h1 { margin: 0; color: var(--df-text); font-size: 30px; line-height: 1.3; font-weight: 600; }
  & .ming-entry-brand p { margin: 4px 0 0; color: var(--df-muted); font-size: 15px; }
  & .ming-entry-header > .ming-theme-toggle { position: absolute; right: 0; top: 6px; }
  & .ming-entry-intro { margin: 12px 0; text-align: center; color: var(--df-muted); font-size: 16px; }
  & .ming-entry-actions { display: flex; justify-content: center; gap: 12px; }
  & .ming-entry-actions button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 24px; border-radius: 8px; font-size: 16px;
  }
  & .ming-entry-actions button[aria-pressed=true] { border-color: var(--df-primary); }
  & .ming-entry-actions span { min-width: 20px; padding: 0 5px; border-radius: 4px; font-size: 12px; background: var(--df-sand); color: var(--df-muted); }
  & .birth-drawer-anchor > .birth-editor {
    position: static; margin-top: 0; padding: 20px; box-shadow: none; animation: none;
    border: 1px solid var(--df-border); border-top: 2px solid var(--df-gold); border-radius: 14px;
  }
  & .page-area:empty { display: none; }
  & .birth-form .birth-grid { row-gap: 14px; margin-bottom: 14px; }
  & .birth-form .birth-date { margin-bottom: 14px; }
  & .birth-form footer { margin-top: 16px; }
}
html[data-q-app="ming"][data-theme] .library-open {
  border: 0; background: transparent; color: var(--df-text); text-align: left;
  font: inherit; font-weight: 600; padding: 4px 6px; margin: -4px -6px; border-radius: 4px;
}
@media (max-width: 600px) {
  html[data-q-app="ming"][data-theme] .ming-entry {
    & .ming-entry-brand { justify-content: flex-start; padding-right: 44px; gap: 12px; }
    & .ming-entry-brand h1 { font-size: 26px; }
    & .ming-entry-brand img { width: 44px; height: 44px; }
    & .ming-entry-intro { text-align: left; font-size: 15px; }
    & .ming-entry-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    & .ming-entry-actions button { padding-inline: 8px; font-size: 15px; }
    & .birth-drawer-anchor > .birth-editor { padding: 16px; }
    & .birth-form footer { margin-top: 18px; }
    & .birth-form footer > .segments { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    & .birth-form footer > .primary { width: 100%; }
  }
}
