/* ============================================
   MOMENTUM — VISIONARY LIFE PLANNER
   Premium Design System
   ============================================ */

:root {
  --primary: #3a86ff;
  --secondary: #2ec4b6;
  --primary-rgb: 58, 134, 255;
  --secondary-rgb: 46, 196, 182;
  --gradient: linear-gradient(135deg, #3a86ff 0%, #2ec4b6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(var(--primary-rgb),0.12) 0%, rgba(var(--secondary-rgb),0.12) 100%);
  --gradient-warm: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-rose: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-amber: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  --gradient-green: linear-gradient(135deg, #96fbc4 0%, #f9f586 100%);

  --bg: #f7fafc;
  --bg-soft: #edf7f6;
  --card: #ffffff;
  --card-soft: #f8fbfd;

  --text: #1c1c1e;
  --text-muted: #6b7280;
  --text-soft: #64748b; /* was #94a3b8 — darkened for WCAG AA contrast (5.7:1 on white) */

  --border: #e5e7eb;
  --border-soft: #f0f4f8;

  --shadow-xs: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-card: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-elevated: 0 4px 20px rgba(0,0,0,0.10), 0 1px 6px rgba(0,0,0,0.06);
  --shadow-modal: 0 8px 40px rgba(0,0,0,0.16), 0 2px 12px rgba(0,0,0,0.08);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 0.22s;
  --duration-slow: 0.35s;

  --nav-height: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---- Dark Mode Theme ---- */
body.dark {
  --bg: #0a0f1e;
  --bg-soft: #0d1428;
  --card: #111827;
  --card-soft: #16213a;
  --text: #f2f6fd;
  --text-muted: #9ba5b8;
  --text-soft: #aab8cf;
  --border: rgba(255,255,255,0.07);
  --border-soft: rgba(255,255,255,0.04);
  --gradient-soft: linear-gradient(135deg, rgba(var(--primary-rgb),0.14) 0%, rgba(var(--secondary-rgb),0.14) 100%);
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.5);
  --shadow-card: 0 1px 4px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.5);
  --shadow-elevated: 0 4px 20px rgba(0,0,0,0.6), 0 1px 6px rgba(0,0,0,0.5);
  --shadow-modal: 0 8px 40px rgba(0,0,0,0.7), 0 2px 12px rgba(0,0,0,0.6);
  --primary: #60a5fa; --secondary: #2dd4bf;
  --primary-rgb: 96, 165, 250; --secondary-rgb: 45, 212, 191;
  --gradient: linear-gradient(135deg, #60a5fa 0%, #2dd4bf 100%);
}
/* ---- Colour Themes ---- */
body.theme-violet {
  --primary: #7c3aed; --secondary: #a78bfa;
  --primary-rgb: 124, 58, 237; --secondary-rgb: 167, 139, 250;
  --gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}
body.theme-ember {
  --primary: #f97316; --secondary: #ef4444;
  --primary-rgb: 249, 115, 22; --secondary-rgb: 239, 68, 68;
  --gradient: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
}
body.theme-forest {
  --primary: #059669; --secondary: #10b981;
  --primary-rgb: 5, 150, 105; --secondary-rgb: 16, 185, 129;
  --gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
}
body.theme-rose {
  --primary: #ec4899; --secondary: #f43f5e;
  --primary-rgb: 236, 72, 153; --secondary-rgb: 244, 63, 94;
  --gradient: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
}
body.theme-crimson {
  --primary: #a01018; --secondary: #c1121f;
  --primary-rgb: 160, 16, 24; --secondary-rgb: 193, 18, 31;
  --gradient: linear-gradient(135deg, #a01018 0%, #c1121f 100%);
}
/* ---- Dark mode: lighten theme primaries that are too dark to read on dark backgrounds ---- */
body.dark.theme-violet {
  --primary: #a78bfa; --secondary: #c4b5fd;
  --primary-rgb: 167, 139, 250; --secondary-rgb: 196, 181, 253;
  --gradient: linear-gradient(135deg, #a78bfa 0%, #c4b5fd 100%);
}
body.dark.theme-forest {
  --primary: #10b981; --secondary: #34d399;
  --primary-rgb: 16, 185, 129; --secondary-rgb: 52, 211, 153;
  --gradient: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}
body.dark.theme-crimson {
  --primary: #e53535; --secondary: #ef4444;
  --primary-rgb: 229, 53, 53; --secondary-rgb: 239, 68, 68;
  --gradient: linear-gradient(135deg, #e53535 0%, #ef4444 100%);
}
body.dark.theme-crimson .drag-order-hint {
  opacity: 1 !important;
}
body.dark.theme-rose {
  --primary: #f472b6; --secondary: #f9a8d4;
  --primary-rgb: 244, 114, 182; --secondary-rgb: 249, 168, 212;
  --gradient: linear-gradient(135deg, #f472b6 0%, #f9a8d4 100%);
}

/* Theme swatches in settings — 3-per-row grid so they don't overflow */
.theme-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100px; }
.theme-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2.5px solid transparent; transition: all var(--duration) var(--ease);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active {
  border-color: var(--card);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

body.dark .modal-overlay { background: rgba(0,0,0,0.72); }
body.dark .profile-hero { background: var(--card); border-color: rgba(255,255,255,0.05); }
body.dark .content-card { background: linear-gradient(135deg, rgba(var(--primary-rgb),0.2) 0%, rgba(var(--secondary-rgb),0.2) 100%); border-color: rgba(var(--primary-rgb),0.2); }
body.dark .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Fixed overlay so the status bar area always shows the app background,
   even on Android 15 where edge-to-edge is OS-enforced */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  z-index: 9999;
  pointer-events: none;
}
#app { height: 100%; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; border: none; background: none; outline: none; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-family: inherit; outline: none; border: none; background: none; }

/* ---- Keyboard focus ring — visible only for keyboard nav (not mouse/touch) ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
/* Inputs and textareas get their own border-based focus indicator */
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
a { color: inherit; text-decoration: none; }
svg { display: block; }
img { display: block; max-width: 100%; }

/* ---- Splash Screen ---- */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  background: #0a0a14;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease;
}
.splash.hiding { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-mark {
  width: 96px; height: 96px; border-radius: 30px;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6), 0 0 30px rgba(0,200,255,0.22), 0 0 60px rgba(0,150,255,0.08);
  animation: splashPulse 1s var(--ease-spring) 0.2s both;
}
.splash-mark svg { width: 60px; height: 60px; filter: drop-shadow(0 0 18px rgba(0,200,255,0.45)); }
.splash-logo-img { width: 78px; height: 78px; object-fit: contain; border-radius: 0; }
.splash-title { font-size: 22px; font-weight: 700; color: #ffffff; letter-spacing: -0.3px; animation: splashUp 0.5s var(--ease) 0.5s both; }
.splash-sub { font-size: 13px; color: rgba(255,255,255,0.45); margin-top: 4px; animation: splashUp 0.5s var(--ease) 0.7s both; }

@keyframes splashPulse { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes splashUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Layout ---- */
.main {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}
.pages {
  flex: 1; overflow: hidden;
  position: relative;
}
.page {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  padding-bottom: calc(var(--safe-bottom) + 4px);
  display: none;
}
.page.active { display: block; }
.page.page-enter { animation: pageEnter 0.28s var(--ease) both; }
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 14px;
}

/* ---- Bottom Navigation ---- */
.bottom-nav {
  position: relative; z-index: 100;
  padding: 0 12px calc(var(--safe-bottom)) 12px;
  background: var(--bg);
  pointer-events: none;
  margin-top: -var(--nav-height);
}
.nav-inner {
  display: flex; align-items: stretch;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-elevated);
  padding: 6px 4px;
  pointer-events: all;
  border: 1px solid var(--border-soft);
  height: var(--nav-height);
  max-width: 600px; margin: 0 auto;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 4px 2px;
  border-radius: 14px;
  color: var(--text-soft);
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
  position: relative;
}
.nav-item:active { transform: scale(0.93); }
.nav-item span {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
}
.nav-icon { width: 20px; height: 20px; }
.nav-item.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb),0.08);
}
.nav-item.active .nav-icon { stroke: var(--primary); }

/* ---- Page Header ---- */
.page-header {
  padding: calc(env(safe-area-inset-top, 12px) + 4px) 14px 0;
  max-width: 600px; margin: 0 auto;
}
.page-header-row {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.page-title {
  font-size: 20px; font-weight: 700;
  color: var(--text); letter-spacing: -0.3px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 12px; color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Btn System ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 16px; height: 36px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: var(--gradient); color: white;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.3);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(var(--primary-rgb),0.4); filter: brightness(1.05); }
.btn-secondary {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 0 8px; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }
.btn-danger { background: linear-gradient(135deg, #ff6b6b, #ee5a24); color: white; box-shadow: 0 2px 8px rgba(255,107,107,0.3); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-filter-toggle {
  height: 36px; padding: 0 12px; font-size: 12px; font-weight: 600;
  border-radius: var(--radius-xs); flex-shrink: 0; white-space: nowrap;
  border: 1.5px solid rgba(var(--primary-rgb),0.45);
  background: rgba(var(--primary-rgb),0.08); color: var(--primary);
  cursor: pointer; transition: all var(--duration) var(--ease);
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-filter-toggle:hover { background: rgba(var(--primary-rgb),0.15); }
.btn-filter-toggle.active {
  border-color: var(--primary); background: rgba(var(--primary-rgb),0.18);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb),0.12);
}
.filter-chevron { transition: transform 0.2s ease; flex-shrink: 0; }
.btn-filter-toggle._fd-open .filter-chevron { transform: rotate(180deg); }
body.dark .btn-filter-toggle { color: #ffffff; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); flex-shrink: 0; }
.btn-icon-sm { width: 28px; height: 28px; padding: 0; border-radius: var(--radius-xs); }
.btn-add {
  background: var(--gradient); color: white;
  box-shadow: 0 2px 10px rgba(var(--primary-rgb),0.28);
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
}
.btn-add svg { width: 14px; height: 14px; }

/* ---- Card ---- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
}
.card-soft {
  background: var(--card-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.card-inner { padding: 14px; }
.card-sm { border-radius: var(--radius-md); }

/* ---- Section Component ---- */
.section {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  margin-bottom: 10px;
  transition: box-shadow var(--duration) var(--ease);
}
.section:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04); }
.section-header {
  display: flex; align-items: flex-start;
  gap: 10px; padding: 12px 14px;
  cursor: pointer; user-select: none;
  touch-action: manipulation;
  min-height: 52px;
}
.section-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card) padding-box, var(--gradient) border-box;
  border: 2px solid transparent;
  flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
}
.section-icon-inner {
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.section-header-info {
  flex: 1; min-width: 0;
}
.section-title-row {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.section-title {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600;
  color: var(--text); letter-spacing: -0.1px;
}
.section-preview {
  display: block; font-size: 12px; color: var(--text-soft);
  overflow: hidden; white-space: normal; line-height: 1.4;
  max-height: 0; opacity: 0; margin-top: 0;
  transition: max-height 0.25s var(--ease), opacity 0.2s var(--ease), margin-top 0.2s var(--ease);
}
.section:not(.open) .section-preview { max-height: 48px; opacity: 1; margin-top: 2px; }
.section-count {
  font-size: 12px; font-weight: 600;
  color: var(--primary);
  background: rgba(var(--primary-rgb),0.1);
  padding: 2px 7px; border-radius: var(--radius-full);
}
.section-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-top: -2px;
}
.gratitude-add-row {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; padding: 9px 12px; margin-top: 4px;
  background: none; border: none; border-top: 1px solid var(--border-soft);
  color: var(--primary); font-size: 12px; font-weight: 600;
  cursor: pointer; border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: background var(--duration) var(--ease);
}
.gratitude-add-row:hover { background: rgba(var(--primary-rgb),0.05); }
.gratitude-add-row svg { width: 13px; height: 13px; }
.pin-btn {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft);
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.pin-btn:hover { background: var(--bg); color: var(--text-muted); }
.pin-btn.pinned-open { color: var(--primary); }
.pin-btn.pinned-closed { color: var(--text-soft); opacity: 0.6; }
.pin-btn svg { width: 14px; height: 14px; }
.chevron-btn {
  height: 36px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0 4px;
  color: var(--text-soft); cursor: pointer;
  touch-action: manipulation; border: none; background: transparent; flex-shrink: 0;
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease), background var(--duration) var(--ease);
}
.chevron-btn:hover { background: var(--bg); color: var(--text-muted); }
.chevron-btn svg { width: 16px; height: 16px; transition: transform var(--duration) var(--ease); pointer-events: none; }
.section.open .chevron-btn svg { transform: rotate(180deg); }
.section-chevron-label { font-size: 11px; color: var(--text-soft); font-weight: 500; white-space: nowrap; pointer-events: none; }
.section.open .section-chevron-label { display: none; }
.section:not(.open) .section-add-pill { display: none; }
.section-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s var(--ease-out);
}
.section.open .section-body { max-height: 9999px; }
.section-content { padding: 0 14px 14px; }

