/* =============================================================
   Eanchainn — Design System
   eanchainn.co.uk
   Mobile-first. iPhone PWA primary target.
   ============================================================= */

/* -------------------------------------------------------------
   1. CUSTOM PROPERTIES (TOKENS)
   ------------------------------------------------------------- */

:root {

  /* --- Pink (primary) --- */
  --pink-50:  #FFF0F5;
  --pink-100: #FFD6E7;
  --pink-200: #FFB3D1;
  --pink-400: #F472B6;
  --pink-600: #DB2777;
  --pink-800: #9D174D;

  /* --- Yellow / Sunshine (accent) --- */
  --yellow-50:  #FFFBEB;
  --yellow-100: #FEF3C7;
  --yellow-200: #FDE68A;
  --yellow-400: #FBBF24;
  --yellow-600: #D97706;
  --yellow-800: #92400E;

  /* --- Peach (warm bridge) --- */
  --peach-50:  #FFF5F0;
  --peach-100: #FFE4D6;
  --peach-200: #FFC8AD;
  --peach-400: #FB923C;
  --peach-600: #EA580C;
  --peach-800: #9A3412;

  /* --- Lilac (coping strategies) --- */
  --lilac-50:  #FAF5FF;
  --lilac-100: #F3E8FF;
  --lilac-200: #E9D5FF;
  --lilac-400: #C084FC;
  --lilac-600: #9333EA;
  --lilac-800: #6B21A8;

  /* --- Stone / Neutral --- */
  --neutral-50:  #FAFAF9;
  --neutral-100: #F5F5F4;
  --neutral-200: #E7E5E4;
  --neutral-400: #A8A29E;
  --neutral-600: #57534E;
  --neutral-800: #1C1917;

  /* --- Traffic light (mood only — never repurpose) --- */
  --traffic-green-bg:     #F0FDF4;
  --traffic-green-dot:    #4ADE80;
  --traffic-green-text:   #16A34A;
  --traffic-green-border: #86EFAC;

  --traffic-amber-bg:     #FFFBEB;
  --traffic-amber-dot:    #FBBF24;
  --traffic-amber-text:   #D97706;
  --traffic-amber-border: #FDE68A;

  --traffic-red-bg:       #FFF1F2;
  --traffic-red-dot:      #FB7185;
  --traffic-red-text:     #E11D48;
  --traffic-red-border:   #FECDD3;

  /* --- Semantic aliases --- */
  --color-primary:        var(--pink-400);
  --color-primary-dark:   var(--pink-600);
  --color-primary-light:  var(--pink-50);
  --color-primary-border: var(--pink-200);

  --color-accent:         var(--yellow-400);
  --color-accent-dark:    var(--yellow-600);
  --color-accent-light:   var(--yellow-50);
  --color-accent-border:  var(--yellow-200);

  --color-strategy:       var(--lilac-400);
  --color-strategy-dark:  var(--lilac-600);
  --color-strategy-light: var(--lilac-50);
  --color-strategy-border:var(--lilac-200);

  --color-surface:        #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-bg:             var(--neutral-100);
  --color-text:           var(--neutral-800);
  --color-text-muted:     var(--neutral-600);
  --color-text-subtle:    var(--neutral-400);
  --color-border:         rgba(0, 0, 0, 0.08);
  --color-border-strong:  rgba(0, 0, 0, 0.15);

  /* --- Gradient (wordmark / hero use only) --- */
  --gradient-sunshine: linear-gradient(135deg, var(--pink-400) 0%, var(--peach-400) 50%, var(--yellow-400) 100%);
  --gradient-sunshine-soft: linear-gradient(135deg, var(--pink-50) 0%, var(--peach-50) 50%, var(--yellow-50) 100%);

  /* --- Spacing --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* --- Border radius --- */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* --- Typography --- */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
  --font-size-xs:   11px;
  --font-size-sm:   13px;
  --font-size-base: 15px;
  --font-size-md:   17px;
  --font-size-lg:   20px;
  --font-size-xl:   24px;
  --font-size-2xl:  28px;
  --line-height-tight:  1.2;
  --line-height-normal: 1.5;
  --line-height-loose:  1.7;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);

  /* --- Transitions --- */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;

  /* --- Touch targets (iOS minimum) --- */
  --touch-min: 44px;

}


