/* Module overrides load after each page's styles. Imagery and map feature colors
   remain unchanged; only the surrounding interface follows the selected theme. */

@media screen {

/* Assistant conversations, proposals, and the shared side panel. */
:root[data-theme="dark"] :is(.ai-panel-header, .ai-panel-status, .ai-panel [data-ai-refresh-notice], .ai-question, .ai-selection, .ai-background-notice) {
  background: var(--theme-soft);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] :is(.ai-shortcuts button, .ai-proposal-card, .ai-panel .ai-proposal-card, .ai-panel .ai-answer, .ai-panel .ai-composer) {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] :is(.ai-shortcuts button:hover, .ai-shortcuts button.selected, .ws.ai-panel-open [data-toggle-pane="context"]) {
  background: var(--theme-hover);
  border-color: var(--green);
  color: var(--theme-accent);
}
:root[data-theme="dark"] :is(.ai-options, .ai-conversation-list a, .ai-proposals, .ai-diff, .ai-composer, .ai-selection blockquote) {
  border-color: var(--line);
}
:root[data-theme="dark"] :is(.ai-conversation-list small, .ai-context-used, .ai-diff .context) { color: var(--muted); }
:root[data-theme="dark"] .ai-diff .added { background: var(--theme-success-bg); color: #b9dfb2; }
:root[data-theme="dark"] .ai-diff .removed { background: var(--theme-danger-bg); color: var(--danger); }
:root[data-theme="dark"] .ai-panel-status[data-error="1"] { background: var(--theme-danger-bg); color: var(--danger); }
:root[data-theme="dark"] :is(.ai-panel button, .ai-panel a):focus-visible { outline-color: var(--green); }

/* File library, readers, and connected storage. Document images retain their
   original paper background, while empty previews use the interface palette. */
:root[data-theme="dark"] :is(.file-source-tabs a.selected, .file-add > summary, .file-reader-contents summary, .file-preview-toc summary) {
  color: var(--theme-accent);
  border-color: var(--green);
}
:root[data-theme="dark"] :is(.file-extra-filters, .file-list-labels, .file-reader-contents, .file-table-scroll th, .file-preview-notice, .integration-logo, .integration-permissions, .integration-setup, .file-preview-toc) {
  background: var(--theme-soft);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] .file-view-switch a { color: var(--muted); }
:root[data-theme="dark"] :is(.file-view-switch .selected, .file-preview-toc nav a[aria-current="page"]) {
  background: var(--theme-hover);
  color: var(--theme-accent);
}
:root[data-theme="dark"] :is(.file-tile-preview, .file-tile-preview img, .file-preview-canvas, .file-media-preview) { background: var(--paper); }
:root[data-theme="dark"] .category-pdf .file-tile-preview { background: #302821; }
:root[data-theme="dark"] .category-document .file-tile-preview { background: var(--theme-info-bg); }
:root[data-theme="dark"] .category-ebook .file-tile-preview { background: #302d25; }
:root[data-theme="dark"] .category-spreadsheet .file-tile-preview { background: var(--theme-success-bg); }
:root[data-theme="dark"] :is(.category-audio, .category-video) .file-tile-preview { background: #302b38; }
:root[data-theme="dark"] :is(.file-format-glyph, .file-link-count, .file-tile-date, .file-folder-manage, .file-search-field > .icon, .file-path > span, .file-preview-toc nav a > span) { color: var(--muted); }
:root[data-theme="dark"] .category-pdf .file-format-glyph { color: #d1a48b; }
:root[data-theme="dark"] .category-document .file-format-glyph { color: #a7c3d2; }
:root[data-theme="dark"] .category-ebook .file-format-glyph { color: #c6b99e; }
:root[data-theme="dark"] .category-spreadsheet .file-format-glyph { color: #b0ca98; }
:root[data-theme="dark"] :is(.category-audio, .category-video) .file-format-glyph { color: #c4aed2; }
:root[data-theme="dark"] .file-folder-glyph { fill: #465c37; stroke: #a9ba8a; }
:root[data-theme="dark"] .file-star { color: var(--lime); text-shadow: 0 1px 2px #000; }
:root[data-theme="dark"] .file-tile:hover { border-color: var(--green); }
:root[data-theme="dark"] :is(.file-library-list .file-tile:hover, .file-link-option:hover) { background: var(--theme-hover); }
:root[data-theme="dark"] .file-empty-icon { background: var(--theme-soft); color: var(--muted); border-color: var(--line); }
:root[data-theme="dark"] .file-trash-badge { background: var(--theme-warning-bg); color: var(--theme-warning-ink); border-color: var(--line); }
:root[data-theme="dark"] .file-link-checklist { background: var(--surface); }

/* The workspace defines its own surface tokens on the body. */
:root[data-theme="dark"] .workspace-page { --paper: #111c17; --surface: #1a2922; }
:root[data-theme="dark"] :is(.ws-view-switch, .ws-tabs, .ws-group summary > span) { background: var(--theme-soft); }
:root[data-theme="dark"] :is(.ws-view-switch [aria-current], .ws-editor-actions) { background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .ws-search { background: var(--theme-input); }
:root[data-theme="dark"] :is(.ws-tree-link:hover, .ws-tab button:hover) { background: var(--theme-hover); }
:root[data-theme="dark"] .ws-tree-link.selected { background: var(--theme-hover); color: var(--theme-accent); box-shadow: inset 3px 0 var(--green); }
:root[data-theme="dark"] :is(.ws-tabs > a, .ws-tab) { color: var(--muted); }
:root[data-theme="dark"] :is(.ws-tabs [aria-current="page"], .ws-tab:has([aria-current="page"])) {
  background: var(--surface);
  border-color: var(--line);
  border-bottom-color: var(--surface);
  color: var(--theme-accent);
}
:root[data-theme="dark"] :is(.ws-tree-link > span:first-child, .ws-group summary, .ws-tab button, .ws-document-path, .ws-document-path span, .ws-lead, .ws-status) { color: var(--muted); }
:root[data-theme="dark"] #ws-outline a { color: var(--muted); }
:root[data-theme="dark"] .ws-task-dot { color: var(--green); }
:root[data-theme="dark"] .ws-list-row { border-color: var(--line); }
:root[data-theme="dark"] .ws-resizer:after { background: var(--line); }
:root[data-theme="dark"] :is(.ws-resizer:hover, .ws-resizer:focus-visible):after { background: var(--green); }
:root[data-theme="dark"] .ws-context progress { accent-color: var(--green); }

/* Study and project budgets. */
:root[data-theme="dark"] :is(.study-progress-native, .study-bar progress, .study-week progress) { accent-color: var(--green); }
:root[data-theme="dark"] .study-ratings .rating-0 { border-color: var(--danger); }
:root[data-theme="dark"] .study-ratings .rating-3 { background: var(--theme-success-bg); border-color: var(--green); }
:root[data-theme="dark"] .project-cost-overview { background: linear-gradient(135deg, var(--theme-soft), var(--surface) 80%); }
:root[data-theme="dark"] .project-cost-warning { background: var(--theme-warning-bg); color: var(--theme-warning-ink); border-color: #655337; }
:root[data-theme="dark"] .project-cost-progress { background: var(--line); }
:root[data-theme="dark"] .project-cost-progress::-webkit-progress-bar { background: var(--line); }

/* Plant collections, records, and field tools. */
:root[data-theme="dark"] :is(.plantings-workspace summary, .planting-collection-count strong, .planting-stats strong, .planting-event-date span) { color: var(--theme-accent); }
:root[data-theme="dark"] :is(.plantings-workspace pre, .planting-stats > a, .planting-stats > div, .planting-card-image, .planting-hero-photo) { background: var(--theme-soft); }
:root[data-theme="dark"] .planting-collection { background: linear-gradient(150deg, var(--surface), var(--theme-soft)); }
:root[data-theme="dark"] .planting-card:hover { border-color: var(--green); }
:root[data-theme="dark"] .planting-code { background: #15241ced; color: var(--theme-accent); }
:root[data-theme="dark"] .planting-placeholder { color: var(--green); }
:root[data-theme="dark"] :is(.planting-timeline, .planting-map-canvas) { border-color: var(--line); }
:root[data-theme="dark"] .planting-event:before { background: var(--green); }
:root[data-theme="dark"] .planting-missing { background: var(--theme-warning-bg); color: var(--theme-warning-ink); }
/* QR labels are physical print artifacts and need a white quiet zone. */
:root[data-theme="dark"] .planting-label { background: #fff; color: #17241c; border-color: #ccc; }
:root[data-theme="dark"] .planting-label a { color: #183d34; }

/* Terrain overview and setup. */
:root[data-theme="dark"] :is(.terrain-row, .outdoors-section, .terrain-advanced) { border-color: var(--line); }
:root[data-theme="dark"] .outdoors-section:hover { border-color: var(--green); }
:root[data-theme="dark"] :is(.terrain-row small, .outdoors-section p, .outdoors-count, .terrain-setup-steps, .terrain-advanced summary) { color: var(--muted); }
:root[data-theme="dark"] :is(.outdoors-count strong, .terrain-setup-steps [aria-current="step"]) { color: var(--theme-accent); }
:root[data-theme="dark"] :is(.outdoors-symbol, .outdoors-summary, .terrain-setup-steps strong, .terrain-map-choice) { background: var(--theme-soft); }
:root[data-theme="dark"] .outdoors-symbol { color: var(--green); }
:root[data-theme="dark"] .terrain-setup-steps [aria-current="step"] strong { background: var(--forest); color: var(--ink); }
:root[data-theme="dark"] .terrain-workspace .errorlist { color: var(--danger); }
:root[data-theme="dark"] :is(.terrain-workspace a, .terrain-workspace button):focus-visible { outline-color: var(--green); }

/* Map controls and editors; basemaps, photographs, zones, and marker colors
   keep their original rendering. */
:root[data-theme="dark"] #terrain-map-app { --terrain-line: var(--line); --terrain-light: var(--theme-soft); --terrain-ink: var(--ink); }
:root[data-theme="dark"] #terrain-map-app button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] #terrain-map-app button:hover { background: var(--theme-hover); }
:root[data-theme="dark"] #terrain-map-app :is(button[aria-pressed="true"], button.terrain-primary) { background: #315c43; color: #fff; border-color: var(--green); }
:root[data-theme="dark"] #terrain-map-app .terrain-crosshair-actions button { background: #315c43; color: #fff; border-color: #fff; }
:root[data-theme="dark"] #terrain-map-app :is(input:not([type="checkbox"]):not([type="range"]):not([type="color"]), select) { background: var(--theme-input); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.terrain-coordinates form, .terrain-search-results, .terrain-map-aside, .terrain-editor, .terrain-mode-badge, .terrain-position) { background: var(--surface); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] #terrain-map-app .help { color: var(--muted); }
:root[data-theme="dark"] #terrain-map-status[data-error="true"] { background: var(--theme-danger-bg); color: var(--danger); }
:root[data-theme="dark"] .terrain-map-frame { border-color: var(--line); }
:root[data-theme="dark"] #terrain-canvas {
  --ol-background-color: var(--surface);
  --ol-accent-background-color: var(--theme-soft);
  --ol-subtle-background-color: #1a2922db;
  --ol-partial-background-color: #1a2922ed;
  --ol-foreground-color: var(--ink);
  --ol-subtle-foreground-color: var(--muted);
}
:root[data-theme="dark"] #terrain-canvas .ol-control { background: #1a2922db; }
:root[data-theme="dark"] #terrain-canvas .ol-control button { background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] #terrain-canvas .ol-attribution { background: #1a2922ed; color: var(--ink); }
:root[data-theme="dark"] #terrain-canvas .ol-attribution a { color: var(--theme-accent); }
:root[data-theme="dark"] #terrain-map-app :is(.terrain-under-map button, .terrain-drawer-tabs button, .terrain-object-row button) { background: transparent; }
:root[data-theme="dark"] #terrain-map-app :is(.terrain-drawer-tabs [aria-selected="true"], .terrain-object-row button[aria-pressed="true"]) { background: var(--theme-soft); color: var(--theme-accent); }
:root[data-theme="dark"] :is(.terrain-plant-card, .terrain-object-row) { border-color: var(--line); }
:root[data-theme="dark"] :is(.terrain-plant-card img, .terrain-plant-placeholder) { background: var(--theme-soft); }
:root[data-theme="dark"] .terrain-plant-placeholder { color: var(--green); }
:root[data-theme="dark"] :is(.terrain-plant-copy small, .terrain-object-row small, .terrain-empty) { color: var(--muted); }
:root[data-theme="dark"] .terrain-plant-card[data-active="true"] { background: var(--theme-hover); }
:root[data-theme="dark"] .terrain-fields input[type="color"] { background: var(--surface); border-color: var(--line); }

/* Photo registration and its coordinate table. */
:root[data-theme="dark"] .terrain-registration { background: var(--surface); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.registration-status, .registration-points th, .registration-preview-summary) { background: var(--theme-soft); }
:root[data-theme="dark"] .registration-status[data-error="true"] { background: var(--theme-danger-bg); color: var(--danger); }
:root[data-theme="dark"] .terrain-registration button { background: var(--surface); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.registration-search input, .registration-coordinate-pair input) { background: var(--theme-input); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.registration-coordinate-form fieldset, .registration-points th, .registration-points td, .registration-local-help, .registration-destination-map) { border-color: var(--line); }
:root[data-theme="dark"] .registration-source-image { background: repeating-conic-gradient(#22352a 0 25%, #1a2922 0 50%) 0 / 20px 20px; border-color: var(--line); }
:root[data-theme="dark"] .registration-destination-map .ol-control { background: #1a2922db; }
:root[data-theme="dark"] .registration-destination-map .ol-attribution { background: #1a2922ed; color: var(--ink); }
:root[data-theme="dark"] .registration-points { background: var(--surface); }
:root[data-theme="dark"] .registration-points caption { color: var(--ink); }
:root[data-theme="dark"] :is(.terrain-registration .help, .registration-preview-summary .help) { color: var(--muted); }
:root[data-theme="dark"] .registration-preview-summary { border-left-color: var(--green); }
:root[data-theme="dark"] :is(.registration-preview-opacity input, .registration-checkpoint input, .registration-confirm input) { accent-color: var(--green); }

}
