/* Theme overrides are deliberately loaded after every app stylesheet. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6eee8;
  --ink-soft: #c1cec4;
  --muted: #99a99e;
  --line: #35443b;
  --panel: #1b2520;
  --canvas: #111916;
  --sidebar: #151e19;
  --green: #3c7958;
  --green-deep: #286044;
  --green-mid: #64a47a;
  --lime: #d3ee80;
  --mint: #20382b;
  --peach: #3a2d24;
  --blue: #253449;
  --yellow: #3c3522;
  --shadow: 0 10px 30px rgba(0, 0, 0, .24);
}

html[data-theme="dark"] body { background: var(--canvas); color: var(--ink); }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .mobile-bottom-nav {
  background: rgba(21, 30, 25, .97);
  border-color: var(--line);
}
html[data-theme="dark"] .topbar { background: rgba(21, 30, 25, .92); }
html[data-theme="dark"] .mobile-bottom-nav { background: rgba(21, 30, 25, .98); }
html[data-theme="dark"] .mobile-scrim,
html[data-theme="dark"] .modal-backdrop,
html[data-theme="dark"] [class*="-scrim"] { background-color: rgba(0, 0, 0, .68); }

/* Common app panels, cards and dialogs. Keep the photographic brand hero colorful. */
html[data-theme="dark"] :is(
  .panel-card, .metric-card, .source-tag, .workspace-card, .workspace-summary-strip,
  .summary-stat, .draft-project-card, .draft-table-panel, .folder-card, .project-card,
  .project-folder-card, .project-analysis-panel, .analysis-detail-card,
  .account-card, .account-note-card, .info-card, .donor-board, .donor-list-item,
  .partner-card, .partner-admin-panel, .partner-contact-panel, .partner-demo-card,
  .partner-directory-empty, .template-local-card, .template-how-card, .template-side-panel,
  .saved-template-card, .admin-price-panel, .admin-metric-card, .donation-admin-panel,
  .donor-admin-form, .donor-admin-row, .openmoji-picker-dialog, .openmoji-picker-shell,
  .topic-dialog, .topic-dialog-sheet, .auth-modal, .volume-backup-dialog,
  .add-work-drawer, .detail-drawer, .detail-price-card, .project-analysis-summary,
  .project-division-row, .project-group-row, .project-subdivision-row,
  .component-row, .quick-item, .schedule-entry, .supabase-data-card, .supabase-quota-card,
  .supabase-info-wrap, .catalog-panel, .draft-side, .template-builder, .template-result-more
) {
  background-color: #1b2520;
  border-color: #35443b;
  color: #e4ece6;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .14);
}
html[data-theme="dark"] :is(.hero-card, .hero-float-card) { color: #fff; }
html[data-theme="dark"] .hero-float-card { background-color: rgba(255, 255, 255, .95); }
html[data-theme="dark"] .hero-card { background-color: #173e30; }

/* Recolor neutral insets, headers, table bands and nested form surfaces. */
html[data-theme="dark"] :is(
  .workspace-switcher, .source-card, .search-bar, .admin-search, .admin-price-edit,
  .filter-control select, .page-size select, .project-picker select, .project-name-input,
  .workspace-field input, .workspace-field select, .workspace-field textarea,
  .account-field input, .account-field select, .account-field textarea,
  .auth-field input, .community-form input, .community-form textarea, .community-form select,
  .donor-admin-form input, .donor-admin-form textarea, .donation-url-form input,
  .partner-listing-form input, .partner-listing-form textarea, .partner-inquiry-form input,
  .partner-inquiry-form textarea, .template-search, .template-name-grid input,
  .add-work-search, .dimension-field input, .project-name-input,
  .volume-backup-form input, .volume-backup-form select, .volume-backup-form textarea,
  .openmoji-picker-search, .topic-icon-field input, .project-icon-color input,
  .project-icon-controls input, .folder-empty, .quick-empty, .component-empty,
  .template-empty-list, .partner-directory-empty, .donor-empty, .admin-forum-empty,
  .local-demo-note, .forum-storage-note, .guide-persistence, .guide-banner,
  .admin-local-footer, .supabase-info, .supabase-tooltip, .draft-local-note,
  .project-price-context, .volume-backup-readonly-row
) {
  background-color: #202c25;
  border-color: #3a4a40;
  color: #dce7df;
}
html[data-theme="dark"] :is(.admin-price-table thead th, .catalog-table thead th, .draft-table thead th,
  .analysis-component-table thead th, .recap-table thead th, .table-wrap thead th,
  .admin-kind-tabs, .admin-pagination, .pagination, .filter-row, .results-header,
  .draft-table-head, .draft-table-footer, .side-card-head, .admin-panel-heading,
  .topic-dialog-header, .volume-backup-dialog-head, .openmoji-picker-heading,
  .openmoji-picker-footer, .account-card-heading, .workspace-card-heading) {
  background-color: #202a24;
  border-color: #35443b;
  color: #aebdb2;
}
html[data-theme="dark"] :is(table, th, td, .catalog-row td, .draft-table tbody td,
  .admin-price-table tbody td, .analysis-component-table td, .recap-table td,
  .donor-admin-row, .partner-inquiry-row, .admin-forum-topic-row, .topic-row) {
  border-color: #344139;
}
html[data-theme="dark"] :is(.catalog-row:hover, .admin-price-table tbody tr:hover,
  .admin-forum-topic-row:hover, .partner-inquiry-row:hover) { background-color: #25332b; }

/* Make dark foregrounds from legacy light-only rules readable while preserving status hues. */
html[data-theme="dark"] :is(
  .breadcrumbs strong, .workspace-copy strong, .workspace-copy span, .nav-link,
  .nav-link.active, .nav-count, .nav-link.active .nav-count, .source-card > strong,
  .source-card > span, .source-link, .project-picker, .project-picker label,
  .storage-indicator, .auth-status, .page-intro h1, .page-lede, .catalog-heading h2,
  .catalog-heading p, .metric-card strong, .metric-card small, .metric-label,
  .source-tag b, .source-tag small, .results-header strong, .results-header,
  .results-meta, .page-size, .filter-control span, .filter-control select,
  .reset-filters, .item-name-button, .item-category, .item-price, .pagination,
  .pagination-info, .side-card-head h3, .project-name-label, .draft-list-head,
  .quick-empty strong, .quick-empty span, .quick-item-title, .quick-item-meta,
  .subtotal-row, .side-note, .draft-intro p, .draft-project-card, .draft-project-fields label,
  .draft-table tbody td, .draft-table tbody th, .summary-stat, .grand-total,
  .workspace-heading h1, .workspace-heading p, .workspace-card-heading,
  .workspace-card-title, .workspace-meta-line, .workspace-field label,
  .analysis-detail-heading, .analysis-component-name, .analysis-code,
  .analysis-effective-price, .analysis-source-note, .analysis-subdivision,
  .analysis-kind-row, .analysis-total-row, .component-name, .component-meta,
  .component-amount, .detail-title, .detail-section-head, .detail-warning,
  .account-page-intro, .account-kicker, .account-card, .account-card-heading,
  .account-field label, .account-info-links, .account-note-card, .account-message,
  .profile-openmoji-copy, .avatar-attribution, .forum-page-actions,
  .forum-topic-launch, .community-form, .community-form-status, .forum-storage-note,
  .topic-dialog-header, .topic-icon-choice-copy, .topic-icon-field,
  .partner-card-copy, .partner-category, .partner-listing-summary,
  .partner-inquiry-row, .partner-admin-heading, .partner-admin-row-actions,
  .donor-board-heading, .donor-copy, .donor-rank, .donor-amount,
  .template-analysis-copy, .template-analysis-row, .template-selection-meta,
  .saved-template-heading, .admin-panel-heading h2, .admin-panel-heading p,
  .admin-metric-card strong, .price-component-cell strong, .source-price-cell,
  .admin-result-count, .admin-pagination, .admin-only-edited, .override-state,
  .admin-security-note, .admin-security-note p, .volume-backup-label-field,
  .volume-backup-row, .volume-backup-row-value, .volume-backup-unit-note,
  .volume-backup-readonly-row, .openmoji-picker-heading, .openmoji-picker-count,
  .openmoji-picker-option, .project-price-context, .project-analysis-summary,
  .schedule-entry, .app-footer, .guide-grid, .info-view, .local-status-chip
) { color: #d5e0d8; }
html[data-theme="dark"] :is(.nav-group-label, .metric-label, .metric-card small,
  .workspace-copy span, .page-lede, .catalog-heading p, .source-tag small,
  .results-header, .results-meta, .filter-control span, .item-category,
  .quick-item-meta, .account-info-links, .admin-panel-heading p, .admin-metric-card small,
  .admin-result-count, .override-state, .volume-backup-unit-note, .app-footer,
  .partner-category, .profile-openmoji-copy, .forum-storage-note, .openmoji-picker-count) {
  color: #a7b6ab;
}
html[data-theme="dark"] :is(a, .text-link-button, .source-link, .reset-filters,
  .back-to-folders, .nav-link.active, .item-code, .item-name-button:hover,
  .price-restore-button, .auth-mode-toggle, .account-profile-link) { color: #9bd1a8; }
html[data-theme="dark"] .hero-card :is(h1, h2, h3, p, span, small, strong, em) { color: inherit; }
html[data-theme="dark"] .hero-card h2 em { color: #d4ee9a; }
html[data-theme="dark"] .hero-card .hero-kicker,
html[data-theme="dark"] .hero-card .hero-footnote { color: #c2d1c8; }
html[data-theme="dark"] .hero-float-card { color: #26342c; }

/* Form controls, placeholders and text selection. */
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  color: #e4ece6;
  background-color: #17211b;
  border-color: #435349;
  caret-color: #d3ee80;
}
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #91a196; opacity: 1; }
html[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) { accent-color: #79bd89; }
html[data-theme="dark"] option { color: #e4ece6; background: #17211b; }
html[data-theme="dark"] ::selection { color: #f4fff6; background: #386b4b; }
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] textarea:focus-visible,
html[data-theme="dark"] [tabindex]:focus-visible {
  outline: 3px solid #a4e3ad;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(110, 190, 128, .2);
}
html[data-theme="dark"] :is(.nav-link:hover, .mobile-nav-link:hover) { background-color: #26362d; color: #e5f2e7; }
html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .mobile-nav-link.active { background-color: #274433; color: #b9e7c1; }
html[data-theme="dark"] .workspace-switcher { background-color: #202c25; }
html[data-theme="dark"] .source-card { background-image: linear-gradient(145deg, #203329, #1c2821); }
html[data-theme="dark"] .workspace-icon { background-color: #2c4935; color: #d1ebd0; }
html[data-theme="dark"] .search-bar { background-color: #17211b; }
html[data-theme="dark"] :is(.search-bar input, .admin-search input, .admin-price-edit input) { background-color: transparent; }
html[data-theme="dark"] :is(.catalog-table thead th, .draft-table thead th, .admin-price-table thead th) { color: #aebdb2; }
html[data-theme="dark"] .catalog-shortcut kbd,
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Family-level coverage for feature panels added by the community/admin modules. */
html[data-theme="dark"] :is(.card, [class*="-card"], [class*="-panel"], [class*="-dialog"], [class*="-modal"], [class*="-drawer"]):not(.hero-card):not(.hero-float-card):not([class*="backdrop"]):not([class*="overlay"]):not([class*="scrim"]):not([class*="badge"]):not([class*="status"]) {
  background-color: #1b2520;
  border-color: #35443b;
  color: #e0e9e2;
}
html[data-theme="dark"] :is([class*="-title"], [class*="-heading"], [class*="-name"], [class*="-copy"], [class*="-label"], [class*="-meta"], [class*="-description"], [class*="-lede"], [class*="-empty"], [class*="-summary"], [class*="-value"]) {
  color: #d5e0d8;
}
html[data-theme="dark"] :is(.hero-card, .hero-float-card) :is([class*="-title"], [class*="-heading"], [class*="-name"], [class*="-copy"], [class*="-label"], [class*="-meta"], [class*="-description"], [class*="-lede"], [class*="-value"]) {
  color: inherit;
}

/* Legacy neutral gradients and nested text need explicit dark surfaces. */
html[data-theme="dark"] :is(.home-sheet-card, .sheet-bars, .home-partner-strip, .partner-contact-panel, .template-how-card, .donor-board, .coming-soon-card, .ect-tools) { background-image: none; background-color: #1b2520; border-color: #35443b; }
html[data-theme="dark"] :is(.button-outline, .icon-button, .page-button, .auth-google-button, .auth-modal-close, .account-sidebar-toggle, .account-profile-link) { background: #243229; color: #dce7df; border-color: #46564b; }
html[data-theme="dark"] :is(.button-outline:hover, .icon-button:hover, .page-button:hover, .auth-google-button:hover:not(:disabled), .account-sidebar-toggle:hover, .account-profile-link:hover) { background: #304437; color: #f0f7f1; border-color: #789981; }
html[data-theme="dark"] :is(.button-primary, .button-dark) { color: #fff; background: #3c7958; }
html[data-theme="dark"] :is(.button-primary:hover, .button-dark:hover) { background: #32674a; }
html[data-theme="dark"] :is(.price-cell, .quick-item-total, .subtotal-row strong, .auth-modal h2, .folder-card-title h2, .folder-metric strong, .workspace-summary-strip b, .recap-table strong) { color: #e1ece4; }
html[data-theme="dark"] :is(.home-feature-card, .home-workflow-card, .home-local-card, .home-partner-strip, .partner-contact-panel, .partner-demo-card, .template-how-card, .template-local-card, .donor-board, .guide-card, .info-card, .auth-modal, .account-card, .workspace-card, .project-folder-card, .forum-main) :is(h1, h2, h3, h4, strong, p, small, label) { color: #d5e0d8; }
html[data-theme="dark"] :is(.auth-field, .auth-modal-lede, .auth-signup-hint, .auth-privacy-note, .auth-provider-note, .sheet-top, .sheet-row, .sheet-total, .forum-topic-body) { color: #b3c2b7; }
html[data-theme="dark"] :is(.sheet-row strong, .sheet-total strong, .sheet-title) { color: #e0ece3; }
html[data-theme="dark"] .sheet-top b { background: #2a4433; color: #c9e5c9; }
html[data-theme="dark"] :is(.sheet-rule, .auth-divider:before, .auth-divider:after) { background: #3b4a40; }
html[data-theme="dark"] :is(.sheet-row, .auth-privacy-note) { border-color: #3b4a40; }
html[data-theme="dark"] :is(.forum-reply, .forum-reply-login, .forum-no-replies, .forum-channel-button) { background: #202d25; color: #c7d7cc; border-color: #3b4a40; }
html[data-theme="dark"] .forum-channel-button.is-active { background: #2a4936; color: #d9efde; border-color: #81ac8b; }
html[data-theme="dark"] .auth-modal .auth-message { color: #b7debd; }
html[data-theme="dark"] .auth-modal .auth-message.error { color: #ffb6aa; }
html[data-theme="dark"] .auth-divider { color: #b3c2b7; }

.legal-document { min-width: 0; max-width: 100%; overflow-wrap: anywhere; line-height: 1.75; }
.legal-document section { margin-top: 24px; }
.legal-document section:first-child { margin-top: 0; }
.legal-document h3 { margin: 20px 0 9px; font-size: 16px; line-height: 1.5; }
.legal-document p, .legal-document li { font-size: 14px; line-height: 1.75; }
.legal-document ul { padding-left: 22px; }
.legal-document li + li { margin-top: 9px; }
.legal-document .legal-meta { color: var(--ink-soft); font-weight: 750; }
html[data-theme="dark"] :is(.documentation-sidebar, .documentation-feed, .documentation-message, .documentation-notice, .documentation-server-title, .documentation-feed-header) { background: #1b2520; color: #d5e0d8; border-color: #35443b; }
html[data-theme="dark"] :is(.documentation-message, .documentation-feed-header, .documentation-server-title) :is(h2, h3, p, li, strong, b, small) { color: #d5e0d8; }
html[data-theme="dark"] :is(.documentation-channel-link, .documentation-group-title, .documentation-message-meta, .documentation-channel-hash) { color: #b3c2b7; }
html[data-theme="dark"] :is(.documentation-channel-link:hover, .documentation-channel-link.active, .documentation-channel-link[aria-current="true"]) { background: #2a4433; color: #e5f3e8; }
html[data-theme="dark"] :is(.documentation-status, .documentation-data-tags span, .documentation-stat, .documentation-info-card, .documentation-supabase-card) { background: #25352b; color: #d5e0d8; border-color: #405449; }
html[data-theme="dark"] .legal-document :is(p, li, h3, strong) { color: #d5e0d8; }
@media (max-width: 480px) { .legal-document p, .legal-document li { font-size: 13px; } .legal-document h3 { font-size: 15px; } }

/* Small table labels retain readable contrast in the light palette. */
html:not([data-theme="dark"]) :is(.catalog-table thead th, .draft-list-head) { color: #526159; }

/* Public pages have legacy heading/link colors beyond the catalog workspace. */
html[data-theme="dark"] .page-content :is(h1,h2,h3,h4) { color: var(--ink); }
html[data-theme="dark"] .home-section-heading :is(p,span) { color: #b3c2b7; }
html[data-theme="dark"] .documentation-channel-link { background: #25352b; color: #d5e0d8; border-color: #405449; }
html[data-theme="dark"] .documentation-channel-link > .documentation-channel-title { color: inherit; }
html[data-theme="dark"] .documentation-notice strong { color: #e3ce8f; }
@media(max-width:760px) {
 .documentation-channels { display:grid; grid-template-columns:minmax(0,1fr); overflow:visible; gap:14px; }
 .documentation-channel-group { min-width:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
 .documentation-group-title { display:block; grid-column:1/-1; color:var(--ink-soft); padding:0 2px 3px; }
 .documentation-channel-link { min-width:0; width:100%; min-height:44px; padding:7px; }
 .documentation-channel-link > .documentation-channel-title { min-width:0; white-space:normal; overflow-wrap:anywhere; }
}

.documentation-attribution { margin-top:18px; padding:20px; border:1px solid var(--line); border-radius:12px; overflow-wrap:anywhere; }
.documentation-attribution h3 { margin:0 0 10px; font-size:16px; }
.documentation-attribution p { font-size:13px; line-height:1.7; color:var(--ink-soft); }
.documentation-attribution a { color:#386b45; text-decoration:underline; text-underline-offset:3px; }
html[data-theme="dark"] .documentation-attribution a { color:#c2dfb7; }


/* Matte near-black dark palette refinement. Light-theme declarations are unchanged. */
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f4f6;
  --ink-soft: #d0d4d9;
  --muted: #b2b8bf;
  --line: #3a3e43;
  --panel: #191b1e;
  --canvas: #0c0d0f;
  --sidebar: #121315;
  --green: #347f4d;
  --green-deep: #26683e;
  --green-mid: #79c88e;
  --lime: #d3ee80;
  --mint: #1d2b21;
  --peach: #30241e;
  --blue: #202833;
  --yellow: #30291b;
  --shadow: 0 12px 32px rgba(0, 0, 0, .38);
  --dark-surface-1: #191b1e;
  --dark-surface-2: #222427;
  --dark-surface-3: #292c30;
  --dark-inset: #141619;
  --dark-border: #3b4046;
  --dark-border-strong: #535960;
  --dark-text-primary: #f3f4f6;
  --dark-text-secondary: #d0d4d9;
  --dark-text-muted: #b2b8bf;
  --dark-green-accent: #83d295;
  --dark-green-action: #347f4d;
  --chart-grid: #383d43;
  --chart-axis: #70777f;
  --chart-label: #c7ccd1;
  --chart-planned: #75d18d;
  --chart-actual: #ffb36b;
}
html[data-theme="dark"] body {
  background: var(--canvas);
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(.sidebar, .topbar, .mobile-bottom-nav) {
  background: rgba(18, 19, 21, .98);
  border-color: var(--dark-border);
}
html[data-theme="dark"] .topbar { background: rgba(18, 19, 21, .96); }
html[data-theme="dark"] .mobile-bottom-nav { background: rgba(18, 19, 21, .99); }
html[data-theme="dark"] :is(
  .panel-card, .metric-card, .source-tag, .workspace-card, .workspace-summary-strip,
  .summary-stat, .draft-project-card, .draft-table-panel, .folder-card, .project-card,
  .project-folder-card, .project-analysis-panel, .analysis-detail-card, .account-card,
  .account-note-card, .info-card, .donor-board, .donor-list-item, .partner-card,
  .partner-admin-panel, .partner-contact-panel, .partner-demo-card, .partner-directory-empty,
  .template-local-card, .template-how-card, .template-side-panel, .saved-template-card,
  .admin-price-panel, .admin-metric-card, .donation-admin-panel, .donor-admin-form,
  .donor-admin-row, .openmoji-picker-dialog, .openmoji-picker-shell, .topic-dialog,
  .topic-dialog-sheet, .auth-modal, .volume-backup-dialog, .add-work-drawer,
  .detail-drawer, .detail-price-card, .project-analysis-summary, .project-division-row,
  .project-group-row, .project-subdivision-row, .component-row, .quick-item,
  .schedule-entry, .supabase-data-card, .supabase-quota-card, .supabase-info-wrap,
  .catalog-panel, .draft-side, .template-builder, .template-result-more,
  .documentation-sidebar, .documentation-feed, .admin-documentation-sidebar,
  .admin-documentation-feed, .ect-tools, .ect-dialog, .avatar-choice
) {
  background-color: var(--dark-surface-1);
  border-color: var(--dark-border);
  color: var(--dark-text-primary);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .24);
}
html[data-theme="dark"] :is(.hero-card, .hero-float-card) {
  background-image: none;
  background-color: #171a18;
  border-color: #343a36;
  color: var(--dark-text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
}
html[data-theme="dark"] .hero-card :is(h1, h2, h3, h4, p, span, small, strong, em) { color: inherit; }
html[data-theme="dark"] .hero-card h2 em { color: #d3ee80; }
html[data-theme="dark"] .hero-card :is(.hero-kicker, .hero-footnote) { color: #d0d4d9; }
html[data-theme="dark"] .hero-float-card { background-color: var(--dark-surface-2); color: var(--dark-text-primary); }
html[data-theme="dark"] .hero-float-card :is(h1, h2, h3, p, span, small, strong, em) { color: inherit; }
html[data-theme="dark"] :is(
  .workspace-switcher, .source-card, .search-bar, .admin-search, .admin-price-edit,
  .filter-control select, .page-size select, .project-picker select, .project-name-input,
  .workspace-field input, .workspace-field select, .workspace-field textarea,
  .account-field input, .account-field select, .account-field textarea, .auth-field input,
  .community-form input, .community-form textarea, .community-form select,
  .donor-admin-form input, .donor-admin-form textarea, .donation-url-form input,
  .partner-listing-form input, .partner-listing-form textarea, .partner-inquiry-form input,
  .partner-inquiry-form textarea, .template-search, .template-name-grid input,
  .add-work-search, .dimension-field input, .volume-backup-form input,
  .volume-backup-form select, .volume-backup-form textarea, .openmoji-picker-search,
  .topic-icon-field input, .project-icon-color input, .project-icon-controls input,
  .record-inline-input, .record-inline-select, .ect-dialog textarea, .ect-dialog input
) {
  background-color: var(--dark-inset);
  border-color: var(--dark-border-strong);
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  color: var(--dark-text-primary);
  background-color: var(--dark-inset);
  border-color: var(--dark-border-strong);
  caret-color: var(--lime);
}
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #b1b8c0; opacity: 1; }
html[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) { accent-color: #80d292; }
html[data-theme="dark"] option { color: var(--dark-text-primary); background: var(--dark-inset); }
html[data-theme="dark"] ::selection { color: #fff; background: #286b40; }
html[data-theme="dark"] :is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #91e2a4;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(104, 202, 128, .22);
}
html[data-theme="dark"] :is(
  .admin-price-table thead th, .catalog-table thead th, .draft-table thead th,
  .analysis-component-table thead th, .recap-table thead th, .table-wrap thead th,
  .admin-kind-tabs, .admin-pagination, .pagination, .filter-row, .results-header,
  .draft-table-head, .draft-table-footer, .side-card-head, .admin-panel-heading,
  .topic-dialog-header, .volume-backup-dialog-head, .openmoji-picker-heading,
  .openmoji-picker-footer, .account-card-heading, .workspace-card-heading,
  .recap-section-head, .analysis-detail-heading
) {
  background-color: var(--dark-surface-2);
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] :is(table, th, td, .catalog-row td, .draft-table tbody td,
  .admin-price-table tbody td, .analysis-component-table td, .recap-table td,
  .donor-admin-row, .partner-inquiry-row, .admin-forum-topic-row, .topic-row) {
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] :is(.catalog-row:hover, .admin-price-table tbody tr:hover,
  .admin-forum-topic-row:hover, .partner-inquiry-row:hover, .ect-own-row:hover) {
  background-color: var(--dark-surface-3);
}
html[data-theme="dark"] :is(
  .page-intro h1, .workspace-heading h1, .workspace-card-title, .documentation-message h2,
  .documentation-message h3, .documentation-feed-header strong, .admin-section-heading h2,
  .admin-panel-heading h2, .donation-admin-heading h2, .analysis-detail-heading h4,
  .volume-backup-analysis h3, .volume-backup-row-main>strong, .ect-dialog h3,
  .ect-own-row strong, .avatar-choice-fieldset legend, .price-component-cell strong,
  .source-price-cell, .admin-metric-card strong, .item-name-button, .quick-item-title,
  .quick-item-total, .grand-total, .folder-card-title h2, .folder-metric strong,
  .workspace-summary-strip b, .recap-table strong
) { color: var(--dark-text-primary); }
html[data-theme="dark"] :is(
  .page-lede, .workspace-heading p, .documentation-message p, .documentation-message li,
  .documentation-message-meta, .admin-section-heading p, .admin-panel-heading p,
  .donation-admin-heading p, .partner-card-copy, .forum-topic-body, .account-info-links,
  .analysis-source-note, .analysis-detail-heading p, .volume-backup-row-main>span,
  .volume-backup-analysis header p, .volume-backup-analysis-total span,
  .ect-head p, .ect-dialog>p, .ect-own-row small, .legal-document p, .legal-document li
) { color: var(--dark-text-secondary); }
html[data-theme="dark"] :is(
  .breadcrumbs, .workspace-copy span, .nav-group-label, .metric-label, .metric-card small,
  .source-tag small, .results-header, .results-meta, .page-size, .item-category,
  .quick-item-meta, .workspace-meta-line, .workspace-field label, .account-field label,
  .documentation-group-title, .documentation-channel-link, .documentation-message-meta,
  .admin-result-count, .admin-only-edited, .override-state, .volume-backup-unit-note,
  .volume-backup-analysis-total small, .admin-channel-nav-button,
  .local-status-chip, .ect-kicker, .ect-own-list
) { color: var(--dark-text-muted); }
html[data-theme="dark"] :is(a, .text-link-button, .source-link, .reset-filters,
  .back-to-folders, .nav-link.active, .item-code, .item-name-button:hover,
  .price-restore-button, .auth-mode-toggle, .account-profile-link,
  .documentation-message a, .documentation-attribution a) { color: #9fe3ad; }
html[data-theme="dark"] :is(.nav-link:hover, .mobile-nav-link:hover) {
  background-color: #262a2e;
  color: #f3f4f6;
}
html[data-theme="dark"] :is(.nav-link.active, .mobile-nav-link.active) {
  background-color: #203327;
  color: #d3f0d8;
}
html[data-theme="dark"] :is(.button-outline, .icon-button, .page-button, .auth-google-button,
  .auth-modal-close, .account-sidebar-toggle, .account-profile-link, .ect-button) {
  background: var(--dark-surface-2);
  color: var(--dark-text-primary);
  border-color: var(--dark-border-strong);
}
html[data-theme="dark"] :is(.button-outline:hover, .icon-button:hover, .page-button:hover,
  .auth-google-button:hover:not(:disabled), .account-sidebar-toggle:hover,
  .account-profile-link:hover, .ect-button:hover:not(:disabled)) {
  background: var(--dark-surface-3);
  color: #fff;
  border-color: #6a7178;
}
html[data-theme="dark"] :is(.button-primary, .button-dark, .ect-primary) {
  color: #fff;
  background: #347f4d;
  border-color: #63b67b;
}
html[data-theme="dark"] :is(.button-primary:hover, .button-dark:hover, .ect-primary:hover:not(:disabled)) {
  background: #286b40;
  border-color: #8bd79b;
}
html[data-theme="dark"] :is(button:disabled, input:disabled, select:disabled, textarea:disabled) { opacity: .68; }
html[data-theme="dark"] :is(.admin-security-note, .local-demo-banner, .local-demo-note) {
  background: #292419;
  border-color: #5b4c2b;
  color: #f0dfb4;
}
html[data-theme="dark"] :is(.admin-security-note strong, .local-demo-banner b, .local-demo-note strong) { color: #fff0c6; }
html[data-theme="dark"] .admin-note-icon { background: #44391f; color: #ffe39a; }
html[data-theme="dark"] :is(.documentation-notice, .documentation-status, .ect-confirm-label) {
  background: #292419;
  border-color: #5b4c2b;
  color: #f0dfb4;
}
html[data-theme="dark"] :is(.documentation-notice strong, .documentation-status strong) { color: #fff0c6; }
html[data-theme="dark"] :is(.forum-reply, .forum-reply-login, .forum-no-replies, .forum-channel-button,
  .folder-empty, .quick-empty, .component-empty, .template-empty-list, .partner-directory-empty,
  .donor-empty, .admin-forum-empty, .local-demo-note, .forum-storage-note, .guide-persistence,
  .guide-banner, .admin-local-footer, .supabase-info, .supabase-tooltip, .draft-local-note,
  .project-price-context, .volume-backup-readonly-row) {
  background-color: var(--dark-surface-2);
  color: var(--dark-text-secondary);
  border-color: var(--dark-border);
}
html[data-theme="dark"] .forum-channel-button.is-active { background: #203327; color: #e1f3e5; border-color: #6bb67e; }
html[data-theme="dark"] :is(.documentation-sidebar, .documentation-feed, .documentation-message,
  .documentation-server-title, .documentation-feed-header) {
  background-color: var(--dark-surface-1);
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}
html[data-theme="dark"] :is(.documentation-message h2, .documentation-message h3,
  .documentation-message p, .documentation-message li, .documentation-message strong,
  .documentation-message b, .documentation-message small, .documentation-feed-header strong) {
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] :is(.documentation-channel-link:hover, .documentation-channel-link.active,
  .documentation-channel-link[aria-current="true"]) { background: #203327; color: #e4f4e7; }
html[data-theme="dark"] :is(.home-sheet-card, .sheet-bars, .home-partner-strip, .partner-contact-panel,
  .template-how-card, .donor-board, .coming-soon-card, .ect-tools) {
  background-image: none;
  background-color: var(--dark-surface-1);
  border-color: var(--dark-border);
}
html[data-theme="dark"] .home-float-note {
  background: var(--dark-surface-2);
  border-color: var(--dark-border-strong);
  color: var(--dark-text-primary);
}
html[data-theme="dark"] .home-float-note small { color: var(--dark-text-muted); }
html[data-theme="dark"] .home-float-icon { background: #203327; color: #a2e3ad; }
html[data-theme="dark"] :is(.workspace-switcher, .source-card, .search-bar) { background-image: none; }
html[data-theme="dark"] .admin-mode-badge { background: #302a19; color: #ffe39a; border-color: #65572f; }
html[data-theme="dark"] :is(.admin-kind-tab.active, .admin-kind-tab.active b) { color: #bce9c4; }
html[data-theme="dark"] .admin-kind-tab.active { border-color: #73c688; }
html[data-theme="dark"] :is(.admin-kind-tab b, .unit-chip, .workspace-icon, .avatar-choice.selected) {
  background: #203327;
  color: #d3f0d8;
  border-color: #527a5b;
}
html[data-theme="dark"] :is(.admin-price-edit:focus-within, .search-bar:focus-within) {
  border-color: #83d295;
  box-shadow: 0 0 0 3px rgba(104, 202, 128, .18);
}
html[data-theme="dark"] .price-component-cell small,
html[data-theme="dark"] .override-state { color: var(--dark-text-muted); }
html[data-theme="dark"] .override-state.active { color: #9fe3ad; }
html[data-theme="dark"] :is(.project-division-row th, .project-subdivision-row th,
  .analysis-total-row th, .analysis-total-row td, .recap-section-head) {
  background-color: var(--dark-surface-2);
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}
html[data-theme="dark"] :is(.analysis-source-note, .analysis-detail-heading) {
  background: var(--dark-surface-2);
  color: var(--dark-text-secondary);
  border-color: var(--dark-border);
}
html[data-theme="dark"] :is(.analysis-source-note strong, .project-division-row th,
  .project-subdivision-row th, .analysis-total-row strong) { color: #e6e9ed; }
html[data-theme="dark"] :is(.curve-chart, .curve-chart-wide, .schedule-entry, .entry-form) {
  background-color: var(--dark-surface-2);
  border-color: var(--dark-border);
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(.curve-chart svg, .curve-chart-wide svg) { color: var(--dark-text-secondary); }
html[data-theme="dark"] :is(.curve-chart svg g line, .curve-chart-wide svg g line) { stroke: var(--chart-grid) !important; }
html[data-theme="dark"] :is(.curve-chart svg > line, .curve-chart-wide svg > line) { stroke: var(--chart-axis) !important; }
html[data-theme="dark"] :is(.curve-chart svg text, .curve-chart-wide svg text) { fill: var(--chart-label) !important; }
html[data-theme="dark"] :is(.curve-chart svg polyline[stroke="#39774c"], .curve-chart-wide svg polyline[stroke="#39774c"]) { stroke: var(--chart-planned) !important; }
html[data-theme="dark"] :is(.curve-chart svg polyline[stroke="#d88f4c"], .curve-chart-wide svg polyline[stroke="#d88f4c"]) { stroke: var(--chart-actual) !important; }
html[data-theme="dark"] :is(.curve-legend, .curve-matrix-heading, .curve-work-table) { color: var(--dark-text-secondary); }
html[data-theme="dark"] :is(.curve-legend i, .curve-chart-wide .curve-legend i) { background: var(--chart-planned); }
html[data-theme="dark"] :is(.curve-legend i.actual-key, .curve-chart-wide .curve-legend .actual-key) { background: var(--chart-actual); }
html[data-theme="dark"] :is(.volume-backup-analysis, .volume-backup-row, .volume-backup-panel-empty) {
  background: var(--dark-surface-1);
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] .volume-backup-analysis>header { background: var(--dark-surface-2); border-color: var(--dark-border); }
html[data-theme="dark"] .volume-backup-analysis-code { background: #203327; color: #bce9c4; }
html[data-theme="dark"] .volume-backup-total { background: #1d2b21; color: #d7e6da; }
html[data-theme="dark"] :is(.volume-backup-row-value strong, .volume-backup-analysis-total strong,
  .volume-backup-total>strong) { color: #a1e2ad; }
html[data-theme="dark"] .volume-backup-panel-empty { border-style: dashed; }
html[data-theme="dark"] .volume-backup-panel-empty strong { color: #e4f1e6; }
html[data-theme="dark"] .volume-backup-analysis-total .is-mismatch { color: #ffb36b; }
html[data-theme="dark"] .avatar-choice { background: var(--dark-surface-2); color: var(--dark-text-secondary); border-color: var(--dark-border-strong); }
html[data-theme="dark"] .avatar-choice:hover { background: var(--dark-surface-3); border-color: #77c68b; }
html[data-theme="dark"] .avatar-choice.selected { background: #203327; color: #e3f5e6; border-color: #77c68b; }
html[data-theme="dark"] .avatar-choice img { background: var(--dark-inset); }
html[data-theme="dark"] .ect-button:hover:not(:disabled) { background: var(--dark-surface-3); border-color: #70777f; }
html[data-theme="dark"] .ect-primary { background: #347f4d; border-color: #63b67b; color: #fff; }
html[data-theme="dark"] .ect-danger { background: #351f20; border-color: #784343; color: #ffb5ad; }
html[data-theme="dark"] .ect-status { background: #1d2b21; color: #d2edd7; }
html[data-theme="dark"] .ect-status.is-error { background: #351f20; color: #ffb5ad; }
html[data-theme="dark"] .ect-own-row { background: var(--dark-surface-2); border-color: var(--dark-border); }
html[data-theme="dark"] .ect-dialog { background: var(--dark-surface-1); border-color: var(--dark-border-strong); color: var(--dark-text-primary); }
html[data-theme="dark"] .ect-dialog .ect-target { background: var(--dark-inset); color: var(--dark-text-secondary); }
html[data-theme="dark"] .ect-confirm-label { background: #292419; border-color: #5b4c2b; color: #f0dfb4; }
html[data-theme="dark"] :is(.auth-modal .auth-message, .community-form-status:not(.is-error)) { color: #a8e6b2; }
html[data-theme="dark"] :is(.auth-modal .auth-message.error, .community-form-status.is-error,
  .field-error, .is-error) { color: #ffb5ad; }
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: #111214; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3b4046; border: 2px solid #111214; border-radius: 99px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #555c63; }

/* Keep the dark theme matte while retaining a subdued photographic accent. */
html[data-theme="dark"] .hero-image { filter: brightness(.56) saturate(.56); }
html[data-theme="dark"] .hero-image-shade {
  background: linear-gradient(90deg, rgba(15, 18, 16, .94) 0%, rgba(15, 18, 16, .78) 48%, rgba(15, 18, 16, .42) 100%),
    linear-gradient(0deg, rgba(10, 12, 11, .55), rgba(0, 0, 0, 0) 54%);
}
html[data-theme="dark"] .hero-image-caption { color: #d5e0d8; }
html[data-theme="dark"] .hero-float-card { background-color: rgba(29, 34, 31, .96); color: #e4ece6; border-color: #46534a; }
html[data-theme="dark"] .partner-listing-form {
  background-color: #1b2520;
  border-color: #35443b;
  color: #d5e0d8;
}
html[data-theme="dark"] .partner-listing-form input[type="file"]::file-selector-button {
  margin-right: 8px;
  padding: 6px 9px;
  border: 1px solid #506055;
  border-radius: 6px;
  background: #29382f;
  color: #dce7df;
  cursor: pointer;
}
html[data-theme="dark"] .partner-listing-form input[type="file"]::file-selector-button:hover {
  background: #34483a;
}
html[data-theme="dark"] .partner-listing-form :is(input:disabled, select:disabled, textarea:disabled) {
  background-color: #181e1a;
  color: #a5b1a8;
  opacity: 1;
}


/* Keep the sidebar source card and Profile session actions aligned. */
.sidebar { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
.sidebar-bottom { display: grid; gap: 10px; }
.sidebar-bottom .source-card { margin-bottom: 0; }
.account-session-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--account-border); }
.account-session-actions h3 { margin: 5px 0 4px; color: var(--account-text); font-size: 16px; }
.account-session-actions p { margin: 0; color: var(--account-muted); font-size: 13px; line-height: 1.55; }
.account-session-actions .button { min-height: 42px; flex: 0 0 auto; }
.account-session-actions [hidden] { display: none !important; }
html[data-theme="dark"] .account-session-actions { border-color: var(--dark-border); }
@media (max-width: 760px) {
  .topbar-actions .avatar-small { display: grid !important; }
  .sidebar { padding-bottom: 18px; }
  .account-session-actions { align-items: stretch; flex-direction: column; gap: 12px; }
  .account-session-actions .button { width: 100%; }
}


/* High-contrast corrections for legacy light-only component declarations. */
html[data-theme="dark"] :is(
  .home-feature-card, .home-workflow-card, .home-local-card,
  .template-create-action, .template-analysis-list, .template-analysis-row, .template-result-more,
  .template-mini-flow, .curve-matrix, .curve-toolbar, .curve-mode-switch, .curve-cell-input,
  .curve-table th, .curve-matrix-heading > b,
  .recap-subdivision-head, .recap-grand-row td, .recap-grand-row th, .analysis-kind-row th,
  .draft-list-head, .draft-table tbody tr, .component-group-title,
  .workspace-empty-state, .workspace-record, .project-analysis-summary,
  .volume-backup-readonly-dims span
) {
  background-color: var(--dark-surface-2);
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] :is(
  .home-section-heading h2, .home-section-heading p, .home-workflow-card h2,
  .home-local-card h3, .home-local-card p, .community-eyebrow,
  .home-feature-card > strong, .home-feature-card > small, .feature-number,
  .workflow-steps strong, .workflow-steps small, .local-card-mark,
  .template-builder-head h2, .template-builder-head p, .template-name-grid label,
  .template-create-action small, .template-selection-meta, .template-selection-meta b,
  .template-analysis-copy strong, .template-analysis-copy small, .template-result-more,
  .template-builder-footer > small, .template-how-card h2, .template-how-card p,
  .template-mini-flow, .template-mini-flow i, .saved-templates-heading h2,
  .saved-templates-heading p, .saved-template-heading, .saved-template-card,
  .draft-item-title strong, .draft-item-title small, .draft-price, .draft-line-total,
  .draft-table tbody td, .draft-table tbody th, .draft-list-head,
  .recap-table td, .recap-table th, .recap-muted, .recap-subdivision-head,
  .recap-grand-row td, .recap-grand-row th, .recap-work-name,
  .analysis-kind-row th, .analysis-kind-row th span, .analysis-component-name strong,
  .analysis-component-name small, .analysis-detail-heading p, .analysis-effective-price,
  .analysis-effective-price small, .analysis-effective-price span, .analysis-code,
  .curve-table th, .curve-table td, .curve-table th small, .curve-work-cell strong,
  .curve-work-cell small, .curve-weight-cell, .curve-matrix-heading strong,
  .curve-matrix-heading span, .curve-legend, .component-group-title,
  .component-name, .component-meta, .component-amount, .workspace-record-main strong,
  .workspace-record-main span, .workspace-record-detail, .volume-backup-row-main > strong,
  .volume-backup-row-main > span, .volume-backup-row-value strong,
  .volume-backup-row-value small, .volume-backup-analysis h3,
  .volume-backup-analysis header p, .volume-backup-analysis-total small,
  .volume-backup-analysis-total span, .volume-backup-readonly-head,
  .volume-backup-readonly-head b, .volume-backup-readonly-formula,
  .volume-backup-readonly-formula strong, .volume-backup-panel-footer,
  .project-division-row th, .project-subdivision-row th
) {
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(
  .home-feature-card > small, .home-section-heading p, .workflow-steps small,
  .home-local-card p, .template-builder-head p, .template-create-action small,
  .template-selection-meta, .template-analysis-copy small, .template-result-more,
  .template-builder-footer > small, .template-how-card p, .template-mini-flow i,
  .saved-templates-heading p, .draft-item-title small, .recap-muted,
  .analysis-component-name small, .analysis-detail-heading p, .analysis-effective-price,
  .analysis-effective-price small, .analysis-effective-price span, .curve-table th small,
  .curve-work-cell small, .curve-matrix-heading span, .curve-legend,
  .component-meta, .workspace-record-main span, .workspace-record-detail,
  .volume-backup-row-main > span, .volume-backup-row-value small,
  .volume-backup-analysis header p, .volume-backup-analysis-total small,
  .volume-backup-analysis-total span, .volume-backup-readonly-formula,
  .volume-backup-panel-footer
) { color: var(--dark-text-secondary); }
html[data-theme="dark"] :is(.feature-arrow, .text-link-button, .folder-open-button,
  .back-to-folders, .project-tab.active, .curve-weight-cell) { color: #a8e6b2; }
html[data-theme="dark"] :is(.feature-green, .saved-template-icon, .local-card-mark) {
  background-color: #203327;
  color: #bce9c4;
  border-color: #527a5b;
}
html[data-theme="dark"] .feature-sand { background-color: #332b1c; color: #f0d394; }
html[data-theme="dark"] .feature-blue { background-color: #202b3b; color: #b6d0ff; }
html[data-theme="dark"] .feature-peach { background-color: #38251f; color: #ffc1a0; }
html[data-theme="dark"] .template-local-card {
  background-color: #292419;
  border-color: #5b4c2b;
  color: #f0dfb4;
}
html[data-theme="dark"] :is(.template-local-card strong, .template-local-card small) { color: #f0dfb4; }
html[data-theme="dark"] .template-step-number {
  background-color: #203327;
  border-color: #527a5b;
  color: #bce9c4;
}
html[data-theme="dark"] .template-analysis-row { border-color: var(--dark-border); }
html[data-theme="dark"] :is(.template-analysis-row:hover, .template-analysis-row.is-selected) {
  background-color: var(--dark-surface-3);
}
html[data-theme="dark"] .template-check {
  background-color: var(--dark-inset);
  border-color: var(--dark-border-strong);
}
html[data-theme="dark"] .template-analysis-row.is-selected .template-check {
  background-color: #347f4d;
  border-color: #83d295;
}
html[data-theme="dark"] .template-result-more { border-color: var(--dark-border); }
html[data-theme="dark"] :is(.recap-work-name, .draft-item-title strong, .curve-work-cell strong) {
  color: var(--dark-text-primary) !important;
}
html[data-theme="dark"] :is(.curve-table th, .curve-table td) { border-color: var(--dark-border); }
html[data-theme="dark"] .curve-cell-input {
  background-color: var(--dark-inset);
  border-color: var(--dark-border-strong);
}
html[data-theme="dark"] .curve-cell-input input { background-color: transparent; color: var(--dark-text-primary); }
html[data-theme="dark"] .curve-cell-input span { color: var(--dark-text-secondary); }
html[data-theme="dark"] :is(.row-add, .volume-backup-open) {
  background-color: #203327;
  border-color: #527a5b;
  color: #bce9c4;
}
html[data-theme="dark"] :is(.entry-delete, .remove-line, .template-delete-button,
  .forum-topic-delete, .workspace-record-action) {
  background-color: #351f20;
  border-color: #784343;
  color: #ffb5ad;
}
html[data-theme="dark"] :is(.calc-result-option, .formula-tab, .curve-mode-switch button) {
  background-color: var(--dark-surface-2);
  border-color: var(--dark-border);
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] :is(.formula-tab.active, .curve-mode-switch button.active) {
  background-color: var(--dark-surface-3);
  border-color: #6a9d74;
  color: #d3f0d8;
}
html[data-theme="dark"] :is(.calc-result-option:hover, .project-tab:hover) {
  background-color: var(--dark-surface-3);
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(.home-feature-card:hover, .saved-template-card:hover) {
  border-color: var(--dark-border-strong);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .32);
}


/* Final dark surfaces for small summary and saved-template badges. */
html[data-theme="dark"] :is(.analysis-code, .detail-code) {
  background-color: #203327;
  border: 1px solid #527a5b;
  color: #bce9c4;
}
html[data-theme="dark"] .saved-template-empty {
  background-color: var(--dark-surface-2);
  border-color: var(--dark-border);
  border-style: dashed;
  color: var(--dark-text-secondary);
}
html[data-theme="dark"] .saved-template-empty > span {
  background-color: #203327;
  color: #bce9c4;
}
html[data-theme="dark"] :is(.project-analysis-summary strong, .curve-matrix-heading > b) {
  color: var(--dark-text-primary);
}
html[data-theme="dark"] :is(.project-analysis-summary span, .grand-total span,
  .saved-template-date, .saved-template-count span, .saved-template-card ul,
  .saved-template-empty p) { color: var(--dark-text-secondary); }
