:root {
    --bg: #0f0f0f;
    --bg-surface: #1a1a1a;
    --bg-elevated: #242424;
    --bg-hover: #2c2c2c;
    --accent: #a78bfa;
    --accent-dim: rgba(167,139,250,.10);
    --accent-strong: rgba(167,139,250,.22);
    --accent-glow: rgba(167,139,250,.35);
    --text: #f5f5f5;
    --text-2: #b0b0b0;
    --text-3: #737373;
    --border: #262626;
    --border-light: rgba(255,255,255,0.06);
    --danger: #ef4444;
    --success: #4ade80;
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;
    --user-bubble: #2d2b3d;
    --bot-bubble: #1e1e1e;
}

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

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #000; color: var(--text); height: 100%; overflow: hidden;
    -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}

/* ── Shell ──────────────────────────── */
.app-container {
    width: 100%; height: 100dvh; margin: 0 auto;
    background: var(--bg); position: relative; overflow: hidden;
    display: flex; flex-direction: column;
}
@media (min-width: 600px) {
    body { display: flex; justify-content: center; align-items: center; background: #050505; }
    .app-container {
        width: 400px; height: 92dvh; max-height: 850px;
        border-radius: 24px; border: 1px solid var(--border);
        box-shadow: 0 30px 80px rgba(0,0,0,.7);
    }
}

/* ── Screens ───────────────────────── */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.screen.active { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.tab-content { display: none; flex: 1; flex-direction: column; overflow-y: auto; padding-bottom: 72px; }
.tab-content.active { display: flex; }

/* ── Toast Notifications ────────────── */
.toast-container {
    position: fixed; top: 1.5rem; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: .5rem; z-index: 9999;
    pointer-events: none; width: 90%; max-width: 400px;
}
.toast {
    background: rgba(30, 30, 30, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-light); border-radius: var(--r-md);
    color: var(--text); padding: .8rem 1.2rem;
    font-size: .85rem; font-weight: 500; display: flex; align-items: center; gap: .6rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto; position: relative; overflow: hidden;
}
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-info { border-left: 3px solid var(--accent); }
.toast.hiding { animation: toastFadeOut 0.3s ease forwards; }

.toast-icon { flex-shrink: 0; font-size: 1rem; }
.toast-error .toast-icon { color: var(--danger); }
.toast-success .toast-icon { color: var(--success); }
.toast-info .toast-icon { color: var(--accent); }

@keyframes toastSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes toastFadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

/* ── AUTH ───────────────────────────── */
#auth-screen { justify-content: center; align-items: center; padding: 2rem; background: var(--bg); }
.auth-box { width: 100%; max-width: 320px; text-align: center; }
.logo { font-size: 2rem; font-weight: 700; color: var(--accent); margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: center; gap: .5rem; }
.auth-box h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: .25rem; }
.auth-subtitle { color: var(--text-2); margin-bottom: 1.8rem; font-size: .92rem; }

.input-group { margin-bottom: .9rem; text-align: left; }
.input-group label { display: block; margin-bottom: .35rem; color: var(--text-2); font-size: .82rem; font-weight: 500; }
.input-group input, .input-group textarea {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: .8rem 1rem; color: var(--text);
    font-size: .92rem; font-family: inherit; transition: border-color .15s;
}
.input-group input:focus, .input-group textarea:focus { outline: none; border-color: var(--accent); }
.input-group textarea { resize: vertical; line-height: 1.45; }

.btn {
    width: 100%; padding: .8rem; border-radius: var(--r-md); border: none;
    font-size: .92rem; font-weight: 600; cursor: pointer; transition: all .12s;
    display: flex; justify-content: center; align-items: center; gap: .4rem;
}
.btn:active { transform: scale(.97); }
.primary-btn { background: var(--accent); color: #000; margin-bottom: .7rem; }
.primary-btn:hover { filter: brightness(1.12); }
.danger-btn { background: transparent; color: var(--danger); border: 1px solid rgba(239,68,68,.35); }
.danger-btn:hover { background: rgba(239,68,68,.08); }

.error-msg { font-size: .82rem; margin-top: .6rem; min-height: 1rem; color: var(--danger); }
.auth-switch { margin-top: 1.2rem; font-size: .88rem; color: var(--text-2); }
.auth-switch span { color: var(--accent); font-weight: 500; cursor: pointer; }
.auth-switch span:hover { text-decoration: underline; }

/* ── HEADER ────────────────────────── */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.1rem; background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.logo-small {
    font-size: 1.45rem; font-weight: 800; letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--accent), #d8b4fe);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    display: flex; align-items: center; gap: .4rem;
}
.header-title { font-weight: 600; font-size: 1.15rem; letter-spacing: -0.02em; }

.icon-btn {
    background: transparent; border: none; color: var(--text-2);
    font-size: 1.1rem; cursor: pointer; padding: .5rem; border-radius: var(--r-full);
    display: flex; justify-content: center; align-items: center; transition: all .12s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }
.text-btn { background: transparent; border: none; color: var(--accent); font-weight: 600; font-size: .92rem; cursor: pointer; }

/* ── SEARCH & TAGS ─────────────────── */
.search-bar-container { padding: 0 1rem .5rem; }
.search-bar {
    display: flex; align-items: center; gap: .5rem;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--r-full); padding: .55rem 1rem;
}
.search-bar i { color: var(--text-3); font-size: .85rem; flex-shrink: 0; }
.search-bar input {
    flex: 1; background: transparent; border: none; color: var(--text); font-size: .88rem; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-3); }
