
:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, sans-serif;
    background: #0b1220;
    color: #edf2ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100dvh;
}

button, input, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 12px;
    background: #688aff;
    color: #081225;
    padding: 12px 20px;
    font-weight: 650;
}

button:hover {
    filter: brightness(1.1);
}

button:disabled {
    opacity: .5;
    cursor: wait;
}

input, textarea {
    border: 1px solid #33415c;
    border-radius: 12px;
    background: #151f32;
    color: #fff;
    padding: 13px 15px;
    width: 100%;
    outline-offset: 3px;
}

input:focus, textarea:focus {
    border-color: #8aa3ff;
}

[hidden] {
    display: none !important;
}

.login-view {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 410px);
    padding: 38px;
    border: 1px solid #293751;
    border-radius: 24px;
    background: #121d30;
    box-shadow: 0 24px 80px #0004;
}

.brand-icon {
    color: #9bb0ff;
    font-size: 36px;
}

.brand-icon.small {
    font-size: 24px;
}

.login-card h1 {
    font-size: 28px;
    margin: 12px 0 4px;
}

.subtitle {
    color: #9eabc3;
    margin: 0 0 30px;
}

#loginForm {
    display: grid;
    gap: 11px;
}

#loginForm label {
    font-size: 13px;
    color: #c1cbe0;
}

#loginForm button {
    margin-top: 14px;
}

.error {
    color: #ff9b9b;
    min-height: 1.2em;
    font-size: 14px;
}

.chat-view {
    width: min(100%, 1100px);
    margin: auto;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #10192a;
    border-inline: 1px solid #28354d;
}

.chat-header {
    padding: 17px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #29364d;
}

.header-identity, .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-identity h1 {
    margin: 0;
    font-size: 18px;
}

.header-identity p {
    color: #9eabc3;
    font-size: 12px;
    margin: 3px 0 0;
}

#currentUser {
    color: #aab9d4;
    font-size: 13px;
}

.secondary {
    background: #26344c;
    color: #e8eeff;
    padding: 9px 13px;
}

.connection-status {
    min-height: 20px;
    padding: 3px 20px;
    color: #9aabc7;
    font-size: 12px;
    text-align: center;
}

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: min(78%, 560px);
    align-self: flex-start;
}

.message.mine {
    align-self: flex-end;
}

.bubble {
    padding: 12px 15px;
    background: #26334a;
    border-radius: 17px 17px 17px 5px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: 1.45;
}

.mine .bubble {
    background: #3d5da4;
    border-radius: 17px 17px 5px 17px;
}

.message-meta {
    font-size: 11px;
    color: #91a0ba;
    margin: 5px 4px 0;
}

.mine .message-meta {
    text-align: right;
}

.composer {
    padding: 15px 20px;
    display: flex;
    align-items: end;
    gap: 12px;
    border-top: 1px solid #29364d;
}

.composer textarea {
    resize: none;
    max-height: 140px;
    min-height: 48px;
}

.composer button {
    height: 48px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 600px) {
    .chat-header {
        padding: 12px;
    }

    .messages {
        padding: 12px;
    }

    .composer {
        padding: 10px;
    }

    #currentUser {
        display: none;
    }

    .message {
        max-width: 88%;
    }

    .login-card {
        padding: 28px 22px;
    }
}

/* ============================================================
   Messaging v0.2 — Message Management
   ============================================================ */

.message {
    position: relative;
    min-width: 0;
}

.message-body {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.message.mine .message-body {
    flex-direction: row;
}

.message-body .bubble {
    min-width: 0;
}

.bubble.deleted {
    background: #202a3c;
    color: #aab6cb;
    font-style: italic;
    border: 1px solid #3b465b;
}

.message-menu-button {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    color: #c8d3e8;
    font-size: 22px;
    line-height: 1;
}

.message-menu-button:hover,
.message-menu-button:focus-visible {
    background: #293a56;
}

.message-context-menu {
    position: fixed;
    z-index: 1000;
    min-width: 180px;
    padding: 5px;
    border: 1px solid #40516e;
    border-radius: 12px;
    background: #19263a;
    box-shadow: 0 12px 35px #0009;
}

.message-menu-action {
    display: block;
    width: 100%;
    padding: 11px 13px;
    border-radius: 7px;
    background: transparent;
    color: #edf2ff;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
}

.message-menu-action:hover,
.message-menu-action:focus-visible {
    background: #344865;
}

.message-edit-form {
    width: min(100%, 440px);
    min-width: min(260px, 70vw);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-edit-input {
    width: 100%;
    min-height: 90px;
    resize: vertical;
    line-height: 1.45;
}

.message-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.message-edit-actions button {
    padding: 8px 13px;
    border-radius: 8px;
    font-size: 13px;
}

.message:focus-visible {
    outline: 2px solid #8aa3ff;
    outline-offset: 4px;
    border-radius: 8px;
}

@media (max-width: 600px) {
    .message-menu-button {
        width: 36px;
        height: 36px;
    }

    .message-context-menu {
        min-width: 175px;
    }

    .message-edit-form {
        min-width: min(230px, 70vw);
    }
}