/* -------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  /* Account for iOS safe areas when installed as PWA */
  padding-bottom: env(safe-area-inset-bottom);
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--color-primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--pink-400);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}


/* -------------------------------------------------------------
   3. TYPOGRAPHY
   ------------------------------------------------------------- */

.text-xs     { font-size: var(--font-size-xs); }
.text-sm     { font-size: var(--font-size-sm); }
.text-base   { font-size: var(--font-size-base); }
.text-md     { font-size: var(--font-size-md); }
.text-lg     { font-size: var(--font-size-lg); }
.text-xl     { font-size: var(--font-size-xl); }
.text-2xl    { font-size: var(--font-size-2xl); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }

.text-primary { color: var(--color-text); }
.text-muted   { color: var(--color-text-muted); }
.text-subtle  { color: var(--color-text-subtle); }
.text-pink    { color: var(--pink-600); }
.text-yellow  { color: var(--yellow-600); }
.text-lilac   { color: var(--lilac-600); }

.label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

/* Wordmark — gradient text */
.wordmark {
  font-size: var(--font-size-2xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  background: var(--gradient-sunshine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}


/* -------------------------------------------------------------
   4. LAYOUT
   ------------------------------------------------------------- */

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-4);
  /* Bottom padding for nav bar */
  padding-bottom: calc(72px + env(safe-area-inset-bottom) + var(--space-4));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0 var(--space-6);
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack-2  { gap: var(--space-2); }
.stack-3  { gap: var(--space-3); }
.stack-4  { gap: var(--space-4); }
.stack-6  { gap: var(--space-6); }

.row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.row-between {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }


/* -------------------------------------------------------------
   5. CARDS
   ------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-pink {
  background: var(--pink-50);
  border: 0.5px solid var(--pink-100);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.card-yellow {
  background: var(--yellow-50);
  border: 0.5px solid var(--yellow-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.card-lilac {
  background: var(--lilac-50);
  border: 0.5px solid var(--lilac-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

/* Sunshine gradient hero card */
.card-hero {
  background: var(--gradient-sunshine-soft);
  border: 0.5px solid var(--pink-100);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}


/* -------------------------------------------------------------
   6. BUTTONS
   ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: var(--font-size-base);
  border-radius: var(--radius-md);
  padding: 0 var(--space-5);
  min-height: var(--touch-min);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-full {
  width: 100%;
}

/* Primary — pink */
.btn-primary {
  background: var(--pink-400);
  color: #fff;
}

.btn-primary:hover {
  background: var(--pink-600);
  color: #fff;
  text-decoration: none;
}

/* Accent — yellow */
.btn-accent {
  background: var(--yellow-400);
  color: var(--yellow-800);
}

.btn-accent:hover {
  background: var(--yellow-600);
  color: #fff;
}

/* Secondary — soft pink */
.btn-secondary {
  background: var(--pink-50);
  color: var(--pink-600);
  border: 1px solid var(--pink-200);
}

.btn-secondary:hover {
  background: var(--pink-100);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 0.5px solid var(--color-border-strong);
}

.btn-ghost:hover {
  background: var(--neutral-100);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: #E11D48;
  border: 0.5px solid #FECDD3;
}

.btn-danger:hover {
  background: #FFF1F2;
}

/* Icon button — square, no label */
.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.btn-icon:hover {
  background: var(--neutral-200);
}


/* -------------------------------------------------------------
   7. FORM ELEMENTS
   ------------------------------------------------------------- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 0.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--pink-400);
  box-shadow: 0 0 0 3px var(--pink-100);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: var(--line-height-loose);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
}

/* Context tag selector */
.context-tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.context-tab {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 0.5px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
}

.context-tab.active,
.context-tab:hover {
  background: var(--pink-50);
  border-color: var(--pink-200);
  color: var(--pink-600);
}


/* -------------------------------------------------------------
   8. MOOD / TRAFFIC LIGHT
   ------------------------------------------------------------- */

.mood-grid {
  display: flex;
  gap: var(--space-3);
}

.mood-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
}

