:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #ffffff;
    --text-muted: #a0a0a0;
    --primary: #6200ee;
    --success: #03dac6;
    --danger: #cf6679;
    --nav-bg: #1f1f1f;
    --code-bg: #000;
    --code-text: var(--success);
    --card-gradient: linear-gradient(145deg, var(--card-bg), #2a2a2a);
    --border-color: rgba(255,255,255,0.05);
}

[data-theme="light"] {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #111827;
    --text-muted: #6b7280;
    --primary: #6200ee;
    --success: #10b981;
    --danger: #ef4444;
    --nav-bg: #ffffff;
    --code-bg: #e5e7eb;
    --code-text: #059669;
    --border-color: #e5e7eb;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-color: #f3f4f6;
        --card-bg: #ffffff;
        --text-color: #111827;
        --text-muted: #6b7280;
        --primary: #6200ee;
        --success: #10b981;
        --danger: #ef4444;
        --nav-bg: #ffffff;
        --code-bg: #e5e7eb;
        --code-text: #059669;
        --card-gradient: linear-gradient(145deg, var(--card-bg), #f3f4f6);
        --border-color: #e5e7eb;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

.view {
    display: none;
    min-height: 100vh;
}
.view.active {
    display: flex;
    flex-direction: column;
}

/* Auth View */
.auth-container {
    margin: auto;
    width: 90%;
    max-width: 400px;
    padding: 2rem 0;
}
.logo {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary);
}
.tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-bg);
}
.tabs button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
}
.tabs button.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
input {
    background-color: var(--card-bg);
    border: 1px solid #333;
    color: var(--text-color);
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
}
input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: #fff;
    transition: opacity 0.2s;
}
.btn:active { opacity: 0.8; }
.btn.primary { background-color: var(--primary); }
.btn.success { background-color: var(--success); color: #000; }
.btn.secondary { 
    background-color: var(--card-bg); 
    color: var(--text-color); 
    border: 1px solid var(--border-color); 
}
.btn.secondary:hover {
    filter: brightness(0.95);
}
.btn.danger { background-color: var(--danger); }
.btn.full-width { width: 100%; }

.error-msg {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
}

/* App Header */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    width: 100%;
}
.header-wrapper {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(15px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    backdrop-filter: blur(10px);
}
.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    cursor: pointer;
    width: 100%;
    transition: color 0.2s, transform 0.2s;
}
.nav-btn.active {
    color: var(--primary);
    transform: scale(1.08);
}
.nav-btn i {
    font-size: 22px;
}

/* Main Content */
main {
    width: 100%;
    padding: 20px;
    padding-bottom: calc(110px + env(safe-area-inset-bottom)); /* Space for bottom nav */
}
.main-tab { display: none; }
.main-tab.active { display: block; }

.balance-card { 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    background-color: var(--card-bg); 
    border: 1px solid var(--border-color);
    padding: 25px 20px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 25px;
}
.balance-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}
#total-balance {
    font-size: 42px;
    font-weight: 800;
    margin: 15px 0;
    color: var(--text-color);
}
.balance-compare {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}
.success-text { color: var(--success); }
.danger-text { color: var(--danger); }

.actions {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}
.actions .action-btn {
    flex: 1;
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 0 0 auto;
}
.card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 0 0 auto;
    text-decoration: none;
    line-height: 1.2;
}
.card-action-btn:hover, .action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-1px);
}
.card-action-btn.success {
    background: rgba(3, 218, 198, 0.12);
    border-color: rgba(3, 218, 198, 0.35);
    color: var(--success);
}
.card-action-btn.success:hover {
    background: var(--success);
    color: #000;
}
[data-theme="light"] .card-action-btn, [data-theme="light"] .action-btn {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #111827;
}
[data-theme="light"] .card-action-btn:hover, [data-theme="light"] .action-btn:hover {
    background: var(--primary);
    color: #ffffff;
}
[data-theme="light"] .card-action-btn.success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.35);
    color: #059669;
}
[data-theme="light"] .card-action-btn.success:hover {
    background: #10b981;
    color: #ffffff;
}

.stats-grid {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}
.stat-card { box-shadow: 0 4px 15px rgba(0,0,0,0.2); transition: transform 0.2s;
    flex: 1;
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}
.stat-card span {
    color: var(--text-muted);
    font-size: 14px;
}

/* Transactions */
.transaction-list {
    list-style: none;
    margin-top: 15px;
}
.tx-item { box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    text-align: left;
}
.tx-info { text-align: left; }
.tx-info h4 { margin-bottom: 5px; text-align: left; }
.tx-info p { color: var(--text-muted); font-size: 12px; text-align: left; }
.tx-amount { font-weight: bold; font-size: 16px; }

