/* ============================================
   SOMA AI — Stylesheet (Direction 2)
   Dark starfield via CSS only · no JS particles
   No backdrop-filter on scrolling elements
   Mobile-first
   ============================================ */

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.soma-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #0b0d18;
    color: #e2e8f0;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* CSS-only starfield — radial dots, zero JS, zero animation */
.soma-body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 12% 14%, rgba(255,255,255,0.55) 0%, transparent 100%),
        radial-gradient(1px 1px at 35% 6%,  rgba(255,255,255,0.40) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 22%, rgba(255,255,255,0.50) 0%, transparent 100%),
        radial-gradient(1px 1px at 80% 8%,  rgba(255,255,255,0.35) 0%, transparent 100%),
        radial-gradient(1px 1px at 91% 18%, rgba(255,255,255,0.45) 0%, transparent 100%),
        radial-gradient(1px 1px at 22% 35%, rgba(255,255,255,0.30) 0%, transparent 100%),
        radial-gradient(1px 1px at 48% 42%, rgba(255,255,255,0.38) 0%, transparent 100%),
        radial-gradient(1px 1px at 73% 55%, rgba(255,255,255,0.28) 0%, transparent 100%),
        radial-gradient(1px 1px at 5%  68%, rgba(255,255,255,0.42) 0%, transparent 100%),
        radial-gradient(1px 1px at 88% 74%, rgba(255,255,255,0.32) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 82%, rgba(255,255,255,0.36) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 90%, rgba(255,255,255,0.25) 0%, transparent 100%),
        radial-gradient(1px 1px at 18% 95%, rgba(255,255,255,0.30) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 68% 88%, rgba(180,180,255,0.40) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 42% 72%, rgba(180,180,255,0.30) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

/* ── View management ──────────────────────────────────────────────────────── */
.soma-view { position: fixed; inset: 0; z-index: 1; }
.soma-hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════
   REGISTER / LOGIN VIEW
═══════════════════════════════════════════════════════════════════ */

.soma-register-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px 16px;
    position: relative;
    overflow: hidden;
}

/* Large ambient glow behind the card */
.soma-reg-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(109,40,217,0.45) 0%, rgba(14,165,233,0.18) 55%, transparent 80%);
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.soma-reg-card {
    position: relative;
    background: rgba(15, 17, 34, 0.88);
    border: 1px solid rgba(139,92,246,0.35);
    border-radius: 20px;
    padding: 36px 28px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px -12px rgba(99,102,241,0.35), 0 0 0 1px rgba(129,140,248,0.08) inset;
    text-align: center;
}

.soma-reg-icon {
    margin-bottom: 12px;
}
.soma-reg-icon img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 16px rgba(56, 189, 248, 0.45));
}

.soma-reg-title {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 6px;
    background: linear-gradient(120deg, #a78bfa 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.soma-reg-sub {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.soma-reg-free {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(251,191,36,0.12);
    border: 1px solid rgba(251,191,36,0.3);
    border-radius: 20px;
    padding: 3px 12px;
    margin: 12px 0 24px;
}

.soma-reg-form { display: flex; flex-direction: column; gap: 12px; }

.soma-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 12px;
    color: #e2e8f0;
    font-size: 15px;
    padding: 14px 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}
