/* =========================================================
   TheSushant Habits — Design System
   Single source of truth. Every component used anywhere lives here.
   ========================================================= */

:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-surface-2: #f4f5f7;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-text: #111827;
  --color-muted: #6b7280;

  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-soft: #eef2ff;

  --color-success: #059669;
  --color-success-soft: #d1fae5;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-info: #0284c7;
  --color-info-soft: #e0f2fe;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  --fs-xs: 12px; --fs-sm: 14px; --fs-base: 16px;
  --fs-lg: 18px; --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 30px; --fs-4xl: 40px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;

  --container-max: 1120px;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.25; font-weight: 700; }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-4); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }

/* ---------- Layout ---------- */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--sp-5); }

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 10;
}
.site-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px; gap: var(--sp-4);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; color: var(--color-text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 20px; }
.site-nav { display: flex; align-items: center; gap: var(--sp-2); }

.site-main { padding: var(--sp-10) 0 var(--sp-12); min-height: calc(100vh - 140px); }

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-6) 0;
}

.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-2); }

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

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

.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { padding: 14px 24px; font-size: var(--fs-base); }
.btn-block { width: 100%; }

.inline-form { display: inline; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: var(--sp-4); }
.label { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.hint { display: block; color: var(--color-muted); font-size: var(--fs-xs); margin-top: var(--sp-1); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--color-text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.textarea { min-height: 120px; resize: vertical; }
.input-error { border-color: var(--color-danger); }
.form-error { color: var(--color-danger); font-size: var(--fs-xs); margin-top: var(--sp-1); }

.checkbox-row { display: flex; align-items: center; gap: var(--sp-2); }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.card-header { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--color-border); margin-bottom: var(--sp-4); }
.card-title { margin: 0; font-size: var(--fs-lg); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
}
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: #a7f3d0; }
.alert-error   { background: var(--color-danger-soft);  color: var(--color-danger);  border-color: #fecaca; }
.alert-info    { background: var(--color-info-soft);    color: var(--color-info);    border-color: #bae6fd; }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: #fde68a; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600;
  background: var(--color-surface-2); color: var(--color-muted);
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info    { background: var(--color-info-soft);    color: var(--color-info); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }

/* ---------- Progress ---------- */
.progress { width: 100%; height: 10px; background: var(--color-surface-2); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-primary); transition: width var(--dur) var(--ease); }
.progress-success .progress-bar { background: var(--color-success); }

/* ---------- Stats ---------- */
.stat { text-align: center; padding: var(--sp-4); }
.stat-value { font-size: var(--fs-3xl); font-weight: 800; line-height: 1; color: var(--color-text); }
.stat-label { font-size: var(--fs-xs); color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: var(--sp-2); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--color-border); }
.table th { font-weight: 600; color: var(--color-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Hero / marketing ---------- */
.hero { padding: var(--sp-8) 0 var(--sp-12); }
.hero-title { font-size: clamp(var(--fs-2xl), 5vw, var(--fs-4xl)); margin-bottom: var(--sp-4); max-width: 720px; }
.hero-lede { font-size: var(--fs-lg); color: var(--color-muted); max-width: 680px; margin-bottom: var(--sp-6); }
.hero-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-10); }
.hero-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--color-muted); }
.empty-icon { font-size: 40px; margin-bottom: var(--sp-3); }

/* ---------- Error page ---------- */
.error-page { max-width: 480px; margin: var(--sp-12) auto; text-align: center; }
.error-code { font-family: var(--font-mono); color: var(--color-muted); font-size: var(--fs-sm); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: var(--sp-2); }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: 1000; max-width: 320px;
}
.toast {
  background: var(--color-text); color: #fff;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.modal-overlay.modal-show { opacity: 1; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
}
.modal-header { margin-bottom: var(--sp-3); }
.modal-title { margin: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---------- Utilities ---------- */
.text-muted { color: var(--color-muted); }
.text-sm    { font-size: var(--fs-sm); }
.text-center{ text-align: center; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); } .gap-4 { gap: var(--sp-4); }
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-main { padding: var(--sp-6) 0; }
  .card { padding: var(--sp-4); }
  .toast-container { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); max-width: none; }
}
/* =========================================================
   Habit components (added in Step 3)
   ========================================================= */

