: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;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

html {
    -webkit-text-size-adjust: 100%;
}

input,
textarea,
button {
    font-family: inherit;
}

* {
    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 {
    width: 100%;
    max-width: 720px;

    margin: 0 auto;

    background: rgba(27, 11, 20, 0.96);

    padding: 32px;

    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-topbar {
    display: none;
}

.mobile-overlay {
    display: none;
}

.attach-btn {
    width: 46px;
    min-width: 46px;
    padding: 0;
    font-size: 20px;
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--raspberry-light);
}

.attach-btn:hover {
    background: var(--bg-card-hover);
}

@media (max-width: 800px) {

    body {
        overflow: hidden;
    }

    .mobile-topbar {
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 14px;
        background: rgba(20, 8, 14, 0.96);
        border-bottom: 1px solid var(--border);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        backdrop-filter: blur(12px);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: bold;
        font-size: 18px;
    }

    .mobile-brand img {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .menu-btn {
        width: 44px;
        height: 44px;
        padding: 0;
        margin: 0;
        border-radius: 12px;
        font-size: 20px;
    }

    .messenger {
        display: flex;
        height: 100dvh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;

        width: 88%;
        max-width: 340px;
        height: 100dvh;

        z-index: 2000;

        transform: translateX(-105%);
        transition: transform 0.25s ease;

        border-right: 1px solid var(--border);
        border-bottom: none;

        padding-top: 76px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-overlay.active {
        display: block;

        position: fixed;
        inset: 0;

        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(2px);

        z-index: 1500;
    }

    .chat-panel {
        width: 100%;
        height: 100dvh;

        padding:
            76px
            10px
            calc(env(safe-area-inset-bottom) + 10px)
            10px;
    }

    .messages {
        border-radius: 16px;
    }

    .message {
        max-width: 92%;
        font-size: 14px;
    }

    .input-area {
        position: sticky;
        bottom: 0;

        background: rgba(27,11,20,0.98);

        backdrop-filter: blur(10px);

        padding-bottom:
            calc(env(safe-area-inset-bottom) + 8px);
    }

    .upload-area {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 8px;
        padding: 8px;
    }

    .upload-area input {
        font-size: 13px;
    }

    .upload-area button {
        width: 100%;
        min-height: 42px;
    }

    /* .upload-area {
        display: none;
    } */

    .chat-image,
    .chat-video {
        max-width: 100%;
    }
}

/* 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;
    }
}

/* =========================
   AUTH MOBILE
========================= */

@media (max-width: 700px) {

    body {
        min-height: 100dvh;
        overflow-x: hidden;
    }

    .container {
        min-height: 100dvh;

        border-radius: 0;

        padding:
            calc(env(safe-area-inset-top) + 26px)
            20px
            calc(env(safe-area-inset-bottom) + 24px)
            20px;

        display: flex;
        flex-direction: column;
        justify-content: center;

        border: none;

        box-shadow: none;
    }

    .auth-logo {
        justify-content: center;
        margin-bottom: 26px;
    }

    .auth-logo img {
        width: 72px;
        height: 72px;

        border-radius: 22px;
    }

    .auth-logo h1 {
        font-size: 36px;
    }

    .container h2 {
        text-align: center;
        font-size: 32px;
        margin-bottom: 28px;
    }

    input {
        height: 54px;
        font-size: 16px;

        border-radius: 14px;

        padding: 0 16px;
    }

    button {
        min-height: 52px;

        font-size: 16px;

        border-radius: 14px;
    }

    .password-row {
        flex-direction: column;
    }

    .password-row button {
        width: 100%;
    }

    .rules {
        background: rgba(255,255,255,0.03);

        border: 1px solid var(--border);

        border-radius: 16px;

        padding: 14px;

        margin-top: 12px;
    }

    .rules ul {
        padding-left: 18px;
        margin-bottom: 0;
    }

    #result {
        margin-top: 14px;
        text-align: center;
        line-height: 1.4;
    }

    .container p {
        text-align: center;
    }

}