/* Three portal palettes. Color-only overrides; existing layout and font rules remain authoritative. */
html[data-theme="steady"] {
  --theme-page: #f5f2eb;
  --theme-surface: #fffdf8;
  --theme-soft: #edf0e7;
  --theme-soft-hover: #e6ebdf;
  --theme-plain: #f8f7ef;
  --theme-alt: #f8f7f0;
  --theme-nav: #233c35;
  --theme-text: #2d3d34;
  --theme-heading: #233c35;
  --theme-muted: #59675d;
  --theme-link: #233c35;
  --theme-link-hover: #765935;
  --theme-accent: #92734e;
  --theme-accent-strong: #765935;
  --theme-primary: #233c35;
  --theme-primary-hover: #335044;
  --theme-on-primary: #faf7ef;
  --theme-on-primary-hover: #faf7ef;
  --theme-on-dark: #f8f5ec;
  --theme-on-dark-muted: #e4e8de;
  --theme-hero-button: #f8f4e9;
  --theme-hero-button-hover: #e8ddc8;
  --theme-on-hero-button: #233c35;
  --theme-control-border: #7d896f;
  --theme-border: #d8d5c8;
  --theme-toolbar: #eeece2;
  --theme-selection: #dfddc8;
  --theme-user: #eaf0e5;
  --theme-error-bg: #fcf1eb;
  --theme-error-text: #843c2c;
  --theme-error-border: #a97562;
  --theme-focus: #765935;
  --theme-focus-dark: #e9d5ad;
  --theme-shadow: #233c3524;
}
html[data-theme="future"] {
  --theme-page: #ecf4f8;
  --theme-surface: #fcfeff;
  --theme-soft: #e7f1f5;
  --theme-soft-hover: #d8e9ef;
  --theme-plain: #f0f7fa;
  --theme-alt: #f3f8fc;
  --theme-nav: #0d2c40;
  --theme-text: #223b4a;
  --theme-heading: #103952;
  --theme-muted: #4e6573;
  --theme-link: #075e79;
  --theme-link-hover: #08445e;
  --theme-accent: #2a9fb0;
  --theme-accent-strong: #0b718c;
  --theme-primary: #0b6d88;
  --theme-primary-hover: #07546b;
  --theme-on-primary: #ffffff;
  --theme-on-primary-hover: #ffffff;
  --theme-on-dark: #f2fbff;
  --theme-on-dark-muted: #cfebf3;
  --theme-hero-button: #ddf3f8;
  --theme-hero-button-hover: #c2e7ee;
  --theme-on-hero-button: #0d2c40;
  --theme-control-border: #6b8694;
  --theme-border: #cddee7;
  --theme-toolbar: #dfebf1;
  --theme-selection: #bfdde8;
  --theme-user: #e0f2f5;
  --theme-error-bg: #fff1ed;
  --theme-error-text: #843c2c;
  --theme-error-border: #a97562;
  --theme-focus: #0b718c;
  --theme-focus-dark: #65dbe7;
  --theme-shadow: #0d2c4024;
}
html[data-theme="adcote"] {
  --theme-page: #f1f2f2;
  --theme-surface: #ffffff;
  --theme-soft: #f1f2f2;
  --theme-soft-hover: #e3edf5;
  --theme-plain: #f7fafc;
  --theme-alt: #f7fafd;
  --theme-nav: #192c4b;
  --theme-text: #192c4b;
  --theme-heading: #192c4b;
  --theme-muted: #52667e;
  --theme-link: #192c4b;
  --theme-link-hover: #476a88;
  --theme-accent: #799dbc;
  --theme-accent-strong: #476a88;
  --theme-primary: #799dbc;
  --theme-primary-hover: #192c4b;
  --theme-on-primary: #192c4b;
  --theme-on-primary-hover: #ffffff;
  --theme-on-dark: #ffffff;
  --theme-on-dark-muted: #e3ecf4;
  --theme-hero-button: #ffffff;
  --theme-hero-button-hover: #d4e4f1;
  --theme-on-hero-button: #192c4b;
  --theme-control-border: #6d8298;
  --theme-border: #cddae6;
  --theme-toolbar: #f1f2f2;
  --theme-selection: #d4e4f1;
  --theme-user: #e9f1f7;
  --theme-error-bg: #fff1ed;
  --theme-error-text: #843c2c;
  --theme-error-border: #a97562;
  --theme-focus: #476a88;
  --theme-focus-dark: #b8d5ec;
  --theme-shadow: #192c4b24;
}