.form-row { display: grid; gap: var(--sp-4); grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.color-picker { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.color-swatch { position: relative; cursor: pointer; }
.color-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.color-swatch span {
  display: block; width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--swatch);
  border: 3px solid transparent;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.color-swatch input:checked + span { border-color: var(--color-text); transform: scale(1.1); }
.color-swatch:hover span { transform: scale(1.05); }

.habit-list { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.habit-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  color: var(--color-text);
}
.habit-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--habit-color, var(--color-primary));
}
a.habit-card {
  display: block;
  text-decoration: none;
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
a.habit-card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.habit-card.is-archived { opacity: 0.65; }
.habit-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-2); margin-bottom: var(--sp-2);
}
.habit-name { font-size: var(--fs-lg); font-weight: 700; margin: 0; line-height: 1.3; }
.habit-identity { font-size: var(--fs-sm); font-style: italic; color: var(--color-muted); margin: var(--sp-1) 0 0; }
.habit-cue { font-size: var(--fs-sm); color: var(--color-muted); margin: var(--sp-2) 0 var(--sp-3); }
.habit-meta { display: flex; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--color-muted); }
.habit-actions {
  display: flex; gap: var(--sp-2); margin-top: var(--sp-3);
  padding-top: var(--sp-3); border-top: 1px solid var(--color-border);
}

.streak-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.streak-chip.is-cold { background: var(--color-surface-2); color: var(--color-muted); }

/* =========================================================
   Check-in components (added in Step 4)
   ========================================================= */

.checkin-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.checkin-panel {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.checkin-panel::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--habit-color, var(--color-primary));
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.checkin-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}

.checkin-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}
.checkin-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 8px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit; font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.checkin-btn:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.checkin-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.checkin-btn-icon { font-size: 14px; line-height: 1; }

.checkin-btn.is-selected[data-status="done"]    { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.checkin-btn.is-selected[data-status="partial"] { background: var(--color-warning); border-color: var(--color-warning); color: #fff; }
.checkin-btn.is-selected[data-status="skipped"] { background: var(--color-muted);   border-color: var(--color-muted);   color: #fff; }

.input-sm { padding: 8px 10px; font-size: var(--fs-sm); }

.heat-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.heat-cell {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  background: var(--color-surface-2);
  color: var(--color-muted);
}
.heat-cell.is-done    { background: var(--color-success); color: #fff; }
.heat-cell.is-partial { background: var(--color-warning); color: #fff; }
.heat-cell.is-skipped { background: var(--color-muted);   color: #fff; }
.heat-cell.is-missed  { background: var(--color-danger-soft); color: var(--color-danger); }
.heat-day { text-transform: uppercase; letter-spacing: 0.02em; }

.text-xs { font-size: var(--fs-xs); }

/* =========================================================
   Journal components (added in Step 5)
   ========================================================= */

.journal-layout {
  display: grid;
  gap: var(--sp-6);
  grid-template-columns: 1fr 280px;
  align-items: start;
}
@media (max-width: 900px) {
  .journal-layout { grid-template-columns: 1fr; }
}

.textarea-lg { min-height: 220px; line-height: 1.7; }

.save-status {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-muted);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.save-status.is-saving { background: var(--color-info-soft);    color: var(--color-info); }
.save-status.is-saved  { background: var(--color-success-soft); color: var(--color-success); }
.save-status.is-dirty  { background: var(--color-warning-soft); color: var(--color-warning); }
.save-status.is-error  { background: var(--color-danger-soft);  color: var(--color-danger); }

.journal-recent { list-style: none; padding: 0; margin: 0; }
.journal-recent li {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  transition: background var(--dur-fast) var(--ease);
}
.journal-recent li:hover { background: var(--color-surface-2); }
.journal-recent li a { color: var(--color-text); font-weight: 500; text-decoration: none; }
.journal-recent li a:hover { text-decoration: none; }
.journal-recent li.is-current { background: var(--color-primary-soft); }
.journal-recent li.is-current a { color: var(--color-primary); }

.journal-dots { display: flex; gap: 4px; }
.journal-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-primary);
}

/* =========================================================
   Analytics components (Step 7)
   ========================================================= */

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.heatmap-cell {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-muted);
  transition: transform var(--dur-fast) var(--ease);
}
.heatmap-cell:hover { transform: scale(1.08); }
.heatmap-level-0 { background: var(--color-surface-2); color: var(--color-muted); }
.heatmap-level-1 { background: #c7d2fe; color: #3730a3; }
.heatmap-level-2 { background: #818cf8; color: #1e1b4b; }
.heatmap-level-3 { background: var(--color-primary); color: #ffffff; }

.dow-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  height: 160px;
  align-items: end;
  padding: 0 var(--sp-2);
}
.dow-bar {
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  height: 100%; position: relative;
}
.dow-bar-fill {
  width: 100%; max-width: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height var(--dur) var(--ease);
}
.dow-bar-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-muted);
  margin-top: 6px;
}

.trend-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); }
.trend-item {}
.trend-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
}
.trend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.trend-name { flex: 1; font-weight: 600; }
.trend-pct { color: var(--color-muted); font-variant-numeric: tabular-nums; }

