/**
 * SIRCE-UV — Módulo Global de Accesibilidad Web
 * Estilos de escalado tipográfico, espaciado, modos de contraste,
 * línea guía de lectura y panel flotante adaptable (Escritorio y Móvil).
 *
 * Diseñado para operar sobre las 9 plantillas raíz sin alterar la
 * apariencia original cuando las opciones están en su estado predeterminado.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   0. UTILIDADES DE ACCESIBILIDAD Y SALVAGUARDAS DE REFLUJO
   ═══════════════════════════════════════════════════════════════════════════ */

/* Utilidad para lectores de pantalla (modern-web-guidance: accessibility) */
.sirce-visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Salvaguarda 1: Permitir desplazamiento vertical en todas las vistas de login/registro
   cuando el texto se amplía o en pantallas móviles pequeñas */
body:has(.login-form-panel) {
  min-height: 100vh;
  min-height: 100dvh;
  height: auto !important;
  overflow-x: hidden;
  overflow-y: auto !important;
}

.login-form-panel {
  overflow-y: auto !important;
  max-height: 100dvh;
  align-items: safe center !important;
  padding-bottom: 72px !important;
}

.login-form-panel .form-box {
  margin-top: auto;
  margin-bottom: auto;
}

/* Salvaguarda 2: Corregir posición del footer fijo en móvil dentro de layout/main.php */
@media (max-width: 768px) {
  body > footer {
    left: 0 !important;
  }
}

/* Salvaguarda 3: Espacio inferior suficiente para que el footer fijo y el botón
   flotante nunca tapen paginación ni botones de formulario */
.page-content {
  padding-bottom: 4.75rem !important;
}

body > .container.pb-5 {
  padding-bottom: 5.25rem !important;
}

/* Salvaguarda 4: Altura flexible en barra superior cuando crece la fuente */
.topbar {
  min-height: var(--topbar-height, 62px);
  height: auto !important;
}

/* Salvaguarda 5: Evitar desbordamiento horizontal de palabras largas */
.card-body,
.page-card,
.descripcion-html,
.anuncio-content,
.msg-text,
.tl-body,
.legal-dialog-body {
  overflow-wrap: break-word;
}

/* ═══════════════════════════════════════════════════════════════════════════
   1. ESCALA TIPOGRÁFICA DINÁMICA (data-a11y-scale)
   Nota: En 100% (sin atributo) NO se fija font-size en html para respetar
   <meta name="text-scale" content="scale"> y la preferencia del sistema.
   ═══════════════════════════════════════════════════════════════════════════ */

html[data-a11y-scale="90"] {
  font-size: 90%;
}

html[data-a11y-scale="115"] {
  font-size: 115%;
}

html[data-a11y-scale="130"] {
  font-size: 130%;
}

html[data-a11y-scale="145"] {
  font-size: 145%;
}

/* Al ampliar el texto por encima de 100%, reforzar las etiquetas más pequeñas
   (.field-label, encabezados de tabla, pistas) para que ganen aún más claridad */
html:is([data-a11y-scale="115"], [data-a11y-scale="130"], [data-a11y-scale="145"])
  :is(.field-label, .lbl, .table thead th, .nav-section-label, .sidebar-brand-sub, .opt-tag, .pwd-rules, .user-role) {
  font-size: max(0.78rem, 13px) !important;
  color: var(--text-secondary, #475569);
}

html:is([data-a11y-scale="115"], [data-a11y-scale="130"], [data-a11y-scale="145"])
  #sidebar :is(.nav-section-label, .sidebar-brand-sub) {
  color: rgba(255, 255, 255, 0.72) !important;
}

/* Ampliar ligeramente el ancho del sidebar en escritorio cuando la letra es muy grande */
@media (min-width: 769px) {
  html[data-a11y-scale="130"] {
    --sidebar-width: 282px;
  }
  html[data-a11y-scale="145"] {
    --sidebar-width: 306px;
  }
}

/* En pantallas móviles táctiles, cuando el usuario amplía texto o usa controles,
   asegurar al menos 16px en inputs para evitar el auto-zoom brusco de iOS Safari */
