/* ── Chat FAB ─────────────────────────────────────────── */
.chat-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 900;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.chat-fab svg { width: 22px; height: 22px; }

/* ── Chat Panel ───────────────────────────────────────── */
.chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 910;
    width: min(420px, 100%);
    height: 70vh;
    max-height: 700px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.25s ease;
}
.chat-panel.open {
    transform: translateY(0);
}

/* ── Header ───────────────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-header-title {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.chat-header-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}
.chat-header-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.chat-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    line-height: 1;
}
.chat-close:hover { background: var(--bg-hover); }

/* ── Messages ─────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-msg {
    max-width: 88%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-msg.user {
    align-self: flex-end;
    background: #111;
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg.assistant .md-li {
    display: block;
    padding-left: 0.25rem;
}

/* ── Status indicators ────────────────────────────────── */
.chat-status {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.375rem 0;
}
.chat-status .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: chat-spin 0.7s linear infinite;
}
@keyframes chat-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .chat-status .spinner { animation: none; opacity: 0.6; }
}
.chat-tool-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}
.chat-tool-pill .check {
    color: #22c55e;
    font-weight: 700;
}

/* ── Welcome ──────────────────────────────────────────── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.5rem;
    flex: 1;
    gap: 0.75rem;
}
.chat-welcome h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.chat-welcome p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 280px;
    line-height: 1.5;
}
.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
    width: 100%;
    max-width: 300px;
}
.chat-suggestion {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s;
}
.chat-suggestion:hover {
    border-color: var(--accent);
}

/* ── Input area ───────────────────────────────────────── */
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.75rem;
    flex-shrink: 0;
}
.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    min-height: 38px;
    max-height: 120px;
    line-height: 1.4;
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}
.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.chat-send svg { width: 16px; height: 16px; }
.chat-input-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-align: right;
}

/* ── Full-page layout ─────────────────────────────────── */
.chat-page {
    display: flex;
    justify-content: center;
    padding: 0;
    height: calc(100vh - var(--topbar-height, 52px));
}
.chat-fullpage {
    width: 100%;
    max-width: 720px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.chat-fullpage-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.chat-fullpage-panel .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.chat-fullpage-panel .chat-msg {
    max-width: 80%;
}
.chat-fullpage-panel .chat-welcome {
    padding: 3rem 2rem;
}
.chat-fullpage-panel .chat-welcome h3 {
    font-size: 1.2rem;
}
.chat-fullpage-panel .chat-welcome p {
    font-size: 0.88rem;
    max-width: 380px;
}
.chat-fullpage-panel .chat-suggestions {
    max-width: 400px;
}

