/* ============================================================
   ROOT & CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
    --bg-main:             #09090b;
    --bg-surface:          #141417;
    --bg-surface-elevated: #1c1c21;
    --bg-surface-high:     #232329;
    --border:              #2a2a32;
    --border-subtle:       #1e1e24;
    --text-main:           #f0f0f2;
    --text-muted:          #8b8b99;
    --text-faint:          #52525e;
    --heart:               #f43f5e;
    --mention-bg:          rgba(99, 102, 241, 0.18);
    --gold:                #fbbf24;
    --gold-dim:            rgba(251, 191, 36, 0.14);
    --success:             #10b981;
    --danger:              #ef4444;
    --radius-sm:           8px;
    --radius-md:           14px;
    --radius-lg:           20px;
    --radius-xl:           28px;
    --radius-pill:         999px;
    --shadow-sm:           0 2px 8px rgba(0,0,0,0.35);
    --shadow-md:           0 6px 24px rgba(0,0,0,0.5);
    --shadow-lg:           0 16px 48px rgba(0,0,0,0.65);
    --transition-fast:     0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring:   0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Gradient theme vars — overridden by JS */
    --user-gradient-from:  #6366f1;
    --user-gradient-to:    #a855f7;
    --user-gradient:       linear-gradient(135deg, #6366f1, #a855f7);
    --user-color:          #6366f1;
    --on-gradient-text:    #ffffff;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    background: #000;
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    justify-content: center;
    height: 100dvh;
    overflow: hidden;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-container {
    width: 100%;
    max-width: 640px;
    height: 100dvh;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    position: relative;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(0.9rem, env(safe-area-inset-top)) 1.25rem 0.9rem;
    background: rgba(9, 9, 11, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 10;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-titles {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.header-left h1 {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -0.6px;
    background: var(--user-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: background var(--transition-smooth);
}

.connection-label {
    font-size: 0.68rem;
    color: var(--text-faint);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Live indicator dot */
.live-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2), 0 0 10px rgba(16, 185, 129, 0.6);
    animation: livePulse 2.4s ease-in-out infinite;
}

.live-indicator.offline {
    background: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2), 0 0 8px rgba(239, 68, 68, 0.5);
    animation: none;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 2px rgba(16,185,129,0.2), 0 0 10px rgba(16,185,129,0.6); }
    50%       { opacity: 0.65; box-shadow: 0 0 0 4px rgba(16,185,129,0.1), 0 0 16px rgba(16,185,129,0.3); }
}

/* Wallet pill */
.wallet-pill {
    background: var(--gold-dim);
    border: 1px solid rgba(251, 191, 36, 0.25);
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    letter-spacing: 0.2px;
    transition: background var(--transition-fast), transform var(--transition-fast);
    cursor: default;
    user-select: none;
}

.wallet-pill:hover {
    background: rgba(251, 191, 36, 0.2);
    transform: scale(1.03);
}

/* Profile trigger & avatar */
.profile-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform var(--transition-spring);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-trigger:hover { transform: scale(1.08); }
.profile-trigger:active { transform: scale(0.94); }

#my-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: block;
    object-fit: cover;
    border: 2px solid transparent;
    background:
        var(--user-gradient) padding-box,
        var(--user-gradient) border-box;
    transition: box-shadow var(--transition-smooth);
}

#my-avatar:hover {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

/* ============================================================
   GLOW RING (Profile Glow store cosmetic)
   ============================================================ */
.glow-ring {
    position: relative;
    border-radius: 50%;
}

.glow-ring::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    background: var(--user-gradient);
    z-index: -1;
    filter: blur(8px);
    opacity: 0.75;
    animation: glowPulse 2.8s ease-in-out infinite;
}

.msg-avatar-wrapper.glow-ring::after {
    border-radius: 14px;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.45; filter: blur(6px); }
    50%       { opacity: 0.9;  filter: blur(11px); }
}

/* ============================================================
   PINNED BAR
   ============================================================ */
.pinned-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1.25rem;
    background: linear-gradient(to right, rgba(251,191,36,0.06), rgba(251,191,36,0.02));
    border-bottom: 1px solid rgba(251,191,36,0.15);
    font-size: 0.8rem;
    flex-shrink: 0;
    overflow: hidden;
    animation: slideDown 0.3s var(--transition-spring);
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.pin-icon { flex-shrink: 0; font-size: 0.9rem; }

