.lia-assist-chat {
    max-width: 480px;
    margin: 0 auto;
    border: 1px solid #d8dfd6;
    border-radius: 10px;
    background: #f7faf7;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 10px 24px rgba(0,0,0,.09);
}

.lia-assist-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--lia-green-300, #9cbe9c);
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.lia-assist-app-header__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.lia-assist-app-header__title {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--lia-green-900, #1f3a1c);
}

.lia-assist-chat--app {
    max-width: 640px;
    height: 100%;
    border: 1px solid #d8dfd6;
    border-radius: 12px;
    margin: 0 auto;
    min-height: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 10px 24px rgba(0,0,0,.09);
}

.lia-assist-chat--app .lia-assist-chat__header,
.lia-assist-chat--app .lia-assist-chat__form {
    flex: 0 0 auto;
}

.lia-assist-chat--app .lia-assist-chat__messages {
    flex: 1;
    max-height: none;
    min-height: 0;
}

/* App-Seite (/lernreise-app/) nutzt dieselbe Titel-/Unterzeilen-Größe wie
   die eigenständigen App-Seiten von Lia - Poll und Lia - Coaching — das
   schwebende Chat-Bubble-Widget auf der normalen Website bleibt unverändert. */
.lia-assist-chat--app .lia-assist-chat__title {
    font-size: 1.4rem;
}

.lia-assist-chat--app .lia-assist-chat__tagline {
    font-size: 0.9rem;
}

/* Das eingebettete Lernreise-Chatfenster darf auf größeren Bildschirmen
   etwas breiter sein als der Standard-Chat — auf dem Handy bleibt die
   kompakte Breite erhalten, damit es sich weiterhin gut einfügt. */
@media (min-width: 600px) {
    .lia-assist-chat[data-lia-assist-context="lernreise"] {
        max-width: 640px;
    }
}

.lia-assist-chat__header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e2e8e0;
    background: #fff;
}

.lia-assist-chat__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2f5e22;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.lia-assist-chat__tagline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 2px;
}

.lia-assist-chat__tagline {
    font-size: 0.85rem;
    color: var(--lia-text-muted, #5b6b57);
}

.lia-assist-chat__badge {
    display: inline-block;
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.lia-assist-chat__badge--lernreise {
    background: #f0e8d6;
    color: var(--lia-amber-text, #7a5a1e);
    border: 1px solid #e3d3ad;
}

.lia-assist-chat__messages {
    flex: 1;
    min-height: 240px;
    max-height: 420px;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lia-assist-chat__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.lia-assist-chat__row.is-user {
    justify-content: flex-end;
}

.lia-assist-chat__row.is-assistant {
    justify-content: flex-start;
}

.lia-assist-chat__avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(61, 123, 45, 0.25);
}

.lia-assist-chat__message {
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 85%;
    line-height: 1.4;
    font-size: 0.95rem;
}

.lia-assist-chat__message.is-user {
    white-space: pre-wrap;
}

.lia-assist-chat__typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
}

.lia-assist-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    animation: lia-assist-typing-bounce 1.2s infinite ease-in-out;
}

.lia-assist-chat__typing-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.85em;
    opacity: 0.6;
}

.lia-assist-chat__typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.lia-assist-chat__typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes lia-assist-typing-bounce {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.lia-assist-chat__message p {
    margin: 0 0 8px;
}

.lia-assist-chat__message p:last-child {
    margin-bottom: 0;
}

.lia-assist-chat__message ul {
    margin: 0 0 8px;
    padding-left: 1.2em;
}

.lia-assist-chat__message ul:last-child {
    margin-bottom: 0;
}

.lia-assist-chat__message li {
    margin: 0 0 2px;
}

.lia-assist-chat__message strong {
    font-weight: 700;
}

.lia-assist-chat__message em {
    font-style: italic;
}

.lia-assist-chat__message a {
    color: #2f5e22;
    font-weight: 600;
    text-decoration: underline;
}

.lia-assist-chat__message h4,
.lia-assist-chat__message h5,
.lia-assist-chat__message h6 {
    margin: 12px 0 6px;
    line-height: 1.3;
    font-weight: 600;
    color: #2f5e22;
}

.lia-assist-chat__message h4 {
    font-size: 1.05em;
}

.lia-assist-chat__message h5 {
    font-size: 1em;
}

.lia-assist-chat__message h6 {
    font-size: 0.95em;
}

.lia-assist-chat__message hr {
    border: none;
    border-top: 1px solid #d8e0d6;
    margin: 10px 0;
}

.lia-assist-chat__table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
    font-size: 0.85rem;
}

