/* ============================================================
   MicroRhythms — styles.css
   Light-first design with dark mode via [data-theme="dark"]
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Colors — light */
  --bg:        #FAFAFA;
  --surface:   #FFFFFF;
  --surface-2: #F3F4F6;
  --border:    #E5E7EB;
  --text:      #1F2937;
  --text-2:    #6B7280;
  --text-3:    #9CA3AF;

  --primary:   #3B82F6;
  --primary-h: #2563EB;
  --primary-s: rgba(59,130,246,0.12);

  --success:   #10B981;
  --success-s: rgba(16,185,129,0.12);

  --warning:   #F59E0B;
  --danger:    #EF4444;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

  /* Radii */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Transitions */
  --t: 160ms ease;
  --t-slow: 280ms ease;

  /* Nav */
  --nav-h: 60px;
}

[data-theme="dark"] {
  --bg:        #0F172A;
  --surface:   #1E293B;
  --surface-2: #263347;
  --border:    #334155;
  --text:      #F1F5F9;
  --text-2:    #94A3B8;
  --text-3:    #64748B;

  --primary:   #60A5FA;
  --primary-h: #93C5FD;
  --primary-s: rgba(96,165,250,0.15);

  --success:   #34D399;
  --success-s: rgba(52,211,153,0.15);

  --warning:   #FCD34D;
  --danger:    #F87171;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--t-slow), color var(--t-slow);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
textarea, input, select { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; }

/* ── Nav ───────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 8px;
  transition: background var(--t-slow), border-color var(--t-slow);
}

.nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  text-decoration: none; margin-right: 16px;
  flex-shrink: 0;
}
.nav-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.nav-links {
  display: flex; gap: 2px; flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 0.9rem; font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  transition: color var(--t), background var(--t);
  cursor: pointer;
}
.nav-link:hover  { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--primary); background: var(--primary-s); }

.nav-actions {
  display: flex; align-items: center; gap: 8px;
}

.streak-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: var(--warning);
  color: #fff;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}

.btn-icon {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--t);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* ── Page Layout ───────────────────────────────────────────── */
.main {
  margin-top: var(--nav-h);
  padding: 40px 24px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.view { display: none; animation: fadeIn 200ms ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }

.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.78rem; }
.text-muted { color: var(--text-2); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: background var(--t-slow), border-color var(--t-slow);
}
.card-body { padding: 24px; }
.card-sm .card-body { padding: 16px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: 0.9rem; font-weight: 600;
  border: none;
  transition: all var(--t);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}
.btn-primary:hover { background: var(--primary-h); box-shadow: 0 4px 12px rgba(59,130,246,0.4); }

.btn-success {
  background: var(--success); color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.35);
}
.btn-success:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn-full { width: 100%; justify-content: center; }

