/* ================================================
   HabitTracker — Main Stylesheet
   Dark mode first, glassmorphism, Inter font
   ================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Colors */
  --bg-primary:       #0f0f1a;
  --bg-secondary:     #1a1a2e;
  --bg-surface:       #16213e;
  --bg-card:          rgba(255, 255, 255, 0.05);
  --bg-card-hover:    rgba(255, 255, 255, 0.09);
  --border-color:     rgba(255, 255, 255, 0.08);
  --border-accent:    rgba(99, 102, 241, 0.4);

  --primary:          #6366f1;
  --primary-dark:     #4f46e5;
  --primary-light:    #818cf8;
  --primary-glow:     rgba(99, 102, 241, 0.35);
  --secondary:        #8b5cf6;
  --accent:           #ec4899;
  --success:          #10b981;
  --success-glow:     rgba(16, 185, 129, 0.3);
  --warning:          #f59e0b;
  --danger:           #ef4444;
  --danger-glow:      rgba(239, 68, 68, 0.3);

  --text-primary:     #e2e8f0;
  --text-secondary:   #94a3b8;
  --text-muted:       #64748b;

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 40px;

  /* Radius */
  --r-sm:  8px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  /* Shadow */
  --shadow-sm:  0 2px 8px rgba(0,0,0,.35);
  --shadow-md:  0 8px 24px rgba(0,0,0,.45);
  --shadow-lg:  0 20px 48px rgba(0,0,0,.55);
  --glow:       0 0 24px var(--primary-glow);

  /* Transitions */
  --t-fast: 150ms ease;
  --t-med:  250ms ease;
  --t-slow: 400ms cubic-bezier(.34,1.56,.64,1);

  /* Layout */
  --navbar-h: 64px;
  --container-max: 1200px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a  { color: var(--primary-light); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* ================================================
   UTILITIES
   ================================================ */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.flex-1 { flex: 1; }

/* ================================================
   NAVBAR
   ================================================ */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--navbar-h);
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: box-shadow var(--t-med);
}
.navbar.scrolled { box-shadow: 0 4px 24px rgba(0,0,0,.5); }

.nav-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--sp-lg);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
}

.nav-logo {
  display: flex; align-items: center; gap: var(--sp-sm);
  color: var(--text-primary); text-decoration: none;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.4rem; animation: flicker 3s ease-in-out infinite; }
.logo-text  { background: linear-gradient(135deg, var(--primary-light), var(--accent));
               -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.nav-links {
  display: flex; align-items: center; gap: var(--sp-xs);
  margin-left: auto;
}

.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: .875rem; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}
.nav-link:hover, .nav-link.active {
  background: rgba(99,102,241,.15);
  color: var(--text-primary);
}
.nav-link.active { color: var(--primary-light); }
.nav-icon { font-size: 1rem; }

.nav-right {
  display: flex; align-items: center; gap: var(--sp-sm); margin-left: var(--sp-sm);
}

.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.btn-logout:hover { color: var(--danger); background: var(--danger-glow); }

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 36px; height: 36px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text-primary); border-radius: 2px;
  transition: transform var(--t-med), opacity var(--t-med);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 99; backdrop-filter: blur(4px);
}
.nav-overlay.show { display: block; }

/* Mobile nav */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .nav-links {
    position: fixed; top: var(--navbar-h); right: 0;
    width: min(280px, 80vw);
    height: calc(100vh - var(--navbar-h));
    flex-direction: column; align-items: stretch;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: var(--sp-md);
    transform: translateX(100%);
    transition: transform var(--t-slow);
    z-index: 100; gap: var(--sp-xs);
  }
  .nav-links.open { transform: translateX(0); }
}

/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all var(--t-med);
  white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}
.btn:hover::after { background: rgba(255,255,255,.08); }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--primary-glow); color: #fff; transform: translateY(-1px); }

.btn-ghost {
  background: rgba(255,255,255,.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); color: var(--text-primary); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c53030);
  color: #fff; box-shadow: 0 4px 16px var(--danger-glow);
}
.btn-done {
  background: rgba(16,185,129,.15);
  color: var(--success); border: 1px solid rgba(16,185,129,.3);
  cursor: default;
}