.pin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.pin-sender {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pin-text {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.78rem;
}

.pin-jump {
    flex-shrink: 0;
    background: var(--gold-dim);
    color: var(--gold);
    border: 1px solid rgba(251,191,36,0.3);
    padding: 0.28rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.pin-jump:hover {
    background: rgba(251,191,36,0.2);
    transform: scale(1.04);
}

/* ============================================================
   CHAT STREAM
   ============================================================ */
.chat-stream {
    flex: 1;
    padding: 1rem 1.1rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    overscroll-behavior: contain;
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    color: var(--text-muted);
    padding: 2rem;
    animation: fadeIn 0.5s ease-out;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
    filter: grayscale(0.3);
}

.empty-state h2 {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.3px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-link {
    background: none;
    border: none;
    background: var(--user-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: opacity var(--transition-fast);
}

.btn-link:hover { opacity: 0.8; }

/* ============================================================
   MESSAGE WRAPPERS
   ============================================================ */
.msg-wrapper {
    display: flex;
    gap: 0.65rem;
    max-width: 85%;
    animation: msgSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.msg-wrapper.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-wrapper.grouped {
    margin-top: -0.45rem;
}

.msg-wrapper.grouped .msg-avatar-wrapper {
    visibility: hidden;
}

.msg-wrapper.grouped .msg-author {
    display: none;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes slideOut {
    from { opacity: 1; transform: scale(1); max-height: 200px; }
    to   { opacity: 0; transform: scale(0.96); max-height: 0; margin: 0; padding: 0; }
}

/* Avatar wrapper */
.msg-avatar-wrapper {
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition-spring);
    width: 34px;
    height: 34px;
    border-radius: 12px;
}

.msg-avatar-wrapper:hover { transform: scale(1.08); }
.msg-avatar-wrapper:active { transform: scale(0.95); }

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: var(--bg-surface);
    display: block;
    object-fit: cover;
}

/* Message content */
.msg-content {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    min-width: 0;
}

.msg-wrapper.me .msg-content {
    align-items: flex-end;
}

/* Author name */
.msg-author {
    font-size: 0.73rem;
    font-weight: 800;
    margin: 0 0.2rem 0.05rem;
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: -0.1px;
    cursor: pointer;
}

.author-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.name-badge {
    font-size: 0.8em;
    -webkit-text-fill-color: initial !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    color: initial !important;
    flex-shrink: 0;
}

.name-badge.hidden { display: none; }

/* Bubble */
.msg-bubble {
    background: var(--bg-surface);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 5px;
    font-size: 0.93rem;
    line-height: 1.5;
    position: relative;
    user-select: text;
    border: 1px solid var(--border);
    word-break: break-word;
    overflow-wrap: anywhere;
    color: var(--text-main);
    max-width: 100%;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.msg-wrapper.me .msg-bubble {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: 5px;
}

.msg-bubble:active {
    transform: scale(0.98);
}

/* Emoji-only bubbles */
.msg-bubble.emoji-bubble {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 0.1rem;
    font-size: 2.5rem;
    line-height: 1.15;
}

.msg-bubble.emoji-bubble.emoji-big {
    font-size: 4.2rem;
}

/* Mention highlight */
.mention {
    color: inherit;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 5px;
    border-radius: 5px;
}

.msg-bubble.mentioned-me {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5), 0 0 18px rgba(255,255,255,0.2), var(--shadow-sm);
}

/* Pinned flash */
.flash-highlight {
    animation: flashGlow 1.4s ease-out;
}

@keyframes flashGlow {
    0%   { box-shadow: 0 0 0 4px var(--gold), 0 0 24px rgba(251,191,36,0.4); }
    100% { box-shadow: none; }
}

/* Links */
.msg-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.88;
    word-break: break-all;
}

/* Meta row */
.msg-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 1px;
}

.msg-wrapper.me .msg-meta {
    flex-direction: row-reverse;
}

.msg-time {
    font-size: 0.66rem;
    color: var(--text-faint);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Like reaction badge */
.msg-reaction {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    padding: 3px 9px 3px 7px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.msg-wrapper.me .msg-reaction {
    cursor: default;
    pointer-events: none;
}

.msg-wrapper:not(.me) .msg-reaction:hover {
    transform: scale(1.1);
    border-color: var(--heart);
    background: rgba(244, 63, 94, 0.08);
}

.msg-reaction.liked {
    border-color: var(--heart);
    background: rgba(244, 63, 94, 0.12);
}

.heart-icon {
    color: var(--text-faint);
    transition: color var(--transition-fast);
    font-size: 0.85em;
    line-height: 1;
}

.msg-reaction.liked .heart-icon {
    color: var(--heart);
    animation: heartPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heartPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.6); }
    100% { transform: scale(1); }
}

/* Delete button */
.msg-delete {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-faint);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    opacity: 0;
    transform: scale(0.8);
}

.msg-wrapper:hover .msg-delete,
.msg-wrapper:focus-within .msg-delete {
    opacity: 1;
    transform: scale(1);
}

.msg-delete:hover {
    color: var(--heart);
    border-color: var(--heart);
    background: rgba(244, 63, 94, 0.1);
    transform: scale(1.12);
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.typing-indicator {
    padding: 0.45rem 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    animation: fadeIn 0.25s ease-out;
}

.dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.dot {
    width: 5px;
    height: 5px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ============================================================
   FOOTER / MESSAGE INPUT
   ============================================================ */
.app-footer {
    padding: 0.8rem 1rem;
    padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    z-index: 10;
    flex-shrink: 0;
}

#chat-form {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.3rem 0.3rem 1rem;
    border: 1px solid var(--border);
    gap: 0.4rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#chat-form:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.55rem 0;
    font-size: 0.93rem;
    min-width: 0;
    font-family: inherit;
}

#message-input::placeholder { color: var(--text-faint); }
#message-input:focus { outline: none; }

.cc-preview {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--gold);
    flex-shrink: 0;
    background: var(--gold-dim);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    animation: fadeIn 0.2s ease-out;
}

.char-counter {
    font-size: 0.67rem;
    color: var(--text-faint);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: center;
}

.char-counter.warn { color: var(--heart); }

/* Send button */
.btn-send {
    background: var(--user-gradient);
    color: var(--on-gradient-text);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-spring), opacity var(--transition-fast);
    box-shadow: 0 2px 10px rgba(99,102,241,0.35);
}

