/* The device supplies the initial palette. An explicit reader choice overrides it. */
:root {
  color-scheme: light dark;
  --ink: light-dark(#172b3c, #e2e9ec);
  --secondary: light-dark(#435563, #b4c4cb);
  --accent: light-dark(#00467e, #9dd1f2);
  --line: light-dark(#c9d1d2, #536470);
  --canvas: light-dark(#f8f6f0, #141c23);
  --panel: light-dark(#fffefb, #1d2931);
  --well: light-dark(#eee9dd, #27353c);
  --signature: light-dark(#4cba1e, #a1d87a);
  --green: light-dark(#2d7012, #a1d87a);
  --selected-bg: light-dark(#e8f0f4, #304757);
  --add-ink: light-dark(#153d2a, #caf2d6);
  --add-bg: light-dark(#d6e8d6, #284a3a);
  --remove-ink: light-dark(#65271e, #ffdad4);
  --remove-bg: light-dark(#f3ddd6, #59383b);
}
:root[data-appearance="light"] { color-scheme: only light; }
:root[data-appearance="dark"] { color-scheme: only dark; }

.masthead-inner-compact {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "brand guides theme languages";
}
.appearance {
  grid-area: theme;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  min-inline-size: 0;
  margin: 0;
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 2rem;
  color: var(--secondary);
  background: var(--panel);
}
.appearance label { position: relative; display: block; cursor: pointer; }
.appearance input, .appearance-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.appearance-symbol {
  display: grid;
  place-content: center;
  inline-size: 2rem;
  block-size: 2rem;
  border: 1px solid transparent;
  border-radius: 50%;
}
.appearance label:hover .appearance-symbol { color: var(--accent); background: var(--selected-bg); }
.appearance input:checked + .appearance-symbol {
  background: var(--accent);
  color: var(--canvas);
}
.appearance input:focus + .appearance-symbol { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 49rem) {
  .masthead-inner-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand languages" "guides theme";
    row-gap: .2rem;
  }
}
@media (max-width: 22rem) {
  .masthead-inner-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand theme" "languages languages" "guides guides";
  }
}
@media (forced-colors: active) {
  .appearance input:checked + .appearance-symbol { outline: 2px solid Highlight; outline-offset: -2px; }
}

textarea, select, .appearance, button:not(.quiet-button) { border-color: light-dark(#839694, #748b96); }
textarea { background: light-dark(#fffdf7, #142027); }
input[type="file"]::file-selector-button { color: var(--ink); background: var(--well); border: 1px solid var(--line); border-radius: .2rem; padding: .35rem .6rem; }
.compact-language-nav a[aria-current="true"] { background: var(--selected-bg); }
.task-card:hover, .task-card:focus-visible { background: light-dark(#eef4f8, #263c4b); }
button:hover:not(:disabled), button[aria-pressed="true"] { background: light-dark(#e8eddf, #30424b); }
#clean, #inspect-clean, .audit-tool button[data-run], .prediction-toolbar > button:first-of-type {
  background: var(--accent); color: light-dark(white,#102330);
}
#clean:hover:not(:disabled), #inspect-clean:hover:not(:disabled), .audit-tool button[data-run]:hover:not(:disabled),
.prediction-toolbar > button:first-of-type:hover:not(:disabled) { background: light-dark(#28566b,#c0e5fd); }
.tool-privacy { background: light-dark(#edf2e8, #25382e); }
.hero-plate {
  border-color: light-dark(#9bb5c4,#4f7385);
  border-block-start-color: var(--signature);
  background: linear-gradient(128deg, light-dark(#f3f6f6,#26363d), light-dark(#e5eef3,#23333e) 75%, light-dark(#dbe7ed,#20303a));
}
.hero-plate .code-row { border-color: light-dark(#9bb5c4,#63808e); }
.wrap-proof figure { background: light-dark(#f1f4f5,#24343c); }
.wrap-sample { background: light-dark(#fff,#192329); outline-color: var(--line); }
.editorial-link { background: light-dark(#eef3f1,#263830); }
.menu-proof-mark, .proof-mark, .powered-footer img { background-color: light-dark(transparent,#cbe0e8); border-radius: .28rem; }

.comparison-review-titles { background: light-dark(#edf2f4,#253a48); }
.comparison-review-blank { background: light-dark(#f5f4f0,#1a252c); }
.comparison-review-add { background: light-dark(#eef6ee,#1e332a); }
.comparison-review-remove { background: light-dark(#fcf0ec,#39292d); }
.comparison-review-move { background: light-dark(#edf3fb,#253546); }
.comparison-review-move-route { color: light-dark(#263e55,#c6e1f5); background: light-dark(#e0eaf4,#2d4252); }
.comparison-review-parts, .comparison-review-fold { background: light-dark(#f3f4ef,#27343a); }
.comparison-review-excerpt ins, .worked-sample ins, .diff-results ins { color: var(--add-ink); background: var(--add-bg); }
.comparison-review-excerpt del, .worked-sample del, .diff-results del { color: var(--remove-ink); background: var(--remove-bg); }
mark, .prediction-snippet mark, .comparison-review-inline-move { color: light-dark(#4a2a00,#ffe9b3); background: light-dark(#ffe2a6,#5b461f); }
.input-error { color: light-dark(#702d21,#ffc0ae); }
textarea[aria-invalid="true"], .diff-results .diff-remove { border-color: light-dark(#a55448,#e49f99); }
.diff-results .diff-add { border-color: light-dark(#356a50,#8fcba6); }
.diff-results .diff-move { border-color: light-dark(#4a6590,#9ac6ef); background: light-dark(#eaf0f6,#273a48); }

@media print {
  :root, :root[data-appearance] { color-scheme: only light; }
  .appearance { display: none; }
}
