:root {
  --section-edge: #b7c4d5;
  --control-edge: #a0b2c9;
  --control-surface: #f5f8fd;
  --control-hover: #e7effb;
  --field-surface: #fbfcff;
  --selected-surface: #2455b4;
  --selected-ink: #fff;
  --focus-ring: #234ca7;
  --fee-surface: #edf3ff;
  --fee-edge: #829bc1;
  --fee-row-surface: #f7faff;
  --operations-surface: #eef4fc;
  --operations-edge: #9cb6d9;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --nav: #0b1322;
  --nav-border: #425673;
  --paper: #101a29;
  --white: #192639;
  --ink: #edf3ff;
  --muted: #bfd0e5;
  --line: #516984;
  --blue: #a7caff;
  --blue-dark: #c1d9ff;
  --blue-soft: #233d60;
  --amber: #ffda95;
  --amber-soft: #372a18;
  --section-edge: #617c99;
  --control-edge: #839bb8;
  --control-surface: #283c58;
  --control-hover: #314b6d;
  --field-surface: #122034;
  --selected-surface: #a7caff;
  --selected-ink: #10223f;
  --focus-ring: #c1d9ff;
  --fee-surface: #1b3050;
  --fee-edge: #8fb8ef;
  --fee-row-surface: #223a5e;
  --operations-surface: #252e40;
  --operations-edge: #8297b4;
}

:is(a,button,input,select,textarea,summary):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--control-edge);
  border-radius: 8px;
  background: var(--control-surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--control-hover); }
.editor-top { gap: 16px; }
.editor-top .theme-toggle { margin-left: auto; }

:is(.panel,.quick-facts,.reader-toolbar,.filterbar,dialog) { border-color: var(--section-edge); }
:is(.secondary,.top-search,.icon-btn,.tab,.record-view-label select) { border-color: var(--control-edge); }
:is(.field-label select,.editor-field :is(input,textarea,select),.filter-field,.search-field) {
  border-color: var(--control-edge);
  background: var(--field-surface);
  color: var(--ink);
}
:is(.tab[aria-pressed="true"],.reader-filters .tab[aria-current="page"],.editor-sections button[aria-current="true"],.review-queue button[aria-current="true"]) {
  border-color: var(--selected-surface);
  background: var(--selected-surface);
  color: var(--selected-ink);
  font-weight: 750;
}
.review-queue button[aria-current="true"] .sub { color: inherit; }
.workspace-tabs a[aria-current="page"] { background: var(--blue-soft); }
.editor-workbar { border-top: 2px solid var(--blue); }

.government-fee-panel, .service-operations-panel {
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--panel-edge);
  border-inline-start: 3px solid var(--panel-accent);
  border-radius: 8px;
  background: var(--panel-surface);
  overflow-wrap: anywhere;
}
.government-fee-panel {
  --panel-edge: var(--fee-edge);
  --panel-accent: var(--blue);
  --panel-surface: var(--fee-surface);
}
.service-operations-panel {
  --panel-edge: var(--operations-edge);
  --panel-accent: var(--operations-edge);
  --panel-surface: var(--operations-surface);
}

[data-theme="dark"] :is(.panel,.quick-facts,.reader-toolbar,.filterbar,.service-tile-body,dialog,.skip) { background: var(--white); }
[data-theme="dark"] :is(.top-search,.secondary,.icon-btn,.tab,.fee-card,.service-card,.editor-group) {
  background: var(--control-surface);
  color: var(--ink);
  border-color: var(--control-edge);
}
[data-theme="dark"] :is(.top-search kbd,.tag-muted,.directory-head) {
  background: var(--control-surface);
  color: var(--muted);
}
[data-theme="dark"] :is(.top-search,.secondary,.icon-btn,.tab):hover { background: var(--control-hover); }
[data-theme="dark"] :is(.tab[aria-pressed="true"],.reader-filters .tab[aria-current="page"],.editor-sections button[aria-current="true"],.review-queue button[aria-current="true"]) {
  background: var(--selected-surface);
  color: var(--selected-ink);
  border-color: var(--selected-surface);
}
[data-theme="dark"] :is(.secondary-hero,.service-tile > summary:hover,.service-tile[open] > summary,.pilot-scope) {
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-color: var(--section-edge);
}
[data-theme="dark"] :is(.bullet-list,.filter-static .filter-value,.tier-table th,.resource-muted,.resource-muted .ico,.editor-field) { color: var(--muted); }
[data-theme="dark"] :is(.record-view-label select,.map-region-label select,.map-settings > summary) {
  background: var(--control-surface);
  border-color: var(--control-edge);
}
[data-theme="dark"] :is(.search-field input,.filter-field input) { background: transparent; color: var(--ink); }
[data-theme="dark"] :is(.resource,.service-tile-body,.record-view-section .detail) { border-color: var(--line); }
[data-theme="dark"] :is(.service-tile,.notice) {
  background: var(--field-surface);
  border-color: var(--section-edge);
  color: var(--ink);
}
[data-theme="dark"] .callout { background: var(--amber-soft); border-color: #b78a45; }
[data-theme="dark"] :is(.callout h3,.callout a) { color: var(--amber); }
[data-theme="dark"] .operations-panel { background: var(--operations-surface); border-color: var(--operations-edge); border-top-color: var(--blue); }
[data-theme="dark"] .operations-panel .detail { border-color: var(--line); }
[data-theme="dark"] .editor-field :is(input,textarea)[readonly] { background: var(--white); color: var(--muted); }
[data-theme="dark"] .editor-primary { background: #346bc6; color: #fff; border-color: #8fb8ef; }
[data-theme="dark"] .editor-primary:disabled { background: #29394f; color: #adbed5; border-color: var(--line); }
[data-theme="dark"] .editor-message { color: #92dfb3; }
[data-theme="dark"] .editor-message.error { color: #ffb2a7; }
.explorer-panel .map-search { background: #2258bd; color: #fff; border-color: #2258bd; }
.explorer-panel .map-search:hover { background: #174794; }
[data-theme="dark"] .explorer-panel .map-search { background: #346bc6; border-color: #8fb8ef; }

@media (max-width: 610px) {
  .theme-toggle { min-width: 36px; padding: 7px; }
  .theme-toggle span,.preview-badge { display: none; }
}
@media print {
  :root[data-theme="dark"] {
    --paper: #fff;
    --white: #fff;
    --ink: #182438;
    --muted: #52627a;
    --line: #dfe5ef;
    --blue: #2258bd;
    --blue-dark: #174794;
    --blue-soft: #edf3ff;
    --section-edge: #b7c4d5;
    --control-edge: #a0b2c9;
    --control-surface: #f5f8fd;
    --field-surface: #fbfcff;
    --fee-surface: #edf3ff;
    --fee-edge: #829bc1;
    --fee-row-surface: #f7faff;
    --operations-surface: #eef4fc;
    --operations-edge: #9cb6d9;
  }
  .theme-toggle { display: none; }
}
