/* Reading has its own header slot beside theme and settings at every width. */
@media screen {
  html body #wfProgramSpeechButton {
    position: absolute; inset-inline-start: 68px; inset-inline-end: auto;
    top: 50%; transform: translateY(-50%); margin: 0; padding: 0;
    width: 40px; height: 40px; min-width: 40px; flex: 0 0 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 13px;
    background: var(--card); color: var(--ui-accent, #21566b);
    box-shadow: 0 3px 9px rgba(33, 86, 107, .12); cursor: pointer;
  }
  html body #wfProgramSpeechButton:hover { background: var(--ui-soft); }
  html body #wfProgramSpeechButton:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 3px; }
  #wfProgramSpeechButton svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  #wfProgramSpeechButton .wf-reader-stop { display: none; fill: currentColor; }
  #wfProgramSpeechButton :is(.wf-reader-pause,.wf-reader-resume) { display: none; }
  #wfProgramSpeechButton[data-active="true"] .wf-reader-speaker { display: none; }
  #wfProgramSpeechButton[data-active="true"] .wf-reader-stop { display: block; }
  #wfProgramSpeechButton[data-active="true"][data-can-pause="true"] .wf-reader-stop { display: none; }
  #wfProgramSpeechButton[data-active="true"][data-can-pause="true"][data-paused="false"] .wf-reader-pause { display: block; stroke-width: 3; }
  #wfProgramSpeechButton[data-active="true"][data-can-pause="true"][data-paused="true"] .wf-reader-resume { display: block; fill: currentColor; }
  #wfProgramSpeechButton[data-active="true"] { color: var(--brand-primary); background: var(--ui-soft); }
  #wfProgramSpeechStatus {
    position: fixed; z-index: 1250; inset-inline: 16px; top: calc(var(--nav-h, 72px) + 8px + env(safe-area-inset-top, 0px)); bottom: auto;
    width: fit-content; max-width: min(440px, calc(100vw - 32px)); margin-inline: auto;
    padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--card, #fff); color: var(--text, #182f38);
    box-shadow: 0 5px 24px rgba(20, 46, 60, .16); font-size: 14px; line-height: 1.6;
    text-align: start; overflow-wrap: anywhere; pointer-events: none;
  }
  #wfProgramSpeechStatus[hidden] { display: none; }
  /* The same control moves into the active section's actual heading. Equal
     reserved side columns keep its title centered beside Back and Menu. */
  html.wf-section-mode:not(.wf-speech-toolbar-active) body #mainContent .page .wf-heading-row.wf-program-speech-slot {
    grid-template-columns:48px 44px minmax(0,1fr) 44px 48px!important;
  }
  html.wf-section-mode:not(.wf-speech-toolbar-active) body #mainContent .page .wf-heading-row.wf-program-speech-slot > .wf-centered-heading {grid-column:3!important;}
  html.wf-section-mode:not(.wf-speech-toolbar-active) body #mainContent .page .wf-heading-row.wf-program-speech-slot > .wf-section-menu {grid-column:5!important;}
  html.wf-section-mode body #mainContent .page .wf-heading-row > #wfProgramSpeechButton {
    position:static!important;inset:auto!important;transform:none!important;z-index:auto;
    grid-column:4;grid-row:1;justify-self:center;align-self:center;
    width:44px;height:44px;min-width:44px;min-height:44px;margin:0;padding:0;
  }
  html.wf-section-mode body #wfProgramSpeechButton[hidden],html body #wfProgramSpeechButton[data-location="none"] {display:none!important;}
  @media(max-width:480px) {
    html.wf-section-mode:not(.wf-speech-toolbar-active) body #mainContent .page .wf-heading-row.wf-program-speech-slot {column-gap:4px!important;}
  }
}
@media screen {
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar {
    --wf-header-button: 40px;
    display: grid !important;
    grid-template-columns: var(--wf-header-button) minmax(0, 1fr) repeat(3, var(--wf-header-button)) !important;
    align-items: center !important; gap: 6px !important;
    padding-inline: 10px !important;
  }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar .wf-header-controls {
    display: contents !important;
  }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar .wf-nav-wordmark {
    position: static !important; transform: none !important; grid-area: 1 / 2 !important;
    min-width: 0; width: auto !important; margin: 0 !important;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar .wf-header-controls :is(#desktopSidebarToggle,#wfProgramSpeechButton,#themeBtn,#headerSettingsBtn),
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar .wf-header-controls :is(#desktopSidebarToggle,#wfProgramSpeechButton,#themeBtn,#headerSettingsBtn):is(:hover,:active) {
    display: inline-flex !important; position: static !important; transform: none !important;
    width: var(--wf-header-button) !important; height: var(--wf-header-button) !important;
    min-width: var(--wf-header-button) !important; min-height: var(--wf-header-button) !important;
    margin: 0 !important; padding: 0 !important; grid-row: 1 !important;
    align-items: center !important; justify-content: center !important; justify-self: stretch !important;
    pointer-events: auto !important;
  }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar #desktopSidebarToggle { grid-column: 1 !important; }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar #wfProgramSpeechButton { grid-column: 3 !important; }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar #themeBtn { grid-column: 4 !important; }
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar #headerSettingsBtn { grid-column: 5 !important; }
}
@media screen and (min-width: 1025px) {
  html.wf-program-speech-enabled:not(.wf-section-mode) body nav.navbar {
    --wf-header-button: 48px; gap: 8px !important; padding-inline: 16px !important;
  }
}
@media print { #wfProgramSpeechButton, #wfProgramSpeechStatus { display: none !important; } }