.soma-input::placeholder { color: #64748b; }
.soma-input:focus { border-color: rgba(139,92,246,0.7); }

.soma-btn-primary {
    background: linear-gradient(120deg, #7c3aed 0%, #0ea5e9 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    padding: 14px 20px;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s, transform 0.15s;
}
.soma-btn-primary:hover  { opacity: 0.9; transform: translateY(-1px); }
.soma-btn-primary:active { transform: translateY(0); }
.soma-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.soma-reg-note {
    margin-top: 14px;
    font-size: 12px;
    color: #475569;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════
   CHAT VIEW
═══════════════════════════════════════════════════════════════════ */

#somaChatView {
    display: flex;
    flex-direction: column;
    /* Sized to the *visible* viewport (set from JS via visualViewport) so the
       on-screen keyboard shrinks the app instead of scrolling the page. */
    top: 0;
    bottom: auto;
    height: var(--soma-vh, 100dvh);
    transform: translate3d(0, var(--soma-vt, 0px), 0);
}

/* ── Header ─────────────────────────────────────────────────── */
/* Absolute overlay so it floats over the messages and can slide in/out
   smoothly on scroll without reflowing the conversation underneath. */
.soma-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: linear-gradient(100deg, #4c1d95 0%, #1e3a5f 55%, #0c4a6e 100%);
    border-bottom: 1px solid rgba(139,92,246,0.3);
    box-shadow: 0 4px 20px -4px rgba(99,102,241,0.4);
    z-index: 20;
    transform: translate3d(0, 0, 0);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.soma-header.soma-header-hidden {
    transform: translate3d(0, -102%, 0);
    box-shadow: none;
}

.soma-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.soma-header-left > div {
    min-width: 0;
}
.soma-header-title,
.soma-header-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 400px) {
    .soma-header-sub { display: none; }
}

.soma-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #e2e8f0;
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.soma-back-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.5);
    transform: translateX(-2px);
}
.soma-back-btn:active {
    transform: scale(0.94);
}

.soma-header-icon {
    line-height: 1;
    display: flex;
    align-items: center;
}
.soma-header-icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
}

.soma-header-title {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.2px;
}

.soma-header-sub {
    font-size: 11px;
    color: #93c5fd;
    margin-top: 1px;
}

.soma-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.soma-newchat-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}
.soma-newchat-actions .soma-modal-cancel {
    flex: 1;
    margin-top: 0;
}
.soma-newchat-confirm {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    transition: filter 0.2s, transform 0.15s;
}
.soma-newchat-confirm:hover { filter: brightness(1.08); }
.soma-newchat-confirm:active { transform: scale(0.97); }

.soma-logout-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}
.soma-logout-actions .soma-modal-cancel {
    flex: 1;
    margin-top: 0;
}
.soma-logout-confirm {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    transition: filter 0.2s, transform 0.15s;
}
.soma-logout-confirm:hover { filter: brightness(1.08); }
.soma-logout-confirm:active { transform: scale(0.97); }

.soma-upload-btn { display: none; }

.soma-newchat-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    color: #e2e8f0;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.3);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.soma-history-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: #e2e8f0;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.3);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.soma-logout-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: #fecaca;
    cursor: pointer;
    background: rgba(127, 29, 29, 0.22);
    border: 1px solid rgba(248, 113, 113, 0.45);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.soma-history-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.55);
    transform: translateY(-1px);
}
.soma-logout-btn:hover {
    background: rgba(127, 29, 29, 0.34);
    border-color: rgba(248, 113, 113, 0.72);
    transform: translateY(-1px);
}
.soma-history-btn:active { transform: scale(0.94); }
.soma-newchat-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.55);
    transform: translateY(-1px);
}
.soma-newchat-btn:active { transform: scale(0.94); }
.soma-logout-btn:active { transform: scale(0.94); }

.soma-cvtu-link {
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.2px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.3);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.soma-cvtu-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.55);
    transform: translateY(-1px);
}
.soma-cvtu-link:active { transform: scale(0.94); }

/* ── Message counter ─────────────────────────────────────────── */
.soma-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(139,92,246,0.4);
    border-radius: 10px;
    padding: 5px 10px;
    min-width: 54px;
    transition: border-color 0.3s;
}
.soma-counter.low  { border-color: rgba(245,158,11,0.7); }
.soma-counter.empty { border-color: rgba(239,68,68,0.7); }

#somaCounterNum {
    font-size: 18px;
    font-weight: 800;
    color: #e2e8f0;
    line-height: 1;
    transition: color 0.3s;
}
.soma-counter.low  #somaCounterNum { color: #fbbf24; }
.soma-counter.empty #somaCounterNum { color: #f87171; }