/* Developer Tab */
.dev-card { box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-top: 15px;
}
.dev-card h4 { margin-bottom: 10px; }
.dev-card code {
    display: block;
    background-color: var(--code-bg);
    padding: 10px;
    border-radius: 8px;
    color: var(--code-text);
    font-family: monospace;
    word-break: break-all;
    margin-bottom: 10px;
}
.api-key-box {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.api-key-box code { margin-bottom: 0; flex: 1; }
.copy-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 15px;
    cursor: pointer;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
    background-color: var(--bg-color);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
}
.close {
    position: absolute;
    right: 20px;
    top: 20px;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}
.modal-content h2 { margin-bottom: 20px; }


.privacy-blur {
    filter: blur(8px);
    opacity: 0.8;
    user-select: none;
}


input[type="date"] {
    color-scheme: dark;
}
[data-theme="light"] input[type="date"] {
    color-scheme: light;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) input[type="date"] {
        color-scheme: light;
    }
}

/* Tutorial Center Styles */
.tutorial-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 20px;
    scrollbar-width: thin;
}
.tutorial-tabs::-webkit-scrollbar {
    height: 4px;
}
.tutorial-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.tutorial-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.tutorial-tab-btn:hover {
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.25);
}
.tutorial-tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(98, 0, 238, 0.3);
}
.tutorial-card {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    background-color: var(--card-bg);
    padding: 22px;
    border-radius: 14px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.tutorial-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}
.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.tutorial-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tutorial-badge.ios {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.tutorial-badge.android {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}
.tutorial-badge.general {
    background: rgba(98, 0, 238, 0.15);
    color: #b388ff;
}
.tutorial-badge.amber {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.tutorial-badge.cyan {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}
.step-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.step-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.45;
}
.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.step-content {
    flex: 1;
}
.copy-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--code-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px 0;
    gap: 10px;
}
.copy-box code {
    font-size: 0.8rem;
    word-break: break-all;
    color: var(--code-text);
    background: none;
    padding: 0;
    margin: 0;
    flex: 1;
}
.btn-copy {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-copy:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
[data-theme="light"] .tutorial-tab-btn {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #4b5563;
}
[data-theme="light"] .tutorial-tab-btn.active {
    background: var(--primary);
    color: #ffffff;
}
[data-theme="light"] .tutorial-card {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .step-number {
    background: #e5e7eb;
    color: #111827;
    border-color: #d1d5db;
}
[data-theme="light"] .copy-box {
    background: #f3f4f6;
    border-color: #e5e7eb;
}
[data-theme="light"] .btn-copy {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}
[data-theme="light"] .tutorial-badge.ios {
    background: #1f2937;
    color: #fff;
}

/* Stonkz Wrapped Banner */
.wrapped-banner {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(236, 72, 153, 0.16));
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 14px;
    padding: 14px 18px;
    margin: 15px 0 20px 0;
    display: none;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.12);
}
.wrapped-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.25);
    border-color: rgba(167, 139, 250, 0.6);
}

/* Stonkz Wrapped Modal */
.wrapped-modal-container {
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 15px;
    z-index: 10000;
}
.wrapped-modal-container.active {
    display: flex;
}
.wrapped-card {
    background: linear-gradient(160deg, #181028 0%, #0d1222 55%, #050b14 100%);
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 24px;
    width: 100%;
    max-width: 440px;
    min-height: 560px;
    position: relative;
    padding: 18px 18px 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 40px rgba(139, 92, 246, 0.25);
    overflow: hidden;
    user-select: none;
}

/* Stories Top Bar */
.wrapped-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 12px;
    position: relative;
    z-index: 30;
}
.wrapped-progress-container {
    flex: 1;
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    position: relative;
}
.wrapped-prog-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}
.wrapped-prog-fill {
    height: 100%;
    width: 0%;
    background: #a78bfa;
    transition: width 0.2s linear;
}
.wrapped-prog-segment.active .wrapped-prog-fill {
    width: 100%;
    background: #fff;
}
.wrapped-prog-segment.done .wrapped-prog-fill {
    width: 100%;
    background: #a78bfa;
}

.wrapped-close-btn {
    flex-shrink: 0;
    position: static;
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 35;
    transition: background 0.2s, transform 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.wrapped-close-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}
.wrapped-close-btn:active {
    transform: scale(0.9);
}

/* Tap Zones */
.wrapped-tap-left, .wrapped-tap-right {
    position: absolute;
    top: 55px;
    bottom: 65px;
    width: 35%;
    z-index: 5;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.wrapped-tap-left { left: 0; }
.wrapped-tap-right { right: 0; }

/* Slide Content */
.wrapped-slide-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 6;
    padding: 10px 10px;
    animation: fadeInSlide 0.35s ease;
}
@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Controls */
.wrapped-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.wrapped-ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.wrapped-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}
.wrapped-ctrl-btn.primary {
    background: #8b5cf6;
    border-color: #a78bfa;
}
.wrapped-ctrl-btn.primary:hover {
    background: #7c3aed;
}