/* EBD reader preferences. Keep after all other EBD stylesheets. */
html[data-ebd-color-mode] {
  --v9-ink: var(--ebd-ink);
  --v9-muted: var(--ebd-muted);
  --v9-paper: var(--ebd-paper);
  --v9-rail: var(--ebd-rail);
  --v9-surface: var(--ebd-surface);
  --v9-line: var(--ebd-line);
  --v9-navy: var(--ebd-navy);
  --v9-soft: var(--ebd-soft-accent);
  --v9-accent: var(--ebd-accent-ink);
  --v9-accent-dark: var(--ebd-accent-ink);
}
html[data-theme='dune-light'], html[data-theme='default-light'] { color-scheme: light; }
html[data-theme*='dark'] { color-scheme: dark; --ebd-navy: #2c4654; }

/* Change inherited foregrounds and page surfaces in the same frame. The
   legacy reduced-motion reset sets a nonzero transition duration even on
   these containers, briefly retaining the previous theme's text color. */
html[data-ebd-color-mode],
html[data-ebd-color-mode] body.ebd-site,
html[data-ebd-color-mode] .ebd-site > .v9-shell { transition: none !important; }

.ebd-site .ebd-preferences {
  display: grid;
  gap: 10px;
  margin: 18px 0 16px;
  padding: 16px 0;
  border-top: 1px solid var(--ebd-line);
  border-bottom: 1px solid var(--ebd-line);
  color: var(--ebd-muted);
}
.ebd-site .ebd-preference {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 112px);
  gap: 8px;
  align-items: center;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.ebd-site .ebd-preference select {
  appearance: auto;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 9px 7px;
  border: 1px solid var(--ebd-line);
  border-radius: 5px;
  background: var(--ebd-paper);
  color: var(--ebd-ink);
  font: inherit;
  cursor: pointer;
}
.ebd-site .ebd-preference select:focus-visible {
  outline: 3px solid var(--ebd-accent-ink);
  outline-offset: 3px;
}
.ebd-site .ebd-preference select:disabled { cursor: wait; }
.ebd-preference-status:empty { display: none; }
.ebd-preference-status {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ebd-muted);
}
.ebd-site .ebd-preferences[hidden], .ebd-site .ebd-preference[hidden] { display: none !important; }

/* The base theme already maps its content, rails, menus and EBD dialogs to
   the --ebd-* palette. Replace the remaining light-only utility surfaces. */
@media screen {
  html[data-theme*='dark'] .v9 .v9-note {
    background: var(--ebd-soft-accent);
    border-color: var(--ebd-line);
    border-left-color: var(--ebd-accent-ink);
    color: var(--ebd-ink);
  }
  html[data-theme*='dark'] .v9 .v9-status-box { background: #233a31; border-color: #55705f; color: #dcebe1; }
  html[data-theme*='dark'] .v9 .v9-status-box.v9-error { background: #402c29; border-color: #986254; color: #f1c8bc; }
  html[data-theme*='dark'] .v9 .v9-rail-links a { border-color: var(--ebd-line); }
  html[data-theme*='dark'] .v9 .v9-document { border-color: var(--ebd-line); }
  html[data-theme*='dark'] .v9 .v9-badge.v9-orange { border-color: #8c6653; }
  html[data-theme*='dark'] .v9 input,
  html[data-theme*='dark'] .v9 textarea,
  html[data-theme*='dark'] .v9 select { border-color: var(--ebd-line); }
  html[data-theme*='dark'] .v9 input::placeholder,
  html[data-theme*='dark'] .v9 textarea::placeholder { color: var(--ebd-muted); }
  html[data-theme*='dark'] .v9 .v9-button.v9-light { background: #eef0eb; border-color: #eef0eb; color: #192933; }
  html[data-theme*='dark'] .v9 .v9-button.v9-outline { border-color: #84959a; }
  html[data-theme*='dark'] .ebd-site :focus-visible { outline-color: var(--ebd-accent-ink); }
}
@media print {
  .ebd-preferences { display: none !important; }
  html[data-ebd-color-mode] {
    color-scheme: light;
    --ebd-ink: #192933;
    --ebd-muted: #58636a;
    --ebd-paper: #ffffff;
    --ebd-surface: #f1eee7;
    --ebd-rail: #f5f3ed;
    --ebd-line: #dddcd4;
    --ebd-navy: #182b35;
    --ebd-soft-accent: #f7e9df;
    --ebd-accent-ink: #bc4928;
  }
}
