/* ── Page layout ───────────────────────────────────────── */
.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4.5rem);
    max-width: 820px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ── Header ────────────────────────────────────────────── */
.chat-header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    flex-shrink: 0;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
    letter-spacing: -0.03em;
}

.chat-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Messages area ─────────────────────────────────────── */
.chat-messages-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

/* ── Empty state ───────────────────────────────────────── */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-dim);
    gap: 0.5rem;
}

.chat-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.chat-empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.chat-empty-sub {
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* ── Message wrappers ──────────────────────────────────── */
.msg-wrapper {
    display: flex;
    max-width: 100%;
}

.msg-wrapper.user {
    justify-content: flex-end;
}

.msg-wrapper.assistant,
.msg-wrapper.thinking {
    justify-content: flex-start;
}

/* ── Message bubbles ───────────────────────────────────── */
.msg-bubble {
    max-width: 78%;
    padding: 0.85rem 1.1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.65;
}

.msg-bubble.user {
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 0.25rem;
    font-weight: 500;
}

.msg-bubble.assistant {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

/* ── Thinking animation ────────────────────────────────── */
.msg-bubble.thinking {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1.0); opacity: 1.0; }
}

.thinking-text {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-family: monospace;
}

/* ── Markdown inside assistant bubbles ─────────────────── */
.msg-bubble.assistant p          { margin-bottom: 0.6rem; }
.msg-bubble.assistant p:last-child { margin-bottom: 0; }
.msg-bubble.assistant strong     { color: var(--text); font-weight: 600; }
.msg-bubble.assistant ul,
.msg-bubble.assistant ol         { padding-left: 1.25rem; margin-bottom: 0.6rem; }
.msg-bubble.assistant li         { margin-bottom: 0.3rem; }
.msg-bubble.assistant a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-dim, #005f7a);
}
.msg-bubble.assistant a:hover    { border-color: var(--accent); }
.msg-bubble.assistant code {
    font-family: monospace;
    font-size: 0.82rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    color: var(--accent);
}
.msg-bubble.assistant table      { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-bottom: 0.75rem; }
.msg-bubble.assistant th {
    background: var(--bg);
    padding: 0.4rem 0.65rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}
.msg-bubble.assistant td         { padding: 0.4rem 0.65rem; border-bottom: 1px solid var(--border); }
.msg-bubble.assistant tr:last-child td { border-bottom: none; }
.msg-bubble.assistant h3,
.msg-bubble.assistant h4         { font-size: 0.9rem; font-weight: 600; margin: 0.75rem 0 0.4rem; }

/* ── Bottom area ───────────────────────────────────────── */
.chat-bottom {
    flex-shrink: 0;
    padding-bottom: 1.25rem;
}

/* ── Suggestion chips ──────────────────────────────────── */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
    justify-content: center;
}

.suggestion-chip {
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg);
}

/* ── Input box ─────────────────────────────────────────── */
.chat-input-box {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    transition: border-color 0.2s ease;
}

.chat-input-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow, rgba(0,212,255,0.1));
}

.chat-input-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    max-height: 160px;
    padding: 0.2rem 0;
}

.chat-input-box textarea::placeholder {
    color: var(--text-dim);
}

.chat-send-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 0.6rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
    background: #33ddff;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    cursor: not-allowed;
}

.chat-input-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.5rem;
}

.chat-input-hint kbd {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-size: 0.68rem;
    font-family: monospace;
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-page      { padding: 0 0.75rem; }
    .chat-header    { padding: 1.25rem 0.5rem 0.75rem; }
    .chat-header h1 { font-size: 1.2rem; }
    .msg-bubble     { max-width: 90%; }

    .suggestion-chips {
        gap: 0.35rem;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .suggestion-chip {
        flex-shrink: 0;
    }
}