.btn-send:hover { transform: scale(1.07); }
.btn-send:active { transform: scale(0.92); }
.btn-send.sending { opacity: 0.6; pointer-events: none; }
.btn-send svg { width: 17px; height: 17px; transform: translateX(-1px); }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 100;
    padding: 0;
    animation: fadeIn 0.2s ease-out;
}

/* Sheet-style modal — slides up from bottom */
.modal-content {
    background: var(--bg-surface);
    width: 100%;
    max-width: 480px;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 1.5rem 1.5rem max(1.5rem, env(safe-area-inset-bottom));
    animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
}

/* On larger screens, center it like a card */
@media (min-height: 700px) and (min-width: 480px) {
    .modal {
        align-items: center;
        padding: 1rem;
    }
    .modal-content {
        border-radius: var(--radius-xl);
        border-bottom: 1px solid var(--border);
        animation: cardPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        max-height: 88dvh;
    }
}

@keyframes sheetUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes cardPop {
    from { transform: scale(0.94) translateY(12px); opacity: 0; }
    to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.modal-content.store-content { max-width: 520px; }
.modal-content.confirm-content { max-width: 360px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.4rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* Drag handle hint on mobile */
.modal-content::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: -0.5rem auto 1rem;
    opacity: 0.6;
}

@media (min-width: 480px) {
    .modal-content::before { display: none; }
}

.close-modal {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.close-modal:hover {
    color: var(--text-main);
    border-color: var(--user-gradient-from);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.text-center { text-align: center; align-items: center; }

/* ============================================================
   PROFILE MODALS
   ============================================================ */
.avatar-preview-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.large-avatar {
    width: 88px;
    height: 88px;
    border-radius: 26px;
    background: var(--bg-surface-elevated);
    object-fit: cover;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-spring);
}

.large-avatar:hover { transform: scale(1.04); }

.profile-pop {
    animation: avatarPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes avatarPop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.view-avatar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.view-name {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 0.4rem;
}

.view-status {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

.view-details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.view-detail {
    font-size: 0.85rem;
    color: var(--text-main);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.9rem;
    text-align: left;
    width: 100%;
}

/* CC row in view profile */
.view-cc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gold-dim);
    border: 1px solid rgba(251, 191, 36, 0.22);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    width: 100%;
}

.view-cc-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; }
.view-cc-amount { font-size: 1rem; font-weight: 900; color: var(--gold); }

/* ============================================================
   SETTINGS MODAL SPECIFICS
   ============================================================ */
.wallet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gold-dim);
    border: 1px solid rgba(251, 191, 36, 0.18);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
}

.wallet-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 700;
}

.wallet-amount {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--gold);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.78rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder { color: var(--text-faint); }

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="number"] { -moz-appearance: textfield; }

.hint-text {
    font-size: 0.76rem;
    color: var(--text-faint);
}

/* Toggle fields */
.toggle-field {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.toggle-field:focus-within {
    border-color: rgba(99, 102, 241, 0.35);
}

.toggle-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
}

.toggle-field-label-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-field-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

.toggle-field-header label {
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.toggle-field-input {
    border-top: 1px solid var(--border-subtle);
}

.toggle-field-input input {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0.7rem 1rem;
}

.toggle-field-input input:focus {
    box-shadow: none;
    border: none;
    outline: none;
}

.cosmetic-row .toggle-field-header { padding: 0.75rem 1rem; }

/* Switch (toggle) */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-main);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    transition: all var(--transition-smooth);
}

.switch-slider::before {
    position: absolute;
    content: '';
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-faint);
    border-radius: 50%;
    transition: all var(--transition-smooth);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.switch input:checked + .switch-slider {
    background: var(--user-gradient);
    border-color: transparent;
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
    background: #fff;
}

