:root {
    --bg: #f4f6fb;
    --surface: #fff;
    --surface2: #f8f9fd;
    --text: #172033;
    --muted: #7a8398;
    --border: #e8eaf2;
    --primary: #6c5ce7;
    --primary2: #9b5de5;
    --green: #20c997;
    --shadow: 0 18px 50px rgba(34,41,85,.09);
    --sidebar: 260px
}

html[data-theme=dark] {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface2: #20263b;
    --text: #f3f5ff;
    --muted: #9fa8c2;
    --border: #2b324c;
    --shadow: 0 18px 50px rgba(0,0,0,.3)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter,"Segoe UI",sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh
}

a {
    text-decoration: none
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    background: linear-gradient(180deg,#151932,#242251);
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    color: white
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 21px;
    font-weight: 800;
    color: #fff;
    padding: 0 10px 30px
}

.brand-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: linear-gradient(135deg,#8b5cf6,#4f46e5);
    color: white;
    box-shadow: 0 8px 20px #6c5ce766
}

    .brand-icon.big {
        width: 62px;
        height: 62px;
        font-size: 26px
    }

.sidebar nav {
    display: grid;
    gap: 7px
}

    .sidebar nav a, .logout-link {
        color: #aeb6d6;
        padding: 13px 15px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        gap: 14px;
        transition: .25s
    }

        .sidebar nav a:hover, .sidebar nav a.active {
            background: #ffffff14;
            color: #fff;
            transform: translateX(4px)
        }

.logout-link {
    margin-top: auto
}

.app-shell {
    margin-left: var(--sidebar);
    min-height: 100vh
}

.topbar {
    height: 78px;
    background: color-mix(in srgb,var(--surface) 92%,transparent);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 30
}

.global-search {
    width: min(480px,48vw);
    height: 46px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 10px;
    transition: .3s
}

    .global-search:focus-within {
        box-shadow: 0 0 0 4px #6c5ce71a;
        border-color: #8b5cf6;
        transform: translateY(-1px)
    }

    .global-search input {
        border: 0;
        outline: 0;
        background: transparent;
        color: var(--text);
        width: 100%
    }

.search-key {
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 6px;
    color: var(--muted)
}

.top-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 13px;
    display: grid;
    place-items: center;
    cursor: pointer
}

.notification-btn {
    position: relative
}

.notify-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ff4d6d;
    border: 2px solid var(--surface);
    border-radius: 50%;
    right: 8px;
    top: 8px
}

.profile-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    margin-left: 8px
}

    .profile-mini span:last-child {
        display: grid
    }

    .profile-mini small {
        color: var(--muted)
    }

.page-content {
    padding: 30px;
    max-width: 1600px;
    margin: auto
}

.hero-card {
    min-height: 230px;
    padding: 38px 42px;
    border-radius: 28px;
    background: linear-gradient(125deg,#6c5ce7,#8b5cf6 54%,#b06ab3);
    color: white;
    display: flex;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
    box-shadow: 0 22px 50px #6c5ce73b
}

    .hero-card h1 {
        font-size: 38px;
        margin: 8px 0
    }

    .hero-card p {
        opacity: .85
    }

.hero-orbs {
    width: 280px;
    position: relative
}

    .hero-orbs span {
        position: absolute;
        border-radius: 50%;
        background: #ffffff20
    }

        .hero-orbs span:first-child {
            width: 190px;
            height: 190px;
            right: -15px;
            top: -12px
        }

        .hero-orbs span:nth-child(2) {
            width: 90px;
            height: 90px;
            left: 20px;
            bottom: -20px
        }

    .hero-orbs i {
        position: absolute;
        font-size: 90px;
        right: 55px;
        top: 56px;
        transform: rotate(-8deg)
    }

.eyebrow {
    font-size: 11px;
    letter-spacing: 1.8px;
    font-weight: 800;
    color: #8b5cf6
}

.hero-card .eyebrow {
    color: #fff
}

.btn-gradient {
    border: 0;
    color: #fff !important;
    background: linear-gradient(135deg,#7c5ce7,#5b54e8);
    padding: 11px 18px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-weight: 700;
    box-shadow: 0 10px 22px #6c5ce733;
    cursor: pointer
}

.hero-card .btn-gradient {
    background: white;
    color: #5b54e8 !important;
    margin-top: 14px
}

.btn-soft, .btn-danger-soft {
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer
}

.btn-danger-soft {
    color: #e74c5c;
    background: #e74c5c12
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 18px;
    margin: 22px 0
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text);
    box-shadow: var(--shadow);
    position: relative
}

    .stat-card h3 {
        margin: 2px 0 0;
        font-size: 27px
    }

    .stat-card small {
        color: var(--muted)
    }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: grid;
    place-items: center
}