.soma-counter-label {
    font-size: 9px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 2px;
}

/* Quick top-up button — always available, don't make them wait for 0 msgs */
.soma-admin-link {
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.2px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.3);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.soma-admin-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.55);
    transform: translateY(-1px);
}
.soma-admin-link:active { transform: scale(0.94); }

.soma-topup-quick-btn {
    height: 30px;
    padding: 0 12px;
    border-radius: 16px;
    border: 1px solid rgba(167,139,250,0.5);
    background: linear-gradient(135deg, #7c3aed, #0ea5e9);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 10px -2px rgba(124,58,237,0.6);
    transition: transform 0.15s, box-shadow 0.15s;
}
.soma-topup-quick-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px -2px rgba(124,58,237,0.8);
}

/* Logged-in mobile header fit: prevent overlap/collision */
@media (max-width: 560px) {
    .soma-header {
        padding: 10px 10px;
        padding-top: max(10px, env(safe-area-inset-top));
    }
    .soma-header-left {
        gap: 6px;
        flex: 1;
    }
    .soma-back-btn {
        width: 30px;
        height: 30px;
        font-size: 22px;
        border-radius: 9px;
    }
    .soma-header-icon img {
        width: 24px;
        height: 24px;
    }
    .soma-header-title {
        font-size: 14px;
    }
    .soma-header-right {
        gap: 5px;
        flex-shrink: 0;
    }
    .soma-upload-btn { display: none; }
    .soma-newchat-btn,
    .soma-history-btn,
    .soma-logout-btn {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }
    .soma-upload-btn svg {
        width: 14px;
        height: 14px;
    }
    .soma-newchat-btn { font-size: 18px; }
    .soma-history-btn svg { width: 18px; height: 18px; }
    .soma-logout-btn svg { width: 18px; height: 18px; }
    .soma-cvtu-link,
    .soma-admin-link {
        height: 26px;
        padding: 0 8px;
        font-size: 11px;
        border-radius: 8px;
    }
    .soma-counter {
        min-width: 42px;
        padding: 3px 6px;
        border-radius: 8px;
    }
    #somaCounterNum {
        font-size: 15px;
    }
    .soma-counter-label {
        font-size: 8px;
        letter-spacing: 0.2px;
    }
    .soma-topup-quick-btn {
        height: 28px;
        padding: 0 9px;
        font-size: 11px;
        border-radius: 14px;
        gap: 3px;
    }
}

@media (max-width: 420px) {
    .soma-header-sub {
        display: none;
    }
    .soma-counter-label {
        display: none;
    }
    .soma-counter {
        min-width: 30px;
        padding: 3px 6px;
    }
    #somaCounterNum {
        font-size: 14px;
    }
    .soma-topup-quick-btn {
        padding: 0 8px;
        font-size: 10.5px;
    }
}

/* ── Messages list ───────────────────────────────────────────── */
.soma-messages {
    flex: 1;
    overflow-y: auto;
    padding: calc(var(--soma-header-h, 64px) + 10px) 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* NO backdrop-filter here — it causes GPU stutter on cheap Android */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: padding-top 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Header collapse feels smoother when content top spacing collapses too. */
#somaChatView.soma-header-collapsed .soma-messages {
    padding-top: calc(env(safe-area-inset-top) + 10px);
}
/* Empty welcome state never scrolls — nothing to read yet. */
.soma-messages.soma-no-scroll { overflow-y: hidden; }
.soma-messages::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ── Centered welcome hero (empty state) ─────────────────────── */
.soma-welcome-hero {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    padding: 32px 24px;
    max-width: 400px;
    position: relative;
    animation: somaWelcomeIn 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}