.mood-btn:active {
  transform: scale(0.96);
}

.mood-btn.green  { background: var(--traffic-green-bg); }
.mood-btn.amber  { background: var(--traffic-amber-bg); }
.mood-btn.red    { background: var(--traffic-red-bg); }

.mood-btn.green.selected  { border-color: var(--traffic-green-dot); }
.mood-btn.amber.selected  { border-color: var(--traffic-amber-dot); }
.mood-btn.red.selected    { border-color: var(--traffic-red-dot); }

.mood-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.mood-btn.green .mood-dot  { background: var(--traffic-green-dot); }
.mood-btn.amber .mood-dot  { background: var(--traffic-amber-dot); }
.mood-btn.red   .mood-dot  { background: var(--traffic-red-dot); }

.mood-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.mood-btn.green .mood-label  { color: var(--traffic-green-text); }
.mood-btn.amber .mood-label  { color: var(--traffic-amber-text); }
.mood-btn.red   .mood-label  { color: var(--traffic-red-text); }

/* Inline mood badge (history views) */
.mood-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.mood-badge.green { background: var(--traffic-green-bg); color: var(--traffic-green-text); }
.mood-badge.amber { background: var(--traffic-amber-bg); color: var(--traffic-amber-text); }
.mood-badge.red   { background: var(--traffic-red-bg);   color: var(--traffic-red-text); }

.mood-badge::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.mood-badge.green::before { background: var(--traffic-green-dot); }
.mood-badge.amber::before { background: var(--traffic-amber-dot); }
.mood-badge.red::before   { background: var(--traffic-red-dot); }


/* -------------------------------------------------------------
   9. STRATEGY CARDS
   ------------------------------------------------------------- */

.strategy-card {
  background: var(--lilac-50);
  border: 0.5px solid var(--lilac-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.strategy-card__category {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--lilac-200);
  color: var(--lilac-800);
  display: inline-block;
  align-self: flex-start;
}

.strategy-card__title {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--lilac-800);
}

.strategy-card__body {
  font-size: var(--font-size-sm);
  color: var(--lilac-600);
  line-height: var(--line-height-loose);
}

.strategy-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.helpful-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 0.5px solid var(--lilac-200);
  background: var(--color-surface);
  color: var(--lilac-600);
  cursor: pointer;
  min-height: var(--touch-min);
  transition: all var(--transition-fast);
}

.helpful-btn:hover,
.helpful-btn.selected {
  background: var(--lilac-100);
  border-color: var(--lilac-400);
  color: var(--lilac-800);
}


/* -------------------------------------------------------------
   10. TASKS & CHECKLISTS
   ------------------------------------------------------------- */

.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 0.5px solid var(--color-border);
}

.task-item:last-child {
  border-bottom: none;
}

.task-checkbox {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--pink-200);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 2px;
  transition: all var(--transition-fast);
  background: transparent;
}

.task-checkbox.checked {
  background: var(--pink-400);
  border-color: var(--pink-400);
}

.task-checkbox svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task-label {
  flex: 1;
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: var(--line-height-normal);
}

.task-label.done {
  color: var(--color-text-subtle);
  text-decoration: line-through;
}

.task-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
  margin-top: 2px;
}

/* Priority indicator */
.priority-high   { border-left: 3px solid var(--pink-400); padding-left: var(--space-3); }
.priority-normal { border-left: 3px solid var(--neutral-200); padding-left: var(--space-3); }
.priority-low    { border-left: 3px solid var(--neutral-100); padding-left: var(--space-3); }


/* -------------------------------------------------------------
   11. ROUTINES
   ------------------------------------------------------------- */

.routine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.routine-title {
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--color-text);
}

.routine-progress {
  font-size: var(--font-size-sm);
  color: var(--color-text-subtle);
}

.routine-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 0.5px solid var(--color-border);
  cursor: pointer;
}

