:root {
    --bg: #f3f5f8;
    --shell: #ffffff;
    --line: #dee3ea;
    --bot: #eef6ff;
    --user: #dff5e8;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #f0f4fb, #eef2f6);
    font-family: "Segoe UI", Tahoma, sans-serif;
}

.app-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.chat-shell {
    width: 100%;
    max-width: 920px;
    background: var(--shell);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.chat-messages {
    height: 62vh;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
}

.msg {
    max-width: 78%;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    white-space: pre-wrap;
}

.msg.bot {
    background: var(--bot);
    border: 1px solid #cfe3ff;
}

.msg.user {
    background: var(--user);
    border: 1px solid #bee7d1;
    margin-left: auto;
}

.msg .meta {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
}

.chat-input {
    background: #fff;
}

.filters-bar {
    background: #f9fbff;
}

.filter-chip {
    border: 1px solid #cfe3ff;
    background: #eef6ff;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-chip button {
    border: 0;
    background: transparent;
    color: #4b5563;
    padding: 0;
    line-height: 1;
}

.filter-chip-action {
    cursor: pointer;
    border-style: dashed;
}

.option-actions .btn {
    min-width: 34px;
}

.heart-btn {
    border: 1px solid #dee2e6;
    background: #fff;
    color: #6c757d;
    min-width: 34px;
    line-height: 1;
}

.heart-btn:hover,
.heart-btn:focus {
    border-color: #adb5bd;
    background: #f8f9fa;
    color: #495057;
}

.flow-selector .btn {
    min-width: 86px;
}

.flow-selector .btn.active {
    color: #fff;
    background: #0d6efd;
    border-color: #0d6efd;
}

.msg.typing {
    opacity: 0.9;
}

.typing-dots {
    display: inline-block;
    margin-left: 4px;
}

.typing-dots span {
    display: inline-block;
    animation: typingBlink 1.2s infinite;
}

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

@keyframes typingBlink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

#toastHost {
    top: 14px;
    right: 14px;
    left: auto;
    bottom: auto;
    z-index: 1080;
    max-width: min(400px, calc(100vw - 28px));
}

#toastHost .toast {
    width: 100%;
}

@media (max-width: 768px) {
    .chat-messages { height: 58vh; }
    .msg { max-width: 92%; }
    .flow-selector .btn { min-width: 74px; }
    #toastHost {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: min(96vw, 560px);
    }
}

.sort-bar {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.sort-bar label {
    white-space: nowrap;
}

.sort-select {
    width: auto;
    min-width: 220px;
}

@media (max-width: 768px) {
    .sort-bar {
        justify-content: flex-start;
    }

    .sort-select {
        width: 100%;
        min-width: 0;
    }
}

.chat-actions-row {
    justify-content: space-between;
}

#quickActions {
    flex: 1 1 auto;
}

.sort-bar {
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .chat-actions-row {
        align-items: stretch;
    }

    .sort-bar {
        width: 100%;
        margin-left: 0 !important;
    }
}