/* ==========================================================================
   AnonChat — World-Class Instagram Dark Theme
   Fully Responsive for Desktop, Tablet, and Mobile
   ========================================================================== */

:root {
    --bg-base: #000000;
    --bg-surface: #121212;
    --bg-elevated: #1e1e1e;
    --bg-input: #262626;
    --border-color: #262626;
    --border-subtle: #1a1a1a;
    --text-primary: #f5f5f5;
    --text-secondary: #a8a8a8;
    --text-muted: #737373;
    --accent-blue: #0095f6;
    --accent-blue-hover: #1877f2;
    --accent-green: #00ba7c;
    --error-red: #ed4956;
    --insta-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --sidebar-width: 245px;
    --sidebar-collapsed-width: 72px;
    --feed-width: 380px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
    width: 100vw;
}

.message-bubble, input, textarea, .selectable-text {
    user-select: text;
    -webkit-user-select: text;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   Single Page Application Shell
   ========================================================================== */
#app-root {
    width: 100vw;
    height: 100vh;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Full Auth & Landing Page (Instagram Dual-Card & Showcase)
   ========================================================================== */
.auth-page-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
    padding: 24px;
    background-color: var(--bg-base);
    overflow-y: auto;
}

.auth-showcase-phone {
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-frame {
    width: 290px;
    height: 560px;
    border: 9px solid #262626;
    border-radius: 42px;
    background: #0d0d0d;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 20px rgba(255, 255, 255, 0.03);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.phone-notch {
    width: 90px;
    height: 18px;
    background: #262626;
    border-radius: 0 0 12px 12px;
    margin: 0 auto;
    z-index: 2;
}

.phone-screen {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.phone-chat-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.phone-chat-preview-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

.phone-chat-preview-input {
    background: var(--bg-input);
    border-radius: 16px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-forms-stack {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 36px 32px 28px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.auth-switch-card {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.auth-link-btn {
    color: var(--accent-blue);
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
}
.auth-link-btn:hover {
    text-decoration: underline;
}

.auth-disclaimer {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.45;
    margin-top: 14px;
}

.auth-separator {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px 0 10px 0;
    width: 100%;
}
.sep-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}
.sep-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.auth-trust-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: var(--accent-green);
    margin-top: 6px;
}

@media (max-width: 860px) {
    .auth-showcase-phone {
        display: none;
    }
}

.auth-logo {
    font-size: 2.4rem;
    font-weight: 800;
    font-style: italic;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: var(--insta-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    text-align: center;
}

.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-input-group {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
}

.auth-input-group:focus-within {
    border-color: var(--text-secondary);
}

.auth-input-group input {
    width: 100%;
    font-size: 14px;
    color: var(--text-primary);
}

.auth-btn-primary {
    background-color: var(--accent-blue);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    padding: 13px;
    border-radius: 8px;
    margin-top: 6px;
    transition: background 0.2s;
}

.auth-btn-primary:hover {
    background-color: var(--accent-blue-hover);
}

.auth-btn-secondary {
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 14px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background 0.2s;
}

.auth-btn-secondary:hover {
    background-color: var(--bg-input);
}

.auth-error-msg {
    color: var(--error-red);
    font-size: 13px;
    text-align: center;
    margin-top: 4px;
    display: none;
}

/* ==========================================================================
   Main App Container (Authenticated)
   ========================================================================== */
.main-layout {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Desktop Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-base);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 12px 20px 12px;
    flex-shrink: 0;
    transition: width 0.2s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 28px 12px;
    cursor: pointer;
}

.sidebar-logo span {
    font-size: 1.45rem;
    font-weight: 800;
    font-style: italic;
    background: var(--insta-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
    position: relative;
    user-select: none;
}

.nav-item:hover {
    background-color: var(--bg-elevated);
}

.nav-item.active {
    font-weight: 700;
}

.nav-item.active svg {
    stroke-width: 2.6;
}

.nav-badge {
    position: absolute;
    right: 12px;
    background-color: var(--error-red);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.user-mini-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.user-mini-card:hover {
    background-color: var(--bg-elevated);
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-mini-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-mini-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-mini-handle {
    font-size: 11px;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Center Stage: Master & Detail Pane
   -------------------------------------------------------------------------- */
.main-content-pane {
    flex: 1;
    height: 100%;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Left Sub-Column (Feed / Conversations List) */
.conversations-pane {
    width: var(--feed-width);
    height: 100%;
    background-color: var(--bg-base);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.conversations-header {
    padding: 20px 20px 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversations-header h2 {
    font-size: 19px;
    font-weight: 700;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background 0.15s;
}

.btn-icon:hover {
    background-color: var(--bg-elevated);
}

/* Stories Tray on Top of Chats */
.stories-section {
    padding: 10px 16px 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.stories-carousel {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.stories-carousel::-webkit-scrollbar {
    display: none;
}

.story-create-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .55);
}
.story-create-dialog {
    display: flex;
    width: min(100%, 340px);
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-surface);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}
.story-create-dialog h3 {
    margin-bottom: 8px;
    font-size: 17px;
}
.story-create-dialog button {
    padding: 12px;
    border-radius: 9px;
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: left;
}
.story-create-dialog button:hover {
    background: var(--bg-elevated);
}

.story-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    width: 64px;
}

.story-ring {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--insta-gradient);
    padding: 2.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-ring.own-story {
    background: none;
    border: 2px dashed var(--accent-blue);
    padding: 0;
}

.story-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--bg-surface);
    border: 2px solid var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
}

.story-avatar-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-label {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

/* Conversation Search */
.conversations-search {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-box {
    min-width: 0;
    flex: 1;
    background-color: var(--bg-input);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--text-muted);
}

.search-input-box input {
    width: 100%;
    font-size: 13px;
    color: var(--text-primary);
}

/* Conversation Items List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    touch-action: pan-y;
}

.conversation-item:hover {
    background-color: var(--bg-surface);
}

.conversation-item.active {
    background-color: var(--bg-elevated);
}

.archived-chats-toggle {
    flex-shrink: 0;
    padding: 8px 11px;
    white-space: nowrap;
}
.archived-chats-toggle.active {
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
}
.conversation-action-menu {
    position: fixed;
    z-index: 1200;
    display: flex;
    min-width: 190px;
    flex-direction: column;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-surface);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .35);
}
.conversation-action-menu button,
.conversation-delete-dialog button {
    padding: 11px 13px;
    color: var(--text-primary);
    text-align: left;
    border-radius: 8px;
}
.conversation-action-menu button:hover,
.conversation-delete-dialog button:hover {
    background: var(--bg-elevated);
}
.conversation-action-menu .danger,
.conversation-delete-dialog .danger {
    color: var(--error-red);
}
.conversation-delete-overlay {
    position: fixed;
    inset: 0;
    z-index: 1201;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .68);
}
.conversation-delete-dialog {
    display: flex;
    width: min(100%, 380px);
    flex-direction: column;
    gap: 7px;
    padding: 22px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-surface);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
}
.conversation-delete-dialog h3 {
    margin: 0;
}
.conversation-delete-dialog p {
    margin: 0 0 9px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conv-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: var(--accent-green);
    border: 2px solid var(--bg-base);
}

.conv-details {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conv-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--text-muted);
}

.conv-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-unread-pill {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Right Main Column: Active Chat Window
   -------------------------------------------------------------------------- */
.chat-window {
    flex: 1;
    height: 100%;
    max-height: 100dvh;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.chat-back-btn {
    display: none;
    margin-right: 4px;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 700;
}

.chat-header-status {
    font-size: 11px;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header-actions button {
    color: var(--text-primary);
    transition: opacity 0.15s;
}

.chat-header-actions button:hover {
    opacity: 0.7;
}

/* Messages Area */
.chat-messages-scroll {
    flex: 1;
    min-height: 0;
    padding: 24px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior-y: contain;
}

#messages-feed-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.chat-date-separator {
    text-align: center;
    margin: 14px 0;
}

.chat-date-separator span {
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--bg-elevated);
    padding: 4px 12px;
    border-radius: 12px;
}

.chat-p2p-alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #e2e8f0;
    padding: 10px 14px;
    margin: 12px 16px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.45;
}

.btn-p2p-mode-toggle {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-p2p-mode-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-p2p-mode-toggle.active-p2p {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.net-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin-left: 4px;
    vertical-align: middle;
}

.net-mode-pill.lan {
    background: rgba(16, 185, 129, 0.16);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.net-mode-pill.wan {
    background: rgba(59, 130, 246, 0.16);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.message-row {
    display: flex;
    gap: 8px;
    max-width: 75%;
    width: fit-content;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-row.sent {
    align-self: flex-end;
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-row.received {
    align-self: flex-start;
    margin-right: auto;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}

.message-row.sent .message-bubble {
    background-color: var(--accent-blue);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-row.received .message-bubble {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    opacity: 0.8;
}

.msg-action-bar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
}

.msg-action-bar button {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.2);
    outline: none;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    line-height: 1.4;
}

.msg-action-bar .btn-edit-msg {
    color: #ffffff;
}

.msg-action-bar .btn-unsend-msg {
    color: #ffb3ba;
}

.msg-action-bar button:hover {
    background: rgba(0, 0, 0, 0.45);
}

/* Chat Input Bar */
.chat-input-bar {
    padding: 16px 24px;
    background-color: var(--bg-surface);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input-container {
    flex: 1;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
    transition: border-color 0.2s;
}

.chat-input-container:focus-within {
    border-color: var(--text-muted);
}

.chat-input-container input {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.chat-input-action {
    color: var(--text-secondary);
    transition: color 0.15s;
}
.chat-input-action:hover {
    color: var(--text-primary);
}

.chat-send-btn {
    color: var(--accent-blue);
    font-weight: 700;
    font-size: 14px;
    padding: 4px 8px;
    transition: opacity 0.15s;
}

.chat-send-btn:hover {
    opacity: 0.8;
}

/* Empty State Window (When no chat is selected) */
.empty-chat-state {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.empty-chat-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 2px solid var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.empty-chat-title {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-chat-desc {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 320px;
    margin-bottom: 24px;
    line-height: 1.4;
}

.empty-chat-btn {
    background-color: var(--accent-blue);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
}

/* --------------------------------------------------------------------------
   Sub-Views (Friends, Profile, Settings)
   -------------------------------------------------------------------------- */
.view-container {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 32px 40px;
    background-color: var(--bg-surface);
}

.view-header {
    margin-bottom: 28px;
}
.view-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}
.view-header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Friends / Search View */
.search-users-box {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    margin-bottom: 24px;
}
.search-users-box input {
    flex: 1;
    font-size: 14px;
}

.tabs-nav {
    display: flex;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}
.tab-btn {
    padding: 10px 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.tab-btn.active {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.user-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.user-card-info {
    display: flex;
    align-items: center;
    gap: 14px;
}
.user-card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.pending-outgoing-requests {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-elevated);
}
.search-results-list {
    min-width: 0;
}
.btn-sm-primary {
    background-color: var(--accent-blue);
    color: white;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 6px;
}
.btn-sm-secondary {
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 6px;
}

/* Profile View */
.profile-card-top {
    display: flex;
    align-items: center;
    gap: 36px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
}
.profile-avatar-large {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background-color: var(--bg-input);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.profile-handle {
    font-size: 22px;
    font-weight: 600;
}
.profile-name {
    font-size: 15px;
    font-weight: 600;
}
.profile-bio {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 440px;
    line-height: 1.4;
}

.profile-posts {
    max-width: 960px;
    margin: 0 auto;
}
.profile-posts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}
.profile-posts-header h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.profile-photo-form {
    max-width: 480px;
    padding: 16px;
    margin: 0 0 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-base);
}
.profile-photo-form label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}
.profile-photo-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
}
.profile-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
}
.profile-photo-tile {
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-input);
}
.profile-photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-photo-caption {
    position: absolute;
    inset: auto 0 0;
    padding: 24px 8px 8px;
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: linear-gradient(transparent, rgba(0, 0, 0, .75));
}
.profile-photo-tile button {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, .65);
    font-size: 20px;
    line-height: 1;
}
.profile-photo-empty {
    grid-column: 1 / -1;
    padding: 48px 16px;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 440px;
}
.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-group input, .form-group textarea {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
}

/* Settings View */
.settings-section-card {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
    max-width: 600px;
}
.danger-zone-card {
    border-color: rgba(237, 73, 86, .45);
}
.danger-zone-card h3 {
    margin-bottom: 8px;
    color: var(--error-red);
}
.danger-zone-card p {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}
.danger-zone-card label {
    display: block;
    margin: 12px 0 6px;
    font-size: 13px;
    font-weight: 600;
}
.danger-zone-card input,
.danger-zone-card select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
}
.danger-zone-card #btn-delete-account {
    margin-top: 16px;
    background: var(--error-red);
}
.danger-zone-card .account-delete-error {
    margin-top: 10px;
    color: var(--error-red);
}
.button-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 7px;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: button-spinner-rotate .7s linear infinite;
}
@keyframes button-spinner-rotate {
    to { transform: rotate(360deg); }
}
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.settings-row:last-child {
    border-bottom: none;
}
.toggle-switch {
    width: 44px;
    height: 24px;
    background-color: var(--bg-input);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-switch.active {
    background-color: var(--accent-blue);
}
.toggle-knob {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: white;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}
.toggle-switch.active .toggle-knob {
    transform: translateX(20px);
}

/* --------------------------------------------------------------------------
   Mobile Navigation Bars
   -------------------------------------------------------------------------- */
.mobile-top-bar {
    display: none;
    height: 52px;
    background-color: var(--bg-base);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.mobile-bottom-bar {
    display: none;
    height: 54px;
    background-color: var(--bg-base);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    justify-content: space-around;
    align-items: center;
}

/* --------------------------------------------------------------------------
   Media Queries & Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
    :root {
        --sidebar-width: var(--sidebar-collapsed-width);
    }
    .sidebar-logo span,
    .nav-item span,
    .user-mini-info,
    .sidebar-footer .nav-item span {
        display: none;
    }
    .sidebar {
        padding: 20px 8px;
        align-items: center;
    }
    .nav-item {
        padding: 12px;
        justify-content: center;
    }
    .sidebar-logo {
        padding: 0 0 24px 0;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .profile-card-top {
        align-items: flex-start;
        gap: 18px;
        padding-bottom: 22px;
        margin-bottom: 20px;
    }
    .profile-avatar-large {
        flex: 0 0 82px;
        width: 82px;
        height: 82px;
    }
    .profile-handle {
        font-size: 18px;
    }
    .profile-meta {
        min-width: 0;
        gap: 7px;
    }
    .profile-photo-grid {
        gap: 2px;
    }
    .sidebar {
        display: none;
    }
    .mobile-top-bar {
        display: flex;
    }
    .mobile-bottom-bar {
        display: flex;
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(54px + env(safe-area-inset-bottom));
    }
    .main-layout {
        padding-top: 52px;
        padding-bottom: calc(54px + env(safe-area-inset-bottom));
        height: 100dvh;
        max-height: 100dvh;
    }
    .main-content-pane {
        width: 100%;
        height: 100%;
    }
    .conv-mount-wrapper {
        width: 100% !important;
        height: 100% !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .conversations-pane {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important;
        border-right: none !important;
    }
    #chat-window-mount:empty,
    #chat-window-mount:has(.empty-chat-state) {
        display: none !important;
    }
    .chat-window {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        z-index: 999;
        display: none;
        background-color: var(--bg-surface);
        flex-direction: column;
    }
    .chat-window.open-mobile {
        display: flex;
    }
    .chat-messages-scroll {
        padding: 16px 14px;
    }
    .chat-window.open-mobile .chat-header {
        height: 58px;
        padding: 0 16px;
        padding-top: env(safe-area-inset-top);
        position: sticky;
        top: 0;
        flex-shrink: 0;
        z-index: 30;
    }
    .chat-window.open-mobile .chat-input-bar {
        padding: 10px 14px;
        padding-bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
        position: sticky;
        bottom: 0;
        flex-shrink: 0;
        z-index: 30;
        background-color: var(--bg-surface);
    }
    .chat-back-btn {
        display: flex;
    }
    .empty-chat-state {
        display: none !important;
    }
    .view-container {
        padding: 20px 16px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

@keyframes pulseRing {
    0% { transform: scale(0.98); box-shadow: 0 0 0 0 rgba(0, 149, 246, 0.7); }
    70% { transform: scale(1.03); box-shadow: 0 0 0 16px rgba(0, 149, 246, 0); }
    100% { transform: scale(0.98); box-shadow: 0 0 0 0 rgba(0, 149, 246, 0); }
}

/* Hide raw action buttons by default; revealed via Long-Press / Right-Click */
.msg-action-bar {
    display: none !important;
}

/* Native Floating Message Context Menu */
.msg-context-menu {
    position: fixed;
    background: rgba(22, 22, 22, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75);
    z-index: 5000;
    min-width: 175px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    animation: fadeIn 0.12s ease;
}

.msg-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: #f5f5f5;
    border-radius: 9px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
    user-select: none;
}

.msg-context-item:hover, .msg-context-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.msg-context-item.danger {
    color: #ff5252;
}

.msg-context-item.danger:hover, .msg-context-item.danger:active {
    background: rgba(255, 82, 82, 0.16);
}
