.guru-launcher {
    position: fixed;
    z-index: 90;
    right: 24px;
    bottom: 22px;
    width: 96px;
    height: 96px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    filter: drop-shadow(0 12px 24px rgba(118, 87, 222, .42));
}

.guru-launcher:hover {
    filter: drop-shadow(0 14px 30px rgba(50, 213, 196, .44));
}

.guru-launcher:focus-visible,
.guru-panel button:focus-visible,
.guru-panel textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
    outline-offset: 3px;
}

.guru-launcher img,
.guru-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.guru-launcher > img {
    animation: guru-float 3.4s ease-in-out infinite;
}

.guru-launcher-label {
    position: absolute;
    right: 78px;
    bottom: 12px;
    width: 82px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 12px 12px 3px 12px;
    color: var(--text);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.guru-launcher[aria-expanded="false"]:hover .guru-launcher-label,
.guru-launcher[aria-expanded="false"]:focus-visible .guru-launcher-label {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.guru-panel {
    position: fixed;
    z-index: 100;
    right: 24px;
    bottom: 126px;
    width: min(430px, calc(100vw - 32px));
    height: min(650px, calc(100vh - 160px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--violet) 35%, var(--border));
    border-radius: 22px;
    color: var(--text);
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--surface-solid) 96%, var(--violet) 4%), var(--surface-solid));
    box-shadow: 0 28px 90px rgba(0, 0, 0, .42);
    transform: translateY(18px) scale(.98);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

.guru-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.guru-header {
    min-height: 88px;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    color: #fff;
    background: linear-gradient(135deg, #3d2478, #6548be 58%, #177f87);
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.guru-avatar {
    width: 64px;
    height: 64px;
    animation: guru-float-small 3.4s ease-in-out infinite;
    filter: drop-shadow(0 7px 14px rgba(0, 0, 0, .28));
}

.guru-heading strong,
.guru-heading small {
    display: block;
}

.guru-heading strong {
    margin-bottom: 4px;
    font-size: 15px;
    letter-spacing: -.01em;
}

.guru-heading small {
    color: rgba(255, 255, 255, .75);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
}

.guru-header-actions {
    display: flex;
    gap: 7px;
}

.guru-icon-button {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 11px;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    cursor: pointer;
    font-size: 17px;
}

.guru-icon-button:hover {
    background: rgba(255, 255, 255, .2);
}

.guru-context {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    color: var(--text-soft);
    background: color-mix(in srgb, var(--violet) 8%, transparent);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 750;
}

.guru-context span:last-child {
    color: var(--primary);
}

.guru-suggestions {
    display: flex;
    gap: 7px;
    padding: 10px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
}

.guru-suggestion {
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-soft);
    background: var(--surface-soft);
    cursor: pointer;
    font-size: 10px;
    font-weight: 750;
}

.guru-suggestion:hover {
    color: var(--text);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.guru-messages {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.guru-message {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 15px;
    font-size: 12px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.guru-message.user {
    align-self: flex-end;
    color: #061310;
    background: linear-gradient(135deg, #77eadb, var(--primary));
    border-bottom-right-radius: 4px;
}

.guru-message.assistant,
.guru-message.error {
    align-self: flex-start;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.guru-message.error {
    border-color: rgba(240, 109, 122, .42);
    color: #f7a8b0;
}

.guru-panel.dragging { transition: none; user-select: none; }
.guru-header { user-select: none; }

.guru-message.rich { white-space: normal; }
.guru-message.rich > :first-child { margin-top: 0; }
.guru-message.rich > :last-child { margin-bottom: 0; }
.guru-md-p { margin: 0 0 8px; }
.guru-md-title { margin: 12px 0 5px; font-size: 12.5px; font-weight: 850; color: var(--primary); }
.guru-md-list { margin: 0 0 8px; padding-left: 18px; }
.guru-md-list li { margin-bottom: 4px; }
.guru-md-rule { margin: 10px 0; border: 0; border-top: 1px solid var(--border); }

.guru-message a {
    color: var(--primary);
    text-decoration: underline;
}

.guru-message code {
    padding: 1px 5px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--bg) 65%, transparent);
    font-size: 11px;
}

.guru-action-card {
    align-self: stretch;
    padding: 13px;
    border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
    border-radius: 16px;
    background: color-mix(in srgb, var(--warning) 7%, var(--surface-solid));
}

.guru-action-card strong,
.guru-action-card small {
    display: block;
}

.guru-action-card > strong {
    color: var(--warning);
    font-size: 12px;
}

.guru-action-card > small {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 10px;
    line-height: 1.45;
}

.guru-action-list {
    display: grid;
    gap: 7px;
    margin: 11px 0;
    padding: 0;
    list-style: none;
}

.guru-action-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 9px;
    border-radius: 10px;
    color: var(--text-soft);
    background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
    font-size: 10px;
}

.guru-action-list b {
    color: var(--text);
}

.guru-apply {
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 11px;
    color: #061310;
    background: var(--primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 850;
}

.guru-apply:hover {
    background: color-mix(in srgb, var(--primary) 82%, #fff);
}

.guru-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.guru-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--violet);
    animation: guru-typing 1.1s infinite ease-in-out;
}

.guru-typing span:nth-child(2) { animation-delay: .15s; }
.guru-typing span:nth-child(3) { animation-delay: .3s; }

.guru-composer {
    padding: 11px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-solid) 96%, transparent);
}

.guru-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: end;
}

.guru-input {
    width: 100%;
    min-height: 42px;
    max-height: 112px;
    resize: none;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--text);
    background: var(--surface-soft);
    line-height: 1.45;
    font: inherit;
    font-size: 12px;
}

.guru-input::placeholder {
    color: var(--text-soft);
}

.guru-send {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 13px;
    color: #061310;
    background: var(--primary);
    cursor: pointer;
    font-size: 19px;
    font-weight: 900;
}

.guru-send:disabled,
.guru-input:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.guru-disclaimer {
    margin: 7px 2px 0;
    color: var(--text-soft);
    font-size: 8px;
    line-height: 1.35;
    text-align: center;
}

.guru-field-applied {
    outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent) !important;
    outline-offset: 3px;
    transition: outline-color .3s ease;
}

@keyframes guru-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-11px); }
}

@keyframes guru-float-small {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes guru-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Textes plus grands et fenêtre un peu plus large, pour une lecture plus confortable. */
.guru-panel { width: min(480px, calc(100vw - 32px)); height: min(700px, calc(100vh - 150px)); }
.guru-heading strong { font-size: 17px; }
.guru-heading small { font-size: 12px; }
.guru-context { font-size: 12px; }
.guru-suggestion { padding: 9px 12px; font-size: 12.5px; }
.guru-message { font-size: 14.5px; line-height: 1.6; }
.guru-message code { font-size: 13px; }
.guru-md-title { font-size: 15.5px; }
.guru-action-card > strong { font-size: 14px; }
.guru-action-card > small { font-size: 12px; }
.guru-action-list li { font-size: 12.5px; }
.guru-apply { font-size: 13px; }
.guru-input { font-size: 14.5px; }
.guru-disclaimer { font-size: 11px; }

@media (max-width: 700px) {
    .guru-launcher {
        right: 12px;
        bottom: 12px;
        width: 78px;
        height: 78px;
    }

    .guru-launcher-label {
        display: none;
    }

    .guru-panel {
        inset: 10px 10px 96px;
        width: auto;
        height: auto;
        max-height: none;
        border-radius: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .guru-launcher,
    .guru-launcher > img,
    .guru-avatar,
    .guru-typing span {
        animation: none;
    }

    .guru-panel {
        transition: none;
    }
}
