body {
    background: #111;
    color: white;
    font-family: sans-serif;
    margin: 0;
    padding: 20px;
}

h1 { margin-top: 0; }

#join-screen {
    max-width: 400px;
    margin: auto;
    text-align: center;
}

#chat-screen {
    width: 95vw;
    max-width: 1400px;
    margin: auto;
}


#messages {
    height: 75vh;
    overflow-y: auto;
    border: 1px solid #444;
    padding: 10px;
    margin-bottom: 10px;
}

/* attachment preview strip */
#attachment-preview {
    display: none;
    align-items: center;
    gap: 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.preview-img {
    max-height: 80px;
    max-width: 120px;
    border-radius: 6px;
    object-fit: cover;
}

.preview-icon {
    font-size: 24px;
}

.preview-name {
    flex: 1;
    font-size: 13px;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cancel-attach {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

#cancel-attach:hover {
    color: white;
}

/* bottom bar */
#bottom-bar {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#attach-btn {
    background: none;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
    color: white;
    line-height: 1.4;
    flex-shrink: 0;
}

#attach-btn:hover {
    background: #222;
}

#message-input {
    flex: 1;
    background: #222;
    color: white;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 15px;
    box-sizing: border-box;
    min-height: 30px;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
    word-break: break-word;
    white-space: pre-wrap;
    outline: none;
}

#message-input:empty::before {
    content: attr(placeholder);
    color: #888;
    pointer-events: none;
}

button {
    padding: 4px 16px;
    font-size: 15px;
    cursor: pointer;
}

/* messages */
.message {
    margin-bottom: 2px;
}

.message:not(.grouped) {
    margin-top: 14px;
}

#messages > .message:first-child {
    margin-top: 4px;
}
.username {
    font-size: 14px;
    font-weight: bold;

    margin-left: 8px;

    margin-bottom: 3px;

    line-height: 1;
}
.bubble {
    background: #222;
    border-radius: 10px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 80%;
}

.bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}

.timestamp {
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
    line-height: 1;
    padding-bottom: 1px;
}

/* image bubbles */
.bubble-file {
    display: inline-block;
    padding: 6px;
}

.chat-image {
    display: block;
    max-width: 250px;
    max-height: 300px;
    border-radius: 6px;
    cursor: pointer;
}

.timestamp-block {
    display: block;
    text-align: right;
    margin-top: 3px;
    font-size: 11px;
    color: #888;
}

/* file link */
.file-link {
    color: #58a6ff;
    text-decoration: none;
    word-break: break-all;
}

.file-link:hover {
    text-decoration: underline;
}

/* own messages */
.own-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.own-message .bubble {
    background: #1f3b5a;
}

/* date separator */
.date-separator {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #888;
    font-size: 13px;
    font-weight: bold;
}

.date-separator::before,
.date-separator::after {
    content: "";
    flex: 1;
    border-top: 1px solid #555;
}

.date-separator::before { margin-right: 12px; }
.date-separator::after  { margin-left: 12px; }

#image-viewer {
    position: fixed;

    top: 0;
    left: 0;

    width: 100vw;
    height: 100vh;

    background: rgba(0,0,0,0.9);

    display: none;

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

    z-index: 9999;
}

#viewer-image {
    max-width: 95%;
    max-height: 95%;

    border-radius: 10px;
}

.grouped {
    margin-bottom: 2px;
}

/* other user grouped: flatten top-left only */
.grouped .bubble {
    border-top-left-radius: 3px;
}

/* own message grouped: flatten top-right only */
.own-message.grouped .bubble {
    border-top-left-radius: 10px;
    border-top-right-radius: 3px;
}

.grouped + .message:not(.grouped) {
    margin-top: 14px;
}
#header {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chat-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-bottom: 20px;
}