/* ==========================================================================
   🤫 4KIN CHAT — CORE DESIGN SYSTEM
   Electric violet, fluid motion, no cap.
   ========================================================================== */

:root {
    --bg-main: #0B0713;
    --panel-bg: #150E22;
    --sidebar-bg: #190F28;

    --accent: #6D28FF;
    --accent-bright: #8B5CF6;
    --accent-soft: rgba(109, 40, 255, 0.16);
    --pop: #FF5B9F;

    --text-primary: #F2EEFA;
    --text-secondary: #9E8FC2;
    --border-ui: #2A1F3D;

    --bubble-me: #6D28FF;
    --bubble-peer: #221732;

    --ease-fluid: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   ☀️ LIGHT THEME — white + purple gradient
   ========================================================================== */
:root[data-theme="light"] {
    --bg-main: #F7F3FF;
    --panel-bg: #FFFFFF;
    --sidebar-bg: #FBF9FF;

    --accent: #6D28FF;
    --accent-bright: #7C3AED;
    --accent-soft: rgba(109, 40, 255, 0.10);
    --pop: #E8368F;

    --text-primary: #241A38;
    --text-secondary: #6F6285;
    --border-ui: #E7DEFA;

    --bubble-me: #6D28FF;
    --bubble-peer: #F1EBFE;
}

:root[data-theme="light"] body {
    background: linear-gradient(160deg, #FFFFFF 0%, #F3ECFE 45%, #E9D9FC 100%);
}
:root[data-theme="light"] .msg.peer { color: var(--text-primary); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(109, 40, 255, 0.22); }

body, .overlay-screen, .panel-bg-transition, #dashboard, .sidebar, .main-chat-window,
.chat-header, .chat-footer, .modal-card, .sidebar-desktop-status, .left-utility-strip {
    transition: background-color 0.35s var(--ease-fluid), color 0.35s var(--ease-fluid), border-color 0.35s var(--ease-fluid);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html { height: 100%; }

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    height: var(--app-height, 100vh);
    height: 100dvh;
    width: 100vw;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: fixed;
    inset: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ==========================================================================
   🌌 AMBIENT VIOLET AURORA — signature motion element
   Soft drifting glow blobs behind onboarding / empty screens.
   ========================================================================== */

.aurora-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.aurora-bg::before, .aurora-bg::after {
    content: "";
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    animation: auroraDrift 16s var(--ease-fluid) infinite alternate;
}
.aurora-bg::before {
    top: -20%; left: -15%;
    background: radial-gradient(circle at 30% 30%, var(--accent-bright), transparent 70%);
}
.aurora-bg::after {
    bottom: -25%; right: -15%;
    background: radial-gradient(circle at 70% 70%, var(--pop), transparent 70%);
    animation-delay: -8s;
    opacity: 0.35;
}
@keyframes auroraDrift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(6%, 8%) scale(1.12); }
}

/* ==========================================================================
   🧱 ONBOARDING & SCREEN OVERLAYS
   ========================================================================== */

.overlay-screen {
    position: fixed; inset: 0; background-color: var(--bg-main);
    display: flex; justify-content: center; align-items: center; z-index: 100;
    padding: 20px; overflow: hidden;
}
.intro-card {
    position: relative; z-index: 1;
    background-color: var(--panel-bg); padding: 44px 40px; border-radius: 24px;
    border: 1px solid var(--border-ui); text-align: center; max-width: 400px;
    width: 90%; max-height: 90%; overflow-y: auto; box-shadow: 0 30px 60px rgba(0,0,0,0.55);
    animation: cardPop 0.45s var(--ease-bounce) both;
}

.brand-mark {
    display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 10px;
}
.brand-mark img {
    width: 72px; height: 72px; border-radius: 20px;
    box-shadow: 0 8px 24px var(--accent-soft), 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.logo-text { font-size: 1.7rem; color: var(--text-primary); font-weight: 800; letter-spacing: 0.5px; }
.tagline { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 30px; line-height: 1.5; }

.input-group { display: flex; flex-direction: column; gap: 12px; }
.input-group input {
    padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border-ui);
    background-color: var(--bg-main); color: var(--text-primary); font-size: 1rem; outline: none;
    transition: border-color 0.2s var(--ease-fluid), box-shadow 0.2s var(--ease-fluid);
}
.input-group input:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group button {
    padding: 14px; border-radius: 12px; border: none; background-color: var(--accent);
    color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid), box-shadow 0.2s var(--ease-fluid);
    box-shadow: 0 8px 20px var(--accent-soft);
}
.input-group button:hover:not(:disabled) { background-color: var(--accent-bright); }
.input-group button:active:not(:disabled) { transform: scale(0.96); }
.input-group button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ==========================================================================
   ⚡→🤫 MULTI-COLUMN APP WORKSPACE ENGINE
   ========================================================================== */