.search-bar input:focus { outline: none; }

.tags-filter-container { padding: 0 1rem .8rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tags-scroll {
    display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tags-scroll::-webkit-scrollbar { display: none; }
.tag-pill {
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-2); font-size: .75rem; font-weight: 500;
    padding: .35rem .75rem; border-radius: var(--r-full); cursor: pointer;
    white-space: nowrap; transition: all .15s; flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.tag-pill:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.tag-pill.active { background: var(--accent-strong); border-color: var(--accent); color: var(--accent); box-shadow: 0 4px 10px rgba(167,139,250,0.15); }

/* Create Character Tags Select */
.create-tags-container {
    display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem;
}
.create-tags-container .tag-pill {
    padding: .3rem .6rem; font-size: .7rem;
}

/* ── EXPLORE HERO ──────────────────── */
.explore-hero {
    position: relative; padding: 1.2rem 1.2rem .6rem; overflow: hidden;
    flex-shrink: 0;
}
.hero-glow {
    position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
    width: 220px; height: 120px;
    background: radial-gradient(ellipse, var(--accent-glow), transparent 70%);
    filter: blur(40px); pointer-events: none; opacity: .7;
}
.hero-title {
    font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em;
    position: relative; z-index: 1;
    background: linear-gradient(135deg, #fff 30%, var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-subtitle {
    font-size: .82rem; color: var(--text-3); margin-top: .25rem;
    position: relative; z-index: 1;
}

/* ── HOME GRID ─────────────────────── */
.home-section-label {
    padding: .4rem 1.1rem .5rem; font-size: .78rem; font-weight: 600;
    color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
}

.characters-grid {
    padding: 0 .8rem 1rem;
    display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem;
    align-content: start;
}

.character-card {
    display: flex; flex-direction: column;
    background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
    transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1), border-color .2s, box-shadow .2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    position: relative;
}
.character-card:active { transform: scale(.97); }
.character-card:hover {
    border-color: var(--accent); transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(167, 139, 250, 0.12), 0 4px 10px rgba(0,0,0,0.3);
}
.character-card .card-img-wrapper {
    position: relative; width: 100%; aspect-ratio: 1; overflow: hidden;
}
.character-card .card-img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .3s ease;
}
.character-card:hover .card-img { transform: scale(1.05); }
.card-img-overlay {
    position: absolute; bottom: 0; left: 0; right: 0; height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    pointer-events: none;
}
.char-info { padding: .7rem .7rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.card-creator { font-size: .62rem; color: var(--accent); font-weight: 500; margin-bottom: .05rem; opacity: .8; }
.char-info h3 {
    font-size: .88rem; font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em;
}
.char-info p {
    color: var(--text-3); font-size: .72rem; margin-top: .1rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.35;
}
.char-tags {
    display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .25rem;
}
.char-tag {
    background: var(--accent-dim); color: var(--accent);
    font-size: .58rem; padding: .15rem .4rem; border-radius: var(--r-full); font-weight: 600;
    letter-spacing: .02em;
}

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 3rem 1rem; color: var(--text-3); text-align: center; gap: .5rem;
    grid-column: 1 / -1;
}
.empty-state i { font-size: 2rem; margin-bottom: .3rem; color: var(--text-2); opacity: .5; }

/* ── CHAT HISTORY ──────────────────── */
.chat-history-list { padding: .4rem 0; }
.chat-history-item {
    display: flex; align-items: center; gap: .9rem;
    padding: .8rem 1.1rem; cursor: pointer;
    transition: background .15s, transform .15s;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}
.chat-history-item:last-child { border-bottom: none; }
.chat-history-item:hover { background: var(--bg-surface); }
.chat-history-item:active { transform: scale(.98); }
.history-avatar-wrapper { position: relative; flex-shrink: 0; }
.history-avatar {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.history-online-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--success); border: 2px solid var(--bg);
}
.chat-history-info { flex: 1; min-width: 0; }
.chat-history-info h4 { font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-history-info p {
    font-size: .78rem; color: var(--text-3); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-top: .15rem;
}
.chat-history-time { font-size: .68rem; color: var(--text-3); flex-shrink: 0; }
.chat-history-chevron {
    color: var(--text-3); font-size: .7rem; flex-shrink: 0; opacity: .5;
    transition: opacity .12s;
}
.chat-history-item:hover .chat-history-chevron { opacity: 1; color: var(--accent); }

/* ── BOTTOM NAV ────────────────────── */
.bottom-nav {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 64px;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-light);
    display: flex; justify-content: space-around; align-items: center; z-index: 50;
}
.nav-item {
    background: transparent; border: none; color: var(--text-3);
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    font-size: 1.15rem; cursor: pointer; transition: color .15s, transform .15s; width: 52px;
    position: relative;
}
.nav-item span { font-size: .62rem; font-weight: 500; }
.nav-item.active { color: var(--accent); }
.nav-item:active { transform: scale(.9); }
.create-btn { color: var(--text); }
.create-icon-wrapper {
    width: 36px; height: 36px; border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), #9333ea); color: #fff;
    display: flex; justify-content: center; align-items: center; font-size: .95rem;
    box-shadow: 0 3px 12px var(--accent-glow);
    transition: transform .15s;
}
.create-btn:active .create-icon-wrapper { transform: scale(.9); }

