/* ============================================================
   Quantum Bubble Chat — Theme & Animations
   Copyright (c) 2026 Derek King / Qubble Labs LLC.
   All Rights Reserved. PROPRIETARY AND CONFIDENTIAL.
   See LICENSE file for terms.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@400;600;700;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Colors */
    --color-void:         #0a0a0f;
    --color-surface:      #12121f;
    --color-surface-up:   #1a1a2e;
    --color-primary:      #7b2ff7;
    --color-primary-lt:   #a855f7;
    --color-secondary:    #00d4ff;
    --color-secondary-mt: #0ea5e9;
    --color-accent-warm:  #f59e0b;
    --color-accent-hot:   #f472b6;
    --color-success:      #34d399;
    --color-text:         #e8e8f0;
    --color-text-dim:     #8888a8;
    --color-border:       rgba(123, 47, 247, 0.15);
    --color-danger:       #ff003c;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #7b2ff7 0%, #00d4ff 100%);
    --gradient-bubble-sent: linear-gradient(135deg, rgba(123, 47, 247, 0.22) 0%, rgba(123, 47, 247, 0.08) 100%);
    --gradient-bubble-recv: linear-gradient(135deg, rgba(0, 212, 255, 0.18) 0%, rgba(0, 212, 255, 0.06) 100%);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Orbitron', 'Exo 2', sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

    /* Effects */
    --glass-blur: blur(12px) saturate(150%);
    --glow-primary: 0 0 15px rgba(123, 47, 247, 0.15);
    --glow-secondary: 0 0 15px rgba(0, 212, 255, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    background-color: var(--color-void);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}
/* When chat is active (login dismissed) revert to viewport-locked layout for
   the messages pane, which manages its own scroll. */
body.in-chat {
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   QUANTUM PARTICLE BACKGROUND
   ============================================================ */
.quantum-bg {
    position: fixed;
    inset: 0;
    background: var(--color-void);
    overflow: hidden;
    z-index: 0;
}

.quantum-bg::before {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(123, 47, 247, 0.6), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(0, 212, 255, 0.5), transparent),
        radial-gradient(1.5px 1.5px at 60% 20%, rgba(168, 85, 247, 0.4), transparent),
        radial-gradient(1.5px 1.5px at 80% 60%, rgba(0, 212, 255, 0.3), transparent),
        radial-gradient(2px 2px at 10% 80%, rgba(123, 47, 247, 0.5), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(244, 114, 182, 0.3), transparent),
        radial-gradient(2px 2px at 70% 40%, rgba(0, 212, 255, 0.4), transparent),
        radial-gradient(1.5px 1.5px at 30% 90%, rgba(123, 47, 247, 0.3), transparent),
        radial-gradient(1px 1px at 90% 10%, rgba(168, 85, 247, 0.5), transparent),
        radial-gradient(2px 2px at 15% 55%, rgba(0, 212, 255, 0.35), transparent);
    animation: quantum-drift 120s linear infinite;
}

.quantum-bg::after {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(1px 1px at 25% 35%, rgba(123, 47, 247, 0.4), transparent),
        radial-gradient(1px 1px at 45% 75%, rgba(0, 212, 255, 0.35), transparent),
        radial-gradient(1px 1px at 65% 25%, rgba(168, 85, 247, 0.3), transparent),
        radial-gradient(1px 1px at 85% 65%, rgba(0, 212, 255, 0.25), transparent),
        radial-gradient(1px 1px at 35% 85%, rgba(244, 114, 182, 0.2), transparent),
        radial-gradient(1px 1px at 55% 15%, rgba(52, 211, 153, 0.25), transparent),
        radial-gradient(1px 1px at 75% 45%, rgba(123, 47, 247, 0.3), transparent),
        radial-gradient(1px 1px at 5% 95%, rgba(0, 212, 255, 0.3), transparent);
    animation: quantum-drift 80s linear infinite reverse;
}

@keyframes quantum-drift {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-5%, -3%); }
    50%  { transform: translate(-2%, -6%); }
    75%  { transform: translate(-7%, -2%); }
    100% { transform: translate(0, 0); }
}

