:root {
    --tibdas-font-scale-percentage: 100%;
}

.tibdas-widget-root {
    all: initial !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147482900 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
    color-scheme: light !important;
}

.tibdas-widget-root .tibdas-launcher,
.tibdas-widget-root .tibdas-panel {
    pointer-events: auto !important;
}

/* L'agrandissement est appliqué par JavaScript afin de prendre également en
 * charge les applications qui utilisent des tailles de caractères en pixels. */

.tibdas-launcher,
.tibdas-panel,
.tibdas-launcher *,
.tibdas-panel * {
    box-sizing: border-box;
}

.tibdas-launcher {
    position: fixed;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    background: var(--tibdas-primary, #1F4B99);
    color: var(--tibdas-launcher-text, #FFFFFF);
    font: 700 14px/1.2 Arial, sans-serif;
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.30);
    cursor: pointer;
}

.tibdas-launcher:focus-visible,
.tibdas-panel button:focus-visible {
    outline: 4px solid #FBBF24 !important;
    outline-offset: 3px !important;
}

.tibdas-shape-round {
    border-radius: 999px;
}

.tibdas-shape-square {
    border-radius: 12px;
}

.tibdas-shape-pill {
    border-radius: 999px;
    padding-inline: 18px !important;
}

.tibdas-size-small {
    min-width: 46px;
    min-height: 46px;
    padding: 10px;
}

.tibdas-size-medium {
    min-width: 58px;
    min-height: 58px;
    padding: 13px;
}

.tibdas-size-large {
    min-width: 72px;
    min-height: 72px;
    padding: 16px;
    font-size: 16px;
}

.tibdas-position-top-left {
    top: var(--tibdas-offset-y, 24px);
    left: var(--tibdas-offset-x, 24px);
}

.tibdas-position-top-right {
    top: var(--tibdas-offset-y, 24px);
    right: var(--tibdas-offset-x, 24px);
}

.tibdas-position-middle-left {
    top: 50%;
    left: var(--tibdas-offset-x, 24px);
    transform: translateY(-50%);
}

.tibdas-position-middle-right {
    top: 50%;
    right: var(--tibdas-offset-x, 24px);
    transform: translateY(-50%);
}

.tibdas-position-bottom-left {
    bottom: var(--tibdas-offset-y, 24px);
    left: var(--tibdas-offset-x, 24px);
}

.tibdas-position-bottom-right {
    right: var(--tibdas-offset-x, 24px);
    bottom: var(--tibdas-offset-y, 24px);
}

.tibdas-launcher-icon {
    font-size: 1.25em;
}

.tibdas-launcher-label[data-desktop="hide"] {
    display: none;
}

.tibdas-panel {
    position: fixed;
    right: 24px;
    bottom: 105px;
    z-index: 2147482999;
    width: min(410px, calc(100vw - 28px));
    max-height: min(760px, calc(100vh - 130px));
    overflow: auto;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 20px;
    background: #FFFFFF;
    color: #101828;
    font: 400 15px/1.45 Arial, sans-serif;
    box-shadow: 0 18px 60px rgba(16, 24, 40, 0.30);
}

.tibdas-panel[hidden] {
    display: none !important;
}

.tibdas-panel-for-bottom-left,
.tibdas-panel-for-middle-left,
.tibdas-panel-for-top-left {
    right: auto;
    left: 24px;
}

.tibdas-panel-for-top-left,
.tibdas-panel-for-top-right {
    top: 90px;
    bottom: auto;
}

.tibdas-panel-for-middle-left,
.tibdas-panel-for-middle-right {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

.tibdas-theme-dark {
    background: #111827;
    color: #F9FAFB;
}

@media (prefers-color-scheme: dark) {
    .tibdas-theme-auto {
        background: #111827;
        color: #F9FAFB;
    }
}

.tibdas-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

#tibdas-widget-root .tibdas-language-select {
    width: calc(100% - 28px);
    min-height: 42px;
    margin: 12px 14px 4px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}

.tibdas-header > div {
    display: grid;
}

.tibdas-header strong {
    font-size: 18px;
}

.tibdas-header small {
    margin-top: 3px;
    color: #667085;
}

.tibdas-theme-dark .tibdas-header small {
    color: #CBD5E1;
}

.tibdas-close {
    width: 38px;
    height: 38px;
    border: 1px solid #D0D5DD;
    border-radius: 10px;
    background: #F8FAFC;
    color: #101828;
    font-size: 24px;
    cursor: pointer;
}

.tibdas-section-title {
    margin: 20px 0 10px;
    font-size: 14px;
}

.tibdas-grid,
.tibdas-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tibdas-option {
    min-height: 48px;
    padding: 11px;
    border: 1px solid #D0D5DD;
    border-radius: 11px;
    background: #F8FAFC;
    color: #101828;
    font: 700 13px/1.25 Arial, sans-serif;
    cursor: pointer;
}

.tibdas-option[aria-pressed="true"] {
    border-color: var(--tibdas-primary, #1F4B99);
    background: #EAF1FF;
    box-shadow: inset 0 0 0 2px var(--tibdas-primary, #1F4B99);
}

.tibdas-theme-dark .tibdas-option {
    border-color: #475467;
    background: #1F2937;
    color: #F9FAFB;
}

.tibdas-scale-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 82px 1fr;
    align-items: center;
    gap: 10px;
}

.tibdas-zoom-group {
    margin-bottom: 2px;
}

.tibdas-scale-output {
    display: grid;
    min-height: 48px;
    place-items: center;
    border: 1px solid #D0D5DD;
    border-radius: 11px;
    background: #FFFFFF;
    color: #101828;
    font-weight: 800;
}

.tibdas-reset {
    width: 100%;
    margin-top: 16px;
}

.tibdas-powered {
    display: block;
    margin-top: 12px;
    text-align: center;
    color: #667085;
}

/* Effets d’accessibilité */

/* Le profil visuel améliore la clarté sans imposer le thème sombre. */
html.tibdas-visual-clarity body > :not(.tibdas-widget-root) {
    filter: brightness(1.1) contrast(1.12) saturate(1.04);
}

html.tibdas-high-contrast body {
    background:#05080f !important;
    color:#ffffff !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root),
html.tibdas-high-contrast body > :not(.tibdas-widget-root) :where(
    main,section,article,div,p,span,li,ul,ol,dl,dt,dd,
    h1,h2,h3,h4,h5,h6,table,thead,tbody,tfoot,tr,th,td,
    header,footer,nav,aside,details,summary,blockquote,pre,code
) {
    background-color:#05080f !important;
    color:#ffffff !important;
    border-color:#ffffff !important;
    text-shadow:none !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root) a,
html.tibdas-high-contrast body > :not(.tibdas-widget-root) a * {
    color:#ffdf33 !important;
    text-decoration:underline !important;
    text-decoration-thickness:2px !important;
    text-underline-offset:3px !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root) :where(button,input,select,textarea,[role="button"]) {
    background:#000000 !important;
    color:#ffffff !important;
    border:2px solid #ffffff !important;
    box-shadow:none !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root) :where(input,textarea)::placeholder {
    color:#e5e7eb !important;
    opacity:1 !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root) :where(button,a,input,select,textarea,[tabindex]):focus {
    outline:4px solid #00e5ff !important;
    outline-offset:3px !important;
}

html.tibdas-high-contrast body > :not(.tibdas-widget-root) :where(img,picture,video,canvas,svg) {
    filter:none !important;
}

html.tibdas-grayscale body > :not(.tibdas-widget-root) {
    filter: grayscale(1);
}

html.tibdas-high-contrast.tibdas-grayscale body > :not(.tibdas-widget-root) :where(img,picture,video,canvas,svg) {
    filter:grayscale(1) !important;
}

/* Le widget ne doit pas subir les filtres du site. */
html.tibdas-high-contrast .tibdas-launcher,
html.tibdas-high-contrast .tibdas-panel,
html.tibdas-grayscale .tibdas-launcher,
html.tibdas-grayscale .tibdas-panel {
    filter: none !important;
}

html.tibdas-underline-links body a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
}

html.tibdas-readable-font body,
html.tibdas-readable-font body button,
html.tibdas-readable-font body input,
html.tibdas-readable-font body select,
html.tibdas-readable-font body textarea {
    font-family: Arial, Verdana, sans-serif !important;
}

html.tibdas-text-spacing body :where(
    p, li, a, span, label, button, input, select, textarea,
    h1, h2, h3, h4, h5, h6
) {
    letter-spacing: 0.08em !important;
    word-spacing: 0.12em !important;
    line-height: 1.7 !important;
}

html.tibdas-stop-animations body > :not(.tibdas-widget-root),
html.tibdas-stop-animations body > :not(.tibdas-widget-root) *,
html.tibdas-stop-animations body > :not(.tibdas-widget-root) *::before,
html.tibdas-stop-animations body > :not(.tibdas-widget-root) *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

html.tibdas-highlight-focus body *:focus {
    outline: 4px solid #FBBF24 !important;
    outline-offset: 3px !important;
}

html.tibdas-hide-images body img,
html.tibdas-hide-images body picture,
html.tibdas-hide-images body video {
    visibility: hidden !important;
}

html.tibdas-large-cursor body,
html.tibdas-large-cursor body * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M3 3l12 32 5-11 11-5z' fill='white' stroke='black' stroke-width='3'/%3E%3C/svg%3E") 3 3, auto !important;
}

html.tibdas-reading-guide-active body::after {
    content: "";
    position: fixed;
    top: 48%;
    right: 0;
    left: 0;
    z-index: 2147482000;
    height: 58px;
    border-top: 3px solid #FBBF24;
    border-bottom: 3px solid #FBBF24;
    background: rgba(251, 191, 36, 0.15);
    pointer-events: none;
}

@media (max-width: 640px) {
    .tibdas-launcher-label[data-mobile="hide"] {
        display: none;
    }

    .tibdas-launcher-label[data-mobile="show"] {
        display: inline;
    }

    .tibdas-panel,
    .tibdas-panel-for-bottom-left,
    .tibdas-panel-for-middle-left,
    .tibdas-panel-for-top-left,
    .tibdas-panel-for-top-right,
    .tibdas-panel-for-middle-right {
        top: auto;
        right: 14px;
        bottom: 92px;
        left: 14px;
        width: auto;
        max-height: calc(100vh - 110px);
        transform: none;
    }

    .tibdas-grid,
    .tibdas-profile-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Bloc 20.3 — guidage de page, formulaires et TIB Brain */
.tibdas-panel {
    width: min(470px, calc(100vw - 28px));
    max-height: 75vh;
    padding: 0;
    border: 0;
    border-radius: 22px 22px 18px 18px;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 transparent;
}
.tibdas-header {
    position: sticky;
    top: 0;
    z-index: 5;
    align-items: center;
    padding: 18px 18px;
    border-radius: 20px 20px 0 0;
    background: var(--tibdas-primary, #1F4B99);
    color: var(--tibdas-launcher-text, #fff);
}
.tibdas-header strong { font-size: 19px; }
.tibdas-header small { color: inherit !important; opacity: .86; }
.tibdas-close { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.12); color: inherit; }
.tibdas-section-title { margin: 20px 18px 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: #334155; }
.tibdas-grid,.tibdas-profile-grid { padding: 0 18px; gap: 9px; }
.tibdas-profile-grid .tibdas-option { justify-content: flex-start; text-align: left; }
.tibdas-option {
    position: relative;
    min-height: 52px;
    padding: 11px 38px 11px 13px;
    border-color: #d7e0ed;
    background: #fff;
    color: #13233a;
    text-align: left;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.tibdas-option:hover { border-color: var(--tibdas-primary,#1F4B99); transform: translateY(-1px); }
.tibdas-option[aria-pressed="true"] { background: #edf4ff; }
.tibdas-option[data-tibdas-state]::after,.tibdas-option[data-tibdas-profile]::after {
    content: "OFF";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 29px;
    padding: 3px 5px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 9px;
    text-align: center;
}
.tibdas-option[aria-pressed="true"]::after { content: "ON"; background: var(--tibdas-primary,#1F4B99); color:#fff; }
.tibdas-scale-group { padding: 0; }
.tibdas-advanced-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 14px 18px 0;
}
.tibdas-advanced-actions .tibdas-option {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding-right: 13px;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.tibdas-page-navigation { margin: 8px 18px 0; padding: 10px; border: 1px solid #d7e0ed; border-radius: 12px; background:#f8fafc; }
.tibdas-heading-link { display:block; width:100%; padding:8px 10px; border:0; border-radius:8px; background:transparent; color:#16355f; text-align:left; cursor:pointer; }
.tibdas-heading-link:hover { background:#eaf2ff; }
.tibdas-level-2 { padding-left:22px; }.tibdas-level-3 { padding-left:34px; font-size:12px; }
.tibdas-ai-card { margin: 20px 18px 0; padding: 15px; border: 1px solid #bfd2f2; border-radius: 16px; background: linear-gradient(145deg,#f5f9ff,#eef3ff); }
.tibdas-ai-card .tibdas-section-title { margin:0 0 8px; color:#143b78; }
.tibdas-ai-card p { margin:0 0 10px; color:#475569; font-size:13px; }
.tibdas-ai-card textarea { box-sizing:border-box; width:100%; resize:vertical; padding:10px; border:1px solid #b8c6da; border-radius:10px; background:#fff; color:#17263b; font:400 14px/1.45 Arial,sans-serif; }
.tibdas-ai-actions { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin-top:9px; }
.tibdas-ai-actions button { min-height:40px; border:0; border-radius:9px; background:var(--tibdas-primary,#1F4B99); color:#fff; font-weight:700; cursor:pointer; }
.tibdas-ai-actions button:disabled { opacity:.55; cursor:wait; }
.tibdas-ai-output { margin-top:10px; padding:11px; border-radius:10px; background:#fff; color:#17263b; white-space:pre-wrap; }
.tibdas-ai-output:empty { display:none; }
.tibdas-ai-card small { display:block; margin-top:8px; color:#64748b; }
.tibdas-assistant-request-actions { display:grid; grid-template-columns:1fr 1.35fr; gap:7px; margin-top:9px; }
.tibdas-assistant-request-actions button,
.tibdas-ai-confirm-actions button,
.tibdas-ai-undo {
    min-height:42px; padding:9px 11px; border:1px solid var(--tibdas-primary,#1F4B99);
    border-radius:9px; background:var(--tibdas-primary,#1F4B99); color:#fff;
    font-weight:700; cursor:pointer;
}
.tibdas-assistant-request-actions button:first-child { background:#fff; color:var(--tibdas-primary,#1F4B99); }
.tibdas-assistant-request-actions button:disabled,
.tibdas-ai-confirm-actions button:disabled { opacity:.55; cursor:wait; }
.tibdas-ai-proposal { margin-top:12px; padding:12px; border:1px solid #9db9e5; border-radius:12px; background:#fff; }
.tibdas-ai-proposal-summary { margin:0 0 10px !important; color:#17263b !important; font-weight:700; }
.tibdas-ai-proposal-list { display:grid; gap:7px; }
.tibdas-ai-proposal-item { display:grid; grid-template-columns:22px 1fr; gap:8px; align-items:start; padding:9px; border:1px solid #d7e0ed; border-radius:9px; cursor:pointer; }
.tibdas-ai-proposal-item input { width:18px; height:18px; margin:2px 0 0; accent-color:var(--tibdas-primary,#1F4B99); }
.tibdas-ai-proposal-item strong { display:block; color:#17263b; font-size:13px; }
.tibdas-ai-proposal-item small { margin:3px 0 0; font-size:11px; }
.tibdas-ai-confirm-actions { display:grid; grid-template-columns:1.45fr .75fr; gap:7px; margin-top:10px; }
.tibdas-ai-confirm-actions .is-secondary { background:#fff; color:var(--tibdas-primary,#1F4B99); }
.tibdas-ai-undo { width:100%; margin-top:10px; background:#fff; color:var(--tibdas-primary,#1F4B99); }
.tibdas-ai-divider { display:flex; align-items:center; gap:8px; margin:18px 0 10px; color:#334155; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.04em; }
.tibdas-ai-divider::after { content:""; flex:1; height:1px; background:#cbd5e1; }
.tibdas-page-guide { margin-top:18px; padding-top:2px; border-top:1px solid #cbd5e1; }
.tibdas-page-guide .tibdas-section-title { margin:14px 0 7px; color:#143b78; }
.tibdas-page-guide > p { margin-bottom:8px; }
.tibdas-page-guide input[type="search"] { box-sizing:border-box; width:100%; min-height:42px; padding:9px 11px; border:1px solid #b8c6da; border-radius:9px; background:#fff; color:#17263b; }
.tibdas-page-guide-actions { display:grid; grid-template-columns:.7fr 1fr 1.15fr; gap:6px; margin-top:8px; }
.tibdas-page-guide-actions button,
.tibdas-page-guide-output button { min-height:40px; padding:8px 9px; border:1px solid var(--tibdas-primary,#1F4B99); border-radius:9px; background:#fff; color:var(--tibdas-primary,#1F4B99); font-weight:700; cursor:pointer; }
.tibdas-page-guide-actions button:first-child { background:var(--tibdas-primary,#1F4B99); color:#fff; }
.tibdas-page-guide-actions button:disabled { opacity:.55; cursor:wait; }
.tibdas-page-guide-output { display:grid; gap:6px; margin-top:9px; }
.tibdas-page-guide-output:empty { display:none; }
.tibdas-page-guide-output p { margin:0 !important; padding:9px; border-radius:8px; background:#fff; color:#334155 !important; }
.tibdas-page-guide-output button { width:100%; text-align:left; }
.tibdas-global-ai { margin-top:18px; padding:14px; border:1px solid #9db9e8; border-radius:14px; background:#fff; }
.tibdas-global-ai .tibdas-section-title { margin:0 0 7px; color:#143b78; }
.tibdas-global-ai > p { margin-bottom:9px; }
.tibdas-global-ai-actions { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin-top:9px; }
.tibdas-global-ai-actions button,
.tibdas-ai-speech-actions button { min-height:42px; padding:8px 10px; border:1px solid var(--tibdas-primary,#1F4B99); border-radius:9px; background:#fff; color:var(--tibdas-primary,#1F4B99); font-weight:700; cursor:pointer; }
.tibdas-global-ai-actions button:nth-child(2),
.tibdas-global-ai-actions button:nth-child(3) { background:var(--tibdas-primary,#1F4B99); color:#fff; }
.tibdas-global-ai-actions button:disabled { opacity:.55; cursor:wait; }
.tibdas-global-ai-output { border:1px solid #d7e1f0; line-height:1.55; }
.tibdas-ai-speech-actions { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin-top:8px; }
.tibdas-ai-speech-actions[hidden] { display:none; }
.tibdas-ai-speech-actions button:last-child { border-color:#64748b; color:#475569; }
.tibdas-ai-site-sources { display:grid; gap:6px; margin-top:12px; padding:10px; border:1px solid #cbd8ea; border-radius:10px; background:#f7faff; font-size:12px; }
.tibdas-ai-site-sources[hidden] { display:none!important; }
.tibdas-ai-site-sources a { color:#064fc4; text-decoration:underline; overflow-wrap:anywhere; }
.tibdas-voice-language { display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center; margin-top:8px; font-size:12px; font-weight:700; }
.tibdas-voice-language select { min-height:38px; padding:6px 30px 6px 9px; border:1px solid #9db9e8; border-radius:9px; background:#fff; color:#102b55; font-weight:700; }
.tibdas-target-highlight { outline:4px solid #f59e0b !important; outline-offset:4px !important; border-radius:3px; }
.tibdas-notice { position:sticky; bottom:0; z-index:6; margin:12px 18px; padding:10px 12px; border-radius:10px; background:#e8f7ee; color:#17633a; font-size:13px; }
.tibdas-notice.is-error { background:#fff0f0; color:#a52121; }
.tibdas-reset { width:calc(100% - 36px); margin:18px; }
.tibdas-powered { margin:0 18px 18px; }

@media (max-width: 390px) {
    .tibdas-advanced-actions { grid-template-columns: 1fr; }
    .tibdas-assistant-request-actions,
    .tibdas-ai-confirm-actions,
    .tibdas-page-guide-actions,
    .tibdas-global-ai-actions,
    .tibdas-ai-speech-actions { grid-template-columns:1fr; }
}
html.tibdas-reading-mask-active body::before,html.tibdas-reading-mask-active body::after { content:""; position:fixed; z-index:2147481900; left:0; right:0; height:calc(50vh - 42px); background:rgba(4,15,32,.64); pointer-events:none; }
html.tibdas-reading-mask-active body::before { top:0; } html.tibdas-reading-mask-active body::after { bottom:0; }
html.tibdas-form-assistant body > :not(.tibdas-widget-root) :is(input,select,textarea,button) { outline:3px solid #22c55e !important; outline-offset:2px !important; }
html.tibdas-epilepsy-safe body > :not(.tibdas-widget-root) { filter:saturate(.62) brightness(.94); }
html.tibdas-epilepsy-safe.tibdas-high-contrast body > :not(.tibdas-widget-root) { filter:saturate(.62) brightness(.94) contrast(1.2); }
@media (max-width:640px){.tibdas-panel{max-height:78vh}.tibdas-ai-actions{grid-template-columns:1fr}.tibdas-section-title{margin-top:16px}}
