:root {
    --bg: #0b0f14;
    --panel: #111720;
    --panel-soft: #151c26;
    --border: #252e3a;
    --text: #f1f5f9;
    --muted: #8b98a8;
    --accent: #6ee7b7;
    --accent-dark: #34d399;
    --user: #1b2633;
    --assistant: #10161e;
    --input: #151c26;
    --danger: #ef4444;
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */

header {
    height: 64px;
    min-height: 64px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 24px;

    background: rgba(11, 15, 20, 0.94);
    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    position: relative;
    z-index: 10;
}

header h1 {
    margin: 0;

    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;

    display: flex;
    align-items: center;
    gap: 10px;
}

header h1::before {
    content: "";
    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: var(--accent);

    box-shadow:
        0 0 8px rgba(110, 231, 183, 0.8),
        0 0 18px rgba(110, 231, 183, 0.35);
}

#newChat {
    border: 1px solid var(--border);

    background: transparent;
    color: var(--text);

    border-radius: 10px;

    padding: 9px 14px;

    font-size: 14px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

#newChat:hover {
    background: var(--panel-soft);
    border-color: #364252;
}

#newChat:active {
    transform: scale(0.97);
}

/* Chat */

main#chat {
    flex: 1;

    width: 100%;
    max-width: 900px;

    margin: 0 auto;

    padding: 32px 24px 180px;

    overflow-y: auto;
    overflow-x: hidden;

    scroll-behavior: smooth;

    scrollbar-width: thin;
    scrollbar-color: #303a47 transparent;
}

main#chat::-webkit-scrollbar {
    width: 7px;
}

main#chat::-webkit-scrollbar-track {
    background: transparent;
}

main#chat::-webkit-scrollbar-thumb {
    background: #303a47;
    border-radius: 20px;
}

/* Welcome */

main#chat:empty::before {
    content: "How can I help you today?";

    display: block;

    margin-top: 25vh;

    text-align: center;

    color: var(--text);

    font-size: 28px;
    font-weight: 600;

    letter-spacing: -0.03em;
}

/* Messages */

.message {
    width: 100%;

    margin-bottom: 28px;

    line-height: 1.65;

    font-size: 15.5px;

    animation: messageIn 0.2s ease-out;
}

.message strong {
    display: block;

    margin-bottom: 7px;

    font-size: 13px;
    font-weight: 600;

    color: var(--muted);
}

.message.user {
    padding: 15px 18px;

    background: var(--user);

    border: 1px solid #263241;

    border-radius: var(--radius);
}

.message.user strong {
    color: #d7e0e9;
}

.message.assistant {
    padding: 4px 4px 4px 0;

    color: #e6edf4;
}

.message.assistant strong {
    color: var(--accent);
}

.message.assistant > div {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Composer */

#chatForm {
    position: fixed;

    left: 50%;
    bottom: 20px;

    transform: translateX(-50%);

    width: calc(100% - 32px);
    max-width: 900px;

    display: flex;
    align-items: flex-end;
    gap: 10px;

    padding: 10px;

    background: rgba(21, 28, 38, 0.96);

    border: 1px solid var(--border);

    border-radius: 18px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.35),
        0 2px 10px rgba(0, 0, 0, 0.2);

    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    z-index: 20;
}

#message {
    flex: 1;

    min-height: 24px;
    max-height: 180px;

    resize: none;

    border: 0;
    outline: 0;

    background: transparent;

    color: var(--text);

    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;

    padding: 7px 8px;
}

#message::placeholder {
    color: #697687;
}

#send {
    flex-shrink: 0;

    width: 42px;
    height: 42px;

    border: 0;
    border-radius: 12px;

    background: var(--accent);

    color: #07110c;

    font-size: 0;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition:
        background 0.2s ease,
        transform 0.15s ease,
        opacity 0.2s ease;
}

#send::before {
    content: "↑";

    font-size: 21px;
    font-weight: 800;

    line-height: 1;

    transform: translateY(-1px);
}

#send:hover {
    background: var(--accent-dark);
}

#send:active {
    transform: scale(0.92);
}

#send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Focus */

#chatForm:focus-within {
    border-color: #3a4858;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(110, 231, 183, 0.08);
}

/* Animation */

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */

@media (max-width: 700px) {
    header {
        height: 58px;
        min-height: 58px;

        padding: 0 14px;
    }

    header h1 {
        font-size: 18px;
    }

    #newChat {
        padding: 8px 11px;
        font-size: 13px;
    }

    main#chat {
        padding:
            24px
            14px
            150px;
    }

    main#chat:empty::before {
        margin-top: 25vh;

        font-size: 24px;

        padding: 0 20px;
    }

    .message {
        font-size: 15px;
        margin-bottom: 22px;
    }

    .message.user {
        padding: 13px 15px;
        border-radius: 14px;
    }

    #chatForm {
        bottom: 10px;

        width: calc(100% - 20px);

        border-radius: 16px;

        padding: 8px;
    }

    #message {
        font-size: 16px;
    }

    #send {
        width: 40px;
        height: 40px;
    }
}

/* Small phones */

@media (max-width: 420px) {
    header {
        padding: 0 12px;
    }

    main#chat {
        padding-left: 12px;
        padding-right: 12px;
    }

    #chatForm {
        width: calc(100% - 14px);
        bottom: 7px;
    }
}