.quantum-nebula {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 400px at 20% 80%, rgba(123, 47, 247, 0.08), transparent),
        radial-gradient(ellipse 500px 500px at 80% 20%, rgba(0, 212, 255, 0.06), transparent);
    pointer-events: none;
    z-index: 1;
    animation: nebula-pulse 20s ease-in-out infinite alternate;
}

@keyframes nebula-pulse {
    0%   { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: flex-start;   /* margin:auto on .login-card handles centering */
    min-height: 100vh;
    padding: 32px 20px;
    position: relative;
    z-index: 2;
}

.login-card {
    text-align: center;
    background: rgba(18, 18, 31, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 560px;          /* was 440 — wider so the onboarding panel fits comfortably */
    margin: auto;              /* centers vertically if there's spare space, top-aligns when content overflows */
    box-shadow: 0 0 40px rgba(123, 47, 247, 0.08), 0 20px 60px rgba(0, 0, 0, 0.5);
}

.brand-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 6s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.brand-tagline {
    font-size: 0.875rem;
    color: var(--color-text-dim);
    font-style: italic;
    letter-spacing: 0.05em;
    margin-bottom: 2rem;
}

.login-card label {
    display: block;
    font-size: 0.7rem;
    color: var(--color-text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: left;
    margin-bottom: 6px;
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(123, 47, 247, 0.2);
    background: rgba(10, 10, 15, 0.6);
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}

.login-card input[type="text"]::placeholder,
.login-card input[type="password"]::placeholder {
    color: rgba(136, 136, 168, 0.7);   /* was 0.5 — too dim made fields read as "disabled / filled" rather than "empty waiting" */
    font-style: italic;
}

/* Cyan-tinted helper text below the confirm-password input so new users
   notice it as an actionable pending step. */
.signup-hint {
    font-family: var(--font-primary);
    font-size: 11px;
    color: rgba(0, 212, 255, 0.78);
    text-align: left;
    margin: -10px 2px 14px;
    letter-spacing: 0.02em;
    font-style: italic;
}
.signup-hint b {
    color: rgba(0, 212, 255, 1);
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.08em;
}
@media (min-width: 760px) {
    .signup-hint { font-size: 10.5px; margin: -8px 2px 8px; }
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

.login-card select {
    color: var(--color-secondary);
    cursor: pointer;
}

.btn-generate {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(123, 47, 247, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
}

.btn-generate::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 45%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 55%, transparent 100%);
    transform: rotate(25deg);
    animation: btn-shimmer 4s ease-in-out infinite;
}

@keyframes btn-shimmer {
    0%, 100% { transform: rotate(25deg) translateX(-100%); }
    50%      { transform: rotate(25deg) translateX(100%); }
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--color-text-dim);
    font-size: 0.875rem;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(123, 47, 247, 0.2), transparent);
}

.crypto-status {
    margin-top: 16px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--color-text-dim);
    letter-spacing: 0.05em;
}

/* ============================================================
   MAIN LAYOUT — CHAT SCREEN
   ============================================================ */
#main-layout {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
    z-index: 2;
}

#chat-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* Header */
header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.codename {
    color: var(--color-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.user-count {
    background: rgba(123, 47, 247, 0.3);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.hbtn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--color-text-dim);
    padding: 5px 10px;
    font-size: 11px;
    font-family: var(--font-primary);
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    border-radius: 6px;
    transition: 0.2s;
}

.hbtn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.hbtn.e2ee { border-color: rgba(52, 211, 153, 0.4); color: var(--color-success); font-family: var(--font-mono); font-size: 10px; }
.hbtn.e2ee:hover { background: rgba(52, 211, 153, 0.15); }

.hbtn.share { border-color: rgba(0, 212, 255, 0.3); color: var(--color-secondary); }
.hbtn.share:hover { background: rgba(0, 212, 255, 0.1); }

.hbtn.dc { border-color: rgba(244, 114, 182, 0.3); color: var(--color-accent-hot); }
.hbtn.dc:hover { background: rgba(244, 114, 182, 0.15); }

/* Share link banner */
#share-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    background: rgba(0, 212, 255, 0.04);
    border-bottom: 1px solid rgba(0, 212, 255, 0.1);
}