/* ── Form Elements ─────────────────────────────────────────── */
textarea, input[type="text"], input[type="email"], input[type="url"], select {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  resize: vertical;
}
textarea:focus,
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-s);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}
.form-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-3);
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-track {
  background: var(--surface-2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.progress-fill.success { background: var(--success); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-primary { background: var(--primary-s); color: var(--primary); }
.badge-success { background: var(--success-s); color: var(--success); }
.badge-gray    { background: var(--surface-2); color: var(--text-2); }
.badge-warning { background: rgba(245,158,11,0.12); color: var(--warning); }

/* ── Divider ───────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── ====================================================
   CHECK-IN VIEW
   ==================================================== */
.checkin-header {
  text-align: center;
  margin-bottom: 40px;
}
.checkin-header .date-label {
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* Done state */
.checkin-done-card {
  text-align: center;
  padding: 48px 32px;
}
.checkin-done-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: popIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.checkin-done-summary {
  margin-top: 24px;
  text-align: left;
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 16px 20px;
}
.summary-row {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.summary-row:last-child { border-bottom: none; }
.summary-label {
  flex-shrink: 0; width: 24px; text-align: center;
}

/* Step-by-step form */
.checkin-flow {}
.step-indicator {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 32px;
}
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: all var(--t);
}
.step-dot.active  { background: var(--primary); transform: scale(1.3); }
.step-dot.done    { background: var(--success); }
.step-label {
  margin-left: 8px;
  font-size: 0.8rem; color: var(--text-3);
}

.step-card { display: none; }
.step-card.active { display: block; animation: fadeIn 200ms ease; }

.step-question {
  margin-bottom: 6px;
}
.step-question .q-num {
  font-size: 0.78rem; font-weight: 600;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.step-question h2 { font-size: 1.4rem; margin-bottom: 4px; }
.step-question p  { color: var(--text-2); font-size: 0.9rem; margin-bottom: 20px; }

.prev-answer {
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--primary-s);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--primary);
  font-size: 0.85rem; color: var(--text-2);
}
.prev-answer strong { color: var(--text); display: block; margin-bottom: 4px; }

.step-actions {
  display: flex; gap: 10px; align-items: center;
  margin-top: 16px;
}
.step-skip {
  background: none; border: none;
  color: var(--text-3); font-size: 0.85rem;
  padding: 8px; cursor: pointer;
  transition: color var(--t);
}
.step-skip:hover { color: var(--text-2); }

/* Unblocking panel */
.unblock-panel {
  display: none;
  animation: fadeIn 200ms ease;
}
.unblock-panel.active { display: block; }
.unblock-intro {
  margin-bottom: 20px;
}
.unblock-options {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 24px;
}
.unblock-option {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--t);
  text-align: left;
}
.unblock-option:hover {
  border-color: var(--primary);
  background: var(--primary-s);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.unblock-option.selected {
  border-color: var(--primary);
  background: var(--primary-s);
}
.unblock-option-emoji { font-size: 1.4rem; flex-shrink: 0; margin-top: 1px; }
.unblock-option-text  { font-size: 0.92rem; font-weight: 500; line-height: 1.45; }

/* Completion */
.checkin-complete { display: none; text-align: center; }
.checkin-complete.active { display: block; animation: fadeIn 300ms ease; }
.complete-icon {
  font-size: 4rem; margin-bottom: 16px;
  animation: popIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.complete-stats {
  display: flex; justify-content: center; gap: 24px;
  margin: 24px 0;
}
.complete-stat {
  text-align: center;
}
.complete-stat .val {
  font-size: 2rem; font-weight: 700; line-height: 1;
  color: var(--primary);
}
.complete-stat .lbl {
  font-size: 0.8rem; color: var(--text-2); margin-top: 4px;
}

/* ── ====================================================
   ACHIEVEMENTS VIEW
   ==================================================== */
.achievements-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}
.achievement-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--primary);
}
.achievement-card.completed {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--surface) 0%, var(--success-s) 100%);
}
.achievement-card.completed::after {
  content: '✓';
  position: absolute; top: 12px; right: 12px;
  width: 22px; height: 22px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.achievement-emoji { font-size: 2rem; margin-bottom: 10px; }
.achievement-title {
  font-size: 0.95rem; font-weight: 600;
  margin-bottom: 6px; line-height: 1.3;
}
.achievement-meta {
  font-size: 0.8rem; color: var(--text-2);
  margin-bottom: 12px;
}
.achievement-pct {
  font-size: 0.82rem; font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.achievement-card.completed .achievement-pct { color: var(--success); }

.add-achievement-card {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 20px;
  cursor: pointer;
  color: var(--text-3);
  transition: all var(--t);
  font-size: 0.9rem;
  background: transparent;
  gap: 8px;
}
.add-achievement-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-s);
}
.add-achievement-card .plus { font-size: 1.8rem; font-weight: 300; }

.achievements-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.achievements-empty .empty-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── ====================================================
   REPORTS VIEW
   ==================================================== */
.report-period {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.report-period h2 { margin: 0; }
.report-nav-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px 10px;
  font-size: 0.85rem; color: var(--text-2);
  cursor: pointer; transition: all var(--t);
}
.report-nav-btn:hover { color: var(--text); background: var(--surface); }

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 600px) { .report-grid { grid-template-columns: 1fr; } }

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.report-card-full { grid-column: 1 / -1; }

.report-stat-val {
  font-size: 2.4rem; font-weight: 700;
  line-height: 1; color: var(--primary);
  margin-bottom: 4px;
}
.report-stat-lbl { font-size: 0.85rem; color: var(--text-2); }

.report-list { list-style: none; }
.report-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem; display: flex; gap: 10px;
}
.report-list li:last-child { border-bottom: none; }

.focus-textarea {
  width: 100%; min-height: 80px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  color: var(--text);
  font-size: 0.9rem;
  resize: vertical;
}
.focus-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-s);
  outline: none;
}

.report-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 20px;
}

.report-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-2);
}
.report-empty .empty-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── ====================================================
   SETTINGS VIEW
   ==================================================== */