.routine-step:last-child {
  border-bottom: none;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--neutral-100);
  border: 0.5px solid var(--color-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.routine-step.done .step-number {
  background: var(--pink-400);
  border-color: var(--pink-400);
  color: #fff;
}

.step-text {
  font-size: var(--font-size-base);
  color: var(--color-text);
}

.routine-step.done .step-text {
  color: var(--color-text-subtle);
  text-decoration: line-through;
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.progress-bar__fill {
  height: 100%;
  background: var(--gradient-sunshine);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}


/* -------------------------------------------------------------
   12. BOTTOM NAVIGATION
   ------------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 0.5px solid var(--color-border);
  display: flex;
  padding: var(--space-2) var(--space-4);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  min-height: var(--touch-min);
  justify-content: center;
}

.nav-item:hover {
  background: var(--neutral-100);
  text-decoration: none;
}

.nav-item.active {
  background: var(--pink-50);
}

.nav-icon {
  width: 24px;
  height: 24px;
  color: var(--color-text-subtle);
}

.nav-item.active .nav-icon {
  color: var(--pink-600);
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-subtle);
}

.nav-item.active .nav-label {
  color: var(--pink-600);
}


/* -------------------------------------------------------------
   13. TAGS & BADGES
   ------------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.tag-pink   { background: var(--pink-100);   color: var(--pink-800); }
.tag-yellow { background: var(--yellow-100); color: var(--yellow-800); }
.tag-lilac  { background: var(--lilac-100);  color: var(--lilac-800); }
.tag-peach  { background: var(--peach-100);  color: var(--peach-800); }
.tag-neutral{ background: var(--neutral-200); color: var(--neutral-600); }


/* -------------------------------------------------------------
   14. UTILITY CLASSES
   ------------------------------------------------------------- */

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

.divider {
  border: none;
  border-top: 0.5px solid var(--color-border);
  margin: var(--space-4) 0;
}

.rounded-full { border-radius: var(--radius-full); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }

.mt-4  { margin-top: var(--space-4); }
.mb-4  { margin-bottom: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-6  { margin-bottom: var(--space-6); }

.p-4   { padding: var(--space-4); }
.px-4  { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4  { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1       { flex: 1; }

.hidden { display: none; }

/* Loading state */
.skeleton {
  background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-200) 50%, var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  text-align: center;
}

.empty-state__title {
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--color-text);
}

.empty-state__body {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  max-width: 260px;
  line-height: var(--line-height-loose);
}


/* -------------------------------------------------------------
   15. ANIMATIONS
   ------------------------------------------------------------- */

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

.fade-in {
  animation: fade-in 0.2s ease forwards;
}

@keyframes check-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.check-pop {
  animation: check-pop 0.2s ease;
}


/* -------------------------------------------------------------
   16. MEDIA QUERIES
   ------------------------------------------------------------- */

/* Slightly more breathing room on larger phones */
@media (min-width: 390px) {
  .page {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
}

/* Tablet — centre the app column */
@media (min-width: 600px) {
  body {
    background: var(--neutral-200);
  }

  .page {
    max-width: 520px;
    margin: 0 auto;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }

  .bottom-nav {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 0.5px solid var(--color-border);
    border-right: 0.5px solid var(--color-border);
  }

  .auth-page {
    max-width: 520px;
  }
}

/* Desktop — side nav instead of bottom nav */
@media (min-width: 960px) {
  body {
    background: var(--neutral-200);
    display: flex;
    min-height: 100vh;
    padding-bottom: 0;
  }

  /* App shell: sidebar + content */
  .app-shell {
    display: flex;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100vh;
  }

  /* Side nav */
  .bottom-nav {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    max-width: none;
    width: 200px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: var(--space-8) var(--space-3);
    border-top: none;
    border-right: 0.5px solid var(--color-border);
    border-left: none;
    gap: var(--space-1);
    flex-shrink: 0;
    background: var(--color-surface);
    order: -1;
  }

  .nav-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    min-height: auto;
    border-radius: var(--radius-md);
  }

  .nav-label {
    font-size: var(--font-size-sm);
  }

  /* Wordmark above side nav */
  .bottom-nav::before {
    content: 'Eanchainn';
    display: block;
    font-size: var(--font-size-md);
    font-weight: 500;
    letter-spacing: -0.02em;
    background: var(--gradient-sunshine);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 0 var(--space-3);
    margin-bottom: var(--space-6);
  }

  /* Main content area */
  .page {
    max-width: 640px;
    margin: 0;
    padding: var(--space-8) var(--space-8);
    padding-bottom: var(--space-8);
    flex: 1;
    background: var(--neutral-100);
    min-height: 100vh;
  }

  .auth-page {
    max-width: 480px;
    margin: 0 auto;
  }
}


/* -------------------------------------------------------------
   17. AUTH PAGES
   Auth pages don't use the bottom nav — they use a simpler
   centred layout with no padding-bottom for the nav bar.
   ------------------------------------------------------------- */

.auth-page {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.auth-logo {
  margin-bottom: var(--space-8);
  text-align: center;
}

.auth-card {
  width: 100%;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-title {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.auth-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: var(--line-height-loose);
}

.auth-footer-link {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Alerts */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-loose);
  border: 0.5px solid transparent;
}

.alert-error {
  background: #FFF1F2;
  border-color: #FECDD3;
  color: #9F1239;
}

.alert-success {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #166534;
}

.alert-warning {
  background: var(--yellow-50);
  border-color: var(--yellow-200);
  color: var(--yellow-800);
}

/* Checkbox row */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
}

.form-checkbox {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--pink-400);
  cursor: pointer;
}

.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}

/* Code input (TOTP / backup) */
.form-input--code {
  font-family: var(--font-mono);
  font-size: var(--font-size-xl);
  letter-spacing: 0.25em;
  text-align: center;
}

/* MFA setup */
.mfa-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.qr-code {
  padding: var(--space-3);
  background: #fff;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--color-border);
}

.mfa-manual summary {
  cursor: pointer;
  color: var(--pink-600);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-2) 0;
}