.lia-assist-chat__table th,
.lia-assist-chat__table td {
    text-align: left;
    padding: 6px 8px;
    border: 1px solid #d8e0d6;
    vertical-align: top;
}

.lia-assist-chat__table th {
    background: #eef3ec;
    color: #2f5e22;
    font-weight: 700;
}

.lia-assist-chat__table tr:nth-child(even) td {
    background: #f7faf6;
}

.lia-assist-chat__message a:hover {
    color: #1f3f17;
}

.lia-assist-chat__message.is-user {
    align-self: flex-end;
    background: var(--lia-green-300, #9cbe9c);
    color: var(--lia-green-900, #1f3a1c);
}

.lia-assist-chat__message.is-assistant {
    align-self: flex-start;
    background: #eef4ec;
    color: #1f2a1c;
}

.lia-assist-chat__message.is-error {
    align-self: flex-start;
    background: #fff7ed;
    color: var(--lia-red-text, #9a3412);
    border: 1px solid #fed7aa;
}

.lia-assist-chat__form {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8e0;
    background: #fff;
}

.lia-assist-chat__input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #c7d3c5;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
}

.lia-assist-chat__submit {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--lia-green-300, #9cbe9c);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.lia-assist-chat__submit:hover {
    background: #89ad89;
}

.lia-assist-chat__submit:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Login-Gate (Name + Zugangscode) für den geschützten Lernreise-Bereich */
.lia-assist-chat__gate {
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lia-assist-chat__gate-heading {
    font-weight: 700;
    font-size: 1.05rem;
    color: #2f5e22;
}

.lia-assist-chat__gate-intro {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--lia-text-2, #41513c);
}

.lia-assist-chat__gate-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.lia-assist-chat__gate-input {
    padding: 9px 11px;
    border: 1px solid #c7d3c5;
    border-radius: 6px;
    font-size: 0.95rem;
}

.lia-assist-chat__gate-submit {
    padding: 11px 18px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--lia-green-400, #5a9e49) 0%, var(--lia-green-700, #3d7b2d) 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--lia-green-800, #2a5a1e), 0 6px 14px rgba(47,94,34,.28);
    transition: transform .1s, box-shadow .1s, filter .1s;
}

.lia-assist-chat__gate-submit:hover {
    filter: brightness(1.05);
}

.lia-assist-chat__gate-submit:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--lia-green-800, #2a5a1e), 0 3px 6px rgba(47,94,34,.2);
}

.lia-assist-chat__gate-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.lia-assist-chat__gate-feedback {
    font-size: 0.88rem;
    line-height: 1.4;
    min-height: 1.2em;
}

.lia-assist-chat__gate-feedback.is-error {
    color: #b3261e;
}

.lia-assist-chat__gate-feedback.is-success {
    color: #2f5e22;
    font-weight: 600;
}

/* ---------------------------------------------------------------- */
/* Schwebender Chat (site-weit): Launcher-Button unten rechts +      */
/* ausklappbares Panel, das den eigentlichen Chat enthält.           */
/* ---------------------------------------------------------------- */

.lia-assist-chat--floating-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99999;
    max-width: none;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
    display: block;
    box-shadow: none;
}

.lia-assist-chat__launcher {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: none;
    background: var(--lia-green-300, #9cbe9c);
    color: var(--lia-green-900, #1f3a1c);
    box-shadow: 0 6px 20px rgba(31, 63, 23, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    transition: background 0.15s ease, transform 0.15s ease;
}

.lia-assist-chat__launcher:hover {
    background: #89ad89;
    transform: scale(1.05);
}

.lia-assist-chat__launcher-icon {
    position: absolute;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.lia-assist-chat__launcher-icon--close {
    opacity: 0;
    transform: scale(0.6);
}

.lia-assist-chat--floating-root.is-open .lia-assist-chat__launcher-icon--open {
    opacity: 0;
    transform: scale(0.6);
}

.lia-assist-chat--floating-root.is-open .lia-assist-chat__launcher-icon--close {
    opacity: 1;
    transform: scale(1);
}

.lia-assist-chat__panel {
    position: absolute;
    right: 0;
    bottom: 92px;
    width: min(440px, calc(100vw - 40px));
    max-height: min(720px, calc(100vh - 140px));
    display: flex;
    flex-direction: column;
    background: #f7faf7;
    border: 1px solid #d8dfd6;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(31, 63, 23, 0.25);
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.lia-assist-chat--floating-root.is-open .lia-assist-chat__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.lia-assist-chat--floating-root .lia-assist-chat__messages {
    min-height: 200px;
    max-height: 58vh;
}

@media (max-width: 480px) {
    .lia-assist-chat--floating-root {
        right: 12px;
        bottom: 12px;
    }

    .lia-assist-chat__panel {
        width: calc(100vw - 24px);
        right: -8px;
    }
}

/* Auf größeren Bildschirmen (Tablet/Desktop) darf der Launcher-Button etwas
   größer und präsenter sein — auf dem Handy bleibt die kompaktere Größe
   erhalten, damit er den Inhalt nicht zu sehr überdeckt. */
@media (min-width: 600px) {
    .lia-assist-chat__launcher {
        width: 92px;
        height: 92px;
        font-size: 1.9rem;
    }

    .lia-assist-chat__panel {
        bottom: 108px;
    }
}

/* === Launcher: Lia-Avatar + Puls-Animation (v3.2.0) === */

.lia-assist-chat__launcher-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.lia-assist-chat__launcher-icon--open {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes lia-assist-pulse {
    0%   { box-shadow: 0 6px 20px rgba(31, 63, 23, 0.35), 0 0 0 0 rgba(61, 123, 45, 0.45); }
    70%  { box-shadow: 0 6px 20px rgba(31, 63, 23, 0.35), 0 0 0 14px rgba(61, 123, 45, 0); }
    100% { box-shadow: 0 6px 20px rgba(31, 63, 23, 0.35), 0 0 0 0 rgba(61, 123, 45, 0); }
}

.lia-assist-chat__launcher--pulse {
    animation: lia-assist-pulse 2s ease-out 3;
}

/* === Begrüßungs-Bubble neben dem Launcher === */

.lia-assist-chat .lia-assist-chat__nudge {
    position: absolute;
    right: 70px;
    bottom: 6px;
    width: max-content;
    max-width: min(270px, calc(100vw - 110px));
    display: flex;
    align-items: flex-start;
    gap: 4px;
    background: #fff;
    border: 1px solid #d8e4d3;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 6px 24px rgba(31, 63, 23, 0.18);
    padding: 10px 8px 10px 14px;
    animation: lia-assist-nudge-in 0.35s ease-out;
    z-index: 1;
}

@keyframes lia-assist-nudge-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* !important nötig: das Theme stylt <button> global (Hintergrund-Pille,
   Serifenschrift, Padding) und gewinnt sonst den Spezifitätskampf. */
.lia-assist-chat .lia-assist-chat__nudge-text {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    font-family: inherit !important;
    font-size: 0.88rem !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    color: #2c3a27 !important;
    text-align: left !important;
    white-space: normal;
    cursor: pointer;
}

.lia-assist-chat .lia-assist-chat__nudge-text:hover {
    color: var(--lia-green-700, #3d7b2d) !important;
    background: none !important;
}

.lia-assist-chat .lia-assist-chat__nudge-close {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 2px !important;
    margin: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    font-family: inherit !important;
    font-size: 0.75rem !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: #9aa896 !important;
    cursor: pointer;
    flex-shrink: 0;
}

.lia-assist-chat .lia-assist-chat__nudge-close:hover {
    color: #2c3a27 !important;
    background: none !important;
}

/* === Vorschlags-Chips (v3.5.0) === */

.lia-assist-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px 8px;
}

.lia-assist-chat .lia-assist-chat__chip {
    background: #fff !important;
    border: 1px solid var(--lia-green-700, #3d7b2d) !important;
    border-radius: 999px !important;
    box-shadow: none !important;
    padding: 5px 12px !important;
    margin: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    font-family: inherit !important;
    font-size: 0.82rem !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    color: var(--lia-green-700, #3d7b2d) !important;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.lia-assist-chat .lia-assist-chat__chip:hover {
    background: var(--lia-green-700, #3d7b2d) !important;
    color: #fff !important;
}

/* === Feedback-Daumen unter Lia-Antworten (v3.5.0) === */

.lia-assist-chat__feedback {
    margin-top: 6px;
    display: flex;
    gap: 4px;
}

.lia-assist-chat .lia-assist-chat__feedback-btn {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 3px !important;
    margin: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    font-size: 0.85rem !important;
    line-height: 1 !important;
    cursor: pointer;
    opacity: 0.45;
    filter: grayscale(60%);
    transition: opacity 0.15s ease, filter 0.15s ease, transform 0.15s ease;
}

.lia-assist-chat .lia-assist-chat__feedback-btn:hover {
    opacity: 1;
    filter: none;
    transform: scale(1.15);
}

.lia-assist-chat .lia-assist-chat__feedback-btn.is-selected {
    opacity: 1;
    filter: none;
}