.settings-section {
  margin-bottom: 36px;
}
.settings-section h3 {
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.settings-section .section-desc {
  color: var(--text-2); font-size: 0.875rem; margin-bottom: 20px;
}

.integration-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 12px;
}
.integration-icon { font-size: 1.3rem; flex-shrink: 0; }
.integration-info { flex: 1; }
.integration-name { font-weight: 600; font-size: 0.9rem; }
.integration-status { font-size: 0.8rem; color: var(--text-2); }
.integration-status.connected { color: var(--success); }

/* ── ====================================================
   WELCOME / SETUP VIEW
   ==================================================== */
.welcome-view {
  max-width: 560px; margin: 60px auto 0;
  text-align: center;
}
.welcome-logo {
  font-size: 3rem; margin-bottom: 16px;
  animation: popIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.welcome-tagline {
  color: var(--text-2); font-size: 1.05rem;
  margin: 8px 0 36px;
}
.welcome-steps {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 28px;
}
.setup-step {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
.setup-step:last-child { border-bottom: none; }
.setup-step .s-num {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--primary-s);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  margin-top: 1px;
}
.setup-step h4 { margin-bottom: 2px; }
.setup-step p  { font-size: 0.85rem; color: var(--text-2); }

/* ── ====================================================
   MODAL
   ==================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn 150ms ease; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 0;
  margin-bottom: 20px;
}
.modal-body    { padding: 0 24px 24px; }
.modal-close {
  width: 30px; height: 30px;
  background: var(--surface-2); border: none;
  border-radius: var(--r-sm);
  color: var(--text-2); font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t);
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* Emoji picker inline */
.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.emoji-btn {
  width: 36px; height: 36px;
  font-size: 1.2rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer; transition: all var(--t);
}
.emoji-btn:hover, .emoji-btn.active { border-color: var(--primary); background: var(--primary-s); }

/* ── ====================================================
   TOAST
   ==================================================== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem; font-weight: 500;
  min-width: 260px; max-width: 380px;
  animation: slideInRight 200ms ease;
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--primary); }

/* ── ====================================================
   CONFETTI (canvas overlay)
   ==================================================== */
#confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
}

/* ── ====================================================
   MISC UTILITIES
   ==================================================== */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── ====================================================
   PLAYBOOKS VIEW
   ==================================================== */

.pb-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px; gap: 16px;
}

/* Back link */
.pb-back-btn {
  background: none; border: none; padding: 0;
  color: var(--text-2); font-size: 0.875rem; cursor: pointer;
  transition: color var(--t);
}
.pb-back-btn:hover { color: var(--primary); }

/* Last role banner */
.pb-last-role-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--primary-s);
  border: 1px solid var(--primary);
  border-radius: var(--r);
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 24px;
}

/* Role picker grid */
.pb-role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.pb-role-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--t);
  text-align: center;
}
.pb-role-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  background: var(--primary-s);
}
.pb-role-card--active {
  border-color: var(--primary);
  background: var(--primary-s);
}
.pb-role-emoji { font-size: 2rem; }
.pb-role-label { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.pb-role-desc  { font-size: 0.75rem; color: var(--text-2); }

/* AI suggestion box */
.pb-ai-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}
.pb-ai-header {
  display: flex; gap: 14px; align-items: flex-start;
}
.pb-ai-icon { font-size: 1.6rem; flex-shrink: 0; margin-top: 2px; }

/* Category sections */
.pb-category { margin-bottom: 36px; }
.pb-category-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.pb-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* Suggestion card */
.pb-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow var(--t), border-color var(--t);
}
.pb-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.pb-item--ai {
  border-color: rgba(139,92,246,0.3);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(139,92,246,0.04) 100%);
}

.pb-item-top {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.pb-item-emoji { font-size: 1.4rem; }

.pb-freq-badge {
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
}

.pb-item-title {
  font-size: 0.92rem; font-weight: 600;
  color: var(--text); line-height: 1.4;
}
.pb-item-tip {
  font-size: 0.82rem; color: var(--text-2);
  line-height: 1.5;
}

.pb-item-actions {
  display: flex; gap: 8px; margin-top: 4px;
}
.pb-action-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.78rem; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t);
}
.pb-action-btn:hover {
  background: var(--primary-s);
  border-color: var(--primary);
  color: var(--primary);
}

/* AI results area */
.pb-ai-results {
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 16px;
}

/* AI loading spinner */
.pb-ai-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0;
  color: var(--text-2); font-size: 0.875rem;
}
.pb-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ====================================================
   AUTH GATE
   ==================================================== */
