:root {
  --mt-reader-font-scale: 1;
  --mt-toolbar-z: 999999;
}

.mt-lesehilfe-toolbar {
  /* Enfold exposes the General Styling palette as inherited CSS variables. */
  --mt-background: var(--enfold-main-color-bg, #fff);
  --mt-surface: var(--enfold-main-color-bg2, #f6f6f6);
  --mt-text: var(--enfold-main-color-color, #111);
  --mt-border: var(--enfold-main-color-border, #ccc);
  --mt-accent: var(--enfold-main-color-primary, #444);
  --mt-on-accent: var(--enfold-main-color-constant-font, #fff);
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 10px;
  top: 150px;
  z-index: var(--mt-toolbar-z);
  font-family: Arial, sans-serif;
}

.mt-position-right { right: 18px; }
.mt-position-left { left: 18px; }

.mt-main-toggle,
.mt-close,
.mt-action {
  cursor: pointer;
}

.mt-main-toggle {
  width: 52px;
  height: 52px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 3px 15px rgba(0,0,0,.18);
}

.mt-main-toggle:focus-visible,
.mt-close:focus-visible,
.mt-action:focus-visible,
.mt-lesehilfe-toolbar select:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.mt-panel[hidden] {
  display: none !important;
}

.mt-panel {
  box-sizing: border-box;
  position: absolute;
  top: 0;
  width: 290px;
  max-width: calc(100vw - 30px);
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  padding: 14px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mt-position-right .mt-panel {
  right: 64px;
}

.mt-position-left .mt-panel {
  left: 64px;
}

.mt-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 18px;
}

.mt-close {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
}

.mt-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mt-action {
  min-height: 52px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: #f7f7f7;
  color: #111;
  font-size: 14px;
  text-align: left;
  padding: 8px 10px;
}

.mt-action:hover {
  background: #efefef;
}

.mt-reset {
  grid-column: 1 / -1;
}

.mt-rate-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
}

.mt-rate {
  min-width: 82px;
}

.mt-status {
  margin-top: 10px;
  min-height: 1.4em;
  font-size: 13px;
}

body.mt-font-scaling main,
body.mt-font-scaling article,
body.mt-font-scaling .entry-content,
body.mt-font-scaling .post-entry,
body.mt-font-scaling .avia_textblock {
  font-size: calc(1em * var(--mt-reader-font-scale)) !important;
}

body.mt-line-height main p,
body.mt-line-height main li,
body.mt-line-height article p,
body.mt-line-height article li,
body.mt-line-height .entry-content p,
body.mt-line-height .entry-content li,
body.mt-line-height .avia_textblock p,
body.mt-line-height .avia_textblock li {
  line-height: 1.9 !important;
}

body.mt-reader-mode > *:not(.mt-lesehilfe-toolbar):not(.mt-focus-mask) {
  visibility: hidden !important;
}

body.mt-reader-mode .mt-reader-active {
  visibility: visible !important;
}

/* Versteckte WordPress-/Enfold-Hilfsdaten dürfen im Lesemodus nicht
   durch erzwungene Sichtbarkeit eingeblendet werden. */
body.mt-reader-mode .mt-reader-active [hidden],
body.mt-reader-mode .mt-reader-active [aria-hidden="true"],
body.mt-reader-mode .mt-reader-active .screen-reader-text,
body.mt-reader-mode .mt-reader-active .av-structured-data,
body.mt-reader-mode .mt-reader-active .avia-hidden,
body.mt-reader-mode .mt-reader-active .avia_hidden_link_text {
  visibility: hidden !important;
}

body.mt-reader-mode .mt-reader-active {
  position: relative !important;
  z-index: 99990 !important;
  max-width: 850px !important;
  margin: 30px auto !important;
  padding: 30px !important;
  background: #fff !important;
  color: #111 !important;
  box-shadow: 0 3px 20px rgba(0,0,0,.12);
}

.mt-focus-mask {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 99980;
  background: rgba(0,0,0,.72);
  pointer-events: none;
}

.mt-focus-mask-top {
  top: 0;
}

.mt-focus-mask-bottom {
  bottom: 0;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 600px) {
  .mt-lesehilfe-toolbar {
    top: auto;
    bottom: 20px;
  }

  .mt-position-right {
    right: 12px;
  }

  .mt-position-left {
    left: 12px;
  }

  .mt-position-right .mt-panel {
    right: 0;
    bottom: 126px;
    top: auto;
  }

  .mt-position-left .mt-panel {
    left: 0;
    bottom: 126px;
    top: auto;
  }

  .mt-tool-grid {
    grid-template-columns: 1fr;
  }

  .mt-reset {
    grid-column: auto;
  }
}


.mt-control-group {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.mt-control-group label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  font-size: 12px;
}

.mt-control-group select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 32px;
  margin: 0;
  padding: 4px 6px;
  font-size: 13px;
  line-height: 1.3;
}


.mt-speak-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mt-speak-wrap .mt-action {
  width: 100%;
}

.mt-browser-hint-inline {
  font-size: 10px;
  line-height: 1.3;
  color: #666;
  padding: 0 4px 4px;
}

/* Version 0.2.8: klare Trennung von Vorlesefunktion und weiteren Lesehilfen */
.mt-speech-section {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(92px, .65fr);
  gap: 8px;
  align-items: start;
}

.mt-speech-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mt-compact-action {
  min-height: 44px;
}

.mt-speak-button {
  width: 100%;
  min-height: 52px;
}

.mt-section-divider {
  height: 1px;
  background: #d7d7d7;
  margin: 14px 0 10px;
}

.mt-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
}

.mt-reading-tools {
  margin-bottom: 2px;
}

@media (max-width: 600px) {
  .mt-speech-section {
    grid-template-columns: 1fr;
  }

  .mt-speech-controls {
    grid-template-columns: 1fr 1fr;
  }
}

.mt-reset-standalone {
  width: 100%;
  min-height: 44px;
}

.mt-control-group {
  margin-top: 0;
}

.mt-status-top {
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  background: #f6f6f6;
  font-size: 11px;
  line-height: 1.35;
}

.mt-status-top:empty {
  display: none;
}

@media (max-width: 600px) {
  .mt-panel {
    max-height: calc(100vh - 166px);
    max-height: calc(100dvh - 166px);
  }
}

/* Each launcher and its panel share a distinct theme accent. */
.mt-lesehilfe-toolbar .mt-main-toggle[aria-controls="mt-reading-panel"],
.mt-lesehilfe-toolbar #mt-reading-panel {
  --mt-accent: var(--enfold-main-color-secondary, #526b36);
}

/* Keep the theme palette consistent across both panels and theme form styles. */
:is(body, #top) .mt-lesehilfe-toolbar .mt-panel {
  background: var(--mt-background);
  background: color-mix(in srgb, var(--mt-accent) 12%, var(--mt-background));
  color: var(--mt-text);
  border-color: var(--mt-accent);
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-main-toggle,
:is(body, #top) .mt-lesehilfe-toolbar .mt-action {
  background: var(--mt-accent);
  color: var(--mt-on-accent);
  border-color: var(--mt-accent);
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-main-toggle:hover,
:is(body, #top) .mt-lesehilfe-toolbar .mt-main-toggle[aria-expanded="true"],
:is(body, #top) .mt-lesehilfe-toolbar .mt-action:hover {
  background: var(--mt-accent);
  background: color-mix(in srgb, var(--mt-accent) 88%, var(--mt-text));
  color: var(--mt-on-accent);
  border-color: var(--mt-accent);
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-panel-header {
  background: var(--mt-accent);
  color: var(--mt-on-accent);
  margin: -14px -14px 12px;
  padding: 10px 14px;
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-panel-header strong,
:is(body, #top) .mt-lesehilfe-toolbar .mt-close {
  color: inherit;
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-close {
  background: transparent;
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-control-group label,
:is(body, #top) .mt-lesehilfe-toolbar .mt-browser-hint-inline {
  color: var(--mt-text);
}

:is(body, #top) .mt-lesehilfe-toolbar select,
:is(body, #top) .mt-lesehilfe-toolbar select option,
:is(body, #top) .mt-lesehilfe-toolbar .mt-status-top {
  background: var(--mt-surface);
  color: var(--mt-text);
  border-color: var(--mt-border);
}

:is(body, #top) .mt-lesehilfe-toolbar .mt-section-divider {
  background: var(--mt-border);
}

:is(body, #top) .mt-lesehilfe-toolbar button:focus-visible,
:is(body, #top) .mt-lesehilfe-toolbar select:focus-visible {
  outline: 3px solid var(--mt-text);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--mt-background);
}

/* Internal controls use a fixed contrasting pair, independent of accent colors. */
.mt-lesehilfe-toolbar {
  --mt-button-bg: #333333;
  --mt-button-text: #ffffff;
}
.mt-lesehilfe-toolbar.mt-dark-theme {
  --mt-button-bg: #ffffff;
  --mt-button-text: #333333;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-panel .mt-action,
:is(body, #top) .mt-lesehilfe-toolbar .mt-panel .mt-close {
  background: var(--mt-button-bg);
  color: var(--mt-button-text);
  border-color: var(--mt-button-bg);
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-panel .mt-action:hover {
  text-decoration: underline;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-panel .mt-close {
  border-radius: 4px;
  min-width: 32px;
  min-height: 32px;
}

/* Opt-in text contrast; photos, video, canvas and SVG artwork are not filtered. */
body.mt-high-contrast {
  --mt-hc-bg: #fff;
  --mt-hc-fg: #111;
}
body.mt-high-contrast.mt-contrast-dark {
  --mt-hc-bg: #111;
  --mt-hc-fg: #fff;
}
body.mt-high-contrast,
body.mt-high-contrast :where(div, section, article, main, aside, header, footer, nav, p, span, strong, em, b, i, small, h1, h2, h3, h4, h5, h6, ul, ol, li, dl, dt, dd, blockquote, figcaption, label, form, fieldset, legend, table, thead, tbody, tr, th, td, a, button, input, select, option, textarea):not(.mt-focus-mask) {
  background-color: var(--mt-hc-bg) !important;
  background-image: none !important;
  color: var(--mt-hc-fg) !important;
  border-color: var(--mt-hc-fg) !important;
  text-shadow: none !important;
}
body.mt-high-contrast a {
  text-decoration: underline !important;
  text-underline-offset: .15em;
}
body.mt-high-contrast :is(button, input, select, textarea, [role="button"]) {
  border: 2px solid var(--mt-hc-fg) !important;
}
body.mt-high-contrast :is([aria-pressed="true"], [aria-selected="true"], [aria-current="page"]) {
  outline: 3px double var(--mt-hc-fg) !important;
  outline-offset: 2px;
  text-decoration: underline !important;
}
body.mt-high-contrast :focus-visible {
  outline: 3px solid var(--mt-hc-fg) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px var(--mt-hc-bg) !important;
}

/* Monochrome SVG avoids the fixed pale colors of platform speaker emoji. */
:is(body, #top) .mt-lesehilfe-toolbar .mt-speaker-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  vertical-align: middle;
  color: inherit;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-main-toggle .mt-speaker-icon {
  width: 30px;
  height: 30px;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-speaker-body {
  fill: currentColor;
  stroke: none;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-speaker-waves {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}
:is(body, #top) .mt-lesehilfe-toolbar .mt-speak-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mt-panel-size { display: none; }
@media (max-width: 1024px) {
  .mt-lesehilfe-toolbar { top: auto; bottom: 20px; }
  .mt-position-right { right: 12px; }
  .mt-position-left { left: 12px; }
  .mt-position-right .mt-panel { right: 0; top: auto; bottom: 126px; }
  .mt-position-left .mt-panel { left: 0; top: auto; bottom: 126px; }
  .mt-panel { max-height: calc(100dvh - 166px); }
  .mt-panel-header { gap: 6px; font-size: 16px; }
  .mt-panel-header strong { margin-right: auto; }
  :is(body, #top) .mt-lesehilfe-toolbar .mt-panel-size {
    display: inline-block;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    font-size: 24px;
    cursor: pointer;
    background: var(--mt-button-bg);
    color: var(--mt-button-text);
  }
  .mt-position-right .mt-panel-compact { right: 64px; bottom: 0; }
  .mt-position-left .mt-panel-compact { left: 64px; bottom: 0; }
  .mt-panel-compact { width: 290px; max-width: calc(100vw - 88px); }
  .mt-panel-compact > :not(.mt-panel-header):not(.mt-speech-section):not(.mt-reset) {
    display: none !important;
  }
  .mt-panel-compact .mt-speak-wrap { display: none !important; }
  .mt-panel-compact .mt-speech-section { display: block; }
  .mt-panel-compact .mt-speech-controls { grid-template-columns: 1fr 1fr; }
  .mt-panel-compact .mt-action { min-height: 44px; padding: 6px; }
}