/* ═══════════════════════════════════════
   CHAT SCREEN
   ═══════════════════════════════════════ */
.chat-header {
    display: flex; align-items: center; padding: .65rem .9rem;
    border-bottom: 1px solid var(--border-light); background: rgba(15, 15, 15, 0.75);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 10; gap: .25rem;
}
.chat-header-info { display: flex; align-items: center; gap: .7rem; flex: 1; margin-left: .25rem; }
.header-avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    border: 2px solid var(--accent-dim);
}
.chat-title { min-width: 0; display: flex; flex-direction: column; }
#chat-name { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status {
    font-size: .65rem; color: var(--success); font-weight: 500;
    display: flex; align-items: center; gap: .3rem;
}
.chat-status::before {
    content: ''; width: 5px; height: 5px; border-radius: 50%;
    background: var(--success); display: inline-block;
}
.chat-screen-bg {
    background: linear-gradient(180deg, #0a0a12 0%, var(--bg) 30%, var(--bg) 100%);
}

/* ── Chat Settings Screen ─────────── */
.cs-profile-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem; background: var(--bg-surface); border-radius: var(--r-lg);
    border: 1px solid var(--border-light); margin-bottom: 1.5rem;
}
.cs-avatar {
    width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--accent-dim);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.cs-profile-info h3 { font-size: 1rem; font-weight: 600; }
.cs-char-creator { font-size: .72rem; color: var(--accent); opacity: .8; }

.cs-setting-row {
    display: flex; flex-direction: column; gap: .4rem;
    padding: .8rem; background: var(--bg-surface); border-radius: var(--r-md);
    border: 1px solid var(--border-light); margin-bottom: .6rem;
}
.cs-setting-info { display: flex; flex-direction: column; gap: .05rem; }
.cs-setting-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.cs-setting-desc { font-size: .7rem; color: var(--text-3); }
.cs-range-wrap {
    display: flex; align-items: center; gap: .7rem; margin-top: .2rem;
}
.cs-range {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 5px; border-radius: 5px; background: var(--bg-elevated);
    outline: none;
}
.cs-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); cursor: pointer;
    box-shadow: 0 2px 8px rgba(167,139,250,0.4);
}
.cs-range-val {
    font-size: .88rem; font-weight: 700; color: var(--accent);
    min-width: 36px; text-align: center;
    background: var(--accent-dim); padding: .2rem .4rem;
    border-radius: var(--r-sm);
}

