* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f8ff;
    --panel: #ffffff;
    --panel-2: #eef5ff;
    --border: #cfe0ff;

    --text: #16345f;
    --muted: #6f88ad;

    --accent: #3b82f6;
    --accent-hover: #2563eb;

    --bubble-user: #dcebff;
    --bubble-assistant: #ffffff;

    --shadow: 0 10px 30px rgba(59, 130, 246, 0.08);
    --shadow-soft: 0 6px 18px rgba(59, 130, 246, 0.06);
}

html,
body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 320px),
        radial-gradient(circle at bottom right, rgba(125, 211, 252, 0.12), transparent 360px),
        var(--bg);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
    height: 100%;
}

body {
    min-height: 100vh;
}

.layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #f7fbff, #edf5ff);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px;
    gap: 16px;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand-box {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.logo-slot {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b82f6, #7dd3fc);
    border: 1px solid #bcd4ff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.logo-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-slot span {
    font-weight: 700;
    color: #fff;
    font-size: 18px;
}

.brand-texts h1 {
    margin: 0;
    font-size: 21px;
    color: #12325f;
    letter-spacing: 0.01em;
}

.brand-texts p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.new-chat-btn {
    width: 100%;
    border: 1px solid #aecdff;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.sidebar-section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.09em;
    padding: 2px 4px 0;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
}

.conversation-item-row {
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: 8px;
    align-items: stretch;
}

.conversation-item {
    width: 100%;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.55);
    color: var(--text);
    padding: 12px 13px;
    border-radius: 14px;
    text-align: left;
    cursor: pointer;
    transition: 0.2s ease;
}

.conversation-item:hover,
.conversation-item.active {
    background: #ddebff;
    border-color: #abd0ff;
}

.conversation-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #143463;
}

.conversation-date {
    font-size: 12px;
    color: var(--muted);
}

.conversation-delete-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s, border-color 0.2s;
}

.conversation-item-row:hover .conversation-delete-btn {
    opacity: 1;
}

.conversation-delete-btn:hover {
    background: #ddebff;
    border-color: #abd0ff;
    color: #1d4ed8;
}

.chat-layout {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

.chat-header {
    padding: 20px 26px;
    border-bottom: 1px solid rgba(171, 208, 255, 0.7);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-header h2 {
    margin: 0;
    font-size: 22px;
    color: #12325f;
}

.chat-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.chat-messages {
    overflow-y: auto;
    padding: 28px 0 124px;
}

.message-row {
    display: flex;
    gap: 16px;
    width: min(940px, calc(100% - 40px));
    margin: 0 auto 22px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 4px;
    box-shadow: var(--shadow-soft);
}

.message-avatar.assistant {
    background: linear-gradient(135deg, #3b82f6, #7dd3fc);
    color: #fff;
}

.message-avatar.user {
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    color: #fff;
}

.message-bubble {
    flex: 1;
    border-radius: 22px;
    padding: 18px 20px;
    line-height: 1.68;
    border: 1px solid #d8e7ff;
    box-shadow: var(--shadow);
}

.message-bubble.assistant {
    background: #ffffff;
}

.message-bubble.user {
    background: linear-gradient(135deg, #dcebff, #cfe2ff);
    border: 1px solid #bdd6ff;
}

.message-content {
    white-space: normal;
    word-wrap: break-word;
    font-size: 15px;
    color: #16345f;
}

.message-content strong {
    font-weight: 700;
    color: #12325f;
}

.message-content a {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-word;
}

.message-content ul {
    padding-left: 20px;
    margin: 8px 0;
}

.message-content li {
    margin-bottom: 7px;
}

.message-content p {
    margin: 0 0 10px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.composer-wrap {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, rgba(244, 248, 255, 1) 72%, rgba(244, 248, 255, 0));
    padding: 22px;
}

.composer-box {
    width: min(940px, calc(100% - 20px));
    margin: 0 auto;
    border: 1px solid #d3e3ff;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 28px;
    padding: 15px 16px;
    box-shadow: var(--shadow);
}

.composer-box textarea {
    width: 100%;
    resize: none;
    border: 0;
    background: transparent;
    color: #16345f;
    outline: none;
    font-size: 16px;
    min-height: 28px;
    max-height: 240px;
    line-height: 1.55;
}

.composer-box textarea::placeholder {
    color: #7d96bb;
}

.composer-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.composer-hint {
    font-size: 12px;
    color: var(--muted);
}

.send-btn {
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.send-btn:hover {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

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

.products-grid {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.product-card {
    display: grid;
    grid-template-columns: 148px 1fr;
    gap: 16px;
    border: 1px solid #d7e6ff;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff, #f6faff);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.product-image {
    width: 148px;
    height: 100%;
    min-height: 148px;
    object-fit: cover;
    display: block;
    background: #eef5ff;
}

.product-content {
    padding: 16px 16px 16px 0;
}

.product-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #12325f;
}

.product-description {
    color: #47688f;
    font-size: 14px;
    line-height: 1.62;
}

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
}

.product-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
    text-decoration: none;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.product-link:hover {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.typing-indicator {
    color: var(--muted);
    font-style: italic;
}

.streaming-cursor {
    display: inline-block;
    width: 8px;
    margin-left: 2px;
    animation: pwBlink 1s steps(1) infinite;
    color: #2563eb;
}

@keyframes pwBlink {
    0%,
    50% {
        opacity: 1;
    }

    50.01%,
    100% {
        opacity: 0;
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .message-row {
        width: calc(100% - 24px);
    }

    .composer-box {
        width: calc(100% - 8px);
    }

    .product-card {
        grid-template-columns: 1fr;
    }

    .product-image {
        width: 100%;
        min-height: 220px;
    }

    .product-content {
        padding: 0 16px 16px;
    }
}