.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-icon { font-size: 1rem; }

/* Icon buttons */
.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 4px 8px;
  border-radius: var(--r-sm);
  opacity: .5; transition: opacity var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* ================================================
   FORMS
   ================================================ */
.form-group {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: var(--sp-md);
}
.form-group label {
  font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  letter-spacing: .04em; text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: .95rem;
  padding: 11px 14px; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
input::placeholder { color: var(--text-muted); }
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="color"].color-picker {
  height: 44px; padding: 4px;
  cursor: pointer;
}

.input-wrap { position: relative; }
.input-wrap input { padding-right: 42px; }
.eye-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; opacity: .5;
  transition: opacity var(--t-fast);
}
.eye-toggle:hover { opacity: 1; }

.form-error {
  font-size: .8rem; color: var(--danger);
  display: flex; align-items: center; gap: 4px;
}

.form-row { display: flex; gap: var(--sp-md); }

/* Checkbox */
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: .875rem; color: var(--text-secondary);
}
.checkbox-label input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* Radio */
.lang-radio-group { display: flex; gap: var(--sp-sm); flex-wrap: wrap; }
.radio-label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border-color);
  cursor: pointer; font-size: .9rem; font-weight: 500;
  transition: all var(--t-fast); flex: 1;
  justify-content: center;
}
.radio-label input[type="radio"] { display: none; }
.radio-label:hover { border-color: var(--primary); background: rgba(99,102,241,.1); }
.radio-label.checked { border-color: var(--primary); background: rgba(99,102,241,.15); color: var(--primary-light); }

/* Alert */
.alert {
  padding: 12px 16px; border-radius: var(--r-sm); font-size: .9rem; margin-bottom: var(--sp-md);
}
.alert-error   { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }

/* ================================================
   AUTH PAGE
   ================================================ */
.auth-page { background: var(--bg-primary); }

.auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-lg);
  position: relative; overflow: hidden;
}

/* Animated blobs */
.blob {
  position: fixed; border-radius: 50%;
  filter: blur(80px); opacity: .12;
  pointer-events: none; animation: blobFloat 8s ease-in-out infinite;
}
.blob-1 { width: 600px; height: 600px; background: var(--primary);    top: -200px; left: -200px; animation-delay: 0s; }
.blob-2 { width: 500px; height: 500px; background: var(--secondary);  bottom: -100px; right: -100px; animation-delay: -3s; }
.blob-3 { width: 400px; height: 400px; background: var(--accent);     top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -6s; }

@keyframes blobFloat {
  0%, 100% { transform: scale(1) translate(0,0); }
  33%       { transform: scale(1.05) translate(20px, -15px); }
  66%       { transform: scale(.95) translate(-10px, 20px); }
}

.auth-card {
  width: 100%; max-width: 460px;
  padding: var(--sp-xl) var(--sp-xl);
  position: relative; z-index: 1;
  border: 1px solid rgba(99,102,241,.2);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.05);
}

.auth-logo { text-align: center; margin-bottom: var(--sp-lg); }
.auth-logo-icon { font-size: 3.5rem; animation: flicker 2s ease-in-out infinite; display: block; margin-bottom: 8px; }
.auth-app-name  { font-size: 1.8rem; font-weight: 800; letter-spacing: -.04em;
                   background: linear-gradient(135deg, var(--primary-light), var(--accent));
                   -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.auth-subtitle  { color: var(--text-secondary); font-size: .95rem; margin-top: 6px; }

.auth-lang-switch { display: flex; justify-content: flex-end; margin-bottom: var(--sp-sm); }
.btn-lang-sm {
  font-size: .8rem; padding: 5px 10px;
  border-radius: var(--r-sm); background: rgba(255,255,255,.05);
  color: var(--text-secondary); border: 1px solid var(--border-color);
  transition: all var(--t-fast);
}
.btn-lang-sm:hover { background: rgba(255,255,255,.1); color: var(--text-primary); }

.auth-form { margin-top: var(--sp-md); }

.form-check { margin-bottom: var(--sp-sm); }

.auth-switch {
  text-align: center; margin-top: var(--sp-md);
  font-size: .875rem; color: var(--text-secondary);
}
.auth-switch a { color: var(--primary-light); font-weight: 600; }
.auth-switch a:hover { color: #fff; }

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
  padding-top: var(--sp-lg);
  padding-bottom: var(--sp-xl);
  min-height: calc(100vh - var(--navbar-h) - 60px);
}

/* ================================================
   DASHBOARD
   ================================================ */
.dashboard-container { padding-top: var(--sp-lg); }

/* Hero */
.dashboard-hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-lg); margin-bottom: var(--sp-xl);
  flex-wrap: wrap;
}
.hero-greeting {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 800; letter-spacing: -.03em;
  line-height: 1.2; margin-bottom: 6px;
}
.hero-name { color: var(--primary-light); }
.hero-sub  { color: var(--text-secondary); font-size: .95rem; }