.purple {
    background: #7c5ce719;
    color: #7c5ce7
}

.green {
    background: #20c99719;
    color: #20c997
}

.orange {
    background: #ff9f4319;
    color: #ff9f43
}

.blue {
    background: #3498db19;
    color: #3498db
}

.stat-link {
    margin-left: auto;
    color: var(--muted)
}

.pulse-label {
    margin-left: auto;
    color: #20c997;
    font-size: 12px
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 22px
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 23px;
    padding: 24px;
    box-shadow: var(--shadow)
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px
}

    .panel-head h2 {
        font-size: 20px;
        margin: 4px 0
    }

    .panel-head.compact {
        margin-top: 18px
    }

    .panel-head a {
        color: #6c5ce7;
        font-weight: 700
    }

.person-row {
    display: flex;
    align-items: center;
    padding: 14px 3px;
    border-bottom: 1px solid var(--border);
    gap: 14px
}

    .person-row:last-child {
        border: 0
    }

.person-info {
    flex: 1
}

    .person-info h4, .person-info h3 {
        margin: 0 0 4px
    }

    .person-info p, .muted {
        margin: 0;
        color: var(--muted)
    }
.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6c63ff;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

    .avatar.sm {
        width: 39px;
        height: 39px
    }

    .avatar.lg {
        width: 58px;
        height: 58px
    }

    .avatar.xl {
        width: 82px;
        height: 82px;
        font-size: 28px
    }

    .avatar.xxl {
        width: 130px;
        height: 130px;
        border-radius: 50%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #6c63ff;
        color: #fff;
        font-size: 42px;
        font-weight: bold;
    }

.avatar-wrap {
    position: relative
}
.profile-avatar-image {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
}
.status-dot {
    width: 12px;
    height: 12px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    position: absolute;
    right: 0;
    bottom: 1px
}

.online {
    background: #20c997
}

.offline {
    background: #9aa1b5
}

.round-action {
    width: 39px;
    height: 39px;
    border-radius: 12px;
    background: #6c5ce714;
    color: #6c5ce7;
    display: grid;
    place-items: center
}

.avatar-stack {
    display: flex;
    margin: 18px 0
}

    .avatar-stack .avatar {
        margin-left: -10px;
        border: 3px solid var(--surface)
    }

        .avatar-stack .avatar:first-child {
            margin-left: 0
        }

.notification-line {
    display: flex;
    gap: 12px;
    padding: 10px 0
}

    .notification-line div {
        display: grid
    }

    .notification-line small {
        color: var(--muted)
    }

.mini-icon {
    width: 37px;
    height: 37px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #6c5ce714;
    color: #6c5ce7
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 24px
}

    .page-heading h1 {
        margin: 5px 0
    }

    .page-heading p {
        color: var(--muted);
        margin: 0
    }

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(245px,1fr));
    gap: 20px
}

.user-profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 27px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden
}

    .user-profile-card .avatar {
        margin: auto auto 14px
    }

    .user-profile-card h3 {
        margin: 9px 0 4px
    }

    .user-profile-card p, .user-profile-card small {
        color: var(--muted)
    }

.status-pill {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 800
}

.online-bg {
    background: #20c99718;
    color: #20c997
}

.offline-bg {
    background: #9aa1b518;
    color: #8d94a5
}

.card-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 18px
}

.request-list {
    display: grid;
    gap: 14px
}

.request-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow)
}

.request-actions {
    display: flex;
    gap: 8px
}

.empty-state {
    text-align: center;
    padding: 44px;
    color: var(--muted)
}

    .empty-state i {
        font-size: 42px;
        color: #8b5cf6
    }

.wide {
    grid-column: 1/-1;
    background: var(--surface);
    border-radius: 20px
}

.auth-body {
    background: linear-gradient(135deg,#16172d,#2e1b47);
    overflow-x: hidden
}

.auth-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    padding: 34px;
    gap: 30px
}

.auth-visual {
    border-radius: 32px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg,#6c5ce7,#9b5de5 60%,#f15bb5);
    display: grid;
    place-items: center;
    color: white
}

.visual-copy {
    max-width: 500px;
    padding: 50px;
    position: relative;
    z-index: 2
}

    .visual-copy h1 {
        font-size: 52px;
        line-height: 1.05;
        margin: 25px 0 15px
    }

.floating-chat {
    position: absolute;
    background: #ffffffde;
    color: #2b2b3f;
    padding: 14px 20px;
    border-radius: 18px;
    box-shadow: 0 18px 40px #0003;
    animation: float 4s ease-in-out infinite
}

    .floating-chat.one {
        top: 14%;
        right: 10%
    }

    .floating-chat.two {
        bottom: 17%;
        left: 10%;
        animation-delay: 1s
    }

