:root {
  --site-text-scale: 1;
}

/* The masthead and floating tools keep their touch targets and room to fit. */
body > header,
.wendao-tools,
.study-tools,
.service-navigation-actions,
.qr-quick,
.wendao-book-cover-face {
  --site-text-scale: 1;
}

/* Use the homepage family for rendered text on routes with the shared control. */
html[data-site-text-controls] :is(body, main, footer, dialog, .hero) {
  font-family: var(--sans);
}
html[data-site-text-controls] :is(header, main, footer, dialog, .hero, .wendao-tools) :is(
  a, button, input, select, textarea, label, span, small, strong, em,
  h1, h2, h3, h4, h5, h6, p, li, dt, dd, th, td, figcaption, summary, output
) {
  font-family: var(--sans) !important;
}

.site-text-size {
  position: fixed;
  z-index: 12;
  inset-inline-end: max(14px, env(safe-area-inset-right));
  inset-block-end: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  padding: 3px;
  border: 1px solid #b8beae;
  border-radius: 8px;
  background: #f9f7ef;
  color: #293d2b;
  box-shadow: 0 3px 14px #29342624;
  font: 600 17px/1 var(--sans);
}
.site-text-size[hidden] { display: none; }
.site-text-size button {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.site-text-size [data-size-step="0"] {
  min-width: 56px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.site-text-size button:hover:not([aria-disabled="true"]) { background: #e8ecdf; }
.site-text-size button:focus-visible { outline: 2px solid #445c41; outline-offset: -2px; }
.site-text-size button[aria-disabled="true"] { color: #6a7164; cursor: default; }

body:has(.wendao-tools:not([hidden]), .service-navigation-actions) .site-text-size {
  inset-block-end: calc(70px + env(safe-area-inset-bottom));
}
@media (max-width: 860px) {
  body:has(.study-tools, .qr-quick:not([hidden])) .site-text-size {
    inset-block-end: calc(70px + env(safe-area-inset-bottom));
  }
}
@media screen {
  html[data-site-text-controls] body::after {
    content: "";
    display: block;
    height: calc(64px + env(safe-area-inset-bottom));
  }
}
@media print {
  .site-text-size { display: none; }
}