/* Progress ring */
.today-ring-wrap {
  position: relative; flex-shrink: 0;
  width: 120px; height: 120px;
}
.today-ring { transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 10; }
.ring-fill { fill: none; stroke-width: 10; stroke-linecap: round;
              transition: stroke-dasharray .8s cubic-bezier(.4,0,.2,1); }
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.ring-pct  { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.ring-sub  { font-size: .65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.stat-card {
  display: flex; align-items: center; gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  transition: transform var(--t-med), box-shadow var(--t-med);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon { font-size: 2rem; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.stat-label { display: block; font-size: .75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }

/* Habits section */
.habits-section { margin-bottom: var(--sp-xl); }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-lg);
}
.section-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }

.habits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-lg);
}

/* Habit Card */
.habit-card {
  padding: var(--sp-lg);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
  border: 1px solid var(--border-color);
  position: relative; overflow: hidden;
}
.habit-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--habit-color, var(--primary));
  opacity: .8;
}
.habit-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-accent); }
.habit-card.done { border-color: rgba(16,185,129,.3); }
.habit-card.done::before { background: var(--success); }

.habit-header {
  display: flex; align-items: flex-start; gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.habit-icon {
  width: 48px; height: 48px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
}
.habit-title-wrap { flex: 1; min-width: 0; }
.habit-name   { font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-target { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.habit-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Streak row */
.streak-row {
  display: flex; gap: var(--sp-md); margin-bottom: var(--sp-md);
}
.streak-badge {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-sm);
  background: rgba(255,255,255,.04); border-radius: var(--r-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}
.streak-badge.active { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.05); }

.streak-flame { font-size: 1.2rem; display: block; }
.streak-flame { animation: none; }
.streak-badge.active .streak-flame { animation: flicker 1.5s ease-in-out infinite; }
.mega-flame { animation: megaFlicker 1s ease-in-out infinite !important; }

.streak-num   { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.streak-label { font-size: .65rem; color: var(--text-muted); text-align: center; text-transform: uppercase; letter-spacing: .04em; }

/* Progress */
.progress-wrap { margin-bottom: var(--sp-md); }
.progress-header {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--text-secondary); margin-bottom: 6px;
}
.progress-pct { font-weight: 600; }
.progress-bar { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* Habit footer */
.habit-footer { display: flex; gap: var(--sp-sm); justify-content: flex-end; }

.checkin-btn.done-anim {
  animation: checkPop .4s cubic-bezier(.34,1.56,.64,1);
}

/* Empty state */
.empty-state {
  padding: var(--sp-xl); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-md);
}
.empty-emoji { font-size: 4rem; }
.empty-state h3 { font-size: 1.3rem; font-weight: 700; }
.empty-state p  { color: var(--text-secondary); }

/* ================================================
   MODALS
   ================================================ */
dialog {
  background: transparent; border: none; padding: 0;
  max-width: min(520px, 95vw); width: 100%;
}
dialog::backdrop {
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
}
dialog[open] { animation: modalIn .3s cubic-bezier(.34,1.56,.64,1); }

.modal-inner {
  padding: var(--sp-lg) var(--sp-xl);
  border: 1px solid rgba(99,102,241,.2);
  box-shadow: var(--shadow-lg);
}
.modal-sm .modal-inner { max-width: 380px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-lg);
}
.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 1.1rem;
  color: var(--text-muted); padding: 4px 8px; border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: rgba(255,255,255,.1); color: var(--text-primary); }