#dashboard {
    display: flex; width: 100%; height: 100%; overflow: hidden; position: relative;
    background-color: var(--bg-main);
    max-width: 100vw;
}

.left-utility-strip {
    width: 64px; min-width: 64px; height: 100%; background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-ui); display: flex; flex-direction: column;
    justify-content: space-between; align-items: center; padding: 20px 0; z-index: 50;
}
.app-logo-indicator img { width: 34px; height: 34px; border-radius: 10px; display: block; }
.strip-bottom-actions { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }

.strip-icon-btn {
    background: none; border: none; color: var(--text-secondary); font-size: 1.4rem;
    cursor: pointer; width: 44px; height: 44px; display: flex; align-items: center;
    justify-content: center; border-radius: 50%; transition: background-color 0.2s var(--ease-fluid), color 0.2s var(--ease-fluid), transform 0.18s var(--ease-bounce);
}
.strip-icon-btn:hover { background-color: var(--accent-soft); color: var(--text-primary); }
.strip-icon-btn:active { transform: scale(0.9); }

.sidebar {
    width: 320px; min-width: 320px; height: 100%; background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-ui); display: flex; flex-direction: column;
    position: relative; z-index: 30;
}

.sidebar-header-title {
    padding: 20px 20px 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header-title h2 { font-size: 1.35rem; color: var(--text-primary); font-weight: 700; }

.mobile-only-btn { display: none; }

.connect-box { padding: 10px 20px 15px 20px; display: flex; gap: 8px; }
.connect-box input {
    flex: 1 1 auto; min-width: 0; width: 100%; padding: 10px 14px; background-color: var(--bg-main); border: 1px solid var(--border-ui);
    border-radius: 10px; color: var(--text-primary); font-size: 0.88rem; outline: none;
    transition: border-color 0.2s var(--ease-fluid), box-shadow 0.2s var(--ease-fluid);
}
.connect-box input:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
.connect-box button {
    flex: 0 0 auto; min-width: 44px; width: 44px; height: 44px;
    background-color: var(--accent); color: #fff; border: none; border-radius: 10px;
    padding: 0; font-weight: bold; cursor: pointer; font-size: 1.3rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transform: scale(0.7); pointer-events: none;
    transition: opacity 0.22s var(--ease-fluid), transform 0.22s var(--ease-bounce), background-color 0.2s var(--ease-fluid);
}
.connect-box button.visible { opacity: 1; transform: scale(1); pointer-events: auto; }
.connect-box button.ready { background-color: var(--pop); }
.connect-box button:hover { background-color: var(--accent-bright); }
.connect-box button.ready:hover { background-color: var(--pop); filter: brightness(1.1); }
.connect-box button:active { transform: scale(0.9); }
.connect-box button.visible:active { transform: scale(0.9); }

.chat-list-container { flex: 1; overflow-y: auto; padding: 0 8px; }
.empty-list-hint { padding: 32px 16px; color: var(--text-secondary); text-align: center; font-size: 0.88rem; line-height: 1.5; }
.chat-user-item {
    padding: 14px 16px; margin: 4px 0; border-radius: 12px; cursor: pointer;
    animation: itemRise 0.3s var(--ease-fluid) both;
    transition: background-color 0.18s var(--ease-fluid);
}
.chat-user-item:hover { background-color: rgba(255, 255, 255, 0.04); }
.chat-user-item.active { background-color: var(--accent-soft); }
.chat-user-item .item-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.unread-dot {
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: var(--pop);
    box-shadow: 0 0 8px rgba(255, 91, 159, 0.8);
    animation: unreadPulse 1.8s ease-in-out infinite;
}
@keyframes unreadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
.chat-user-item .title { font-weight: bold; font-size: 0.95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-user-item .preview { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-delete-btn {
    margin-left: auto; flex-shrink: 0; background: none; border: none; color: var(--text-secondary);
    font-size: 0.9rem; cursor: pointer; padding: 4px 6px; border-radius: 8px; opacity: 0; transition: opacity 0.15s var(--ease-fluid);
}
.chat-user-item:hover .chat-item-delete-btn { opacity: 1; }
.chat-item-delete-btn:hover { color: var(--pop); background-color: rgba(255, 91, 159, 0.12); }

.sidebar-desktop-status {
    padding: 12px 20px; background-color: rgba(0,0,0,0.2); border-top: 1px solid var(--border-ui);
    display: flex; flex-direction: column; gap: 2px;
}
.desktop-username-label { font-size: 0.85rem; font-weight: bold; }
.desktop-number-label { font-size: 0.75rem; color: var(--text-secondary); font-family: monospace; }
.my-tag-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.copy-tag-btn {
    background: none; border: 1px solid var(--border-ui); color: var(--text-secondary);
    font-size: 0.75rem; line-height: 1; padding: 3px 6px; border-radius: 8px; cursor: pointer;
    transition: background-color 0.18s var(--ease-fluid), color 0.18s var(--ease-fluid), transform 0.18s var(--ease-bounce);
    flex-shrink: 0;
}
.copy-tag-btn:hover { background-color: var(--accent-soft); color: var(--text-primary); border-color: var(--accent-bright); }
.copy-tag-btn:active { transform: scale(0.93); }

.main-chat-window {
    flex: 1; min-width: 0; height: 100%; background-color: var(--bg-main); display: flex;
    flex-direction: column; position: relative; z-index: 20;
}

.blank-state-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    justify-content: center; align-items: center; background-color: var(--bg-main);
    color: var(--text-secondary); text-align: center; padding: 20px; z-index: 5;
}
.blank-state-overlay img { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 18px; }
.blank-state-overlay p { max-width: 280px; line-height: 1.5; }
#active-chat-container { display: flex; flex-direction: column; width: 100%; height: 100%; position: relative; z-index: 10; }

.chat-header { flex-shrink: 0; padding: 14px 24px; background-color: var(--panel-bg); border-bottom: 1px solid var(--border-ui); display: flex; align-items: center; gap: 16px; min-height: 64px; }
.back-arrow-btn { background: none; border: none; color: var(--text-primary); font-size: 1.4rem; cursor: pointer; display: none; transition: transform 0.18s var(--ease-bounce); }
.back-arrow-btn:active { transform: translateX(-4px); }
.active-title-meta { display: flex; flex-direction: column; min-width: 0; }
.active-title-meta span { font-weight: bold; font-size: 1rem; }
.active-title-meta .muted-label { font-size: 0.75rem; color: var(--text-secondary); font-family: monospace; margin-top: 2px; }

.header-icon-btn { margin-left: auto; background: none; border: none; color: var(--text-secondary); font-size: 1.15rem; cursor: pointer; padding: 8px; border-radius: 10px; flex-shrink: 0; transition: background-color 0.18s var(--ease-fluid), color 0.18s var(--ease-fluid); }
.header-icon-btn:hover { background-color: rgba(255, 91, 159, 0.12); color: var(--pop); }

.peer-deleted-banner { flex-shrink: 0; background-color: rgba(255, 91, 159, 0.1); color: var(--pop); border-top: 1px solid rgba(255, 91, 159, 0.3); padding: 10px 16px; font-size: 0.8rem; text-align: center; }

.messages-container { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; padding-bottom: 8px; display: flex; flex-direction: column; gap: 14px; background-color: var(--bg-main); }
.msg {
    max-width: 65%; padding: 10px 14px; border-radius: 14px; font-size: 0.95rem; line-height: 1.4; word-break: break-word;
    animation: bubbleIn 0.28s var(--ease-fluid) both;
}
.msg.me { background-color: var(--bubble-me); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.peer { background-color: var(--bubble-peer); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.system { background-color: rgba(255,255,255,0.05); color: var(--text-secondary); align-self: center; max-width: 85%; font-size: 0.82rem; text-align: center; padding: 6px 12px; border: 1px solid var(--border-ui); }
.msg img { max-width: 100%; border-radius: 10px; display: block; margin: 2px 0; }
.msg a.chat-link { text-decoration: underline; word-break: break-word; }
.msg.me a.chat-link { color: #fff; }
.msg.peer a.chat-link { color: var(--accent-bright); }
:root[data-theme="light"] .msg.peer a.chat-link { color: var(--accent); }

.msg .chat-phone {
    text-decoration: underline dotted;
    text-underline-offset: 2px;
    cursor: pointer;
    word-break: break-word;
    transition: opacity 0.15s var(--ease-fluid);
}
.msg.me .chat-phone { color: #fff; }
.msg.peer .chat-phone { color: var(--accent-bright); }
:root[data-theme="light"] .msg.peer .chat-phone { color: var(--accent); }
.msg .chat-phone:active { opacity: 0.6; }
.msg .chat-phone.chat-phone-copied { text-decoration-style: solid; opacity: 0.75; }

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 15;
    margin: 0 14px 14px 14px;
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background-color: var(--panel-bg);
    border: 1px solid var(--border-ui);
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-footer button { background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; padding: 4px; flex-shrink: 0; transition: transform 0.18s var(--ease-bounce), color 0.18s var(--ease-fluid); }
.chat-footer button:hover { color: var(--text-primary); }
.chat-footer button:active { transform: scale(0.88); }
.chat-footer input[type="text"] { flex: 1; min-width: 0; padding: 12px 16px; background-color: var(--bg-main); border: 1px solid var(--border-ui); border-radius: 12px; color: var(--text-primary); outline: none; transition: border-color 0.2s var(--ease-fluid), box-shadow 0.2s var(--ease-fluid); }
.chat-footer input[type="text"]:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
#send-btn { background-color: var(--accent) !important; color: #fff !important; font-size: 0.9rem !important; font-weight: bold; padding: 10px 20px !important; border-radius: 10px; flex-shrink: 0; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid) !important; }
#send-btn:hover { background-color: var(--accent-bright) !important; }
#send-btn:active { transform: scale(0.94); }

/* ==========================================================================
   🎛️ EXTENDED TAB HOOK LAYOUTS & MODALS
   ========================================================================== */

.modal-overlay { position: fixed; inset: 0; background-color: rgba(5,2,10,0.82); display: flex; justify-content: center; align-items: center; z-index: 200; padding: 20px; animation: overlayFade 0.2s var(--ease-fluid) both; }
.system-hub-card { max-width: 420px; width: 92%; max-height: 90%; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; background-color: var(--panel-bg); border: 1px solid var(--border-ui); border-radius: 22px; animation: cardPop 0.35s var(--ease-bounce) both; }

.tab-header-nav { display: flex; background-color: var(--bg-main); padding: 4px; border-radius: 12px; margin-bottom: 24px; border: 1px solid var(--border-ui); }
.tab-btn { flex: 1; padding: 10px 0; background: none; border: none; color: var(--text-secondary); font-size: 0.9rem; font-weight: 600; cursor: pointer; border-radius: 9px; transition: background-color 0.2s var(--ease-fluid), color 0.2s var(--ease-fluid); }
.tab-btn.active { background-color: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-soft); }

.hub-identity-summary { text-align: center; margin-bottom: 24px; padding: 20px 16px; background-color: rgba(255,255,255,0.03); border-radius: 16px; }
#hub-display-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
#hub-display-number { font-size: 0.85rem; color: var(--text-secondary); font-family: monospace; margin: 0; }
.hub-tag-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.hub-tag-row .copy-tag-btn { font-size: 0.78rem; padding: 4px 10px; }

.hub-action-stack { display: flex; flex-direction: column; gap: 12px; }
.primary-hub-action { background-color: var(--accent); color: #fff; font-weight: bold; border: none; padding: 14px; border-radius: 12px; cursor: pointer; font-size: 0.95rem; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid); }
.primary-hub-action:hover { background-color: var(--accent-bright); }
.primary-hub-action:active { transform: scale(0.97); }
.secondary-hub-action { background-color: var(--sidebar-bg); color: var(--text-primary); border: 1px solid var(--border-ui); font-weight: bold; padding: 14px; border-radius: 12px; cursor: pointer; font-size: 0.95rem; transition: transform 0.18s var(--ease-bounce), border-color 0.2s var(--ease-fluid); }
.secondary-hub-action:hover { border-color: var(--accent-bright); }
.secondary-hub-action:active { transform: scale(0.97); }

.input-group-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.input-group-field label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.input-group-field input { padding: 12px 14px; background-color: var(--bg-main); border: 1px solid var(--border-ui); color: var(--text-primary); border-radius: 12px; outline: none; transition: border-color 0.2s var(--ease-fluid), box-shadow 0.2s var(--ease-fluid); }
.input-group-field input:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-soft); }
#save-profile-btn { background-color: var(--accent); color: #fff; border: none; padding: 12px; border-radius: 12px; font-weight: bold; cursor: pointer; margin-top: 4px; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid); }
#save-profile-btn:hover { background-color: var(--accent-bright); }
#save-profile-btn:active { transform: scale(0.97); }

.hub-divider { border: none; border-top: 1px solid var(--border-ui); margin: 20px 0; }

.theme-toggle-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 4px 0 2px 0; }
.theme-toggle-label { font-size: 0.85rem; color: var(--text-secondary); }
.theme-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-switch-slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: var(--border-ui); border-radius: 999px;
    transition: background-color 0.25s var(--ease-fluid);
}
.theme-switch-slider::before {
    content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
    background-color: #fff; border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.25s var(--ease-bounce);
}
.theme-switch input:checked + .theme-switch-slider { background-color: var(--accent); }
.theme-switch input:checked + .theme-switch-slider::before { transform: translateX(22px); }

.update-check-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background-color: var(--sidebar-bg); color: var(--text-primary); border: 1px solid var(--border-ui);
    font-weight: bold; padding: 12px; border-radius: 12px; cursor: pointer; font-size: 0.9rem; width: 100%;
    transition: transform 0.18s var(--ease-bounce), border-color 0.2s var(--ease-fluid), background-color 0.2s var(--ease-fluid);
}
.update-check-btn:hover { border-color: var(--accent-bright); }
.update-check-btn:active { transform: scale(0.97); }
.update-check-btn.spinning span { display: inline-block; animation: spin360 0.8s linear infinite; }
@keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.danger-zone-container { display: flex; flex-direction: column; gap: 10px; }
#delete-profile-btn { background-color: transparent; color: var(--pop); border: 1px solid rgba(255, 91, 159, 0.4); padding: 12px; border-radius: 12px; font-weight: bold; cursor: pointer; transition: background-color 0.2s var(--ease-fluid), transform 0.18s var(--ease-bounce); }
#delete-profile-btn:hover { background-color: rgba(255, 91, 159, 0.1); }
#delete-profile-btn:active { transform: scale(0.97); }
#native-install-btn { background-color: var(--accent); color: #fff; padding: 12px; border: none; border-radius: 12px; font-weight: bold; cursor: pointer; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid); }
#native-install-btn:hover { background-color: var(--accent-bright); }
#native-install-btn:active { transform: scale(0.97); }

.hub-close-btn { background: none; border: none; color: var(--text-secondary); margin-top: 24px; cursor: pointer; transition: color 0.2s var(--ease-fluid); }
.hub-close-btn:hover { color: var(--text-primary); }

/* ==========================================================================
   👥 GROUP CHAT + 🖼️ AVATAR UI
   ========================================================================== */

/* Group creation now lives in the Settings tab as #settings-create-group-btn,
   which reuses the .update-check-btn look — no bespoke styling needed here. */

/* Mini avatar shown in the chat list + chat header. Falls back to an
   initials circle when no picture has been set. */
.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; font-weight: 700; font-size: 0.9rem; color: #fff;
    background: linear-gradient(160deg, var(--accent) 0%, var(--accent-bright) 100%);
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-circle.mini-avatar { width: 30px; height: 30px; font-size: 0.78rem; }
.chat-user-item .item-row { gap: 10px; }

.chat-header-avatar { flex-shrink: 0; }
.chat-header-avatar.hidden { display: none; }
.chat-header-avatar .avatar-circle { width: 38px; height: 38px; }

/* Profile-tab avatar button — replaces the old static emoji <div> so it can
   host either the 👤 fallback or the user's actual picture, and be clickable. */
.hub-avatar {
    width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 10px auto;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
    background: linear-gradient(160deg, var(--accent) 0%, var(--accent-bright) 100%);
    border: none; padding: 0; cursor: pointer; overflow: hidden; color: #fff;
    transition: transform 0.18s var(--ease-bounce);
}
.hub-avatar:hover { transform: scale(1.05); }
.hub-avatar:active { transform: scale(0.95); }
.hub-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Sender name label above peer bubbles in group chats, where a single log
   mixes messages from many different people. */
.msg-sender-label { font-size: 0.72rem; font-weight: 700; color: var(--accent-bright); margin-bottom: 3px; }

/* Group-created / group-invite share popup link field */
.group-link-row { margin: 14px 0; }
.group-link-row input {
    width: 100%; padding: 12px 14px; background-color: var(--bg-main); border: 1px solid var(--border-ui);
    border-radius: 12px; color: var(--text-primary); font-size: 0.82rem; font-family: monospace;
    text-align: center; outline: none;
}
#app-prompt-input {
    font-family: inherit; text-align: left; font-size: 0.95rem;
}
#app-prompt-input:focus { border-color: var(--accent-bright); }

