/* Reset sizing defaults */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Lock root elements to fixed screen height */
html, body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height */
    overflow: hidden;
    overscroll-behavior: none; /* Prevents pull-to-refresh and bounce scrolling */
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #181A1B;
    color: #C8C3BC;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

h2 {
    color: #C8C3BC;
    margin-bottom: 15px;
}

.hidden {
    display: none !important;
}

/* -------------------------------------------------- */
/* Auth Section - Centered Card                       */
/* -------------------------------------------------- */
#auth-section {
    width: 100%;
    max-width: 400px;
    background: #131516;
    border: 1px solid #393D40;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#auth-section input {
    width: 100%;
    margin-bottom: 12px;
}

#auth-section button {
    width: 48%;
    margin-right: 2%;
}

#auth-section button:last-of-type {
    margin-right: 0;
}

/* -------------------------------------------------- */
/* Chat Section - Full Screen Dynamic Flex Container  */
/* -------------------------------------------------- */
#chat-section {
    width: 100%;
    max-width: 800px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Flex child grow handles responsive height scaling */
#chat-box {
    flex: 1;
    min-height: 0; /* Required for nested flexbox scrolling */
    border: 1px solid #393D40;
    border-radius: 8px;
    background: #131516;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

/* Input Row Layout */
#chat-section {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: hidden;
}

#chat-section > div:last-child {
/* Ensures input bar stays aligned at bottom */
display: flex;
gap: 8px;
width: 100%;
flex-shrink: 0;
}

.input-container {
    display: flex;
    gap: 8px;
    width: 100%;
    flex-shrink: 0; /* Prevents input box from shrinking when keyboard opens */
}
}
#msg-input {
    flex: 1;
    font-size: 16px; /* Prevents iOS Safari auto-zoom on input focus */
}

/* -------------------------------------------------- */
/* Message Elements                                   */
/* -------------------------------------------------- */
.msg {
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
}

.user {
    font-weight: 600;
}

.time {
    color: #999;
    font-size: 0.75em;
    margin-left: 6px;
}

.system-msg {
    color: #9E9689;
    background: #202224;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-align: center;
    font-size: 0.85em;
}

#load-more-btn {
margin-bottom: 12px;
text-align: center;
}

#load-more-btn button {
background: #202224;
border: 1px solid #393D40;
color: #C8C3BC;
cursor: pointer;
padding: 6px 12px;
font-size: 0.85em;
border-radius: 4px;
}

/* Form Inputs & Buttons */
input {
    background: #2B2D2F;
    color: white;
    border: 1px solid #393D40;
}

input[type="text"], input[type="password"] {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px; /* Prevents auto-zoom on iOS safari */
}

button {
    padding: 10px 16px;
    background: #2B2D2F;
    color: white;
    border: 1px solid #393D40;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

button:hover {
    background-color: #131516;
}

/* Mobile Specific Adjustments */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    #chat-section {
    max-width: 100%;
    }

    h2 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
}