.modal-msg { color: var(--text-secondary); margin-bottom: var(--sp-lg); font-size: .95rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-sm); margin-top: var(--sp-lg); }

/* Emoji picker */
.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: var(--sp-md);
}
.emoji-pick {
  font-size: 1.3rem; background: rgba(255,255,255,.06);
  border: 1px solid var(--border-color); border-radius: var(--r-sm);
  width: 40px; height: 40px; cursor: pointer;
  transition: all var(--t-fast); display: flex; align-items: center; justify-content: center;
}
.emoji-pick:hover { background: rgba(99,102,241,.2); border-color: var(--primary); transform: scale(1.1); }
.emoji-input { text-align: center; font-size: 1.4rem; letter-spacing: .05em; }

/* Target chips */
.target-row { display: flex; gap: var(--sp-sm); align-items: center; flex-wrap: wrap; }
.target-chip {
  padding: 7px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,.05);
  color: var(--text-secondary); font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all var(--t-fast);
}
.target-chip:hover { border-color: var(--primary); color: var(--primary-light); }
.target-chip.active { background: rgba(99,102,241,.2); border-color: var(--primary); color: var(--primary-light); }
.target-input { flex: 1; min-width: 70px; max-width: 90px; }

/* ================================================
   DETAIL PAGE
   ================================================ */
.detail-container { padding-top: var(--sp-md); }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: .875rem; font-weight: 500;
  margin-bottom: var(--sp-md);
  transition: color var(--t-fast);
}
.back-link:hover { color: var(--text-primary); }

.detail-hero {
  display: flex; align-items: center; gap: var(--sp-lg);
  padding: var(--sp-lg) var(--sp-xl); margin-bottom: var(--sp-lg);
  border-top: 4px solid var(--habit-color, var(--primary));
}
.detail-icon { font-size: 3rem; width: 72px; height: 72px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.detail-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.detail-since, .detail-target { font-size: .85rem; color: var(--text-secondary); }

.detail-stats { margin-bottom: var(--sp-lg); }

/* Heatmap */
.heatmap-section { padding: var(--sp-lg); margin-bottom: var(--sp-lg); }
.heatmap-wrap  { overflow-x: auto; padding-bottom: var(--sp-sm); }
.heatmap-legend {
  display: flex; align-items: center; gap: var(--sp-sm);
  margin-top: var(--sp-sm); font-size: .75rem; color: var(--text-muted); justify-content: flex-end;
}
.legend-boxes { display: flex; gap: 3px; }
.legend-box { width: 14px; height: 14px; border-radius: 3px; }

/* Bar chart */
.chart-section { padding: var(--sp-lg); margin-bottom: var(--sp-lg); }
.bar-chart {
  display: flex; align-items: flex-end; gap: var(--sp-sm);
  height: 160px; padding-top: var(--sp-md);
}
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; height: 100%; }
.bar-col   { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill  { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: height .6s cubic-bezier(.4,0,.2,1); }
.bar-label { font-size: .65rem; color: var(--text-muted); white-space: nowrap; }
.bar-val   { font-size: .75rem; font-weight: 600; color: var(--text-secondary); }

/* Badges */
.badges-section { padding: var(--sp-lg); margin-bottom: var(--sp-lg); }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-md); margin-top: var(--sp-md); }
.badge-card {
  display: flex; align-items: center; gap: var(--sp-md);
  padding: var(--sp-md);
  border-radius: var(--r-sm); border: 1px solid var(--border-color);
  background: rgba(255,255,255,.04);
}
.badge-card.earned { border-color: rgba(99,102,241,.3); background: rgba(99,102,241,.08); }
.badge-card.locked { opacity: .5; }
.badge-icon { font-size: 2rem; flex-shrink: 0; }
.badge-name { display: block; font-weight: 700; font-size: .9rem; }
.badge-desc { display: block; font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.badge-date { display: block; font-size: .72rem; color: var(--text-muted); margin-top: 4px; }
.badges-locked { margin-top: var(--sp-md); }
.empty-badges { color: var(--text-muted); font-size: .9rem; margin-top: var(--sp-sm); }

/* ================================================
   PROFILE PAGE
   ================================================ */
.profile-container { padding-top: var(--sp-lg); }
.page-title { font-size: 1.8rem; font-weight: 800; margin-bottom: var(--sp-lg); letter-spacing: -.03em; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
}
@media (max-width: 768px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-card {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--sp-xl);
  padding: var(--sp-xl);
  flex-wrap: wrap;
}
.profile-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--sp-sm); position: relative; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(99,102,241,.2); border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 3.5rem; box-shadow: 0 0 24px var(--primary-glow);
}
.avatar-picker {
  position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--r-md); padding: var(--sp-sm);
  display: flex; flex-wrap: wrap; gap: 6px; width: 200px;
  box-shadow: var(--shadow-lg); z-index: 10;
}
.avatar-opt {
  font-size: 1.8rem; background: none; border: 1px solid transparent;
  border-radius: var(--r-sm); width: 44px; height: 44px; cursor: pointer;
  transition: all var(--t-fast); display: flex; align-items: center; justify-content: center;
}
.avatar-opt:hover { background: rgba(255,255,255,.1); border-color: var(--primary); transform: scale(1.1); }