.chat-user-item.is-group .title { color: var(--text-primary); }

/* Popups & Dialogs */
.invite-card { position: relative; background-color: var(--panel-bg); border: 1px solid var(--border-ui); padding: 32px 24px; border-radius: 22px; text-align: center; max-width: 350px; width: 90%; max-height: 90%; overflow-y: auto; animation: cardPop 0.4s var(--ease-bounce) both; }
.invite-icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px auto; display: block; }
.primary-action-btn { background-color: var(--accent); color: #fff; font-weight: bold; border: none; padding: 12px; border-radius: 12px; cursor: pointer; width: 100%; margin-bottom: 10px; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid); }
.primary-action-btn:hover { background-color: var(--accent-bright); }
.primary-action-btn:active { transform: scale(0.97); }
.secondary-action-btn { background: none; border: none; color: var(--text-secondary); font-size: 0.85rem; cursor: pointer; padding: 6px; transition: color 0.2s var(--ease-fluid); }
.secondary-action-btn:hover { color: var(--text-primary); }

#invite-popup-overlay, #group-join-popup-overlay, #group-created-popup-overlay, #anon-msg-popup-overlay {
    position: fixed; inset: 0; background-color: rgba(5,2,10,0.82); display: flex;
    justify-content: center; align-items: center; z-index: 200; padding: 20px;
}