/* Habit detail page */
.habit-cal { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; }
.habit-cal-cell { aspect-ratio: 1/1; border-radius: 3px; background: var(--color-surface-2); }
.habit-cal-done { background: var(--color-success); }
.habit-cal-partial { background: var(--color-warning); }
.habit-cal-skipped { background: var(--color-muted); }
.notes-list { list-style: none; padding: 0; margin: 0; }
.note-item { display: grid; grid-template-columns: 70px auto 1fr; gap: var(--sp-3); align-items: start; padding: var(--sp-3) 0; border-bottom: 1px solid var(--color-border); }
.note-item:last-child { border-bottom: 0; }
.note-date { font-size: var(--fs-xs); color: var(--color-muted); }
.note-text { margin: 0; font-size: var(--fs-sm); }
/* =========================================================
   Responsive pass (Step 7.1) — mobile & tablet
   ========================================================= */

/* 1. Header: never overflow. Stacks brand on top of centered nav below 720px. */
.site-header-inner { flex-wrap: wrap; }
@media (max-width: 720px) {
  .site-header-inner { flex-direction: column; align-items: stretch; gap: var(--sp-2); padding: var(--sp-2) 0; min-height: auto; }
  .brand { justify-content: center; }
  .site-nav { justify-content: center; flex-wrap: wrap; gap: var(--sp-1); }
  .site-nav .btn-sm { padding: 6px 10px; font-size: 13px; }
}
@media (max-width: 400px) {
  .site-nav .btn-sm { padding: 5px 9px; font-size: 12px; }
  .brand-name { font-size: 15px; }
  .brand-mark { font-size: 18px; }
}

/* 2. Container, cards, headings — tighter on mobile. Grids get 2-per-row. */
@media (max-width: 720px) {
  .container { padding: 0 var(--sp-4); }
  .site-main { padding: var(--sp-6) 0 var(--sp-8); }
  .card { padding: var(--sp-4); }
  .card-header { margin-bottom: var(--sp-3); }
  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }
  .hero-title { font-size: var(--fs-2xl); }
  .hero-lede { font-size: var(--fs-base); }
  .grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat { padding: var(--sp-3); }
  .stat-value { font-size: var(--fs-2xl); }
  .stat-label { font-size: 10px; }
}
@media (max-width: 400px) {
  .container { padding: 0 var(--sp-3); }
  .card { padding: var(--sp-3); }
  h1 { font-size: var(--fs-xl); }
}

/* 3. Habit detail: 90-day calendar caps at 500px desktop, 10 cols tablet, 7 cols phone */
.habit-cal { max-width: 500px; }
@media (max-width: 720px) { .habit-cal { grid-template-columns: repeat(10, 1fr); max-width: 100%; } }
@media (max-width: 460px) { .habit-cal { grid-template-columns: repeat(7, 1fr); gap: 3px; } }

