/* The local wrapper marks the exact route. Important paint declarations override the estate theme only inside these controls. */
:root[data-mg-control-pilot] {
  --mg-control-ink: #27362e;
  --mg-control-muted: #4b564c;
  --mg-control-surface: #f8f6ed;
  --mg-control-border: #8b9286;
  --mg-control-hover: #e9ede1;
  --mg-control-selected: #dce7dc;
  --mg-control-selected-border: #486253;
  --mg-control-focus: #834b20;
}

:root[data-mg-control-pilot="search"] :where(.hd-ui-controls button[data-search-ui], .searchform #lang),
:root[data-mg-control-pilot="collections"] .org-chips button[data-shelf],
:root[data-mg-control-pilot="edition"] :where(
  .contents #toc-toggle, #book-controls #query, #book-controls #scope,
  #book-controls #language, #book-controls #reset, .entry > .source-notes > summary
) {
  min-block-size: 44px;
  max-inline-size: 100%;
  padding-block: .55rem;
  padding-inline: .7rem;
  border: 1px solid var(--mg-control-border);
  border-radius: .35rem;
  background-color: var(--mg-control-surface) !important;
  color: var(--mg-control-ink) !important;
  font-size: max(.875rem, 1em);
  line-height: 1.3;
  text-align: start;
  overflow-wrap: anywhere;
}

:root[data-mg-control-pilot="search"] .hd-ui-controls button[data-search-ui] {
  min-inline-size: 44px;
  text-align: center;
}

:root[data-mg-control-pilot="search"] .hd-ui-controls,
:root[data-mg-control-pilot="collections"] .org-chips:not([hidden]) {
  gap: .5rem;
  flex-wrap: wrap;
}

:root[data-mg-control-pilot="edition"] .entry > .source-notes > summary {
  min-inline-size: 0;
  cursor: pointer;
}

:root[data-mg-control-pilot="search"] .hd-ui-controls button[aria-pressed="true"],
:root[data-mg-control-pilot="collections"] .org-chips button[aria-pressed="true"],
:root[data-mg-control-pilot="edition"] :where(
  .contents #toc-toggle[aria-expanded="true"], .entry > .source-notes[open] > summary
) {
  border-color: var(--mg-control-selected-border);
  background-color: var(--mg-control-selected) !important;
  text-decoration: underline;
  text-underline-offset: .19em;
  font-weight: 650;
}

@media (hover: hover) {
  :root[data-mg-control-pilot="search"] .hd-ui-controls button:not(:disabled):not([aria-pressed="true"]):hover,
  :root[data-mg-control-pilot="collections"] .org-chips button:not(:disabled):not([aria-pressed="true"]):hover,
  :root[data-mg-control-pilot="edition"] :where(
    .contents #toc-toggle[aria-expanded="false"]:hover, #book-controls #reset:not(:disabled):hover,
    .entry > .source-notes:not([open]) > summary:hover
  ) {
    background-color: var(--mg-control-hover) !important;
  }
}

:root[data-mg-control-pilot="search"] :where(.hd-ui-controls button, .searchform #lang):focus-visible,
:root[data-mg-control-pilot="collections"] .org-chips button:focus-visible,
:root[data-mg-control-pilot="edition"] :where(
  .contents #toc-toggle, #book-controls #query, #book-controls #scope,
  #book-controls #language, #book-controls #reset, .entry > .source-notes > summary
):focus-visible {
  outline: 3px solid var(--mg-control-focus);
  outline-offset: 2px;
}

:root[data-mg-control-pilot="search"] :where(.hd-ui-controls button, .searchform #lang):disabled,
:root[data-mg-control-pilot="collections"] .org-chips button:disabled,
:root[data-mg-control-pilot="edition"] #book-controls :is(button,input,select):disabled {
  color: var(--mg-control-muted) !important;
  background-color: #eae8dd !important;
  border-color: var(--mg-control-border);
  text-decoration: none;
  cursor: not-allowed;
  opacity: .7;
}