/* ---- Home Page ---- */
.home-brand {
  display: flex; align-items: center; justify-content: center;
  gap: 7px; padding: calc(env(safe-area-inset-top, 14px) + 4px) 14px 10px;
  max-width: 600px; margin: 0 auto;
}
.home-brand-logo {
  width: 34px; height: 34px; flex-shrink: 0;
  background: #090d1a;
  border-radius: 9px;
  padding: 4px;
  box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,160,255,0.28), 0 1px 3px rgba(0,0,0,0.25);
}
.home-brand-logo svg { width: 26px; height: 26px; }
.home-logo-img { width: 26px; height: 26px; object-fit: contain; border-radius: 0; }
.home-brand-name {
  font-size: 14px; font-weight: 700; letter-spacing: 0.2px;
  color: var(--text);
}

.home-header {
  padding: 12px 14px 16px;
  max-width: 600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.home-header-text { flex: 1; min-width: 0; }
.home-greeting { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.home-greeting span { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.home-date { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Day Picker */
.day-picker-wrap {
  padding: 18px 14px 28px;
  max-width: 600px; margin: 0 auto;
}
.day-picker {
  display: flex; align-items: center; gap: 4px;
}
.day-picker-inner { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.day-month-label { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--primary); letter-spacing: 0.06em; text-transform: uppercase; }
.day-today-pill { font-size: 10px; font-weight: 600; padding: 2px 9px; border-radius: 10px; background: var(--gradient); color: #fff; cursor: pointer; flex-shrink: 0; text-transform: none; letter-spacing: 0; }

/* Home completion ring */
.home-ring-wrap { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 12px; }
.home-ring-inner { position: absolute; text-align: center; line-height: 1; pointer-events: none; }
.home-ring-pct { font-size: 13px; font-weight: 700; color: var(--primary); }
.home-ring-label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* Confetti celebration */
.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden; }
.confetti-particle { position: absolute; top: -12px; animation: confettiFall linear forwards; }
@keyframes confettiFall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(100vh) translateX(var(--dx, 30px)) rotate(var(--rx, 360deg)); opacity: 0; }
}
.day-nav {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; cursor: pointer; flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration) var(--ease);
}
.day-nav:hover { background: var(--bg-soft); color: var(--primary); }
.days-row {
  flex: 1; display: flex; gap: 4px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.days-row::-webkit-scrollbar { display: none; }
.day-btn {
  flex: 1; min-width: 40px; max-width: 56px;
  display: flex; flex-direction: column; align-items: center;
  padding: 7px 4px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
  cursor: pointer; gap: 2px;
}
.day-btn:hover { border-color: var(--primary); color: var(--primary); }
.day-btn.today { border-color: rgba(var(--primary-rgb),0.3); background: rgba(var(--primary-rgb),0.05); }
.day-btn.today .day-num { color: var(--primary); }
.day-btn.selected {
  background: var(--card); border: 2px solid var(--primary);
  color: var(--text); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1);
}
.day-btn .day-name { font-size: 12px; font-weight: 500; letter-spacing: 0.05em; }
.day-btn .day-num { font-size: 18px; font-weight: 700; line-height: 1; }
.day-btn .day-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.5; }
.day-btn.selected .day-dot { background: var(--primary); opacity: 0.8; }
.day-btn.has-data .day-dot { opacity: 1; }

/* Home sections wrapper */
.home-sections { padding: 0 14px 32px; max-width: 600px; margin: 0 auto; }

/* Gratitude */
.gratitude-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.gratitude-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-md); border: 1px solid var(--border);
  transition: all var(--duration) var(--ease);
}
.gratitude-item:hover { background: var(--card-soft); }
.gratitude-item .icon-btn { opacity: 0; pointer-events: none; transition: opacity 0.15s var(--ease); }
.gratitude-item:focus-within .icon-btn,
.gratitude-item:hover .icon-btn { opacity: 1; pointer-events: auto; }
.gratitude-text { flex: 1; font-size: 13px; color: var(--text-soft); line-height: 1.5; word-break: break-word; }
.gratitude-actions { display: flex; gap: 2px; flex-shrink: 0; }
.icon-btn {
  /* Visual: 28px. Tap target: 36px minimum (WCAG 2.5.8 AA) */
  width: 36px; height: 36px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); transition: all var(--duration) var(--ease);
  touch-action: manipulation; cursor: pointer; border: none; background: transparent;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 14px; height: 14px; pointer-events: none; }
.fav-btn.favourited svg { stroke: url(#grad-fav); }
.add-gratitude-row { display: flex; justify-content: center; padding-top: 2px; }

/* Plan/Reflection Tabs */
.plan-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.plan-tab {
  flex: 1; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  transition: all var(--duration) var(--ease); cursor: pointer;
}
.plan-tab.active {
  background: var(--gradient); color: white; border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.25);
}
.plan-panel { display: none; }
.plan-panel.active { display: block; }
.field-group { margin-bottom: 12px; }
.field-label {
  font-size: 12px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px;
  display: block;
}
.field-textarea {
  width: 100%; min-height: 90px; max-height: 200px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 13px; color: var(--text);
  line-height: 1.5; resize: none; overflow-y: scroll;
  transition: border-color var(--duration) var(--ease);
}
.field-textarea:focus { border-color: var(--primary); background: var(--card); }
.field-input-line {
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color var(--duration) var(--ease);
}
.field-input-line:focus { border-color: var(--primary); background: var(--card); outline: none; }
.field-textarea::placeholder { color: var(--text-soft); }

/* ---- Inline add form (gratitude, tasks) ---- */
.inline-add-form {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 4px 0 10px;
}
.inline-add-input {
  flex: 1; padding: 9px 12px;
  background: var(--card); border: 1.5px solid var(--primary);
  border-radius: var(--radius-md); font-size: 13px; color: var(--text);
  outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1);
  resize: none; line-height: 1.5; font-family: inherit;
}
.inline-add-input::placeholder { color: var(--text-soft); }
.inline-add-cancel {
  width: 28px; height: 28px; border-radius: 50%; border: none; flex-shrink: 0;
  background: transparent; color: var(--text-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  margin-top: 6px;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.inline-add-cancel:hover { color: var(--text); background: var(--bg); }

/* Habit completion animation */
@keyframes habitComplete {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.025); box-shadow: 0 6px 24px rgba(var(--primary-rgb),0.28); }
  100% { transform: scale(1); }
}
.habit-complete-anim { animation: habitComplete 0.5s var(--ease-spring) forwards; }