#share-banner span {
    font-size: 11px;
    color: var(--color-text-dim);
    font-weight: 600;
    letter-spacing: 1px;
    white-space: nowrap;
}

#share-banner input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(10, 10, 15, 0.6);
    border: 1px solid rgba(123, 47, 247, 0.15);
    border-radius: 6px;
    color: var(--color-secondary);
    font-size: 11px;
    font-family: var(--font-mono);
    outline: none;
    cursor: pointer;
}

#share-banner button {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 1px;
    border-radius: 6px;
    transition: 0.2s;
}

#share-banner button:hover { opacity: 0.85; }

/* Encryption status bar */
.enc-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 20px;
    background: rgba(52, 211, 153, 0.06);
    border-bottom: 1px solid rgba(52, 211, 153, 0.1);
    font-size: 10px;
    letter-spacing: 1px;
    font-family: var(--font-mono);
}

.enc-bar .st { color: var(--color-success); animation: enc-pulse 3s ease-in-out infinite; }

@keyframes enc-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.enc-bar .pg { color: var(--color-accent-hot); font-weight: bold; }

/* Discoverable hint — many users don't realize bubbles are click-to-pop */
.enc-bar .tip {
    color: var(--color-secondary);
    font-weight: 600;
    letter-spacing: 1.5px;
    cursor: help;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.20);
    transition: all 200ms;
    animation: tip-attract 5s ease-in-out infinite;
}
.enc-bar .tip:hover {
    background: rgba(0, 212, 255, 0.14);
    border-color: rgba(0, 212, 255, 0.50);
    animation: none;
}
.enc-bar .tip-emoji {
    display: inline-block;
    animation: tip-bounce 2.6s ease-in-out infinite;
    font-style: normal;
}
@keyframes tip-attract {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
    60%      { box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.06); }
}
@keyframes tip-bounce {
    0%, 100% { transform: scale(1) rotate(0); }
    50%      { transform: scale(1.18) rotate(-12deg); }
}
@media (max-width: 720px) {
    .enc-bar .tip { font-size: 9px; letter-spacing: 1px; padding: 1px 6px; }
}

/* Encryption transparency panel */
#crypto-panel {
    display: none;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(52, 211, 153, 0.15);
    box-shadow: 0 2px 15px rgba(52, 211, 153, 0.08);
    padding: 14px 20px;
    animation: panel-slide 0.3s ease;
}

@keyframes panel-slide {
    from { max-height: 0; opacity: 0; }
    to   { max-height: 500px; opacity: 1; }
}

.crypto-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.crypto-row:last-child { border-bottom: none; }

.crypto-label {
    color: var(--color-text-dim);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-right: 15px;
}

.crypto-value {
    color: var(--color-success);
    font-size: 11px;
    text-align: right;
    font-family: var(--font-mono);
}

.crypto-value.warn { color: var(--color-accent-warm); }
.crypto-value.info { color: var(--color-secondary); }
.crypto-value.safe { color: var(--color-success); }

.crypto-panel select {
    background: rgba(18, 18, 31, 0.8);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--color-secondary);
    padding: 4px 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    outline: none;
    cursor: pointer;
    border-radius: 4px;
}

/* ============================================================
   MESSAGES / BUBBLES
   ============================================================ */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.bubble {
    position: relative;
    max-width: 70%;
    padding: 14px 20px;
    border-radius: 28px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: quantum-idle var(--bob-duration, 4s) ease-in-out infinite;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Glassmorphism shine — big curved highlight like a real bubble */
.bubble::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 15%; right: 15%;
    height: 45%;
    border-radius: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.14), rgba(255,255,255,0.02) 60%, transparent);
    pointer-events: none;
}

