* {
    box-sizing: border-box;
}

:root {
    --bg: #090d13;
    --panel: #0d131c;
    --panel2: #111923;
    --panel3: #151f2c;

    --border: #202d3d;
    --border2: #2a3b50;

    --text: #f3f6fb;
    --muted: #8391a3;

    --blue: #2f6df6;
    --blue2: #1f5bdd;

    --green: #24d88a;

    --sidebar: 300px;
    --header: 62px;
}

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

body {
    background: var(--bg);
    color: var(--text);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    overflow: hidden;
}

button,
input,
textarea,
select {
    font-family: inherit;
}


/* ============================================================
   APP
   ============================================================ */

.app {
    width: 100vw;
    height: 100vh;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
    height: var(--header);

    flex-shrink: 0;

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

    padding: 0 20px;

    background: #0a0f16;

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


.brand {
    display: flex;
    align-items: center;

    gap: 8px;
}


.brand-icon {
    font-size: 18px;
}


.brand-name {
    font-size: 15px;

    font-weight: 750;
}


.brand-version {
    padding: 3px 7px;

    border-radius: 6px;

    background: #17243a;

    color: #78a5ff;

    font-size: 10px;

    font-weight: 700;
}


.topbar-right {
    display: flex;
    align-items: center;

    gap: 8px;
}


.icon-button {
    width: 36px;
    height: 36px;

    padding: 0;

    background: transparent;

    border: 1px solid transparent;

    color: #9caabc;

    cursor: pointer;
}


.icon-button:hover {
    background: #141c27;

    border-color: var(--border);

    color: white;
}


.user-menu {
    display: flex;
    align-items: center;

    gap: 9px;

    margin-left: 8px;

    font-size: 13px;
}


.avatar {
    width: 30px;
    height: 30px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: #285ed0;

    color: white;

    font-weight: 700;
}


.logout-button {
    padding: 8px 12px;

    background: #245ee0;

    color: white;

    border: 0;

    border-radius: 7px;

    cursor: pointer;
}


/* ============================================================
   WORKSPACE
   ============================================================ */

.workspace {
    flex: 1;

    min-height: 0;

    display: grid;

    grid-template-columns:
        var(--sidebar)
        minmax(0, 1fr);

    overflow: hidden;
}


/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    min-width: 0;

    display: flex;
    flex-direction: column;

    padding: 14px;

    background: #0a1018;

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

    overflow-y: auto;
}


.new-chat {
    width: 100%;

    height: 45px;

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

    gap: 8px;

    border: 1px solid #3d7dff;

    border-radius: 9px;

    background:
        linear-gradient(
            135deg,
            #2d72f5,
            #1f59d4
        );

    color: white;

    font-size: 13px;

    font-weight: 700;

    cursor: pointer;
}


.new-chat:hover {
    filter: brightness(1.1);
}


.search-box {
    height: 42px;

    margin-top: 12px;

    display: flex;
    align-items: center;

    padding: 0 11px;

    gap: 8px;

    background: #111923;

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

    border-radius: 8px;
}


.search-icon {
    color: #65758a;
}


.search-box input {
    width: 100%;

    border: 0;

    outline: 0;

    background: transparent;

    color: white;

    font-size: 13px;
}


.search-box input::placeholder {
    color: #647286;
}


.sidebar-title {
    margin: 21px 6px 8px;

    color: #65758b;

    font-size: 11px;

    font-weight: 700;

    text-transform: uppercase;
}


.chat-list {
    display: flex;
    flex-direction: column;

    gap: 3px;
}


.chat-item {
    min-height: 55px;

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 8px 9px;

    border-radius: 8px;

    cursor: pointer;

    color: #ccd6e5;
}


.chat-item:hover {
    background: #111b28;
}


.chat-item.active {
    background: #152235;

    border: 1px solid #223a57;
}


.chat-item-icon {
    font-size: 15px;
}


.chat-item-content {
    flex: 1;

    min-width: 0;
}


.chat-item-title {
    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 13px;
}


.chat-item-date {
    margin-top: 3px;

    color: #627186;

    font-size: 10px;
}


