/* Mobile tweaks (keep visuals identical, but GPU-accelerate) */
@media screen and (max-width: 768px) {
    .outgoingRadius {
        border-top-right-radius: 5px;
        border-top-left-radius: 18px;

        /* GPU hint for rounded-corner repaints */
        will-change: transform, opacity;
        backface-visibility: hidden;
        transform: translateZ(0);
    }
}

/* Mobile layout and UI adjustments */
@media (max-width: 768px) {
    :root {
        --size: 120px;
    }

    .light_mode {
        --size: 120px;
    }

    .signIn {
        left: 0;
        top: 0;
        transform: unset;
        /* keep behavior unchanged */
        width: 100%;
        height: 100%;
        max-width: unset;
        max-height: unset;
        border-radius: 0;
        background-color: #090909;

        /* prepare for smooth opacity/transform (promote to GPU layer) */
        will-change: transform, opacity;
        backface-visibility: hidden;
    }

    .outgoing .text {
        margin-left: 0;

        /* text repaint hint */
        will-change: transform;
        transform: translateZ(0);
    }

    #stop-stream-button {
        bottom: 5px;
        right: 5px;

        will-change: transform, opacity;
        display: none;
        transform: translateZ(0);
    }

    .nav .icon {
        width: 45px;
        height: 45px;

        will-change: transform, opacity;
        transform: translateZ(0);
        backface-visibility: hidden;
    }

    .nav .nav-menu-button {
        margin-top: 7px;
        margin-left: 7px;

        will-change: transform;
        transform: translateZ(0);
    }

    .nav .action-buttons {
        top: 3px;

        will-change: transform;
        transform: translateZ(0);
    }

    .incoming .text {
        margin-left: 10px;
        margin-top: 0;
        user-select: text;

        will-change: transform;
        transform: translateZ(0);
    }

    .outgoing {
        border-top-right-radius: 5px;
        border-top-left-radius: 18px;
        padding: 12px;
        background: var(--light-dark-background);
        width: 80%;
        margin-left: auto !important;
        margin-right: 0px !important;
        margin-top: 22px !important;

        /* GPU hint for bubble updates */
        will-change: transform, opacity, background;
        backface-visibility: hidden;
        transform: translateZ(0);
    }

    .outgoing .avatar {
        display: none;
    }

    .chat-list .message .icon {
        margin-left: 0;

        will-change: opacity, transform;
        transform: translateZ(0);
    }

    .chat-list .message .message-content {
        display: block;

        /* prepare for DOM insertions without repaint jank */
        will-change: transform, opacity;
        transform: translateZ(0);
    }

    .header :is(.title, .subtitle) {
        font-size: 2rem;
        line-height: 2.6rem;

        will-change: transform;
        transform: translateZ(0);
    }

    .header .subtitle {
        font-size: 1.7rem;

        will-change: transform;
        transform: translateZ(0);
    }

    .typing-area :where(.typing-form, .action-buttons) {
        gap: 0.4rem;

        /* smooth input-area compositing on mobile */
        will-change: transform;
        transform: translateZ(0);
    }

    /* New composer layout: textarea sits above the actions bar, so it needs
       normal padding (no room reserved for an absolutely-placed send button). */
    .typing-form .typing-input {
        padding: 12px 14px 0 14px;
        font-size: 16px; /* >=16px stops iOS auto-zoom on focus */

        /* promote to GPU for fast typing repainting */
        will-change: contents, transform;
        backface-visibility: hidden;
        transform: translateZ(0);
    }

    /* Actions bar: keep everything on one tidy row with breathing room and a
       proper 40px tap target for each control. */
    .input-actions {
        padding: 4px 6px 8px 6px;
        min-height: 48px;
        gap: 6px;
    }

    .input-tools-left {
        gap: 2px;
        min-width: 0;
        flex: 1;
    }

    .input-tools-left .tool-btn,
    .input-actions-right .action-btn {
        width: 40px;
        height: 40px;
    }

    .input-actions-right {
        gap: 6px;
        flex-shrink: 0;
    }

    /* The send button must never be absolutely positioned in the new layout */
    .typing-form #send-message-button {
        position: static;
        bottom: auto;
        right: auto;
        will-change: transform, opacity;
        transform: translateZ(0);
    }

    .icon {
        height: 50px;
        width: 50px;

        will-change: transform, opacity;
        transform: translateZ(0);
        backface-visibility: hidden;
    }

    .typing-area .disclaimer-text {
        font-size: 0.75rem;
        margin-top: 0.5rem;

        will-change: transform, opacity;
        transform: translateZ(0);
    }

    /* Ensure smooth native scrolling for mobile containers */
    .chat-list,
    .typing-area,
    .sources-window .content {
        -webkit-overflow-scrolling: touch;
    }
}

