* {
    box-sizing: border-box;
}

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

body {
    font-family: Arial, sans-serif;
    background: #0f1418;
    color: #ffffff;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
textarea {
    font-family: inherit;
}

button {
    cursor: pointer;
}

.app {
    min-height: 100vh;
}


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

.app-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid #242c32;
    background: #12181d;
}

.brand {
    font-size: 24px;
    font-weight: 700;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 18px;
}

.user-name {
    font-size: 14px;
    color: #c8d0d6;
}

.logout-link {
    font-size: 14px;
    color: #8fb8ff;
}

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 20px 100px;
}

.welcome {
    padding: 25px 0;
}

.welcome h1 {
    margin: 0 0 8px;
    font-size: 32px;
}

.welcome p {
    margin: 0;
    color: #89949d;
}

.main-navigation {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #242c32;
    margin-bottom: 30px;
}

.nav-item {
    padding: 12px 18px;
    color: #89949d;
    border-bottom: 2px solid transparent;
}

.nav-item.active {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

.content-area {
    min-height: 300px;
}

.empty-state {
    border: 1px solid #242c32;
    border-radius: 12px;
    padding: 40px 25px;
    text-align: center;
    background: #12181d;
}

.empty-state h2 {
    margin: 0 0 10px;
}

.empty-state p {
    margin: 0;
    color: #89949d;
}


/* =========================================================
   SQUAD HEADER
   ========================================================= */

.mardly-squad-header {
    display: flex;
    align-items: center;
    gap: 13px;

    min-height: 72px;
    padding: 12px 16px;

    border: 1px solid #242c32;
    border-radius: 16px;

    background: #12181d;

    flex-shrink: 0;
}

.mardly-squad-back {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;

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

    border-radius: 50%;

    color: #c8d0d6;
    font-size: 25px;
}

.mardly-squad-back:hover {
    background: #1b2228;
    color: #ffffff;
}

.mardly-squad-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;

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

    border-radius: 13px;

    background: #211638;
    border: 1px solid #743cff;

    font-size: 21px;
}

.mardly-squad-header-info {
    min-width: 0;
    flex: 1;
}

