﻿:root {
    --primary: #006c68;
    --primary-dark: #004f4c;
    --background: #eef5f5;
    --surface: #ffffff;
    --text: #17302f;
    --muted: #59716f;
    --border: #d4e2e0;
    --user: #d8f0ed;
    --danger: #9d2f2f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--background);
    color: var(--text);
}

.chat-shell {
    width: min(920px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 20px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-logo {
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
    object-fit: contain;
    border-radius: 10px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 1.45rem;
}

.assistant-name {
    margin: 3px 0 0;
    color: var(--primary-dark);
    font-size: 0.95rem;
    font-weight: 600;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 3px;
    border-radius: 50%;
    background: #2f9963;
}

.notice {
    margin: 14px 0;
    padding: 12px 14px;
    border-left: 4px solid #d18a00;
    background: #fff8e8;
    color: #614500;
    border-radius: 6px;
    font-size: 0.92rem;
}

.messages {
    display: flex;
    min-height: 420px;
    max-height: calc(100vh - 290px);
    overflow-y: auto;
    flex-direction: column;
    gap: 14px;
    padding: 18px 4px;
}

.message {
    max-width: 82%;
    padding: 13px 15px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.assistant-message {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
}

.user-message {
    align-self: flex-end;
    background: var(--user);
}

.message-label {
    margin-bottom: 7px;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
}

.message-label span {
    margin-left: 5px;
    color: var(--muted);
    font-weight: 400;
}

.message-content {
    line-height: 1.55;
    white-space: pre-wrap;
}

.answer-link {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.answer-link:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 2px;
}

.sources {
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.84rem;
}

.source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}

.source-item {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f5f9f8;
    font-size: 0.8rem;
}

.typing-message {
    min-width: 175px;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: typing-pulse 1.2s infinite ease-in-out;
}

.typing-indicator i:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
    position: sticky;
    bottom: 0;
    padding: 12px 0 2px;
    background: var(--background);
}

textarea {
    flex: 1;
    resize: vertical;
    min-height: 52px;
    max-height: 150px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

textarea:focus {
    outline: 3px solid rgba(0, 108, 104, 0.15);
    border-color: var(--primary);
}

button {
    border: 0;
    border-radius: 10px;
    padding: 0 17px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

button:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(0, 108, 104, 0.25);
    outline-offset: 2px;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.secondary-button {
    min-height: 44px;
    padding: 0 12px;
    background: #617371;
    white-space: nowrap;
}

.input-help {
    margin: 5px 2px 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

@media (prefers-reduced-motion: reduce) {
    .typing-indicator i {
        animation: none;
        opacity: 0.65;
    }
}

@media (max-width: 650px) {
    .chat-shell {
        padding: 10px;
    }

    .chat-header {
        flex-direction: column;
        padding: 14px;
    }

    .header-logo {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
    }

    .chat-header .secondary-button {
        width: 100%;
    }

    .message {
        max-width: 94%;
    }

    .messages {
        min-height: calc(100dvh - 390px);
        max-height: none;
    }

    .chat-form {
        align-items: end;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .chat-form button {
        min-width: 72px;
        height: 52px;
    }

    textarea {
        min-height: 52px;
        font-size: 16px;
    }
}
