* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: #080b16;
    color: #f5f7ff;
}

.hidden {
    display: none !important;
}

button,
input {
    font: inherit;
}


/* =========================================
   LINK PAGE
========================================= */

.link-page,
#linkPage {
    width: 100%;
    min-height: 100vh;

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

    padding: 20px;
}

.link-card {
    width: min(420px, 100%);

    padding: 30px 24px;

    border-radius: 24px;

    background: #111827;

    border: 1px solid rgba(255, 255, 255, 0.08);

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.45);

    text-align: center;
}

.signal-logo,
.logo {
    width: 70px;
    height: 70px;

    margin: 0 auto 20px;

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

    border-radius: 50%;

    background: #3b82f6;

    font-size: 32px;
}

.link-card h1,
.link-card h2 {
    margin: 0 0 10px;

    font-size: 30px;
}

.link-description {
    margin: 0 0 20px;

    color: #9ca8bd;

    line-height: 1.5;
}


/* =========================================
   QR
========================================= */
#qrStep {
    width: 100%;
}

.qr-container,
#qrContainer {
    width: 320px;
    height: 320px;

    max-width: 82vw;
    max-height: 82vw;

    margin: 24px auto;

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

    background: #ffffff;

    padding: 18px;
    box-sizing: border-box;

    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.25);

    overflow: hidden;
}

.qr-container img,
#qrContainer img {
    display: block;

    width: 100%;
    height: 100%;

    padding: 0;
    margin: 0;

    object-fit: contain;

    background: #ffffff;

    border: 0;
    border-radius: 6px;
}
/* =========================================
   STATUS
========================================= */

.status,
#linkStatus {
    min-height: 24px;

    margin: 12px 0;

    color: #aab4c8;

    font-size: 14px;

    line-height: 1.5;
}

.qr-help {
    margin-top: 16px;

    color: #8d98ad;

    font-size: 13px;

    line-height: 1.6;
}


/* =========================================
   SUCCESS
========================================= */

.success-icon {
    width: 70px;
    height: 70px;

    margin: 0 auto 20px;

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

    border-radius: 50%;

    background: #22c55e;

    color: white;

    font-size: 38px;
}


/* =========================================
   APP
========================================= */

.app-page {
    width: 100%;
    height: 100vh;

    display: flex;

    overflow: hidden;
}


/* =========================================
   SIDEBAR
========================================= */

.sidebar {
    width: 360px;
    min-width: 360px;

    background: #101522;

    border-right:
        1px solid rgba(255, 255, 255, 0.07);

    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 18px;
}

.profile {
    display: flex;
    align-items: center;

    gap: 12px;
}

.profile small,
.chat-info small {
    display: block;

    margin-top: 3px;

    color: #8d98ad;

    font-size: 12px;
}

.avatar {
    width: 44px;
    height: 44px;

    flex-shrink: 0;

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

    border-radius: 50%;

    background: #263653;

    font-weight: 700;
}


/* =========================================
   SEARCH
========================================= */

.search-box {
    margin: 0 14px 12px;

    padding: 10px 14px;

    display: flex;
    align-items: center;

    gap: 8px;

    border-radius: 12px;

    background: #1a2131;
}

.search-box input {
    width: 100%;

    border: 0;
    outline: 0;

    background: transparent;

    color: white;
}


/* =========================================
   CONVERSATIONS
========================================= */

.conversation-list {
    flex: 1;

    overflow-y: auto;
}

.conversation {
    padding: 14px 16px;

    display: flex;

    gap: 12px;

    cursor: pointer;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.04);
}

.conversation:hover {
    background: #171e2d;
}

.conversation.active {
    background: #1c2639;
}

.conversation-body {
    min-width: 0;

    flex: 1;
}

.conversation-top {
    display: flex;

    justify-content: space-between;

    gap: 8px;
}