.soma-welcome-star,
.soma-welcome-title,
.soma-welcome-sub { position: relative; z-index: 1; }
.soma-welcome-star {
    line-height: 1;
    filter: drop-shadow(0 0 24px rgba(139, 92, 246, 0.6));
    animation: somaWelcomeStar 3.4s ease-in-out infinite;
}
.soma-welcome-star img {
    width: 104px;
    height: 104px;
    object-fit: contain;
    display: block;
}
.soma-welcome-title {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 31px;
    font-weight: 800;
    letter-spacing: -0.4px;
    line-height: 1.12;
    background: linear-gradient(110deg, #f8fafc 0%, #c4b5fd 40%, #7dd3fc 60%, #f8fafc 100%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: somaWelcomeShimmer 5.5s ease-in-out infinite;
}
.soma-welcome-sub {
    font-size: 15px;
    color: #9aa8bd;
    line-height: 1.55;
    max-width: 300px;
}
.soma-welcome-caps {
    font-size: 12.5px;
    color: #93a4bd;
    line-height: 1.5;
    max-width: 320px;
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 12px;
    padding: 10px 15px;
}
.soma-welcome-caps strong { color: #c4b5fd; }
.soma-welcome-perks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-top: 2px;
}
.soma-perks-label {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #64748b;
    text-align: left;
    margin-bottom: 1px;
    padding-left: 2px;
}
.soma-perk {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #cbd5e1;
    background: linear-gradient(135deg, rgba(124,58,237,0.10) 0%, rgba(14,165,233,0.10) 100%);
    border: 1px solid rgba(139,92,246,0.22);
    border-radius: 11px;
    padding: 9px 13px;
    text-align: left;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.soma-perk-ico {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}
@keyframes somaWelcomeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
@keyframes somaWelcomeStar {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-6px) scale(1.06); }
}
@keyframes somaWelcomeShimmer {
    0%, 100% { background-position: 0% center; }
    50%      { background-position: 100% center; }
}
.soma-messages::-webkit-scrollbar-track { background: transparent; }
.soma-messages::-webkit-scrollbar-thumb { background: transparent; }

/* ── Message bubbles ─────────────────────────────────────────── */
.soma-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: somaMsgIn 0.2s ease-out;
}
@keyframes somaMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.soma-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.soma-msg-ai {
    align-self: flex-start;
}

