:root,
:root[data-theme="day"] {
  color-scheme: light;
  --theme-page: #f6f4fa;
  --theme-page-accent: rgba(124, 92, 255, .12);
  --theme-surface: #ffffff;
  --theme-surface-raised: #ffffff;
  --theme-surface-soft: #faf8ff;
  --theme-surface-muted: #f1edf9;
  --theme-surface-disabled: #efeff1;
  --theme-text: #2f2938;
  --theme-heading: #2d2340;
  --theme-text-soft: #625d6e;
  --theme-text-faint: #777083;
  --theme-border: #e2ddf2;
  --theme-border-strong: #cfc9df;
  --theme-primary: #6644cc;
  --theme-primary-hover: #5637bd;
  --theme-primary-text: #ffffff;
  --theme-link: #5632bd;
  --theme-primary-soft: #eee8fb;
  --theme-primary-soft-hover: #e4dcf8;
  --theme-header-start: #5632bd;
  --theme-header-mid: #7049d6;
  --theme-header-end: #805ce0;
  --theme-header-text: #ffffff;
  --theme-header-control: rgba(255, 255, 255, .08);
  --theme-header-control-hover: rgba(255, 255, 255, .17);
  --theme-header-border: rgba(255, 255, 255, .25);
  --theme-overlay: rgba(20, 16, 36, .55);
  --theme-shadow: rgba(49, 32, 87, .08);
  --theme-shadow-strong: rgba(40, 24, 80, .18);
  --theme-focus: rgba(96, 69, 199, .42);
  --theme-danger: #b42318;
  --theme-danger-soft: #fff0f0;
  --theme-success: #176b3a;
  --theme-success-soft: #e6f4ea;
  --theme-warning: #704700;
  --theme-warning-border: #e1a72b;
  --theme-warning-soft: #fff8e7;
  --theme-info: #0369a1;
  --theme-info-text: #ffffff;
}

:root[data-theme="eye-care"] {
  color-scheme: light;
  --theme-page: #f1f3e7;
  --theme-page-accent: rgba(89, 122, 83, .11);
  --theme-surface: #fbfcf3;
  --theme-surface-raised: #fffff8;
  --theme-surface-soft: #f4f6ea;
  --theme-surface-muted: #e9eedf;
  --theme-surface-disabled: #e4e7dc;
  --theme-text: #29342c;
  --theme-heading: #1f2d23;
  --theme-text-soft: #536057;
  --theme-text-faint: #6b766e;
  --theme-border: #d3dac8;
  --theme-border-strong: #bac6af;
  --theme-primary: #52745a;
  --theme-primary-hover: #3f6048;
  --theme-primary-text: #ffffff;
  --theme-link: #3f674b;
  --theme-primary-soft: #e1eadb;
  --theme-primary-soft-hover: #d5e2ce;
  --theme-header-start: #42634b;
  --theme-header-mid: #58785b;
  --theme-header-end: #728b69;
  --theme-header-text: #ffffff;
  --theme-header-control: rgba(255, 255, 244, .1);
  --theme-header-control-hover: rgba(255, 255, 244, .2);
  --theme-header-border: rgba(255, 255, 244, .3);
  --theme-overlay: rgba(28, 38, 30, .5);
  --theme-shadow: rgba(53, 73, 56, .09);
  --theme-shadow-strong: rgba(42, 63, 46, .18);
  --theme-focus: rgba(63, 103, 75, .4);
  --theme-danger: #a13c32;
  --theme-danger-soft: #faece7;
  --theme-success: #326846;
  --theme-success-soft: #e2efe2;
  --theme-warning: #725515;
  --theme-warning-border: #c7a45a;
  --theme-warning-soft: #faf3dc;
  --theme-info: #0e7490;
  --theme-info-text: #ffffff;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --theme-page: #16141c;
  --theme-page-accent: rgba(144, 118, 229, .12);
  --theme-surface: #211e2a;
  --theme-surface-raised: #272330;
  --theme-surface-soft: #292532;
  --theme-surface-muted: #302b3b;
  --theme-surface-disabled: #302e35;
  --theme-text: #eeeaf6;
  --theme-heading: #fffaff;
  --theme-text-soft: #c7c0d1;
  --theme-text-faint: #a69ead;
  --theme-border: #3d374b;
  --theme-border-strong: #514960;
  --theme-primary: #9f87f5;
  --theme-primary-hover: #b29df8;
  --theme-primary-text: #17121f;
  --theme-link: #bdaaff;
  --theme-primary-soft: #372e50;
  --theme-primary-soft-hover: #43375f;
  --theme-header-start: #24184a;
  --theme-header-mid: #39266e;
  --theme-header-end: #4b337f;
  --theme-header-text: #fffaff;
  --theme-header-control: rgba(255, 255, 255, .08);
  --theme-header-control-hover: rgba(255, 255, 255, .16);
  --theme-header-border: rgba(255, 255, 255, .23);
  --theme-overlay: rgba(0, 0, 0, .72);
  --theme-shadow: rgba(0, 0, 0, .28);
  --theme-shadow-strong: rgba(0, 0, 0, .45);
  --theme-focus: rgba(189, 170, 255, .5);
  --theme-danger: #ff9a92;
  --theme-danger-soft: #422626;
  --theme-success: #8dd5a7;
  --theme-success-soft: #22372b;
  --theme-warning: #f0ca75;
  --theme-warning-border: #8d6e30;
  --theme-warning-soft: #3a311f;
  --theme-info: #67c8f0;
  --theme-info-text: #16141c;
}

