:root {
  --qbap-primary: #2563eb;
  --qbap-bg: #ffffff;
  --qbap-text: #0f172a;
  --qbap-muted: #64748b;
  --qbap-border: #e2e8f0;
  --qbap-shadow: 0 16px 38px rgba(15,23,42,.20);
  --qbap-radius: 18px;
}

.qbap-root,
.qbap-root *,
.qbap-root *::before,
.qbap-root *::after {
  box-sizing: border-box !important;
}

.qbap-root {
  position: fixed !important;
  bottom: 18px !important;
  z-index: 2147483647 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  direction: rtl !important;
  color: var(--qbap-text) !important;
  filter: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

.qbap-position-bottom-left { left: 18px !important; bottom: 18px !important; }
.qbap-position-bottom-right { right: 18px !important; bottom: 18px !important; }
.qbap-position-middle-left { left: 18px !important; top: 50% !important; bottom: auto !important; transform: translateY(-50%) !important; }
.qbap-position-middle-right { right: 18px !important; top: 50% !important; bottom: auto !important; transform: translateY(-50%) !important; }
.qbap-position-top-left { left: 18px !important; top: 18px !important; bottom: auto !important; }
.qbap-position-top-right { right: 18px !important; top: 18px !important; bottom: auto !important; }

.qbap-toggle {
  min-width: 58px !important;
  height: 58px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: var(--qbap-primary) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  justify-content: center !important;
  padding: 0 16px !important;
  cursor: pointer !important;
  box-shadow: var(--qbap-shadow) !important;
  font-weight: 700 !important;
  font-size: 15px !important;
}

.qbap-panel {
  width: min(520px, calc(100vw - 28px)) !important;
  max-height: none !important;
  overflow: visible !important;
  margin-bottom: 10px !important;
  background: var(--qbap-bg) !important;
  color: var(--qbap-text) !important;
  border: 1px solid var(--qbap-border) !important;
  border-radius: var(--qbap-radius) !important;
  box-shadow: var(--qbap-shadow) !important;
  padding: 12px !important;
  filter: none !important;
}

.qbap-header {
  display: grid !important;
  grid-template-columns: 74px 1fr 34px !important;
  align-items: center !important;
  gap: 10px !important;
  padding-bottom: 9px !important;
  border-bottom: 1px solid var(--qbap-border) !important;
  margin-bottom: 10px !important;
}

.qbap-logo {
  width: 74px !important;
  height: 44px !important;
  object-fit: contain !important;
  visibility: visible !important;
  filter: none !important;
}

.qbap-header strong {
  display: block !important;
  font-size: 17px !important;
  line-height: 1.15 !important;
  color: var(--qbap-text) !important;
}

.qbap-header small {
  color: var(--qbap-muted) !important;
  font-size: 11px !important;
}

.qbap-close {
  width: 34px !important;
  height: 34px !important;
  border: 1px solid var(--qbap-border) !important;
  background: #f8fafc !important;
  color: var(--qbap-text) !important;
  border-radius: 11px !important;
  cursor: pointer !important;
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
}

.qbap-grid {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 7px !important;
}

.qbap-tool {
  min-height: 68px !important;
  border: 1px solid var(--qbap-border) !important;
  border-radius: 13px !important;
  background: #f8fafc !important;
  color: var(--qbap-text) !important;
  padding: 7px 5px !important;
  cursor: pointer !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  font-size: 12px !important;
  line-height: 1.15 !important;
  text-align: center !important;
  font-weight: 700 !important;
}

.qbap-tool:hover {
  background: #eff6ff !important;
}

.qbap-tool[aria-pressed="true"] {
  background: var(--qbap-primary) !important;
  color: #fff !important;
  border-color: var(--qbap-primary) !important;
}

.qbap-tool-icon {
  min-height: 22px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
  font-weight: 900 !important;
  font-size: 17px !important;
}

.qbap-svg {
  display: inline-flex !important;
  width: 21px !important;
  height: 21px !important;
  color: currentColor !important;
}

.qbap-svg svg {
  width: 100% !important;
  height: 100% !important;
  fill: currentColor !important;
}

.qbap-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 7px !important;
  margin-top: 10px !important;
}