.cs-info-block {
    background: var(--bg-surface); border-radius: var(--r-md);
    border: 1px solid var(--border-light); padding: .7rem .9rem;
    margin-bottom: .6rem;
}
.cs-info-label {
    font-size: .72rem; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .03em; margin-bottom: .3rem; display: block;
}
.cs-info-text {
    font-size: .82rem; color: var(--text-2); line-height: 1.4;
    max-height: 120px; overflow-y: auto;
}

.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem .8rem;
    display: flex; flex-direction: column; gap: 1rem; scroll-behavior: smooth;
}

/* ── Message Bubbles ───────────────── */
.msg-row { display: flex; gap: .6rem; animation: msgIn .2s ease; margin-bottom: 0.2rem; }
.msg-row.user { flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-top: .15rem; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }

.msg-body { display: flex; flex-direction: column; max-width: 82%; gap: .15rem; }
.msg-row.user .msg-body { align-items: flex-end; }

.msg-sender { font-size: .7rem; color: var(--text-3); font-weight: 600; padding: 0 .25rem; letter-spacing: 0.01em; }

.msg-bubble {
    font-size: .95rem; line-height: 1.55; word-break: break-word;
    padding: .75rem 1rem; border-radius: var(--r-xl);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.msg-row.assistant .msg-bubble {
    background: var(--bg-elevated); border: 1px solid rgba(255,255,255,0.06);
    border-top-left-radius: 6px;
}
.msg-row.user .msg-bubble {
    background: linear-gradient(135deg, var(--accent), #7e22ce);
    color: #fff; border-top-right-radius: 6px; border: none;
}
.msg-row.user .msg-bubble * { color: #fff !important; }

/* ── Reroll ─────────────────────────── */
.reroll-bar { display: flex; padding-left: 42px; margin-top: -.25rem; }
.reroll-btn {
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-3); font-size: .75rem; font-weight: 500;
    padding: .35rem .7rem; border-radius: var(--r-full); cursor: pointer;
    display: flex; align-items: center; gap: .3rem; transition: all .15s; font-family: inherit;
}
.reroll-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-strong); box-shadow: 0 2px 8px rgba(167, 139, 250, 0.2); }
.reroll-btn i { font-size: .7rem; }

/* ── Input Area ────────────────────── */
.chat-input-area {
    padding: .6rem .8rem 1rem; background: var(--bg);
    display: flex; align-items: flex-end; gap: .5rem; z-index: 10;
}
.chat-input-area textarea {
    flex: 1; background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 24px; padding: .75rem 1.1rem; color: var(--text);
    resize: none; max-height: 120px; font-family: inherit; font-size: .95rem; line-height: 1.45;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15); transition: border-color .15s;
}
.chat-input-area textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
    background: linear-gradient(135deg, var(--accent), #9333ea); color: #fff; width: 42px; height: 42px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
    border: none; cursor: pointer; flex-shrink: 0; margin-bottom: 2px; font-size: 1rem;
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.4); transition: transform .15s, filter .15s;
}
.send-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.send-btn:active { transform: translateY(0); }

/* ── Markdown inside bubbles ───────── */
.msg-bubble p { margin: 0 0 .35rem; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; color: var(--text-2); }
.msg-bubble code {
    background: var(--bg-elevated); padding: .1rem .3rem;
    border-radius: 4px; font-size: .83em; font-family: 'Courier New', monospace;
}
.msg-bubble pre {
    background: var(--bg-elevated); padding: .5rem .7rem;
    border-radius: var(--r-sm); overflow-x: auto; margin: .35rem 0; font-size: .83rem;
}
.msg-bubble pre code { background: transparent; padding: 0; }
.msg-bubble blockquote {
    border-left: 3px solid var(--accent); padding-left: .6rem;
    color: var(--text-2); margin: .35rem 0; font-style: italic;
}
.msg-bubble ul, .msg-bubble ol { padding-left: 1.2rem; margin: .25rem 0; }
.msg-bubble li { margin-bottom: .15rem; }