html[data-theme] {
  min-width: 0;
  background: var(--theme-page);
  color: var(--theme-text);
}

body {
  color: var(--theme-text);
  background-color: var(--theme-page);
  transition: color .18s ease, background-color .18s ease;
}

a { color: var(--theme-link); }

button,
input,
select,
textarea,
dialog { color: var(--theme-text); }

input,
select,
textarea {
  border-color: var(--theme-border-strong);
  background-color: var(--theme-surface-raised);
}

input::placeholder,
textarea::placeholder { color: var(--theme-text-faint); opacity: 1; }

:focus-visible { outline-color: var(--theme-focus); }

.header,
.member-header,
.professional-header,
.report-topbar,
.feedback-management-header {
  color: var(--theme-header-text);
  background: linear-gradient(135deg, var(--theme-header-start) 0%, var(--theme-header-mid) 58%, var(--theme-header-end) 100%);
  box-shadow: 0 4px 18px var(--theme-shadow-strong);
}

.site-theme-toolbar {
  position: relative;
  z-index: 24;
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: flex-end;
  padding: 6px clamp(12px, 3vw, 34px);
  border-bottom: 1px solid var(--theme-border);
  background: color-mix(in srgb, var(--theme-page) 88%, var(--theme-surface));
}

.site-theme-switcher {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  padding: 2px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 10px;
  background: var(--theme-surface-muted);
  box-shadow: 0 3px 12px var(--theme-shadow);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

.site-theme-options { display: inline-flex; align-items: center; }

.site-theme-switcher button {
  display: inline-flex;
  width: 34px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 5px;
  border: 0;
  border-radius: 7px;
  color: var(--theme-text-soft);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.site-theme-switcher button:hover { color: var(--theme-text); background: var(--theme-primary-soft-hover); }
.site-theme-switcher button[aria-pressed="true"] {
  color: var(--theme-primary-text);
  background: var(--theme-primary);
  box-shadow: 0 2px 7px var(--theme-shadow);
}
.site-theme-switcher button:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--theme-focus); outline-offset: 1px; }
.site-theme-icon { font-size: 15px; line-height: 1; text-align: center; }
.site-theme-select { display: none; }
.site-theme-switcher-topbar {
  flex: 0 0 auto;
  border-color: var(--theme-header-border);
  background: var(--theme-header-control);
  box-shadow: none;
}
.site-theme-switcher-topbar button { color: var(--theme-header-text); }
.site-theme-switcher-topbar button:hover { color: var(--theme-header-text); background: var(--theme-header-control-hover); }
.site-theme-switcher-topbar button[aria-pressed="true"] { color: var(--theme-header-start); background: var(--theme-header-text); }
.site-theme-switcher-floating { position: fixed; z-index: 90; top: 12px; right: 12px; }

