:root {
  color-scheme: light;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

#themeSelect {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--card);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8efed;
  --ink-soft: #b7c5c1;
  --ink-faint: #9aaea8;
  --paper: #111817;
  --card: #192321;
  --line: #3b4d46;
  --grid: #293a34;
  --teal: #55d2bd;
  --teal-dark: #8ce6d4;
  --teal-soft: #203f37;
  --blue: #71bfff;
  --coral: #fb997f;
  --warning: #f3ca79;
  --danger: #ff9c92;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
  --theme-surface: #15201c;
  --theme-raised: #24342e;
  --theme-hover: #2a4037;
  --theme-input: #111b17;
  --theme-plot: #101916;
  --theme-warning-bg: #3d321c;
  --theme-danger-bg: #412622;
  --theme-focus: #9adfd0;
  background: var(--paper);
}

html[data-theme="dark"] body {
  background: var(--paper);
}

html[data-theme="dark"] ::selection {
  color: var(--ink);
  background: #386252;
}

html[data-theme="dark"] :is(
  button, select, input, textarea, [tabindex]
):focus-visible {
  outline-color: var(--theme-focus);
}

html[data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]), select, textarea
) {
  color: var(--ink);
  border-color: var(--line);
  background: var(--theme-input);
}

html[data-theme="dark"] .tic-pan-slider {
  border: 0;
  background: transparent;
}

html[data-theme="dark"] :is(input, textarea)::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

html[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--teal);
}

html[data-theme="dark"] :is(
  .card, .data-source-pane, .path-input, .file-tree, .file-group + .file-group,
  .tic-peak-toolbar, .rt-method-toolbar, .rt-pin-form, .feature-table-wrap,
  .target-record, .analysis-empty, .standards-method-badge, .standards-build-bar,
  .profile-figures figure, .match-details, .standard-match-note,
  .compound-context-menu button, .nist-structure-preview,
  .nist-source-disclosure summary
) {
  border-color: var(--line);
}

html[data-theme="dark"] :is(
  .data-source-pane, .tic-peak-toolbar, .rt-method-toolbar, .rt-pin-form,
  .nist-source, .analysis-empty, .standards-import, .match-details,
  .standards-build-bar, .target-record, .profile-stats,
  .nist-source-disclosure summary
) {
  background: var(--theme-surface);
}

html[data-theme="dark"] :is(
  .file-tree, .analysis-table-wrap, .standards-table-wrap, .standard-profile,
  .compound-context-menu, .compound-context-menu button,
  .queue-check-button, .header-transfer-button, .button--quiet, .icon-button
) {
  background: var(--card);
}

html[data-theme="dark"] :is(
  .auth-tabs, .workflow-tabs, .spectrum-tabs, .tic-role-controls
) {
  background: var(--theme-surface);
}