html[data-theme] {
  --paper: var(--theme-page); --sheet: var(--theme-surface); --ink: var(--theme-heading);
  --text: var(--theme-text); --muted: var(--theme-muted); --bronze: var(--theme-accent);
  --bronze-deep: var(--theme-accent-strong); --line: var(--theme-border); --sage: var(--theme-soft);
  color: var(--theme-text); background-color: var(--theme-page);
}
html[data-theme] body { color: var(--theme-text); background-color: var(--theme-page); background-image: none; }
html[data-theme] main { background-color: var(--theme-surface); border-color: var(--theme-border); box-shadow: 0 8px 30px var(--theme-shadow); }
html[data-theme] a { color: var(--theme-link); }
html[data-theme] a:hover { color: var(--theme-link-hover); }
html[data-theme] :focus-visible { outline-color: var(--theme-focus); }
html[data-theme] ::selection { color: var(--theme-heading); background: var(--theme-selection); }
html[data-theme] h1, html[data-theme] h2, html[data-theme] h3, html[data-theme] h4, html[data-theme] strong, html[data-theme] label, html[data-theme] dt { color: var(--theme-heading); }
html[data-theme] h2 { border-color: var(--theme-border); }
html[data-theme] .page-context, html[data-theme] .dim-code, html[data-theme] .score small,
html[data-theme] .library-count, html[data-theme] .document-list small,
html[data-theme] .muted, html[data-theme] footer { color: var(--theme-muted); }
html[data-theme] header { color: var(--theme-on-dark); background: var(--theme-nav); border-color: var(--theme-accent); }
html[data-theme] header a, html[data-theme] .hero a { color: var(--theme-on-dark); }
html[data-theme] header a:hover { color: var(--theme-focus-dark); }
html[data-theme] header :focus-visible, html[data-theme] .hero :focus-visible { outline-color: var(--theme-focus-dark); }
html[data-theme] .hero { color: var(--theme-on-dark); background-color: var(--theme-nav); background-image: none; border-color: var(--theme-accent); }
html[data-theme] .hero h1 { color: var(--theme-on-dark); }
html[data-theme] .hero p { color: var(--theme-on-dark-muted); }
html[data-theme] .button { color: var(--theme-on-hero-button) !important; background: var(--theme-hero-button); border-color: var(--theme-hero-button); }
html[data-theme] .button:hover { background: var(--theme-hero-button-hover); border-color: var(--theme-hero-button-hover); }
html[data-theme] .subtle-button { color: var(--theme-on-dark) !important; background: transparent; border-color: var(--theme-focus-dark); }
html[data-theme] .subtle-button:hover { color: var(--theme-on-dark) !important; background: #ffffff14; border-color: var(--theme-focus-dark); }
html[data-theme] .dimension-card { background: var(--theme-surface); border-color: var(--theme-border); border-top-color: var(--theme-accent); }
html[data-theme] .dimension-card summary { background: var(--theme-soft); }
html[data-theme] .dimension-card summary:hover { background: var(--theme-soft-hover); }
html[data-theme] .dim-title, html[data-theme] .score { color: var(--theme-heading); }
html[data-theme] .indicator-list li { border-color: var(--theme-border); }
html[data-theme] .note { color: var(--theme-text); background: var(--theme-soft); border-color: var(--theme-accent); }
html[data-theme] .topic-links a, html[data-theme] .pager a { color: var(--theme-link); background: var(--theme-plain); border-color: var(--theme-control-border); }
html[data-theme] .topic-links a:hover, html[data-theme] .pager a:hover { background: var(--theme-soft-hover); border-color: var(--theme-focus); }
html[data-theme] .document-list li { background: var(--theme-surface); border-color: var(--theme-border); }
html[data-theme] .document-list li:hover { background: var(--theme-plain); border-color: var(--theme-control-border); }
html[data-theme] input, html[data-theme] select, html[data-theme] textarea,
html[data-theme] .library-controls input, html[data-theme] .library-controls select {
  color: var(--theme-text); background-color: var(--theme-surface); border-color: var(--theme-control-border);
}
html[data-theme] input::placeholder, html[data-theme] textarea::placeholder,
html[data-theme] .library-controls input::placeholder { color: var(--theme-muted); opacity: 1; }
html[data-theme] button { color: var(--theme-on-primary); background: var(--theme-primary); border-color: var(--theme-primary); }
html[data-theme] button:hover { color: var(--theme-on-primary-hover); background: var(--theme-primary-hover); border-color: var(--theme-primary-hover); }
html[data-theme] .login { border-top-color: var(--theme-accent); }
html[data-theme] .error { color: var(--theme-error-text); background: var(--theme-error-bg); border-color: var(--theme-error-border); }
html[data-theme] .results li, html[data-theme] .footer { border-color: var(--theme-border); }
html[data-theme] .table-scroll, html[data-theme] td, html[data-theme] th { border-color: var(--theme-border); }
html[data-theme] table, html[data-theme] td { color: var(--theme-text); }
html[data-theme] th { color: var(--theme-heading); background: var(--theme-soft-hover); }
html[data-theme] tbody tr:nth-child(even) { background: var(--theme-alt); }
html[data-theme] .evidence-link { color: var(--theme-muted); }
html[data-theme] blockquote { color: var(--theme-text); background: var(--theme-soft); border-color: var(--theme-accent); }
html[data-theme] pre { color: var(--theme-text); background: var(--theme-plain); border-color: var(--theme-border); }
html[data-theme] .dudao-toolbar { color: var(--theme-text); background: var(--theme-toolbar); border-color: var(--theme-border); }
html[data-theme] .dudao-toolbar a { color: var(--theme-link); }
html[data-theme] .dudao-toolbar a:hover { color: var(--theme-link-hover); }
html[data-theme] .dudao-toolbar .dudao-publish { color: var(--theme-muted); }
html[data-theme] .dudao-toolbar :focus-visible { outline-color: var(--theme-focus); }
html[data-theme] .dudao-toolbar button { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-control-border); }
html[data-theme] .dudao-toolbar button:hover { color: var(--theme-text); background: var(--theme-soft-hover); border-color: var(--theme-focus); }
html[data-theme] .dudao-theme-picker {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; margin: 0;
  color: var(--theme-text); font: 13px/1.7 "Microsoft YaHei", "微软雅黑", sans-serif;
}
html[data-theme] .dudao-theme-picker select, html[data-theme] select.dudao-theme-picker {
  color: var(--theme-text); background: var(--theme-surface); border: 1px solid var(--theme-control-border);
  border-radius: 3px; min-height: 36px; min-width: 108px; max-width: 170px; padding: 6px 9px; font: inherit;
}
html[data-theme] .dudao-theme-picker :focus-visible, html[data-theme] select.dudao-theme-picker:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 3px; }