/* Secondary shine — small specular dot */
.bubble::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 18%;
    width: 12px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    filter: blur(2px);
    pointer-events: none;
}

.bubble--sent {
    align-self: flex-end;
    background: var(--gradient-bubble-sent);
    border-color: rgba(123, 47, 247, 0.25);
    box-shadow:
        0 0 20px rgba(123, 47, 247, 0.15),
        0 0 40px rgba(123, 47, 247, 0.05),
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 -2px 6px rgba(123, 47, 247, 0.1);
    border-bottom-right-radius: 8px;
}

.bubble--recv {
    align-self: flex-start;
    background: var(--gradient-bubble-recv);
    border-color: rgba(0, 212, 255, 0.2);
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.12),
        0 0 40px rgba(0, 212, 255, 0.04),
        0 6px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 -2px 6px rgba(0, 212, 255, 0.08);
    border-bottom-left-radius: 8px;
}

.bubble .sender {
    font-size: 0.7rem;
    color: var(--color-text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.bubble--sent .sender { color: var(--color-primary-lt); }
.bubble--recv .sender { color: var(--color-secondary); }

.bubble .text { font-size: 0.95rem; line-height: 1.5; }

.bubble .enc-badge {
    position: absolute;
    bottom: 3px;
    right: 10px;
    font-size: 8px;
    color: var(--color-success);
    opacity: 0.35;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    pointer-events: none;
}

/* Idle quantum breathing — visible bob like floating in liquid */
@keyframes quantum-idle {
    0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
    25%      { transform: translateY(-4px) scale(1.008) rotate(0.3deg); }
    50%      { transform: translateY(-6px) scale(1.012) rotate(-0.2deg); }
    75%      { transform: translateY(-3px) scale(1.005) rotate(0.15deg); }
}

.bubble:nth-child(2n)  { animation-delay: -1.2s; }
.bubble:nth-child(3n)  { animation-delay: -2.3s; }
.bubble:nth-child(5n)  { animation-delay: -0.7s; }
.bubble:nth-child(7n)  { animation-delay: -3.1s; animation-duration: 5.5s; }
.bubble:nth-child(11n) { animation-delay: -1.8s; animation-duration: 3.8s; }

/* Hover — bubble excites, lifts up */
.bubble:hover {
    transform: translateY(-8px) scale(1.03);
    filter: brightness(1.12);
    box-shadow:
        0 0 30px rgba(123, 47, 247, 0.25),
        0 12px 30px rgba(0, 0, 0, 0.4);
}

.bubble--sent:hover {
    box-shadow: 0 0 25px rgba(123, 47, 247, 0.25), 0 8px 20px rgba(0, 0, 0, 0.4);
}

.bubble--recv:hover {
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.2), 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   BUBBLE ANIMATIONS
   ============================================================ */

/* Float up from input — exaggerated bubbly rise with wobble */
@keyframes bubble-float-up {
    0%   { opacity: 0;   transform: translateY(150px) translateX(0px) scale(0.3) rotate(0deg); }
    8%   { opacity: 0.5; transform: translateY(130px) translateX(12px) scale(0.5) rotate(2deg); }
    18%  { opacity: 0.8; transform: translateY(100px) translateX(-15px) scale(0.7) rotate(-3deg); }
    30%  {               transform: translateY(70px) translateX(18px) scale(0.85) rotate(2.5deg); }
    42%  { opacity: 1;   transform: translateY(40px) translateX(-12px) scale(0.95) rotate(-1.5deg); }
    55%  {               transform: translateY(15px) translateX(8px) scale(1.04) rotate(1deg); }
    68%  {               transform: translateY(-5px) translateX(-5px) scale(1.02) rotate(-0.5deg); }
    78%  {               transform: translateY(-12px) translateX(3px) scale(1.005) rotate(0.3deg); }
    88%  {               transform: translateY(-4px) translateX(-1px) scale(1.01) rotate(-0.1deg); }
    95%  {               transform: translateY(2px) translateX(0px) scale(1.003) rotate(0deg); }
    100% { opacity: 1;   transform: translateY(0) translateX(0) scale(1) rotate(0deg); }
}

.bubble--arriving {
    animation: bubble-float-up 1.1s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

/* Materialize for received messages — pops into existence like a real bubble forming */
@keyframes quantum-materialize {
    0%   { transform: scale(0.1) translateY(30px); opacity: 0; filter: blur(12px); border-radius: 50%; }
    30%  { transform: scale(0.6) translateY(10px); opacity: 0.5; filter: blur(4px); }
    50%  { transform: scale(1.08) translateY(-5px); opacity: 0.9; filter: blur(1px); }
    70%  { transform: scale(0.97) translateY(2px); opacity: 1; filter: blur(0); }
    85%  { transform: scale(1.02) translateY(-1px); }
    100% { transform: scale(1) translateY(0); opacity: 1; filter: blur(0); }
}

.bubble--materializing {
    animation: quantum-materialize 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Pop animation */
@keyframes bubble-pop {
    0%   { transform: scale(1); opacity: 1; filter: brightness(1); }
    30%  { transform: scale(1.15); opacity: 0.9; filter: brightness(1.5); box-shadow: 0 0 40px rgba(244, 114, 182, 0.6); }
    60%  { transform: scale(0.3); opacity: 0.5; filter: brightness(2); border-radius: 50%; }
    100% { transform: scale(0); opacity: 0; filter: brightness(3); }
}

.bubble--popping {
    animation: bubble-pop 0.45s ease-in forwards !important;
    pointer-events: none;
}

/* Pop particle (spawned via JS) */
.pop-particle {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
}

/* System messages */
.system-message {
    text-align: center;
    color: var(--color-text-dim);
    font-size: 11px;
    padding: 6px 15px;
    letter-spacing: 1px;
    font-family: var(--font-mono);
    opacity: 0.6;
}

/* ============================================================
   CHAT FORM
   ============================================================ */
#chat-form {
    display: flex;
    padding: 12px 16px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--color-border);
    gap: 10px;
}

#chat-form input {
    flex: 1;
    padding: 14px 16px;
    background: rgba(18, 18, 31, 0.6);
    border: 1px solid rgba(123, 47, 247, 0.15);
    border-radius: 12px;
    color: #fff;
    outline: none;
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: 0.2s;
}

#chat-form input:focus {
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.08);
}