@media (max-width: 768px) {
  html:is([data-a11y-scale="115"], [data-a11y-scale="130"], [data-a11y-scale="145"])
    :is(input, select, textarea, .form-control, .form-select) {
    font-size: max(1rem, 16px) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. ESPACIADO DE TEXTO AMPLIADO (data-a11y-spacing — WCAG 2.1 SC 1.4.12)
   ═══════════════════════════════════════════════════════════════════════════ */

html[data-a11y-spacing="wide"] body {
  line-height: 1.75 !important;
  letter-spacing: 0.04em !important;
  word-spacing: 0.08em !important;
}

html[data-a11y-spacing="wide"]
  :is(p, li, td, th, label, .field-value, .field-label, .sub, .msg-text, .descripcion-html, .anuncio-content, .form-control, .form-select, .btn):not(.sirce-a11y-root *) {
  line-height: 1.7 !important;
  letter-spacing: 0.04em !important;
  word-spacing: 0.08em !important;
}

html[data-a11y-spacing="xwide"] body {
  line-height: 1.95 !important;
  letter-spacing: 0.075em !important;
  word-spacing: 0.15em !important;
}

html[data-a11y-spacing="xwide"]
  :is(p, li, td, th, label, .field-value, .field-label, .sub, .msg-text, .descripcion-html, .anuncio-content, .form-control, .form-select, .btn):not(.sirce-a11y-root *) {
  line-height: 1.9 !important;
  letter-spacing: 0.075em !important;
  word-spacing: 0.15em !important;
}

html[data-a11y-spacing="xwide"] :is(p, .timeline-item, .anuncio-card, .msg-bubble):not(.sirce-a11y-root *) {
  margin-bottom: 1.15em !important;
}

html[data-a11y-spacing="xwide"] .sirce-table :is(th, td) {
  padding-top: 0.55rem !important;
  padding-bottom: 0.55rem !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. TIPOGRAFÍA DE LECTURA CLARA (data-a11y-font="readable")
   Protege los iconos de Bootstrap Icons (.bi) para no alterar sus glifos.
   ═══════════════════════════════════════════════════════════════════════════ */

html[data-a11y-font="readable"]
  :is(body, h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, input, select, textarea, button, .card-title, .page-title, .section-title, .brand, .form-box h2, .stat-value):not(.bi, [class^="bi-"], [class*=" bi-"]) {
  font-family: Verdana, Tahoma, "Trebuchet MS", Geneva, sans-serif !important;
  letter-spacing: 0.015em;
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. RESALTAR ENLACES Y CONTROLES INTERACTIVOS (data-a11y-links="1")
   ═══════════════════════════════════════════════════════════════════════════ */

html[data-a11y-links="1"] a:not(.sirce-a11y-root *) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  font-weight: 700 !important;
}

html[data-a11y-links="1"]
  :is(button, .btn, input, select, textarea, [role="button"], .page-link):not(.sirce-a11y-root *) {
  outline: 2px solid var(--uv-blue, #003e6b) !important;
  outline-offset: 1px !important;
}

html[data-a11y-links="1"]:is([data-a11y-theme="dark"], [data-a11y-theme="contrast"])
  :is(button, .btn, input, select, textarea, [role="button"], .page-link):not(.sirce-a11y-root *) {
  outline: 2px solid #facc15 !important;
}

/* Indicador de foco accesible de alto contraste en todo el sistema */
:where(a:any-link, button, input, select, textarea, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid #f59e0b !important;
  outline-offset: 2px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. MODOS DE COLOR Y CONTRASTE (data-a11y-theme)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 5A. MODO OSCURO (dark) ─────────────────────────────────────────────── */
html[data-a11y-theme="dark"] {
  color-scheme: dark;
  --surface: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-light: #1e293b;
}

html[data-a11y-theme="dark"] body {
  background-color: #0f172a !important;
  color: #f1f5f9 !important;
}

html[data-a11y-theme="dark"] :is(.card, .page-card, .sim-stepper-card, .scenario-card, .modal-content, .sirce-legal-dialog, .swal2-popup, .sirce-ui-lock-card) {
  background: #1e293b !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

html[data-a11y-theme="dark"] :is(.card-header, .card-section-header, .modal-header, .modal-footer, .legal-dialog-footer) {
  background: #192335 !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-a11y-theme="dark"] .topbar:not(.portal-topbar-uv) {
  background: rgba(15, 23, 42, 0.92) !important;
  border-bottom-color: #334155 !important;
}

/* Mantener topbar azul del portal de alumnos con tono oscuro elegante */
html[data-a11y-theme="dark"] nav.topbar {
  background: #0b2540 !important;
  border-bottom: 1px solid #334155 !important;
}

html[data-a11y-theme="dark"] :is(.login-form-panel, .step-item, .step-circle) {
  background: #0f172a !important;
  color: #f1f5f9 !important;
}

html[data-a11y-theme="dark"] :is(h1, h2, h3, h4, h5, h6, .page-title, .section-title, .card-section-title, .card-title-text, .field-value, .form-box h2, .anuncio-card h6, .anuncio-card .anuncio-content strong, .text-dark) {
  color: #f8fafc !important;
}

html[data-a11y-theme="dark"] :is(.page-subtitle, .form-box .sub, .lbl, .field-label, .form-label, .stat-label, .step-label, .anuncio-card .anuncio-content, .descripcion-html, .msg-bubble .msg-text, .legal-dialog-body, .text-secondary, .text-muted) {
  color: #cbd5e1 !important;
}

html[data-a11y-theme="dark"] :is(.form-control, .form-select, .inp-wrap input, .input-group-text, .ql-toolbar, .ql-container) {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

html[data-a11y-theme="dark"] :is(.form-control, .inp-wrap input)::placeholder {
  color: #94a3b8 !important;
}

html[data-a11y-theme="dark"] :is(.anuncio-card, .descripcion-html, .tl-body, .current-file-box, .legal-notice-box, .legal-highlight-card, .msg-bubble) {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-a11y-theme="dark"] :is(.table, .sirce-table) {
  color: #f1f5f9 !important;
  --bs-table-bg: transparent;
  --bs-table-color: #f1f5f9;
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-table-hover-color: #ffffff;
}

html[data-a11y-theme="dark"] .table thead th,
html[data-a11y-theme="dark"] .table thead {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

html[data-a11y-theme="dark"] .table td {
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-a11y-theme="dark"] :is(.dropdown-menu) {
  background: #1e293b !important;
  border-color: #475569 !important;
}

html[data-a11y-theme="dark"] .dropdown-item {
  color: #f1f5f9 !important;
}

html[data-a11y-theme="dark"] .dropdown-item:hover {
  background: #334155 !important;
}

html[data-a11y-theme="dark"] body > footer {
  background: rgba(15, 23, 42, 0.96) !important;
  border-top-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-a11y-theme="dark"] body > footer :is(strong, .footer-legal-btn) {
  color: #93c5fd !important;
}

html[data-a11y-theme="dark"] :is(.btn-back, .page-link) {
  background: #1e293b !important;
  color: #93c5fd !important;
  border-color: #475569 !important;
}

/* Adaptación de contenedores con fondos claros en línea dentro de vistas */
html[data-a11y-theme="dark"] [style*="background:#f8fafc"],
html[data-a11y-theme="dark"] [style*="background: #f8fafc"],
html[data-a11y-theme="dark"] [style*="background:#fff;"],
html[data-a11y-theme="dark"] [style*="background: #fff"] {
  background: #152033 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

/* ── 5B. MODO ALTO CONTRASTE OSCURO (contrast — WCAG AAA) ───────────────── */
html[data-a11y-theme="contrast"] {
  color-scheme: dark;
  --surface: #000000;
  --card-bg: #080808;
  --text-primary: #ffffff;
  --text-secondary: #f8fafc;
  --text-muted: #e2e8f0;
  --border-color: #ffffff;
  --border-light: #94a3b8;
}

html[data-a11y-theme="contrast"] body {
  background: #000000 !important;
  color: #ffffff !important;
}

html[data-a11y-theme="contrast"] :is(.card, .page-card, .sim-stepper-card, .scenario-card, .modal-content, .sirce-legal-dialog, .swal2-popup, .sirce-ui-lock-card, .anuncio-card, .descripcion-html, .tl-body, .current-file-box, .legal-notice-box, .legal-highlight-card, .msg-bubble, .err-box, .revision-indicator, .evidencia-aviso) {
  background: #050505 !important;
  color: #ffffff !important;
  border: 1.5px solid #ffffff !important;
  box-shadow: none !important;
}

html[data-a11y-theme="contrast"] :is(.card-header, .card-section-header, .modal-header, .modal-footer, .legal-dialog-header, .legal-dialog-footer, .topbar, nav.topbar, #sidebar, .sim-header, .login-hero) {
  background: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

html[data-a11y-theme="contrast"] #sidebar {
  border-right: 2px solid #ffffff !important;
}

html[data-a11y-theme="contrast"] .topbar,
html[data-a11y-theme="contrast"] nav.topbar {
  border-bottom: 2px solid #ffffff !important;
}

html[data-a11y-theme="contrast"] :is(.login-form-panel, .step-item, .step-circle) {
  background: #000000 !important;
  color: #ffffff !important;
}

html[data-a11y-theme="contrast"] :is(h1, h2, h3, h4, h5, h6, p, span, div, label, td, th, li):not(.sirce-a11y-root *) {
  color: #ffffff !important;
}

html[data-a11y-theme="contrast"] :is(a, .legal-link-btn, .footer-legal-btn, .btn-back):not(.sirce-a11y-root *) {
  color: #fde047 !important;
  text-decoration: underline !important;
}

html[data-a11y-theme="contrast"] :is(.btn-uv, .btn-go, .btn-primary, .btn-legal-accept):not(.sirce-a11y-root *) {
  background: #fde047 !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
  font-weight: 800 !important;
}

html[data-a11y-theme="contrast"] :is(.btn-uv, .btn-go, .btn-primary, .btn-legal-accept):not(.sirce-a11y-root *) :is(span, i) {
  color: #000000 !important;
}

html[data-a11y-theme="contrast"] :is(.form-control, .form-select, .inp-wrap input, .input-group-text, textarea, select, .ql-toolbar, .ql-container):not(.sirce-a11y-root *) {
  background: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

html[data-a11y-theme="contrast"] .table thead th,
html[data-a11y-theme="contrast"] .table thead {
  background: #111111 !important;
  color: #fde047 !important;
  border-bottom: 2px solid #ffffff !important;
}

html[data-a11y-theme="contrast"] .table td {
  background: #000000 !important;
  color: #ffffff !important;
  border-bottom: 1px solid #ffffff !important;
}

html[data-a11y-theme="contrast"] body > footer {
  background: #000000 !important;
  border-top: 2px solid #ffffff !important;
  color: #ffffff !important;
}

/* ── 5C. MODO LECTURA CÁLIDA / SEPIA (warm) ─────────────────────────────── */
html[data-a11y-theme="warm"] {
  color-scheme: light;
  --surface: #f3ead6;
  --card-bg: #fcf6e8;
  --text-primary: #2b2117;
  --text-secondary: #5a4633;
  --text-muted: #786048;
  --border-color: #d8c6a8;
  --border-light: #e7d8be;
}

html[data-a11y-theme="warm"] body,
html[data-a11y-theme="warm"] .login-form-panel {
  background-color: #f3ead6 !important;
  color: #2b2117 !important;
}

html[data-a11y-theme="warm"] :is(.card, .page-card, .sim-stepper-card, .scenario-card, .modal-content, .sirce-legal-dialog, .swal2-popup) {
  background: #fcf6e8 !important;
  color: #2b2117 !important;
  border-color: #d8c6a8 !important;
}

html[data-a11y-theme="warm"] :is(.card-header, .card-section-header, .modal-header, .modal-footer, .legal-dialog-footer, .anuncio-card, .descripcion-html, .tl-body, .current-file-box, .legal-notice-box, .msg-bubble) {
  background: #f5ebd8 !important;
  border-color: #d8c6a8 !important;
  color: #2b2117 !important;
}

html[data-a11y-theme="warm"] .topbar:not(nav.topbar) {
  background: rgba(252, 246, 232, 0.92) !important;
  border-bottom-color: #d8c6a8 !important;
}

html[data-a11y-theme="warm"] :is(.form-control, .form-select, .inp-wrap input, .input-group-text, .ql-container) {
  background-color: #fffdf7 !important;
  color: #2b2117 !important;
  border-color: #c8b290 !important;
}

html[data-a11y-theme="warm"] .table thead th,
html[data-a11y-theme="warm"] .table thead {
  background: #efe3ca !important;
  color: #4a3826 !important;
  border-color: #d8c6a8 !important;
}

html[data-a11y-theme="warm"] .table td {
  border-color: #e7d8be !important;
  color: #2b2117 !important;
}

html[data-a11y-theme="warm"] body > footer {
  background: rgba(243, 234, 214, 0.96) !important;
  border-top-color: #d8c6a8 !important;
  color: #5a4633 !important;
}

/* ── 5D. MODO ESCALA DE GRISES (grayscale) ──────────────────────────────── */
/* Se aplica mediante una capa fija pasiva (pointer-events: none) con backdrop-filter
   para NO romper ningún elemento position: fixed del sistema. */
#sirceA11yGrayscaleLayer {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483640;
  backdrop-filter: grayscale(1);
  -webkit-backdrop-filter: grayscale(1);
}

html[data-a11y-theme="grayscale"] #sirceA11yGrayscaleLayer {
  display: block;
}

/* Soporte complementario para elementos <dialog> en Top Layer */
html[data-a11y-theme="grayscale"] dialog:not(.sirce-a11y-dialog) {
  filter: grayscale(1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. PUNTERO GRANDE Y REDUCCIÓN DE ANIMACIONES
   ═══════════════════════════════════════════════════════════════════════════ */

@media (pointer: fine) {
  html[data-a11y-cursor="large"],
  html[data-a11y-cursor="large"] body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M7 4 L7 36 L16 27 L22 40 L28 37 L22 24 L34 24 Z' fill='%23000000' stroke='%23ffffff' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") 6 4, auto !important;
  }

  html[data-a11y-cursor="large"] :is(a, button, .btn, [role="button"], input[type="submit"], input[type="button"], select, summary, label[for], .sirce-sortable) {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Ccircle cx='18' cy='18' r='14' fill='%23facc15' fill-opacity='0.45' stroke='%23000000' stroke-width='2.5'/%3E%3Cpath d='M12 10 L12 34 L19 27 L24 37 L28 35 L23 25 L32 25 Z' fill='%23003E6B' stroke='%23ffffff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 12 10, pointer !important;
  }
}

/* Reducción de movimiento en componentes de SIRCE */
html[data-a11y-motion="reduce"] :is(.page-content, .stat-card, .scenario-card, .btn, .btn-uv, .btn-go, #sidebar, .collapse-chevron, .step-circle, .stepper-progress) {
  animation: none !important;
  transition: none !important;
}

html[data-a11y-motion="reduce"] :is(.stat-card:hover, .scenario-card:hover, .btn-uv:hover, .btn-go:hover) {
  transform: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   7. LÍNEA GUÍA DE LECTURA (Regla horizontal con soporte de ratón y táctil)
   ═══════════════════════════════════════════════════════════════════════════ */

#sirceA11yReadingGuide {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 38px;
  transform: translate3d(0, var(--a11y-guide-y, 240px), 0);
  pointer-events: none;
  z-index: 2147483642;
  background: rgba(250, 204, 21, 0.16);
  border-top: 2px solid #003e6b;
  border-bottom: 3px solid #f59e0b;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.14);
}

html[data-a11y-guide="1"] #sirceA11yReadingGuide {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Manija lateral táctil/arrastrable para mover la regla en celulares y tabletas */
.sirce-a11y-guide-handle {
  pointer-events: auto;
  touch-action: none;
  cursor: ns-resize;
  background: #003e6b;
  color: #ffffff;
  border: 2px solid #facc15;
  border-radius: 999px;
  padding: 4px 10px;
  margin-right: 12px;
  font-family: "DM Sans", system-ui, sans-serif !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-user-select: none;
}

html[data-a11y-pos="right"] .sirce-a11y-guide-handle {
  margin-right: auto;
  margin-left: 12px;
}

/* En escritorio con ratón fino, la manija es discreta; en táctil es más amplia */
@media (pointer: fine) {
  .sirce-a11y-guide-handle {
    opacity: 0.75;
  }
  .sirce-a11y-guide-handle:hover,
  .sirce-a11y-guide-handle:focus-visible {
    opacity: 1;
  }
}

@media (pointer: coarse) {
  .sirce-a11y-guide-handle {
    padding: 7px 13px;
    font-size: 13px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   8. WIDGET FLOTANTE Y PANEL DE ACCESIBILIDAD (.sirce-a11y-root)
   Medidas aisladas en px para que el propio menú NUNCA se deforme al subir
   el tamaño de fuente de la página al 145%.
   ═══════════════════════════════════════════════════════════════════════════ */

.sirce-a11y-root,
.sirce-a11y-root * {
  box-sizing: border-box;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
}

/* Botón Flotante (Globo) */
.sirce-a11y-trigger {
  position: fixed;
  bottom: calc(50px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 2147483645;
  width: 66px;
  height: 66px;
  border-radius: 999px;
  background: linear-gradient(135deg, #003e6b 0%, #006f4f 100%);
  color: #ffffff !important;
  border: 3px solid #ffffff;
  box-shadow: 0 10px 28px rgba(0, 38, 66, 0.42), 0 3px 8px rgba(0, 0, 0, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, width 0.2s ease, border-radius 0.2s ease;
  text-decoration: none !important;
}

.sirce-a11y-trigger:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 32px rgba(0, 38, 66, 0.52);
}

.sirce-a11y-trigger i {
  font-size: 34px !important;
  line-height: 1 !important;
  color: #ffffff !important;
}

/* Posición a la izquierda */
html[data-a11y-pos="left"] .sirce-a11y-trigger {
  right: auto;
  left: 20px;
}

/* Modo pestaña lateral compacta (Ideal para pantallas móviles pequeñas) */
html[data-a11y-compact="1"] .sirce-a11y-trigger {
  right: 0;
  width: 44px;
  height: 54px;
  border-radius: 16px 0 0 16px;
  border-right: none;
  opacity: 0.94;
}

html[data-a11y-pos="left"][data-a11y-compact="1"] .sirce-a11y-trigger {
  left: 0;
  right: auto;
  border-radius: 0 16px 16px 0;
  border-left: none;
  border-right: 3px solid #ffffff;
}

html[data-a11y-compact="1"] .sirce-a11y-trigger i {
  font-size: 25px !important;
}

/* Punto indicador cuando hay alguna preferencia activa distinta a la predeterminada */
.sirce-a11y-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #facc15;
  border: 2.5px solid #003e6b;
  display: none;
}

html[data-a11y-active="1"] .sirce-a11y-badge {
  display: block;
}

/* Panel desplegable (Soporta Popover API nativo + clase fallback .is-open) */
.sirce-a11y-panel {
  position: fixed;
  inset: auto 20px calc(124px + env(safe-area-inset-bottom, 0px)) auto;
  margin: 0;
  padding: 0;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 140px);
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 18px !important;
  box-shadow: 0 22px 48px -10px rgba(2, 6, 23, 0.35), 0 6px 16px -4px rgba(2, 6, 23, 0.15) !important;
  z-index: 2147483646;
  overflow: hidden;
  display: none;
  flex-direction: column;
  font-size: 14px !important;
  line-height: 1.4 !important;
}

/* Compatibilidad con Popover API nativo y polyfill (\:popover-open) + fallback manual */
.sirce-a11y-panel:is(:popover-open, .\:popover-open, .is-open) {
  display: flex !important;
}

html[data-a11y-pos="left"] .sirce-a11y-panel {
  right: auto;
  left: 20px;
}

/* Cabecera del panel */
.sirce-a11y-header {
  background: linear-gradient(135deg, #003e6b 0%, #00503a 100%) !important;
  color: #ffffff !important;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 3px solid #f2a900;
  flex-shrink: 0;
}

.sirce-a11y-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sirce-a11y-title-wrap i {
  font-size: 20px !important;
  color: #facc15 !important;
}

.sirce-a11y-title {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  margin: 0 !important;
  line-height: 1.2 !important;
}

.sirce-a11y-subtitle {
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.8) !important;
  margin: 1px 0 0 0 !important;
  display: block;
}

.sirce-a11y-close {
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  color: #ffffff !important;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.sirce-a11y-close:hover {
  background: rgba(255, 255, 255, 0.28) !important;
}

/* Cuerpo desplazable del panel */
.sirce-a11y-body {
  padding: 14px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff !important;
  color: #0f172a !important;
}

.sirce-a11y-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sirce-a11y-section-label {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  color: #475569 !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Control Stepper de Tamaño de Texto */
.sirce-a11y-scale-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9 !important;
  padding: 5px;
  border-radius: 11px;
  border: 1px solid #e2e8f0;
}

.sirce-a11y-scale-step {
  background: #ffffff !important;
  color: #003e6b !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px;
  height: 36px;
  min-width: 48px;
  padding: 0 10px;
  font-size: 14px !important;
  font-weight: 800 !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.sirce-a11y-scale-step:hover:not(:disabled) {
  background: #e2e8f0 !important;
}

.sirce-a11y-scale-step:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sirce-a11y-scale-value {
  flex: 1;
  text-align: center;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
}

/* Botones rápidos de porcentaje */
.sirce-a11y-scale-presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.sirce-a11y-preset-btn {
  background: #f8fafc !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 7px;
  padding: 6px 2px;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  text-align: center;
}

.sirce-a11y-preset-btn[aria-pressed="true"] {
  background: #003e6b !important;
  color: #ffffff !important;
  border-color: #003e6b !important;
  font-weight: 700 !important;
}

/* Cuadrícula de botones de opciones */
.sirce-a11y-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.sirce-a11y-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sirce-a11y-btn {
  background: #f8fafc !important;
  color: #1e293b !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 10px;
  padding: 9px 10px;
  min-height: 44px;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.sirce-a11y-btn i {
  font-size: 16px !important;
  color: #003e6b !important;
  flex-shrink: 0;
}

.sirce-a11y-btn:hover {
  background: #f1f5f9 !important;
  border-color: #94a3b8 !important;
}

.sirce-a11y-btn[aria-pressed="true"] {
  background: #edf7f3 !important;
  color: #00503a !important;
  border-color: #006f4f !important;
  box-shadow: inset 0 0 0 1px #006f4f;
  font-weight: 700 !important;
}

.sirce-a11y-btn[aria-pressed="true"] i {
  color: #006f4f !important;
}

/* Ocultar opción de puntero grande en pantallas táctiles donde no existe cursor */
@media (pointer: coarse) {
  .sirce-a11y-desktop-only {
    display: none !important;
  }
}

/* Selector de Temas de Color */
.sirce-a11y-theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.sirce-a11y-theme-btn {
  background: #f8fafc !important;
  color: #1e293b !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 9px;
  padding: 7px 4px;
  min-height: 54px;
  font-size: 11px !important;
  font-weight: 600 !important;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  line-height: 1.15 !important;
}

.sirce-a11y-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px !important;
  font-weight: 800 !important;
}

.sirce-a11y-theme-btn[aria-pressed="true"] {
  border-color: #003e6b !important;
  background: #e0f2fe !important;
  color: #003e6b !important;
  box-shadow: inset 0 0 0 1px #003e6b;
  font-weight: 700 !important;
}

/* Pie del panel */
.sirce-a11y-footer {
  padding: 10px 16px;
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.sirce-a11y-reset-btn {
  background: #ffffff !important;
  color: #b91c1c !important;
  border: 1px solid #fca5a5 !important;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
}

.sirce-a11y-reset-btn:hover {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   9. ADAPTACIÓN MÓVIL (Bandeja inferior / Bottom Sheet en <= 576px)
   Deja visible el 35% superior de la pantalla para previsualizar en vivo.
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 576px) {
  .sirce-a11y-trigger {
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    right: 14px;
  }

  .sirce-a11y-trigger i {
    font-size: 29px !important;
  }

  html[data-a11y-pos="left"] .sirce-a11y-trigger {
    left: 14px;
    right: auto;
  }

  .sirce-a11y-panel {
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 68dvh !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sirce-a11y-body {
    padding: 12px 14px;
    gap: 12px;
  }
}