html[data-theme="dark"] :is(.auth-tab.is-active, .spectrum-tab.is-active) {
  background: var(--theme-raised);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .standards-tabs .is-active {
  background: var(--teal-soft);
}

html[data-theme="dark"] :is(
  .button--primary, .workflow-tab.is-active, .tic-role-button[aria-pressed="true"]
) {
  color: #10231c;
  border-color: var(--teal);
}

html[data-theme="dark"] .tic-role-button--control[aria-pressed="true"] {
  color: var(--ink);
  border-color: #91a39b;
  background: #3d4c45;
}

html[data-theme="dark"] .tic-role-button--subtract[aria-pressed="true"] {
  border-color: var(--coral);
}

html[data-theme="dark"] :is(
  .button--quiet, .icon-button, .queue-check-button, .header-transfer-button
):hover:not(:disabled),
html[data-theme="dark"] .compound-context-menu button:hover:not(:disabled),
html[data-theme="dark"] .file-row:hover,
html[data-theme="dark"] .file-row--selectable:focus-visible {
  color: var(--ink);
  border-color: var(--teal);
  background: var(--theme-hover);
}

html[data-theme="dark"] .file-row--selectable.is-selected {
  background: var(--teal-soft);
}

html[data-theme="dark"] :is(
  .analysis-table th, .analysis-table td, .feature-table th, .feature-table td,
  .standards-table th, .standards-table td, .result-table th, .result-table td,
  .qualifier-check-table th, .qualifier-check-table td,
  .profile-levels th, .profile-levels td
) {
  border-color: var(--line);
}

html[data-theme="dark"] :is(
  .analysis-table th, .feature-table th, .standards-table th, .result-table th
) {
  color: var(--ink-soft);
  background: var(--theme-raised);
}

html[data-theme="dark"] :is(.analysis-table td, .standards-table td),
html[data-theme="dark"] .result-table tbody tr:not(.table-empty) td:first-child {
  background: var(--card);
}

html[data-theme="dark"] .analysis-table tbody th {
  background: var(--theme-surface);
}

html[data-theme="dark"] .analysis-table tbody tr:hover :is(td, th),
html[data-theme="dark"] .result-table tbody tr:not(.table-empty):hover,
html[data-theme="dark"] .result-table tbody tr:not(.table-empty):hover td:first-child,
html[data-theme="dark"] .result-table tbody tr.is-copy-selected:not(.is-selected),
html[data-theme="dark"] .result-table tbody tr.is-copy-selected:not(.is-selected) td:first-child {
  background: var(--theme-hover);
}

html[data-theme="dark"] .analysis-table tbody tr.analysis-row--pending > :is(td, th),
html[data-theme="dark"] .analysis-table tbody tr.analysis-row--pending:hover > :is(td, th) {
  color: var(--warning);
  background: var(--theme-warning-bg);
}

html[data-theme="dark"] .result-table tbody tr.is-selected,
html[data-theme="dark"] .result-table tbody tr.is-selected td:first-child {
  background: var(--teal-soft);
}

html[data-theme="dark"] .analysis-table .is-grid-selected {
  background: var(--teal-soft) !important;
  box-shadow: inset 0 0 0 1px var(--teal);
}

html[data-theme="dark"] :is(.analysis-sort-button, .empty-icon) {
  color: var(--ink-faint);
}

html[data-theme="dark"] :is(
  .standards-table input:disabled, .compound-context-menu button:disabled
) {
  color: var(--ink-faint);
  background: var(--theme-surface);
}

html[data-theme="dark"] :is(
  .profile-warnings, .button.is-pending, .profile-status--review,
  .standard-match-status--review, .standard-profile-review
) {
  color: var(--warning);
  border-color: #7b663a;
  background: var(--theme-warning-bg);
}

html[data-theme="dark"] .standard-match-warnings {
  color: var(--warning);
}

html[data-theme="dark"] :is(
  .profile-status--ready, .standard-match-status--pass,
  .standards-method-badge, .toast--info, .toast--notice
) {
  color: var(--teal-dark);
  border-color: #3b6d5e;
  background: var(--teal-soft);
}

html[data-theme="dark"] :is(
  .standard-match-status--fail, .button--danger,
  .toast:not(.toast--info):not(.toast--notice)
) {
  color: var(--danger);
  border-color: #7c5149;
  background: var(--theme-danger-bg);
}

html[data-theme="dark"] .button--danger:hover:not(:disabled),
html[data-theme="dark"] .remove-file-button:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #55302a;
}

html[data-theme="dark"] .svg-chart,
html[data-theme="dark"] .profile-figures figure {
  border-color: var(--line);
  background: var(--theme-plot);
}

html[data-theme="dark"] :is(.chart-axis, .profile-axis) {
  stroke: #7f9c8e;
}

html[data-theme="dark"] :is(
  .chart-label, .chart-axis-title, .profile-chart-label, .tic-peak-label,
  .tic-peak-candidate
) {
  fill: var(--ink-soft);
}

html[data-theme="dark"] .tic-peak-guide {
  stroke: #9eaea6;
}

html[data-theme="dark"] .tic-rt-pin-label {
  fill: var(--coral);
}

html[data-theme="dark"] :is(.tic-selection, .tic-selection-dot) {
  stroke: #c6a3ff;
}

html[data-theme="dark"] .tic-selection-dot {
  fill: var(--theme-plot);
}

html[data-theme="dark"] :is(
  .tic-peak-dot, .tic-hover-dot, .profile-calibration-point
) {
  stroke: var(--theme-plot);
}

html[data-theme="dark"] .hover-line {
  stroke: var(--ink-soft);
}

html[data-theme="dark"] .chart-tooltip {
  color: var(--ink);
  border-color: #6b8d7b;
  background: #233a2e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .loading-overlay {
  background: rgba(17, 24, 23, 0.92);
}