.soma-bubble {
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.soma-msg-user .soma-bubble {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    color: #f1f5f9;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px -4px rgba(124,58,237,0.5);
}

.soma-msg-ai .soma-bubble {
    background: rgba(22, 26, 50, 0.92);
    color: #cbd5e1;
    border-bottom-left-radius: 4px;
    border-left: 2px solid rgba(56,189,248,0.5);
    box-shadow: 0 4px 16px -4px rgba(14,165,233,0.2);
}

/* Markdown rendered inside AI bubbles */
.soma-msg-ai .soma-bubble h1,
.soma-msg-ai .soma-bubble h2,
.soma-msg-ai .soma-bubble h3 { color: #e2e8f0; margin: 10px 0 4px; font-weight: 700; line-height: 1.3; }
.soma-msg-ai .soma-bubble h1 { font-size: 16px; }
.soma-msg-ai .soma-bubble h2 { font-size: 15px; }
.soma-msg-ai .soma-bubble h3 { font-size: 14px; }
.soma-msg-ai .soma-bubble p  { margin: 0 0 7px; }
.soma-msg-ai .soma-bubble p:last-child { margin-bottom: 0; }
.soma-msg-ai .soma-bubble ul,
.soma-msg-ai .soma-bubble ol { margin: 4px 0 8px 18px; padding: 0; }
.soma-msg-ai .soma-bubble li { margin-bottom: 3px; }
.soma-msg-ai .soma-bubble hr { border: none; border-top: 1px solid rgba(56,189,248,0.2); margin: 10px 0; }
.soma-msg-ai .soma-bubble strong { color: #f1f5f9; font-weight: 700; }
.soma-msg-ai .soma-bubble code { background: rgba(0,0,0,0.3); border-radius: 4px; padding: 1px 5px; font-size: 12px; font-family: monospace; }

.soma-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-top: 2px;
    overflow: hidden;
}
.soma-msg-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.soma-msg-ai .soma-msg-avatar {
    background: linear-gradient(135deg, #7c3aed, #0ea5e9);
    color: #fff;
}

/* Streaming cursor */
.soma-streaming .soma-bubble::after {
    content: '▋';
    display: inline-block;
    font-size: 13px;
    color: #38bdf8;
    animation: somaCursor 0.8s step-end infinite;
    margin-left: 2px;
}
/* While Soma is still thinking (waves indicator showing) hide the caret */
.soma-streaming .soma-bubble:has(.soma-typing)::after {
    content: none;
}
@keyframes somaCursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── "Thinking" wave indicator ───────────────────────────────── */
.soma-typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 12px;
    padding: 1px 0;
}
.soma-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c4b5fd 0%, #38bdf8 100%);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.55);
    animation: somaWave 1.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.soma-typing span:nth-child(2) { animation-delay: 0.2s; }
.soma-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes somaWave {
    0%, 100% { transform: scale(0.68) translateY(0);     opacity: 0.35; }
    40%      { transform: scale(1)    translateY(-3px);  opacity: 1; }
}

/* Image thumbnail inside user bubble */
/* ── Message actions (download buttons) ──────────────────────── */
.soma-msg-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.soma-dl-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(139,92,246,0.35);
    border-radius: 8px;
    color: #94a3b8;
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.soma-dl-btn:hover { background: rgba(139,92,246,0.2); color: #c4b5fd; }

.soma-export-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #7dd3fc;
    line-height: 1.4;
}

/* ── Input bar ───────────────────────────────────────────────── */
.soma-input-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: rgba(11, 13, 24, 0.95);
    border-top: 1px solid rgba(139,92,246,0.2);
    position: relative;
    z-index: 15;
}

.soma-attach-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(124,58,237,0.18);
    border: 1px solid rgba(124,58,237,0.4);
    color: #a78bfa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}
.soma-attach-btn:hover { background: rgba(124,58,237,0.3); }

/* ── + (upload) button in input bar ─────────────────────────── */
.soma-plus-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(124,58,237,0.18);
    border: 1px solid rgba(124,58,237,0.4);
    color: #a78bfa;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}
.soma-plus-btn:hover  { background: rgba(124,58,237,0.3); }
.soma-plus-btn:active { transform: scale(0.94); }

/* ── Microphone button in input bar ─────────────────────────── */
.soma-mic-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(124,58,237,0.18);
    border: 1px solid rgba(124,58,237,0.4);
    color: #a78bfa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.soma-mic-btn:hover  { background: rgba(124,58,237,0.3); }
.soma-mic-btn:active { transform: scale(0.94); }
/* Recording state — glows red */
.soma-mic-btn.soma-mic-btn--active {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.7);
    color: #f87171;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.25);
    animation: somaMicPulse 1.2s ease-in-out infinite;
}
@keyframes somaMicPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(239,68,68,0.25); }
    50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0.08); }
}

.soma-text-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Attachment preview chip */
.soma-attachment-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.soma-attach-chip {
    background: rgba(124,58,237,0.15);
    border: 1px solid rgba(124,58,237,0.35);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: #a78bfa;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 220px;
}
.soma-attach-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.soma-attach-chip button {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.soma-textarea {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(139,92,246,0.48);
    border-radius: 16px;
    color: #e2e8f0;
    font-size: 14.5px;
    line-height: 1.45;
    padding: 12px 16px;
    resize: none;
    outline: none;
    width: 100%;
    min-height: 46px;
    max-height: 120px;
    overflow-y: auto;
    box-shadow: 0 0 0 1px rgba(56,189,248,0.2), 0 0 16px rgba(56,189,248,0.14);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    font-family: inherit;
}
.soma-textarea::placeholder { color: #475569; }
.soma-textarea:focus {
    border-color: rgba(125,211,252,0.9);
    background: rgba(255,255,255,0.09);
    box-shadow: 0 0 0 1px rgba(125,211,252,0.45), 0 0 0 4px rgba(14,165,233,0.2), 0 0 24px rgba(56,189,248,0.2);
}

.soma-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, #7c3aed, #0ea5e9);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px -4px rgba(124,58,237,0.6);
    transition: opacity 0.15s, transform 0.15s;
}
.soma-send-btn:hover  { opacity: 0.9; transform: scale(1.05); }
.soma-send-btn:active { transform: scale(0.96); }
.soma-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════════════════════════════════
   PAYWALL + PHONE MODALS
═══════════════════════════════════════════════════════════════════ */

.soma-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 0 0 env(safe-area-inset-bottom);
}
@media (min-height: 600px) {
    .soma-modal-overlay { align-items: center; }
}

