* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family:
        Inter,
        "Segoe UI",
        Tahoma,
        Arial,
        sans-serif;

    background: #212121;
    color: #ececec;

    overflow: hidden;
}


/* =========================
   APP
========================= */

.app {
    width: 100%;
    height: 100vh;

    display: flex;
}


/* =========================
   SIDEBAR
========================= */

.sidebar {
    width: 260px;
    height: 100vh;

    flex-shrink: 0;

    background: #171717;

    border-left: 1px solid #2d2d2d;

    display: flex;
    flex-direction: column;

    padding: 12px;

    position: relative;

    z-index: 100;
}


.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 6px 4px 14px;
}


.brand {
    display: flex;

    align-items: center;

    gap: 9px;
}


.brand-mark {
    width: 29px;
    height: 29px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 8px;

    background: #f5f5f5;

    color: #171717;

    font-size: 15px;

    font-weight: 700;
}


.brand-name {
    font-size: 16px;

    font-weight: 600;
}


.collapse-btn {
    border: none;

    background: transparent;

    color: #8f8f8f;

    font-size: 23px;

    cursor: pointer;

    display: none;
}


/* =========================
   NEW CHAT
========================= */

.new-chat-btn {
    width: 100%;

    height: 44px;

    border-radius: 8px;

    border: 1px solid #3c3c3c;

    background: #222222;

    color: #ececec;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 8px;

    font-size: 13px;

    transition: background 0.15s ease;
}

.new-chat-btn:hover {
    background: #2a2a2a;
}

.new-chat-plus {
    font-size: 20px;

    line-height: 1;
}


/* =========================
   SEARCH
========================= */

.search-box {
    margin-top: 12px;

    height: 40px;

    border: 1px solid #303030;

    background: #212121;

    border-radius: 8px;

    display: flex;

    align-items: center;

    padding: 0 10px;

    gap: 7px;
}


.search-icon {
    color: #777;

    font-size: 19px;
}


.search-box input {
    flex: 1;

    min-width: 0;

    border: none;

    outline: none;

    background: transparent;

    color: #ddd;

    font-family: inherit;

    font-size: 12px;
}

.search-box input::placeholder {
    color: #707070;
}


/* =========================
   HISTORY
========================= */

.history-title {
    padding: 18px 7px 8px;

    color: #777;

    font-size: 11px;
}


.history {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding-right: 2px;
}


.history-item {
    width: 100%;

    border: none;

    background: transparent;

    color: #c7c7c7;

    padding: 10px;

    border-radius: 7px;

    text-align: right;

    font-family: inherit;

    font-size: 12px;

    cursor: pointer;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;

    transition: background 0.15s ease;
}

.history-item:hover,
.history-item.active {
    background: #2a2a2a;

    color: #f2f2f2;
}


.history-empty {
    color: #666;

    font-size: 11px;

    padding: 10px 7px;
}


/* =========================
   SIDEBAR FOOTER
========================= */

.sidebar-footer {
    border-top: 1px solid #2a2a2a;

    padding-top: 8px;

    margin-top: 8px;
}


.sidebar-item {
    width: 100%;

    padding: 11px 10px;

    border: none;

    background: transparent;

    border-radius: 7px;

    color: #b7b7b7;

    cursor: pointer;

    display: flex;

    align-items: center;

    gap: 9px;

    font-family: inherit;

    font-size: 12px;

    text-align: right;
}

.sidebar-item:hover {
    background: #222;

    color: #fff;
}


/* =========================
   MAIN
========================= */

.main {
    flex: 1;

    min-width: 0;

    height: 100vh;

    display: flex;

    flex-direction: column;

    background: #212121;
}


/* =========================
   TOPBAR
========================= */

.topbar {
    height: 56px;

    flex-shrink: 0;

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 0 20px;

    border-bottom: 1px solid #2c2c2c;

    background: #212121;
}


.model-selector {
    display: flex;

    align-items: center;

    gap: 6px;

    font-size: 14px;

    font-weight: 600;

    color: #ededed;
}