#chat-form input::placeholder {
    color: rgba(136, 136, 168, 0.4);
}

#chat-form button {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

#chat-form button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ============================================================
   SIDEBAR (contacts)
   ============================================================ */
#sidebar {
    width: 250px;
    background: rgba(12, 12, 20, 0.9);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-family: var(--font-display);
    font-size: 0.8rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#add-friend-btn {
    padding: 2px 8px;
    font-size: 16px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

#add-friend-btn:hover { background: rgba(0, 212, 255, 0.1); }

#friend-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.friend-item {
    padding: 12px 15px;
    border: 1px solid rgba(123, 47, 247, 0.1);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    background: rgba(18, 18, 31, 0.4);
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.friend-item:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(123, 47, 247, 0.1);
}

.friend-name { font-weight: 600; font-size: 0.9rem; }

.copy-friend-link {
    background: transparent;
    border: none;
    color: var(--color-text-dim);
    padding: 0 5px;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
}

.copy-friend-link:hover { color: var(--color-secondary); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(123, 47, 247, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(123, 47, 247, 0.5); }

/* ============================================================
   MOBILE
   ============================================================ */
.mobile-only { display: none; }

@media (max-width: 768px) {
    #sidebar {
        position: absolute;
        left: -250px;
        top: 0; bottom: 0;
        z-index: 1000;
    }
    #sidebar.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
    }
    .mobile-only { display: block; }
    .bubble { max-width: 88%; }
    #chat-form { padding: 10px; }
    #chat-form input { padding: 12px; }
    header { padding: 10px 14px; }
    .header-right { gap: 5px; }
    .hbtn { padding: 4px 6px; font-size: 10px; }
    .brand-title { font-size: 1.5rem; }
    #share-banner { flex-wrap: wrap; }
    #share-banner input { min-width: 0; }

    /* May-27 fix (King: "chatroom scaled larger than the window, what i'm
       typing is getting cut off"): the 6 header buttons + balance chip + Q-E2EE
       badge totalled ~622px and didn't wrap, forcing #chat-screen to 825px on a
       390px viewport. msg-input then overflowed off the right edge of the
       phone, so the cursor went off-screen as you typed.
       Fixes: (1) min-width:0 on the flex children so they can shrink below
       their content size; (2) flex-wrap on header + header-right so the
       buttons spill to a second row instead of pushing the layout wider;
       (3) chat-form input takes its own full-width row on mobile, send buttons
       wrap onto a second row aligned right — keyboard-friendly phone pattern. */
    #main-layout       { min-width: 0; }
    #chat-screen       { min-width: 0; }
    #chat-screen > *   { min-width: 0; max-width: 100%; }
    #main-layout header { flex-wrap: wrap; min-width: 0; row-gap: 6px; }
    .header-right       { flex-wrap: wrap; min-width: 0; row-gap: 6px; justify-content: flex-end; }
    #chat-form          { flex-wrap: wrap; row-gap: 8px; justify-content: flex-end; }
    #chat-form input    { flex: 1 1 100%; min-width: 0; }
}

