/* Minimal layout wrapper centering everything correctly */
body {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    gap: 40px;
    font-family: sans-serif;
}

#mobile-header {
    display: none; /* Hidden on desktop viewports */
}

/* Sidebar configuration grouped cleanly to the left */
#sidebar {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#sidebar div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

textarea#system-prompt {
    height: 80px;
    resize: vertical;
}

.mobile-only-btn {
    display: none;
}

/* Dynamic Multi-chat list switcher panel */
#chat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

.chat-item.active {
    font-weight: bold;
    text-decoration: underline;
}

.chat-item .del-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 0.8em;
}

/* Chat container grouped sensibly to the right */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 90vh;
    gap: 20px;
}

/* Scrollable message stack history container box */
#chat-history {
    flex: 1;
    overflow-y: auto;
    border: 1px solid gray;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Logical conversational lists instead of bubble canvas templates */
.msg-wrapper {
    display: flex;
    flex-direction: column;
}

.msg-user {
    align-items: flex-end;
    text-align: right;
}

.msg-ai {
    align-items: flex-start;
    text-align: left;
}

.msg-user::before {
    content: "You:";
    font-weight: bold;
    font-size: 0.85em;
    margin-bottom: 2px;
}

.msg-ai::before {
    content: "AI:";
    font-weight: bold;
    font-size: 0.85em;
    margin-bottom: 2px;
}

.bubble {
    max-width: 85%;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Code containers displaying basic copy metrics inline */
.code-container {
    width: 100%;
    margin: 8px 0;
    text-align: left;
}

.code-container button {
    font-size: 0.75em;
    cursor: pointer;
    display: block;
    margin-bottom: 4px;
}

/* Standard default plain text pre-formatted system files */
pre {
    background: #eeeeee;
    border: 1px solid #cccccc;
    padding: 10px;
    overflow-x: auto;
    font-family: monospace;
}

code {
    font-family: monospace;
}

@media (prefers-color-scheme: dark) {
    pre {
        background: #222222;
        border: 1px solid #444444;
    }
}

/* Native multi-line prompt box layouts layout elements */
#input-area {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    height: 50px;
    resize: none;
}

#send-btn {
    padding: 0 20px;
    cursor: pointer;
}

/* --- Mobile Responsiveness Styles --- */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        padding: 10px;
        gap: 0;
        height: 100vh;
    }

    #mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid gray;
        background: var(--bg);
        z-index: 10;
    }

    #mobile-header button {
        background: transparent;
        border: none;
        cursor: pointer;
        font-family: monospace;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: -100%; /* Off-screen default positioning */
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: #ffffff;
        z-index: 100;
        padding: 20px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        transition: left 0.3s ease;
    }

    @media (prefers-color-scheme: dark) {
        #sidebar { background: #111111; }
    }

    /* Active visibility selector rule class */
    #sidebar.mobile-open {
        left: 0;
    }

    .mobile-only-btn {
        display: inline-block;
        background: transparent;
        border: none;
        cursor: pointer;
    }

    #main {
        height: calc(100vh - 60px);
        margin-top: 10px;
    }

    #chat-history {
        padding: 10px;
    }

    .bubble {
        max-width: 100%; /* Allow code text cards to occupy full mobile width profiles */
    }
}