.soma-modal-card {
    background: #0f1122;
    border: 1px solid rgba(139,92,246,0.35);
    border-radius: 20px 20px 0 0;
    padding: 28px 22px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 -12px 60px -8px rgba(99,102,241,0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
@media (min-height: 600px) {
    .soma-modal-card { border-radius: 20px; }
}

.soma-modal-icon {
    text-align: center;
}
.soma-modal-icon img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 4px 16px rgba(124, 58, 237, 0.45));
}

.soma-modal-title {
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    color: #f1f5f9;
}

.soma-modal-desc {
    text-align: center;
    font-size: 14px;
    color: #94a3b8;
    line-height: 1.5;
}

.soma-modal-price {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    color: #f1f5f9;
}
.soma-modal-price span {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    margin-left: 4px;
}

/* Provider buttons */
.soma-providers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.soma-provider-btn {
    position: relative;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 600;
    padding: 13px 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.soma-provider-btn:hover:not(:disabled) { background: rgba(124,58,237,0.2); border-color: rgba(139,92,246,0.6); }

.soma-provider-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.soma-soon {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #374151;
    color: #9ca3af;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.soma-pay-status {
    font-size: 13px;
    text-align: center;
    border-radius: 8px;
    padding: 8px 12px;
    display: none;
}
.soma-pay-status.info    { display: block; background: rgba(14,165,233,0.1); color: #38bdf8; }
.soma-pay-status.success { display: block; background: rgba(5,150,105,0.1);  color: #34d399; }
.soma-pay-status.error   { display: block; background: rgba(239,68,68,0.1);  color: #f87171; }

.soma-modal-cancel {
    background: none;
    border: none;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    transition: color 0.15s;
}
.soma-modal-cancel:hover { color: #94a3b8; }

/* ══════════════════════════════════════════════════════════════════
   ADMIN VIEW — Redesigned
═══════════════════════════════════════════════════════════════════ */

.soma-admin-wrap {
    height: 100%;
    overflow-y: auto;
    padding: 0 0 40px;
    padding-top: env(safe-area-inset-top);
}

.soma-admin-login {
    max-width: 360px;
    margin: 60px auto 0;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

/* Top bar */
.soma-admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 14px;
    background: linear-gradient(100deg, #1e1b4b 0%, #0c1a2e 100%);
    border-bottom: 1px solid rgba(139,92,246,0.25);
    position: sticky;
    top: 0;
    z-index: 20;
}
.soma-admin-brand { display: flex; align-items: center; gap: 10px; }
.soma-admin-brand-icon {
    display: flex;
    align-items: center;
}
.soma-admin-brand-icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
}
.soma-admin-brand-title { font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; font-weight: 700; color: #f1f5f9; letter-spacing: 0.2px; }
.soma-admin-brand-sub   { font-size: 10px; color: #64748b; }

.soma-admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.soma-admin-nav-btn {
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    background: rgba(255,255,255,0.05);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.soma-admin-nav-btn:hover { background: rgba(255,255,255,0.1); color: #e2e8f0; }
.soma-admin-nav-btn--soma {
    background: linear-gradient(120deg, rgba(91,33,182,0.35) 0%, rgba(3,105,161,0.3) 100%);
    border-color: rgba(139,92,246,0.4);
    color: #c4b5fd;
}
.soma-admin-nav-btn--soma:hover { background: linear-gradient(120deg, rgba(109,40,217,0.5) 0%, rgba(3,105,161,0.45) 100%); color: #fff; }

.soma-admin-refresh {
    background: rgba(139,92,246,0.15);
    border: 1px solid rgba(139,92,246,0.35);
    border-radius: 8px;
    color: #a78bfa;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.soma-admin-refresh:hover { background: rgba(139,92,246,0.3); }

/* Tab nav */
.soma-admin-tabs {
    display: flex;
    gap: 0;
    padding: 12px 16px 0;
    border-bottom: 1px solid rgba(139,92,246,0.15);
    background: rgba(11,13,24,0.6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.soma-admin-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.soma-admin-tab:hover    { color: #a78bfa; }
.soma-admin-tab.active   { color: #c4b5fd; border-bottom-color: #7c3aed; }

/* Tab content padding */
#somaAdminTab_users,
#somaAdminTab_payments,
#somaAdminTab_topup { padding: 18px 16px; }

/* Stats grid */
.soma-admin-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
@media (min-width: 480px) { .soma-admin-stats { grid-template-columns: repeat(3, 1fr); } }

.soma-stat-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 12px;
    padding: 14px 12px;
    transition: border-color 0.2s;
}
.soma-stat-card:hover { border-color: rgba(139,92,246,0.4); }
.soma-stat-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: #64748b; margin-bottom: 6px;
}
.soma-stat-value { font-size: 26px; font-weight: 800; color: #f1f5f9; }
.soma-stat-value.purple { color: #a78bfa; }
.soma-stat-value.cyan   { color: #38bdf8; }
.soma-stat-value.green  { color: #34d399; }
.soma-stat-value.amber  { color: #fbbf24; }

/* Cards */
.soma-admin-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(139,92,246,0.15);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
}
.soma-admin-card-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: #94a3b8;
    padding-bottom: 10px; margin-bottom: 14px;
    border-bottom: 1px solid rgba(139,92,246,0.12);
}
.soma-admin-card-desc { font-size: 13px; color: #64748b; margin-bottom: 14px; line-height: 1.5; }

/* Recent users list */
.soma-admin-recent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    gap: 10px;
}
.soma-admin-recent-row:last-child { border-bottom: none; }
.soma-admin-recent-name { font-size: 13.5px; font-weight: 600; color: #e2e8f0; }
.soma-admin-recent-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Phone links */
.soma-admin-phone-link {
    color: #38bdf8; text-decoration: none; font-weight: 600; font-size: 12.5px;
    transition: color 0.15s;
}
.soma-admin-phone-link:hover { color: #7dd3fc; }

/* Balance chips */
.soma-bal-chip {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
}
.soma-bal-chip.green { background: rgba(5,150,105,0.15); color: #34d399; }
.soma-bal-chip.amber { background: rgba(245,158,11,0.15); color: #fbbf24; }
.soma-bal-chip.red   { background: rgba(239,68,68,0.12);  color: #f87171; }
.soma-used-chip {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
    background: rgba(56,189,248,0.12); color: #7dd3fc;
    margin-right: 6px;
}

/* Search */
.soma-admin-search-wrap { margin-bottom: 14px; }
.soma-admin-search {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 14px;
    padding: 11px 14px;
    outline: none;
    transition: border-color 0.2s;
}
.soma-admin-search::placeholder { color: #475569; }
.soma-admin-search:focus { border-color: rgba(139,92,246,0.65); }

/* Table */
.soma-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.soma-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 380px;
}
.soma-admin-table thead { position: sticky; top: 0; }
.soma-admin-table th {
    text-align: left; padding: 8px 10px;
    color: #64748b; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.4px;
    background: rgba(15,17,34,0.95);
    border-bottom: 1px solid rgba(139,92,246,0.2);
    white-space: nowrap;
}
.soma-admin-table td {
    padding: 10px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #cbd5e1; white-space: nowrap;
}
.soma-admin-table tbody tr:hover td { background: rgba(139,92,246,0.06); }
.soma-td-name   { font-weight: 600; color: #e2e8f0 !important; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.soma-td-amount { font-weight: 700; color: #34d399 !important; }
.soma-td-ref    { color: #475569 !important; font-size: 11px; font-family: monospace; }
.soma-td-date   { color: #64748b !important; font-size: 12px; }

.soma-admin-del-btn {
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.soma-admin-del-btn:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.7);
}

/* Top-up form */
.soma-topup-form {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px;
}
.soma-topup-form .soma-input { flex: 1; min-width: 160px; }
.soma-topup-num { max-width: 130px !important; }
.soma-topup-preview {
    font-size: 13px; color: #a78bfa; font-weight: 600; min-height: 20px;
}

/* Loading / empty states */
.soma-admin-loading { color: #475569; font-size: 13px; padding: 12px 0; }
.soma-admin-empty   { color: #475569; font-size: 13px; padding: 16px 0; text-align: center; }

/* ── Toast container (reused from CvTu) ──────────────────────── */
#somaToastContainer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: min(92vw, 400px);
}

/* ── Spinner overlay ─────────────────────────────────────────── */
.soma-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: somaSpinAnim 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes somaSpinAnim { to { transform: rotate(360deg); } }

/* ── Floating Soma badge (on CvTu pages) — defined here for the main page ── */
.soma-floating-badge {
    position: fixed;
    bottom: 88px;
    right: 16px;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
    text-decoration: none;
    filter: drop-shadow(0 4px 16px rgba(124,58,237,0.55));
    transition: transform 0.2s;
}
.soma-floating-badge:hover { transform: scale(1.04); }

.soma-floating-badge-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(120deg, #5b21b6 0%, #0369a1 100%);
    border: 1px solid rgba(167,139,250,0.5);
    border-radius: 24px;
    padding: 10px 14px 10px 10px;
    box-shadow: 0 2px 0 rgba(255,255,255,0.08) inset;
}

.soma-floating-icon {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.soma-floating-text-wrap { display: flex; flex-direction: column; line-height: 1.2; }
.soma-floating-title    { font-size: 12px; font-weight: 800; color: #fff; }
.soma-floating-subtitle { font-size: 10px; color: #bae6fd; }

/* ══════════════════════════════════════════════════════════════════
   HISTORY DRAWER
═══════════════════════════════════════════════════════════════════ */

.soma-history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 40;
    transition: opacity 0.25s ease;
}
.soma-history-backdrop.soma-hidden { display: none; }

.soma-history-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(320px, 88vw);
    background: #0d0f20;
    border-right: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 4px 0 32px rgba(99, 102, 241, 0.3);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    padding-top: env(safe-area-inset-top);
}
.soma-history-drawer--closed {
    transform: translateX(-100%);
}

.soma-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    flex-shrink: 0;
}
.soma-history-title {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
}
.soma-history-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.soma-history-close:hover { color: #e2e8f0; background: rgba(255,255,255,0.06); }

.soma-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: none;
}
.soma-history-list::-webkit-scrollbar { display: none; }

.soma-history-empty {
    color: #475569;
    font-size: 13px;
    text-align: center;
    padding: 32px 16px;
}

.soma-history-session {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}
.soma-history-session:hover { background: rgba(139, 92, 246, 0.1); }
.soma-history-session:active { background: rgba(139, 92, 246, 0.18); }
.soma-history-session-date {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7c3aed;
}
.soma-history-session-preview {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.soma-history-session-meta {
    font-size: 11px;
    color: #475569;
    margin-top: 1px;
}

/* Mobile: history button sizing in cramped header */
@media (max-width: 560px) {
    .soma-history-btn,
    .soma-logout-btn {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }
    .soma-history-btn svg,
    .soma-logout-btn svg {
        width: 18px;
        height: 18px;
    }
}