.chat-more {
    padding: 4px;

    background: transparent;

    color: #6e7d91;

    border: 0;

    opacity: 0;
}


.chat-item:hover .chat-more {
    opacity: 1;
}


.sidebar-spacer {
    flex: 1;
    min-height: 25px;
}


.sidebar-action {
    width: 100%;

    height: 43px;

    display: flex;
    align-items: center;

    gap: 11px;

    padding: 0 10px;

    background: transparent;

    color: #c5d0df;

    border: 0;

    border-radius: 8px;

    text-align: left;

    cursor: pointer;

    font-size: 13px;
}


.sidebar-action:hover {
    background: #111b27;
}


.sidebar-footer {
    padding: 15px 8px 4px;

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

    color: #536276;

    font-size: 10px;

    line-height: 1.7;
}


.sidebar-footer span {
    color: #3f4c5e;
}


/* ============================================================
   CHAT AREA
   ============================================================ */

.chat-area {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    background:
        radial-gradient(
            circle at 50% 25%,
            rgba(38, 93, 180, .06),
            transparent 40%
        ),
        #080c12;
}


/* ============================================================
   CHAT HEADER
   ============================================================ */

.chat-header {
    min-height: 65px;

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

    padding: 0 25px;

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

    background: rgba(9, 14, 21, .9);
}


.current-chat-title {
    font-size: 14px;

    font-weight: 700;
}


.current-chat-status {
    display: flex;
    align-items: center;

    gap: 6px;

    margin-top: 4px;

    color: #64748a;

    font-size: 10px;
}


.status-dot {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: var(--green);

    box-shadow:
        0 0 8px
        rgba(36, 216, 138, .6);
}


.chat-header-actions {
    display: flex;
    gap: 6px;
}


.small-button {
    padding: 8px 11px;

    background: #111923;

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

    color: #9eacbe;

    border-radius: 7px;

    font-size: 11px;

    cursor: pointer;
}


.small-button:hover {
    background: #172232;

    color: white;
}


/* ============================================================
   MESSAGES
   ============================================================ */

.messages {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 38px clamp(20px, 7vw, 120px);
}


.welcome {
    width: min(850px, 100%);

    margin:
        8vh auto
        0;

    text-align: center;
}


.welcome-icon {
    width: 65px;
    height: 65px;

    margin: 0 auto 20px;

    display: grid;
    place-items: center;

    border-radius: 18px;

    background:
        linear-gradient(
            135deg,
            #17396e,
            #10233e
        );

    border: 1px solid #294d7e;

    font-size: 31px;

    box-shadow:
        0 15px 45px
        rgba(20, 80, 170, .18);
}


.welcome h1 {
    margin: 0;

    font-size:
        clamp(25px, 3vw, 39px);

    letter-spacing: -1px;
}


.welcome > p {
    margin: 11px 0 30px;

    color: var(--muted);

    font-size: 14px;
}


.quick-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;

    text-align: left;
}


.quick-card {
    min-height: 82px;

    display: flex;
    align-items: center;

    gap: 13px;

    padding: 15px;

    background:
        linear-gradient(
            145deg,
            #0e1722,
            #0b121b
        );

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

    border-radius: 12px;

    color: white;

    text-align: left;

    cursor: pointer;

    transition:
        border-color .15s,
        transform .15s,
        background .15s;
}


.quick-card:hover {
    transform: translateY(-2px);

    background: #111c29;

    border-color: #2c4767;
}


.quick-icon {
    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    flex-shrink: 0;

    border-radius: 10px;

    background: #17263a;

    font-size: 19px;
}


.quick-card strong {
    display: block;

    margin-bottom: 4px;

    font-size: 13px;
}


.quick-card span {
    display: block;

    color: #718096;

    font-size: 11px;
}


/* ============================================================
   NORMAL MESSAGES
   ============================================================ */

.msg {
    width: fit-content;

    max-width: min(850px, 82%);

    margin: 13px 0;

    padding: 13px 16px;

    border-radius: 14px;

    line-height: 1.65;

    white-space: pre-wrap;

    overflow-wrap: anywhere;

    font-size: 14px;
}


