*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

* { -webkit-tap-highlight-color: transparent; }

/* (Bug fix — REGRESSION FIX, restored) Several elements in this file
   set their own `display` (buttons, flex/grid containers, etc.) with
   equal-or-higher specificity than the browser's built-in
   `[hidden] { display: none; }` rule — and author styles always win
   over user-agent styles regardless of specificity or source order.
   That silently breaks `hidden` on every .btn-connect / .btn-block-btn,
   which is why all seven-plus relationship buttons could show at once
   on a profile page instead of just the right one. This rule
   re-asserts `hidden` above everything else in this file, globally.

   This exact rule existed before and was accidentally dropped during a
   later full-file rewrite of chat.css (the logout-button-label change)
   — restoring it here, at the very top, so it can never again be lost
   in the middle of an unrelated edit. */
[hidden] { display: none !important; }

.btn, .nav-link, .icon-btn, .toolbar-btn, .chat-room, .logout-btn, .mobile-back-btn, .logo-cell, .profile {
    touch-action: manipulation;
}

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #162032;
    --chat-bg: #202b45;
    --amber: #ff9100;
    --amber-dim: rgba(255, 145, 0, 0.12);
    --white: #ffffff;
    --muted: #64748b;
    --text: #cbd5e1;
    --border: rgba(255,255,255,0.06);
    --header-h: 64px;
    --sidebar-w: 256px;
    --panel-bg: rgba(15, 23, 42, 0.85);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.14);
    --yellow: #eab308;
    --red: #ef4444;
    --pending-gray: #64748b;
    --pending-gray-dim: rgba(100, 116, 139, 0.14);
}

html, body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 145, 0, 0.25);
    border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 145, 0, 0.5);
}
* { scrollbar-width: thin; scrollbar-color: rgba(255,145,0,0.25) transparent; }

.status-dot {
    display: inline-block;
    border-radius: 50%;
    background: var(--muted);
    transition: background 0.4s ease, box-shadow 0.4s ease;
    flex-shrink: 0;
}

.status-dot.status-offline { background: var(--muted); box-shadow: none; }
.status-dot.status-idle    { background: var(--yellow); box-shadow: 0 0 6px rgba(234, 179, 8, 0.5); }
.status-dot.status-online  { background: var(--green);  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.status-dot.status-inactive {
    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), transparent 55%),
        var(--pending-gray);
    box-shadow: none;
}

.status-dot-badge {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--bg);
    box-sizing: content-box;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
        "logo   topbar"
        "sidebar main";
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

.logo-cell {
    grid-area: logo;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.2s;
}

.logo-cell:hover {
    background: #141d33;
}

.logo-cell img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
}

.logo-cell-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--white);
    letter-spacing: -0.02em;
}

.logo-cell-text span { color: var(--amber); }

.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--white);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
}

.icon-btn svg {
    width: 19px;
    height: 19px;
    stroke: var(--text);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover svg { stroke: var(--white); }

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--amber);
    color: #0f172a;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.notifications-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-height: 420px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.4);
    padding: 0;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    z-index: 1500;
    overflow: hidden;
}

.notifications-dropdown.open { display: flex; }

.notif-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.notif-tab {
    flex: 1;
    padding: 12px 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.notif-tab:hover { color: var(--text); }

.notif-tab.active {
    color: var(--amber);
    border-bottom-color: var(--amber);
}

.notif-list {
    overflow-y: auto;
    max-height: 360px;
}

.notif-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    position: relative;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-item:hover .notif-item-mark-read { opacity: 1; }

.notif-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--amber-dim);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-item-icon img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.notif-item-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--amber);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notif-item-body { min-width: 0; flex: 1; padding-right: 18px; }

.notif-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 2px;
}

.notif-item-text {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

.notif-item-time {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 4px;
    letter-spacing: 0.01em;
}

.notif-item.unread .notif-item-title::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber);
    margin-left: 6px;
    vertical-align: middle;
}

.notif-item-mark-read {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.notif-item-mark-read:hover { background: rgba(255,145,0,0.12); color: var(--amber); }
.notif-item-mark-read svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 700px) {
    .notifications-dropdown { width: min(320px, calc(100vw - 32px)); right: -6px; }
    .notif-item-mark-read { opacity: 0.55; }
}

.sidebar {
    grid-area: sidebar;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 7px;
    height: 38px;
    padding: 0 10px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.toolbar-btn svg {
    width: 15px;
    height: 15px;
    stroke: var(--text);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    transition: stroke 0.2s;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
    color: var(--white);
}

.toolbar-btn:hover svg { stroke: var(--white); }

.chat-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 56px 24px;
    color: var(--muted);
}