.habit-streak-badge {
  font-size: 12px; font-weight: 700; color: #f97316;
  background: rgba(249,115,22,0.12);
  padding: 2px 7px; border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Habit in Home */
.habit-home-item {
  display: block; background: var(--bg);
  border-radius: var(--radius-md); border: 1px solid var(--border);
  margin-bottom: 6px; overflow: hidden;
  transition: all var(--duration) var(--ease);
}
.habit-home-item-body { display: flex; align-items: center; gap: 10px; padding: 10px 12px 8px; }
.habit-home-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.habit-home-info { flex: 1; min-width: 0; }
.habit-home-title { font-size: 13px; font-weight: 600; color: var(--text); }
.habit-home-sub { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.habit-home-progress {
  height: 3px; background: var(--border); border-radius: var(--radius-full);
  margin-top: 5px; overflow: hidden;
}
.habit-home-progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--gradient); transition: width 0.4s var(--ease); }
.habit-state-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  transition: all var(--duration) var(--ease);
  color: var(--text-soft);
}
.habit-state-btn:hover { border-color: var(--primary); color: var(--primary); }
.habit-state-btn.worked { border-color: #f59e0b; background: rgba(245,158,11,0.1); color: #f59e0b; }
.habit-state-btn.complete { border-color: var(--secondary); background: rgba(var(--secondary-rgb),0.1); color: var(--secondary); }
.habit-qty-row { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.habit-qty-btn {
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-muted); font-weight: 700;
  transition: all var(--duration) var(--ease);
}
.habit-qty-btn:hover { background: var(--bg-soft); color: var(--primary); }
.habit-qty-val { font-size: 13px; font-weight: 600; color: var(--text); min-width: 32px; text-align: center; }

/* Goal Focus Card */
.goal-focus-card {
  display: block; background: var(--bg);
  border-radius: var(--radius-md); border: 1px solid var(--border);
  margin-bottom: 6px; overflow: hidden; cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.goal-focus-card-body { display: flex; align-items: center; gap: 10px; padding: 11px 12px 8px; }
.goal-focus-card:hover { background: var(--card-soft); }
.goal-focus-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.goal-focus-info { flex: 1; min-width: 0; }
.goal-focus-title { font-size: 13px; font-weight: 600; color: var(--text); overflow-wrap: break-word; word-break: break-word; }
.goal-focus-sub { font-size: 12px; color: var(--text-soft); }
.goal-focus-prog { height: 3px; border-radius: var(--radius-full); background: var(--border); margin-top: 4px; overflow: hidden; }
.goal-focus-prog-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.4s var(--ease); }
.goal-state-btn {
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  border: 1.5px solid var(--border); color: var(--text-soft);
  transition: all var(--duration) var(--ease);
}
.goal-state-btn:hover { border-color: var(--primary); color: var(--primary); }
.goal-state-btn.worked { background: rgba(245,158,11,0.1); border-color: #f59e0b; color: #b45309; }
.goal-state-btn.complete { background: rgba(var(--secondary-rgb),0.1); border-color: var(--secondary); color: #0e9f8a; }

/* Lesson/Quote/Affirmation cards */
.content-card {
  background: rgba(var(--primary-rgb),0.08);
  border-radius: var(--radius-md);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  padding: 10px 12px;
}
.content-card-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.content-card-text {
  font-size: 12px; color: var(--text); line-height: 1.6;
}
.content-card-author {
  font-size: 12px; color: var(--text-muted); margin-top: 6px;
  font-style: italic;
}
.content-card-footer {
  display: flex; align-items: center; justify-content: flex-end;
  margin-top: 8px; gap: 6px;
}
.fav-icon-btn {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-soft);
  padding: 4px 8px; border-radius: var(--radius-xs);
  transition: all var(--duration) var(--ease);
}
.fav-icon-btn:hover { background: var(--bg); color: var(--primary); }
.fav-icon-btn svg { width: 14px; height: 14px; }
.fav-icon-btn.favourited { color: var(--primary); }

/* ---- Goals Page ---- */
.filter-tabs {
  display: flex; gap: 4px;
  padding: 0 14px; max-width: 600px; margin: 0 auto 10px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  padding-bottom: 2px;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0; padding: 5px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.filter-tab.active {
  background: var(--gradient); color: white; border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.25);
}
.goals-list { padding: 0 14px; max-width: 600px; margin: 0 auto; }
.goal-card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); border: 1px solid var(--border-soft);
  overflow: hidden; margin-bottom: 10px; cursor: grab;
  transition: all var(--duration) var(--ease);
}
.goal-card:hover { box-shadow: var(--shadow-elevated); transform: translateY(-1px); }
.goal-card-accent { display: none; }
.goal-card-body { padding: 12px 14px; }
.goal-card-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.goal-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.goal-card-meta { flex: 1; min-width: 0; }
.goal-card-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.1px; }
.goal-card-category { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.goal-status-badge {
  padding: 3px 8px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-active { background: rgba(var(--secondary-rgb),0.12); color: #0e9f8a; }
.badge-paused { background: rgba(245,158,11,0.12); color: #b45309; }
.badge-completed { background: rgba(var(--primary-rgb),0.12); color: var(--primary); }
.badge-archived { background: var(--bg); color: var(--text-soft); }
.goal-progress-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.goal-progress-bar {
  flex: 1; height: 6px; background: var(--border);
  border-radius: var(--radius-full); overflow: hidden;
}
.goal-progress-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.6s var(--ease); }
.goal-progress-pct { font-size: 12px; font-weight: 700; color: var(--text-muted); min-width: 30px; text-align: right; }
.goal-card-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-top: 1px solid var(--border-soft);
  background: var(--card-soft);
}
.goal-meta-chip {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-soft);
}
.goal-meta-chip svg { width: 12px; height: 12px; }

/* Goal Detail */
.goal-detail { padding: 0 14px 14px; max-width: 600px; margin: 0 auto; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--primary);
  padding: 8px 0; margin-bottom: 4px;
}
.back-btn svg { width: 16px; height: 16px; }
.goal-detail-hero {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); border: 1px solid var(--border-soft);
  overflow: hidden; margin-bottom: 12px;
}
.goal-detail-accent { height: 6px; }
.goal-detail-body { padding: 16px; }
.goal-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.goal-detail-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.goal-detail-title { font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.goal-detail-category { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.detail-section { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); border: 1px solid var(--border-soft); padding: 14px; margin-bottom: 10px; }
.detail-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.detail-section-title svg { width: 14px; height: 14px; color: var(--primary); }
.milestone-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.milestone-item:last-child { border-bottom: none; padding-bottom: 0; }
.milestone-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--duration) var(--ease);
}
.milestone-check.done { background: var(--gradient); border-color: transparent; }
.milestone-check.done svg { display: block; }
.milestone-check svg { display: none; width: 10px; height: 10px; stroke: white; stroke-width: 2.5; }
.milestone-info { flex: 1; }
.milestone-title { font-size: 13px; color: var(--text-soft); }
.milestone-date { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.milestone-title.done { color: var(--text-soft); }

/* ---- Habits Page ---- */
.habits-stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 0 14px; max-width: 600px; margin: 0 auto 12px;
}
.stat-chip {
  background: var(--card); border-radius: var(--radius-md);
  border: 1px solid var(--border-soft); box-shadow: var(--shadow-xs);
  padding: 10px 12px; text-align: center;
}
.stat-chip-val { font-size: 20px; font-weight: 700; color: var(--text); background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-chip-label { font-size: 10px; color: var(--text-soft); margin-top: 2px; font-weight: 500; }
.search-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 0 14px; max-width: 600px; margin: 0 auto 10px;
}
.search-input-wrap {
  flex: 1 1 100%; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0 12px;
  box-shadow: var(--shadow-xs);
}
.search-input-wrap svg { width: 15px; height: 15px; color: var(--text-soft); flex-shrink: 0; }
.search-input { flex: 1; height: 36px; font-size: 16px; color: var(--text); }
.search-input::placeholder { color: var(--text-soft); }
.habits-list { padding: 0 14px; max-width: 600px; margin: 0 auto; }
.habit-card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); border: 1px solid var(--border-soft);
  overflow: hidden; margin-bottom: 8px; cursor: grab;
  transition: all var(--duration) var(--ease);
}
.habit-card:hover { box-shadow: var(--shadow-elevated); }
.habit-card:active { cursor: grabbing; }
.habit-card button, .habit-card a { cursor: pointer; }
.goal-card:active { cursor: grabbing; }
.goal-card button, .goal-card a { cursor: pointer; }
.habit-card-inner { padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; }
.habit-card-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; margin-top: 2px;
}
.habit-card-info { flex: 1; min-width: 0; }
.habit-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.habit-card-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.habit-card-streak {
  display: flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.habit-card-streak svg { width: 13px; height: 13px; }
.habit-card-prog { padding: 0 14px 10px; }
.habit-prog-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.habit-prog-bar { height: 5px; background: var(--border); border-radius: var(--radius-full); overflow: hidden; }
.habit-prog-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.5s var(--ease); }
.habit-card-footer {
  display: flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-top: 1px solid var(--border-soft);
  background: var(--card-soft);
}
.habit-footer-calendar {
  display: flex; align-items: center; gap: 3px; margin-left: auto;
  background: none; border: none; cursor: pointer; touch-action: manipulation;
  font-size: 12px; font-weight: 500; color: var(--text-soft); padding: 0 2px;
}
.habit-footer-calendar svg { width: 12px; height: 12px; }
.habit-footer-calendar .cal-chevron { transition: transform 0.2s; }
.habit-footer-calendar.active .cal-chevron { transform: rotate(180deg); }
/* Shared footer strip for home + actions tiles */
.tile-footer {
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap;
  padding: 7px 12px; border-top: 1px solid var(--border-soft);
  background: var(--card-soft);
}

