:root {
    --bg-main: #12070d;
    --bg-panel: #1b0b14;
    --bg-panel-soft: #24101b;
    --bg-card: #2b1421;
    --bg-card-hover: #371829;

    --raspberry: #d61f69;
    --raspberry-light: #ff4f93;
    --raspberry-dark: #9f164c;

    --text-main: #f7eaf1;
    --text-muted: #b98ca3;
    --border: #48263a;

    --message-other: #24101b;
    --message-mine: linear-gradient(135deg, #d61f69, #8d1b52);

    --danger: #ff5c7a;
    --success: #4ade80;

    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: radial-gradient(circle at top left, #3a1028, var(--bg-main) 45%);
    color: var(--text-main);
}

.container,
.chat-container {
    max-width: 720px;
    margin: 40px auto;
    background: rgba(27, 11, 20, 0.96);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

input {
    padding: 12px 14px;
    margin: 5px 0;
    width: 100%;
    background: #12070d;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

input:focus {
    border-color: var(--raspberry-light);
    box-shadow: 0 0 0 3px rgba(214, 31, 105, 0.2);
}

input::placeholder {
    color: var(--text-muted);
}

button {
    padding: 11px 16px;
    cursor: pointer;
    margin-top: 5px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--raspberry), var(--raspberry-dark));
    color: white;
    font-weight: bold;
    transition: 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(214, 31, 105, 0.25);
}

button:active {
    transform: translateY(0);
}

button:disabled,
input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

a {
    color: var(--raspberry-light);
}

.password-row {
    display: flex;
    gap: 8px;
}

.password-row input {
    flex: 1;
}

.rules {
    font-size: 14px;
    color: var(--text-muted);
    margin: 10px 0;
}

#result {
    white-space: pre-line;
    font-weight: bold;
}

/* Messenger layout */

.messenger {
    display: flex;
    height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(214, 31, 105, 0.18), transparent 32%),
        linear-gradient(135deg, #10060b, #1a0913);
}

.sidebar {
    width: 360px;
    background: rgba(27, 11, 20, 0.98);
    border-right: 1px solid var(--border);
    padding: 18px;
    overflow-y: auto;
    box-sizing: border-box;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 18px;
    box-sizing: border-box;
    min-width: 0;
}

.profile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: linear-gradient(135deg, #2b1421, #1b0b14);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.profile b {
    font-size: 22px;
    letter-spacing: 0.5px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 14px;
    box-shadow:
        0 0 25px rgba(214, 31, 105, 0.35),
        0 0 60px rgba(214, 31, 105, 0.15);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-text b {
    font-size: 24px;
    letter-spacing: 0.5px;
}

.brand-text span {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

#me {
    color: var(--text-muted);
    font-size: 14px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

h2,
h3 {
    margin-top: 0;
}

h3 {
    color: var(--text-main);
    font-size: 15px;
    opacity: 0.95;
}

.search-block {
    margin-top: 12px;
}

.list-item,
.chat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: 0.15s ease;
}

.list-item button {
    margin-right: 6px;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 13px;
}

.chat-item:hover,
.list-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--raspberry);
}

.chat-item small,
.list-item small {
    color: var(--text-muted);
}

.chat-header {
    background: rgba(27, 11, 20, 0.96);
    padding: 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.chat-header h2 {
    margin: 0;
}

/* Messages */

.messages {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border);
    padding: 14px;
    margin: 0 0 12px 0;
    background:
        radial-gradient(circle at bottom right, rgba(214, 31, 105, 0.12), transparent 35%),
        rgba(18, 7, 13, 0.88);
    border-radius: var(--radius-lg);
}

.message {
    max-width: 72%;
    padding: 11px 13px;
    margin-bottom: 12px;
    background: var(--message-other);
    border-radius: 16px 16px 16px 4px;
    border: 1px solid var(--border);
    box-sizing: border-box;
    color: var(--text-main);
}

.my-message {
    margin-left: auto;
    background: var(--message-mine);
    border-color: rgba(255, 255, 255, 0.12);
    border-radius: 16px 16px 4px 16px;
}

.message-header {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--raspberry-light);
}

.my-message .message-header {
    color: #ffe6f0;
}

.message-text {
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.35;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

.my-message .message-time {
    color: rgba(255, 255, 255, 0.75);
}

/* Inputs */

.input-area,
.upload-area {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    background: rgba(27, 11, 20, 0.96);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px;
}

.input-area input,
.upload-area input {
    flex: 1;
    margin: 0;
}

.input-area button,
.upload-area button {
    margin: 0;
    white-space: nowrap;
}

/* Media */

.chat-image {
    max-width: 260px;
    display: block;
    margin-top: 8px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-video {
    max-width: 320px;
    display: block;
    margin-top: 8px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Unread */

.has-new-message {
    border-left: 4px solid var(--raspberry-light);
    background: linear-gradient(135deg, rgba(214, 31, 105, 0.22), var(--bg-card));
}

.unread-badge {
    float: right;
    background: var(--raspberry);
    color: white;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 0 12px rgba(214, 31, 105, 0.45);
}

/* Scrollbar */

.sidebar::-webkit-scrollbar,
.messages::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
    background: var(--raspberry-dark);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
    background: transparent;
}

.container {
    position: relative;
    overflow: hidden;
}

.container::before {
    content: "";
    position: absolute;
    inset: -80px;
    background:
        radial-gradient(circle at top left, rgba(255, 79, 147, 0.22), transparent 35%),
        radial-gradient(circle at bottom right, rgba(214, 31, 105, 0.16), transparent 40%);
    pointer-events: none;
}

.container > * {
    position: relative;
    z-index: 1;
}

.container h2 {
    font-size: 30px;
    margin-top: 0;
    margin-bottom: 18px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.auth-logo img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(214, 31, 105, 0.35);
}

.auth-logo h1 {
    margin: 0;
    font-size: 30px;
}

/* Mobile */

@media (max-width: 800px) {
    .messenger {
        flex-direction: column;
        height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: 42vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px;
    }

    .chat-panel {
        height: 58vh;
        padding: 12px;
    }

    .chat-header {
        padding: 12px;
        margin-bottom: 10px;
    }

    .messages {
        padding: 10px;
        border-radius: var(--radius-md);
    }

    .message {
        max-width: 90%;
        font-size: 14px;
    }

    .input-area,
    .upload-area {
        padding: 8px;
        gap: 6px;
    }

    .input-area button,
    .upload-area button {
        padding: 10px;
        font-size: 13px;
    }

    .chat-image {
        max-width: 220px;
    }

    .chat-video {
        max-width: 240px;
    }
}

@media (max-width: 520px) {
    .container,
    .chat-container {
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
    }

    .sidebar {
        height: 38vh;
    }

    .chat-panel {
        height: 62vh;
    }

    .profile b {
        font-size: 19px;
    }

    .input-area {
        flex-direction: row;
    }

    .upload-area {
        flex-direction: column;
    }

    .message {
        max-width: 96%;
    }

    button {
        padding: 10px 12px;
    }
}