.mfa-manual-key {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  letter-spacing: 0.1em;
  background: var(--neutral-50);
  border: 0.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  word-break: break-all;
  color: var(--color-text);
}

.mfa-manual-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
  margin-top: var(--space-2);
}

/* Backup codes */
.backup-code-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.backup-code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  letter-spacing: 0.08em;
  background: var(--neutral-50);
  border: 0.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  text-align: center;
}

/* Alpine.js — hide x-cloak elements before init */
[x-cloak] { display: none !important; }

/* ============================================================
   18. Routines
   ============================================================ */

.routine-card {
  transition: opacity 0.2s;
}

.routine-card--done {
  opacity: 0.65;
}

/* Accordion summary row (tap to expand) */
.routine-card__summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.routine-card__chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--color-text-subtle);
  transition: transform 0.2s ease;
}

.routine-card__chevron.open {
  transform: rotate(180deg);
}

/* Progress bar */
.routine-progress {
  height: 4px;
  background: var(--neutral-100);
  border-radius: 2px;
  overflow: hidden;
}

.routine-progress__bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.25s ease;
}

/* Routine toggle button (mark whole routine done) */
.routine-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-border-strong);
  background: transparent;
  color: var(--color-text-subtle);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.routine-toggle-btn.done {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.routine-toggle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Step rows */
.routine-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  background: none;
  border: none;
  padding: var(--space-2) 0;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.routine-step:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.routine-step__check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  background: transparent;
  flex-shrink: 0;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.routine-step.done .routine-step__check {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.routine-step__text {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  transition: text-decoration 0.1s;
}

.routine-step.done .routine-step__text {
  text-decoration: line-through;
  color: var(--color-text-subtle);
}

/* Day toggle buttons (edit form) */
.day-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: transparent;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-subtle);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.day-btn.active,
.day-btn[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* Streak tag */
.tag-streak {
  background: var(--sunshine-50, #fefce8);
  color: var(--sunshine-700, #a16207);
  border: 0.5px solid var(--sunshine-200, #fef08a);
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

/* Small secondary button */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
}

/* ============================================================
   19. Dopamine (impulse / food / caffeine quick-log)
   ============================================================ */

.dopamine-grid,
.urge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.dopamine-btn,
.urge-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background: var(--neutral-50);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  min-height: 72px;
  text-align: center;
}

.dopamine-btn:hover,
.urge-btn:hover {
  background: var(--pink-50);
  border-color: var(--color-primary-border);
}

.dopamine-btn.selected,
.urge-btn.selected {
  background: var(--pink-50);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--pink-200);
}

.dopamine-btn:disabled,
.urge-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.dopamine-btn__icon,
.urge-btn__icon {
  font-size: 24px;
  line-height: 1;
}

.dopamine-btn__label,
.urge-btn__label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  line-height: var(--line-height-tight);
}

.dopamine-btn.selected .dopamine-btn__label,
.urge-btn.selected .urge-btn__label {
  color: var(--pink-600);
}

/* Quick-log confirmation banner */
.quick-log-confirm {
  font-size: var(--font-size-sm);
  color: var(--pink-600);
  padding: var(--space-2) var(--space-3);
  background: var(--pink-50);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  text-align: center;
}

/* ============================================================
   20. History / Journal
   ============================================================ */

/* Mood dots — coloured circles used in day summaries and timeline */
.mood-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mood-dot--green  { background: #4ade80; }
.mood-dot--amber  { background: #fbbf24; }
.mood-dot--red    { background: #f87171; }

/* Day card */
.history-day__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.history-day__chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--color-text-subtle);
  transition: transform 0.2s ease;
}
.history-day__chevron.open { transform: rotate(180deg); }

.history-day__date {
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}

.history-day__summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-left: auto;
}

.history-day__pill {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  background: var(--neutral-100);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-2);
  white-space: nowrap;
}

/* Timeline */
.history-timeline {
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.history-event {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.history-event__time {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
  white-space: nowrap;
  min-width: 36px;
  padding-top: 2px;
}

.history-event__icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.history-event__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-event__label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.history-event__note {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ============================================================
   21. App shell (desktop layout wrapper)
   ============================================================ */

.app-shell {
  display: contents; /* on mobile, transparent — nav is fixed, page is direct child of body */
}

@media (min-width: 960px) {
  .app-shell {
    display: flex;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100vh;
  }
}

/* ============================================================
   21. Tasks
   ============================================================ */

.task-group {
  margin-bottom: var(--space-6);
}

.task-group__label {
  display: block;
  margin-bottom: var(--space-3);
}

.task-group__label--overdue {
  color: var(--traffic-red-text);
}

.task-group__toggle {
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
  width: 100%;
}

.task-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--color-border);
  padding: var(--space-3) var(--space-3);
  transition: opacity 0.2s;
}

.task-card__summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.task-card__chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--color-text-subtle);
  transition: transform 0.2s ease;
}