/* The assistant has its own local palette; map it into the page's selected roles. */
html[data-theme] .dudao-assistant {
  --da-paper: var(--theme-page); --da-sheet: var(--theme-surface); --da-ink: var(--theme-heading);
  --da-muted: var(--theme-muted); --da-line: var(--theme-border); --da-bronze: var(--theme-accent); color: var(--theme-text);
}
html[data-theme] .dudao-assistant :focus-visible { outline-color: var(--theme-focus); }
html[data-theme] .da-launcher, html[data-theme] .da-heading { color: var(--theme-on-dark); background: var(--theme-nav); border-color: var(--theme-accent); }
html[data-theme] .da-launcher:hover { color: var(--theme-on-dark); background: var(--theme-nav); border-color: var(--theme-focus-dark); }
html[data-theme] .da-launcher { box-shadow: 0 5px 18px var(--theme-shadow); }
html[data-theme] .da-launcher:focus-visible { outline-color: var(--theme-focus); }
html[data-theme] .da-panel { background: var(--theme-surface); border-color: var(--theme-control-border); border-top-color: var(--theme-accent); box-shadow: 0 10px 34px var(--theme-shadow); }
html[data-theme] .da-heading h2 { color: var(--theme-on-dark); }
html[data-theme] .da-heading p { color: var(--theme-on-dark-muted); }
html[data-theme] .da-close { color: var(--theme-on-dark); background: transparent; border-color: var(--theme-focus-dark); }
html[data-theme] .da-close:hover { color: var(--theme-on-dark); background: #ffffff14; border-color: var(--theme-focus-dark); }
html[data-theme] .da-close:focus-visible { outline-color: var(--theme-focus-dark); }
html[data-theme] .da-scope { color: var(--theme-text); background: var(--theme-soft); border-color: var(--theme-border); }
html[data-theme] .da-message { color: var(--theme-text); background: var(--theme-plain); border-color: var(--theme-border); }
html[data-theme] .da-message-user { background: var(--theme-user); border-color: var(--theme-control-border); }
html[data-theme] .da-message-text { color: var(--theme-text); }
html[data-theme] .da-speaker, html[data-theme] .da-sources-label, html[data-theme] .da-sources li,
html[data-theme] .da-grounding, html[data-theme] .da-status, html[data-theme] .da-input-help { color: var(--theme-muted); }
html[data-theme] .da-sources { border-color: var(--theme-border); }
html[data-theme] .da-sources a { color: var(--theme-link); }
html[data-theme] .da-sources a:hover { color: var(--theme-link-hover); }
html[data-theme] .da-speak, html[data-theme] .da-record { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-control-border); }
html[data-theme] .da-speak:hover, html[data-theme] .da-record:hover { color: var(--theme-text); background: var(--theme-soft-hover); border-color: var(--theme-focus); }
html[data-theme] .da-compose { background: var(--theme-page); border-color: var(--theme-border); }
html[data-theme] .da-input-label { color: var(--theme-heading); }
html[data-theme] .da-compose textarea { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-control-border); }
html[data-theme] .da-compose textarea::placeholder { color: var(--theme-muted); }
html[data-theme] .da-send { color: var(--theme-on-primary); background: var(--theme-primary); border-color: var(--theme-primary); }
html[data-theme] .da-send:hover { color: var(--theme-on-primary-hover); background: var(--theme-primary-hover); border-color: var(--theme-primary-hover); }
html[data-theme] .da-record[aria-pressed="true"] { color: var(--theme-error-text); background: var(--theme-error-bg); border-color: var(--theme-error-border); }
html[data-theme] .da-status[data-kind="error"], html[data-theme] .da-status[data-kind="recording"] { color: var(--theme-error-text); }

