:root {
    --app-bg: #d1d7db;
    --panel: #ffffff;
    --panel-soft: #f0f2f5;
    --chat-bg: #efeae2;
    --line: #d9dee3;
    --text: #111b21;
    --muted: #667781;
    --bot: #ffffff;
    --user: #d9fdd3;
    --accent: #25d366;
    --accent-dark: #128c7e;
    --success: #1fa855;
    --danger: #d93025;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #d9dbd5 0 118px, #e7eaed 118px 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

img {
    max-width: 100%;
    display: block;
}

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

.chat-card {
    width: 100%;
    max-width: 980px;
    min-height: 760px;
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 24px;
    box-shadow: 0 12px 34px rgba(17, 27, 33, 0.16);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-soft);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 190px;
    height: auto;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    padding: 6px;
}

.brand-title {
    font-size: 21px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
}

.brand-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-top: 4px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #e7fce8;
    color: #127c3f;
    border: 1px solid #cdeecf;
    font-size: 14px;
    font-weight: 700;
}

.badge-live {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15);
}

.chat-body {
    flex: 1;
    padding: 26px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background:
        radial-gradient(circle at center, rgba(255,255,255,0.18) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.18)),
        var(--chat-bg);
    background-size: 18px 18px, auto, auto;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

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

.message-row.user .avatar-image {
    order: 2;
}

.message-row.user .message-bubble {
    order: 1;
    background: var(--user);
}

.avatar-image {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border: 2px solid rgba(255,255,255,0.85);
    flex: 0 0 48px;
}

.message-bubble {
    max-width: min(740px, 82%);
    background: var(--bot);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(17, 27, 33, 0.08);
}

.message-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.message-text {
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 15px;
    color: var(--text);
}

.cursor {
    display: inline-block;
    width: 1px;
    height: 1em;
    background: currentColor;
    vertical-align: -2px;
    animation: blink 0.9s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 18px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7e8b93;
    animation: pulse 1.2s infinite ease-in-out;
}

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

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

.brand-version {
    font-size: 0.55em;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.9;
}

.chat-footer {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--line);
    background: var(--panel-soft);
}

.command-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.command-form input,
.phone-panel input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid #cfd7de;
    background: #fff;
    color: var(--text);
    outline: none;
    font-size: 15px;
}

.command-form input:focus,
.phone-panel input:focus {
    border-color: rgba(18, 140, 126, 0.7);
    box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12);
}

.command-form button,
.phone-panel button,
.quick-command {
    border: 0;
    cursor: pointer;
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 800;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.command-form button,
.phone-panel button {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
}

.command-form button:hover,
.phone-panel button:hover,
.quick-command:hover {
    transform: translateY(-1px);
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.quick-command {
    padding: 10px 14px;
    background: #ffffff;
    color: var(--text);
    border: 1px solid #d5dce2;
}

.quick-command:hover {
    background: #f8fafb;
}

.footer-note,
.phone-hint,
.small-hint,
.success-text,
.error-text {
    font-size: 13px;
    margin-top: 10px;
}

.footer-note,
.phone-hint,
.small-hint {
    color: var(--muted);
}

.phone-panel {
    margin-top: 14px;
    border-top: 1px solid #d8dee4;
    padding-top: 14px;
}

.phone-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 10px;
}

.success-text {
    color: var(--success);
}

.error-text {
    color: var(--danger);
}

@media (max-width: 860px) {
    .chat-card {
        min-height: 100vh;
        border-radius: 0;
    }

    .app-shell {
        padding: 0;
    }

    .chat-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-logo {
        width: 160px;
    }

    .command-form,
    .phone-form {
        grid-template-columns: 1fr;
    }

    .message-bubble {
        max-width: 100%;
    }
}