.glass-card {
    background: color-mix(in srgb,var(--surface) 88%,transparent);
    backdrop-filter: blur(20px);
    border: 1px solid #ffffff25
}

.auth-panel {
    border-radius: 32px;
    padding: 55px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 30px 70px #0004
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 38px
}

.auth-panel h2 {
    font-size: 32px;
    margin: 8px 0
}

.auth-form {
    display: grid;
    gap: 9px;
    margin-top: 22px
}

    .auth-form label, .profile-form label {
        font-size: 13px;
        font-weight: 700;
        margin-top: 8px
    }

.input-shell {
    height: 50px;
    border: 1px solid var(--border);
    background: var(--surface2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 10px
}

    .input-shell input {
        border: 0;
        outline: 0;
        background: transparent;
        width: 100%;
        color: var(--text)
    }

.password-toggle {
    border: 0;
    background: transparent;
    color: var(--muted)
}

.auth-submit {
    height: 50px;
    margin-top: 14px
}

.auth-switch {
    text-align: center;
    color: var(--muted);
    margin-top: 24px
}

    .auth-switch a {
        color: #6c5ce7;
        font-weight: 700
    }

.signup-animate {
    animation: slideUp .65s ease
}

.profile-layout {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 22px
}

.profile-card {
    text-align: center;
    border-radius: 24px;
    padding: 35px;
    background: var(--surface)
}

    .profile-card .avatar {
        margin: auto
    }

.profile-form {
    display: grid;
    gap: 10px
}

.modern-input {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
    padding: 13px;
    border-radius: 13px
}

.drop-zone {
    min-height: 150px;
    border: 2px dashed #9ca3af;
    border-radius: 16px;
    cursor: pointer;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: 0.3s ease;
}
    .drop-zone:hover,
    .drop-zone.drag-over {
        border-color: #6a5af9;
        background: rgba(106, 90, 249, 0.08);
        transform: translateY(-2px);
    }
    .drop-zone.dragging {
        background: #8b5cf620;
        transform: scale(1.01)
    }

.narrow-panel {
    max-width: 650px
}

.notification-item {
    display: flex;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--border)
}

    .notification-item.unread {
        background: #6c5ce709
    }

    .notification-item h4, .notification-item p {
        margin: 0 0 5px
    }

    .notification-item p, .notification-item small {
        color: var(--muted)
    }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 18px
}

.setting-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 20px;
    display: flex;
    gap: 15px
}

.chat-layout {
    max-width: 1050px;
    margin: auto
}

.chat-window {
    height: calc(100vh - 138px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow)
}

.chat-header {
    height: 76px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px
}

    .chat-header h3 {
        margin: 0
    }

    .chat-header small {
        color: var(--muted)
    }

.chat-tools {
    margin-left: auto;
    display: flex;
    gap: 8px
}

.modern-chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background-color: var(--surface2);
    background-image: radial-gradient(#6c5ce70b 1px,transparent 1px);
    background-size: 20px 20px
}

.message-row {
    display: flex;
    margin: 8px 0
}

    .message-row.mine {
        justify-content: flex-end
    }

.msg-bubble {
    max-width: 70%;
    padding: 11px 14px;
    border-radius: 17px 17px 17px 5px;
    background: var(--surface);
    box-shadow: 0 5px 14px #0000000b
}