.task-card__chevron.open {
  transform: rotate(180deg);
}

.task-items {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
  margin-left: calc(-1 * var(--space-3));
  margin-right: calc(-1 * var(--space-3));
  padding: 0 var(--space-3);
}

.task-card--done {
  opacity: 0.5;
}

.task-card.task-priority--high {
  border-left: 3px solid var(--traffic-red-dot);
}

.task-card.task-priority--low {
  border-left: 3px solid var(--neutral-200);
}

.task-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  background: transparent;
  color: transparent;
  cursor: pointer;
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.task-check.done {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.task-check:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.task-card__title {
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: var(--line-height-tight);
  transition: text-decoration 0.1s, color 0.1s;
}

.task-card__title--done {
  text-decoration: line-through;
  color: var(--color-text-subtle);
}

.task-card__edit {
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.task-card:hover .task-card__edit {
  opacity: 1;
}

.tag-overdue {
  background: var(--traffic-red-bg);
  color: var(--traffic-red-text);
  border: 0.5px solid var(--traffic-red-border);
}

.tag-priority--high {
  background: var(--traffic-red-bg);
  color: var(--traffic-red-text);
}

.tag-priority--low {
  background: var(--neutral-100);
  color: var(--color-text-subtle);
}

/* =============================================================
   OFFLINE SUPPORT
   ============================================================= */

/* Banner — shown when navigator.onLine is false */
#offline-banner[hidden] { display: none; }
#offline-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--neutral-800);
  color: #fff;
  font-size: var(--font-size-sm);
  text-align: center;
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

#offline-banner::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--traffic-amber-dot);
  flex-shrink: 0;
}

/* Toast — bottom-centre, appears briefly on save/sync */
#offline-toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height, 64px) + var(--space-4));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--neutral-800);
  color: #fff;
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}

#offline-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