/* ---- Habit heatmap ---- */
.heatmap-toggle-btn {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration) var(--ease);
}
.heatmap-toggle-btn svg { width: 13px; height: 13px; }
.heatmap-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }
.heatmap-toggle-btn.active { background: rgba(var(--primary-rgb),0.1); border-color: var(--primary); color: var(--primary); }
.habit-card-heatmap { border-top: 1px solid var(--border-soft); }
.habit-heatmap { padding: 10px 14px 12px; }
.heatmap-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-soft); margin-bottom: 8px;
}
.heatmap-wrap { display: flex; gap: 4px; width: 100%; }
.heatmap-days {
  display: grid; grid-template-rows: repeat(7, 11px);
  gap: 2px; flex-shrink: 0;
}
.heatmap-day-label {
  font-size: 8px; color: var(--text-soft); line-height: 11px;
  text-align: right; width: 8px;
}
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-template-columns: repeat(13, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  flex: 1;
}
.heatmap-cell { border-radius: 2px; height: 11px; }
.heatmap-today { outline: 1.5px solid var(--primary); outline-offset: 1px; border-radius: 2px; }
.heatmap-legend {
  display: flex; align-items: center; gap: 3px;
  margin-top: 8px; font-size: 10px; color: var(--text-soft);
}
.heatmap-legend .heatmap-cell { flex-shrink: 0; }

.template-section { padding: 0 14px; max-width: 600px; margin: 0 auto 10px; }
.template-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.template-section-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.1), rgba(var(--secondary-rgb),0.07));
  border: 1.5px solid rgba(var(--primary-rgb),0.25);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 10px;
}
.template-section-banner-icon { font-size: 22px; flex-shrink: 0; }
.template-section-banner-text { flex: 1; min-width: 0; }
.template-section-banner-title { font-size: 13px; font-weight: 700; color: var(--text); }
.template-section-banner-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.template-tile {
  background: var(--card); border-radius: var(--radius-md);
  border: 1px solid var(--border); padding: 10px 12px;
  cursor: pointer; transition: all var(--duration) var(--ease);
  display: flex; align-items: flex-start; gap: 8px;
}
.template-tile:hover { background: var(--bg-soft); border-color: var(--primary); }
.template-tile-icon { font-size: 20px; }
.template-tile-info { }
.template-tile-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: normal; word-wrap: break-word; }
.template-tile-sub { font-size: 12px; color: var(--text-soft); }

/* ---- Tasks Page ---- */
.tasks-wrap { padding: 0 14px; max-width: 600px; margin: 0 auto; }
.task-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 8px 0 6px; display: flex; align-items: center; gap: 6px;
}
.task-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.task-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs); border: 1px solid var(--border-soft);
  padding: 10px 12px; margin-bottom: 6px;
  transition: all var(--duration) var(--ease); cursor: pointer;
}
.task-item:hover { box-shadow: var(--shadow-sm); }
.task-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration) var(--ease); cursor: pointer;
}
.task-check:hover { border-color: var(--primary); }
.task-check.done { background: var(--gradient); border-color: transparent; }
.task-check svg { display: none; width: 11px; height: 11px; stroke: white; stroke-width: 2.5; }
.task-check.done svg { display: block; }
.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 400; color: var(--text-soft); }
.task-title.done { color: var(--text-soft); }
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.task-due { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 3px; }
.task-due svg { width: 11px; height: 11px; }
.task-due.overdue { color: #ef4444; }
.priority-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.priority-dot.priority-high { background: #ef4444; }
.priority-dot.priority-medium { background: var(--primary); }
.priority-dot.priority-low { background: var(--secondary); }
.priority-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px; flex-shrink: 0; letter-spacing: 0.02em; }
.priority-badge.priority-high { background: rgba(239,68,68,0.12); color: #ef4444; }
.priority-badge.priority-medium { background: rgba(var(--primary-rgb),0.12); color: var(--primary); }
.priority-badge.priority-low { background: rgba(var(--secondary-rgb),0.12); color: var(--secondary); }
.task-goal-tag {
  font-size: 10px; font-weight: 600; padding: 2px 6px;
  border-radius: var(--radius-full); border: 1px solid;
}
.task-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ---- Insights Page ---- */
.insights-wrap { padding: 0 14px; max-width: 600px; margin: 0 auto; }
.insights-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.insight-card {
  background: var(--card); border-radius: var(--radius-md);
  border: 1px solid var(--border); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.insight-card-full { grid-column: 1 / -1; }
.insight-card-icon { font-size: 20px; flex-shrink: 0; }
.insight-card-body { flex: 1; min-width: 0; }
.insight-card-val { font-size: 14px; font-weight: 700; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.2; }
.insight-card-label { font-size: 12px; color: var(--text); font-weight: 600; margin-top: 1px; }
.insight-card-sub { font-size: 10px; color: var(--text-soft); margin-top: 1px; }
.insight-section-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; letter-spacing: -0.1px; }
.chart-range-btn { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full); border: 1px solid var(--border); background: transparent; color: var(--text-soft); cursor: pointer; transition: all var(--duration) var(--ease); }
.chart-range-btn.active { background: var(--gradient); color: white; border-color: transparent; }
.chart-range-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }
.habit-rank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft);
}
.habit-rank-item:last-child { border-bottom: none; }
.habit-rank-num { font-size: 12px; font-weight: 700; color: var(--text-soft); min-width: 18px; }
.habit-rank-icon { font-size: 18px; }
.habit-rank-info { flex: 1; min-width: 0; }
.habit-rank-name { font-size: 13px; font-weight: 500; color: var(--text); }
.habit-rank-pct { font-size: 12px; color: var(--text-soft); }
.habit-rank-bar { flex-shrink: 0; width: 60px; height: 6px; background: var(--border); border-radius: var(--radius-full); overflow: hidden; }
.habit-rank-fill { height: 100%; border-radius: var(--radius-full); }
/* SVG Chart */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { width: 100%; display: block; }

/* ---- Inspire Page — Premium Library ---- */
.inspire-wrap { padding: 0 14px 20px; max-width: 600px; margin: 0 auto; }
.inspire-search-row { margin-top: 12px; margin-bottom: 10px; }
.inspire-filter-row { display: flex; gap: 6px; margin-bottom: 14px; }
.inspire-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--text-muted); background: var(--card);
  transition: all var(--duration) var(--ease);
}
.inspire-chip.active { background: var(--gradient); color: white; border-color: transparent; box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.25); }
.inspire-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-soft); margin-bottom: 6px;
}
.inspire-cats { display: flex; flex-direction: column; gap: 5px; }
.inspire-cat-section {
  background: var(--card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft); box-shadow: var(--shadow-xs); overflow: hidden;
}
.inspire-cat-header {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 13px; cursor: pointer; user-select: none; min-height: 46px;
  background: none; border: none; text-align: left;
}
.inspire-cat-icon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--card) padding-box,
              linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) border-box;
  border: 1.5px solid transparent;
}
.inspire-cat-title { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.inspire-cat-count { font-size: 12px; color: var(--text-soft); flex-shrink: 0; }
.inspire-chevron { width: 15px; height: 15px; color: var(--text-soft); flex-shrink: 0; transition: transform var(--duration) var(--ease); }
.inspire-cat-section.open > .inspire-cat-header > .inspire-chevron { transform: rotate(180deg); }
.inspire-cat-body { overflow: hidden; transition: max-height 0.35s var(--ease), opacity 0.25s var(--ease); }
.inspire-lessons-list { padding: 2px 10px 10px; display: flex; flex-direction: column; gap: 5px; }
.inspire-card-list { padding: 2px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.inspire-empty-inner { padding: 12px 14px; font-size: 12px; color: var(--text-soft); font-style: italic; }
.inspire-lesson-tile {
  background: var(--bg); border-radius: var(--radius-md);
  border: 1px solid var(--border-soft); padding: 10px 11px;
  transition: border-color var(--duration) var(--ease);
}
.inspire-lesson-tile:hover { border-color: rgba(var(--primary-rgb),0.2); }
.inspire-lesson-row { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.inspire-lesson-info { flex: 1; min-width: 0; }
.inspire-lesson-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35; }
.inspire-lesson-meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.inspire-lesson-acts { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-top: 1px; }
.inspire-lesson-tile.open .inspire-lesson-acts .inspire-chevron { transform: rotate(180deg); }
.inspire-lesson-preview { font-size: 12px; color: var(--text-muted); line-height: 1.55; margin-top: 5px; }
.inspire-lesson-preview.hidden { display: none; }
.inspire-item-body { overflow: hidden; transition: max-height 0.4s var(--ease), opacity 0.3s var(--ease); }
.inspire-para { font-size: 13px; color: var(--text-muted); line-height: 1.72; margin-top: 10px; font-weight: 400; }
.inspire-para:first-child { margin-top: 8px; }
.inspire-fav-btn {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); flex-shrink: 0; transition: all var(--duration) var(--ease);
}
.inspire-fav-btn:hover { background: var(--gradient-soft); color: var(--primary); }
.inspire-fav-btn.active { color: var(--primary); }
.inspire-quote-card {
  background: rgba(var(--primary-rgb),0.07); border-radius: var(--radius-md);
  border: 1px solid rgba(var(--primary-rgb),0.12); padding: 12px 13px;
}
.inspire-quote-text { font-size: 13px; font-style: italic; line-height: 1.68; color: var(--text-soft); }
.inspire-quote-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.inspire-quote-author { font-size: 12px; color: var(--text-soft); font-style: italic; }
.inspire-aff-card {
  background: rgba(var(--secondary-rgb),0.07);
  border-radius: var(--radius-md); border: 1px solid rgba(var(--secondary-rgb),0.12); padding: 12px 13px;
}
.inspire-aff-text { font-size: 13px; font-weight: 400; line-height: 1.62; color: var(--text-soft); }
.inspire-aff-footer { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ---- Settings Page ---- */
.settings-wrap { padding: 0 14px; max-width: 600px; margin: 0 auto; }
.settings-section { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); border: 1px solid var(--border-soft); overflow: hidden; margin-bottom: 10px; }
.settings-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft);
  transition: background var(--duration) var(--ease); cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: var(--bg); }