.auth-gate {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: background var(--t-slow);
}
.auth-gate.hidden { display: none; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  text-align: center;
  animation: slideUp 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-logo   { font-size: 3rem; margin-bottom: 12px; }
.auth-title  { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.auth-tagline {
  color: var(--text-2); font-size: 0.95rem;
  margin-bottom: 32px; line-height: 1.5;
}
.auth-card .form-group  { text-align: left; }
.auth-card .form-label  { color: var(--text-2); }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-3); font-size: 0.8rem;
  margin: 16px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

.auth-fine-print {
  margin-top: 16px; font-size: 0.78rem;
  color: var(--text-3); line-height: 1.5;
}

/* Google OAuth button */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 0.95rem; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all var(--t);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover {
  border-color: #4285F4;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.btn-google:disabled {
  opacity: 0.7; cursor: not-allowed; transform: none;
}

/* ── ====================================================
   WELLNESS NUDGE BANNER
   ==================================================== */
#wellness-nudge {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 48px); max-width: 540px;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: opacity 300ms ease, transform 300ms ease;
  opacity: 0; transform: translateX(-50%) translateY(20px);
}
#wellness-nudge.wn-visible {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
#wellness-nudge.wn-hidden { display: none; }

.wn-inner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 48px 16px 16px; /* right padding for close btn */
  position: relative;
}
.wn-emoji {
  font-size: 1.6rem; flex-shrink: 0; margin-top: 1px;
}
.wn-text { flex: 1; }
.wn-title {
  font-size: 0.92rem; font-weight: 700;
  color: var(--text); margin-bottom: 3px;
}
.wn-body {
  font-size: 0.82rem; color: var(--text-2); line-height: 1.5;
}
.wn-btns {
  display: flex; gap: 8px; flex-shrink: 0; align-items: center;
  margin-top: 4px;
}
.wn-btn-snooze,
.wn-btn-got-it {
  padding: 5px 12px; border-radius: var(--r-sm);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: all var(--t); border: 1px solid var(--border);
  white-space: nowrap;
}
.wn-btn-snooze {
  background: var(--surface-2); color: var(--text-2);
}
.wn-btn-snooze:hover { background: var(--border); color: var(--text); }
.wn-btn-got-it {
  background: var(--success); color: #fff; border-color: var(--success);
}
.wn-btn-got-it:hover { filter: brightness(1.05); }

.wn-close {
  position: absolute; top: 10px; right: 10px;
  width: 24px; height: 24px;
  background: none; border: none;
  color: var(--text-3); font-size: 0.9rem;
  cursor: pointer; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.wn-close:hover { background: var(--surface-2); color: var(--text-2); }

/* Category colour dot */
.wn-cat-dot {
  width: 4px; align-self: stretch; border-radius: 4px;
  flex-shrink: 0; margin-right: 2px;
}
.wn-cat-movement  { background: var(--success); }
.wn-cat-hydration { background: #60A5FA; }
.wn-cat-food      { background: var(--warning); }
.wn-cat-mental    { background: #8B5CF6; }
.wn-cat-eyes      { background: #EC4899; }
.wn-cat-posture   { background: #F59E0B; }
.wn-cat-mood      { background: #34D399; }

/* Progress bar */
.wn-progress-track {
  height: 3px; background: var(--surface-2);
}
.wn-progress-fill {
  height: 100%; background: var(--primary);
  width: 100%; transition: width 80ms linear;
}

/* ── ====================================================
   ENERGY CHECK (on check-in complete screen)
   ==================================================== */
.energy-check {
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 16px 20px;
  text-align: center;
}
.energy-prompt {
  font-size: 0.9rem; font-weight: 600;
  color: var(--text-2); margin-bottom: 14px;
}
.energy-btns {
  display: flex; justify-content: center; gap: 8px;
  flex-wrap: wrap;
}
.energy-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer; transition: all var(--t);
  min-width: 72px;
}
.energy-btn:hover {
  border-color: var(--primary);
  background: var(--primary-s);
  transform: translateY(-2px);
}
.energy-btn--active {
  border-color: var(--primary);
  background: var(--primary-s);
  box-shadow: 0 0 0 3px var(--primary-s);
}
.energy-emoji { font-size: 1.5rem; }
.energy-lbl   { font-size: 0.72rem; color: var(--text-2); font-weight: 500; }
.energy-result {
  margin-top: 10px;
  font-weight: 600;
}
.energy-result.hidden { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main { padding: 24px 16px; }
  .nav  { padding: 0 16px; }
  .nav-link span { display: none; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  .achievements-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .achievements-grid { grid-template-columns: 1fr; }
}