.mardly-squad-header-info h1 {
    margin: 0;

    font-size: 17px;
    line-height: 1.25;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mardly-squad-header-info p {
    margin: 3px 0 0;

    color: #89949d;
    font-size: 12px;
}

.mardly-squad-menu {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: #89949d;

    font-size: 25px;
    line-height: 1;
}

.mardly-squad-menu:hover {
    background: #1b2228;
    color: #ffffff;
}


/* =========================================================
   MEMBER CHAT PAGE
   ========================================================= */

.squad-page {
    width: 100%;
    max-width: 1100px;
    height: 100dvh;

    margin: 0 auto;

    padding: 20px;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


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

.squad-page .squad-chat {
    flex: 1;

    min-height: 0;

    margin-top: 16px;

    display: flex;
    flex-direction: column;

    border: 1px solid #242c32;
    border-radius: 16px;

    overflow: hidden;

    background: #0b1014;
}


/* =========================================================
   MESSAGE SCROLL AREA
   ========================================================= */

.squad-messages {
    flex: 1;

    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    padding: 22px;

    display: flex;
    flex-direction: column;

    gap: 14px;

    overscroll-behavior: contain;

    scrollbar-width: thin;
}


/* WebKit scrollbar */

.squad-messages::-webkit-scrollbar {
    width: 6px;
}

.squad-messages::-webkit-scrollbar-track {
    background: transparent;
}

.squad-messages::-webkit-scrollbar-thumb {
    background: #303941;
    border-radius: 10px;
}


/* =========================================================
   MESSAGE
   ========================================================= */

.squad-message {
    width: fit-content;

    max-width: 78%;

    padding: 12px 15px;

    border: 1px solid #242c32;
    border-radius: 14px;

    background: #12181d;

    flex-shrink: 0;
}


/* Other members */

.squad-message[data-own="false"] {
    align-self: flex-start;
}


/* Current user */

.squad-message[data-own="true"] {
    align-self: flex-end;

    background: #211638;

    border-color: #743cff;
}


/* Author */

.squad-message-author {
    margin-bottom: 5px;

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

    color: #a66cff;
}

.squad-message[data-own="true"] .squad-message-author {
    color: #c39aff;
}


/* Body */

.squad-message-body {
    font-size: 16px;
    line-height: 1.5;

    color: #f2f4f5;

    overflow-wrap: anywhere;
    word-break: break-word;
}


/* Time */

.squad-message-time {
    margin-top: 7px;

    font-size: 11px;

    color: #737e87;
}

.squad-message[data-own="true"] .squad-message-time {
    text-align: right;
}


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

.squad-chat-empty {
    margin: auto;

    padding: 40px 20px;

    text-align: center;
}

.squad-chat-empty p {
    margin: 4px 0;

    color: #89949d;
}


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

.squad-message-form {
    flex-shrink: 0;

    display: flex;
    align-items: flex-end;

    gap: 10px;

    padding: 12px;

    border-top: 1px solid #242c32;

    background: #12181d;
}


.squad-message-form textarea {
    flex: 1;

    min-width: 0;

    min-height: 48px;
    max-height: 140px;

    resize: vertical;

    padding: 13px 14px;

    border: 1px solid #303941;
    border-radius: 12px;

    outline: none;

    background: #0b1014;
    color: #ffffff;

    font-size: 15px;
    line-height: 1.4;
}


.squad-message-form textarea::placeholder {
    color: #69747d;
}


.squad-message-form textarea:focus {
    border-color: #8b4dff;
}


.squad-message-form button {
    flex-shrink: 0;

    min-height: 48px;

    padding: 0 20px;

    border: 1px solid #8b4dff;
    border-radius: 12px;

    background: #211638;
    color: #a66cff;

    font-size: 15px;
    font-weight: 700;
}


.squad-message-form button:hover {
    background: #2b1a48;
}


/* =========================================================
   PUBLIC SQUAD VIEW
   ========================================================= */

.squad-public-page {
    min-height: 100dvh;
}

.squad-public-content {
    padding-top: 20px;
}

.squad-public-card {
    border: 1px solid #242c32;
    border-radius: 16px;

    padding: 35px 25px;

    text-align: center;

    background: #12181d;
}

.squad-public-card p {
    color: #89949d;
    line-height: 1.6;
}

.squad-join-button {
    min-height: 48px;

    padding: 0 24px;

    border: 1px solid #8b4dff;
    border-radius: 12px;

    background: #211638;
    color: #a66cff;

    font-weight: 700;
}


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

@media (max-width: 600px) {

    .app-header {
        padding: 0 16px;
    }

    .header-user .user-name {
        display: none;
    }

    .app-main {
        padding: 20px 14px 90px;
    }

    .welcome h1 {
        font-size: 26px;
    }

    .main-navigation {
        overflow-x: auto;
    }

    .nav-item {
        white-space: nowrap;
        padding: 11px 14px;
    }


    /* Full-screen mobile chat */

    .squad-page {
        height: 100dvh;

        padding: 10px 10px 0;
    }


    .squad-page .mardly-squad-header {
        border-radius: 14px;

        min-height: 68px;

        padding: 10px 12px;
    }


    .mardly-squad-header {
        gap: 10px;
    }


    .mardly-squad-avatar {
        width: 42px;
        height: 42px;

        flex-basis: 42px;

        border-radius: 12px;
    }


    .mardly-squad-header-info h1 {
        font-size: 17px;
    }


    .mardly-squad-header-info p {
        font-size: 12px;
    }


    /* Chat fills remaining screen */

    .squad-page .squad-chat {
        margin-top: 10px;

        flex: 1;

        min-height: 0;

        border-radius: 14px;

        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }


    /* Larger message area */

    .squad-messages {
        flex: 1;

        min-height: 0;

        padding: 16px 12px;

        gap: 12px;
    }


    .squad-message {
        max-width: 88%;

        padding: 12px 14px;

        border-radius: 14px;
    }


    .squad-message-body {
        font-size: 15px;
    }


    .squad-message-author {
        font-size: 13px;
    }


    /* Composer */

    .squad-message-form {
        padding: 10px;

        gap: 8px;
    }


    .squad-message-form textarea {
        min-height: 48px;

        max-height: 120px;

        font-size: 15px;
    }


    .squad-message-form button {
        min-height: 48px;

        padding: 0 17px;
    }
}

/* Squad WhatsApp-style message layout */
.squad-message{display:flex;align-items:flex-end;gap:8px;width:100%;max-width:760px;margin:0 auto 18px;padding:0;border:0;background:transparent;box-sizing:border-box}
.squad-message.mine{justify-content:flex-end}
.squad-message:not(.mine){justify-content:flex-start}
.squad-message .squad-avatar-button{flex:0 0 36px;width:36px;height:36px;align-self:flex-end}
.squad-message.mine .squad-avatar-button{order:2}
.squad-message .squad-stack{order:1;max-width:min(78%,520px);min-width:0;padding:10px 12px 8px;border:1px solid rgba(74,69,104,.55);border-radius:16px;background:#12151a;box-sizing:border-box}
.squad-message.mine .squad-stack{order:1;background:#211b36;border-color:#4f416f}
.squad-message .squad-sender{margin-left:0}
.squad-message .squad-bubble{padding:9px 11px;border-radius:14px;background:#2a243f;box-shadow:none}
.squad-message.mine .squad-bubble{background:#5f43c7}
.squad-message:not(.mine) .squad-bubble{border-bottom-left-radius:5px}
.squad-message.mine .squad-bubble{border-bottom-right-radius:5px}
.squad-message .squad-time{margin-top:4px}
.squad-message .squad-media-grid{margin-top:6px}
.squad-message .squad-reactions{margin-bottom:1px}
.squad-avatar-button .squad-avatar{width:36px;height:36px}

/* Compact composer */
.squad-composer{padding:4px 10px max(4px,env(safe-area-inset-bottom))}
.squad-inputbox{border-radius:14px}
.squad-textarea{min-height:25px;max-height:56px;padding:4px 9px;font-size:13px;line-height:1.3}
.squad-tools{padding:0 2px 1px}
.squad-attach-label{width:30px;height:30px}
.squad-send{width:34px!important;height:34px!important;min-height:34px!important;padding:0!important;border-radius:11px!important}
.squad-send svg{width:18px;height:18px}
.squad-private{margin:4px 0 0;font-size:9px}

/* Reliable mobile media picker */
.squad-attachment-input{position:absolute!important;width:1px!important;height:1px!important;opacity:0!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;white-space:nowrap!important}
.squad-attach-label{cursor:pointer;touch-action:manipulation}
.squad-media-preview{min-height:0}
.squad-media-preview.show{padding:5px 7px 2px}