.mine .msg-bubble {
    background: linear-gradient(135deg,#765bea,#6954dc);
    color: white;
    border-radius: 17px 17px 5px 17px
}

.msg-bubble small {
    display: block;
    text-align: right;
    font-size: 10px;
    opacity: .7;
    margin-top: 4px
}

.chat-compose {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-top: 1px solid var(--border)
}

    .chat-compose input {
        flex: 1;
        border: 0;
        outline: 0;
        background: var(--surface2);
        color: var(--text);
        padding: 13px 17px;
        border-radius: 16px
    }

.send-btn {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg,#765bea,#5b54e8);
    color: white
}

.message-search {
    display: none;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    gap: 10px
}

    .message-search.show {
        display: flex
    }

    .message-search input {
        flex: 1;
        border: 0;
        outline: 0;
        background: transparent;
        color: var(--text)
    }

.typing-indicator {
    display: none;
    padding: 5px 20px;
    color: var(--muted);
    font-size: 12px
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: #11152ba8;
    display: none;
    place-items: center;
    z-index: 999
}

    .loading-overlay.show {
        display: grid
    }

.loader-ring {
    width: 54px;
    height: 54px;
    border: 5px solid #ffffff30;
    border-top-color: white;
    border-radius: 50%;
    animation: spin .8s linear infinite
}

.toast-card {
    position: fixed;
    right: 25px;
    top: 95px;
    z-index: 1000;
    padding: 14px 18px;
    border-radius: 13px;
    color: white;
    box-shadow: var(--shadow);
    animation: slideIn .3s ease
}

.success-toast {
    background: #20c997
}

.error-toast {
    background: #ef476f
}

.toast-card.hide {
    opacity: 0;
    transform: translateX(30px);
    transition: .4s
}

.mobile-menu {
    display: none
}

.error-page {
    text-align: center;
    padding: 80px
}

.error-code {
    font-size: 120px;
    font-weight: 900;
    background: linear-gradient(135deg,#6c5ce7,#f15bb5);
    -webkit-background-clip: text;
    color: transparent
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

@keyframes float {
    50% {
        transform: translateY(-12px)
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(25px)
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px)
    }
}

@media(max-width:1050px) {
    .stats-grid {
        grid-template-columns: repeat(2,1fr)
    }

    .dashboard-grid {
        grid-template-columns: 1fr
    }

    .auth-screen {
        grid-template-columns: 1fr
    }

    .auth-visual {
        display: none
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr
    }
}

@media(max-width:768px) {
    :root {
        --sidebar: 250px
    }

    .sidebar {
        transform: translateX(-100%);
        transition: .3s
    }

        .sidebar.open {
            transform: translateX(0)
        }

    .app-shell {
        margin-left: 0
    }

    .mobile-menu {
        display: grid
    }

    .topbar {
        padding: 0 14px
    }

    .global-search {
        display: none
    }

    .profile-mini span:last-child {
        display: none
    }

    .page-content {
        padding: 18px
    }

    .hero-card {
        padding: 28px 24px
    }

        .hero-card h1 {
            font-size: 28px
        }

    .hero-orbs {
        display: none
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px
    }

    .stat-card {
        padding: 16px
    }

    .profile-layout {
        grid-template-columns: 1fr
    }

    .page-heading {
        align-items: flex-start;
        gap: 14px;
        flex-direction: column
    }

    .auth-screen {
        padding: 14px
    }

    .auth-panel {
        padding: 30px 22px
    }

    .request-card {
        align-items: flex-start;
        flex-wrap: wrap
    }

    .request-actions {
        width: 100%
    }

    .settings-grid {
        grid-template-columns: 1fr
    }

    .chat-window {
        height: calc(100vh - 112px);
        border-radius: 15px
    }

    .msg-bubble {
        max-width: 84%
    }
}

.message-status.read-tick { color: #38bdf8; }
.notification-item { display:flex; align-items:center; gap:14px; }
.notification-content { flex:1; }
.notification-item.unread { border-left:4px solid #7c3aed; background:rgba(124,58,237,.07); }

/* New messages and profile visitors */
.sidebar nav a { position: relative; }
.menu-count { margin-left:auto; min-width:22px; height:22px; padding:0 6px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; background:#ff4d6d; color:#fff; font-size:.72rem; }
.visitor-count { background:#7c3aed; }
.top-count { position:absolute; top:-5px; right:-5px; min-width:18px; height:18px; padding:0 4px; border-radius:999px; display:flex; align-items:center; justify-content:center; background:#ff4d6d; color:white; font-size:.65rem; font-weight:800; }
.notification-btn { position:relative; }
.inbox-list { display:flex; flex-direction:column; gap:10px; }
.inbox-item { display:flex; align-items:center; gap:14px; padding:15px; border-radius:16px; text-decoration:none; color:inherit; background:var(--card-bg, rgba(255,255,255,.75)); border:1px solid rgba(127,127,127,.12); transition:.2s ease; }
.inbox-item:hover { transform:translateY(-2px); box-shadow:0 12px 30px rgba(20,20,40,.1); }
.inbox-content { flex:1; min-width:0; }
.inbox-title { display:flex; justify-content:space-between; gap:12px; }
.inbox-title time { font-size:.75rem; opacity:.7; white-space:nowrap; }
.inbox-content p { margin:5px 0 0; opacity:.75; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.unread-badge { min-width:28px; height:28px; padding:0 8px; border-radius:999px; display:flex; align-items:center; justify-content:center; background:#22c55e; color:#fff; font-weight:800; }
.visitor-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:18px; }
.visitor-card { text-align:center; padding:24px; border-radius:22px; }
.visitor-card h3 { margin:14px 0 4px; }
.visitor-card p { margin:0 0 8px; opacity:.75; }
.visitor-card small { display:block; margin-bottom:18px; opacity:.65; }
.visitor-card .btn-gradient { display:inline-flex; gap:8px; align-items:center; justify-content:center; text-decoration:none; }
.public-profile-wrap { min-height:70vh; display:grid; place-items:center; }
.public-profile-card { width:min(460px,100%); padding:34px; text-align:center; border-radius:28px; }
.public-profile-card .btn-gradient { margin-top:22px; display:inline-flex; gap:8px; text-decoration:none; }
@media (max-width: 576px) { .inbox-title { flex-direction:column; gap:2px; } .inbox-item { align-items:flex-start; } }
.live-message-toast { position:fixed; right:22px; bottom:22px; z-index:9999; width:min(360px,calc(100vw - 32px)); display:flex; gap:12px; align-items:center; padding:15px 18px; border-radius:16px; background:#111827; color:#fff; box-shadow:0 18px 50px rgba(0,0,0,.28); cursor:pointer; opacity:0; transform:translateY(20px); transition:.22s ease; }
.live-message-toast.show { opacity:1; transform:translateY(0); }
.live-message-toast i { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; background:#22c55e; }
.live-message-toast div { min-width:0; display:flex; flex-direction:column; }
.live-message-toast span { opacity:.8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Friend request message + profile gallery */
.friend-request-form textarea{resize:vertical;min-height:64px}.request-type-badge{display:inline-flex;padding:.25rem .65rem;border-radius:999px;background:rgba(99,102,241,.14);color:#6366f1;font-weight:700;font-size:.78rem}.request-message{margin-top:.55rem;padding:.65rem .8rem;border-radius:12px;background:rgba(148,163,184,.12);max-width:520px}.profile-gallery{margin-top:1.5rem}.gallery-grid{display:grid;grid-template-columns:repeat(4,minmax(90px,1fr));gap:12px}.gallery-item{position:relative;aspect-ratio:1/1;border-radius:16px;overflow:hidden;background:#e5e7eb}.gallery-item img{width:100%;height:100%;object-fit:cover;display:block}.gallery-item form{position:absolute;right:7px;top:7px}.gallery-item button{width:34px;height:34px;border:0;border-radius:50%;background:rgba(17,24,39,.78);color:#fff}.visitor-photo-gallery{width:100%;margin:1.5rem 0}.visitor-gallery .gallery-item{display:block}@media(max-width:700px){.gallery-grid{grid-template-columns:repeat(2,1fr)}.request-card{align-items:flex-start;flex-wrap:wrap}.request-actions{width:100%}}


/* ===== Responsive shell and mobile chat enhancements ===== */
.sidebar,
.app-shell,
.topbar,
.sidebar nav a span,
.sidebar .brand > span:last-child,
.logout-link span {
    transition: width .25s ease, margin .25s ease, transform .25s ease, opacity .2s ease, padding .25s ease;
}

.sidebar-toggle {
    display: inline-grid;
    flex: 0 0 auto;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(8, 12, 28, .58);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: .25s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

body.sidebar-collapsed {
    --sidebar: 84px;
}

body.sidebar-collapsed .sidebar {
    padding-inline: 12px;
}

body.sidebar-collapsed .sidebar .brand {
    justify-content: center;
    padding-inline: 0;
}

body.sidebar-collapsed .sidebar .brand > span:last-child,
body.sidebar-collapsed .sidebar nav a span,
body.sidebar-collapsed .sidebar .logout-link span,
body.sidebar-collapsed .sidebar .menu-count {
    width: 0;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body.sidebar-collapsed .sidebar nav a,
body.sidebar-collapsed .sidebar .logout-link {
    justify-content: center;
    padding-inline: 0;
    gap: 0;
}

body.sidebar-collapsed .sidebar nav a:hover,
body.sidebar-collapsed .sidebar nav a.active {
    transform: none;
}

body.sidebar-collapsed .sidebar nav a i,
body.sidebar-collapsed .sidebar .logout-link i {
    font-size: 1.15rem;
}

.chat-header > div:nth-of-type(2) {
    min-width: 0;
}

.chat-header h3,
.chat-header small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-avatar,
.avatar-wrap .avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;
}

.chat-box {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.msg-bubble span {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-compose {
    background: var(--surface);
    padding-bottom: max(13px, env(safe-area-inset-bottom));
}

.chat-compose input {
    min-width: 0;
    font-size: 16px;
}

@media (max-width: 768px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body.sidebar-collapsed {
        --sidebar: 250px;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
        touch-action: none;
    }

    .sidebar {
        width: min(86vw, 300px);
        max-width: 300px;
        padding-top: max(24px, env(safe-area-inset-top));
        box-shadow: 20px 0 55px rgba(0,0,0,.28);
        z-index: 60;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .topbar {
        height: 64px;
        padding: 0 10px;
        gap: 8px;
    }

    .top-actions {
        margin-left: auto;
        gap: 4px;
    }

    .top-actions .icon-btn {
        width: 40px;
        height: 40px;
    }

    .profile-mini {
        padding: 0;
    }

    .profile-mini .avatar.sm {
        width: 38px;
        height: 38px;
    }

    .page-content {
        padding: 14px;
    }

    .chat-page .page-content {
        padding: 0;
    }

    .chat-page .topbar {
        display: none;
    }

    .chat-page .app-shell {
        min-height: 100dvh;
    }

    .chat-layout {
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .chat-window {
        width: 100%;
        height: 100dvh;
        min-height: 100svh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-header {
        min-height: 64px;
        height: auto;
        padding: max(8px, env(safe-area-inset-top)) 10px 8px;
        gap: 9px;
        flex: 0 0 auto;
        background: color-mix(in srgb, var(--surface) 96%, transparent);
        backdrop-filter: blur(16px);
        position: relative;
        z-index: 3;
    }

    .chat-header .icon-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .chat-header h3 {
        font-size: 1rem;
    }

    .chat-avatar,
    .avatar-wrap .avatar {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }

    .modern-chat {
        padding: 12px 10px 16px;
    }

    .message-row {
        margin: 5px 0;
    }

    .msg-bubble {
        max-width: 88%;
        padding: 9px 11px;
        border-radius: 15px 15px 15px 4px;
        font-size: .94rem;
    }

    .mine .msg-bubble {
        border-radius: 15px 15px 4px 15px;
    }

    .message-search {
        padding: 8px 12px;
        flex: 0 0 auto;
    }

    .message-search input {
        font-size: 16px;
    }

    .typing-indicator {
        flex: 0 0 auto;
    }

    .chat-compose {
        position: relative;
        z-index: 4;
        flex: 0 0 auto;
        gap: 7px;
        padding: 8px 9px max(8px, env(safe-area-inset-bottom));
    }

    .chat-compose .icon-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .chat-compose input {
        padding: 11px 13px;
        border-radius: 20px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 50%;
    }

    .toast-card,
    .live-message-toast {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }

    .stats-grid,
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .user-card,
    .inbox-item,
    .notification-item {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .chat-tools {
        gap: 3px;
    }

    .chat-header > div:nth-of-type(2) {
        max-width: calc(100vw - 184px);
    }

    .msg-bubble {
        max-width: 91%;
    }

    .chat-compose > .icon-btn:first-child {
        display: none;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .sidebar nav a:hover,
    .inbox-item:hover,
    .friend-card:hover {
        transform: none;
    }

    button,
    a,
    input,
    textarea,
    select {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Extended profile/signup/dashboard features */
.input-shell select{width:100%;border:0;background:transparent;outline:0;color:inherit;padding:14px 6px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.profile-detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:22px 0}.profile-detail-grid>div,.about-card{padding:16px;border-radius:16px;background:var(--surface-soft,rgba(255,255,255,.07));text-align:left}.profile-detail-grid small{display:block;opacity:.65;margin-bottom:5px}.profile-main-photo{width:150px;height:150px;margin:auto;border-radius:50%;overflow:hidden}.new-message-strip{margin:20px 0}.new-message-tiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.message-mini-card{display:flex;align-items:center;gap:10px;padding:13px;border-radius:16px;background:var(--surface-soft,rgba(255,255,255,.06));text-decoration:none;color:inherit;min-width:0}.message-mini-card div{min-width:0;flex:1}.message-mini-card b,.message-mini-card small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.count-badge{min-width:25px;height:25px;border-radius:999px;display:grid;place-items:center;background:#6c5ce7;color:#fff;font-weight:700}.empty-inline{display:flex;align-items:center;gap:10px;opacity:.7}.avatar-profile-link{display:block;border-radius:50%;cursor:pointer}.avatar-profile-link:active{transform:scale(.95)}
@media(max-width:900px){.new-message-tiles{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:600px){.form-grid,.profile-detail-grid{grid-template-columns:1fr}.new-message-tiles{grid-template-columns:1fr}.auth-panel{width:100%}.profile-main-photo{width:120px;height:120px}}

/* Messages and progressive chat loading */
.inbox-item.unread-conversation{background:rgba(99,102,241,.08);border-left:3px solid var(--primary,#6366f1)}
.inbox-item.unread-conversation .inbox-title b{font-weight:800}
.chat-box.loading-older::before{content:'Loading older messages…';position:sticky;top:4px;display:block;width:max-content;margin:4px auto;padding:5px 12px;border-radius:999px;background:rgba(15,23,42,.78);color:#fff;font-size:.75rem;z-index:4}

/* Dashboard live unread-message integration */
.section-count {
    display: inline-flex;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    margin-left: 7px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary, #6c5ce7);
    color: #fff;
    font-size: .75rem;
    vertical-align: middle;
}
.dashboard-message-item {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}
.dashboard-message-content {
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.dashboard-message-content b,
.dashboard-message-content small {
    display: block;
}
.dashboard-message-content small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-message-item .count-badge {
    text-decoration: none;
}
@media (max-width: 575.98px) {
    .dashboard-message-item {
        grid-template-columns: auto minmax(0, 1fr) auto;
        width: 100%;
    }
}

/* Authentication feedback */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1rem;
    margin: .9rem 0 1rem;
    border-radius: 14px;
    font-size: .92rem;
    line-height: 1.4;
}
.auth-alert-success {
    color: #166534;
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .28);
}
.auth-alert-error,
.auth-validation-summary.validation-summary-errors {
    color: #b91c1c;
    background: rgba(239, 68, 68, .10);
    border: 1px solid rgba(239, 68, 68, .25);
}
.auth-validation-summary {
    border-radius: 14px;
    margin: .75rem 0;
}
.auth-validation-summary ul {
    margin: 0;
    padding: .75rem 1rem .75rem 2rem;
}
.auth-validation-summary.validation-summary-valid { display: none; }


/* Sidebar totals and responsive dashboard message scroller */
.menu-count-info { background: #6c5ce7; }
.menu-count-warning { background: #f59e0b; }
.menu-count-success { background: #20c997; }

/* Desktop/laptop: unread message cards flow horizontally with an accessible scrollbar. */
#dashboardMessageTiles.new-message-tiles {
    display: flex;
    flex-wrap: nowrap;
    gap: 14px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 14px;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--surface2);
}
#dashboardMessageTiles.new-message-tiles::-webkit-scrollbar { height: 9px; }
#dashboardMessageTiles.new-message-tiles::-webkit-scrollbar-track {
    background: var(--surface2);
    border-radius: 999px;
}
#dashboardMessageTiles.new-message-tiles::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--primary), var(--primary2));
    border-radius: 999px;
}
#dashboardMessageTiles .dashboard-message-item {
    flex: 0 0 clamp(260px, 28vw, 355px);
    min-width: 260px;
    scroll-snap-align: start;
}
#dashboardMessageTiles .empty-inline {
    flex: 1 0 100%;
    min-height: 84px;
    justify-content: center;
}

/* Phones: cards become a vertical list and the panel scrolls vertically only when needed. */
@media (max-width: 767.98px) {
    #dashboardMessageTiles.new-message-tiles {
        display: flex;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        max-height: min(58vh, 470px);
        padding: 2px 4px 8px 0;
        scroll-snap-type: y proximity;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-block: contain;
    }
    #dashboardMessageTiles .dashboard-message-item {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        scroll-snap-align: start;
    }
}


/* Settings, privacy and notification controls */
.enhanced-settings-grid { align-items: stretch; }
.setting-card-form { align-items: flex-start; min-height: 250px; }
.setting-content { flex: 1; min-width: 0; }
.setting-label { display: block; margin: 16px 0 7px; font-weight: 700; }
.switch-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
}
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 3px; padding-right: 56px; }
.switch-row small { color: var(--muted); line-height: 1.4; }
.switch-row input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui {
    width: 48px; height: 27px; border-radius: 999px;
    background: #cbd5e1; position: absolute; right: 0; transition: .2s ease;
}
.switch-ui::after {
    content: ""; position: absolute; width: 21px; height: 21px; border-radius: 50%;
    background: #fff; left: 3px; top: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .2s ease;
}
.switch-row input:checked ~ .switch-ui { background: linear-gradient(135deg,#6c63ff,#8b5cf6); }
.switch-row input:checked ~ .switch-ui::after { transform: translateX(21px); }
.setting-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.permission-text { display: block; color: var(--muted); margin-top: 10px; }
.settings-save-bar { display:flex; justify-content:flex-end; margin: 20px 0 30px; }
.blocked-users-panel { margin-top: 26px; }
.blocked-user-list { display: grid; gap: 12px; }
.blocked-user-row {
    display: grid; grid-template-columns: 54px minmax(0,1fr) auto;
    gap: 14px; align-items:center; padding: 14px;
    border:1px solid var(--border); border-radius:16px; background:var(--card);
}
.blocked-user-row img { width:54px; height:54px; border-radius:50%; object-fit:cover; }
.blocked-user-row h3,.blocked-user-row p { margin:0; }
.blocked-user-row small { color:var(--muted); }
.delete-chat-form { margin:0; }
.danger-icon-btn { color:#ef4444 !important; }
.danger-icon-btn:hover { background:rgba(239,68,68,.12) !important; }

@media (max-width: 768px) {
    .blocked-user-row { grid-template-columns: 48px minmax(0,1fr); }
    .blocked-user-row form { grid-column: 1 / -1; }
    .blocked-user-row form button { width:100%; justify-content:center; }
    .setting-actions .btn-soft { width:100%; justify-content:center; }
    .settings-save-bar .btn-gradient { width:100%; justify-content:center; }
}


/* Chat menu, block and single-message delete */
.chat-menu-wrap{position:relative}.chat-action-menu{position:absolute;z-index:120;top:calc(100% + 8px);right:0;width:230px;padding:7px;border:1px solid var(--border);border-radius:14px;background:var(--card);box-shadow:0 18px 45px rgba(15,23,42,.18);display:none}.chat-action-menu.show{display:block;animation:chatMenuIn .16s ease-out}.chat-action-menu form{margin:0}.chat-menu-item{width:100%;display:flex;align-items:center;gap:11px;padding:11px 12px;border:0;border-radius:10px;background:transparent;color:var(--text);text-align:left;cursor:pointer}.chat-menu-item:hover{background:var(--soft)}.chat-menu-item.danger{color:#dc2626}.message-bubble-wrap{display:inline-flex;align-items:center;gap:5px;max-width:min(78%,680px)}.message-row.mine .message-bubble-wrap{flex-direction:row-reverse}.message-bubble-wrap .msg-bubble{max-width:100%}.single-message-menu-btn{width:30px;height:30px;flex:0 0 30px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:50%;background:transparent;color:var(--muted);cursor:pointer;opacity:0;transition:opacity .15s ease,background .15s ease,color .15s ease}.message-row:hover .single-message-menu-btn,.single-message-menu-btn:focus-visible{opacity:1}.single-message-menu-btn:hover{color:#dc2626;background:rgba(220,38,38,.10)}.message-row.message-removing{opacity:0;transform:scale(.96);transition:opacity .18s ease,transform .18s ease}@keyframes chatMenuIn{from{opacity:0;transform:translateY(-5px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media (hover:none),(max-width:768px){.single-message-menu-btn{opacity:.75}.chat-action-menu{position:fixed;left:12px;right:12px;top:auto;bottom:calc(76px + env(safe-area-inset-bottom));width:auto}.message-bubble-wrap{max-width:88%}}


/* One-to-one WebRTC audio/video calls */
.call-overlay {
    position: fixed; inset: 0; z-index: 3000; display: none;
    align-items: center; justify-content: center; padding: 18px;
    background: rgba(2, 6, 23, .82); backdrop-filter: blur(14px);
}
.call-overlay.show { display: flex; }
.call-panel {
    width: min(520px, 100%); min-height: 520px; border-radius: 28px;
    background: linear-gradient(160deg, #171c34, #0b1024); color: #fff;
    box-shadow: 0 35px 90px rgba(0,0,0,.48); padding: 28px;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
}
.call-person { text-align: center; position: relative; z-index: 2; }
.call-person img { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; border: 4px solid rgba(255,255,255,.28); box-shadow: 0 12px 35px rgba(0,0,0,.35); }
.call-person h2 { margin: 14px 0 4px; font-size: 1.5rem; }
.call-person p { margin: 0; color: #cbd5e1; }
#callTimer { display:block; margin-top:7px; font-variant-numeric: tabular-nums; color:#94a3b8; }
.call-video-stage { width:100%; min-height:210px; display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; border-radius:22px; margin:18px 0; }
.call-video-stage:not(.video-active) { min-height:80px; }
.call-video-stage video { display:none; background:#020617; object-fit:cover; }
.call-video-stage.video-active #remoteCallVideo { display:block; width:100%; height:280px; border-radius:20px; }
.call-video-stage.video-active #localCallVideo { display:block; position:absolute; right:12px; bottom:12px; width:105px; height:140px; border-radius:16px; border:2px solid rgba(255,255,255,.7); box-shadow:0 8px 28px rgba(0,0,0,.35); }
.incoming-call-actions,.active-call-actions { display:flex; gap:22px; align-items:center; justify-content:center; }
.call-round-btn { width:62px; height:62px; border:0; border-radius:50%; color:#fff; font-size:1.15rem; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; transition:.2s ease; }
.call-round-btn:hover { transform:translateY(-2px) scale(1.04); }
.call-round-btn.accept { background:#22c55e; }
.call-round-btn.reject { background:#ef4444; }
.call-round-btn.neutral { background:rgba(255,255,255,.14); }
.call-round-btn.neutral.off { background:#ef4444; }
.call-start-btn { color:#16a34a; }
@media (max-width:600px) {
    .call-overlay { padding:0; }
    .call-panel { width:100%; min-height:100dvh; border-radius:0; padding:calc(22px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom)); }
    .call-video-stage.video-active #remoteCallVideo { height:min(52dvh,430px); }
}