/* Codename ownership warning on login screen */
.codename-hint {
    font-size: 11px;
    line-height: 1.55;
    color: #8888a8;
    margin: 8px 0 14px;
    padding: 10px 12px;
    background: rgba(20, 241, 149, 0.04);
    border-left: 2px solid rgba(20, 241, 149, 0.50);
    border-radius: 4px;
}
.codename-hint b { color: #e8e8f0; }

/* Sidebar footer — discoverable history + topup */
#sidebar { display: flex; flex-direction: column; }
#friend-list { flex: 1; overflow-y: auto; }
.sidebar-foot {
    border-top: 1px solid rgba(123, 47, 247, 0.15);
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 6px;
    background: rgba(10, 10, 20, 0.40);
}
.sidebar-foot__link {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #b8b6cb;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 160ms;
}
.sidebar-foot__link:hover {
    background: rgba(0, 212, 255, 0.08);
    color: #00d4ff;
}

/* ── Forgot-password link on login + recovery modal ── */
.forgot-password-row {
    margin: -8px 0 12px;
    text-align: right;
}
.forgot-password-row a {
    font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace;
    font-size: 11px;
    color: var(--color-secondary, #00d4ff);
    text-decoration: none;
    letter-spacing: 0.05em;
    border-bottom: 1px dashed rgba(0,212,255,0.4);
}
.forgot-password-row a:hover { color: #14f195; border-color: rgba(20,241,149,0.6); }

.recover-overlay {
    position: fixed; inset: 0; z-index: 10003;
    background: rgba(5, 6, 11, 0.92);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.recover-overlay[hidden] { display: none; }
.recover-card {
    position: relative;
    width: 100%; max-width: 480px;
    background: linear-gradient(168deg, rgba(123,47,247,0.10), rgba(0,212,255,0.06), #0a0a14);
    border: 1px solid rgba(123,47,247,0.35);
    border-radius: 14px;
    padding: 30px 28px 26px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.65);
}
.recover-card h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    color: #ffffff;
}
.recover-card label {
    display: block;
    font-family: ui-monospace, 'JetBrains Mono', monospace;
    font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
    color: #8888a8;
    margin: 14px 0 5px;
}
.recover-card input[type="text"], .recover-card input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border-radius: 9px;
    border: 1px solid rgba(123,47,247,0.25);
    background: rgba(10,10,20,0.65);
    color: #e8e8f0;
    font-size: 14px;
    outline: none;
    transition: border-color 200ms, box-shadow 200ms;
}
.recover-card input:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0,212,255,0.18);
}
.recover-blurb {
    color: #b8b8d0;
    font-size: 13px;
    margin-bottom: 10px;
}
.recover-blurb b { color: #ffffff; }
.recover-close {
    position: absolute; top: 12px; right: 14px;
    background: none; border: none; color: #888aa0;
    font-size: 24px; cursor: pointer; line-height: 1;
}
.recover-close:hover { color: #ffffff; }

/* ====================================================================
   NEW-USER ONBOARDING PANEL  (login screen, May-23)
   Shown above the codename input. Expanded by default for first-time
   visitors; collapsed for returners (localStorage 'qbc-onboarded').
   Matches the aerospace-instrument grammar of /download.html .plat tiles.
   ==================================================================== */
.onboard-panel {
    position: relative;
    margin: 16px 0;
    background: rgba(18, 18, 31, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(123, 47, 247, 0.20);
    border-left: 2px solid #00d4ff;
    border-radius: 4px;
    overflow: hidden;
    text-align: left;
}
.onboard-panel::before,
.onboard-panel::after {
    content: "";
    position: absolute;
    width: 8px; height: 8px;
    border: 1px solid #00d4ff;
    opacity: 0.55;
    pointer-events: none;
}
.onboard-panel::before { top: -1px;    left: -1px;  border-right: 0; border-bottom: 0; }
.onboard-panel::after  { bottom: -1px; right: -1px; border-left:  0; border-top:    0; }

.onboard-head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: inherit;
    text-align: left;
    font-family: inherit;
    transition: background-color 160ms ease;
}
.onboard-head:hover { background-color: rgba(123, 47, 247, 0.06); }
.onboard-head:focus-visible {
    outline: 1px solid rgba(0, 212, 255, 0.55);
    outline-offset: -1px;
}

.onboard-chevron {
    display: inline-block;
    color: #00d4ff;
    font-size: 11px;
    line-height: 1;
    width: 14px;
    text-align: center;
    transition: transform 220ms ease;
}
.onboard-panel[data-state="collapsed"] .onboard-chevron { transform: rotate(180deg); }

.onboard-title {
    flex: 1;
    font-family: 'Orbitron', ui-sans-serif, system-ui, sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #7b2ff7, #00d4ff);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.onboard-reopen {
    display: none;
    font-family: ui-monospace, 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.22em;
    color: rgba(125, 125, 153, 0.85);
    text-transform: uppercase;
}
.onboard-panel[data-state="collapsed"] .onboard-reopen { display: inline-block; }

.onboard-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 220ms ease;
    border-top: 1px solid rgba(123, 47, 247, 0.18);
}
.onboard-panel[data-state="collapsed"] .onboard-body {
    grid-template-rows: 0fr;
    border-top-color: transparent;
}
.onboard-list,
.onboard-body > .onboard-dismiss { min-height: 0; }

.onboard-list {
    list-style: none;
    margin: 0;
    padding: 16px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}
.onboard-li {
    display: flex;
    gap: 10px;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.55;
    color: #b8b6cb;
    opacity: 0;
    transform: translateY(2px);
    animation: onboard-li-in 360ms ease-out forwards;
    animation-delay: var(--d, 0ms);
}
.onboard-li b  { color: #e8e8f0; font-weight: 600; }
.onboard-li em { color: #f472b6; opacity: 0.92; font-style: italic; font-weight: 500; }
@keyframes onboard-li-in { to { opacity: 1; transform: translateY(0); } }
.onboard-panel[data-state="collapsed"] .onboard-li {
    animation: none; opacity: 1; transform: none;
}

.onboard-glyph {
    flex-shrink: 0;
    color: #00d4ff;
    opacity: 0.7;
    font-size: 12px;
    line-height: 1.6;
    width: 14px;
    text-align: center;
}

.onboard-dismiss {
    display: block;
    margin: 4px 20px 16px;
    padding: 8px 14px;
    background: rgba(5, 6, 11, 0.55);
    border: 1px solid rgba(123, 47, 247, 0.30);
    border-radius: 3px;
    color: #b8b6cb;
    font-family: ui-monospace, 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.20em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 160ms, border-color 160ms, box-shadow 220ms, background-color 160ms;
}
.onboard-dismiss:hover {
    color: #e8e8f0;
    border-color: rgba(123, 47, 247, 0.55);
    box-shadow: 0 0 14px rgba(123, 47, 247, 0.35);
    background-color: rgba(123, 47, 247, 0.10);
}
.onboard-dismiss:focus-visible {
    outline: 1px solid rgba(0, 212, 255, 0.55);
    outline-offset: 2px;
}

@media (max-width: 360px) {
    .onboard-head    { padding: 12px 14px; gap: 10px; }
    .onboard-title   { font-size: 10px; letter-spacing: 0.18em; }
    .onboard-list    { padding: 14px 16px 6px; gap: 10px; }
    .onboard-li      { font-size: 12px; line-height: 1.5; }
    .onboard-dismiss { margin: 4px 16px 12px; }
}

/* Tablet+ (≥520px): 2-column bullet grid */
@media (min-width: 520px) {
    .onboard-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 18px;
        padding: 16px 20px 10px;
    }
    .onboard-li { font-size: 12.5px; line-height: 1.5; }
}

/* Center the FREEMIUM trial banner (was left-aligned because trial-mode.css
   .trial-banner has display:flex without justify-content). Higher specificity
   wins regardless of stylesheet load order. */
.login-card .trial-banner       { justify-content: center; }
.login-card .trial-banner__body { text-align: center; align-items: center; }

/* Small italic explainer placed under <select> elements when the label
   alone wouldn't be obvious (LINK TYPE → who can open this link). */
.select-hint {
    font-family: var(--font-primary);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--color-text-dim);
    text-align: left;
    margin: 4px 2px 10px;
    font-style: italic;
}
.select-hint b { color: var(--color-text); font-style: normal; }

/* Desktop (≥760px): wider card + 3-column bullet grid + aggressive vertical
   tightening so the WHOLE card (incl. login-foot links) fits on a single PC
   viewport without scrolling. King's call May-23: "full clarity on page load". */
@media (min-width: 760px) {
    .login-card {
        max-width: 880px;
        padding: 22px 36px 24px;
    }
    /* Compact brand header */
    .login-card > img[alt="Qubble Chat"] {
        width: 48px !important; height: 48px !important;
        margin-bottom: 8px !important;
    }
    .brand-title      { font-size: 1.5rem; margin-bottom: 2px; }
    .brand-tagline    { margin-bottom: 4px; font-size: 0.8rem; }
    .brand-attrib     { margin-top: 0 !important; }
    .trial-banner     { margin: 10px 0 12px; }
    /* Compact onboarding panel */
    .onboard-panel    { margin: 10px 0; }
    .onboard-head     { padding: 10px 16px; }
    .onboard-list {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px 18px;
        padding: 10px 18px 6px;
    }
    .onboard-li       { font-size: 11.5px; line-height: 1.4; }
    .onboard-dismiss  { margin: 2px 18px 10px; padding: 6px 12px; font-size: 9.5px; }
    /* Hide redundant codename-hint on desktop (info already in panel) */
    .codename-hint    { display: none; }
    /* Compact form fields */
    .login-card label { margin-bottom: 3px; margin-top: 4px; }
    .login-card input[type="text"],
    .login-card input[type="password"],
    .login-card select {
        padding: 8px 12px;
    }
    .forgot-password-row { margin: 4px 0 6px; font-size: 11px; }
    .btn-generate     { padding: 12px 16px; margin-top: 8px; }
    .login-divider    { margin: 12px 0 6px; }
    .crypto-status    { margin-top: 6px; }
    .login-foot       { margin-top: 12px; padding-top: 12px; }
    .login-foot__disclaimer { font-size: 10px; margin-bottom: 8px; }
    .select-hint      { font-size: 10.5px; margin: 3px 2px 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .onboard-chevron, .onboard-body, .onboard-dismiss { transition: none; }
    .onboard-li { animation: none; opacity: 1; transform: none; }
}
