:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --surface-3: #232328;
    --border: #2a2a2e;
    --border-light: #3a3a3e;
    --text: #e8e8ea;
    --text-secondary: #7a7a80;
    --text-muted: #55555a;
    --accent: #ff6b35;
    --accent-hover: #ff8555;
    --accent-dim: rgba(255, 107, 53, 0.15);
    --success: #34d399;
    --error: #f87171;
    --warning: #fbbf24;
    --tg-blue: #2aabee;
    --glass-bg: rgba(20, 20, 22, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(24px);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 200ms ease-out;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Glass */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
}

/* Navbar */
#navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

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

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    cursor: pointer;
    color: var(--text);
}

.balance-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--accent-dim);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.coin-icon { color: var(--accent); }
.coin-icon.big { font-size: 28px; }

.nav-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}

.nav-btn:hover { background: var(--surface-3); border-color: var(--border-light); }
.nav-btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-btn.accent:hover { background: var(--accent-hover); }

.avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-weight: 700;
    font-size: 14px;
    background: var(--surface-3);
}

.dropdown {
    position: absolute;
    top: 50px;
    right: 16px;
    min-width: 180px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
}

.dropdown-role {
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.dropdown-divider { border-top: 1px solid var(--border); }

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}

.dropdown-item:hover { background: var(--surface-3); }

/* Pages */
.page {
    flex: 1;
    overflow-y: auto;
}

/* Auth */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    border-radius: var(--radius);
    text-align: center;
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 4px 0;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.auth-btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.auth-btn.primary:hover { background: var(--accent-hover); transform: scale(0.98); }
.auth-btn:active { transform: scale(0.97); }

.auth-btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.auth-btn.secondary:hover { background: var(--surface-3); }
.auth-btn.small { padding: 8px 16px; font-size: 13px; }

.auth-btn.telegram {
    background: var(--tg-blue);
    color: #fff;
    border-color: var(--tg-blue);
}

.auth-btn.telegram:hover { filter: brightness(1.1); transform: scale(0.98); }

.auth-btn-icon { font-size: 20px; }

.auth-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.auth-input:focus { border-color: var(--accent); }

.auth-note {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Recovery key */
.recovery-card { text-align: center; }
.recovery-key-box {
    background: var(--surface-2);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin: 20px 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.08em;
    word-spacing: 0.3em;
    color: var(--accent);
    user-select: all;
}

/* Chat */
#page-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages:empty::before {
    content: 'Start a conversation...';
    color: var(--text-muted);
    text-align: center;
    margin: auto;
    font-size: 16px;
}

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
    word-wrap: break-word;
}

.msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-image {
    max-width: 300px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    cursor: pointer;
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

#chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-field {
    flex: 1;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.chat-input-field:focus { border-color: var(--accent); }

.input-action {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.input-action:hover { background: var(--surface-3); color: var(--text); }
.input-action:active { transform: scale(0.95); }

.send-btn {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.send-btn:hover { background: var(--accent-hover) !important; }

.gen-options {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.gen-select {
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.gen-cost {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
}

/* Gallery */
.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.gallery-header h2 { font-size: 20px; font-weight: 700; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 0 20px 20px;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
    cursor: pointer;
    transition: transform var(--transition);
    position: relative;
}

.gallery-item:hover { transform: scale(1.02); }

.gallery-item img, .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
}

.gallery-item-prompt {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    font-size: 12px;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Deposit */
.deposit-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    min-height: calc(100vh - 56px);
}

.deposit-card {
    width: 100%;
    max-width: 480px;
    padding: 32px;
    border-radius: var(--radius);
}

.deposit-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }

.balance-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 36px;
    font-weight: 700;
}

.balance-label { font-size: 16px; color: var(--text-secondary); font-weight: 400; }

.deposit-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.deposit-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.deposit-tab.active { background: var(--surface-3); color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.crypto-coins {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.crypto-coin-btn {
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.crypto-coin-btn.active, .crypto-coin-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.crypto-address-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.crypto-address-box p { color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }

.address-line {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    margin-bottom: 12px;
}

.address-line code {
    flex: 1;
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
}

.copy-btn {
    padding: 6px 12px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.copy-btn:hover { background: var(--accent-dim); color: var(--accent); }

.rate-info { font-size: 12px; color: var(--text-muted); }

.deposit-note { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; }

.card-amounts {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.amount-btn {
    padding: 12px 24px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.amount-btn:hover { border-color: var(--accent); color: var(--accent); }
.amount-btn:active { transform: scale(0.97); }

.rewards-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.reward-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.reward-item:hover { border-color: var(--accent); }
.reward-item:active { transform: scale(0.99); }

.reward-name { font-weight: 600; font-size: 14px; }
.reward-desc { font-size: 12px; color: var(--text-secondary); }
.reward-coins { color: var(--accent); font-weight: 700; font-size: 16px; }

.referral-section { border-top: 1px solid var(--border); padding-top: 20px; }
.referral-section h3 { font-size: 16px; margin-bottom: 6px; }
.referral-section p { color: var(--text-secondary); font-size: 13px; margin-bottom: 12px; }

.referral-link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.referral-link-box code {
    flex: 1;
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
}

/* Profile */
.profile-container {
    display: flex;
    justify-content: center;
    padding: 24px;
    min-height: calc(100vh - 56px);
}

.profile-card {
    width: 100%;
    max-width: 480px;
    padding: 32px;
    border-radius: var(--radius);
}

.profile-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.profile-label { color: var(--text-secondary); font-size: 14px; }
.profile-value { font-weight: 600; }

.profile-section { margin-top: 24px; }
.profile-section h3 { font-size: 16px; margin-bottom: 12px; }

/* Toast */
#toast-container {
    position: fixed;
    top: 72px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toast-in 300ms ease-out;
    max-width: 320px;
}

.toast-success { background: var(--success); color: #000; }
.toast-error { background: var(--error); color: #fff; }
.toast-info { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-content {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius);
    overflow: auto;
}

.modal-content img, .modal-content video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-sm);
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile */
@media (max-width: 640px) {
    #navbar { padding: 0 10px; }
    .logo { font-size: 16px; }
    .nav-btn { padding: 5px 10px; font-size: 12px; }
    .balance-pill { font-size: 12px; padding: 3px 8px; }

    .auth-card { padding: 24px 20px; }
    .auth-title { font-size: 22px; }

    .msg { max-width: 92%; }

    .deposit-card { padding: 20px; }
    .balance-display { font-size: 28px; }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        padding: 0 12px 12px;
    }

    .amount-btn { padding: 10px 18px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}