/* User-selectable application appearance. Keep the geological map and exported
   document surfaces untouched; this palette applies to the working interface. */
.theme-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 420px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}
.theme-setting-row .control { max-width: 190px; }

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5e7eb;
  --muted: #b6c0ce;
  --muted-2: #95a3b5;
  --line: #374151;
  --paper: #1f2937;
  --canvas: #111827;
  --accent-pale: #1e293b;
  --warning-pale: #3b2d17;
  --shadow: 0 1px 3px rgba(0, 0, 0, .24), 0 1px 2px rgba(0, 0, 0, .2);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main-area,
html[data-theme="dark"] .content-wrap { color: #e5e7eb; background: #111827; }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .page-card,
html[data-theme="dark"] .rail-card,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .settings-profile-card,
html[data-theme="dark"] .settings-voice-hub-card,
html[data-theme="dark"] .settings-list-section,
html[data-theme="dark"] .settings-list-toolbar { color: #e5e7eb; background-color: #1f2937; border-color: #374151; }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .page-card,
html[data-theme="dark"] .rail-card,
html[data-theme="dark"] .rbac-card,
html[data-theme="dark"] .section-content,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel {
  color: #e5e7eb !important;
  background: #1f2937 !important;
  border-color: #374151 !important;
}
html[data-theme="dark"] .topbar { background: #18212f !important; }
html[data-theme="dark"] .section-head { border-bottom-color: #374151; }
/* Several legacy enterprise rules use !important and shorthand backgrounds.
   These explicit overrides must cover that cascade. */
html[data-theme="dark"] .section-head {
  color: #e5e7eb !important;
  background: #1f2937 !important;
  border-bottom-color: #374151 !important;
}
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .field-label,
html[data-theme="dark"] .theme-setting-row,
html[data-theme="dark"] .settings-profile-card h3 { color: #e5e7eb; }
html[data-theme="dark"] .section-head p,
html[data-theme="dark"] .section-intro,
html[data-theme="dark"] .settings-profile-card span,
html[data-theme="dark"] .settings-profile-card p,
html[data-theme="dark"] .settings-voice-hub-card p { color: #aeb9c8; }
html[data-theme="dark"] .control,
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color: #e5e7eb !important;
  background: #111827 !important;
  border-color: #4b5563 !important;
}
html[data-theme="dark"] .control::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #8793a3; }
html[data-theme="dark"] .button-secondary,
html[data-theme="dark"] .mini-badge {
  color: #d1d5db !important;
  background: #374151 !important;
  border-color: #4b5563 !important;
}
html[data-theme="dark"] .button-secondary:hover { color: #f3f4f6 !important; background: #475569 !important; }
html[data-theme="dark"] .mini-badge.green { color: #cbd5e1 !important; background: #1e293b !important; }
html[data-theme="dark"] .mini-badge.amber { color: #f6d28c !important; background: #493919 !important; }
html[data-theme="dark"] .settings-profile-card [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"] { background-color: #1f2937 !important; border-color: #374151 !important; }
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"],
html[data-theme="dark"] [style*="color:#233740"],
html[data-theme="dark"] [style*="color: #233740"],
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #334155"] { color: #e5e7eb !important; }
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"] { color: #aeb9c8 !important; }
html[data-theme="dark"] .theme-setting-row { border-top-color: #374151; }
html[data-theme="dark"] .bottom-nav { border-color: #273449; }
html[data-theme="dark"] .toast { color: #e5e7eb; background: #263244; border-color: #475569; }

/* Project overview uses gradient folder cards rather than the shared card
   components, so it needs its own dark surfaces and text colors. */
html[data-theme="dark"] .project-folders-grid .project-folder-body {
  color: #e5e7eb;
  background: linear-gradient(180deg, #263447 0%, #1f2937 100%) !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .project-folders-grid .project-folder-card.is-open .project-folder-body {
  background: linear-gradient(180deg, #1e293b 0%, #1f2937 100%) !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .project-folders-grid .project-folder-title,
html[data-theme="dark"] .project-folders-grid .project-folder-stats b { color: #f3f4f6 !important; }
html[data-theme="dark"] .project-folders-grid .project-folder-stats { color: #c2ccda !important; border-top-color: #475569; }
html[data-theme="dark"] .project-folders-grid .project-folder-status {
  color: #dbe4ef !important;
  background: #374151 !important;
}
html[data-theme="dark"] .project-folders-grid .project-folder-status.active {
  color: #ffffff !important;
  background: #334155 !important;
}
html[data-theme="dark"] .project-folders-grid .project-folder-tab { background: #374151; border-color: #4b5563; }
html[data-theme="dark"] .projects-overview-summary-bar .folder-kpi-pill {
  color: #e5e7eb;
  background: #1f2937 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .projects-overview-summary-bar .folder-kpi-pill strong { color: #f3f4f6 !important; }
html[data-theme="dark"] .registry-project-group { background: #1f2937 !important; border-color: #374151 !important; }
html[data-theme="dark"] .registry-project-header { background: #263447 !important; border-color: #374151 !important; }
html[data-theme="dark"] .registry-project-header strong { color: #e5e7eb !important; }
html[data-theme="dark"] .registry-project-badge { color: #c6d3e1 !important; background: #374151 !important; border-color: #4b5563 !important; }

/* File explorer has its own light folder, breadcrumb, and file-row styles. */
html[data-theme="dark"] .explorer-header { border-bottom-color: #374151 !important; }
html[data-theme="dark"] .explorer-header h2 { color: #f3f4f6 !important; }
html[data-theme="dark"] .explorer-header p { color: #aeb9c8 !important; }
html[data-theme="dark"] .explorer-breadcrumbs-bar {
  background: #111827 !important;
  border-color: #374151 !important;
}
html[data-theme="dark"] .explorer-crumb { color: #94a3b8 !important; }
html[data-theme="dark"] .explorer-crumb:hover { color: #e2e8f0 !important; background: #263447 !important; }
html[data-theme="dark"] .explorer-crumb.is-current { color: #ffffff !important; background: #334155 !important; }
html[data-theme="dark"] .explorer-crumb-sep { color: #8793a3 !important; }
html[data-theme="dark"] .explorer-folder-card {
  color: #e5e7eb !important;
  background: #1f2937 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .explorer-folder-card:hover,
html[data-theme="dark"] .explorer-subfolder-box:hover {
  color: #f3f4f6 !important;
  background: #263447 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .explorer-folder-kicker { color: #94a3b8 !important; }
html[data-theme="dark"] .explorer-folder-title,
html[data-theme="dark"] .explorer-subfolder-box h3 { color: #f3f4f6 !important; }
html[data-theme="dark"] .explorer-folder-meta,
html[data-theme="dark"] .explorer-subfolder-box p { color: #bdc8d6 !important; }
html[data-theme="dark"] .explorer-subfolder-box {
  color: #e5e7eb !important;
  background: linear-gradient(180deg, #263447 0%, #1f2937 100%) !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .explorer-file-row {
  color: #e5e7eb !important;
  background: #1f2937 !important;
  border-color: #374151 !important;
}
html[data-theme="dark"] .explorer-file-row.is-highlighted {
  background: #1e293b !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .explorer-file-info strong { color: #f3f4f6 !important; }
html[data-theme="dark"] .explorer-file-info small { color: #aeb9c8 !important; }

/* Inline styles are used by a few legacy and dynamically-rendered widgets. */
html[data-theme="dark"] [style*="background:#f" i],
html[data-theme="dark"] [style*="background: #f" i],
html[data-theme="dark"] [style*="background-color:#f" i],
html[data-theme="dark"] [style*="background-color: #f" i],
html[data-theme="dark"] [style*="background:#dcfce7" i],
html[data-theme="dark"] [style*="background:#fef3c7" i],
html[data-theme="dark"] [style*="background:#fee2e2" i],
html[data-theme="dark"] [style*="background:#e0f2fe" i] {
  background: #1f2937 !important;
  border-color: #374151 !important;
}
html[data-theme="dark"] [style*="color:#1f2937" i],
html[data-theme="dark"] [style*="color: #1f2937" i],
html[data-theme="dark"] [style*="color:#203740" i],
html[data-theme="dark"] [style*="color: #203740" i],
html[data-theme="dark"] [style*="color:#223638" i],
html[data-theme="dark"] [style*="color: #223638" i],
html[data-theme="dark"] [style*="color:#344b51" i],
html[data-theme="dark"] [style*="color: #344b51" i] { color: #e5e7eb !important; }

@media (max-width: 620px) {
  .theme-setting-row { align-items: flex-start; flex-direction: column; gap: 8px; }
  .theme-setting-row .control { max-width: none; width: 100%; }
}

/* Local rock photo evidence view */
.rock-classifier-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .9fr); gap: 18px; align-items: start; }
.rock-classifier-controls { display: grid; gap: 10px; min-width: 0; }
.rock-classifier-page .field-help { display: block !important; margin: 0; color: #64748b; }
.rock-classifier-file-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rock-classifier-description { width: 100%; min-height: 78px; resize: vertical; }
.rock-classifier-preview { display: grid; min-height: 240px; place-items: center; padding: 12px; overflow: hidden; border: 1px dashed #94a3b8; border-radius: 10px; color: #64748b; background: #f8fafc; text-align: center; }
.rock-classifier-image-stage { position: relative; display: inline-block; max-width: 100%; max-height: 480px; overflow: hidden; cursor: crosshair; line-height: 0; touch-action: none; user-select: none; }
.rock-classifier-image-stage[hidden] { display: none; }
.rock-classifier-image-stage img { display: block; max-width: 100%; max-height: 480px; object-fit: contain; border-radius: 7px; pointer-events: none; }
.rock-classifier-crop-box { position: absolute; z-index: 1; border: 2px solid #e59a20; background: rgb(245 158 11 / 13%); box-shadow: 0 0 0 999px rgb(15 23 42 / 22%); pointer-events: none; }
.rock-classifier-crop-box[hidden] { display: none; }
.rock-classifier-region-clear { justify-self: start; }
.rock-classifier-status { padding: 9px 11px; border: 1px solid #dbe3eb; border-radius: 8px; color: #334155; background: #f8fafc; font-size: 12px; line-height: 1.5; }
.rock-classifier-analysis { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; margin-top: 18px; }
.rock-evidence-panel { min-width: 0; padding: 13px; border: 1px solid #dbe3eb; border-radius: 9px; color: #334155; background: #fff; }
.rock-evidence-panel h3 { margin: 0 0 10px; color: #1e293b; font-size: 14px; }
.rock-evidence-list, .rock-evidence-candidate-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.rock-evidence-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 7px 8px; border-radius: 6px; background: #f8fafc; font-size: 12px; line-height: 1.45; }
.rock-evidence-list small { flex: 0 0 auto; color: #64748b; font-size: 10px; }
.rock-evidence-empty, .rock-evidence-source { margin: 0; color: #64748b; font-size: 11px; line-height: 1.5; }
.rock-evidence-warning { margin: 10px 0 0; padding: 8px 10px; border-left: 3px solid #d59a32; border-radius: 5px; color: #765314; background: #fff8e8; font-size: 11px; line-height: 1.5; }
.rock-evidence-candidate { padding: 10px; border: 1px solid #e2e8f0; border-radius: 7px; background: #fff; }
.rock-evidence-candidate-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rock-evidence-candidate h4 { margin: 0; color: #1e293b; font-size: 13px; }
.rock-evidence-support { flex: 0 0 auto; padding: 3px 6px; border-radius: 999px; color: #334155; background: #e2e8f0; font-size: 9px; font-weight: 700; }
.rock-evidence-match, .rock-evidence-definition { margin: 8px 0 0; color: #475569; font-size: 11px; line-height: 1.5; }
.rock-evidence-properties { display: grid; grid-template-columns: minmax(90px, .4fr) minmax(0, 1fr); gap: 5px 9px; margin: 9px 0; font-size: 10px; line-height: 1.45; }
.rock-evidence-properties dt { color: #64748b; }
.rock-evidence-properties dd { min-width: 0; margin: 0; color: #334155; overflow-wrap: anywhere; }
.rock-evidence-candidate a { display: inline-block; margin-top: 5px; color: #334155; font-size: 10px; }
.rock-classifier-note { color: #64748b; font-size: 10px; line-height: 1.5; }
html[data-theme="dark"] .rock-classifier-preview { color: #aeb9c8; background: #111827; border-color: #4b5563; }
html[data-theme="dark"] .rock-classifier-crop-box { border-color: #ffc15c; background: rgb(245 158 11 / 18%); box-shadow: 0 0 0 999px rgb(0 0 0 / 38%); }
html[data-theme="dark"] .rock-classifier-page .field-help { color: #aeb9c8; }
html[data-theme="dark"] .rock-classifier-status,
html[data-theme="dark"] .rock-evidence-panel,
html[data-theme="dark"] .rock-evidence-candidate { color: #d1d5db; background: #1f2937; border-color: #374151; }
html[data-theme="dark"] .rock-evidence-panel h3,
html[data-theme="dark"] .rock-evidence-candidate h4 { color: #f3f4f6; }
html[data-theme="dark"] .rock-evidence-list li { color: #e5e7eb; background: #111827; }
html[data-theme="dark"] .rock-evidence-list small,
html[data-theme="dark"] .rock-evidence-empty,
html[data-theme="dark"] .rock-evidence-source,
html[data-theme="dark"] .rock-classifier-note { color: #aeb9c8; }
html[data-theme="dark"] .rock-evidence-warning { color: #f6d28c; background: #493919; border-color: #d59a32; }
html[data-theme="dark"] .rock-evidence-support { color: #cbd5e1; background: #1e293b; }
html[data-theme="dark"] .rock-evidence-match,
html[data-theme="dark"] .rock-evidence-definition,
html[data-theme="dark"] .rock-evidence-properties dd { color: #cbd5e1; }
html[data-theme="dark"] .rock-evidence-properties dt { color: #95a3b5; }
html[data-theme="dark"] .rock-evidence-properties { border-color: #374151; }
html[data-theme="dark"] .rock-evidence-candidate a { color: #94a3b8; }
@media (max-width: 760px) {
  .rock-classifier-layout, .rock-classifier-analysis { grid-template-columns: minmax(0, 1fr); }
  .rock-classifier-preview { min-height: 180px; }
  .rock-classifier-image-stage, .rock-classifier-image-stage img { max-height: 340px; }
}