/* Medium widths: promote chat area to GPU layers */
@media screen and (max-width: 1000px) {
    .chat-list {
        width: 98%;

        will-change: transform, opacity;
        transform: translateZ(0);
    }

    .typing-area {
        width: 100%;
        margin-left: 0;

        will-change: transform;
        transform: translateZ(0);
    }

    .chat-container {
        width: 100%;
        margin-left: 0;

        will-change: transform;
        transform: translateZ(0);
    }
}

/* Adjust edit button offsets with GPU hints */
@media screen and (max-width: 1500px) {
    .edit-outgouing-button {
        left: 15%;

        will-change: transform;
        transform: translateZ(0);
    }
}

@media screen and (max-width: 1200px) {
    .edit-outgouing-button {
        left: 13%;

        will-change: transform;
        transform: translateZ(0);
    }
}

@media screen and (max-width: 750px) {
    .edit-outgouing-button {
        left: 12%;

        will-change: transform;
        transform: translateZ(0);
    }
}

@media screen and (max-width: 660px) {
    .edit-outgouing-button {
        left: 11%;

        will-change: transform;
        transform: translateZ(0);
    }
}

@media screen and (max-width: 440px) {
    .edit-outgouing-button {
        left: 9%;

        will-change: transform;
        transform: translateZ(0);
    }
}

@media screen and (max-width: 360px) {
    .edit-outgouing-button {
        left: 8%;

        will-change: transform;
        transform: translateZ(0);
    }
}



/* layout changes when nav is closed */
.chat-list {
    transition: width 0.25s ease-in-out;
    will-change: width;
}

.chat-list.closed_nav {
    width: 98%;
}

.typing-area {
    transition: width 0.25s ease-in-out, margin-left 0.25s ease-in-out;
    will-change: width, margin-left;
}

.typing-area.closed_nav {
    width: 100%;
    margin-left: 0;
}

.chat-container {
    transition: width 0.25s ease-in-out, margin-left 0.25s ease-in-out;
    will-change: width, margin-left;
}

.chat-container.closed_nav {
    width: 100%;
    margin-left: 0;
}

/* copy button: focus transitions only performant props */
.copy-btn {
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
    cursor: pointer;

    will-change: transform, opacity, background-color;
    transform: translateZ(0);
}