.chevron {
    color: #888;

    font-size: 15px;
}


.connection-status {
    display: flex;

    align-items: center;

    gap: 6px;

    color: #7f7f7f;

    font-size: 10px;
}


.status-dot {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: #63c174;
}


.topbar-right,
.topbar-left {
    display: flex;

    align-items: center;
}


.mobile-menu-btn,
.mobile-new-chat {
    border: none;

    background: transparent;

    color: #aaa;

    cursor: pointer;

    display: none;
}


/* =========================
   CHAT
========================= */

.chat-container {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 24px 18px 30px;
}


.welcome {
    max-width: 760px;

    margin: 10vh auto 0;

    text-align: center;
}


.welcome-mark {
    width: 52px;
    height: 52px;

    margin: 0 auto 22px;

    border-radius: 15px;

    display: flex;

    align-items: center;
    justify-content: center;

    background: #f0f0f0;

    color: #161616;

    font-size: 22px;

    font-weight: 700;
}


.welcome h1 {
    margin: 0;

    font-size: 30px;

    font-weight: 600;

    letter-spacing: -0.5px;

    color: #f5f5f5;
}


.welcome p {
    margin-top: 10px;

    color: #8d8d8d;

    font-size: 13px;

    line-height: 1.8;
}


/* =========================
   QUICK PROMPTS
========================= */

.quick-prompts {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 9px;

    margin-top: 34px;
}


.quick-prompts button {
    min-height: 77px;

    padding: 14px;

    border: 1px solid #333;

    background: #242424;

    border-radius: 9px;

    color: #ddd;

    text-align: right;

    cursor: pointer;

    font-family: inherit;

    transition: background 0.15s ease;
}


.quick-prompts button:hover {
    background: #2a2a2a;
}


.quick-prompts strong {
    display: block;

    font-size: 12px;

    font-weight: 600;
}


.quick-prompts span {
    display: block;

    margin-top: 5px;

    color: #777;

    font-size: 10px;

    line-height: 1.5;
}


/* =========================
   MESSAGES
========================= */

.messages {
    max-width: 850px;

    margin: 0 auto;
}


.message-row {
    width: 100%;

    margin: 24px 0;

    display: flex;

    animation: messageAppear 0.18s ease;
}


@keyframes messageAppear {
    from {
        opacity: 0;

        transform: translateY(4px);
    }

    to {
        opacity: 1;

        transform: translateY(0);
    }
}


.message-row.user {
    justify-content: flex-start;
}


.message-row.ai {
    justify-content: flex-end;
}


.message {
    max-width: 78%;

    font-size: 14px;

    line-height: 1.9;

    white-space: pre-wrap;

    color: #ececec;
}


.message.user {
    padding: 11px 15px;

    background: #2f2f2f;

    border-radius: 15px 15px 4px 15px;
}


.message.ai {
    width: 100%;

    padding: 3px 0;

    color: #e8e8e8;

    border-radius: 0;
}


/* =========================
   MESSAGE TOOLS
========================= */

.message-tools {
    margin-top: 9px;

    display: flex;

    align-items: center;

    gap: 4px;

    opacity: 0;

    transition: opacity 0.15s ease;
}


.message:hover .message-tools {
    opacity: 1;
}


.copy-btn {
    border: none;

    background: transparent;

    color: #777;

    font-size: 10px;

    cursor: pointer;

    padding: 3px 5px;

    border-radius: 5px;
}


.copy-btn:hover {
    background: #292929;

    color: #ddd;
}


/* =========================
   TYPING
========================= */

.typing {
    display: inline-flex;

    align-items: center;

    gap: 4px;

    color: #777;
}


.typing span {
    width: 5px;
    height: 5px;

    background: #777;

    border-radius: 50%;

    animation: blink 1.1s infinite;
}


.typing span:nth-child(2) {
    animation-delay: 0.15s;
}


.typing span:nth-child(3) {
    animation-delay: 0.3s;
}


@keyframes blink {
    0%,
    70%,
    100% {
        opacity: 0.25;
    }

    35% {
        opacity: 1;
    }
}