.primary-action-btn.danger { background-color: var(--pop); }
.primary-action-btn.danger:hover { background-color: #E64488; }

#android-demand-overlay, #ios-demand-overlay { position: fixed; inset: 0; background-color: rgba(5,2,10,0.95); display: flex; justify-content: center; align-items: center; z-index: 500; padding: 20px; }
.demand-card { position: relative; background: linear-gradient(160deg, var(--panel-bg) 0%, var(--bg-main) 100%); border: 1px solid var(--border-ui); border-radius: 24px; padding: 40px 30px; text-align: center; max-width: 380px; width: 88%; max-height: 90%; overflow-y: auto; animation: cardPop 0.4s var(--ease-bounce) both; }
.demand-logo-circle { width: 84px; height: 84px; background-color: var(--sidebar-bg); border-radius: 24px; margin: 0 auto 20px auto; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-ui); overflow: hidden; }
.demand-logo-circle img { width: 100%; height: 100%; object-fit: cover; }
#demand-trigger-install-btn { background-color: var(--accent); color: #fff; border: none; border-radius: 12px; padding: 14px 24px; font-weight: bold; width: 100%; cursor: pointer; transition: transform 0.18s var(--ease-bounce), background-color 0.2s var(--ease-fluid); }
#demand-trigger-install-btn:hover { background-color: var(--accent-bright); }
#demand-trigger-install-btn:active { transform: scale(0.97); }
.demand-skip-btn {
    background: none; border: none; color: var(--text-secondary); font-size: 0.85rem;
    padding: 12px 0 0 0; width: 100%; cursor: pointer; text-decoration: underline;
    transition: color 0.18s var(--ease-fluid);
}
.demand-skip-btn:hover { color: var(--text-primary); }