/* Public content page */
.card,
.category-section,
.topic-card,
.topic-detail,
.detail,
.modal-box,
.portal-search,
.search-suggestions,
.pagination .page-link,
.portal-search button,
.portal-search select,
.page-jump button,
.page-jump input,
.audio-transcript-list,
.feedback-thread {
  color: var(--theme-text);
  border-color: var(--theme-border);
  background: var(--theme-surface);
  box-shadow: 0 8px 24px var(--theme-shadow);
}
.card h2,
.category-section-header h2 a,
.category-section-articles a,
.article-content.is-structured-plain-text,
.audio-transcript-cue,
.article-feedback h2 { color: var(--theme-heading); }
.card .subtitle,
.card .meta,
.view-description,
.topic-card p,
.topic-summary,
.breadcrumbs,
.article-topics,
.detail .subtitle,
.loading,
.portal-message,
.empty-state,
.search-no-results,
.audio-transcript-hint,
.feedback-introduction { color: var(--theme-text-soft); }
.category-tree { color: var(--theme-text); background: var(--theme-surface-raised); border-color: var(--theme-border); }
.header .category-tree a { color: var(--theme-text-soft); }
.header .category-tree a:hover,
.header .category-tree a:focus-visible,
.header .category-tree a.active,
.search-suggestions [role="option"]:hover,
.search-suggestions [role="option"][aria-selected="true"],
.audio-transcript-cue:hover,
.audio-transcript-cue:focus-visible { color: var(--theme-link); background: var(--theme-primary-soft); }
.category-tree .category-tree,
.category-section-articles li,
.article-detail > .admin-actions,
.article-feedback,
.feedback-message,
.professional-references [data-reference-kind] { border-color: var(--theme-border); }
.article-content.sun-editor-editable ul,
.article-content.sun-editor-editable ol {
  list-style-position: outside;
  padding-inline-start: 2em;
}
.category-section-header,
.audio-transcript-player {
  border-color: var(--theme-border);
  background: linear-gradient(135deg, var(--theme-surface-soft), var(--theme-surface-muted));
}
.category-section-more,
.topic-card a,
.breadcrumbs a,
.article-topics a,
.article-neighbor-link,
.detail .back,
.audio-transcript-details summary,
.selected-symptoms-list a,
.feedback-notice a { color: var(--theme-link); }
.tag,
.advanced-search,
.container[data-category-slug="BL"] .article-detail .subtitle,
.feedback-create-form,
.feedback-reply-form,
.feedback-management-reply,
.feedback-visibility-note,
.feedback-notice,
.feedback-empty { color: var(--theme-text-soft); background: var(--theme-surface-muted); border-color: var(--theme-border); }
.portal-search button[type="submit"],
.pagination .page-link.active,
.portal-message button,
.modal-box .btns .save,
.feedback-create-form button,
.feedback-reply-form button,
.feedback-management-reply button,
.feedback-management-message button,
.feedback-visibility-control button,
.feedback-pagination button { color: var(--theme-primary-text); border-color: var(--theme-primary); background: var(--theme-primary); }
.modal { background: var(--theme-overlay); }
.modal-box label { color: var(--theme-text-soft); }
.modal-box .btns .cancel { color: var(--theme-text); background: var(--theme-surface-muted); }
.article-neighbor-tooltip { color: var(--theme-header-text); background: var(--theme-heading); box-shadow: 0 8px 20px var(--theme-shadow-strong); }
.audio-transcript-current { color: var(--theme-header-text); background: var(--theme-header-mid); }

/* Login and common form surfaces */
body > main:not([id="assessmentApp"]):not([id="professionalApp"]):not([id="reportApp"]):not(.feedback-management-main),
.member-card,
.professional-profile,
.professional-invitation,
.professional-member-claim,
.professional-invitees-wrap,
.professional-invitee-form-editor,
.professional-report-card,
.professional-references > article,
.professional-report-editor,
#reportApp > section,
#reportApp > details {
  color: var(--theme-text);
  border-color: var(--theme-border);
  background: var(--theme-surface);
  box-shadow: 0 8px 28px var(--theme-shadow);
}
.intro,
.field-help,
.records-copy-help,
.member-inviter,
.load-status,
.form-status,
#memberFormsStatus,
#memberCompareAvailability,
#memberComparisonNotice,
.health-record-number,
.professional-form-version,
.professional-record-time,
.professional-report-card > div > span,
.selected-symptom-short-description,
.analysis-zero-empty,
.professional-report-actions p { color: var(--theme-text-soft); }
button,
.assessment-tabs button,
.assessment-confirm-selection,
.assessment-confirm-profile,
#assessmentSubmit {
  color: var(--theme-primary-text);
  background-color: var(--theme-primary);
}
button:hover:not(:disabled) { background-color: var(--theme-primary-hover); }
[role="alert"],
.feedback-load-error { color: var(--theme-danger); background: var(--theme-danger-soft); }
[role="status"] { color: var(--theme-success); }
body > main input,
body > main select,
body > main textarea,
.search-input,
.modal-box input,
.modal-box select,
.modal-box textarea,
.member-card input,
.professional-invitation input,
.professional-member-claim input,
.professional-report-editor input:not([type="checkbox"]),
.professional-report-editor textarea {
  color: var(--theme-text);
  border-color: var(--theme-border-strong);
  background: var(--theme-surface-raised);
}