/* =========================
   COMPOSER
========================= */

.composer-area {
    width: min(860px, 100%);

    margin: 0 auto;

    padding: 0 16px 17px;
}


.composer {
    width: 100%;

    border: 1px solid #444;

    background: #2f2f2f;

    border-radius: 17px;

    padding: 10px 10px 8px;

    box-shadow:
        0 10px 35px rgba(0, 0, 0, 0.15);
}


#messageInput {
    width: 100%;

    min-height: 30px;

    max-height: 180px;

    padding: 7px 4px;

    resize: none;

    border: none;

    outline: none;

    background: transparent;

    color: #f0f0f0;

    font-family: inherit;

    font-size: 14px;

    line-height: 1.7;

    direction: rtl;
}


#messageInput::placeholder {
    color: #898989;
}


.composer-actions {
    display: flex;

    align-items: center;

    justify-content: space-between;
}


.composer-left,
.composer-right {
    display: flex;

    align-items: center;

    gap: 8px;
}


.composer-btn {
    width: 31px;
    height: 31px;

    border: none;

    border-radius: 7px;

    background: transparent;

    color: #999;

    cursor: pointer;

    font-size: 21px;
}


.composer-btn:hover {
    background: #3a3a3a;

    color: #ddd;
}


.shortcut {
    color: #707070;

    font-size: 9px;
}


.send-btn {
    width: 34px;
    height: 34px;

    border: none;

    border-radius: 9px;

    background: #f1f1f1;

    color: #181818;

    display: flex;

    align-items: center;

    justify-content: center;

    cursor: pointer;

    transition: opacity 0.15s ease;
}


.send-btn:hover {
    opacity: 0.85;
}


.send-btn:disabled {
    opacity: 0.35;

    cursor: not-allowed;
}


.composer-note {
    text-align: center;

    margin-top: 7px;

    color: #666;

    font-size: 9px;
}


/* =========================
   OVERLAY
========================= */

.overlay {
    display: none;
}


/* =========================
   SCROLLBAR
========================= */

::-webkit-scrollbar {
    width: 6px;
}


::-webkit-scrollbar-track {
    background: transparent;
}


::-webkit-scrollbar-thumb {
    background: #3a3a3a;

    border-radius: 99px;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 760px) {

    .sidebar {
        position: fixed;

        top: 0;
        right: 0;

        transform: translateX(100%);

        transition:
            transform 0.2s ease;

        box-shadow:
            -20px 0 50px rgba(0, 0, 0, 0.4);
    }


    .sidebar.open {
        transform: translateX(0);
    }


    .collapse-btn {
        display: block;
    }


    .overlay.visible {
        display: block;

        position: fixed;

        inset: 0;

        background: rgba(0, 0, 0, 0.55);

        z-index: 90;
    }


    .mobile-menu-btn {
        display: block;

        font-size: 20px;

        margin-left: 8px;
    }


    .mobile-new-chat {
        display: block;

        font-size: 22px;

        margin-left: 10px;
    }


    .connection-status {
        display: none;
    }


    .topbar {
        padding: 0 12px;
    }


    .chat-container {
        padding: 18px 12px 25px;
    }


    .welcome {
        margin-top: 7vh;
    }


    .welcome h1 {
        font-size: 24px;
    }


    .welcome p {
        font-size: 12px;

        padding: 0 15px;
    }


    .quick-prompts {
        grid-template-columns: 1fr;

        margin-top: 25px;
    }


    .quick-prompts button {
        min-height: 65px;
    }


    .messages {
        width: 100%;
    }


    .message {
        max-width: 90%;

        font-size: 13px;
    }


    .message.ai {
        max-width: 100%;
    }


    .composer-area {
        padding: 0 9px 10px;
    }
}


@media (max-width: 430px) {

    .welcome-mark {
        width: 46px;
        height: 46px;
    }


    .welcome h1 {
        font-size: 22px;
    }


    .model-selector {
        font-size: 13px;
    }


    .composer-note {
        font-size: 8px;
    }
}