.profile-name   { font-size: 1.5rem; font-weight: 800; }
.profile-email  { color: var(--text-secondary); font-size: .9rem; }
.profile-joined { color: var(--text-muted); font-size: .85rem; margin-top: 4px; }
.profile-stats-mini {
  display: flex; gap: var(--sp-md); margin-top: var(--sp-sm);
  font-size: .85rem; color: var(--text-secondary); flex-wrap: wrap;
}

.settings-card { padding: var(--sp-lg) var(--sp-xl); }
.settings-title { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--sp-lg); }

.danger-card { border-color: rgba(239,68,68,.3); }
.danger-title { color: var(--danger); }
.danger-msg   { color: var(--text-secondary); font-size: .9rem; margin-bottom: var(--sp-md); }

/* ================================================
   FOOTER
   ================================================ */
.footer {
  border-top: 1px solid var(--border-color);
  padding: var(--sp-md) var(--sp-lg);
}
.footer-inner {
  max-width: var(--container-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; gap: var(--sp-sm);
}
.footer-logo { font-weight: 600; color: var(--text-secondary); }

/* ================================================
   TOAST NOTIFICATION
   ================================================ */
.toast {
  position: fixed; bottom: var(--sp-lg); left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--r-sm); padding: 12px 20px;
  font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
  opacity: 0; z-index: 200; pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.toast.error   { border-color: rgba(239,68,68,.4);  color: #fca5a5; }

/* ================================================
   CONFETTI CANVAS
   ================================================ */
.confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
}

/* ================================================
   ANIMATIONS
   ================================================ */
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50%       { transform: scale(1.08) rotate(1deg); }
}
@keyframes megaFlicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  25%       { transform: scale(1.15) rotate(2deg); }
  75%       { transform: scale(.92) rotate(-1deg); }
}
@keyframes checkPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes modalIn {
  from { transform: scale(.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);    opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.habit-card { animation: slideUp .35s ease both; }
.habit-card:nth-child(1){ animation-delay: .05s; }
.habit-card:nth-child(2){ animation-delay: .10s; }
.habit-card:nth-child(3){ animation-delay: .15s; }
.habit-card:nth-child(4){ animation-delay: .20s; }
.habit-card:nth-child(5){ animation-delay: .25s; }
.habit-card:nth-child(n+6){ animation-delay: .30s; }

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 640px) {
  .auth-card { padding: var(--sp-lg) var(--sp-md); }
  .dashboard-hero { flex-direction: column; gap: var(--sp-md); align-items: flex-start; }
  .today-ring-wrap { align-self: center; }
  .habits-grid { grid-template-columns: 1fr; }
  .detail-hero { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-inner { padding: var(--sp-lg); }
  .form-row { flex-direction: column; }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-stats-mini { justify-content: center; }
  .bar-chart { overflow-x: auto; min-width: 480px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
}