/* Future: a quiet technical grid, confined to decorative backgrounds. */
html[data-theme="future"] body {
  background-image: linear-gradient(#2a789c0a 1px, transparent 1px), linear-gradient(90deg, #2a789c0a 1px, transparent 1px);
  background-size: 36px 36px;
}
html[data-theme="future"] .hero {
  background-image: linear-gradient(#62cbdc14 1px, transparent 1px), linear-gradient(90deg, #62cbdc14 1px, transparent 1px);
  background-size: 32px 32px;
}
html[data-theme="future"] .score { color: var(--theme-accent-strong); }
html[data-theme="future"] .dim-code { color: var(--theme-link); }

@media (max-width: 700px) {
  html[data-theme] .dudao-theme-picker { flex-wrap: wrap; max-width: 100%; }
  html[data-theme] .dudao-theme-picker select, html[data-theme] select.dudao-theme-picker { max-width: min(170px, 100%); min-height: 42px; }
}
@media print {
  html[data-theme], html[data-theme] body { color: #000 !important; background: #fff !important; }
  html[data-theme] *, html[data-theme] *::before, html[data-theme] *::after {
    color: #000 !important; background: transparent !important; border-color: #666 !important; box-shadow: none !important; text-shadow: none !important;
  }
  html[data-theme] .button, html[data-theme] .subtle-button { color: #000 !important; background: transparent !important; }
  html[data-theme] .dudao-assistant, html[data-theme] .dudao-theme-picker { display: none !important; }
  html[data-theme] img, html[data-theme] svg { filter: grayscale(1); }
}