.settings-row-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
  background: var(--card) padding-box,
              linear-gradient(135deg, rgba(var(--primary-rgb),0.15), rgba(var(--secondary-rgb),0.15)) border-box;
  border: 1.5px solid transparent;
}
.settings-row-info { flex: 1; }
.settings-row-title { font-size: 14px; font-weight: 500; color: var(--text); }
.settings-row-sub { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.settings-row-right { display: flex; align-items: center; gap: 6px; color: var(--text-soft); }
.settings-row-right svg { width: 15px; height: 15px; }
.settings-row-value { font-size: 13px; color: var(--text-soft); }
.toggle {
  width: 40px; height: 24px; border-radius: var(--radius-full);
  background: var(--border); position: relative; cursor: pointer;
  transition: background var(--duration) var(--ease); flex-shrink: 0;
}
.toggle.on { background: var(--gradient); }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform var(--duration) var(--ease-spring);
}
.toggle.on::after { transform: translateX(16px); }
.profile-hero {
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.10) 0%, rgba(var(--secondary-rgb),0.06) 100%); padding: 20px 16px;
  display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
  border-radius: var(--radius-lg); border: 1px solid rgba(var(--primary-rgb),0.15);
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--gradient); display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: white; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb),0.3);
}
.profile-name { font-size: 17px; font-weight: 700; color: var(--text); }
.profile-type { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.profile-badge { display: inline-flex; align-items: center; gap: 4px; background: var(--card); color: var(--primary); border: 1.5px solid rgba(var(--primary-rgb),0.45); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: var(--radius-full); margin-top: 4px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.50);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-box {
  width: 100%; max-width: 600px;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.22);
  max-height: 90vh; overflow-y: auto;
  padding-bottom: calc(var(--safe-bottom) + 16px);
  animation: modalUp 0.3s var(--ease-spring) both;
}
@keyframes modalUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 10px auto 0; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--gradient);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-title { font-size: 17px; font-weight: 700; color: #ffffff; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center;
  color: #ffffff; font-size: 18px; line-height: 1;
  transition: all var(--duration) var(--ease);
}
.modal-close:hover { background: rgba(255,255,255,0.30); color: #ffffff; }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border-soft);
}
.modal-footer.modal-footer--stack { flex-direction: column; align-items: stretch; }
.modal-footer.modal-footer--stack .btn { width: 100%; justify-content: center; }

/* Form Elements */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 5px; }
#gp-body .form-label, #hp-body .form-label, #tp-body .form-label { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text-soft); }
.form-input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 16px; color: var(--text-soft);
  transition: border-color var(--duration) var(--ease);
}
.form-input:focus { border-color: var(--primary); background: var(--card); }
.form-textarea {
  width: 100%; min-height: 80px; padding: 10px 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 16px; color: var(--text-soft);
  line-height: 1.5; resize: none;
  transition: border-color var(--duration) var(--ease);
}
.form-textarea:focus { border-color: var(--primary); background: var(--card); }
.form-select {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 16px; color: var(--text-soft);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-picker-grid, .color-picker-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-option {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--bg); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.icon-option:hover { border-color: var(--primary); background: var(--gradient-soft); }
.icon-option.selected { border-color: var(--primary); background: var(--gradient-soft); }
.color-option {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  transition: all var(--duration) var(--ease); border: 3px solid transparent;
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: var(--text); transform: scale(1.15); }

/* Confirm Dialog */
#confirm-overlay {
  background: rgba(0,0,0,0.45);
  align-items: flex-end;
}
body.dark #confirm-overlay { background: rgba(0,0,0,0.65); }
.confirm-box {
  background: var(--card); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 3px solid var(--primary);
  width: 100%; max-width: 400px;
  padding: 20px 20px calc(var(--safe-bottom) + 20px);
  box-shadow: var(--shadow-modal);
  animation: modalUp 0.25s var(--ease-spring) both;
}
.confirm-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.confirm-text { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 16px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

/* Toast */
.toast-container { position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px); left: 0; right: 0; z-index: 600; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--gradient); color: #ffffff;
  border-radius: var(--radius-full);
  border-left: none;
  box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.35);
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  max-width: 340px; text-align: center;
  animation: toastIn 0.25s var(--ease-spring) both;
  pointer-events: all;
}
.toast.success { background: var(--gradient); box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.35); }
.toast.error   { background: linear-gradient(135deg,#ef4444,#dc2626); box-shadow: 0 4px 20px rgba(239,68,68,0.40); }
.toast.primary { background: var(--gradient); box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.35); }
.toast.info    { background: linear-gradient(135deg,#3b82f6,#2563eb); box-shadow: 0 4px 20px rgba(59,130,246,0.40); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(0.95); } }

/* Settings inline section feedback — appears directly below the triggering section */
.settings-inline-feedback {
  margin: 2px 14px 8px; padding: 8px 12px;
  border-radius: 10px; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  animation: toastIn 0.2s var(--ease) both;
}
.settings-inline-feedback.success { color: #10b981; background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.2); }
.settings-inline-feedback.primary { color: var(--primary); background: rgba(var(--primary-rgb),0.08); border: 1px solid rgba(var(--primary-rgb),0.2); }
.settings-inline-feedback.error   { color: #ef4444;  background: rgba(239,68,68,0.08);  border: 1px solid rgba(239,68,68,0.2);  }
.settings-inline-feedback.default { color: var(--text-muted); background: var(--bg-soft); border: 1px solid var(--border); }

/* Empty State */
.empty-state { text-align: center; padding: 24px 20px; }
.empty-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.5; display: flex; justify-content: center; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.empty-text { font-size: 13px; color: var(--text-soft); line-height: 1.5; }

/* Gradient SVG definitions */
.svg-defs { position: absolute; width: 0; height: 0; }

/* Misc utilities */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; } .mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; }
.text-gradient { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-center { text-align: center; }
.font-600 { font-weight: 600; }
.font-700 { font-weight: 700; }
.text-12 { font-size: 12px; } .text-13 { font-size: 13px; } .text-14 { font-size: 14px; } .text-15 { font-size: 15px; }
.color-muted { color: var(--text-muted); }
.color-soft { color: var(--text-soft); }
.color-primary { color: var(--primary); }

/* Scrollbar styling */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-soft); }

/* ---- Task in-progress state ---- */
.task-check.in-progress { background: rgba(245,158,11,0.1); border-color: #f59e0b; position: relative; }
.task-check.in-progress svg { display: none; }
.task-check.in-progress::after { content: '~'; position: absolute; font-size: 12px; font-weight: 900; color: #f59e0b; }

/* ---- Drag-to-reorder hint ---- */
.drag-order-hint {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--primary);
  padding: 0 14px 8px;
  opacity: 0.8;
}
.drag-order-hint svg { flex-shrink: 0; }

/* ---- Drag handle ---- */
.drag-handle {
  width: 32px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); cursor: grab;
  touch-action: none; user-select: none;
  border-radius: 6px;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
  margin-left: -4px;
}
.drag-handle:hover { color: var(--primary); background: var(--gradient-soft); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { display: block; width: 14px; height: 14px; }

/* ---- Responsive Design ---- */

/* Very small phones (< 375px) */
@media (max-width: 374px) {
  :root { --nav-height: 60px; }
  .nav-item span { font-size: 10px; }
  .nav-icon { width: 17px; height: 17px; }
  .nav-inner { padding: 3px 2px; }
  .home-greeting { font-size: 15px; }
  .page-title { font-size: 17px; }
  .day-btn { min-width: 32px; padding: 6px 1px; }
  .day-btn .day-num { font-size: 15px; }
  .day-nav { width: 22px; height: 22px; font-size: 12px; }
  .section-title { font-size: 13px; }
  .section-icon { width: 32px; height: 32px; }
  .section-icon-inner { font-size: 14px; }
  .habit-state-btn2 { min-width: 42px; padding: 5px 4px; }
  .goal-state-btn2 { min-width: 48px; padding: 5px 4px; }
  .btn-add { height: 32px; padding: 0 10px; font-size: 12px; }
  .home-header { padding: 12px 10px 14px; }
  .day-picker-wrap { padding: 18px 10px 28px; }
  .home-sections { padding: 0 10px; }
  .page-header { padding: calc(env(safe-area-inset-top, 8px) + 4px) 10px 0; }
  .habits-stats-row, .habits-list, .goals-list, .tasks-wrap,
  .insights-wrap, .inspire-wrap, .settings-wrap { padding-left: 10px; padding-right: 10px; }
  .filter-tabs { padding-left: 10px; padding-right: 10px; }
  .search-row { padding-left: 10px; padding-right: 10px; }
}

/* Small phones: iPhone mini (375px), Samsung S22 (360px) and up */
@media (min-width: 375px) and (max-width: 479px) {
  .day-btn { min-width: 36px; }
}

/* Medium phones and up */
@media (min-width: 480px) {
  .template-grid { grid-template-columns: repeat(3, 1fr); }
  .insights-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Large phone / small tablet */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: var(--radius-xl); max-height: 90vh; max-width: 520px; }
  .confirm-box { max-width: 380px; border-radius: var(--radius-xl); }
  #confirm-overlay { align-items: center; }
}

/* Tablet / Desktop: show as centred phone */
@media (min-width: 768px) {
  body {
    background: linear-gradient(135deg, #dbeafe 0%, #ccfaf6 100%);
    display: flex; align-items: center; justify-content: center;
  }
  #app {
    width: 420px; max-width: 100%;
    height: min(900px, 96vh); height: min(900px, 96dvh);
    border-radius: 36px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(var(--primary-rgb),0.18), 0 0 0 1px rgba(255,255,255,0.6);
    flex-shrink: 0;
    /* transform creates new stacking context so fixed children stay inside #app */
    transform: translateZ(0);
  }
  .main { height: 100%; }
}

/* ---- Habit status badge (home page) ---- */
.habit-status-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--radius-full); flex-shrink: 0;
  letter-spacing: 0.02em;
}
.habit-status-badge.badge-off      { background: rgba(148,163,184,0.14); color: var(--text-soft); }
.habit-status-badge.badge-worked   { background: rgba(245,158,11,0.13);  color: #b45309; }
.habit-status-badge.badge-complete { background: rgba(var(--secondary-rgb),0.13);  color: #0e9f8a; }

/* ---- Habit state button v2 (home page) ---- */
.habit-state-btn2 {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 52px; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); flex-shrink: 0;
  transition: all var(--duration) var(--ease);
  font-size: 12px; font-weight: 600;
}
.habit-state-btn2:active { transform: scale(0.94); }
.habit-state-btn2.hstate-off      { background: var(--bg); color: var(--text-soft); border-color: var(--border); }
.habit-state-btn2.hstate-off:hover { border-color: var(--primary); color: var(--primary); background: rgba(var(--primary-rgb),0.06); }
.habit-state-btn2.hstate-worked   { background: rgba(245,158,11,0.1); border-color: #f59e0b; color: #b45309; }
.habit-state-btn2.hstate-complete { background: rgba(var(--secondary-rgb),0.1); border-color: var(--secondary); color: #0e9f8a; }
.hstate-icon { font-size: 14px; font-weight: 700; line-height: 1; }
.hstate-label { font-size: 10px; font-weight: 600; line-height: 1; }

/* ---- Sort options ---- */
.sort-active-row {
  font-size: 12px; color: var(--text-soft); padding: 0 14px 8px;
  display: flex; align-items: center; gap: 6px; max-width: 600px; margin: 0 auto;
}
.sort-clear-btn { background: none; font-size: 12px; color: var(--text-soft); padding: 0 2px; }
.sort-clear-btn:hover { color: var(--primary); }
.sort-option-list { display: flex; flex-direction: column; gap: 4px; }
.sort-option-btn {
  width: 100%; text-align: left; padding: 10px 14px;
  border-radius: var(--radius-md); font-size: 13px; font-weight: 500;
  color: var(--text); background: var(--bg); border: 1px solid transparent;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--duration) var(--ease);
}
.sort-option-btn:hover { background: var(--gradient-soft); color: var(--primary); }
.sort-option-btn.active { background: var(--gradient-soft); color: var(--primary); border-color: rgba(var(--primary-rgb),0.2); font-weight: 600; }

/* ---- Habit toggle button (lightning bolt / tick) ---- */
.habit-toggle-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration) var(--ease);
}
.habit-toggle-btn:active { transform: scale(0.88); }
.habit-toggle-btn svg { width: 16px; height: 16px; }
.habit-toggle-btn.hbtn-off { color: var(--text-soft); border-color: var(--border); background: var(--bg); }
.habit-toggle-btn.hbtn-off:hover { opacity: 0.8; }
.habit-toggle-btn.hbtn-worked { /* color/border/bg set via inline style from habit colour */ }
.habit-toggle-btn.hbtn-complete { /* color/border/bg set via inline style from habit colour */ }