.msg.user {
    margin-left: auto;

    background:
        linear-gradient(
            135deg,
            #2f6df6,
            #245bd4
        );

    border: 1px solid #407cff;

    border-bottom-right-radius: 5px;
}


.msg.assistant {
    margin-right: auto;

    background:
        linear-gradient(
            145deg,
            #121b27,
            #101721
        );

    border: 1px solid #27384d;

    border-bottom-left-radius: 5px;
}


/* ============================================================
   COMPOSER
   ============================================================ */

.composer-wrapper {
    padding:
        10px
        clamp(15px, 6vw, 100px)
        15px;

    background: #080c12;

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


.composer {
    min-height: 61px;

    display: flex;
    align-items: flex-end;

    gap: 8px;

    padding: 6px;

    background: #111923;

    border: 1px solid #27394f;

    border-radius: 14px;

    box-shadow:
        0 8px 30px
        rgba(0, 0, 0, .2);
}


.composer-button {
    width: 44px;
    height: 48px;

    flex-shrink: 0;

    background: transparent;

    border: 0;

    color: #8393a8;

    font-size: 21px;

    cursor: pointer;
}


.composer-button:hover {
    color: white;
}


.composer textarea {
    flex: 1;

    min-width: 0;

    min-height: 48px;
    max-height: 230px;

    resize: none;

    padding: 13px 5px;

    background: transparent;

    color: white;

    border: 0;

    outline: 0;

    font-size: 14px;

    line-height: 1.5;
}


.composer textarea::placeholder {
    color: #627084;
}


.send-button {
    min-width: 86px;

    height: 48px;

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

    gap: 7px;

    background:
        linear-gradient(
            135deg,
            #3178fa,
            #205bdd
        );

    color: white;

    border: 0;

    border-radius: 9px;

    font-size: 12px;

    font-weight: 700;

    cursor: pointer;
}


.send-button:hover {
    filter: brightness(1.1);
}


.send-arrow {
    font-size: 15px;
}


.composer-info {
    margin-top: 7px;

    text-align: center;

    color: #48566a;

    font-size: 9px;
}


/* ============================================================
   OVERLAY
   ============================================================ */

.overlay {
    position: fixed;

    inset: 0;

    background:
        rgba(0, 0, 0, .45);

    opacity: 0;

    pointer-events: none;

    transition: opacity .2s;

    z-index: 90;
}


.overlay.show {
    opacity: 1;

    pointer-events: auto;
}


/* ============================================================
   SIDE PANEL
   ============================================================ */

.side-panel {
    position: fixed;

    top: 0;
    right: 0;

    width: min(430px, 94vw);

    height: 100vh;

    display: flex;
    flex-direction: column;

    background:
        linear-gradient(
            180deg,
            #0d141e,
            #090f17
        );

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

    box-shadow:
        -20px 0 70px
        rgba(0, 0, 0, .35);

    transform: translateX(105%);

    transition:
        transform .23s ease;

    z-index: 100;
}


.side-panel.open {
    transform: translateX(0);
}


.panel-header {
    min-height: 72px;

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

    padding: 0 20px;

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


.panel-header h2 {
    margin: 0;

    font-size: 16px;
}


.panel-header span {
    display: block;

    margin-top: 4px;

    color: #68778b;

    font-size: 10px;
}


.panel-close {
    width: 34px;
    height: 34px;

    background: transparent;

    color: #8190a5;

    border: 0;

    font-size: 24px;

    cursor: pointer;
}


.panel-close:hover {
    color: white;
}


.panel-content {
    flex: 1;

    overflow-y: auto;

    padding: 20px;
}


.setting-section {
    padding-bottom: 24px;

    margin-bottom: 24px;

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


.setting-section h3 {
    margin: 0 0 17px;

    font-size: 13px;
}


.setting-section label {
    display: block;

    margin:
        13px 0 7px;

    color: #8998aa;

    font-size: 11px;
}


.setting-section select,
.setting-section input[type="number"] {
    width: 100%;

    height: 40px;

    padding: 0 10px;

    background: #111923;

    color: white;

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

    border-radius: 8px;

    outline: 0;
}


.setting-section input[type="range"] {
    width: 100%;
}


.range-value {
    text-align: right;

    color: #6f8198;

    font-size: 10px;
}


.toggle-row {
    min-height: 44px;

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

    border-bottom: 1px solid #172331;

    color: #c5d0df;

    font-size: 12px;
}


.save-settings {
    width: 100%;

    height: 44px;

    background: var(--blue);

    color: white;

    border: 0;

    border-radius: 8px;

    font-weight: 700;

    cursor: pointer;
}


/* ============================================================
   MEMORY
   ============================================================ */

.memory-add textarea {
    width: 100%;

    min-height: 100px;

    padding: 12px;

    resize: vertical;

    background: #111923;

    color: white;

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

    border-radius: 9px;

    outline: 0;
}


.memory-add button {
    width: 100%;

    height: 42px;

    margin-top: 8px;

    background: var(--blue);

    color: white;

    border: 0;

    border-radius: 8px;

    cursor: pointer;
}


.memory-list {
    margin-top: 20px;

    display: flex;
    flex-direction: column;

    gap: 8px;
}


.memory-item {
    display: flex;
    align-items: flex-start;

    gap: 9px;

    padding: 12px;

    background: #111923;

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

    border-radius: 9px;

    color: #c8d3e2;

    font-size: 12px;
}


.memory-item span {
    flex: 1;

    line-height: 1.5;
}


.memory-item button {
    padding: 0;

    background: transparent;

    color: #66758a;

    border: 0;

    cursor: pointer;
}


.empty-memory {
    padding: 30px 10px;

    text-align: center;

    color: #526175;

    font-size: 12px;
}


/* ============================================================
   STATUS
   ============================================================ */

.status-card {
    display: flex;
    align-items: center;

    gap: 13px;

    padding: 15px;

    margin-bottom: 9px;

    background: #111923;

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

    border-radius: 10px;
}


.status-card-icon {
    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    background: #172335;

    border-radius: 9px;
}


.status-card strong {
    display: block;

    font-size: 12px;
}


.status-card span {
    display: block;

    margin-top: 4px;

    color: #708096;

    font-size: 10px;
}


/* ============================================================
   CONTEXT MENU
   ============================================================ */

.context-menu {
    position: fixed;

    display: none;

    min-width: 150px;

    padding: 5px;

    background: #121b27;

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

    border-radius: 9px;

    box-shadow:
        0 15px 40px
        rgba(0, 0, 0, .35);

    z-index: 200;
}


.context-menu.show {
    display: block;
}


.context-menu button {
    width: 100%;

    padding: 9px 11px;

    background: transparent;

    color: #c6d1df;

    border: 0;

    border-radius: 6px;

    text-align: left;

    cursor: pointer;

    font-size: 12px;
}


.context-menu button:hover {
    background: #1a2737;
}


.context-menu button.danger {
    color: #ff818c;
}


/* ============================================================
   SCROLLBARS
   ============================================================ */

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}


::-webkit-scrollbar-track {
    background: transparent;
}


::-webkit-scrollbar-thumb {
    background: #24364d;

    border-radius: 20px;
}


::-webkit-scrollbar-thumb:hover {
    background: #334b68;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 800px) {

    :root {
        --sidebar: 245px;
    }

    .quick-grid {
        grid-template-columns: 1fr;
    }

    .messages {
        padding:
            25px
            18px;
    }

}


@media (max-width: 650px) {

    .sidebar {
        display: none;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .user-menu span {
        display: none;
    }

    .chat-header {
        padding: 0 14px;
    }

    .messages {
        padding: 20px 12px;
    }

    .msg {
        max-width: 94%;
    }

    .composer-wrapper {
        padding:
            8px;
    }

    .composer {
        padding: 5px;
    }

    .send-button {
        min-width: 54px;
    }

    .send-button span:first-child {
        display: none;
    }

    .welcome {
        margin-top: 5vh;
    }

    .welcome h1 {
        font-size: 25px;
    }

}


@media (max-width: 400px) {

    .topbar {
        padding: 0 10px;
    }

    .brand-version {
        display: none;
    }

    .icon-button {
        display: none;
    }

    .current-chat-status {
        display: none;
    }

}