/* ── Modal ─────────────────────────── */
.modal {
    position: absolute; inset: 0; background: var(--bg);
    display: none; flex-direction: column; z-index: 100;
    transform: translateY(100%); transition: transform .28s cubic-bezier(.16,1,.3,1);
}
.modal.active { display: flex; transform: translateY(0); }
.modal-content { width: 100%; height: 100%; display: flex; flex-direction: column; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .9rem 1rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.1rem; overflow-y: auto; flex: 1; }

.avatar-upload-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.5rem; }
.hidden-input { display: none; }
.avatar-preview {
    width: 85px; height: 85px; border-radius: 50%;
    background: var(--bg-elevated); border: 2px dashed var(--border);
    display: flex; justify-content: center; align-items: center;
    font-size: 1.3rem; color: var(--text-3); cursor: pointer;
    background-size: cover; background-position: center; margin-bottom: .5rem; transition: border-color .15s;
}
.avatar-preview:hover { border-color: var(--accent); }
.upload-text { font-size: .78rem; color: var(--text-3); }

/* ── Settings ──────────────────────── */
.settings-content { padding: .8rem 1.1rem 5rem; }
.settings-profile-card {
    display: flex; align-items: center; gap: .9rem;
    padding: .9rem; background: var(--bg-surface); border-radius: var(--r-lg);
    border: 1px solid var(--border); margin-bottom: 1.3rem;
}
.settings-avatar-icon {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-dim); color: var(--accent);
    display: flex; justify-content: center; align-items: center; font-size: 1.1rem; flex-shrink: 0;
    background-size: cover; background-position: center; transition: filter .15s;
}
.settings-avatar-icon:hover { filter: brightness(1.1); }
.settings-username { font-weight: 600; font-size: .95rem; }
.settings-joined { font-size: .75rem; color: var(--text-3); margin-top: .05rem; }

.setting-section { margin-bottom: 1.5rem; }
.setting-section h4 {
    font-size: .82rem; color: var(--text-2); font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: .65rem;
    display: flex; align-items: center; gap: .4rem;
}
.setting-group { margin-bottom: .8rem; }
.setting-desc { font-size: .78rem; color: var(--text-3); margin-bottom: .5rem; line-height: 1.4; }
.setting-desc code { background: var(--bg-elevated); padding: .08rem .3rem; border-radius: 3px; font-size: .75rem; }

.setting-group input, .setting-group textarea {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
    padding: .75rem .9rem; border-radius: var(--r-md); color: var(--text); font-size: .88rem;
    font-family: inherit; line-height: 1.4;
}
.setting-group input:focus, .setting-group textarea:focus { outline: none; border-color: var(--accent); }
.setting-group textarea { resize: vertical; }

/* ── Tutorial ──────────────────────── */
.tutorial-box {
    margin-top: 1.2rem; padding: .9rem 1rem;
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.tutorial-box h5 {
    font-size: .82rem; font-weight: 600; margin-bottom: .65rem;
    display: flex; align-items: center; gap: .35rem; color: var(--accent);
}
.tutorial-box ol { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.tutorial-box li { font-size: .78rem; color: var(--text-2); line-height: 1.4; }
.tutorial-box li b { color: var(--text); }
.tutorial-box a { color: var(--accent); text-decoration: none; }
.tutorial-box a:hover { text-decoration: underline; }
.tutorial-box code { background: var(--bg-elevated); padding: .08rem .25rem; border-radius: 3px; font-size: .74rem; }
.tutorial-note {
    margin-top: .6rem; font-size: .72rem; color: var(--text-3);
    line-height: 1.35; border-top: 1px solid var(--border); padding-top: .5rem;
}

/* ── Typing ────────────────────────── */
.typing-dots { display: flex; gap: 4px; align-items: center; height: 18px; padding: .2rem 0; }
.dot { width: 5px; height: 5px; background: var(--text-3); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -.32s; }
.dot:nth-child(2) { animation-delay: -.16s; }
@keyframes bounce { 0%,80%,100% { transform: scale(.5); opacity: .3; } 40% { transform: scale(1); opacity: 1; } }

/* ── Scrollbar ─────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