/* Theme picker */
.theme-section {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.theme-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theme-label-hint {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: none;
    letter-spacing: 0;
}

.theme-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.55rem;
}

.theme-swatch {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    border: 2.5px solid transparent;
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-spring), border-color var(--transition-fast), box-shadow var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.theme-swatch:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.theme-swatch:active { transform: scale(0.96); }

.theme-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 1px var(--bg-surface), 0 0 0 3px #fff, var(--shadow-md);
    transform: scale(1.06);
}

.theme-swatch.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.theme-swatch.locked:hover { transform: scale(1.0); }

.lock-icon,
.check-icon {
    font-size: 0.9rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.check-icon { color: #fff; font-weight: 900; font-size: 1rem; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }

/* Settings actions row */
.settings-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.settings-actions .btn-secondary { flex: 1; }
.settings-actions .btn-primary { flex: 2; }

/* Give CC modal */
.give-cc-icon {
    font-size: 3rem;
    margin-bottom: 0.25rem;
}

.give-cc-to {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.give-cc-to strong { color: var(--text-main); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    width: 100%;
    padding: 0.88rem;
    background: var(--user-gradient);
    color: var(--on-gradient-text);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 0.93rem;
    cursor: pointer;
    transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
    letter-spacing: -0.1px;
    box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99,102,241,0.45);
}

.btn-primary:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn-primary:disabled { opacity: 0.55; pointer-events: none; }
.btn-primary.hidden { display: none; }

.btn-secondary {
    width: 100%;
    padding: 0.85rem;
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.06);
    transform: translateY(-1px);
}

.btn-secondary:active { transform: translateY(0) scale(0.98); }
.btn-secondary:disabled { opacity: 0.5; pointer-events: none; }

/* Confirm dialog */
.confirm-body {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.25rem;
}

.confirm-body strong { color: var(--text-main); }

.confirm-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.confirm-actions .btn-secondary { flex: 1; }
.confirm-actions .btn-primary { flex: 1; }

/* ============================================================
   STORE
   ============================================================ */
.store-balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gold-dim);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
}

.store-balance-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}

.store-balance-amount {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--gold);
}

.store-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.25rem;
}

.store-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.9rem 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    cursor: default;
}

.store-item:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}

.store-item-top {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.6rem;
}

.store-item-icon-wrap {
    position: relative;
    flex-shrink: 0;
}

.store-item-icon {
    font-size: 1.6rem;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.store-theme-preview {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1.5px solid var(--bg-surface-elevated);
}

.store-item-info {
    flex: 1;
    min-width: 0;
}

.store-item-name {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.2px;
    margin-bottom: 0.2rem;
}

.store-item-badge-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.store-type-badge {
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
}

.store-type-toggle  { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }
.store-type-consumable { background: rgba(251,191,36,0.12); color: var(--gold); border: 1px solid rgba(251,191,36,0.2); }
.store-type-theme   { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

.store-item-action { flex-shrink: 0; }

.store-item-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 0.35rem;
}

.store-item-detail {
    font-size: 0.7rem;
    color: var(--text-faint);
    font-weight: 600;
    letter-spacing: 0.2px;
}

.btn-store-buy {
    background: var(--user-gradient);
    color: var(--on-gradient-text);
    border: none;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
    font-family: inherit;
}

.btn-store-buy:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99,102,241,0.4); }
.btn-store-buy:active { transform: scale(0.96); }

.buy-icon { font-style: normal; }

.owned-tag {
    font-size: 0.73rem;
    font-weight: 800;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 0.42rem 0.75rem;
    border-radius: var(--radius-md);
    white-space: nowrap;
}

.consumable-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.owned-count {
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--gold);
    background: var(--gold-dim);
    border: 1px solid rgba(251,191,36,0.2);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius-pill);
    font-size: 0.84rem;
    font-weight: 600;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    max-width: 88%;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(12px);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
.chat-stream::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 3px;
}

.chat-stream::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.chat-stream::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 400px) {
    .msg-wrapper { max-width: 90%; }
    .header-left h1 { font-size: 1.05rem; }
    .modal-content { padding: 1.2rem 1.1rem max(1.2rem, env(safe-area-inset-bottom)); }
    .theme-swatches { grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
    .wallet-pill { font-size: 0.68rem; padding: 0.3rem 0.6rem; }
    .cc-preview { display: none; }
    .store-item-desc { font-size: 0.75rem; }
}

@media (min-width: 600px) {
    .msg-wrapper { max-width: 78%; }
    .store-list { gap: 0.75rem; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    .msg-wrapper,
    .modal-content,
    .live-indicator,
    .heart-icon,
    .glow-ring::after,
    .btn-send,
    .theme-swatch,
    .store-item {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}