/* 4. Notes, lists, forms, row-between headings — stack on mobile */
@media (max-width: 640px) {
  .note-item { grid-template-columns: 1fr; gap: var(--sp-1); padding: var(--sp-2) 0; }
  .note-date, .note-status { display: inline-block; margin-right: var(--sp-2); }
  .habit-list, .checkin-grid, .journal-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: var(--sp-3); }
  .row-between { align-items: flex-start; }
  .row-between > div:first-child { flex-basis: 100%; min-width: 0; }
  .textarea-lg { min-height: 140px; }
  .site-footer { padding: var(--sp-4) 0; font-size: 12px; }
  .dow-chart { height: 120px; gap: 4px; }
  .heatmap-grid { gap: 3px; }
  .heatmap-cell { font-size: 10px; }
}
/* =========================================================
   Navigation (Step 7.2) — minimalist + hamburger
   ========================================================= */

.site-header { background: #fff; }
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 20px; line-height: 1; }
.brand-name { font-size: 15px; letter-spacing: -0.01em; }

.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a,
.site-nav button {
  display: inline-flex; align-items: center;
  padding: 8px 14px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--color-muted);
  background: none; border: 0; border-radius: 6px;
  cursor: pointer; text-decoration: none;
  transition: color 120ms, background 120ms;
}
.site-nav a:hover,
.site-nav button:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
  text-decoration: none;
}
.site-nav .btn-primary,
.site-nav .btn-primary:hover { color: #fff; background: var(--color-primary); }

.menu-toggle {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  background: none; border: 0; padding: 0;
  border-radius: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle:hover { background: var(--color-surface-2); }
.menu-toggle span {
  position: relative; display: block;
  width: 18px; height: 1.5px;
  background: var(--color-text);
  transition: background 150ms;
}
.menu-toggle span::before,
.menu-toggle span::after {
  content: ''; position: absolute; left: 0;
  width: 18px; height: 1.5px;
  background: var(--color-text);
  transition: transform 200ms;
}
.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }
.menu-toggle.is-open span { background: transparent; }
.menu-toggle.is-open span::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle.is-open span::after { transform: translateY(-6px) rotate(-45deg); }
/* Nav mobile (Step 7.2) */
@media (max-width: 720px) {
  .site-header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    height: 56px;
    min-height: 0;
  }
  .brand-name { font-size: 14px; }
  .menu-toggle { display: inline-flex; }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px 16px 16px;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
    opacity: 0; transform: translateY(-8px); pointer-events: none;
    transition: opacity 180ms var(--ease), transform 180ms var(--ease);
    max-height: calc(100vh - 56px); overflow-y: auto; z-index: 1;
  }
  .site-nav.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .site-nav a,
  .site-nav button {
    width: 100%; justify-content: flex-start;
    padding: 14px 8px;
    font-size: 15px; font-weight: 500;
    color: var(--color-text);
    border-radius: 0;
    border-bottom: 1px solid var(--color-border);
    background: none;
  }
  .site-nav a:hover,
  .site-nav button:hover { background: var(--color-surface-2); }
  .site-nav > form:last-child,
  .site-nav > form:last-child button { border-bottom: 0; }
  .site-nav .inline-form { display: block; }
  .site-nav .btn-primary {
    margin-top: 8px; border-radius: 8px; border-bottom: 0;
    justify-content: center;
  }
  body.menu-open { overflow: hidden; }
}
/* Partner components (Ship 9) */
.partner-list { list-style: none; padding: 0; margin: 0; }
.partner-item { display: grid; grid-template-columns: 1fr auto auto; gap: var(--sp-3); align-items: center; padding: var(--sp-3) 0; border-bottom: 1px solid var(--color-border); }
.partner-item:last-child { border-bottom: 0; }
.partner-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.partner-info strong { font-size: var(--fs-sm); }
.partner-meta { font-size: var(--fs-xs); color: var(--color-muted); }
.partner-actions { display: flex; gap: var(--sp-1); }
@media (max-width: 640px) { .partner-item { grid-template-columns: 1fr; } }