.chat-list-empty-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--amber-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.chat-list-empty-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--amber);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-list-empty-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.chat-list-empty-sub {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
    max-width: 200px;
}

.chat-room {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.chat-room:hover { background: rgba(255,255,255,0.03); }

.chat-room.active {
    background: rgba(255, 145, 0, 0.08);
    border-left-color: var(--amber);
}

.chat-room-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
}

.chat-room-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-room-info { min-width: 0; flex: 1; }

.chat-room-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-preview {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── SIDEBAR FOOTER ──
   (Changed) Was a fixed-width square icon button for logout, no visible
   text. Now sized to content (padding instead of a fixed square) so the
   "Log out" label fits, in a muted red that reads as distinct/
   intentional without competing with the profile row next to it. */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 4px 6px;
    margin: -4px -6px;
    transition: background 0.15s;
}

.profile:hover {
    background: rgba(255,255,255,0.05);
}

.profile-pic-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.profile-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    background: var(--surface);
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 9px;
    flex-shrink: 0;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.18);
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.16);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.32);
}

.logout-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.logout-btn-label {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* On very narrow layouts, drop back to icon-only (with the tooltip and
   aria-label still doing the explaining) so the footer doesn't get
   cramped — the profile row keeps priority since it's the more
   frequently used control. */
@media (max-width: 340px) {
    .logout-btn-label { display: none; }
    .logout-btn { padding: 0; width: 36px; justify-content: center; }
}

.chat-area {
    grid-area: main;
    background: var(--chat-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
}

.mobile-back-btn {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, color 0.2s;
}

.mobile-back-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.mobile-back-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-area-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 320px;
    padding: 24px;
}

.chat-area-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--amber-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.chat-area-empty-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--amber);
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-area-empty h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--white);
    margin-bottom: 8px;
}

.chat-area-empty p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.6;
    font-weight: 300;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    letter-spacing: 0.01em;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-ghost:hover {
    color: var(--white);
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.04);
}

.btn-amber {
    background: var(--amber);
    color: #0f172a;
    font-weight: 600;
}

.btn-amber:hover:not(:disabled) {
    background: #ffaa33;
    box-shadow: 0 0 20px rgba(255, 145, 0, 0.35);
    transform: translateY(-1px);
}

.btn-amber:disabled {
    background: rgba(255,145,0,0.25);
    color: rgba(15,23,42,0.6);
    cursor: not-allowed;
}

.btn-amber-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--amber);
    color: #0f172a;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.btn-amber-small:hover {
    background: #ffaa33;
    box-shadow: 0 0 16px rgba(255, 145, 0, 0.3);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    font-weight: 600;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}
.btn-danger:disabled {
    background: rgba(239, 68, 68, 0.3);
    color: rgba(255,255,255,0.6);
    cursor: not-allowed;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 22, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 400px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
}

.modal-body {
    padding: 20px;
}

.modal-search {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border-radius: 9px;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
}

.modal-search::placeholder { color: var(--muted); }

.modal-search:focus {
    outline: none;
    border-color: rgba(255,145,0,0.4);
}

.modal-search-wrap { position: relative; margin-bottom: 20px; }
.modal-search-wrap .modal-search { margin-bottom: 0; padding-right: 68px; }

