/* LIA inherits typography. Its own configured palette stays independent of the theme. */
#ts-lia {
    --ts-lia-background: #173e35;
    --ts-lia-text: #fffdf8;
    --ts-lia-hover: #102d26;
    --ts-lia-accent: #e8c56e;
    --ts-lia-accent-text: #102d26;
    --ts-lia-surface: #fffdf8;
    --ts-lia-surface-text: #173e35;
    --ts-lia-border: #a4aca3;
    position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 998; display: flex; align-items: stretch; max-width: calc(100vw - 48px);
    border-radius: 16px; background: var(--ts-lia-background) !important; color: var(--ts-lia-text) !important;
    box-shadow: 0 8px 24px #102d2630; font-family: inherit; font-size: 15px; line-height: 1.5;
    text-align: start; letter-spacing: normal;
}
#ts-lia *, #ts-lia *::before, #ts-lia *::after { box-sizing: border-box; }
#ts-lia [hidden] { display: none !important; }
#ts-lia button, #ts-lia a { font: inherit; letter-spacing: inherit; text-transform: none; text-decoration: none; cursor: pointer; margin: 0; }
#ts-lia button { appearance: none; min-height: 44px; border: 0; box-shadow: none; }
#ts-lia svg { display: block; flex-shrink: 0; }
#ts-lia button:focus-visible, #ts-lia a:focus-visible { outline: 3px solid var(--ts-lia-accent); outline-offset: 4px; }
#ts-lia .ts-lia-avatar { display: grid; place-items: center; flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--ts-lia-accent) !important; color: var(--ts-lia-accent-text) !important; }
#ts-lia .ts-lia-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; margin: 0; padding: 0; }
#ts-lia .ts-lia-launcher { position: relative; border-radius: inherit; min-width: 0; }
#ts-lia .ts-lia-launch { display: flex; align-items: center; gap: 14px; padding: 14px 28px 14px 14px; min-height: 88px; width: 100%; background: transparent !important; color: inherit !important; border-radius: inherit; text-align: start; }
#ts-lia .ts-lia-launch:hover, #ts-lia .ts-lia-restore:hover { background: var(--ts-lia-hover) !important; }
#ts-lia .ts-lia-copy { display: grid; gap: 3px; min-width: 0; }
#ts-lia span, #ts-lia .ts-lia-avatar svg { color: inherit !important; }
#ts-lia strong { font-weight: 700; color: inherit !important; }
#ts-lia .ts-lia-copy strong { font-size: 1.0625em; }
#ts-lia .ts-lia-icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 10px; border-radius: 50%; flex: 0 0 44px; background: var(--ts-lia-surface) !important; color: var(--ts-lia-surface-text) !important; }
#ts-lia .ts-lia-icon-button:hover { background: var(--ts-lia-accent) !important; color: var(--ts-lia-accent-text) !important; }
#ts-lia .ts-lia-minimize { position: absolute; top: -12px; right: -12px; padding: 8px; border: 0; background: transparent !important; }
#ts-lia .ts-lia-minimize::before { content: ''; position: absolute; inset: 7px; border: 1px solid var(--ts-lia-border); border-radius: 50%; background: var(--ts-lia-surface) !important; pointer-events: none; }
#ts-lia .ts-lia-minimize svg { position: relative; width: 16px; height: 16px; stroke-width: 1.8; }
#ts-lia .ts-lia-minimize:hover { background: transparent !important; }
#ts-lia .ts-lia-minimize:hover::before { background: var(--ts-lia-accent) !important; }
#ts-lia .ts-lia-restore { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 72px; min-height: 84px; padding: 8px 12px; border-radius: inherit; background: var(--ts-lia-background) !important; color: var(--ts-lia-text) !important; }
#ts-lia .ts-lia-restore .ts-lia-avatar { width: 44px; height: 44px; flex-basis: 44px; }
#ts-lia .ts-lia-bubble { position: absolute; right: 0; bottom: calc(100% + 12px); width: min(352px, calc(100vw - 48px)); max-height: max(96px, calc(100dvh - var(--ts-lia-height, 88px) - 72px - env(safe-area-inset-bottom))); overflow-y: auto; overscroll-behavior: contain; padding: 18px; border: 1px solid var(--ts-lia-border); border-radius: 16px; background: var(--ts-lia-surface) !important; color: var(--ts-lia-surface-text) !important; }
#ts-lia .ts-lia-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#ts-lia .ts-lia-heading > div { display: grid; gap: 2px; }
#ts-lia .ts-lia-heading h2 { margin: 0; padding: 0; font-family: inherit; font-weight: 700; font-size: 1.125em; line-height: 1.4; color: inherit !important; }
#ts-lia .ts-lia-heading span { font-size: .875em; }
#ts-lia .ts-lia-option { display: grid; grid-template-columns: 44px minmax(0,1fr) 20px; align-items: center; gap: 12px; padding: 16px 0; color: inherit !important; min-height: 64px; border-radius: 4px; }
#ts-lia .ts-lia-option + .ts-lia-option { border-top: 1px solid var(--ts-lia-border); }
#ts-lia .ts-lia-option .ts-lia-avatar { width: 44px; height: 44px; }
#ts-lia .ts-lia-option > span:nth-child(2) { display: grid; gap: 4px; min-width: 0; }
#ts-lia .ts-lia-option > span:nth-child(2) > span { font-size: .875em; }
#ts-lia .ts-lia-option:hover strong { text-decoration: underline; text-underline-offset: .2em; }
#ts-lia .ts-lia-message { display: grid; position: relative; margin: 0 0 18px; padding: 0; font: inherit; line-height: 1.65; color: inherit !important; white-space: pre-line; overflow-wrap: anywhere; }
#ts-lia .ts-lia-measure, #ts-lia .ts-lia-typed, #ts-lia .ts-lia-dots { grid-area: 1/1; }
#ts-lia .ts-lia-measure { visibility: hidden; }
#ts-lia .ts-lia-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 12px 16px; border-radius: 8px; background: var(--ts-lia-background) !important; color: var(--ts-lia-text) !important; text-align: start; }
#ts-lia .ts-lia-action:hover { background: var(--ts-lia-hover) !important; }
#ts-lia .ts-lia-top { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 0 0 76px; gap: 4px; min-width: 76px; font-weight: 700 !important; font-size: .875rem; line-height: 1.3; padding: 10px 8px; border-radius: 16px 0 0 16px; background: var(--ts-lia-accent) !important; color: var(--ts-lia-accent-text) !important; }
#ts-lia .ts-lia-top span { max-width: 7ch; text-wrap: balance; overflow-wrap: anywhere; }
#ts-lia .ts-lia-top:not([hidden]) ~ .ts-lia-launcher, #ts-lia .ts-lia-top:not([hidden]) ~ .ts-lia-restore { border-top-left-radius: 0; border-bottom-left-radius: 0; }
#ts-lia .ts-lia-dots { display: flex; align-items: start; gap: 5px; padding-top: 12px; }
#ts-lia .ts-lia-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ts-lia-writing .6s ease-in-out 2; }
#ts-lia .ts-lia-dots i:nth-child(2) { animation-delay: 80ms; }
#ts-lia .ts-lia-dots i:nth-child(3) { animation-delay: 160ms; }
#ts-lia .ts-lia-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes ts-lia-writing { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (max-width:600px) {
    #ts-lia { right: max(20px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); max-width: calc(100vw - 40px); }
    #ts-lia .ts-lia-launch { min-height: 80px; gap: 12px; padding: 12px 24px 12px 12px; }
    #ts-lia .ts-lia-launch .ts-lia-avatar { width: 48px; height: 48px; flex-basis: 48px; }
    #ts-lia .ts-lia-copy strong { font-size: 1em; }
}
@media (prefers-reduced-motion:reduce) { #ts-lia .ts-lia-dots i { animation: none; } }
@media (forced-colors:active) { #ts-lia, #ts-lia .ts-lia-bubble, #ts-lia button, #ts-lia a { border: 1px solid ButtonText; } }

/* Keep LIA's launcher portrait visible without repeating the initial question. */
#ts-lia.ts-lia-open .ts-lia-copy { display: none; }
#ts-lia.ts-lia-open .ts-lia-launch { padding: 14px; }
@media (max-width:600px) { #ts-lia.ts-lia-open .ts-lia-launch { padding: 12px; } }
#ts-lia .ts-lia-avatar.ts-lia-messaging-icon { color: var(--ts-lia-messaging-icon) !important; background: var(--ts-lia-messaging-icon-background) !important; }
#ts-lia .ts-lia-avatar.ts-lia-extra-icon { color: var(--ts-lia-extra-icon) !important; background: var(--ts-lia-extra-icon-background) !important; }
#ts-lia .ts-lia-action-icon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; color: var(--ts-lia-action-icon) !important; background: var(--ts-lia-action-icon-background) !important; }
html.ts-lia-replaces-top .ts-scroll-top { display: none !important; }

#ts-lia .ts-lia-navigation { margin-top: 12px; border-top: 1px solid var(--ts-lia-border); padding-top: 8px; }
#ts-lia .ts-lia-replay { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; text-align: start; background: transparent !important; color: var(--ts-lia-surface-text) !important; border-radius: 4px; }
#ts-lia .ts-lia-replay:hover span { text-decoration: underline; text-underline-offset: .2em; }

#ts-lia .ts-lia-replay span { min-width: 0; overflow-wrap: anywhere; }
