:root {
  --bg: #0f1117; --bg2: #1a1d27; --bg3: #252833; --bg4: #2f3340;
  --text: #f0f0f5; --text2: #9ca3af; --accent: #f59e0b; --accent2: #d97706;
  --green: #22c55e; --red: #ef4444; --blue: #3b82f6; --purple: #a855f7;
  --radius: 16px; --nav-h: 72px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100dvh; padding-bottom: var(--nav-h); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; background: var(--bg3); color: var(--text); border: 2px solid var(--bg4); border-radius: 12px; padding: 14px 16px; font-size: 16px; width: 100%; max-width: 100%; min-width: 0; outline: none; transition: border-color .2s; -webkit-appearance: none; -moz-appearance: textfield; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes countUp { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
.fade-up { animation: fadeUp .5s ease both; }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* Page sections */
.page { display: none; padding: 24px 20px 32px; max-width: 480px; margin: 0 auto; }
.page.active { display: block; }
.page-title { font-size: 24px; font-weight: 800; margin-bottom: 20px; }

/* Onboarding */
#onboarding { display: none; position: fixed; inset: 0; z-index: 100; background: var(--bg); overflow-y: auto; }
#onboarding.active { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.onboard-step { display: none; width: 100%; max-width: 400px; text-align: center; overflow: hidden; }
.onboard-step .form-group { width: 100%; overflow: hidden; }
.onboard-step.active { display: block; animation: fadeUp .4s ease; }
.onboard-step h2 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.onboard-step p { color: var(--text2); margin-bottom: 24px; }
.onboard-step .emoji-big { font-size: 64px; margin-bottom: 16px; display: block; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 24px; }
.chip { padding: 10px 18px; border-radius: 50px; background: var(--bg3); border: 2px solid var(--bg4); font-size: 14px; font-weight: 600; transition: all .2s; }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #000; }

/* Primary button */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 32px; border-radius: 50px; background: var(--accent); color: #000; font-size: 16px; font-weight: 700; transition: all .2s; width: 100%; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; }
.btn-outline { background: transparent; border: 2px solid var(--accent); color: var(--accent); }
.btn-sm { padding: 10px 20px; font-size: 14px; }
.btn-danger { background: var(--red); }

/* Dashboard hero */
.hero { text-align: center; padding: 32px 0 24px; }
.hero .streak-label { font-size: 14px; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.hero .streak-num { font-size: 72px; font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--accent), #fbbf24); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero .streak-unit { font-size: 16px; color: var(--text2); margin-top: 4px; }
.hero .streak-detail { font-size: 20px; font-weight: 600; color: var(--text2); margin-top: 8px; letter-spacing: 1px; }

/* Stats grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border-radius: var(--radius); padding: 20px 16px; text-align: center; }
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; animation: countUp .4s ease; }
.stat-card .stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }

/* Quote card */
.quote-card { background: linear-gradient(135deg, var(--bg2), var(--bg3)); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; border-left: 4px solid var(--accent); }
.quote-card .quote-text { font-size: 16px; font-style: italic; line-height: 1.5; margin-bottom: 8px; }
.quote-card .quote-author { font-size: 13px; color: var(--accent); font-weight: 600; }

/* Cards */
.card { background: var(--bg2); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

/* Timeline */
.timeline { position: relative; padding-left: 32px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: var(--bg4); }
.tl-item { position: relative; margin-bottom: 24px; }
.tl-dot { position: absolute; left: -32px; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg4); border: 3px solid var(--bg); display: flex; align-items: center; justify-content: center; font-size: 10px; transition: all .3s; }
.tl-dot.achieved { background: var(--accent); box-shadow: 0 0 12px rgba(245,158,11,.4); }
.tl-item h4 { font-size: 15px; font-weight: 700; }
.tl-item p { font-size: 13px; color: var(--text2); margin-top: 2px; }
.tl-item .tl-time { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }

/* Craving log */
.craving-entry { background: var(--bg2); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; display: flex; gap: 12px; align-items: flex-start; }
.craving-entry .craving-icon { font-size: 24px; flex-shrink: 0; }
.craving-entry .craving-info { flex: 1; }
.craving-entry .craving-info h4 { font-size: 14px; font-weight: 700; }
.craving-entry .craving-info p { font-size: 12px; color: var(--text2); }
.craving-entry .badge { padding: 4px 10px; border-radius: 50px; font-size: 11px; font-weight: 700; }
.badge-resisted { background: rgba(34,197,94,.15); color: var(--green); }
.badge-gave-in { background: rgba(239,68,68,.15); color: var(--red); }

/* Intensity bar */
.intensity { display: flex; gap: 4px; margin: 8px 0; }
.intensity span { width: 24px; height: 6px; border-radius: 3px; background: var(--bg4); }
.intensity span.filled { background: var(--accent); }

/* Swap suggestions */
.swap-card { background: linear-gradient(135deg, rgba(245,158,11,.1), rgba(34,197,94,.1)); border: 1px solid rgba(245,158,11,.2); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.swap-card h4 { color: var(--accent); font-size: 14px; margin-bottom: 8px; }
.swap-card li { font-size: 13px; color: var(--text2); margin: 6px 0; padding-left: 4px; list-style: none; }
.swap-card li::before { content: '✅ '; }

/* Check-in */
.mood-grid { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.mood-btn { font-size: 28px; padding: 12px; border-radius: 12px; background: var(--bg3); border: 2px solid transparent; transition: all .2s; }
.mood-btn.selected { border-color: var(--accent); background: rgba(245,158,11,.15); transform: scale(1.1); }
.energy-slider { display: flex; gap: 8px; margin-bottom: 16px; }
.energy-dot { width: 44px; height: 44px; border-radius: 50%; background: var(--bg3); border: 2px solid transparent; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; transition: all .2s; }
.energy-dot.selected { border-color: var(--accent); background: rgba(245,158,11,.15); color: var(--accent); }
.clean-options { display: flex; gap: 8px; margin-bottom: 16px; }
.clean-opt { flex: 1; padding: 12px; border-radius: 12px; background: var(--bg3); text-align: center; font-size: 14px; font-weight: 600; border: 2px solid transparent; transition: all .2s; }
.clean-opt.selected { border-color: var(--accent); background: rgba(245,158,11,.15); }
.checkin-history .checkin-item { background: var(--bg2); border-radius: 12px; padding: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.checkin-history .checkin-item .date { font-size: 13px; color: var(--text2); }
.checkin-history .checkin-item .icons { font-size: 18px; }

/* Bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); background: var(--bg2); border-top: 1px solid var(--bg3); display: flex; justify-content: space-around; align-items: center; z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--text2); font-weight: 600; padding: 8px 12px; border-radius: 12px; transition: all .2s; text-transform: uppercase; letter-spacing: .5px; }
.nav-item.active { color: var(--accent); }
.nav-item .nav-icon { font-size: 22px; }

/* Form groups */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; justify-content: center; align-items: flex-end; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg2); border-radius: 24px 24px 0 0; padding: 32px 24px; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; animation: fadeUp .3s ease; }
.modal h3 { font-size: 20px; font-weight: 800; margin-bottom: 20px; text-align: center; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