.modal-search-clear {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; display: none; align-items: center; justify-content: center;
    color: var(--muted); background: transparent; border: none; border-radius: 50%;
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.modal-search-clear.visible { display: flex; }
.modal-search-clear:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.modal-search-clear svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.modal-search-spinner {
    position: absolute; right: 40px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; border: 2px solid rgba(255,145,0,0.2);
    border-top-color: var(--amber); border-radius: 50%; opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.modal-search-spinner.active { opacity: 1; animation: search-spin 0.6s linear infinite; }
@keyframes search-spin { to { transform: rotate(360deg); } }

.modal-contacts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 24px 12px;
}

.modal-contacts-empty-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--amber-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.modal-contacts-empty-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--amber);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.modal-contacts-empty p {
    font-size: 0.85rem;
    color: var(--muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.modal-group-hint {
    font-size: 0.76rem;
    color: var(--muted);
    flex: 1;
    text-align: left;
    margin: 0 12px;
}

.toast-container {
    position: absolute;
    top: -80px;
    right: 95px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast-container.show {
    top: 5px;
}

.toast {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.toast.success { 
    background: #10b981; 
    border: 1px solid #059669; 
}

.toast.error { 
    background: #e11d48; 
    border: 1px solid #be123c; 
}

@media (max-width: 700px) {
    .toast-container { right: 50px; }
}

@media (max-width: 860px) {
    :root { --sidebar-w: 224px; }
}

@media (max-width: 700px) {

    .app-shell {
        grid-template-columns: 58px 1fr;
        grid-template-rows: calc(var(--header-h) + env(safe-area-inset-top, 0px)) 1fr;
        grid-template-areas:
            "logo    topbar"
            "content content";
    }

    .modal-search {
        font-size: 16px;
    }

    .logo-cell {
        padding: 0;
        justify-content: center;
    }

    .logo-cell-text { display: none; }

    .topbar {
        padding: 0 14px;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .topbar-title {
        font-size: 1.05rem;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
    }

    .sidebar,
    .chat-area {
        grid-area: content;
        width: 100%;
    }

    .chat-area { display: none; }

    .app-shell.mobile-chat-open .sidebar { display: none; }
    .app-shell.mobile-chat-open .chat-area { display: flex; }

    .mobile-back-btn { display: inline-flex; }

    .sidebar-toolbar {
        padding: 14px 16px;
    }

    .profile-pic,
    .logout-btn {
        width: 40px;
        height: 40px;
    }

    .sidebar-footer {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .chat-list-empty {
        padding: 44px 24px;
    }

    .chat-area-empty {
        padding: 20px;
    }

    .modal-overlay {
        padding: 14px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
}

.btn-connect {
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 22px;
    border-radius: 10px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-connect:disabled { cursor: not-allowed; }

.btn-connect-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn-connect.state-add,
.btn-connect.state-add-back {
    background: var(--amber);
    color: #0f172a;
}
.btn-connect.state-add .btn-connect-icon,
.btn-connect.state-add-back .btn-connect-icon { stroke: #0f172a; }
.btn-connect.state-add:disabled,
.btn-connect.state-add-back:disabled {
    background: rgba(255, 145, 0, 0.3);
    color: rgba(15, 23, 42, 0.65);
}
.btn-connect.state-add:disabled .btn-connect-icon,
.btn-connect.state-add-back:disabled .btn-connect-icon { stroke: rgba(15, 23, 42, 0.65); }

.btn-connect.state-pending,
.btn-connect.state-blocked {
    background: var(--pending-gray-dim);
    color: var(--pending-gray);
    border: 1px solid rgba(100, 116, 139, 0.25);
}
.btn-connect.state-pending .btn-connect-icon,
.btn-connect.state-blocked .btn-connect-icon { stroke: var(--pending-gray); }
.btn-connect.state-pending:hover:not(:disabled),
.btn-connect.state-blocked:hover:not(:disabled) {
    background: rgba(100, 116, 139, 0.22);
}

.btn-connect.state-message {
    background: var(--amber);
    color: #0f172a;
}
.btn-connect.state-message .btn-connect-icon { stroke: #0f172a; }
.btn-connect.state-message:disabled {
    cursor: not-allowed;
    opacity: 0.75;
}

.btn-connect.search-add-btn {
    height: 34px;
    padding: 0 14px;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.btn-block-btn {
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--red);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.btn-block-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.55);
}

.block-modal-textarea {
    width: 100%;
    min-height: 90px;
    max-height: calc(100dvh - 120px);
    resize: vertical;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--white);
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 12px 14px;
}

.block-modal-textarea:focus {
    outline: none;
    border-color: rgba(239, 68, 68, 0.5);
}

.block-modal-counter {
    font-size: 0.72rem;
    color: var(--muted);
    text-align: right;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.block-modal-notes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.block-modal-note {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
}

.block-modal-note-username {
    font-weight: 600;
    color: var(--white);
}

.modal-contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    margin-bottom: 2px;
    cursor: pointer;
}
.modal-contact-row:hover { background: rgba(255,255,255,0.05); }

.modal-contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-contact-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.modal-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.modal-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 10px;
    border-radius: 100px;
    background: var(--amber-dim);
    border: 1px solid rgba(255, 145, 0, 0.3);
    color: var(--white);
    font-size: 0.78rem;
    font-weight: 500;
    max-width: 100%;
}

.modal-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--amber);
    cursor: pointer;
    flex-shrink: 0;
}
.modal-chip-remove:hover { background: rgba(255,145,0,0.2); }
.modal-chip-remove svg {
    width: 10px;
    height: 10px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
}

.modal-add-toggle {
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 145, 0, 0.4);
    color: var(--amber);
    font-family: 'Inter', sans-serif;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.modal-add-toggle.is-added {
    background: var(--amber);
    color: #0f172a;
}
.modal-add-toggle:hover { background: rgba(255,145,0,0.15); }
.modal-add-toggle.is-added:hover { background: #ffaa33; }

@media (max-width: 700px) {
    .modal-contact-actions .search-add-btn span {
        display: none;
    }
    .modal-contact-actions .search-add-btn {
        width: 34px;
        padding: 0;
    }
}