/* Guided chat: one responsive panel, one scrolling body, one active choice surface. */
.chat-launcher {
    position: fixed;
    z-index: 1000;
    left: 1.25rem;
    bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 50px;
    height: 50px;
    padding: 0 1.1rem 0 1rem;
    border: 1px solid var(--ind-200, #bce0d3);
    border-radius: var(--radius-full, 9999px);
    background: #fff;
    color: var(--ink, #0b1f24);
    font: 700 0.92rem var(--font-display, 'Rubik', sans-serif);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(13, 71, 50, 0.12);
    transition: box-shadow var(--duration-normal, 250ms) var(--ease-out), transform var(--duration-normal, 250ms) var(--ease-out), border-color var(--duration-fast, 150ms) var(--ease-out);
}

.chat-launcher svg { flex-shrink: 0; color: var(--ind-600, #2e7a52); }
.chat-launcher:hover { transform: translateY(-1px); border-color: var(--ind-300, #8fcaa9); box-shadow: 0 10px 28px rgba(13, 71, 50, 0.17); }
.chat-launcher:focus-visible,
.service-chat button:focus-visible,
.service-chat textarea:focus-visible { outline: 3px solid var(--gold-300, #e8c878); outline-offset: 2px; }
.chat-launcher[aria-expanded="true"] { visibility: hidden; pointer-events: none; }

.service-chat {
    position: fixed;
    z-index: 1001;
    left: 1.25rem;
    bottom: 5rem;
    display: flex;
    flex-direction: column;
    width: min(420px, calc(100vw - 2.5rem));
    height: min(680px, calc(100dvh - 7rem));
    min-height: min(420px, calc(100dvh - 7rem));
    overflow: hidden;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: var(--radius-lg, 20px);
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 32, 36, 0.2);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity var(--duration-normal, 250ms) var(--ease-out), transform var(--duration-normal, 250ms) var(--ease-out);
}

.service-chat.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.service-chat[hidden] { display: none; }

.service-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
    flex: 0 0 auto;
    padding: 0.9rem 1rem 0.8rem;
    background: linear-gradient(135deg, var(--org-700, #3d4174), var(--org-600, #4a4f8c));
    color: #fff;
}

.service-chat-header-text { min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.service-chat-header h2 { margin: 0; font: 700 1.02rem/1.3 var(--font-display, 'Rubik', sans-serif); }
.service-chat-header-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem 0.65rem; }
.service-chat-subtitle { margin: 0; font-size: 0.78rem; line-height: 1.4; opacity: 0.86; }
.service-chat-topic-toggle {
    min-height: 30px;
    padding: 0.1rem 0;
    border: 0;
    border-bottom: 1px solid currentColor;
    background: transparent;
    color: #fff;
    font: 600 0.76rem var(--font-body, 'Rubik', sans-serif);
    cursor: pointer;
}
.service-chat-topic-toggle[hidden] { display: none; }
.service-chat-topic-toggle:disabled { opacity: 0.55; cursor: wait; }

.service-chat-close {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.16);
    color: #fff;
    cursor: pointer;
}
.service-chat-close:hover { background: rgba(255,255,255,0.28); }

.service-chat-notice {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.42rem 1rem;
    border-block-end: 1px solid var(--border-light, #e5e7eb);
    background: var(--org-soft-2, #f7f8fd);
    color: var(--text-secondary, #4b5563);
    font-size: 0.72rem;
    line-height: 1.4;
    text-align: center;
}

.service-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fafcfb;
    scrollbar-gutter: stable;
}

.service-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 7rem;
    padding: 0.9rem 1rem 0.35rem;
    direction: ltr;
}
.service-chat-messages:focus { outline: none; }

.service-chat-message {
    max-width: 86%;
    padding: 0.62rem 0.82rem;
    border-radius: 0.95rem;
    font-size: 0.92rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.service-chat-message p { margin: 0; }
.service-chat-message-assistant { align-self: flex-start; border-bottom-left-radius: 0.25rem; background: var(--ind-soft, #e8f5ee); color: var(--ink, #0b1f24); }
.service-chat-message-user { align-self: flex-end; border-bottom-right-radius: 0.25rem; background: var(--org-600, #4a4f8c); color: #fff; }
.service-chat-message-error { background: #fff4e5; color: #7a4300; }
.service-chat-message-typing { font-style: italic; opacity: 0.8; }

.service-chat-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-top: 0.55rem;
    padding: 0.42rem 0.8rem;
    border: 0;
    border-radius: var(--radius-full, 9999px);
    background: var(--ind-600, #2e7a52);
    color: #fff;
    font: 700 0.82rem var(--font-body, 'Rubik', sans-serif);
    cursor: pointer;
}
.service-chat-action:hover { background: var(--ind-700, #286345); }

.service-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem 1rem 1rem;
}
.service-chat-suggestions[hidden] { display: none; }
.service-chat-path {
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--ind-200, #bce0d3);
    border-radius: var(--radius-md, 12px);
    background: #fff;
    color: var(--ind-800, #225038);
    font: 600 0.9rem var(--font-display, 'Rubik', sans-serif);
    text-align: right;
    cursor: pointer;
    transition: background var(--duration-fast, 150ms) var(--ease-out), border-color var(--duration-fast, 150ms) var(--ease-out);
}
.service-chat-path:hover { background: var(--ind-soft, #e8f5ee); border-color: var(--ind-300, #8fcaa9); }

.service-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 0 0 auto;
    padding: 0.7rem max(0.75rem, env(safe-area-inset-right)) max(0.7rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    border-top: 1px solid var(--border-light, #e5e7eb);
    background: #fff;
}
.service-chat-form textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 7.5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border, #d1d5db);
    border-radius: var(--radius-md, 12px);
    background: #fff;
    color: var(--ink, #0b1f24);
    font: 0.95rem/1.35 var(--font-body, 'Rubik', sans-serif);
}
.service-chat-form textarea:focus { border-color: var(--ind-400, #5fae80); box-shadow: 0 0 0 3px rgba(95,174,128,0.18); }
.service-chat-form textarea:disabled { background: #f3f4f6; cursor: wait; }
.service-chat-form button {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--org-600, #4a4f8c);
    color: #fff;
    cursor: pointer;
}
.service-chat-form button:hover { background: var(--org-700, #3d4174); }
.service-chat-form button:disabled { opacity: 0.55; cursor: wait; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 600px) {
    .chat-launcher { left: 1rem; width: 48px; min-width: 48px; height: 48px; padding: 0; justify-content: center; }
    .chat-launcher-label { display: none; }
    .service-chat {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: min(86dvh, calc(100dvh - 1rem));
        min-height: 0;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: var(--radius-lg, 20px) var(--radius-lg, 20px) 0 0;
        transform: translateY(100%);
    }
    .service-chat.is-open { transform: translateY(0); }
    .service-chat-header { padding-top: max(0.85rem, env(safe-area-inset-top)); }
    .service-chat-message { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-launcher,
    .service-chat,
    .service-chat-path { transition: none !important; transform: none !important; }
    .service-chat:not(.is-open) { opacity: 0; }
}