/* ---- Goal state button v2 (home page) ---- */
.goal-state-btn2 {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 58px; padding: 7px 8px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); flex-shrink: 0;
  transition: all var(--duration) var(--ease);
}
.goal-state-btn2:active { transform: scale(0.94); }
.goal-state-btn2.gstate-off      { background: var(--bg); color: var(--text-soft); border-color: var(--border); }
.goal-state-btn2.gstate-off:hover { border-color: var(--primary); color: var(--primary); background: rgba(var(--primary-rgb),0.06); }
.goal-state-btn2.gstate-worked   { background: rgba(245,158,11,0.1); border-color: #f59e0b; color: #b45309; }
.goal-state-btn2.gstate-complete { background: rgba(var(--secondary-rgb),0.1); border-color: var(--secondary); color: #0e9f8a; }
.gstate-icon  { font-size: 15px; line-height: 1; }
.gstate-label { font-size: 10px; font-weight: 600; line-height: 1; }

/* ---- Task status badge (home page goal-tasks) ---- */
.task-status-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--radius-full); display: inline-block;
}
.badge-task-open { background: rgba(var(--primary-rgb),0.1); color: var(--primary); }

/* Drag and drop */
.dragging { opacity: 0.5; }
.drag-over { border: 2px dashed var(--primary) !important; background: var(--gradient-soft) !important; }

/* Fade in animation */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s var(--ease) both; }

/* ---- Feature: Milestone delete button ---- */
.milestone-del-btn {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); flex-shrink: 0;
  opacity: 0.35; transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.milestone-del-btn:hover { opacity: 1; color: #ef4444; background: rgba(239,68,68,0.08); }
.milestone-del-btn svg { width: 12px; height: 12px; }
@media (hover: none) { .milestone-del-btn { opacity: 0.5; } }

/* ---- Feature: Habit skip ---- */
.habit-status-badge.badge-skipped { background: rgba(148,163,184,0.12); color: var(--text-soft); font-style: italic; }
.habit-skip-link {
  font-size: 12px; color: var(--text-soft); cursor: pointer;
  margin-top: 3px; padding: 4px 0; background: none; border: none;
  text-decoration: underline; text-underline-offset: 2px;
  min-height: 36px; display: inline-flex; align-items: center;
  touch-action: manipulation;
  transition: color 0.15s;
}
.habit-skip-link:hover { color: var(--text); }

/* ---- Feature: Habit progress note ---- */
.habit-note-text { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 3px; }
.habit-note-link {
  font-size: 12px; color: var(--primary); cursor: pointer;
  margin-top: 3px; padding: 0; background: none; border: none;
  opacity: 0.7; transition: opacity 0.15s;
}
.habit-note-link:hover { opacity: 1; }

/* ---- Feature: Weekly review card ---- */
.weekly-review-card {
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.08), rgba(var(--secondary-rgb),0.06));
  border: 1.5px solid rgba(var(--primary-rgb),0.2);
  border-radius: var(--radius-lg); padding: 14px 16px;
  margin: 0 16px 12px; animation: fadeIn 0.3s var(--ease) both;
}

/* ---- Feature: Focus mode overlay ---- */
.focus-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.28s ease;
}
.focus-overlay.visible { opacity: 1; }
.focus-panel {
  width: 100%; max-width: 480px;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 20px 20px 36px;
  transform: translateY(30px); transition: transform 0.28s var(--ease-out);
  max-height: 85vh; overflow-y: auto;
}
.focus-overlay.visible .focus-panel { transform: translateY(0); }
.focus-panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.focus-panel-title { font-size: 18px; font-weight: 700; color: var(--text); }
.focus-panel-date  { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.focus-close-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--text-soft);
  flex-shrink: 0; cursor: pointer; touch-action: manipulation;
}
.focus-close-btn svg { width: 14px; height: 14px; }
.home-header-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(var(--primary-rgb),0.1);
  border: 1px solid rgba(var(--primary-rgb),0.22);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); cursor: pointer; touch-action: manipulation;
  transition: all 0.2s; flex-shrink: 0;
}
.home-header-btn:hover { background: rgba(var(--primary-rgb),0.18); }
.home-header-btn:active { background: rgba(var(--primary-rgb),0.28); border-color: rgba(var(--primary-rgb),0.5); }
.focus-section-label {
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px;
}
.focus-habit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: rgba(var(--primary-rgb),0.08);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  border-left: 3px solid var(--primary);
}
.focus-goal-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; background: rgba(var(--primary-rgb),0.08);
  border-radius: var(--radius-sm);
}
.focus-quote {
  font-size: 12px; color: var(--text-soft); font-style: italic;
  text-align: center; margin-top: 20px; padding: 0 8px;
  line-height: 1.6;
}