.conversation-name {
    font-weight: 700;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.conversation-time {
    color: #77839a;

    font-size: 11px;
}

.conversation-preview {
    margin-top: 5px;

    color: #8d98ad;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.unread {
    min-width: 20px;
    height: 20px;

    padding: 0 6px;

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

    border-radius: 20px;

    background: #3b82f6;

    font-size: 11px;
}


/* =========================================
   CHAT
========================================= */

.chat {
    flex: 1;

    min-width: 0;

    display: flex;
    flex-direction: column;

    background:
        radial-gradient(
            circle at top,
            #151d31,
            #080b16 70%
        );
}

.chat-header {
    height: 70px;

    padding: 12px 18px;

    display: flex;
    align-items: center;

    gap: 12px;

    background: rgba(12, 16, 27, 0.88);

    border-bottom:
        1px solid rgba(255, 255, 255, 0.06);
}

.back-btn {
    display: none;

    border: 0;

    background: transparent;

    color: white;

    font-size: 24px;
}

.chat-info {
    min-width: 0;
}

.chat-info strong {
    display: block;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================
   MESSAGES
========================================= */

.messages {
    flex: 1;

    padding: 24px;

    overflow-y: auto;

    display: flex;
    flex-direction: column;

    gap: 8px;
}

.empty-chat {
    margin: auto;

    text-align: center;

    color: #78849b;
}

.empty-chat > div {
    font-size: 48px;
}

.empty-chat h2 {
    color: #dbe2f0;
}

.message {
    max-width: min(75%, 620px);

    padding: 10px 13px;

    border-radius: 16px;

    line-height: 1.45;

    word-wrap: break-word;
}

.message.incoming {
    align-self: flex-start;

    background: #1a2232;

    border-bottom-left-radius: 5px;
}

.message.outgoing {
    align-self: flex-end;

    background: #2563eb;

    border-bottom-right-radius: 5px;
}

.message-time {
    margin-top: 4px;

    font-size: 10px;

    opacity: 0.65;

    text-align: right;
}


/* =========================================
   COMPOSER
========================================= */

.composer {
    padding: 12px 16px;

    display: flex;

    gap: 10px;

    background: #101522;

    border-top:
        1px solid rgba(255, 255, 255, 0.06);
}

.composer input {
    flex: 1;

    min-width: 0;

    padding: 13px 16px;

    border: 0;

    outline: 0;

    border-radius: 15px;

    background: #1a2131;

    color: white;
}

.composer button {
    width: 48px;

    border: 0;

    border-radius: 14px;

    background: #3b82f6;

    color: white;

    cursor: pointer;

    font-size: 20px;
}

.composer button:disabled {
    opacity: 0.4;

    cursor: not-allowed;
}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 700px) {

    .link-page,
    #linkPage {
        min-height: 100dvh;

        padding: 16px;
    }

    .link-card {
        width: 100%;

        padding: 24px 16px;

        border-radius: 20px;
    }

    .link-card h1,
    .link-card h2 {
        font-size: 26px;
    }

    .signal-logo,
    .logo {
        width: 64px;
        height: 64px;

        margin-bottom: 16px;
    }

    #qrContainer,
    .qr-container {
        width: min(280px, 78vw);
        height: min(280px, 78vw);

        margin: 18px auto;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
    }

    .chat {
        display: none;
    }

    .app-page.chat-open .sidebar {
        display: none;
    }

    .app-page.chat-open .chat {
        display: flex;
    }

    .back-btn {
        display: block;
    }

    .messages {
        padding: 16px;
    }

    .message {
        max-width: 85%;
    }
}

#linkUri {
    margin: 14px 0;

    padding: 0;

    background: transparent;
    border: 0;

    color: #9ca8bd;

    font-family: monospace;
    font-size: 11px;

    line-height: 1.5;

    text-align: left;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.creator-button {
    position: fixed;
    right: 18px;
    bottom: 18px;

    width: 46px;
    height: 46px;

    border: 1px solid rgba(255,255,255,.15);
    border-radius: 50%;

    background: #20242b;
    color: #fff;

    font-size: 18px;
    font-weight: 700;

    cursor: pointer;
    z-index: 1000;
}

.creator-button:active {
    transform: scale(.94);
}

.creator-info {
    position: fixed;
    right: 18px;
    bottom: 74px;

    min-width: 180px;
    padding: 14px;

    flex-direction: column;
    gap: 6px;

    background: #20242b;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;

    color: #fff;
    z-index: 999;

    box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.creator-info a {
    color: #70a7ff;
    text-decoration: none;
}