.qbap-reset,
.qbap-statement {
  width: 100% !important;
  min-height: 38px !important;
  border-radius: 12px !important;
  border: 1px solid var(--qbap-border) !important;
  background: #fff !important;
  color: var(--qbap-text) !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  font-weight: 700 !important;
  font-size: 13px !important;
}

.qbap-toggle:focus-visible,
.qbap-tool:focus-visible,
.qbap-close:focus-visible,
.qbap-reset:focus-visible,
.qbap-statement:focus-visible {
  outline: 4px solid #facc15 !important;
  outline-offset: 3px !important;
}

.qbap-reading-guide {
  display: none !important;
  position: fixed !important;
  left: 0 !important;
  width: 100vw !important;
  height: 44px !important;
  background: rgba(250, 204, 21, .28) !important;
  border-top: 2px solid rgba(15, 23, 42, .85) !important;
  border-bottom: 2px solid rgba(15, 23, 42, .85) !important;
  pointer-events: none !important;
  z-index: 2147483646 !important;
}

html.qbap-font-110 body :not(#qbap-root):not(#qbap-root *) { font-size: 110% !important; }
html.qbap-font-120 body :not(#qbap-root):not(#qbap-root *) { font-size: 120% !important; }
html.qbap-font-130 body :not(#qbap-root):not(#qbap-root *) { font-size: 130% !important; }

html.qbap-readable-font body :not(#qbap-root):not(#qbap-root *) {
  font-family: Arial, Verdana, Tahoma, sans-serif !important;
}

html.qbap-contrast body :not(#qbap-root):not(#qbap-root *) {
  background-color: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}

html.qbap-dark-contrast body :not(#qbap-root):not(#qbap-root *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

/* Fixed: grayscale no longer affects the toolbar itself */
html.qbap-grayscale body :not(#qbap-root):not(#qbap-root *) {
  filter: grayscale(1) !important;
}

html.qbap-highlight-links body a:not(#qbap-root a) {
  background: #ffeb3b !important;
  color: #000 !important;
  outline: 2px solid #000 !important;
  text-decoration: underline !important;
  text-decoration-thickness: 3px !important;
}

html.qbap-highlight-headings body h1,
html.qbap-highlight-headings body h2,
html.qbap-highlight-headings body h3,
html.qbap-highlight-headings body h4,
html.qbap-highlight-headings body h5,
html.qbap-highlight-headings body h6 {
  outline: 3px solid #2563eb !important;
  outline-offset: 4px !important;
  background: rgba(37,99,235,.12) !important;
}

html.qbap-highlight-forms body input:not(#qbap-root input),
html.qbap-highlight-forms body select:not(#qbap-root select),
html.qbap-highlight-forms body textarea:not(#qbap-root textarea),
html.qbap-highlight-forms body button:not(#qbap-root button) {
  outline: 3px solid #f59e0b !important;
  outline-offset: 3px !important;
}

html.qbap-text-spacing body :not(#qbap-root):not(#qbap-root *) {
  letter-spacing: .08em !important;
  word-spacing: .16em !important;
  line-height: 1.85 !important;
}

/* Improved: targets animations, transitions, marquee, GIF/video handled by JS too */
html.qbap-pause-animations body :not(#qbap-root):not(#qbap-root *) {
  animation: none !important;
  animation-play-state: paused !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

html.qbap-pause-animations body video:not(#qbap-root video) {
  animation: none !important;
}

html.qbap-hide-images body img:not(#qbap-root img),
html.qbap-hide-images body picture:not(#qbap-root picture),
html.qbap-hide-images body svg:not(#qbap-root svg),
html.qbap-hide-images body video:not(#qbap-root video),
html.qbap-hide-images body iframe:not(#qbap-root iframe) {
  visibility: hidden !important;
}

html.qbap-large-cursor body :not(#qbap-root):not(#qbap-root *),
html.qbap-large-cursor body a:not(#qbap-root a),
html.qbap-large-cursor body button:not(#qbap-root button),
html.qbap-large-cursor body input:not(#qbap-root input),
html.qbap-large-cursor body select:not(#qbap-root select),
html.qbap-large-cursor body textarea:not(#qbap-root textarea),
html.qbap-large-cursor body label:not(#qbap-root label),
html.qbap-large-cursor body [role="button"]:not(#qbap-root [role="button"]) {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M8 3 L38 31 L24 33 L31 45 L25 48 L18 36 L8 45 Z' fill='white' stroke='black' stroke-width='3'/%3E%3C/svg%3E") 8 3, auto !important;
}

html.qbap-focus-mode body a:focus,
html.qbap-focus-mode body button:focus,
html.qbap-focus-mode body input:focus,
html.qbap-focus-mode body select:focus,
html.qbap-focus-mode body textarea:focus,
html.qbap-focus-mode body [tabindex]:focus {
  outline: 5px solid #facc15 !important;
  outline-offset: 5px !important;
  box-shadow: 0 0 0 2px #000 !important;
}

html.qbap-reading-guide-active .qbap-reading-guide {
  display: block !important;
}

@media (max-width: 620px) {
  .qbap-position-bottom-left,
  .qbap-position-bottom-right,
  .qbap-position-middle-left,
  .qbap-position-middle-right,
  .qbap-position-top-left,
  .qbap-position-top-right {
    left: 10px !important;
    right: auto !important;
    bottom: 10px !important;
    top: auto !important;
    transform: none !important;
  }

  .qbap-panel {
    width: calc(100vw - 20px) !important;
  }

  .qbap-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .qbap-toggle-text {
    display: none !important;
  }

  .qbap-toggle {
    width: 58px !important;
    padding: 0 !important;
  }

  .qbap-header {
    grid-template-columns: 60px 1fr 34px !important;
  }

  .qbap-logo {
    width: 60px !important;
  }
}

@media (max-height: 620px) {
  .qbap-panel {
    transform: scale(.88) !important;
    transform-origin: bottom left !important;
  }
}


.qbap-tool[data-qbap-action="large-cursor"][aria-pressed="true"] .qbap-tool-icon::after {
  content: "✓";
  font-size: 12px;
  margin-inline-start: 2px;
}


.qbap-position-top-left .qbap-panel,
.qbap-position-top-right .qbap-panel {
  margin-bottom: 0 !important;
  margin-top: 10px !important;
}

.qbap-position-middle-left .qbap-panel,
.qbap-position-middle-right .qbap-panel {
  margin-bottom: 10px !important;
}

.qbap-display-icon_only .qbap-toggle-text,
.qbap-display-text_only .qbap-toggle > .qbap-svg {
  display: none !important;
}

.qbap-display-icon_only .qbap-toggle {
  width: 58px !important;
  min-width: 58px !important;
  padding: 0 !important;
}

.qbap-display-text_only .qbap-toggle {
  min-width: 92px !important;
  padding: 0 18px !important;
}


.qbap-root[data-panel-width="wide"] .qbap-panel {
  width: min(680px, calc(100vw - 28px)) !important;
}

.qbap-root[data-panel-width="wide"] .qbap-grid {
  grid-template-columns: repeat(6, 1fr) !important;
}

html[dir="ltr"] .qbap-root,
.qbap-root.qbap-lang-ltr {
  direction: ltr !important;
}

html[dir="rtl"] .qbap-root,
.qbap-root.qbap-lang-rtl {
  direction: rtl !important;
}