.ios-install-steps { list-style: none; text-align: left; margin: 22px 0 26px 0; display: flex; flex-direction: column; gap: 14px; }
.ios-install-steps li {
    display: flex; align-items: center; gap: 12px; background-color: var(--sidebar-bg);
    border: 1px solid var(--border-ui); border-radius: 14px; padding: 12px 14px;
    color: var(--text-primary); font-size: 0.88rem;
}
.ios-step-icon { font-size: 1.25rem; flex-shrink: 0; }

.lightbox-content { position: relative; max-width: 85vw; max-height: 75vh; max-height: 75dvh; display: flex; flex-direction: column; align-items: center; gap: 15px; animation: cardPop 0.3s var(--ease-bounce) both; }
.lightbox-content img { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 12px; }
.lightbox-close { position: absolute; top: -40px; right: 0; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; transition: transform 0.18s var(--ease-bounce); }
.lightbox-close:active { transform: scale(0.85); }
.lightbox-download-btn { color: #fff; background-color: var(--accent); text-decoration: none; padding: 10px 18px; border-radius: 10px; font-weight: bold; transition: background-color 0.2s var(--ease-fluid), transform 0.18s var(--ease-bounce); }
.lightbox-download-btn:hover { background-color: var(--accent-bright); }
.lightbox-download-btn:active { transform: scale(0.96); }

.fc-toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: 90%; max-width: 340px; pointer-events: none; }
.fc-toast { background-color: var(--panel-bg); color: var(--text-primary); border-left: 4px solid var(--accent); border-top: 1px solid var(--border-ui); border-right: 1px solid var(--border-ui); border-bottom: 1px solid var(--border-ui); padding: 12px 16px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 0.88rem; box-shadow: 0 10px 30px rgba(0,0,0,0.35); animation: toastIn 0.35s var(--ease-fluid); }
.fc-toast.error-toast { border-left-color: var(--pop); }
.fc-toast.leaving { animation: toastOut 0.22s var(--ease-fluid) forwards; }
@keyframes toastIn { from { transform: translateY(-16px) scale(0.96); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes toastOut { from { transform: translateY(0) scale(1); opacity: 1; } to { transform: translateY(-12px) scale(0.96); opacity: 0; } }

@keyframes cardPop {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes itemRise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(109, 40, 255, 0.35); border-radius: 10px; }

/* ==========================================================================
   ⚡ STRICT FLUID BREAKPOINT CORE
   ========================================================================== */
@media (max-width: 768px) {
    .left-utility-strip { display: none; }

    .mobile-only-btn {
        display: block;
        background: none;
        border: none;
        font-size: 1.4rem;
        color: var(--text-primary);
        cursor: pointer;
    }

    .sidebar { width: 100vw; min-width: 100vw; border-right: none; position: absolute; inset: 0; z-index: 10; transition: transform 0.35s var(--ease-fluid); }
    .main-chat-window { width: 100vw; position: absolute; inset: 0; z-index: 20; transition: transform 0.35s var(--ease-fluid); }

    .sidebar.mobile-hidden { transform: translateX(-100%); }
    .main-chat-window.mobile-hidden { transform: translateX(100%); }

    .back-arrow-btn { display: flex; }
    .chat-header { padding: 10px 16px; min-height: 56px; }
    .messages-container { padding: 16px; padding-bottom: 8px; }
    .msg { max-width: 80%; }
    .chat-footer { margin: 0 10px 10px 10px; border-radius: 18px; }
    .chat-item-delete-btn { opacity: 1; }
}

/* Smaller phones: tighten spacing so nothing gets clipped at narrow widths */
@media (max-width: 380px) {
    .intro-card, .invite-card, .demand-card { padding: 28px 18px; }
    .logo-text { font-size: 1.4rem; }
    .system-hub-card { padding: 18px; }
    .chat-footer { margin: 0 8px 8px 8px; padding: 10px 12px; gap: 8px; }
    .sidebar-header-title, .connect-box { padding-left: 14px; padding-right: 14px; }
}

/* Short / landscape screens: keep overlay cards from overflowing vertically */
@media (max-height: 480px) {
    .overlay-screen, .modal-overlay, #android-demand-overlay, #ios-demand-overlay, #invite-popup-overlay, #group-join-popup-overlay, #group-created-popup-overlay, #anon-msg-popup-overlay { align-items: flex-start; padding-top: 16px; padding-bottom: 16px; }
    .intro-card, .invite-card, .demand-card, .system-hub-card { max-height: 100%; }
}