/* ---- Feature: Confetti ---- */
@keyframes confettiFall {
  0%   { transform: translateY(0)    rotate(0deg)   scaleX(1);   opacity: 1; }
  50%  { transform: translateY(50vh) rotate(360deg) scaleX(-1);  opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg) scaleX(1);  opacity: 0; }
}

/* Progress circle */
.progress-ring { transform: rotate(-90deg); }
.progress-ring-circle { transition: stroke-dashoffset 0.6s var(--ease); }

/* ---- Inspire page redesign ---- */
.inspire-hero {
  background: var(--card);
  border: 1.5px solid rgba(var(--primary-rgb),0.40);
  border-radius: var(--radius-xl); padding: 15px 16px 14px;
  margin-bottom: 12px; animation: fadeIn 0.3s var(--ease) both;
}
.inspire-hero-top {
  display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 9px;
}
.inspire-hero-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--card); color: var(--primary); padding: 3px 9px;
  border-radius: var(--radius-full); border: 1.5px solid rgba(var(--primary-rgb),0.45);
}
.inspire-hero-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-bottom: 5px;
}
.inspire-hero-meta {
  font-size: 12px; color: var(--text-soft);
  display: flex; align-items: center; gap: 5px; margin-bottom: 9px;
}
.inspire-hero-preview {
  font-size: 12px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px;
}
.inspire-hero-footer {
  display: flex; justify-content: flex-end; margin-top: 8px;
}
.inspire-hero-read-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--text-soft);
  padding: 5px 11px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-soft);
  transition: all var(--duration) var(--ease); touch-action: manipulation;
}
.inspire-hero-read-btn:hover { background: var(--border-soft); }
.inspire-hero-read-btn .inspire-chevron { color: var(--text-soft); }

.inspire-cat-pills {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  margin-bottom: 12px; scrollbar-width: none;
}
.inspire-cat-pills::-webkit-scrollbar { display: none; }
.inspire-cat-pill {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: var(--radius-full); border: 1.5px solid var(--border);
  background: var(--card); color: var(--text-soft); white-space: nowrap;
  transition: all var(--duration) var(--ease); touch-action: manipulation;
}
.inspire-cat-pill:hover { border-color: rgba(var(--primary-rgb),0.3); color: var(--primary); }
.inspire-cat-pill.active {
  background: var(--gradient); color: white; border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb),0.22);
}
.inspire-lessons-flat { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.inspire-lesson-cat-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: var(--primary); background: rgba(var(--primary-rgb),0.1);
  padding: 1px 6px; border-radius: var(--radius-full); margin-right: 5px;
}
.inspire-lesson-count {
  display: inline-block; font-size: 12px; font-weight: 600; color: var(--text-soft);
  background: var(--bg-soft); padding: 0 7px; border-radius: var(--radius-full);
  margin-left: 5px;
}

/* ---- Feature: Mood picker ---- */
.mood-picker {
  display: flex; gap: 6px; justify-content: space-between;
  margin-top: 4px;
}
.mood-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 8px 4px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg-soft);
  transition: all var(--duration) var(--ease);
  touch-action: manipulation; cursor: pointer;
}
.mood-btn:hover { border-color: rgba(var(--primary-rgb),0.35); background: rgba(var(--primary-rgb),0.06); }
.mood-btn.selected {
  border-color: var(--primary); background: rgba(var(--primary-rgb),0.1);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb),0.18);
}
.mood-emoji { font-size: 22px; line-height: 1; }
.mood-label { font-size: 10px; font-weight: 600; color: var(--text-soft); }
.mood-btn.selected .mood-label { color: var(--primary); }

/* ---- Feature: Morning/Evening check-in ratings ---- */
.checkin-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  color: var(--text); text-transform: uppercase; margin-bottom: 10px;
}
.rating-row { margin-bottom: 10px; }
.rating-row:last-child { margin-bottom: 0; }
.rating-metric-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.rating-btns { display: flex; gap: 4px; }
.rating-btn {
  flex: 1; min-height: 44px; border-radius: 8px;
  border: 1.5px solid rgba(var(--primary-rgb),0.35); background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s ease; touch-action: manipulation;
}
.rating-emoji { font-size: 20px; line-height: 1; }
.rating-btn:hover { border-color: rgba(var(--primary-rgb),0.55); transform: translateY(-1px); }
.rating-btn.selected { font-weight: 700; }
.rating-poles {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-soft); margin-top: 3px;
}

/* ---- Feature: Daily guidance ---- */
.guidance-card {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.guidance-text { font-size: 13px; line-height: 1.55; color: var(--text-soft); font-style: italic; }

/* ---- Feature: Win / Lesson chips ---- */
.win-chip {
  padding: 5px 12px; border-radius: 20px;
  border: 1.5px solid rgba(var(--primary-rgb),0.35); background: var(--bg-soft);
  font-size: 12px; font-weight: 500; color: var(--text-soft);
  cursor: pointer; transition: all var(--duration) var(--ease);
  touch-action: manipulation;
}
.win-chip:hover { border-color: rgba(var(--primary-rgb),0.45); color: var(--primary); }
.win-chip.selected {
  border-color: var(--primary); background: rgba(var(--primary-rgb),0.1);
  color: var(--primary); font-weight: 600;
}

/* ---- Feature: Modal drag-sort tiles ---- */
.modal-sortable-tile {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 8px 6px;
  margin-bottom: 6px;
}
.modal-sortable-tile:last-child { margin-bottom: 0; }
/* Light mode: add visible theme-tinted border and subtle background so tiles don't merge */
body:not(.dark) .modal-sortable-tile {
  background: rgba(var(--primary-rgb), 0.04) !important;
  border: 1.5px solid rgba(var(--primary-rgb), 0.15);
}
.drag-handle {
  color: var(--text-soft); cursor: grab; font-size: 16px;
  flex-shrink: 0; line-height: 1; user-select: none; padding: 2px 4px;
}
.drag-handle:active { cursor: grabbing; }

/* ---- Feature: Daily streak badge ---- */
.daily-streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: rgba(var(--primary-rgb),0.12); border: 1px solid rgba(var(--primary-rgb),0.25);
  padding: 3px 10px; border-radius: var(--radius-full);
  margin-top: 5px; animation: fadeIn 0.3s var(--ease) both;
}
body.dark .daily-streak-badge { color: var(--primary); background: rgba(var(--primary-rgb),0.18); }

/* ---- Global search overlay ---- */
.gs-group-title {
  font-size: 10px; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 12px 0 5px; margin-top: 4px;
}
.gs-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--border-soft);
  margin-bottom: 5px; cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.gs-item:hover { background: var(--bg-soft); }
.gs-item:active { transform: scale(0.99); }

/* ---- Feature: Section drag handle ---- */
.section-drag-handle {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: var(--text); opacity: 0.45; flex-shrink: 0; cursor: grab;
  border-radius: var(--radius-xs); touch-action: none; transition: opacity 0.15s;
}
.section-drag-handle:hover { opacity: 0.85; }
.section-drag-handle:active { cursor: grabbing; opacity: 1; }
.section.dragging { opacity: 0.45; }

/* ---- Weekly Review card ---- */
.weekly-review-card {
  margin: 4px 14px 8px;
  background: linear-gradient(135deg, rgba(var(--primary-rgb),0.08) 0%, rgba(var(--secondary-rgb),0.05) 100%);
  border: 1.5px solid rgba(var(--primary-rgb),0.25);
  border-radius: var(--radius-lg); padding: 12px 14px;
  animation: fadeIn 0.3s var(--ease) both;
}
.weekly-review-card.done {
  background: rgba(var(--primary-rgb),0.06); border-color: rgba(var(--primary-rgb),0.25);
}

/* ---- Day pills (settings) ---- */
.day-pill {
  font-size: 12px; font-weight: 600; padding: 4px 9px;
  border-radius: var(--radius-full); border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text-soft);
  transition: all var(--duration) var(--ease); touch-action: manipulation; cursor: pointer;
}
.day-pill.active { background: var(--gradient); color: white; border-color: transparent; }

/* ---- Reminder time rows ---- */
.reminder-list { display: flex; flex-direction: column; gap: 6px; }
.reminder-row { display: flex; align-items: center; gap: 8px; }
.reminder-row .form-input { flex: 1; min-width: 0; padding: 6px 10px; height: auto; }

/* ---- Feature: Nav badge ---- */
.nav-badge {
  position: absolute; top: -4px; right: -5px;
  min-width: 16px; height: 16px; border-radius: var(--radius-full);
  background: var(--gradient); color: white;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 1.5px solid var(--card);
  pointer-events: none;
}

/* ---- Nav tooltip ---- */
.nav-tooltip {
  position: fixed;
  background: rgba(var(--primary-rgb), 0.6);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: pre;
  transform: translateX(-50%);
  z-index: 2000;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.35);
  line-height: 1.6;
  animation: fadeIn 0.15s ease;
  text-align: center;
  backdrop-filter: blur(8px);
}
/* downward-pointing arrow toward the nav button */
.nav-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(var(--primary-rgb), 0.6);
}
.nav-tooltip::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(var(--primary-rgb), 0.6);
  z-index: 1;
}

/* ---- Feature: Goal progress chip ---- */
.goal-progress-chip {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--radius-full); border: 1.5px solid;
  cursor: pointer; flex-shrink: 0;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.goal-progress-chip:hover { filter: brightness(0.92); transform: scale(1.04); }
.goal-progress-chip:active { transform: scale(0.96); }

/* ---- Light mode polish ---- */
/* Ensure sufficient contrast for key elements in light mode */
body:not(.dark) .section { border-color: var(--border); }

/* ============================================
   ONBOARDING v2
   ============================================ */