/* Member center */
body:has(.member-header) {
  background: radial-gradient(circle at top left, var(--theme-page-accent), transparent 34rem), var(--theme-page);
}
.member-card,
.member-claim-panel,
#memberForms li,
#memberRecords li,
#memberCompareActions,
.comparison-record,
.symptom-change-card,
.comparison-list li {
  color: var(--theme-text);
  border-color: var(--theme-border);
  background: var(--theme-surface-soft);
}
.member-card { background: var(--theme-surface); }
.profile-field .profile-radio-option { color: var(--theme-text); border-color: var(--theme-border-strong); background: var(--theme-surface-raised); }
.profile-radio-option:hover,
.profile-radio-option:has(input:checked) { color: var(--theme-link); border-color: var(--theme-primary); background: var(--theme-primary-soft); }
input[readonly] { color: var(--theme-text-soft); background: var(--theme-surface-disabled); }
.member-teacher-link-code,
#memberCompareCancel,
#memberCompareBack { color: var(--theme-link); background: var(--theme-primary-soft); }
#memberForms a,
#memberForms button,
#memberRecords a { color: var(--theme-link); }
#memberForms span,
#memberRecords time,
#memberRecords small,
.comparison-record time,
.comparison-record small,
.symptom-change-card p { color: var(--theme-text-soft); }
#memberRecords [data-copy-id].is-copy-quiet,
#memberRecords .member-record-report { color: var(--theme-text-soft); border-color: var(--theme-border-strong); background: var(--theme-surface-raised); }
#memberRecords .member-record-report.is-unread { color: var(--theme-primary-text); border-color: var(--theme-primary); background: var(--theme-primary); }