/* input image preview */
.imp-typing-area-imgpreview {
    border-radius: 20px !important;

    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* chat history scrolling */
.chats-history {
    height: 637px;
    overflow: auto !important;

    /* smoother scrolling on iOS */
    -webkit-overflow-scrolling: touch;

    will-change: scroll-position;
    transform: translateZ(0);
}

/* side account */
.side_account {
    position: absolute;
    bottom: 0;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    gap: 10px;
    width: 100%;
    background-color: var(--darker-background);
    border-radius: 20px 20px 0 0;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    /* only animate performant properties */
    transition: transform 0.12s ease-in-out, background-color 0.12s ease-in-out, box-shadow 0.12s ease-in-out, opacity 0.12s ease-in-out;
    will-change: transform, background-color, box-shadow, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.side_account:active {
    box-shadow:
        rgba(60, 64, 67, 0.3) 0px 1px 2px 0px,
        rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
    background-color: var(--light-dark-background);
}

/* =========================================
   1. BASE AVATAR (Free / Default)
   ========================================= */
.side_account img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    /* Basic border for free users (optional, or remove to keep plain) */
    border: 1px solid rgba(255, 255, 255, 0.1);

    will-change: transform, box-shadow;
    transform: translateZ(0);
    transition: all 0.3s ease;
}

/* =========================================
   2. SHARED ANIMATIONS
   ========================================= */

/* The "Breathing" Glow Animation */
@keyframes breathingGlow {
    0% {
        box-shadow: 0 0 5px var(--glow-inner), 0 0 10px var(--glow-outer);
        border-color: var(--border-light);
    }

    50% {
        box-shadow: 0 0 15px var(--glow-inner), 0 0 25px var(--glow-outer);
        border-color: var(--border-dim);
    }

    100% {
        box-shadow: 0 0 5px var(--glow-inner), 0 0 10px var(--glow-outer);
        border-color: var(--border-light);
    }
}

/* The "Liquid Metal" Text Shine */
@keyframes textShimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

/* =========================================
   3. PRO USERS (Silver / Platinum / Cyberpunk)
   ========================================= */
.side_account.pro {
    /* Define Silver/Blue Palette */
    --border-light: #ffffff;
    --border-dim: #b0bec5;
    --glow-inner: rgba(255, 255, 255, 0.5);
    --glow-outer: rgba(0, 229, 255, 0.4);
    /* Cyan glow */
}

.side_account.pro img {
    /* Double rim effect: Solid border + inset shadow */
    border: 2px solid #e0e0e0;
    animation: breathingGlow 3s ease-in-out infinite;
}

.side_account.pro p {
    /* Liquid Silver Text */
    background: linear-gradient(90deg,
            #9e9e9e 0%,
            #ffffff 50%,
            #9e9e9e 100%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    text-fill-color: transparent;
    -webkit-text-fill-color: transparent;
    color: transparent;
    /* Fallback */

    font-weight: 800;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    animation: textShimmer 3s linear infinite;
}

/* =========================================
   4. PREMIUM USERS (Gold / Luxury)
   ========================================= */
.side_account.premium {
    /* Define Gold/Warm Palette */
    --border-light: #FFD700;
    --border-dim: #DAA520;
    --glow-inner: rgba(255, 215, 0, 0.6);
    --glow-outer: rgba(255, 140, 0, 0.4);
    /* Orange/Gold glow */
}

.side_account.premium img {
    /* Double rim effect: Solid border + inset shadow */
    border: 2px solid #FFD700;
    animation: breathingGlow 3s ease-in-out infinite reverse;
    /* Reverse timing vs Pro */
}

.side_account.premium p {
    /* Liquid Gold Text */
    background: linear-gradient(90deg,
            #bf953f 0%,
            #ffffac 50%,
            #bf953f 100%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    text-fill-color: transparent;
    -webkit-text-fill-color: transparent;
    color: transparent;

    font-weight: 800;
    /* A stronger shadow for gold to make it read well */
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    animation: textShimmer 3s linear infinite;
}

/* =========================================
   5. BASE TEXT (Free / Layout Protection)
   ========================================= */
.side_account p {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    font-weight: 700;
    /* Ensure layout doesn't jump */
    will-change: transform;
    transform: translateZ(0);
}

/* account actions panel */
.account_actions {
    position: absolute;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    bottom: -100%;
    height: 300px;
    width: 100%;
    border-radius: 20px;
    background-color: var(--darker-background);
    user-select: none;
    opacity: 0;
    font-size: 14px;
    /* animate bottom + opacity using hardware-friendly properties */
    transition: bottom 0.28s cubic-bezier(.2, .9, .2, 1), opacity 0.28s ease;
    will-change: bottom, opacity, transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.account_actions.show {
    bottom: 64px;
    opacity: 1;
}

.account_actions.fade-out {
    bottom: -100%;
    opacity: 0;
}

/* profile actions */
.account_actions .profile-actions {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background-color: #cccccc4b;

    transition: background-color 0.12s ease, transform 0.12s ease;
    will-change: background-color, transform;
    transform: translateZ(0);
}

.account_actions .profile-actions span {
    font-weight: 800;

    transform: translateZ(0);
}

.account_actions .profile-actions:active {
    background-color: rgba(0, 0, 0, 0.1);
}

/* icon inside profile-actions */
.account_actions .profile-actions .icon {
    font-size: 16px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;

    transition: transform 0.12s ease, opacity 0.12s ease;
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* disabled state */
.account_actions .disabled {
    pointer-events: none;
    opacity: 0.5;

    will-change: opacity;
    transform: translateZ(0);
}

.account_actions .disabled:active {
    background-color: transparent !important;
}