.ob-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.ob-step-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 28px;
}

.ob-dot {
  height: 7px;
  border-radius: 4px;
  background: var(--border);
  transition: all 0.3s var(--ease);
}
.ob-dot.active { width: 20px; background: var(--primary); }
.ob-dot:not(.active) { width: 7px; }

.ob-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  user-select: none;
}
.ob-chip.selected {
  color: var(--text);
  font-weight: 600;
}

.ob-dim-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.ob-dim-row:last-child { border-bottom: none; }

.ob-dim-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ob-goal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
}

.ob-goal-habits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ob-habit-tag {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface, var(--bg-soft));
  border-radius: var(--radius-full);
  padding: 3px 9px;
  border: 1px solid var(--border);
}

.ob-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 4px;
  align-self: flex-start;
}
.ob-back-btn:hover { color: var(--text); }

/* ---- Onboarding radio cards ---- */
.ob-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}
.ob-radio-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.ob-radio-card.selected {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.06);
}
.ob-radio-card:hover:not(.selected) { border-color: rgba(var(--primary-rgb), 0.4); }
.ob-radio-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.ob-radio-circle.checked {
  background: var(--primary);
  border-color: var(--primary);
}
.ob-radio-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.ob-radio-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---- Home welcome card ---- */
.welcome-card {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: 16px;
  padding: 16px 16px 14px;
  margin: 0 0 16px;
}
.welcome-card-dismiss {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.welcome-card-dismiss:hover { color: var(--text); }
.welcome-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  padding-right: 24px;
}
.welcome-card-body {
  color: var(--text-muted);
}
.welcome-card-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-bottom: 4px;
}
.welcome-card-feat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ---- Date input fix ---- */
.form-input[type="date"],
input.date-input {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 8px;
  color: var(--text);
  min-height: 40px;
  height: auto;
  line-height: normal;
}
.form-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--icon-filter, invert(0.5));
  cursor: pointer;
  padding: 2px;
}
body.dark .form-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

/* ---- Quick date chips (task modal) ---- */
.quick-date-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.quick-date-chip {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--text-muted); background: var(--card-soft);
  cursor: pointer; transition: all var(--duration) var(--ease); white-space: nowrap;
}
.quick-date-chip:hover { background: rgba(var(--primary-rgb),0.12); color: var(--primary); border-color: var(--primary); }
.quick-date-chip.active { background: var(--gradient); color: white; border-color: transparent; box-shadow: 0 2px 6px rgba(var(--primary-rgb),0.3); }

/* ---- Milestone drag handle ---- */
.milestone-drag-handle {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
  cursor: grab; padding: 2px;
  color: var(--text-soft);
}
.milestone-drag-handle:active { cursor: grabbing; }

/* ---- Inline Goal Expansion ---- */
.goal-card.expanded {
  border-color: rgba(var(--primary-rgb), 0.3);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.08), var(--shadow-elevated);
  transform: none !important;
  cursor: default;
}
.goal-card-expanded {
  border-top: 1px solid var(--border-soft);
  padding: 14px 14px 16px;
}
.goal-card-expanded .detail-section {
  background: var(--bg-soft, var(--bg));
  box-shadow: none;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  padding: 12px;
}

/* ---- Setup Flow ---- */
.sf-goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-bottom: 4px;
}
.sf-goal-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 12px 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  text-align: left;
  min-height: 88px;
}
.sf-goal-tile:hover:not(.disabled) { border-color: var(--primary); background: rgba(var(--primary-rgb),0.04); }
.sf-goal-tile.selected { transform: none; box-shadow: none; }

.sf-habit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}
.sf-habit-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  min-height: 76px;
}
.sf-habit-tile:hover:not(.disabled) { border-color: var(--primary); background: rgba(var(--primary-rgb),0.04); }
.sf-habit-tile.selected { transform: none; box-shadow: none; }

/* ---- Template category sections ---- */
.tpl-category { border-bottom: 1px solid var(--border-soft); }
.tpl-category:last-child { border-bottom: none; }
.tpl-cat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px; cursor: pointer; user-select: none;
}
.tpl-cat-header:hover { opacity: 0.8; }
.tpl-cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tpl-cat-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.tpl-cat-count { font-size: 12px; color: var(--text-soft); font-weight: 500; }
.tpl-cat-chevron { width: 16px; height: 16px; color: var(--text-soft); transition: transform 0.2s; flex-shrink: 0; }
.tpl-cat-chevron.open { transform: rotate(180deg); }

/* ---- Section header + button (gradient glow) ---- */
.section-add-btn {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: rgba(var(--primary-rgb), 0.10);
  border: 1.5px solid rgba(var(--primary-rgb), 0.22);
  box-shadow: 0 0 7px rgba(var(--primary-rgb), 0.18);
  touch-action: manipulation; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--duration) var(--ease);
  margin-right: 2px;
}
.section-add-btn span {
  font-size: 20px; font-weight: 300; line-height: 1;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  pointer-events: none;
  margin-top: -1px;
}
.section-add-btn:hover {
  background: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.35);
  transform: scale(1.1);
}
.section-add-btn:active { transform: scale(0.92); }

/* ---- Section header add button (matches page-header btn-add style) ---- */
.section-header-info .section-add-pill { margin-top: 6px; align-self: flex-start; }

/* ---- Page About section ---- */
.page-about {
  margin: 8px 14px 8px; max-width: 572px;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: var(--radius-md); overflow: hidden;
}
.page-about-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 600; color: var(--text-soft);
  user-select: none;
}
.page-about-summary::-webkit-details-marker { display: none; }
.page-about-summary svg.info-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--primary); }
.page-about-chevron { width: 14px; height: 14px; margin-left: auto; flex-shrink: 0; transition: transform 0.2s; }
.page-about[open] .page-about-chevron { transform: rotate(180deg); }
.page-about-body {
  padding: 0 12px 12px; font-size: 13px; color: var(--text-soft);
  line-height: 1.65; border-top: 1px solid var(--border-soft);
}

/* ---- Smart nudge banner ---- */
.smart-nudge {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 10px; padding: 10px 12px;
  background: rgba(var(--primary-rgb), 0.07);
  border: 1.5px solid rgba(var(--primary-rgb), 0.2);
  border-radius: var(--radius-md);
  max-width: 572px; /* 600-14-14 */
}
.smart-nudge-cta { flex-direction: column; align-items: stretch; gap: 6px; }

/* ---- Goal modal collapsible sections ---- */
.goal-modal-collapsible > summary { margin-bottom: 0; user-select: none; }
.goal-modal-collapsible > summary::-webkit-details-marker { display: none; }
.goal-modal-collapsible[open] > summary svg { transform: rotate(180deg); }
.goal-modal-collapsible > summary svg { transition: transform 0.2s; }

/* ---- Heatmap note indicator ---- */
.heatmap-has-note { outline: 2px solid rgba(255,255,255,0.6); outline-offset: -2px; }

/* ---- Journal History Modal ---- */
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-card {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: var(--radius-md); padding: 12px;
}
.hist-card-today { border-color: var(--primary); background: rgba(var(--primary-rgb),0.04); }
.hist-date-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.hist-date { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; }
.hist-section { margin-bottom: 8px; }
.hist-section:last-child { margin-bottom: 0; }
.hist-label { font-size: 12px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.hist-text { font-size: 13px; color: var(--text-soft); line-height: 1.5; padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.hist-text:last-child { border-bottom: none; }

/* ---- Insights tabs ---- */
.insights-tab-row {
  display: flex; gap: 0; margin: 8px 14px 0; max-width: 572px;
  background: var(--card-soft); border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--border-soft);
}
.insights-tab-btn {
  flex: 1; padding: 10px 0; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--text-soft); border: none;
  cursor: pointer; transition: all var(--duration) var(--ease);
  border-bottom: 2px solid transparent;
}
.insights-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: rgba(var(--primary-rgb),0.06); }

/* ---- Life Assessment ---- */
.life-area-form { padding: 14px 18px; }
.life-score-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--border); outline: none; cursor: pointer; }
.life-score-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* ---- Habit Routines ---- */
.routine-card {
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-md); padding: 12px;
  transition: border-color var(--duration) var(--ease);
}
.routine-card:hover { border-color: rgba(var(--primary-rgb),0.3); }

/* ---- Android: extra top clearance below status bar ---- */
body.android .home-brand {
  padding-top: calc(env(safe-area-inset-top, 14px) + 10px);
}
body.android .page-header {
  padding-top: calc(env(safe-area-inset-top, 12px) + 10px);
}

/* ---- iOS: remove the blank gap below the nav bar ----
   On Android the system nav bar sits outside the WebView so env(safe-area-inset-bottom)
   is 0 and there is no wasted space. On iPhone it returns ~34px (home indicator), which
   shows as blank space below the nav pill. On iOS the home indicator overlays app content
   by convention (Apple's own apps do this), so we zero out --safe-bottom here.
   -webkit-touch-callout is iOS-only, making this the most reliable CSS iOS guard. */
@supports (-webkit-touch-callout: none) {
  :root { --safe-bottom: 0px; }
}

/* ---- Print / PDF ---- */
@media print {
  .nav-bar, .page-header .btn, #share-progress-btn, .insights-tab-row,
  .take-assessment-btn, .chart-range-btn, .mood-range-btn, .insights-tab-btn { display: none !important; }
  .insights-wrap { padding: 0 !important; }
  .card, .card-inner { box-shadow: none !important; border: 1px solid #e2e8f0 !important; break-inside: avoid; }
  body { background: white !important; color: black !important; }
}