/* Assessment */
body:has(#assessmentApp) { background: var(--theme-page); }
.assessment-home-link,
.assessment-symptom-title,
.assessment-symptom a,
.assessment-success-actions a,
.assessment-success-claim [data-copy-claim-code] { color: var(--theme-link); }
/* 症状标题是文字按钮：悬停时不能被全局 button:hover 底色盖成同色系底 */
.assessment-symptom-title:hover:not(:disabled) { background-color: transparent; }
.assessment-symptom { border-color: var(--theme-border); }
.assessment-symptom p,
.assessment-profile-note,
.assessment-field-help,
.assessment-success p,
.assessment-success-claim p,
.assessment-success-claim dt { color: var(--theme-text-soft); }
.assessment-profile-field > input,
.assessment-profile-field > select,
.assessment-profile-field .assessment-radio-option,
.assessment-success-claim {
  color: var(--theme-text);
  border-color: var(--theme-border-strong);
  background: var(--theme-surface-raised);
}
:root[data-theme="night"] .assessment-profile-field.is-required > input {
  color: var(--theme-text);
  caret-color: var(--theme-text);
  border-color: var(--theme-warning-border);
  background: var(--theme-surface-raised);
  box-shadow: inset 3px 0 0 var(--theme-warning);
}
:root[data-theme="night"] .assessment-profile-field.is-required > input:-webkit-autofill {
  -webkit-text-fill-color: var(--theme-text);
  caret-color: var(--theme-text);
  border-color: var(--theme-warning-border);
  box-shadow:
    inset 3px 0 0 var(--theme-warning),
    inset 0 0 0 1000px var(--theme-surface-raised);
}
.assessment-radio-option:hover,
.assessment-radio-option:has(input:checked),
.assessment-symptom a,
.assessment-success-claim [data-copy-claim-code] { border-color: var(--theme-primary); background: var(--theme-primary-soft); }
.assessment-success {
  border-color: var(--theme-border);
  background: linear-gradient(145deg, var(--theme-surface), var(--theme-surface-soft));
  box-shadow: 0 18px 50px var(--theme-shadow-strong);
}
.assessment-success h1,
.assessment-success-claim h2,
.assessment-success-claim dd { color: var(--theme-heading); }
.assessment-success-actions a:first-child { color: var(--theme-primary-text); border-color: var(--theme-primary); background: var(--theme-primary); }

/* Professional workspace and health report */
.professional-form-card,
.professional-record-button,
.professional-share-dialog,
.professional-report-editor fieldset,
.feedback-filters,
.feedback-management-list,
.feedback-management-detail,
.feedback-management-row,
.feedback-management-message {
  color: var(--theme-text);
  border-color: var(--theme-border);
  background: var(--theme-surface);
  box-shadow: 0 6px 22px var(--theme-shadow);
}
.professional-form-card { background: linear-gradient(145deg, var(--theme-surface), var(--theme-surface-soft)); }
.professional-form-name,
.professional-record-button,
.professional-detail-form,
#reportApp > h1 { color: var(--theme-heading); }
.professional-form-badge,
nav[aria-label="教师工作区"] button,
nav[aria-label="教师工作区"] .professional-feedback-management,
.professional-detail-form { color: var(--theme-link); background: var(--theme-primary-soft); }
nav[aria-label="教师工作区"] button[aria-selected="true"] { color: var(--theme-primary-text); background: var(--theme-primary); }
.professional-form-actions button,
.professional-report-card button,
.analysis-zero-toggle,
.professional-report-actions button { color: var(--theme-link); border-color: var(--theme-primary); background: var(--theme-surface-raised); }
.professional-form-actions button:first-child,
.professional-report-actions button:nth-child(2) { color: var(--theme-primary-text); background: var(--theme-primary); }
.professional-invitees th { color: var(--theme-text-soft); background: var(--theme-surface-muted); }
.professional-invitees th,
.professional-invitees td { border-color: var(--theme-border); }
.professional-share-dialog::backdrop { background: var(--theme-overlay); }
.analysis-bar { background: var(--theme-primary-soft); }
.analysis-bar-fill { background: var(--theme-primary); }
.nutrient-conflict-notice,
.report-nutrient-conflicts,
#memberComparisonScope { color: var(--theme-warning); border-color: var(--theme-warning-border); background: var(--theme-warning-soft); }
.nutrient-conflict-notice h2,
.nutrient-conflict-notice li p,
.report-nutrient-conflicts h2 { color: var(--theme-warning); }

/* Feedback management */
.feedback-management-body { color: var(--theme-text); background: var(--theme-page); }
.feedback-filters input,
.feedback-filters select,
.feedback-visibility-control select,
.feedback-create-form textarea,
.feedback-reply-form textarea,
.feedback-management-reply textarea,
.feedback-management-message textarea { color: var(--theme-text); border-color: var(--theme-border-strong); background: var(--theme-surface-raised); }
.feedback-management-row:hover,
.feedback-management-row.selected,
.feedback-visibility-control { border-color: var(--theme-primary); background: var(--theme-primary-soft); }
.feedback-management-row span,
.feedback-management-row small,
.feedback-detail-heading p,
.feedback-message header,
.feedback-management-message header,
.feedback-thread > h3 { color: var(--theme-text-soft); }
.feedback-detail-heading h2 a,
.feedback-form-status,
#feedbackManagementStatus { color: var(--theme-link); }
.feedback-message header strong,
.feedback-management-message header strong,
.feedback-message > p,
.feedback-management-message > p { color: var(--theme-text); }
.feedback-status.not_required { color: var(--theme-text-soft); background: var(--theme-surface-muted); }

@media (max-width: 700px) {
  .site-theme-toolbar { min-height: 40px; padding: 5px 10px; }
  .site-theme-switcher {
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .site-theme-options { display: none; }
  .site-theme-select {
    display: block;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 4px;
    border: 0;
    border-radius: 0;
    color: var(--theme-text);
    background: transparent;
    box-shadow: none;
    font: inherit;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
  }
  .site-theme-switcher-topbar { order: 2; }
  .site-theme-switcher-topbar .site-theme-select { color: var(--theme-header-text); background: transparent; }
  .header .session-controls { order: 3; }
  .site-theme-switcher-floating { top: 8px; right: 8px; }
  .header .nav { color: var(--theme-text); background: var(--theme-surface-raised); border-color: var(--theme-border); }
  .header .nav a,
  .header .nav > .channel-navigation > .navigation-row > a { color: var(--theme-text-soft); }
  .header .nav a.active,
  .header .nav > .channel-navigation > .navigation-row > a.active { color: var(--theme-link); background: var(--theme-primary-soft); }
  .category-section-articles li:nth-child(n+5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}
