:root {
    --bg: #d9dbd5;
    --panel: #efeae2;
    --topbar: #f0f2f5;
    --composer: #f0f2f5;
    --border: #d7dee3;
    --text: #111b21;
    --muted: #667781;
    --user: #d9fdd3;
    --bot: #ffffff;
    --accent: #00a884;
    --accent-dark: #008f72;
    --shadow: rgba(17, 27, 33, 0.08);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    background:
        linear-gradient(180deg, #00a884 0, #00a884 92px, var(--bg) 92px, var(--bg) 100%);
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    background: none;
    cursor: pointer;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.app-shell {
    width: min(760px, 100%);
    height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    box-shadow: 0 6px 28px var(--shadow);
}

.chat-topbar {
    position: sticky;
    top: 0;
    z-index: 6;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 10px 14px;
    background: var(--topbar);
    border-bottom: 1px solid var(--border);
}

.chat-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #c7d1d7;
    color: #ffffff;
    font-weight: 700;
}

.chat-meta {
    min-width: 0;
}

.chat-name {
    font-size: 1rem;
    font-weight: 600;
}

.presence-status {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.82rem;
}

.topbar-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    font-size: 1.25rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-text-button {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 17px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
}

.topbar-text-button:hover {
    background: rgba(17, 27, 33, 0.06);
}

.topbar-icon:hover {
    background: rgba(17, 27, 33, 0.06);
}

.chat-shell {
    flex: 1 1 auto;
    min-height: 0;
}

.conversation {
    height: 100%;
    padding: 12px 10px 92px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.04) 1px, transparent 0) 0 0 / 18px 18px,
        #efeae2;
}

.message-row {
    display: flex;
    margin-bottom: 10px;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot,
.message-row.note {
    justify-content: flex-start;
}

.message-row.note {
    justify-content: center;
}

.message {
    max-width: min(75%, 520px);
    padding: 7px 10px 5px;
    border-radius: 10px;
    box-shadow: 0 1px 0 rgba(17, 27, 33, 0.08);
}

.message.user {
    background: var(--user);
    border-top-right-radius: 3px;
}

.message.bot {
    background: var(--bot);
    border-top-left-radius: 3px;
}

.message.note {
    background: rgba(255, 255, 255, 0.82);
    color: var(--muted);
    font-size: 0.86rem;
}

.message-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.42;
    font-size: 0.96rem;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.message-time {
    color: var(--muted);
    font-size: 0.72rem;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #93a3ad;
    animation: typing-pulse 1.1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.45;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.composer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 6px 8px 10px;
    background: linear-gradient(180deg, rgba(240, 242, 245, 0) 0%, rgba(240, 242, 245, 0.92) 24%, rgba(240, 242, 245, 1) 100%);
}

.composer-inner {
    width: min(760px, 100%);
    background: transparent;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 6px 8px;
    border-radius: 24px;
    background: var(--composer);
}

.input-row {
    position: relative;
}

.emoji-wrap {
    position: relative;
    flex: 0 0 auto;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    background: transparent;
    font-size: 1.2rem;
}

.icon-button:hover {
    background: rgba(17, 27, 33, 0.06);
}

#message {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 0;
    border-radius: 22px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

.action-button {
    color: #ffffff;
    background: #bcc4c8;
}

.action-button.primary-action {
    background: var(--accent);
}

.action-button.primary-action:hover {
    background: var(--accent-dark);
}

.emoji-picker {
    position: absolute;
    bottom: 48px;
    left: 0;
    display: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    width: 228px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 10px 28px var(--shadow);
}

.emoji-picker.is-open {
    display: grid;
}

.emoji-option {
    width: 100%;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #f7f8f8;
    font-size: 1.2rem;
}

.emoji-option:hover {
    background: #eef2f4;
}

@media (max-width: 640px) {
    .app-shell {
        width: 100%;
        box-shadow: none;
    }

    .chat-topbar {
        padding: 10px 12px;
    }

    .conversation {
        padding: 10px 8px 88px;
    }

    .message {
        max-width: 86%;
    }

    .composer {
        padding: 8px;
    }

    .emoji-picker {
        left: 0;
        width: 228px;
    }
}
