/* Health Tracker Custom Styles - Consolidated CSS */

/* Design tokens — commercial health SaaS palette */
:root {
  --ht-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --ht-primary: #0d9488;
  --ht-primary-hover: #0f766e;
  --ht-primary-light: #ccfbf1;
  --ht-primary-muted: #f0fdfa;
  --ht-accent: #4f46e5;
  --ht-accent-hover: #3730a3;
  --ht-accent-light: #eef2ff;
  --ht-surface: #ffffff;
  --ht-surface-muted: #f8fafc;
  --ht-canvas: #f1f5f9;
  --ht-sidebar: #ffffff;
  --ht-border: #e2e8f0;
  --ht-border-strong: #cbd5e1;
  --ht-text: #0f172a;
  --ht-text-secondary: #475569;
  --ht-text-muted: #64748b;
  --ht-success: #059669;
  --ht-success-light: #ecfdf5;
  --ht-danger: #dc2626;
  --ht-danger-light: #fef2f2;
  --ht-warning: #d97706;
  --ht-warning-light: #fffbeb;
  --ht-info: #0284c7;
  --ht-info-light: #f0f9ff;
  --ht-radius-sm: 6px;
  --ht-radius: 10px;
  --ht-radius-lg: 14px;
  --ht-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --ht-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --ht-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --ht-shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1);
  --ht-transition: 0.15s ease;
}

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

* {
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--ht-font);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: inherit;
  line-height: inherit;
  color: var(--ht-text);
  background-color: var(--ht-canvas);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tailwind-like Utility Classes */
/* Layout */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }

/* Flexbox */
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

/* Grid */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Spacing */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Padding */
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

/* Margin */
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 0.75rem; }
.m-4 { margin: 1rem; }
.m-6 { margin: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }

/* Width & Height */
.w-full { width: 100%; }
.w-1\/2 { width: 50%; }
.w-1\/3 { width: 33.333333%; }
.w-2\/3 { width: 66.666667%; }
.w-1\/4 { width: 25%; }
.w-3\/4 { width: 75%; }
.h-full { height: 100%; }
.h-auto { height: auto; }
.min-h-screen { min-height: 100vh; }
.max-w-xs { max-width: 20rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-5xl { max-width: 64rem; }
.max-w-6xl { max-width: 72rem; }

/* Colors - Background */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-gray-300 { background-color: #d1d5db; }
.bg-gray-400 { background-color: #9ca3af; }
.bg-gray-500 { background-color: #6b7280; }
.bg-gray-600 { background-color: #4b5563; }
.bg-gray-700 { background-color: #374151; }
.bg-gray-800 { background-color: #1f2937; }
.bg-gray-900 { background-color: #111827; }
.bg-slate-50 { background-color: #f8fafc; }
.bg-slate-100 { background-color: #f1f5f9; }
.bg-slate-200 { background-color: #e2e8f0; }
.bg-slate-300 { background-color: #cbd5e1; }
.bg-slate-400 { background-color: #94a3b8; }
.bg-slate-500 { background-color: #64748b; }
.bg-slate-600 { background-color: #475569; }
.bg-slate-700 { background-color: #334155; }
.bg-slate-800 { background-color: #1e293b; }
.bg-slate-900 { background-color: #0f172a; }
.bg-red-50 { background-color: #fef2f2; }
.bg-red-100 { background-color: #fee2e2; }
.bg-red-500 { background-color: #ef4444; }
.bg-red-600 { background-color: #dc2626; }
.bg-red-700 { background-color: #b91c1c; }
.bg-green-50 { background-color: #f0fdf4; }
.bg-green-100 { background-color: #dcfce7; }
.bg-green-500 { background-color: #22c55e; }
.bg-green-600 { background-color: #16a34a; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-blue-600 { background-color: #2563eb; }
.bg-blue-700 { background-color: #1d4ed8; }
.bg-yellow-50 { background-color: #fefce8; }
.bg-yellow-100 { background-color: #fef3c7; }
.bg-yellow-500 { background-color: #eab308; }

/* Colors - Text */
.text-white { color: #ffffff; }
.text-gray-50 { color: #f9fafb; }
.text-gray-100 { color: #f3f4f6; }
.text-gray-200 { color: #e5e7eb; }
.text-gray-300 { color: #d1d5db; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-gray-900 { color: #111827; }
.text-slate-50 { color: #f8fafc; }
.text-slate-100 { color: #f1f5f9; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-slate-700 { color: #334155; }
.text-slate-800 { color: #1e293b; }
.text-slate-900 { color: #0f172a; }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-red-700 { color: #b91c1c; }
.text-green-500 { color: #22c55e; }
.text-green-600 { color: #16a34a; }
.text-blue-500 { color: #3b82f6; }
.text-blue-600 { color: #2563eb; }

/* Typography */
.text-xs { font-size: 0.85rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.font-thin { font-weight: 100; }
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.underline { text-decoration-line: underline; }
.no-underline { text-decoration-line: none; }

/* Borders */
.border { border-width: 1px; }
.border-0 { border-width: 0px; }
.border-2 { border-width: 2px; }
.border-t { border-top-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-l { border-left-width: 1px; }
.border-r { border-right-width: 1px; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-slate-200 { border-color: #e2e8f0; }
.border-slate-300 { border-color: #cbd5e1; }
.border-red-500 { border-color: #ef4444; }
.border-green-500 { border-color: #22c55e; }

/* Border Radius */
.rounded { border-radius: 0.25rem; }
.rounded-sm { border-radius: 0.125rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.rounded-none { border-radius: 0px; }

/* Shadows */
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); }
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); }
.shadow-none { box-shadow: none; }

/* Position */
.static { position: static; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.top-0 { top: 0px; }
.right-0 { right: 0px; }
.bottom-0 { bottom: 0px; }
.left-0 { left: 0px; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

/* Hover States */
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.hover\:bg-gray-200:hover { background-color: #e5e7eb; }
.hover\:bg-slate-100:hover { background-color: #f1f5f9; }
.hover\:bg-slate-200:hover { background-color: #e2e8f0; }
.hover\:bg-blue-600:hover { background-color: #2563eb; }
.hover\:bg-blue-700:hover { background-color: #1d4ed8; }

/* Solid blue utility controls: body text color would reduce contrast */
button.bg-blue-500,
button.bg-blue-600,
button.bg-blue-700,
a.bg-blue-500,
a.bg-blue-600,
a.bg-blue-700 {
  color: #ffffff;
}

button.bg-blue-500:hover,
button.bg-blue-500:focus-visible,
button.bg-blue-600:hover,
button.bg-blue-600:focus-visible,
button.bg-blue-700:hover,
button.bg-blue-700:focus-visible,
a.bg-blue-500:hover,
a.bg-blue-500:focus-visible,
a.bg-blue-600:hover,
a.bg-blue-600:focus-visible,
a.bg-blue-700:hover,
a.bg-blue-700:focus-visible {
  color: #ffffff;
}
.hover\:bg-green-600:hover { background-color: #16a34a; }
.hover\:bg-red-600:hover { background-color: #dc2626; }
.hover\:text-gray-900:hover { color: #111827; }
.hover\:text-blue-600:hover { color: #2563eb; }
.hover\:text-slate-200:hover { color: #e2e8f0; }
.hover\:underline:hover { text-decoration-line: underline; }
.hover\:shadow-md:hover { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); }
.hover\:shadow-lg:hover { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }

/* Focus States */
.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
.focus\:ring-2:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }
.focus\:ring-blue-500:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }
.focus\:border-blue-500:focus { border-color: #3b82f6; }

/* SVG Icons */
.h-4 { height: 1rem; }
.w-4 { width: 1rem; }
.h-5 { height: 1.25rem; }
.w-5 { width: 1.25rem; }
.h-6 { height: 1.5rem; }
.w-6 { width: 1.5rem; }
.h-8 { height: 2rem; }
.w-8 { width: 2rem; }

/* Form Elements */
.appearance-none { appearance: none; }
.outline-none { outline: 2px solid transparent; outline-offset: 2px; }

/* Dashboard Specific Styles */
/* Container and Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--ht-shadow-sm);
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--ht-text);
  margin: 0;
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 24px;
  color: white;
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(102, 126, 234, 0.4);
}

.stat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  color: white;
}

.stat-diff {
  font-size: 0.85rem;
  opacity: 0.9;
}

.stat-diff.positive {
  color: #10b981;
}

.stat-diff.negative {
  color: #fbbf24;
}

.stat-diff.neutral {
  color: #6b7280;
}

/* Stat card labels and values - white text on gradient background */
.stat-card .stat-label {
  color: white;
  opacity: 0.9;
}

/* ---- Workout / Progress tracking dashboards: four KPI tiles in one row (compact strip) ---- */
.app-main .workout-dashboard > .stats-grid,
.workout-dashboard .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 16px);
  margin-bottom: 1.15rem;
}

.workout-dashboard .stat-card {
  min-width: 0;
  padding: clamp(12px, 1.8vw, 16px);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.24);
}

.workout-dashboard .stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(99, 102, 241, 0.3);
}

.workout-dashboard .stat-header {
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.workout-dashboard .stat-icon {
  font-size: 1.125rem;
  line-height: 1;
  flex-shrink: 0;
}

.workout-dashboard .stat-title {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.25;
  opacity: 0.94;
}

.workout-dashboard .stat-content {
  gap: 4px;
}

.workout-dashboard .stat-value {
  font-size: clamp(1.2rem, 2.8vw, 1.52rem);
  font-weight: 800;
}

.workout-dashboard .stat-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.88;
}

.app-main .workout-dashboard .stat-card {
  color: #ffffff;
}

.app-main .workout-dashboard .stat-title,
.app-main .workout-dashboard .stat-value {
  color: #ffffff;
}

.app-main .workout-dashboard .stat-subtitle {
  color: rgba(255, 255, 255, 0.9);
}

/* Same width as workout history: stay four-wide on small laptops; stack only on narrow phones */
@media (max-width: 640px) {
  .app-main .workout-dashboard > .stats-grid,
  .workout-dashboard .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .app-main .workout-dashboard > .stats-grid,
  .workout-dashboard .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Progress tracking: denser KPI strip (smaller tiles, less vertical space) */
.app-main .workout-dashboard--compact-kpis > .stats-grid,
.workout-dashboard--compact-kpis .stats-grid {
  gap: clamp(6px, 1vw, 10px);
  margin-bottom: 0.7rem;
}

.workout-dashboard--compact-kpis .stat-card {
  padding: clamp(8px, 1.1vw, 11px);
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.22);
}

.workout-dashboard--compact-kpis .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.28);
}

.workout-dashboard--compact-kpis .stat-header {
  gap: 5px;
  margin-bottom: 5px;
}

.workout-dashboard--compact-kpis .stat-icon {
  font-size: 0.95rem;
}

.workout-dashboard--compact-kpis .stat-title {
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.workout-dashboard--compact-kpis .stat-content {
  gap: 2px;
}

.workout-dashboard--compact-kpis .stat-value {
  font-size: clamp(0.92rem, 1.85vw, 1.12rem);
  font-weight: 800;
  line-height: 1.12;
}

.workout-dashboard--compact-kpis .stat-subtitle {
  font-size: 0.6rem;
  line-height: 1.25;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 640px) {
  .app-main .workout-dashboard--compact-kpis > .stats-grid,
  .workout-dashboard--compact-kpis .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }
}

@media (max-width: 480px) {
  .app-main .workout-dashboard--compact-kpis > .stats-grid,
  .workout-dashboard--compact-kpis .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

.stat-card .stat-value {
  color: white;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
  align-items: start;
}

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

.chart-container {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--ht-shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  min-height: 0;
  max-width: 100%;
}

.chart-container--weekly-calorie {
  overflow: hidden;
}

.chart-container--nutrient {
  overflow: hidden;
}

.chart-content--nutrient {
  min-height: 0;
}

/* Nutrient doughnut: bounded square — prevents infinite vertical growth */
.chart-container-inner--nutrient {
  min-height: 0;
  align-items: stretch;
}

.chart-title-section--nutrient {
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Explicit box so Chart.js always gets non-zero size (grid + aspect-ratio alone could collapse) */
.nutrient-doughnut-aspect {
  position: relative;
  width: min(260px, 100%);
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  min-width: 160px;
  min-height: 160px;
}

.nutrient-doughnut-canvas-box {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 0;
  min-width: 0;
}

.chart-canvas--nutrient {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Weekly calorie chart: fixed aspect box — chart fills this (no runaway height) */
.chart-content--weekly-calorie {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.weekly-calorie-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.weekly-calorie-aspect {
  position: relative;
  width: 100%;
  max-width: 100%;
  /* width : height = 1.6 : 1  →  height = width / 1.6 */
  aspect-ratio: 1.6 / 1;
  max-height: 320px;
  min-height: 180px;
  overflow: hidden;
}

.weekly-calorie-canvas-box {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 0;
}

.chart-canvas--weekly {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

.chart-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.chart-header {
  margin-bottom: 20px;
}

.chart-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.chart-header h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 16px;
}

.workout-history-section {
  margin-bottom: 28px;
}

/* Progress weight chart: single card — header row + chart (no workout tabbar chrome, no extra hint line) */
.progress-weight-chart-unified {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.app-main .progress-weight-chart-unified.chart-container {
  padding: 0;
}

.progress-weight-chart-unified__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0;
  padding: 16px 18px 14px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--ht-border);
  background: transparent;
}

.progress-weight-chart-unified__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0;
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 0;
}

.progress-weight-chart-unified__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.app-main .progress-weight-chart-unified__title {
  color: var(--ht-text);
}

.progress-weight-chart-unified__period {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  color: var(--ht-text);
}

.progress-weight-chart-unified .chart-content--workout-history-combined {
  padding: 14px 18px 18px;
  box-sizing: border-box;
}

.progress-weight-history-section .progress-weight-chart-unified.chart-container:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

@media (max-width: 520px) {
  .progress-weight-chart-unified__header {
    flex-direction: row;
    align-items: center;
  }

  .progress-weight-chart-unified__tools {
    width: auto;
    margin-left: auto;
  }
}

.workout-history-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ht-text-muted);
  box-sizing: border-box;
}

/* Tab-style control strip (title + layout left; period + units right — units furthest right) */
.workout-history-tabbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1rem;
  padding: 14px 16px;
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: 12px;
  box-shadow: var(--ht-shadow-sm);
}

.workout-history-tabbar__start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  min-width: 0;
}

.workout-history-tabbar__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0;
  line-height: 1.35;
}

.workout-history-tabbar__layout-switch {
  flex-shrink: 0;
}

.workout-history-tabbar__end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
}

.workout-history-tabbar__metric-switch {
  flex-shrink: 0;
  margin-left: auto;
}

.workout-history-charts-block--hidden {
  display: none !important;
}

.workout-history-charts-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: clamp(16px, 2vw, 30px);
  width: 100%;
  box-sizing: border-box;
}

/* Side-by-side: flex children shrink (Chart.js canvases respect min-width: 0). */
.workout-history-section .workout-history-charts-row > .chart-container.workout-history-chart-panel {
  flex: 1 1 50%;
  min-width: 0;
  width: auto;
}

/* Borderless panels so “All workouts” (and split strength/cardio charts) sit flush like a single sheet */
.workout-history-section .chart-container.workout-history-chart-panel {
  border: none;
  box-shadow: none;
}

.workout-history-section .chart-container.workout-history-chart-panel:hover {
  transform: none;
  box-shadow: none;
}

.chart-header.workout-history-chart-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-header.workout-history-chart-panel__header h4 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.05rem;
}

.workout-history-metric-switch {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  background: var(--ht-surface-muted);
  border-radius: 9px;
  border: 1px solid var(--ht-border);
  gap: 2px;
}

.workout-history-charts-row--combined {
  flex-direction: column;
  gap: clamp(14px, 2vw, 22px);
  margin-bottom: 0.75rem;
}

.workout-history-section .workout-history-charts-row--combined > .workout-history-chart-panel--combined {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
}

.workout-history-charts-row--split {
  flex-direction: row;
  flex-wrap: nowrap;
}

.chart-header.workout-history-chart-panel__header.workout-history-chart-panel__header--stacked {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.35rem;
  margin-bottom: 10px;
}

.chart-header.workout-history-chart-panel__header.workout-history-chart-panel__header--stacked h4 {
  margin: 0;
}

.workout-history-chart-panel__hint {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ht-text-muted);
  line-height: 1.4;
  max-width: 42rem;
}

.chart-content--workout-history-combined {
  height: 280px;
  min-height: 220px;
}

@media (max-width: 768px) {
  .chart-content--workout-history-combined {
    height: 240px;
    min-height: 200px;
  }
}

.workout-history-metric-switch__btn {
  appearance: none;
  border: none;
  cursor: pointer;
  margin: 0;
  padding: 0.4rem 0.7rem;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ht-text-muted);
  background: transparent;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.workout-history-metric-switch__btn:hover {
  color: var(--ht-text);
}

.workout-history-metric-switch__btn:focus-visible {
  outline: 2px solid var(--ht-accent);
  outline-offset: 1px;
}

.workout-history-metric-switch__btn.is-active {
  background: var(--ht-surface);
  color: var(--ht-text);
  box-shadow: var(--ht-shadow-sm);
}

.app-main .workout-history-chart-panel .chart-header.workout-history-chart-panel__header h4 {
  color: var(--ht-text);
}

.app-main .workout-history-tabbar__title {
  color: var(--ht-text);
}

.workout-history-section__period {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  color: var(--ht-text);
}

@media (max-width: 520px) {
  .workout-history-tabbar {
    flex-direction: column;
    align-items: stretch;
  }

  .workout-history-tabbar__end {
    flex-wrap: wrap;
    width: 100%;
  }

  .workout-history-tabbar__metric-switch {
    margin-left: 0;
  }

  .workout-history-charts-row,
  .workout-history-charts-row--split {
    flex-direction: column;
    flex-wrap: wrap;
  }

  .workout-history-section .workout-history-charts-row > .chart-container.workout-history-chart-panel {
    flex: 1 1 auto;
    width: 100%;
  }
}

.chart-content.chart-content--workout-history {
  position: relative;
  height: 260px;
  min-height: 200px;
}

@media (max-width: 768px) {
  .chart-content.chart-content--workout-history {
    height: 220px;
    min-height: 180px;
  }
}

.chart-content {
  position: relative;
}

.chart-canvas {
  width: 100% !important;
}

/* Chart Controls */
.chart-controls-container {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.chart-btn {
  padding: 8px 16px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.chart-btn.active {
  background: #667eea;
  border-color: #667eea;
  color: #ffffff;
}

.chart-btn.active:hover,
.chart-btn.active:focus-visible {
  color: #ffffff;
}

.chart-container-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 768px) {
  .chart-container-inner {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.chart-title-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chart-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 8px;
  text-align: center;
}

/* Nutrient Breakdown */
.nutrient-breakdown {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 250px;
}

.nutrient-breakdown-header {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 12px 20px;
  margin: -24px -24px 20px -24px;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.nutrient-breakdown-icon {
  font-size: 1.2rem;
}

.nutrient-breakdown-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.nutrient-item-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #e5e7eb;
}

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

.nutrient-label-detail {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nutrient-color-detail {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.nutrient-label-detail > div:last-child > div:first-child {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.875rem;
}

.nutrient-percentage {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

.nutrient-value-detail {
  font-weight: 700;
  color: #1f2937;
  font-size: 0.875rem;
}

.info-card {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-card:first-child {
  margin-top: 8px;
}

.info-card:not(:first-child) {
  margin-top: 6px;
}

.info-card-blue {
  background: rgba(59, 130, 246, 0.08);
  border-left: 4px solid #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.info-card-green {
  background: rgba(16, 185, 129, 0.08);
  border-left: 4px solid #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.info-card-header {
  font-size: 0.9rem;
  color: var(--ht-text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-card-content {
  font-size: 0.8rem;
  color: var(--ht-text-muted);
  margin-top: 4px;
}

/* Bottom Grid */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

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

/* Action Cards */
.action-card {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--ht-shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.action-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.action-header {
  margin-bottom: 20px;
}

.action-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0;
}

.action-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.action-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0 0 12px 0;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Recent workouts — columnar table */
.recent-workouts-card .action-content.recent-workouts-body {
  gap: 14px;
}

.recent-workouts-header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  width: 100%;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.recent-workouts-header__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0;
  line-height: 1.3;
}

.recent-workouts-header__cta {
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
}

@media (max-width: 380px) {
  .recent-workouts-header__title {
    font-size: 1.05rem;
  }
}

.recent-workouts-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ht-border);
  border-radius: 12px;
  background: var(--ht-surface);
}

.recent-workouts-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.recent-workouts-table thead {
  background: var(--ht-surface-muted);
}

.recent-workouts-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ht-text-secondary);
  border-bottom: 2px solid var(--ht-border);
  white-space: nowrap;
}

.recent-workouts-table td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--ht-text);
  border-bottom: 1px solid var(--ht-border);
}

.recent-workouts-table tbody tr:last-child td {
  border-bottom: none;
}

.recent-workouts-table tbody tr:nth-child(even) td {
  background: var(--ht-surface-muted);
}

.recent-workouts-table tbody tr:hover td {
  background: var(--ht-border) !important;
}

.recent-workouts-date-compact {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ht-text);
  line-height: 1.35;
  white-space: nowrap;
}

.recent-workouts-date-compact__sep {
  margin: 0 0.35rem;
  color: var(--ht-text-muted);
  font-weight: 500;
}

.recent-workouts-dash {
  color: var(--ht-text-muted);
  font-weight: 600;
  font-size: 1rem;
}

/* Pill tags — duration, intensity */
.recent-workouts-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  max-width: 100%;
  border: 1px solid transparent;
}

.recent-workouts-tag--duration {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.recent-workouts-tag--calories {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.recent-workouts-tag__stars {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  line-height: 1;
  flex-shrink: 0;
}

.recent-workouts-tag__text {
  font-size: 0.8125rem;
  font-weight: 600;
}

.recent-workouts-tag--i1,
.recent-workouts-tag--i2 {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.recent-workouts-tag--i3 {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.recent-workouts-tag--i4,
.recent-workouts-tag--i5 {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.recent-workouts-tag--type.recent-workouts-tag--strength {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

.recent-workouts-tag--type.recent-workouts-tag--cardio {
  background: #ecfeff;
  color: #0e7490;
  border-color: #a5f3fc;
}

.recent-workouts-table__workout {
  max-width: 220px;
}

.recent-workouts-table__workout a {
  font-weight: 600;
  text-decoration: none;
  color: var(--ht-accent);
  word-break: break-word;
}

.recent-workouts-table__workout a:hover,
.recent-workouts-table__workout a:focus-visible {
  text-decoration: underline;
  color: var(--ht-accent-hover);
}

.recent-workouts-table__duration,
.recent-workouts-table__calories,
.recent-workouts-table__weight,
.recent-workouts-table__intensity {
  white-space: nowrap;
}

.recent-workouts-table__weight {
  text-align: center;
}

.recent-workouts-table th.recent-workouts-table__weight,
.recent-workouts-table td.recent-workouts-table__weight {
  text-align: center;
}

/* Weight recent table: three columns (not the wide workout layout) */
.recent-workouts-table-wrap--weight {
  overflow-x: visible;
}

.recent-workouts-table--weight {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.recent-workouts-table--weight th {
  white-space: normal;
}

.recent-workouts-table--weight .recent-workouts-date-compact {
  white-space: normal;
}

.recent-workouts-table--weight th.recent-workouts-table__actions,
.recent-workouts-table--weight td.recent-workouts-table__actions {
  text-align: right;
  width: 30%;
  min-width: 8.75rem;
}

.recent-workouts-table--weight .recent-workouts-table__date {
  width: 50%;
}

.recent-workouts-table--weight .recent-workouts-table__weight {
  width: 20%;
}

.recent-workouts-table--weight .recent-workouts-table__action-btns {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 100%;
}

.recent-workouts-table__intensity {
  min-width: 9rem;
}

.recent-workouts-table th.recent-workouts-table__actions,
.recent-workouts-table td.recent-workouts-table__actions {
  text-align: right;
}

.recent-workouts-table__actions {
  width: 1%;
}

.recent-workouts-table__action-btns {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.recent-workouts-action-btn {
  padding: 6px 12px !important;
  font-size: 0.8125rem !important;
  white-space: nowrap;
}

/* Weight-only recent table: three columns; workout table keeps min-width 760px above */
@media (max-width: 767px) {
  .recent-workouts-table-wrap--weight {
    overflow-x: visible;
  }

  .recent-workouts-table--weight {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
  }

  .recent-workouts-table--weight th {
    white-space: normal;
    padding: 10px 8px;
    font-size: 0.6875rem;
    vertical-align: bottom;
    hyphens: auto;
    word-break: break-word;
  }

  .recent-workouts-table--weight td {
    padding: 10px 8px;
    vertical-align: top;
  }

  .recent-workouts-table--weight .recent-workouts-table__date {
    width: 34%;
  }

  .recent-workouts-table--weight .recent-workouts-date-compact {
    white-space: normal;
    font-size: 0.75rem;
  }

  .recent-workouts-table--weight .recent-workouts-date-compact__sep {
    /* Line break after date without losing spacing (display:none would glue "Y" to time) */
    display: block;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
    line-height: 0;
  }

  .recent-workouts-table--weight .recent-workouts-table__weight {
    white-space: normal;
    width: 26%;
  }

  .recent-workouts-table--weight .recent-workouts-tag--duration {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .recent-workouts-table--weight .recent-workouts-table__actions {
    width: auto;
  }

  .recent-workouts-table--weight .recent-workouts-table__action-btns {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 100%;
  }

  .recent-workouts-table--weight .recent-workouts-action-btn {
    padding: 5px 8px !important;
    font-size: 0.75rem !important;
  }
}

.recent-workouts-feed-actions {
  border: 1px solid var(--ht-border);
  border-radius: 10px;
  background: var(--ht-surface-muted);
  overflow: hidden;
}

.recent-workouts-feed-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ht-accent);
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.recent-workouts-feed-more:hover,
.recent-workouts-feed-more:focus-visible {
  background: var(--ht-accent-light);
  color: var(--ht-accent-hover);
  outline: none;
}

.recent-workouts-feed-more-arrow {
  font-size: 0.95rem;
  opacity: 0.9;
}

.recent-workouts-empty {
  margin: 0;
  padding: 1.25rem 0.5rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--ht-text-muted);
}

.app-main .recent-workouts-table__workout a,
.app-main .recent-workouts-table__workout a:visited {
  color: var(--ht-accent);
}

.app-main a.recent-workouts-feed-more,
.app-main a.recent-workouts-feed-more:visited {
  color: var(--ht-accent);
}

.app-main a.recent-workouts-feed-more:hover,
.app-main a.recent-workouts-feed-more:focus-visible {
  color: var(--ht-accent-hover);
}

/* Full-page workout history — same typography & chips as Recent workouts */
.workout-history-log-card.card {
  margin-top: 4px;
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.06),
    0 10px 40px rgba(15, 23, 42, 0.04);
}

.workout-history-log-card.card:hover {
  transform: none;
}

.workout-history-log-card__inner {
  padding: 18px;
}

@media (max-width: 640px) {
  .workout-history-log-card__inner {
    padding: 14px;
  }
}

.workout-history-log-card__inner--empty {
  padding-bottom: 24px;
}

.workout-history-empty-state {
  text-align: center;
  padding: 2rem 0.75rem;
  color: #64748b;
}

.workout-history-empty-state p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.workout-log-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.workout-log-table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.workout-log-table thead {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.workout-log-table th {
  text-align: left;
  padding: 13px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  vertical-align: bottom;
}

.workout-log-table td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #e8ecf1;
  color: #1e293b;
}

.workout-log-table tbody tr:last-child td {
  border-bottom: none;
}

.workout-log-table tbody tr:nth-child(even) td {
  background: #f9fafb;
}

.workout-log-table tbody tr:hover td {
  background: #f1f5f9 !important;
}

.workout-log-table__date-primary {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ht-text);
  line-height: 1.35;
  white-space: nowrap;
}

.workout-log-table__date-time {
  display: block;
  margin-top: 5px;
  font-size: 0.765rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ht-text-muted);
}

.workout-log-table__col--date {
  min-width: 10rem;
}
.workout-log-table__col--category {
  min-width: 7.25rem;
}
.workout-log-table__col--workout {
  min-width: 11rem;
}
.workout-log-table__col--duration {
  min-width: 6rem;
}
.workout-log-table__col--cal {
  min-width: 4rem;
}
.workout-log-table__col--intensity {
  min-width: 10.25rem;
}
.workout-log-table__col--actions {
  width: 1%;
  min-width: 11.75rem;
  max-width: 16rem;
  text-align: right;
}

.workout-log-table__workout a {
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
}

.workout-log-table__duration,
.workout-log-table__cal,
.workout-log-table__intensity {
  white-space: nowrap;
}

.workout-log-table__actions-cell {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle !important;
}

.workout-log-table__action-btns {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: min-content;
}

.workout-log-table__btn {
  padding: 7px 14px !important;
  font-size: 0.8125rem !important;
  white-space: nowrap;
  flex: 0 0 auto;
  width: auto !important;
  max-width: none;
}

.workout-log-table__btn--danger {
  background: transparent;
  border: 1px solid #fca5a5 !important;
  color: #b91c1c !important;
  box-shadow: none;
}

.workout-log-table__btn--danger:hover,
.workout-log-table__btn--danger:focus-visible {
  background: #fef2f2;
  border-color: #f87171 !important;
  color: #991b1b !important;
}

.app-main .workout-log-table__workout a,
.app-main .workout-log-table__workout a:visited {
  color: #4f46e5;
}

.app-main .workout-log-table__workout a:hover,
.app-main .workout-log-table__workout a:focus-visible {
  color: #4338ca;
  text-decoration: underline;
}

/* Nutrient Grid */
.nutrient-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.nutrient-item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border-left: 4px solid #667eea;
}

.nutrient-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nutrient-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: #10b981;
}

.nutrient-value.calories {
  color: #f59e0b;
}

.nutrient-value.protein {
  color: #3b82f6;
}

.nutrient-value.carbs {
  color: #10b981;
}

.nutrient-value.fat {
  color: #f59e0b;
}

.loading-state {
  color: #9ca3af !important;
}

.error-state {
  color: #ef4444;
  text-align: center;
  padding: 20px;
  font-weight: 500;
}

/* Text Utilities */
.text-center {
  text-align: center;
}

.text-slate-500 {
  color: #64748b;
}

.text-red-500 {
  color: #ef4444;
}

.py-8 {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Custom Component Styles */
/* Navigation Dropdown */
.nav-item {
  position: relative;
}

.nav-item .dropdown-content {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  min-width: 200px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 8px 0;
  margin-top: 8px;
  transition: visibility 0s linear 0.2s, opacity 0.2s;
  z-index: 1000;
}

.nav-item:hover .dropdown-content {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.nav-item .dropdown-content:hover {
  visibility: visible;
  opacity: 1;
}

.dropdown-content a {
  color: #1f2937;
  padding: 8px 16px;
  text-decoration: none;
  display: block;
  font-size: 14px;
}

.dropdown-content a:hover {
  background-color: #f3f4f6;
}

/* Custom Button Styles */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  color: #ffffff;
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: #667eea;
  color: #ffffff;
}

.btn-danger {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  color: white;
}

.btn-danger:hover,
.btn-danger:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 101, 101, 0.4);
  color: #ffffff;
}

.btn-success {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
}

.btn-success:hover,
.btn-success:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
  color: #ffffff;
}

/* Form Styles */
.form-input {
  width: 100%;
  max-width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--ht-border);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: var(--ht-surface);
  color: var(--ht-text);
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.form-select {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--ht-border);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: var(--ht-surface);
  color: var(--ht-text);
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Card Styles */
.card {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Message Styles */
.message {
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-weight: 500;
}

.message.success {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
}

.message.error {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  color: white;
}

.message.warning {
  background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
  color: white;
}

.message.info {
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
  color: white;
}

/* Nutrition-Specific Styles */
/* Common Page Elements */
.page-header {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--ht-shadow-sm);
  margin-bottom: 24px;
}

.search-section,
.results-section {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--ht-shadow-sm);
  margin-bottom: 24px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.results-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0;
}

.results-header p {
  font-size: 0.875rem;
  color: var(--ht-text-muted);
  margin: 0;
}

.food-info {
  flex: 1;
}

.nutrition-info {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.food-photo {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  flex-shrink: 0;
}

.food-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.food-serving {
  font-size: 0.813rem;
  color: #6b7280;
  margin-top: 4px;
}

.region-selector {
  padding: 14px 20px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.region-selector:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
  pointer-events: auto;
  position: relative;
  z-index: 1001;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-header {
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px 0;
}

.modal-header p {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ht-text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--ht-border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--ht-surface);
  color: var(--ht-text);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:hover {
  border-color: #cbd5e1;
}

.form-display {
  padding: 14px 20px;
  background: var(--ht-surface-muted);
  border: 2px solid var(--ht-border);
  border-radius: 10px;
  font-weight: 600;
  color: var(--ht-text);
}

/* Diary Styles */
.diary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.diary-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.diary-table {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
  overflow: hidden;
}

.table-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.table-header p {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  text-align: left;
  border-bottom: 2px solid #e2e8f0;
}

.table tbody td {
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #1f2937;
}

.table tbody tr:hover {
  background: #f9fafb;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.food-name {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.95rem;
}

.food-notes {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

.action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  min-width: 70px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.action-btn.edit {
  background: #2563eb;
  color: #ffffff;
}

.action-btn.edit:hover,
.action-btn.edit:focus-visible {
  background: #1d4ed8;
  color: #ffffff;
}

.action-btn.delete {
  background: #fee2e2;
  color: #dc2626;
}

.action-btn.delete:hover {
  background: #fecaca;
}

/* Diary table actions column */
.table tbody td:last-child {
  vertical-align: top;
  padding-top: 12px;
}

.table tbody td:last-child .flex {
  align-items: flex-start;
  gap: 8px;
}

.daily-total {
  background: #f8fafc;
  padding: 20px 24px;
  border-top: 2px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.daily-total h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px 0;
}

.daily-total p {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.totals {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.total-item {
  text-align: center;
}

.total-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.total-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Meal Category Styles */
.diary-day {
  margin-bottom: 32px;
}

.diary-date-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  padding: 16px 24px;
  border-radius: 16px 16px 0 0;
  margin-bottom: 0;
}

.diary-date-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.meal-category {
  border-radius: 0;
  margin-bottom: 0;
  border-bottom: 1px solid #e2e8f0;
}

.meal-category:last-of-type {
  border-bottom: none;
}

.meal-type-header {
  background: #f1f5f9;
  padding: 12px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.meal-type-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0;
}

.meal-count {
  font-size: 0.875rem;
  color: #6b7280;
  background: white;
  padding: 4px 12px;
  border-radius: 20px;
}

.subtotal-row {
  background: #f8fafc;
}

.subtotal-row td {
  padding: 12px 16px !important;
  border-top: 1px solid #e2e8f0;
}

.diary-day .daily-total {
  border-radius: 0 0 16px 16px;
  margin-top: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0 0 12px 0;
}

.empty-state p {
  font-size: 1rem;
  color: var(--ht-text-muted);
  margin: 0 0 24px 0;
}

/* Search Styles */
.search-header {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--ht-shadow-sm);
  margin-bottom: 24px;
}

.header-links {
  display: flex;
  gap: 12px;
}

.back-link {
  padding: 8px 16px;
  background: var(--ht-surface-muted);
  color: var(--ht-text-secondary);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-link:hover {
  background: var(--ht-border);
  color: var(--ht-text);
}

.search-box,
.search-box-off {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.search-input {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--ht-border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--ht-surface);
  color: var(--ht-text);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-button {
  padding: 14px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.search-button__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.search-button__label {
  line-height: 1.2;
}

.search-button:hover,
.search-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  color: #ffffff;
}

.results-info {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  padding: 12px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  color: #065f46;
  font-weight: 500;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.food-item {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--ht-shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  transition: all 0.3s ease;
}

.food-item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.food-details {
  flex: 1;
}

.food-details .food-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ht-text);
  margin-bottom: 4px;
}

.food-brand {
  font-size: 0.875rem;
  color: var(--ht-text-muted);
  margin-bottom: 12px;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.nutrition-item.protein {
  border-left-color: #3b82f6;
}

.nutrition-item.carbs {
  border-left-color: #10b981;
}

.nutrition-item.fat {
  border-left-color: #f59e0b;
}

.nutrition-item.calories {
  border-left-color: #ef4444;
}

.nutrition-item.energy {
  border-left-color: #8b5cf6;
}

.nutrition-label {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nutrition-unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 2px;
}

.meal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-meal-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: all 0.3s ease;
}

.add-meal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.date-input {
  padding: 10px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.date-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 8px 14px;
  background: white;
  color: #475569;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.page-btn:hover {
  border-color: #667eea;
  color: #667eea;
  background: #f8fafc;
}

.page-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border-color: #667eea;
}

.page-btn.active:hover,
.page-btn.active:focus-visible {
  color: #ffffff;
}

/* Meal Planner Specific Styles */
/* Header Content */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header h1,
.header-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ht-text);
  margin: 0;
}

/* Recipe Cards */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.recipe-card {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--ht-shadow-sm);
  transition: all 0.3s ease;
}

.recipe-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.recipe-card .card-header {
  background: var(--ht-surface-muted);
  border-bottom: 1px solid var(--ht-border);
  color: var(--ht-text);
  padding: 16px 18px;
}

.recipe-card .card-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ht-text);
}

.recipe-card .card-header p {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0;
}

.recipe-card .card-content {
  padding: 20px;
}

/* Recipe Info */
.recipe-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 0.75rem;
  color: var(--ht-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 0.95rem;
  color: var(--ht-text);
  font-weight: 600;
}

.recipe-description {
  font-size: 0.875rem;
  color: var(--ht-text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--ht-border);
}

/* Card Actions */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-btn.view {
  background: #2563eb;
  color: #ffffff;
}

.action-btn.view:hover,
.action-btn.view:focus-visible {
  background: #1d4ed8;
  color: #ffffff;
}

.action-btn.scale {
  background: #0ea5e9;
  color: #ffffff;
}

.action-btn.scale:hover,
.action-btn.scale:focus-visible {
  background: #0284c7;
  color: #ffffff;
}

.action-btn.share {
  background: #059669;
  color: #ffffff;
}

.action-btn.share:hover,
.action-btn.share:focus-visible {
  background: #047857;
  color: #ffffff;
}

/* Meal Plans Grid */
.meal-plans-grid,
.grocery-lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.meal-plan-card,
.grocery-list-card {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--ht-shadow-sm);
  transition: all 0.3s ease;
}

.meal-plan-card:hover,
.grocery-list-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.meal-plan-card .card-header,
.grocery-list-card .card-header {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 20px;
}

.meal-plan-card .card-header h3,
.grocery-list-card .card-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.meal-plan-card .card-header p,
.grocery-list-card .card-header p {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.stat-item {
  text-align: center;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.stat-item .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.list-stats {
  margin-bottom: 16px;
}

.list-stats .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

.list-stats .stat-item:last-child {
  border-bottom: none;
}

.list-stats .stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  text-transform: none;
}

.list-stats .stat-value {
  font-size: 1rem;
  color: #1f2937;
  margin: 0;
}

.list-stats .stat-value.purchased {
  color: #10b981;
}

/* Meal Plan Info */
.meal-plan-info {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.meal-plan-label {
  font-size: 0.75rem;
  color: #065f46;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.meal-plan-name {
  font-size: 0.95rem;
  color: #047857;
  font-weight: 600;
}

/* Button Small Variant */
.btn-small,
.btn.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* Form Container */
.form-container {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  box-shadow: var(--ht-shadow-sm);
  overflow: hidden;
  margin-top: 24px;
}

.form-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px;
}

.form-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.form-header-intro {
  margin: 0.5rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  max-width: 42rem;
}

.form-content {
  padding: 24px;
}

.form-help {
  font-size: 0.9rem;
  color: var(--ht-text-muted);
  margin-top: 4px;
}

.error-message {
  font-size: 0.813rem;
  color: #dc2626;
  margin-top: 4px;
  font-weight: 500;
}

/* Section Divider */
.section-divider {
  margin: 32px 0;
  padding: 24px 0;
  border-top: 2px solid #e5e7eb;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0 0 20px 0;
}

/* Macros Grid */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.macro-input {
  position: relative;
}

.macro-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.macro-label.protein {
  color: #3b82f6;
}

.macro-label.carbs {
  color: #10b981;
}

.macro-label.fat {
  color: #f59e0b;
}

.macro-percentage {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  font-weight: 600;
  color: #6b7280;
  pointer-events: none;
}

.macro-input .form-input {
  padding-right: 40px;
}

.info-note {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
}

.info-note p {
  font-size: 0.875rem;
  color: #92400e;
  margin: 0;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid #e5e7eb;
}

.macro-ratio-manage-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.macro-ratio-manage-help {
  margin: -0.35rem 0 1rem;
}

.macro-ratio-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}

.macro-ratio-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.macro-ratio-table th,
.macro-ratio-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.macro-ratio-table thead th {
  background: #f1f5f9;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  text-align: left;
}

.macro-ratio-table tbody tr:last-child th,
.macro-ratio-table tbody tr:last-child td {
  border-bottom: none;
}

.macro-ratio-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.macro-ratio-table__name {
  font-size: 0.975rem;
  font-weight: 600;
  color: #1f2937;
  text-align: left;
  min-width: 10rem;
}

.macro-ratio-table__num {
  width: 6.5rem;
  text-align: center;
  font-size: 0.975rem;
  font-weight: 700;
  color: #334155;
}

.macro-ratio-table__carbs {
  color: #166534;
}

.macro-ratio-table__protein {
  color: #1e40af;
}

.macro-ratio-table__fat {
  color: #9d174d;
}

.macro-ratio-table__actions {
  width: 11rem;
  text-align: right;
  white-space: nowrap;
}

.macro-ratio-table__action-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.macro-ratio-delete-form {
  display: inline;
  margin: 0;
}

.btn-compact {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
}

@media (max-width: 640px) {
  .macro-ratio-table__actions {
    white-space: normal;
  }

  .macro-ratio-table__action-group {
    width: 100%;
    justify-content: stretch;
  }

  .macro-ratio-table__action-group .btn-compact {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }
}

/* Sub Text */
.sub-text {
  font-size: 0.875rem;
  color: #9ca3af;
  margin-top: 8px;
}

/* Messages Container */
.messages {
  margin-bottom: 24px;
}

/* Additional Tailwind-like Utilities */
.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.space-x-2 > * + * {
  margin-left: 0.5rem;
}

.space-x-3 > * + * {
  margin-left: 0.75rem;
}

.space-x-4 > * + * {
  margin-left: 1rem;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prose {
  max-width: 65ch;
  color: #374151;
  font-size: 1rem;
  line-height: 1.75;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul {
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  padding-left: 1.625rem;
  list-style-type: disc;
}

.prose li {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.max-w-none {
  max-width: none;
}

.rounded-xl {
  border-radius: 0.75rem;
}

.bg-orange-600 {
  background-color: #ea580c;
}

.text-orange-600 {
  color: #ea580c;
}

.inline-flex {
  display: inline-flex;
}

/* Responsive Design */
@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
  .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md\:text-xl { font-size: 1.25rem; line-height: 1.75rem; }
  .md\:px-8 { padding-left: 2rem; padding-right: 2rem; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .nav-item .dropdown-content {
    position: static;
    visibility: visible;
    opacity: 1;
    box-shadow: none;
    background: transparent;
    padding: 0;
    margin: 0;
  }
  
  .dropdown-content a {
    padding: 4px 0;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .dropdown-content a:hover {
    background: transparent;
  }

  /* Nutrition Pages - Mobile */
  .diary-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .diary-controls {
    width: 100%;
    flex-direction: column;
  }

  .diary-controls form,
  .diary-controls a {
    width: 100%;
  }

  /*
   * Food search (narrow screens): field + icon-only submit on one row; region full-width below.
   */
  .app-main .search-box,
  .app-main .search-box-off,
  .app-guest-main .search-box,
  .search-header .search-box {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .app-main .search-box > .search-input,
  .app-main .search-box-off > .search-input,
  .app-guest-main .search-box > .search-input,
  .search-header .search-box > .search-input {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: 100%;
  }

  .app-main .search-box > .search-button,
  .app-main .search-box-off > .search-button,
  .app-guest-main .search-box > .search-button,
  .search-header .search-box > .search-button {
    order: 2;
    flex: 0 0 auto;
    width: auto !important;
    max-width: none;
    padding: 12px 14px;
    min-width: 48px;
    min-height: 48px;
  }

  .app-main .search-box > .search-button .search-button__label,
  .app-main .search-box-off > .search-button .search-button__label,
  .app-guest-main .search-box > .search-button .search-button__label,
  .search-header .search-box > .search-button .search-button__label {
    display: none !important;
  }

  .app-main .search-box > select,
  .app-main .search-box-off > select,
  .app-guest-main .search-box > select,
  .search-header .search-box > select,
  #food-search-panel-off .search-box-off > select {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #food-search-panel-off .search-box-off {
    align-items: stretch;
  }

  /* Flex/grid search rows and food search bars */
  .app-main .plan-food-search,
  .app-main .recipe-search-row,
  .app-main .recipe-list-search-row,
  .app-main .exercise-library-search-row,
  .app-main .range-inputs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .app-main .plan-food-search input,
  .app-main .plan-food-search select,
  .app-main .recipe-search-row .form-input,
  .app-main .recipe-list-search-row .recipe-list-search-input,
  .app-main .exercise-library-search {
    flex: 1 1 12rem;
    min-width: 0;
    max-width: 100%;
  }

  .food-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .meal-actions {
    width: 100%;
  }

  .add-meal-btn {
    width: 100%;
  }

  .table {
    font-size: 0.875rem;
  }

  .table thead th,
  .table tbody td {
    padding: 8px 12px;
  }

  .totals {
    gap: 16px;
  }

  /* Meal Planner Pages - Mobile */
  .recipes-grid,
  .meal-plans-grid,
  .grocery-lists-grid {
    grid-template-columns: 1fr;
  }

  .recipe-info {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .macros-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    flex-direction: column;
  }

  .card-actions .action-btn,
  .card-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-content .btn {
    width: 100%;
  }
}

/* Nutrition Goals Progress Section */
.goals-progress-section {
  margin-bottom: 1.5rem;
}

.goals-progress-section .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.edit-goals-link {
  font-size: 0.875rem;
  color: #667eea;
  text-decoration: none;
}

.edit-goals-link:hover {
  text-decoration: underline;
}

.nutrition-goals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .nutrition-goals-grid {
    grid-template-columns: 1fr;
  }
}

.goal-item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1rem;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.goal-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
}

.goal-values {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

.progress-bar-container {
  height: 10px;
  background: #e5e7eb;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
  max-width: 100%;
}

.progress-bar.calories {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.progress-bar.protein {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.progress-bar.carbs {
  background: linear-gradient(90deg, #10b981, #059669);
}

.progress-bar.fat {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.goal-percentage {
  text-align: right;
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

/* Copy from Previous Meals Section */
.copy-section {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.copy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  cursor: pointer;
  user-select: none;
}

.copy-header:hover,
.copy-header:focus-visible {
  background: linear-gradient(135deg, #5a6fd6, #6a4190);
  color: #ffffff;
}

.copy-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.toggle-icon {
  font-size: 0.875rem;
  transition: transform 0.3s ease;
}

.copy-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1.5rem;
}

.copy-content.expanded {
  max-height: 800px;
  padding: 1.5rem;
}

.copy-description {
  color: #6b7280;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.copy-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .copy-controls {
    grid-template-columns: 1fr;
  }
}

.copy-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.copy-control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.copy-meals-list {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.copy-meals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.copy-meals-header .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  color: #374151;
}

.copy-meal-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.2s;
}

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

.copy-meal-item:hover {
  background: #f9fafb;
}

.copy-meal-item .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  flex: 1;
}

.copy-meal-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.copy-meal-type {
  font-size: 0.75rem;
  color: #6b7280;
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.copy-meal-name {
  font-weight: 500;
  color: #1f2937;
}

.copy-meal-amount {
  font-size: 0.875rem;
  color: #6b7280;
}

.copy-meal-nutrition {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nutrition-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
}

.nutrition-badge.kcal {
  background: #fef3c7;
  color: #92400e;
}

.nutrition-badge.protein {
  background: #dbeafe;
  color: #1e40af;
}

.nutrition-badge.carbs {
  background: #d1fae5;
  color: #065f46;
}

.nutrition-badge.fat {
  background: #ffedd5;
  color: #9a3412;
}

.copy-loading, .copy-empty {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

/* ========================================
   Enhanced Diary Styles
   ======================================== */

.diary-container {
  max-width: 1000px;
  margin: 0 auto;
}

.diary-page-header {
  margin-bottom: 1.5rem;
}

.diary-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.diary-title-row h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

/* Time Frame Selector */
.timeframe-selector {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeframe-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.timeframe-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  color: #4b5563;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.timeframe-tab:hover {
  background: #e5e7eb;
  color: #1f2937;
}

.timeframe-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #ffffff;
}

.timeframe-tab.active:hover,
.timeframe-tab.active:focus-visible {
  color: #ffffff;
}

.tab-icon {
  font-size: 1rem;
}

.tab-label {
  display: none;
}

@media (min-width: 640px) {
  .tab-label {
    display: inline;
  }
}

/* Custom Range Picker */
.custom-range-picker {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.custom-range-picker.hidden {
  display: none;
}

.custom-range-form {
  display: flex;
  align-items: flex-end;
}

.range-inputs {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.range-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.range-input-group label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

.range-input-group .form-input {
  width: 150px;
}

.range-separator {
  color: #9ca3af;
  font-size: 1.25rem;
  padding-bottom: 0.5rem;
}

.date-range-display {
  margin-top: 0.5rem;
}

.date-range-text {
  color: #6b7280;
  font-size: 0.875rem;
}

/* Period Summary Cards */
.period-summary {
  margin-bottom: 1.5rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }
}

.summary-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-left: 4px solid;
}

.summary-card.calories-card { border-left-color: #f59e0b; }
.summary-card.protein-card { border-left-color: #3b82f6; }
.summary-card.carbs-card { border-left-color: #10b981; }
.summary-card.fat-card { border-left-color: #f97316; }

.card-icon {
  font-size: 1.5rem;
  opacity: 0.9;
}

.card-content {
  flex: 1;
}

.card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.2;
}

.card-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-avg {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

.summary-meta {
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

.meta-separator {
  margin: 0 0.5rem;
}

/* Diary Days */
.diary-days {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diary-day-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Day Header */
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #e5e7eb;
}

.day-header:hover {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.day-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.day-toggle {
  color: #9ca3af;
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.day-info {
  display: flex;
  flex-direction: column;
}

.day-date {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.day-full-date {
  font-size: 0.8rem;
  color: #6b7280;
}

.day-header-right {
  display: flex;
  align-items: center;
}

.day-quick-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-stat {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.quick-stat.calories { background: #fef3c7; color: #92400e; }
.quick-stat.protein { background: #dbeafe; color: #1e40af; }
.quick-stat.carbs { background: #d1fae5; color: #065f46; }
.quick-stat.fat { background: #ffedd5; color: #9a3412; }

/* Day Content */
.day-content {
  padding: 0;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.day-content.collapsed {
  max-height: 0;
  padding: 0;
}

/* Meal Sections */
.meal-section {
  border-bottom: 1px solid #f3f4f6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.meal-section:last-child {
  border-bottom: none;
}

.meal-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: #fafafa;
}

.meal-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.meal-type-badge.breakfast { background: #fef3c7; color: #92400e; }
.meal-type-badge.lunch { background: #fef9c3; color: #854d0e; }
.meal-type-badge.dinner { background: #ede9fe; color: #5b21b6; }
.meal-type-badge.snack { background: #fce7f3; color: #9d174d; }

.meal-section-stats {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
}

/* Meal Entries */
.meal-entries {
  padding: 0;
}

.meal-entry {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f9fafb;
  gap: 1rem;
  transition: background 0.2s;
}

.meal-entry:hover {
  background: #fafafa;
}

.meal-entry:last-child {
  border-bottom: none;
}

.meal-entry.highlight {
  background: #fef3c7;
}

.entry-main {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.entry-time {
  font-size: 0.8rem;
  color: #9ca3af;
  font-weight: 500;
  min-width: 45px;
}

.entry-details {
  flex: 1;
  min-width: 0;
}

.entry-name {
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-amount {
  font-size: 0.8rem;
  color: #6b7280;
}

.entry-nutrition {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.nutrition-pill {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.nutrition-pill.protein { background: #dbeafe; color: #1e40af; }
.nutrition-pill.carbs { background: #d1fae5; color: #065f46; }
.nutrition-pill.fat { background: #ffedd5; color: #9a3412; }
.nutrition-pill.calories { background: #fef3c7; color: #92400e; }

.entry-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.entry-action {
  padding: 0.25rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: all 0.2s;
  text-decoration: none;
}

.entry-action:hover {
  opacity: 1;
  background: #f3f4f6;
}

.entry-action.delete:hover {
  background: #fee2e2;
}

/* Day Total Bar (food diary grid footer; mirrors .day-total-bar-inner in diary extra_head) */
.day-total-bar {
  display: block;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border-top: 1px solid #e5e7eb;
}

.day-total-bar-inner {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) minmax(2.85rem, 3.85rem) minmax(2.85rem, 3.85rem) minmax(2.85rem, 3.85rem) minmax(2.85rem, 3.85rem);
  gap: 0.25rem 0.45rem;
  align-items: center;
  font-size: 0.83rem;
  min-width: min(100%, 32rem);
}

.day-total-label {
  grid-column: 1 / span 2;
  font-weight: 700;
  color: #4b5563;
  font-size: 0.9rem;
}

.day-total-val {
  font-weight: 640;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.day-total-val.cb { color: #047857; }
.day-total-val.pr { color: #1d4ed8; }
.day-total-val.ft { color: #c2410c; }
.day-total-val.kc { color: #92400e; }

.day-total-values {
  display: flex;
  gap: 1rem;
}

.total-value {
  font-weight: 600;
  font-size: 0.85rem;
}

.total-value.protein { color: #2563eb; }
.total-value.carbs { color: #059669; }
.total-value.fat { color: #ea580c; }
.total-value.calories { color: #d97706; }

/* Empty State */
.empty-diary {
  text-align: center;
  padding: 4rem 2rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-diary h3 {
  font-size: 1.25rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.empty-diary p {
  color: #6b7280;
  margin-bottom: 1.5rem;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .day-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .day-header-right {
    width: 100%;
  }
  
  .day-quick-stats {
    width: 100%;
    justify-content: flex-start;
  }
  
  .meal-entry {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .entry-main {
    width: 100%;
  }
  
  .entry-nutrition {
    width: 100%;
    justify-content: flex-start;
  }
  
  .entry-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .day-total-bar-inner {
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .day-total-values {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* =============================================================================
   App shell: three-column light layout (primary nav | shortcuts | workspace)
   ============================================================================= */
.app-html {
  height: 100%;
}

.app-body {
  height: 100%;
  min-height: 100vh;
  color: var(--ht-text);
  background: var(--ht-canvas);
}

.app-body:not(.app-body--guest) {
  height: 100vh;
  overflow: hidden;
}

.app-body--guest {
  color: var(--ht-text);
  background: var(--ht-canvas);
}

/* Backdrop (mobile primary nav) */
.app-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-backdrop.is-visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.app-layout {
  display: grid;
  height: 100vh;
  min-height: 0;
  grid-template-columns: 240px 1fr;
  grid-template-areas: "pri main";
  background: #f4f6fb;
}

.app-sidebar--primary {
  grid-area: pri;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  min-height: 0;
  height: 100vh;
  z-index: 50;
  transition: transform 0.2s ease;
  box-shadow: 1px 0 0 rgba(15, 23, 42, 0.04);
}

.app-workspace {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  background: #f4f6fb;
}

.app-workspace__toolbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--ht-border);
  background: var(--ht-surface);
  flex-shrink: 0;
  box-shadow: var(--ht-shadow-sm);
}

.app-mobile-nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border: 1px solid var(--ht-border);
  border-radius: 8px;
  background: var(--ht-surface);
  color: var(--ht-text);
  cursor: pointer;
}

.app-mobile-nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ht-text);
  border-radius: 1px;
}

.app-workspace__mobile-brand {
  font-weight: 600;
  color: var(--ht-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.app-workspace__mobile-brand .app-logo__mark {
  width: 1.5rem;
  height: 1.5rem;
}

.app-workspace__mobile-brand .app-logo__mark svg {
  width: 0.85rem;
  height: 0.85rem;
}

.app-main {
  flex: 1;
  min-height: 0;
  padding: 1.25rem 1.25rem 1.5rem;
  overflow: auto;
}

/* Optional per-page shortcuts (see {% block contextual_nav %} in base.html) */
.contextual-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 0.9rem;
  margin: 0 0 1rem;
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: 10px;
  box-shadow: var(--ht-shadow-sm);
}

.contextual-nav__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ht-text-muted);
  flex-shrink: 0;
}

.contextual-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.contextual-nav__link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ht-text-secondary);
  text-decoration: none;
  border: 1px solid var(--ht-border);
  background: var(--ht-surface-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.contextual-nav__link:hover,
.contextual-nav__link:focus-visible {
  background: var(--ht-accent-light);
  border-color: var(--ht-border-strong);
  color: var(--ht-accent-hover);
}

.contextual-nav__link--current {
  background: var(--ht-accent-light);
  border-color: var(--ht-accent);
  color: var(--ht-accent-hover);
  font-weight: 600;
}

.app-main .contextual-nav .contextual-nav__link {
  color: var(--ht-text-secondary);
}

.app-main .contextual-nav .contextual-nav__link:hover,
.app-main .contextual-nav .contextual-nav__link:focus-visible {
  color: var(--ht-accent-hover);
}

.app-main .contextual-nav .contextual-nav__link--current {
  color: var(--ht-accent-hover);
}

.app-main .contextual-nav .contextual-nav__link:visited {
  color: var(--ht-text-secondary);
}

.app-main .contextual-nav .contextual-nav__link--current:visited {
  color: var(--ht-accent-hover);
}

/* Mobile: fold contextual shortcut strips (collapsed by default); ≥769px unchanged */
.contextual-nav__shortcut-mobile-toggle {
  display: none;
}
@media (max-width: 768px) {
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible .contextual-nav__shortcut-desktop-label {
    display: none;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible .contextual-nav__shortcut-mobile-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: #0f172a;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible .contextual-nav__shortcut-mobile-toggle:focus-visible {
    outline: 2px solid #818cf8;
    outline-offset: 2px;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible .contextual-nav__shortcut-mobile-toggle .contextual-nav__label {
    margin: 0;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible .contextual-nav__shortcut-toggle-chevron {
    flex-shrink: 0;
    font-size: 0.65rem;
    color: #64748b;
    transition: transform 0.15s ease;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible.is-shortcut-expanded .contextual-nav__shortcut-toggle-chevron {
    transform: rotate(-180deg);
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible:not(.is-shortcut-expanded) .contextual-nav__links {
    display: none;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible.is-shortcut-expanded .contextual-nav__links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }
  .contextual-nav.contextual-nav--shortcut-mobile-collapsible.is-shortcut-expanded .contextual-nav__link {
    justify-content: center;
  }
}

/* Primary sidebar */
.app-sidebar__brand {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.app-logo {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ht-text);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.app-sidebar__user {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.app-sidebar__user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.app-sidebar__user-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ht-text-muted);
}

.app-sidebar__profile-link {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: #4f46e5;
  text-decoration: none;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.app-sidebar__profile-link:hover,
.app-sidebar__profile-link:focus-visible {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.app-sidebar__profile-link.is-active {
  background: #e8edff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.app-sidebar__user-email {
  display: block;
  font-size: 0.8rem;
  color: var(--ht-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.app-sidebar__nav {
  flex: 1;
  padding: 0.5rem 0.35rem 1rem;
  overflow: auto;
  overflow-anchor: none;
}

.app-nav-group {
  margin-top: 0.5rem;
}

.app-nav-group--ungrouped {
  margin-top: 0;
}

.app-nav-group__label {
  display: block;
  padding: 0.4rem 0.6rem 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ht-text-muted);
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.1rem 0;
  padding: 0.48rem 0.62rem 0.48rem 0.55rem;
  border-radius: 8px;
  color: var(--ht-text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid transparent;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.app-nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 1px;
  background: #0d9488;
  opacity: 0;
  transition: opacity 0.15s;
}

.app-nav-link:hover {
  background: var(--ht-accent-light);
  color: var(--ht-text);
}

.app-nav-link.is-active {
  background: var(--ht-accent-light);
  color: var(--ht-accent-hover);
  border-color: var(--ht-border-strong);
}

.app-nav-link.is-active::before {
  opacity: 1;
}

.app-nav-icon {
  font-size: 0.95rem;
  opacity: 0.9;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.app-nav-link--muted {
  color: #94a3b8;
  font-weight: 400;
}

/* POST logout: button styled as sidebar nav link */
.app-nav-logout-form {
  margin: 0.1rem 0;
}

button.app-nav-link.app-nav-link--submit {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
}

.app-inline-logout-form {
  display: inline;
  margin: 0;
  padding: 0;
}

button.app-link-as-text {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.app-nav-group--foot {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

/* Footer in workspace */
.app-footer {
  border-top: 1px solid var(--ht-border);
  padding: 0.6rem 1.25rem;
  font-size: 0.75rem;
  color: var(--ht-text-muted);
  background: var(--ht-surface);
  flex-shrink: 0;
}

.app-footer p {
  margin: 0;
}

/* Context messages (auth) */
.app-messages {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.app-message {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  border: 1px solid;
}

.app-message--success {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}

.app-message--error,
.app-message--danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.app-message--warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.app-message--info,
.app-message--debug {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

/* Guest */
.app-guest-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
}

.app-guest-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-logo--guest {
  font-size: 1.1rem;
  color: #0f172a;
}

.app-guest-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-guest-main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: 60vh;
  color: var(--ht-text);
  background: transparent;
}

.app-guest-messages {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.app-footer--guest {
  text-align: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
  color: var(--ht-text-muted);
  background: transparent;
  border: none;
}

/* Buttons in shell */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
}

.app-btn--ghost {
  color: #334155;
  background: #ffffff;
  border-color: #e2e8f0;
}

.app-btn--ghost:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.app-btn--accent {
  color: #ffffff;
  background: #0d9488;
  border-color: #0d9488;
}

.app-btn--accent:hover {
  background: #0f766e;
  border-color: #0f766e;
}

/* --- Workspace: align dashboard & cards with light chrome --- */
.app-main .container {
  max-width: 1280px;
  padding: 0;
}

.app-main .header {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  color: var(--ht-text);
  box-shadow: var(--ht-shadow-sm);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  text-align: left;
}

.app-main .header h1,
.app-main .header h2 {
  color: var(--ht-text);
}

.app-main .header h1 {
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
}

.app-main .header:has(.header-actions) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  flex-wrap: nowrap;
}

.app-main .header:has(.header-actions) > h1 {
  flex: 1 1 auto;
  min-width: 0;
}

.app-main .header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.app-main .header-actions .inline {
  display: inline-flex;
}

@media (max-width: 640px) {
  .app-main .header:has(.header-actions) {
    flex-wrap: wrap;
  }

  .app-main .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Detail grids (tasks, workouts, goals, plans) */
.app-main .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.875rem;
}

@media (min-width: 768px) {
  .app-main .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}

@media (min-width: 1100px) {
  .app-main .workout-log-detail .detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.app-main .detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
  padding: 0.875rem 1rem;
  background: var(--ht-surface-muted);
  border-radius: 10px;
  border: 1px solid var(--ht-border);
}

.app-main .detail-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ht-text-muted);
}

.app-main .detail-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ht-text);
  line-height: 1.45;
  word-break: break-word;
}

.app-main .detail-value--empty {
  color: var(--ht-text-muted);
  font-weight: 500;
}

.app-main .detail-value__hint {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ht-text-secondary);
  line-height: 1.4;
}

/* Workout log detail: align card chrome with app workspace */
.app-main .workout-log-detail > .card {
  padding: 1.25rem 1.35rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: none;
}

.app-main .workout-log-detail > .card:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-main .workout-log-detail > .card .action-header {
  margin-bottom: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f7;
}

.app-main .workout-log-detail > .card .action-header:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.app-main .card-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ht-border);
  border-radius: 10px;
  background: var(--ht-surface);
}

.app-main .workout-log-detail > .card .card-table-wrap {
  margin: 0.75rem -0.125rem 0 -0.125rem;
}

@media (min-width: 640px) {
  .app-main .workout-log-detail > .card .card-table-wrap {
    margin-left: 0;
    margin-right: 0;
  }
}

.app-main table.data-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.app-main table.data-table thead th {
  background: var(--ht-surface-muted);
  padding: 10px 14px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: var(--ht-text-secondary);
  text-align: left;
  white-space: nowrap;
  vertical-align: bottom;
  border-bottom: 1px solid var(--ht-border);
}

.app-main table.data-table tbody td {
  padding: 11px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--ht-border);
  color: var(--ht-text);
}

.app-main table.data-table tbody tr:last-child td {
  border-bottom: none;
}

.app-main table.data-table td.data-table__cell-muted {
  color: var(--ht-text-secondary);
  white-space: normal;
  word-break: break-word;
}

.app-main table.data-table--met {
  min-width: 620px;
}

.app-main table.data-table--met th:nth-child(1),
.app-main table.data-table--met td:nth-child(1) {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
}

.app-main table.data-table--met th:nth-child(2),
.app-main table.data-table--met td:nth-child(2) {
  min-width: 12rem;
}

.app-main table.data-table--met th:nth-child(3),
.app-main table.data-table--met td:nth-child(3),
.app-main table.data-table--met th:nth-child(4),
.app-main table.data-table--met td:nth-child(4),
.app-main table.data-table--met th:nth-child(5),
.app-main table.data-table--met td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}

.app-main table.data-table--sets {
  min-width: 520px;
}

.app-main table.data-table--sets th:nth-child(3),
.app-main table.data-table--sets td:nth-child(3),
.app-main table.data-table--sets th:nth-child(4),
.app-main table.data-table--sets td:nth-child(4) {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-main .workout-log-met-hint {
  margin: 0;
  padding: 4px 0 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
  max-width: 48rem;
}

.app-main .workout-log-detail__notes {
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.app-main .workout-log-detail__notes-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 0.45rem;
}

.app-main .workout-log-detail__notes-body {
  margin: 0;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.5;
  white-space: pre-wrap;
}

.app-main .header.workout-history-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: nowrap;
}

.app-main .header.workout-history-page-header h1 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.app-main .header.workout-history-page-header .workout-history-page-header__cta {
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
  white-space: nowrap;
}

.app-main .header.workout-history-page-header .workout-history-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.app-main .header.workout-history-page-header .workout-history-page-header__actions .workout-history-page-header__cta {
  margin-left: 0;
}

@media (max-width: 560px) {
  .app-main .header.workout-history-page-header {
    flex-wrap: wrap;
  }

  .app-main .header.workout-history-page-header .workout-history-page-header__cta {
    margin-left: 0;
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .app-main .header.workout-history-page-header .workout-history-page-header__actions {
    margin-left: 0;
    width: 100%;
  }

  .app-main .header.workout-history-page-header .workout-history-page-header__actions .workout-history-page-header__cta {
    flex: 1 1 auto;
  }
}

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

.app-main .exercise-progress-picker {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.app-main .exercise-progress-picker__title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ht-text);
}

.app-main .exercise-progress-picker__hint,
.app-main .exercise-progress-add__hint {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  color: var(--ht-text-muted, #64748b);
  line-height: 1.45;
}

.app-main .exercise-progress-picker__form {
  margin-bottom: 0.85rem;
}

.app-main .exercise-progress-picker__row {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto auto;
  gap: 0.55rem;
  align-items: center;
}

.app-main .exercise-progress-picker__input {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.app-main .exercise-progress-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.app-main a.exercise-progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--ht-border, #e2e8f0);
  background: var(--ht-surface, #fff);
  color: var(--ht-text, #0f172a);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.2;
}

.app-main a.exercise-progress-chip:hover {
  border-color: #94a3b8;
  color: var(--ht-accent-hover);
  text-decoration: none;
  transform: translateY(-1px);
}

.app-main a.exercise-progress-chip.is-active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
  color: #4338ca;
}

.app-main .exercise-progress-chip__meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.12);
  font-size: 0.72rem;
  font-weight: 600;
}

.app-main .exercise-progress-add {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--ht-border, #e2e8f0);
  border-radius: 10px;
  background: var(--ht-surface-muted, #f8fafc);
}

.app-main .exercise-progress-add__title {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 600;
}

.app-main .exercise-progress-stats {
  margin-bottom: 1rem;
}

.app-main .exercise-progress-chart__header .workout-history-metric-switch {
  margin: 0;
}

@media (max-width: 720px) {
  .app-main .exercise-progress-picker__row {
    grid-template-columns: 1fr 1fr;
  }

  .app-main .exercise-progress-picker__input {
    grid-column: 1 / -1;
  }

  .app-main .exercise-progress-picker__row .btn {
    width: 100%;
    justify-content: center;
  }

  .app-main .exercise-progress-chart__header {
    align-items: flex-start;
  }

  .app-main .exercise-progress-chart__header .progress-weight-chart-unified__tools {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 440px) {
  .app-main .exercise-progress-picker {
    padding: 1rem;
  }

  .app-main .exercise-progress-picker__row {
    grid-template-columns: 1fr;
  }

  .app-main .exercise-progress-picker__input {
    grid-column: auto;
  }

  .app-main .exercise-progress-chip-row {
    flex-direction: column;
  }

  .app-main a.exercise-progress-chip {
    width: 100%;
    justify-content: space-between;
  }
}


.app-main .chart-container {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  box-shadow: var(--ht-shadow-sm);
  border-radius: 12px;
}

.app-main .chart-title,
.app-main h2.chart-title,
.app-main h3 {
  color: var(--ht-text);
}

.app-main .chart-subtitle,
.app-main .nutrient-legend__label,
.app-main .nutrient-legend__value,
.app-main .chart-info {
  color: var(--ht-text-muted);
}

.app-main .chart-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #64748b;
}

.app-main .chart-btn:hover {
  border-color: #0d9488;
  color: #0d9488;
  background: #f0fdfa;
}

.app-main .chart-btn.active {
  background: #ccfbf1;
  border-color: #0d9488;
  color: #0f766e;
}

.app-main .nutrient-breakdown {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.app-main .nutrient-item-detail {
  border-color: #e2e8f0;
}

.app-main .nutrient-label-text,
.app-main .nutrient-amount,
.app-main .day-card__title,
.app-main .day-card__date {
  color: var(--ht-text);
}

.app-main a {
  color: var(--ht-accent);
}

.app-main a:hover {
  color: var(--ht-accent-hover);
}

/* Link-styled buttons: .app-main a wins over .btn-* (class + element vs one class) */
.app-main a.btn-primary {
  color: #ffffff;
}

.app-main a.btn-primary:hover,
.app-main a.btn-primary:focus-visible {
  color: #ffffff;
}

.app-main a.btn-primary:visited {
  color: #ffffff;
}

.app-main a.btn-secondary {
  color: #667eea;
}

.app-main a.btn-secondary:hover,
.app-main a.btn-secondary:focus-visible {
  color: #ffffff;
}

.app-main a.btn-secondary:visited {
  color: #667eea;
}

.app-main a.btn-danger {
  color: #ffffff;
}

.app-main a.btn-danger:hover,
.app-main a.btn-danger:focus-visible {
  color: #ffffff;
}

.app-main a.btn-danger:visited {
  color: #ffffff;
}

.app-main a.btn-success {
  color: #ffffff;
}

.app-main a.btn-success:hover,
.app-main a.btn-success:focus-visible {
  color: #ffffff;
}

.app-main a.btn-success:visited {
  color: #ffffff;
}

.app-main a.meal-plan-create-btn,
.app-main a.meal-plan-create-btn:hover,
.app-main a.meal-plan-create-btn:focus-visible {
  color: #ffffff;
}

.app-main a.meal-plan-create-btn:visited {
  color: #ffffff;
}

.app-main a.add-meal-btn,
.app-main a.add-meal-btn:hover,
.app-main a.add-meal-btn:focus-visible {
  color: #ffffff;
}

.app-main a.add-meal-btn:visited {
  color: #ffffff;
}

.app-main a.action-btn.view,
.app-main a.action-btn.view:hover,
.app-main a.action-btn.view:focus-visible {
  color: #ffffff;
}

.app-main a.action-btn.view:visited {
  color: #ffffff;
}

.app-main a.action-btn.edit,
.app-main a.action-btn.edit:hover,
.app-main a.action-btn.edit:focus-visible {
  color: #ffffff;
}

.app-main a.action-btn.edit:visited {
  color: #ffffff;
}

.app-main a.action-btn.delete {
  color: #dc2626;
}

.app-main a.action-btn.delete:hover,
.app-main a.action-btn.delete:focus-visible {
  color: #dc2626;
}

.app-main a.action-btn.scale,
.app-main a.action-btn.scale:hover,
.app-main a.action-btn.scale:focus-visible {
  color: #ffffff;
}

.app-main a.action-btn.scale:visited {
  color: #ffffff;
}

.app-main a.action-btn.share,
.app-main a.action-btn.share:hover,
.app-main a.action-btn.share:focus-visible {
  color: #ffffff;
}

.app-main a.action-btn.share:visited {
  color: #ffffff;
}

.app-main a.page-btn {
  color: #475569;
}

.app-main a.page-btn:hover {
  color: #667eea;
}

.app-main a.page-btn.active,
.app-main a.page-btn.active:hover,
.app-main a.page-btn.active:focus-visible {
  color: #ffffff;
}

.app-main a.page-btn.active:visited {
  color: #ffffff;
}

.app-main .day-card,
.app-main .form-card,
.app-main .section-card,
.app-main .data-table-wrap {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  color: var(--ht-text);
  box-shadow: var(--ht-shadow-sm);
  border-radius: 12px;
}

.app-main .form-card {
  padding: 1.25rem 1.35rem;
}

.app-main .form-card:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-main .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.app-main .form-section {
  margin-bottom: 1.25rem;
}

.app-main .form-section h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ht-text);
  margin: 0 0 0.75rem;
}

.app-main .form-section h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ht-text-muted);
  margin: 0 0 0.65rem;
}

.app-main .form-error {
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  color: #dc2626;
  font-weight: 500;
}

.app-main .form-errors {
  margin-bottom: 1rem;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.app-main .required {
  color: #dc2626;
}

.app-main .form-help {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  line-height: 1.4;
}

.app-main .form-group > label,
.app-main .form-group .form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ht-text-secondary);
  margin-bottom: 0.35rem;
}

.app-main .form-control,
.app-main select.form-control,
.app-main textarea.form-control,
.app-main input.form-control[type="text"],
.app-main input.form-control[type="number"],
.app-main input.form-control[type="search"],
.app-main input.form-control[type="date"],
.app-main .form-input,
.app-main select.form-input,
.app-main textarea.form-input,
.app-main input.form-input[type="text"],
.app-main input.form-input[type="number"],
.app-main input.form-input[type="search"],
.app-main input.form-input[type="date"],
.app-main input.form-input[type="time"],
.app-main input.form-input[type="email"],
.app-main input.form-input[type="password"] {
  width: 100%;
  max-width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--ht-border);
  border-radius: 8px;
  font-size: 0.9375rem;
  background: var(--ht-surface);
  color: var(--ht-text);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-main textarea.form-control {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.5;
}

.app-main .form-control:focus {
  outline: none;
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

@media (max-width: 640px) {
  .app-main .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard-specific UX refresh (inspired by modern SaaS dashboards) */
.app-main .dashboard-shell .header {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  text-align: left;
}

.app-main .dashboard-shell .header h1 {
  font-size: 1.85rem;
  margin: 0;
}

.dashboard-notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #eef2ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.dashboard-notice__text {
  color: #4338ca;
  font-size: 0.95rem;
  font-weight: 500;
}

.dashboard-notice__action {
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #c7d2fe;
  color: #4f46e5;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.dashboard-notice__action:hover {
  background: #eef2ff;
}

.app-main .dashboard-shell .stats-grid {
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.app-main .dashboard-shell .stat-card {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: 12px;
  box-shadow: var(--ht-shadow-sm);
  color: var(--ht-text);
  padding: 14px;
}

.app-main .dashboard-shell .stat-card:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.app-main .dashboard-shell .stat-header {
  margin-bottom: 10px;
}

.app-main .dashboard-shell .stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: #eef2ff;
}

.app-main .dashboard-shell .stat-title {
  color: var(--ht-text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.app-main .dashboard-shell .stat-value {
  color: var(--ht-text);
  font-size: 1.4rem;
}

.app-main .dashboard-shell .stat-subtitle {
  color: var(--ht-text-muted);
}

.app-main .dashboard-shell .chart-container,
.app-main .dashboard-shell .action-card {
  border-radius: 12px;
}

.app-main .dashboard-shell .chart-container--dash-workout {
  border: none;
  box-shadow: none;
}

.app-main .dashboard-shell .chart-container--dash-workout:hover {
  transform: none;
  box-shadow: none;
}

.app-main .dashboard-shell .charts-grid {
  gap: 12px;
}

.app-main .dashboard-shell .bottom-grid {
  gap: 12px;
  grid-template-columns: 1fr;
}

.app-main .dashboard-shell .action-card {
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.app-main .dashboard-shell .action-header,
.app-main .dashboard-shell .chart-header {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f7;
}

.app-main .dashboard-shell .action-header h3,
.app-main .dashboard-shell .chart-header h3 {
  font-size: 1.05rem;
}

.app-main .dashboard-shell .goal-item,
.app-main .dashboard-shell .nutrient-item {
  border: 1px solid var(--ht-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--ht-surface);
  color: var(--ht-text);
}

.app-main .dashboard-shell .progress-bar-container {
  background: #edf2f7;
}

@media (max-width: 768px) {
  .dashboard-notice {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-main .dashboard-shell .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .app-main .dashboard-shell .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Responsive: narrow sidebars, then overlay primary */
@media (max-width: 1200px) {
  .app-layout {
    grid-template-columns: 200px 1fr;
  }
}

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }

  .app-sidebar--primary {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 86vw);
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }

  .app-layout--nav-open .app-sidebar--primary {
    transform: translateX(0);
  }

  .app-workspace {
    min-height: 100vh;
  }

  .app-workspace__toolbar {
    display: flex;
  }
}

@media (min-width: 1025px) {
  .app-backdrop {
    display: none !important;
  }
  .app-layout--nav-open .app-sidebar--primary {
    transform: none;
  }
}

/* Exercise library — aligned with workout log detail / workspace cards */
.app-main .exercise-library > .card,
.app-main .exercise-library .card {
  padding: 1.25rem 1.35rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: none;
}

.app-main .exercise-library .card:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-main .header.exercise-library-page-header {
  align-items: flex-start;
}

.app-main .header.exercise-library-page-header > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.app-main .exercise-library-intro {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
  max-width: 42rem;
}

.app-main .exercise-library-breadcrumb {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.app-main .exercise-library-breadcrumb a {
  color: #0d9488;
  text-decoration: none;
}

.app-main .exercise-library-breadcrumb a:hover {
  text-decoration: underline;
}

.app-main .exercise-library-filters .action-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eef2f7;
}

.app-main .exercise-library-filter-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  margin-top: 0.25rem;
}

.app-main .exercise-library-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.app-main .exercise-library-filter-row a.chart-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.app-main .exercise-library-filter-note {
  margin: 0.65rem 0 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
}

.app-main .exercise-library-checkgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.35rem 0.75rem;
}

.app-main .exercise-library-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  color: #334155;
  cursor: pointer;
}

.app-main .exercise-library-check input {
  accent-color: #0d9488;
}

.app-main .exercise-library-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
}

.app-main .exercise-library-search {
  flex: 1 1 14rem;
  min-width: 0;
}

.app-main .exercise-library-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.app-main .exercise-library-result-card {
  display: block;
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.app-main .exercise-library-result-card:hover {
  background: #f0fdfa;
  border-color: #99f6e4;
}

.app-main .exercise-library-result-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-main .exercise-library-result-card__head h4 {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: #0f172a;
  font-weight: 600;
}

.app-main .exercise-library-result-card__desc {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
}

.app-main .exercise-library-result-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.app-main .exercise-library-pagination {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #eef2f7;
}

.app-main .exercise-library .meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  white-space: nowrap;
}

.app-main .exercise-library .meta-tag--category {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.app-main .exercise-library .meta-tag--muscle {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #047857;
}

.app-main .exercise-library-empty-hint {
  font-size: 0.8125rem;
  color: #64748b;
}

.app-main .exercise-library-detail__summary {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.app-main .exercise-library-detail__summary p {
  margin: 0;
  font-size: 0.9375rem;
  color: #334155;
  line-height: 1.55;
}

.app-main .exercise-library-detail .action-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eef2f7;
}

.app-main .exercise-library-detail__body {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.65;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .app-main .exercise-library-filter-columns {
    grid-template-columns: 1fr;
  }
}

/* Exercise library form (add / edit) */
.app-main .exercise-library-form-page .exercise-library-form {
  display: block;
}

.app-main .exercise-library-form-page .form-panel {
  margin-bottom: 0;
}

.app-main .exercise-library-form-page .form-panel .action-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eef2f7;
}

.app-main .exercise-library-form-hint {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
}

.app-main .exercise-library-form-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.app-main .exercise-library-form-columns .form-section {
  margin-bottom: 0;
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.app-main .exercise-library-checkgrid--form ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.45rem;
  max-height: 16rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.app-main .exercise-library-checkgrid--form li {
  margin: 0;
}

.app-main .exercise-library-checkgrid--form li label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-main .exercise-library-checkgrid--form li label:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.app-main .exercise-library-checkgrid--form li label:has(input:checked) {
  background: #f0fdfa;
  border-color: #5eead4;
  color: #0f766e;
}

.app-main .exercise-library-checkgrid--form li input {
  accent-color: #0d9488;
  flex-shrink: 0;
}

.app-main .exercise-library-publish-field .form-label {
  margin-bottom: 0.45rem;
}

.app-main .exercise-library-publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.75rem 0.875rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
}

.app-main .exercise-library-publish-row__text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.app-main .exercise-library-publish-row__text strong {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
}

.app-main .exercise-library-publish-row__text span {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.35;
}

.app-main .exercise-library-publish-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #0d9488;
  flex-shrink: 0;
}

.app-main .exercise-library-form-footer .form-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

@media (max-width: 768px) {
  .app-main .exercise-library-form-columns {
    grid-template-columns: 1fr;
  }

  .app-main .exercise-library-checkgrid--form ul {
    max-height: none;
  }

  .app-main .exercise-library-detail-layout,
  .app-main .mw-exercise-detail {
    grid-template-columns: 1fr;
  }
}

/* MuscleWiki library — tabs, videos, bodymaps, routines */
.app-main .exercise-library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.app-main .exercise-library-tabs__link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.app-main .exercise-library-tabs__link:hover {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

.app-main .exercise-library-tabs__link.active {
  background: #ccfbf1;
  border-color: #5eead4;
  color: #0f766e;
}

.app-main .exercise-library-filter-count {
  margin-left: 0.35rem;
  font-size: 0.6875rem;
  opacity: 0.75;
}

.app-main .exercise-library-advanced-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.app-main .exercise-library-advanced-filters .form-group {
  flex: 1 1 10rem;
  min-width: 0;
  margin: 0;
}

.app-main .exercise-library-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 0.8fr);
  gap: 1rem;
  align-items: start;
}

/* MuscleWiki-style exercise detail page */
.app-main .exercise-library-detail--mw {
  max-width: 72rem;
}

.app-main .exercise-library-detail--mw .exercise-library-breadcrumb {
  margin-bottom: 0.75rem;
}

.app-main .mw-exercise-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(15rem, 1fr);
  gap: 1rem;
  align-items: start;
}

.app-main .mw-exercise-panel {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dbeafe;
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.08);
}

.app-main .mw-exercise-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.15rem;
  background: linear-gradient(180deg, #2b5278 0%, #234567 100%);
  color: #fff;
}

.app-main .mw-exercise-panel__header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
}

.app-main .mw-exercise-panel__header--sidebar {
  justify-content: flex-end;
  min-height: 3.1rem;
}

.app-main .mw-exercise-panel__media {
  position: relative;
  background: #0f172a;
  padding: 0.75rem 1rem;
}

.app-main .mw-difficulty-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 2;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: #2563eb;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.app-main .mw-exercise-panel__videos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
}

.app-main .mw-exercise-panel__videos:has(.mw-exercise-panel__video:only-child) {
  grid-template-columns: minmax(0, 20rem);
}

.app-main .mw-exercise-panel__video {
  margin: 0;
  position: relative;
  width: 100%;
  height: 13.5rem;
  max-height: 13.5rem;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-main .mw-exercise-panel__player,
.app-main .mw-exercise-panel__video video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  background: #000;
  pointer-events: none;
}

.app-main .mw-exercise-panel__player::-webkit-media-controls,
.app-main .mw-exercise-panel__video video::-webkit-media-controls {
  display: none !important;
}

.app-main .mw-exercise-panel__player::-webkit-media-controls-enclosure,
.app-main .mw-exercise-panel__video video::-webkit-media-controls-enclosure {
  display: none !important;
}

.app-main .mw-exercise-panel__video figcaption {
  position: absolute;
  left: 0.5rem;
  bottom: 0.45rem;
  margin: 0;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.78);
  color: #e2e8f0;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: capitalize;
  pointer-events: none;
}

@media (max-width: 640px) {
  .app-main .mw-exercise-panel__video {
    height: 11rem;
    max-height: 11rem;
  }
}

.app-main .mw-exercise-steps {
  list-style: none;
  margin: 0;
  padding: 1.35rem 1.25rem 1.5rem;
}

.app-main .mw-exercise-steps__item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.app-main .mw-exercise-steps__item + .mw-exercise-steps__item {
  margin-top: 1.15rem;
}

.app-main .mw-exercise-steps__num {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2b5278;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}

.app-main .mw-exercise-steps__text {
  padding-top: 0.2rem;
  color: #334155;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.app-main .mw-gender-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.app-main .mw-gender-toggle__btn {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.app-main .mw-gender-toggle__btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.app-main .mw-gender-toggle__btn.is-active {
  background: #fff;
  color: #234567;
}

.app-main .mw-exercise-bodymap {
  padding: 1rem 1rem 0.75rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.app-main .mw-exercise-bodymap__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.app-main .mw-exercise-bodymap__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.75rem;
}

.app-main .mw-legend {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.app-main .mw-legend::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
}

.app-main .mw-legend--primary::before {
  background: #dc2626;
}

.app-main .mw-legend--secondary::before {
  background: #ea580c;
}

.app-main .mw-legend--tertiary::before {
  background: #ca8a04;
}

.app-main .mw-exercise-bodymap__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.app-main .mw-bodymap-option {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font-size: 0.6875rem;
  font-weight: 600;
  text-decoration: none;
}

.app-main .mw-bodymap-option.is-active {
  border-color: #2b5278;
  background: #eff6ff;
  color: #1e4976;
}

.app-main .mw-attribute-list {
  margin: 0;
}

.app-main .mw-attribute-row {
  display: grid;
  grid-template-columns: minmax(6rem, 0.9fr) minmax(0, 1.1fr);
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #e5e7eb;
}

.app-main .mw-attribute-row:first-child {
  border-top: none;
}

.app-main .mw-attribute-row__label,
.app-main .mw-attribute-row__value {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.app-main .mw-attribute-row__label {
  color: #64748b;
  font-weight: 600;
}

.app-main .mw-attribute-row__value {
  color: #0f172a;
  font-weight: 500;
  text-align: right;
}

.app-main .mw-exercise-detail__footer {
  margin-top: 1.25rem;
}

.app-main .exercise-library-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}

.app-main .exercise-library-video-card {
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
}

.app-main .exercise-library-video {
  display: block;
  width: 100%;
  max-height: 18rem;
  background: #000;
}

.app-main .exercise-library-video-label {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.75rem;
  color: #e2e8f0;
}

.app-main .exercise-library-bodymap-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.app-main .exercise-library-bodymap {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #f8fafc;
}

.app-main .exercise-library-bodymap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
  font-size: 0.6875rem;
}

.app-main .exercise-library-bodymap-legend .legend {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
}

.app-main .exercise-library-bodymap-legend .legend--primary {
  background: #fee2e2;
  color: #b91c1c;
}

.app-main .exercise-library-bodymap-legend .legend--secondary {
  background: #ffedd5;
  color: #c2410c;
}

.app-main .exercise-library-bodymap-legend .legend--tertiary {
  background: #fef9c3;
  color: #a16207;
}

.app-main .exercise-library-workout-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.app-main .exercise-library-workout-item {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.app-main .exercise-library-workout-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-main .exercise-library-workout-item__name {
  font-weight: 600;
  color: #0f172a;
  text-decoration: none;
}

.app-main a.exercise-library-workout-item__name:hover {
  color: #0d9488;
  text-decoration: underline;
}

/* Mobile: keep text fields inside page bounds (flex/grid + nested forms) */
@media (max-width: 768px) {
  .app-main .form-grid,
  .app-main .form-group,
  .app-main .plan-form-grid,
  .app-main .plan-form-field,
  .app-main .add-meal-context-bar__grid,
  .app-main .add-meal-recipe-picker__filters,
  .app-main .add-meal-recipe-picker__apply-bar,
  .app-main .meal-item-name-editor,
  .app-main .staging-row,
  .app-guest-main form {
    min-width: 0;
    max-width: 100%;
  }

  .app-main .form-grid > *,
  .app-main .plan-form-grid > *,
  .app-main .add-meal-context-bar__grid > *,
  .app-main .add-meal-recipe-picker__filters > *,
  .app-main .add-meal-recipe-picker__apply-bar > * {
    min-width: 0;
  }

  .app-main .meal-item-name-editor .form-input,
  .app-main .staging-row .form-input {
    width: 100%;
    max-width: 100%;
  }

  .app-main .staging-grams-wrap {
    flex: 1 1 6rem;
    min-width: 0;
    max-width: 100%;
  }

  .app-main .staging-grams-wrap .form-input {
    width: 100%;
    max-width: 7.5rem;
  }

  .app-main .staging-ingredient-name {
    flex: 1 1 100%;
    min-width: 0;
    word-break: break-word;
  }
}

/* Admin reminder: pending trainer requests */
.app-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: auto;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.app-admin-reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 12px;
  color: #9a3412;
}

.app-admin-reminder__text {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.app-admin-reminder__link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  background: #ea580c;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.app-admin-reminder__link:hover {
  background: #c2410c;
  color: #fff;
}

/* ---- Profile ---- */
.profile-container {
  background: var(--ht-surface);
  color: var(--ht-text);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
  overflow: hidden;
  margin-top: 1.5rem;
}

.profile-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ht-border);
  background: var(--ht-surface-muted);
}

.profile-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ht-text);
}

.profile-content {
  padding: 1.5rem;
}

/* ---- Handy Tools ---- */
.tools-hub__intro {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ht-text-muted);
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.tools-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tools-tool-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  text-decoration: none;
  color: var(--ht-text);
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-left: 4px solid var(--ht-accent);
  min-height: 100%;
}

.tools-tool-card:hover,
.tools-tool-card:focus-visible {
  border-color: #c7d2fe;
  border-left-color: #667eea;
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(102, 126, 234, 0.18);
}

.tools-tool-card__icon {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: 12px;
  background: var(--ht-accent-light);
}

.tools-tool-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tools-tool-card__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ht-text);
  line-height: 1.3;
}

.tools-tool-card__description {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ht-text-muted);
}

.tools-tool-card__cta {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ht-accent);
}

.tools-page .tools-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6366f1;
  text-decoration: none;
}

.tools-page .tools-back-link:hover {
  color: #4338ca;
  text-decoration: underline;
}

.tools-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tools-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ht-text-secondary);
  text-decoration: none;
  border: 1px solid var(--ht-border);
  background: var(--ht-surface);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tools-nav__link:hover,
.tools-nav__link:focus-visible {
  background: var(--ht-accent-light);
  border-color: var(--ht-border-strong);
  color: var(--ht-accent-hover);
}

.tools-nav__link.is-active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

.tools-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

.tools-page .form-container.tools-panel {
  margin-top: 0;
}

.tools-page .form-container .form-content {
  padding-bottom: 1.5rem;
}

.tools-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.tools-form-grid .form-group--full {
  grid-column: 1 / -1;
}

.tools-segment {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 10px;
  background: var(--ht-surface-muted);
  border: 1px solid var(--ht-border);
}

.tools-segment label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ht-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tools-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tools-segment label:has(input:checked) {
  background: var(--ht-surface);
  color: var(--ht-accent-hover);
  box-shadow: var(--ht-shadow-sm);
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit .form-input {
  padding-right: 3.25rem;
}

.input-unit {
  position: absolute;
  right: 0.85rem;
  color: var(--ht-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  pointer-events: none;
}

.tools-result-panel {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-radius: 16px;
  border: 1px solid var(--ht-border);
  box-shadow: var(--ht-shadow-sm);
  overflow: hidden;
  position: sticky;
  top: 1rem;
}

.tools-result-panel__header {
  padding: 1rem 1.25rem;
  background: var(--ht-surface-muted);
  border-bottom: 1px solid var(--ht-border);
}

.tools-result-panel__header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ht-text);
}

.tools-result-panel__body {
  padding: 1.25rem;
}

.tools-result-empty {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ht-text-muted);
}

.tools-result-hero {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.tools-result-hero__value {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ht-text);
  font-variant-numeric: tabular-nums;
}

.tools-result-hero__label {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ht-accent);
}

.tools-result-hero__unit {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--ht-text-muted);
}

.calorie-summary {
  background: var(--ht-surface-muted);
  border-radius: 12px;
  padding: 1rem 1.125rem;
  border: 1px solid var(--ht-border);
}

.tools-result-panel .calorie-summary {
  margin-top: 1rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ht-border);
  flex-wrap: wrap;
  gap: 0.35rem;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ht-text-secondary);
}

.summary-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ht-text);
  font-variant-numeric: tabular-nums;
}

.summary-unit {
  color: #6b7280;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.tools-bmi-scale {
  margin-top: 1.25rem;
}

.tools-bmi-scale__track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.tools-bmi-scale__segment {
  flex: 1;
}

.tools-bmi-scale__segment--under { background: #93c5fd; }
.tools-bmi-scale__segment--normal { background: #34d399; }
.tools-bmi-scale__segment--over { background: #fbbf24; }
.tools-bmi-scale__segment--obese { background: #f87171; }

.tools-bmi-scale__marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: #1e293b;
  box-shadow: 0 0 0 2px #fff;
}

.tools-bmi-scale__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tools-info-note {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #92400e;
}

.tools-met-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tools-met-chip {
  display: inline-flex;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

@media (max-width: 960px) {
  .tools-layout {
    grid-template-columns: 1fr;
  }

  .tools-result-panel {
    position: static;
  }
}

@media (max-width: 600px) {
  .tools-form-grid {
    grid-template-columns: 1fr;
  }

  .tools-hub-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Commercial Design System v2 — global refresh
   ============================================ */

/* Logo mark */
.app-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.app-logo__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ht-primary) 0%, #14b8a6 100%);
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.28);
}

.app-logo__mark svg {
  width: 1rem;
  height: 1rem;
}

.app-logo__text {
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Nav SVG icons */
.app-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 1;
}

.app-nav-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-link.is-active .app-nav-icon svg {
  stroke: var(--ht-accent-hover);
}

/* App shell refinements */
.app-layout {
  background: var(--ht-canvas);
}

.app-sidebar--primary {
  background: var(--ht-sidebar);
  border-right: 1px solid var(--ht-border);
  box-shadow: 1px 0 0 rgba(15, 23, 42, 0.03);
}

.app-workspace {
  background: var(--ht-canvas);
}

.app-sidebar__brand {
  padding: 1.1rem 1rem 0.95rem;
}

.app-nav-link.is-active {
  background: var(--ht-accent-light);
  color: var(--ht-accent-hover);
  border-color: #c7d2fe;
  font-weight: 600;
}

.app-nav-link.is-active::before {
  background: var(--ht-primary);
}

.app-nav-link:hover {
  background: var(--ht-accent-light);
  color: var(--ht-text);
}

/* Unified KPI stat cards */
.stat-card {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  padding: 1.25rem;
  color: var(--ht-text);
  box-shadow: var(--ht-shadow-sm);
  transition: box-shadow var(--ht-transition), border-color var(--ht-transition);
}

.stat-card:hover {
  transform: none;
  box-shadow: var(--ht-shadow);
  border-color: var(--ht-border-strong);
}

.stat-title {
  color: var(--ht-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.stat-value {
  color: var(--ht-text);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--ht-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--ht-accent-light);
}

.stat-card .stat-label {
  color: var(--ht-text-muted);
  opacity: 1;
}

.workout-dashboard .stat-card,
.app-main .workout-dashboard .stat-card {
  color: var(--ht-text);
  padding: clamp(12px, 1.8vw, 16px);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.workout-dashboard .stat-card:hover,
.app-main .workout-dashboard .stat-card:hover {
  transform: none;
  box-shadow: var(--ht-shadow);
}

.workout-dashboard .stat-title,
.app-main .workout-dashboard .stat-title,
.workout-dashboard .stat-value,
.app-main .workout-dashboard .stat-value {
  color: var(--ht-text);
}

.workout-dashboard .stat-subtitle,
.app-main .workout-dashboard .stat-subtitle {
  color: var(--ht-text-muted);
  opacity: 1;
}

.workout-dashboard .stat-icon {
  background: var(--ht-primary-muted);
}

/* Buttons — flat, professional */
.btn {
  border-radius: var(--ht-radius);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background var(--ht-transition), border-color var(--ht-transition), color var(--ht-transition), box-shadow var(--ht-transition);
}

.btn-primary {
  background: var(--ht-primary);
  color: #ffffff;
  border: 1px solid var(--ht-primary);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--ht-primary-hover);
  border-color: var(--ht-primary-hover);
  transform: none;
  box-shadow: var(--ht-shadow-md);
  color: #ffffff;
}

.btn-secondary {
  background: var(--ht-surface);
  color: var(--ht-primary);
  border: 1px solid var(--ht-border-strong);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

.btn-danger {
  background: var(--ht-danger);
  border: 1px solid var(--ht-danger);
}

.btn-danger:hover,
.btn-danger:focus-visible {
  background: #b91c1c;
  transform: none;
  box-shadow: var(--ht-shadow-md);
}

.btn-success {
  background: var(--ht-success);
  border: 1px solid var(--ht-success);
}

.btn-success:hover,
.btn-success:focus-visible {
  background: #047857;
  transform: none;
  box-shadow: var(--ht-shadow-md);
}

.app-main a.btn-primary,
.app-main a.btn-primary:hover,
.app-main a.btn-primary:focus-visible,
.app-main a.btn-primary:visited {
  color: #ffffff;
}

/* Cards & panels */
.card {
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.card:hover {
  transform: none;
  box-shadow: var(--ht-shadow);
}

.action-card {
  background: var(--ht-surface);
  color: var(--ht-text);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.chart-container {
  background: var(--ht-surface);
  color: var(--ht-text);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.chart-container:hover {
  transform: none;
}

/* Page headers */
.header {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  text-align: left;
}

.header h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.03em;
  margin: 0;
}

/* Forms */
.form-container {
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.form-header {
  background: var(--ht-surface);
  color: var(--ht-text);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ht-border);
  position: relative;
}

.form-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ht-primary), #14b8a6);
  border-radius: var(--ht-radius-lg) var(--ht-radius-lg) 0 0;
}

.form-header h2 {
  color: var(--ht-text);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.form-header-intro {
  color: var(--ht-text-muted);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--ht-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

/* Flash messages — subtle tinted */
.message.success {
  background: var(--ht-success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.message.error {
  background: var(--ht-danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.message.warning {
  background: var(--ht-warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

.message.info {
  background: var(--ht-info-light);
  color: #075985;
  border: 1px solid #bae6fd;
}

/* Dashboard welcome banner */
.dashboard-notice {
  background: var(--ht-primary-muted);
  border: 1px solid #99f6e4;
  border-radius: var(--ht-radius);
}

.dashboard-notice__text {
  color: #115e59;
  font-weight: 500;
}

.dashboard-notice__action {
  background: var(--ht-surface);
  border: 1px solid #5eead4;
  color: var(--ht-primary-hover);
  font-weight: 600;
}

.dashboard-notice__action:hover {
  background: #ccfbf1;
}

/* Guest experience */
.app-guest-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ht-border);
}

.app-guest-main {
  background: var(--ht-canvas);
}

.app-body--guest {
  background: var(--ht-canvas);
}

/* Auth layout */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  min-height: calc(100vh - 10rem);
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 0;
}

.auth-layout__hero {
  padding: 1rem 0;
}

.auth-layout__hero-title {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin: 0 0 1rem;
}

.auth-layout__hero-text {
  font-size: 1.05rem;
  color: var(--ht-text-muted);
  line-height: 1.6;
  margin: 0 0 1.5rem;
}

.auth-layout__features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-layout__feature {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.92rem;
  color: var(--ht-text-secondary);
  line-height: 1.45;
}

.auth-layout__feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  background: var(--ht-primary-muted);
  color: var(--ht-primary);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.auth-layout__feature-icon svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

.auth-card {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  justify-self: end;
}

.auth-card__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.auth-card__subtitle {
  font-size: 0.9rem;
  color: var(--ht-text-muted);
  margin: 0 0 1.5rem;
}

/* Honeypot: keep in DOM for bots, hide from humans without display:none */
.auth-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.auth-card .auth-field {
  margin-bottom: 1rem;
}

.auth-card .auth-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ht-text-secondary);
  margin-bottom: 0.35rem;
}

.auth-card .auth-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--ht-border-strong);
  border-radius: var(--ht-radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ht-text);
  background: var(--ht-surface);
  transition: border-color var(--ht-transition), box-shadow var(--ht-transition);
}

.auth-card .auth-field input:focus {
  outline: none;
  border-color: var(--ht-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.auth-card .auth-submit {
  width: 100%;
  padding: 0.7rem 1rem;
  margin-top: 0.5rem;
  border: none;
  border-radius: var(--ht-radius);
  background: var(--ht-primary);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--ht-transition), box-shadow var(--ht-transition);
}

.auth-card .auth-submit:hover {
  background: var(--ht-primary-hover);
  box-shadow: var(--ht-shadow-md);
}

.auth-card .auth-footer {
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--ht-text-muted);
  line-height: 1.6;
}

.auth-card .auth-footer a {
  color: var(--ht-primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-card .auth-footer a:hover {
  color: var(--ht-primary-hover);
  text-decoration: underline;
}

.auth-card .auth-error {
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  border-radius: var(--ht-radius);
  background: var(--ht-danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.85rem;
}

.auth-card .auth-field-error {
  color: var(--ht-danger);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

@media (max-width: 768px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    min-height: auto;
    padding: 1rem 0;
  }

  .auth-layout__hero {
    text-align: center;
    padding: 0;
  }

  .auth-layout__features {
    display: none;
  }

  .auth-card {
    justify-self: center;
    max-width: 100%;
    padding: 1.5rem;
  }
}

/* Chart controls */
.chart-btn.active,
.chart-btn:hover {
  border-color: var(--ht-primary);
  color: var(--ht-primary);
}

.chart-btn.active {
  background: var(--ht-primary-muted);
}

/* Search & data tables */
.search-input:focus {
  border-color: var(--ht-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.page-header,
.search-section,
.results-section {
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

/* Legacy purple accent overrides */
.app-main a.btn-secondary {
  color: var(--ht-primary);
}

.app-main a.btn-secondary:hover,
.app-main a.btn-secondary:focus-visible {
  color: var(--ht-primary-hover);
}

/* ============================================
   Theme toggle
   ============================================ */
.app-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.app-brand-row .app-logo {
  flex: 1;
  min-width: 0;
}

.app-brand-row--toolbar {
  flex: 1;
  min-width: 0;
}

.app-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.48rem 0.62rem;
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-sm);
  background: var(--ht-surface-muted);
  color: var(--ht-text-secondary);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ht-transition), border-color var(--ht-transition), color var(--ht-transition);
}

.app-theme-toggle:hover {
  background: var(--ht-border);
  border-color: var(--ht-border-strong);
  color: var(--ht-text);
}

.app-theme-toggle--brand {
  width: auto;
  flex-shrink: 0;
  padding: 0.4rem;
  border-radius: 8px;
}

.app-theme-toggle__icon {
  display: inline-flex;
  width: 1.1rem;
  height: 1.1rem;
}

.app-theme-toggle__icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-theme-toggle__icon--dark { display: none; }
[data-theme="dark"] .app-theme-toggle__icon--light { display: none; }
[data-theme="dark"] .app-theme-toggle__icon--dark { display: inline-flex; }

.app-theme-toggle__label {
  flex: 1;
  text-align: left;
}

/* ============================================
   Dark mode
   ============================================ */
[data-theme="dark"] {
  color-scheme: dark;
  --ht-primary: #14b8a6;
  --ht-primary-hover: #2dd4bf;
  --ht-primary-light: #134e4a;
  --ht-primary-muted: #042f2e;
  --ht-accent: #818cf8;
  --ht-accent-hover: #a5b4fc;
  --ht-accent-light: #1e1b4b;
  --ht-surface: #1e293b;
  --ht-surface-muted: #0f172a;
  --ht-canvas: #0b1120;
  --ht-sidebar: #111827;
  --ht-border: #334155;
  --ht-border-strong: #475569;
  --ht-text: #f1f5f9;
  --ht-text-secondary: #cbd5e1;
  --ht-text-muted: #94a3b8;
  --ht-success-light: #064e3b;
  --ht-danger-light: #450a0a;
  --ht-warning-light: #451a03;
  --ht-info-light: #0c4a6e;
  --ht-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ht-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --ht-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --ht-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .app-guest-header {
  background: rgba(17, 24, 39, 0.92);
}

[data-theme="dark"] .app-workspace__toolbar {
  background: var(--ht-surface);
}

[data-theme="dark"] .app-footer {
  background: var(--ht-surface);
}

[data-theme="dark"] .app-nav-link:hover {
  background: #1e293b;
}

[data-theme="dark"] .app-nav-link.is-active {
  background: var(--ht-accent-light);
  border-color: #4338ca;
}

[data-theme="dark"] .contextual-nav,
[data-theme="dark"] .contextual-nav__link {
  background: var(--ht-surface);
}

[data-theme="dark"] .contextual-nav__link:hover {
  background: var(--ht-accent-light);
}

[data-theme="dark"] .stat-icon {
  background: var(--ht-accent-light);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .auth-card .auth-field input {
  background: var(--ht-surface-muted);
  color: var(--ht-text);
  border-color: var(--ht-border-strong);
}

[data-theme="dark"] .dashboard-notice {
  background: var(--ht-primary-muted);
  border-color: #115e59;
}

[data-theme="dark"] .dashboard-notice__text {
  color: #5eead4;
}

[data-theme="dark"] .app-message--success {
  background: var(--ht-success-light);
  border-color: #065f46;
  color: #6ee7b7;
}

[data-theme="dark"] .app-message--error {
  background: var(--ht-danger-light);
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .app-message--warning {
  background: var(--ht-warning-light);
  border-color: #78350f;
  color: #fcd34d;
}

[data-theme="dark"] .app-message--info,
[data-theme="dark"] .app-message--debug {
  background: var(--ht-primary-muted);
  border-color: #115e59;
  color: #5eead4;
}

/* ============================================
   Landing page
   ============================================ */
.app-guest-main:has(.landing) {
  max-width: none;
  padding: 0;
}

.landing {
  width: 100%;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  max-width: 1140px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
}

.landing-hero__eyebrow {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--ht-primary-muted);
  border: 1px solid #99f6e4;
  color: var(--ht-primary-hover);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.landing-hero__title {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  color: var(--ht-text);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.landing-hero__subtitle {
  margin: 0 0 1.75rem;
  font-size: 1.1rem;
  color: var(--ht-text-muted);
  line-height: 1.65;
  max-width: 32rem;
}

.landing-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.landing-hero__note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ht-text-muted);
}

.landing-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.35rem;
  border-radius: var(--ht-radius);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--ht-transition), box-shadow var(--ht-transition), border-color var(--ht-transition);
}

.landing-btn--primary {
  background: var(--ht-primary);
  color: #ffffff;
  border: 1px solid var(--ht-primary);
}

.landing-btn--primary:hover {
  background: var(--ht-primary-hover);
  box-shadow: var(--ht-shadow-md);
  color: #ffffff;
}

.landing-btn--secondary {
  background: var(--ht-surface);
  color: var(--ht-text);
  border: 1px solid var(--ht-border-strong);
}

.landing-btn--secondary:hover {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border-strong);
}

.landing-btn--lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
}

.landing-mockup {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-lg);
  overflow: hidden;
}

.landing-mockup__bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  background: var(--ht-surface-muted);
  border-bottom: 1px solid var(--ht-border);
}

.landing-mockup__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ht-border-strong);
}

.landing-mockup__body {
  padding: 1.25rem;
}

.landing-mockup__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.landing-mockup__stat {
  padding: 0.75rem;
  border-radius: var(--ht-radius);
  background: var(--ht-surface-muted);
  border: 1px solid var(--ht-border);
}

.landing-mockup__stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ht-text-muted);
  margin-bottom: 0.25rem;
}

.landing-mockup__stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.02em;
}

.landing-mockup__chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 6rem;
  padding: 0.75rem;
  border-radius: var(--ht-radius);
  background: var(--ht-surface-muted);
  border: 1px solid var(--ht-border);
}

.landing-mockup__chart-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--ht-primary), #14b8a6);
  opacity: 0.85;
}

.landing-features {
  background: var(--ht-surface);
  border-top: 1px solid var(--ht-border);
  border-bottom: 1px solid var(--ht-border);
  padding: 4rem 1.5rem;
}

.landing-section-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2.5rem;
}

.landing-section-header h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.03em;
}

.landing-section-header p {
  margin: 0;
  font-size: 1rem;
  color: var(--ht-text-muted);
  line-height: 1.6;
}

.landing-features__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 1140px;
  margin: 0 auto;
}

.landing-feature-card {
  padding: 1.5rem;
  border-radius: var(--ht-radius-lg);
  border: 1px solid var(--ht-border);
  background: var(--ht-surface-muted);
  transition: box-shadow var(--ht-transition), border-color var(--ht-transition);
}

.landing-feature-card:hover {
  box-shadow: var(--ht-shadow);
  border-color: var(--ht-border-strong);
}

.landing-feature-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--ht-radius);
  background: var(--ht-primary-muted);
  color: var(--ht-primary);
  margin-bottom: 1rem;
}

.landing-feature-card__icon svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.landing-feature-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ht-text);
}

.landing-feature-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ht-text-muted);
  line-height: 1.55;
}

.landing-steps {
  max-width: 800px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.landing-steps__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.landing-step {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-radius: var(--ht-radius-lg);
  border: 1px solid var(--ht-border);
  background: var(--ht-surface);
  box-shadow: var(--ht-shadow-sm);
}

.landing-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--ht-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.landing-step h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ht-text);
}

.landing-step p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ht-text-muted);
  line-height: 1.55;
}

.landing-cta {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
}

.landing-cta h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.03em;
}

.landing-cta p {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--ht-text-muted);
  line-height: 1.6;
}

@media (max-width: 960px) {
  .landing-hero {
    grid-template-columns: 1fr;
    padding-top: 2rem;
    text-align: center;
  }

  .landing-hero__subtitle {
    margin-left: auto;
    margin-right: auto;
  }

  .landing-hero__actions {
    justify-content: center;
  }

  .landing-hero__visual {
    order: -1;
  }

  .landing-features__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .landing-features__grid {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    padding: 1.5rem 1rem 2.5rem;
  }
}

/* ============================================
   Food diary — commercial overrides
   ============================================ */
.diary-container .diary-title-row h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--ht-text);
  letter-spacing: -0.03em;
}

.diary-container .timeframe-selector {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.diary-container .timeframe-tab {
  background: var(--ht-surface-muted);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-sm);
  color: var(--ht-text-secondary);
}

.diary-container .timeframe-tab:hover {
  background: var(--ht-border);
}

.diary-container .timeframe-tab.active {
  background: var(--ht-primary);
  border-color: var(--ht-primary);
  color: #ffffff;
}

.diary-container .summary-card {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-left-width: 4px;
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.diary-container .summary-card.calories-card { border-left-color: #f59e0b; }
.diary-container .summary-card.protein-card { border-left-color: #3b82f6; }
.diary-container .summary-card.carbs-card { border-left-color: #10b981; }
.diary-container .summary-card.fat-card { border-left-color: #f97316; }

.diary-container .card-value {
  color: var(--ht-text);
}

.diary-container .card-label,
.diary-container .card-avg {
  color: var(--ht-text-muted);
}

.diary-container .diary-day-card {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  box-shadow: var(--ht-shadow-sm);
}

.diary-container .day-header {
  background: var(--ht-surface-muted);
  border-bottom: 1px solid var(--ht-border);
}

.diary-container .day-date {
  color: var(--ht-text);
}

.diary-container .day-full-date {
  color: var(--ht-text-muted);
}

.diary-container .day-total-bar {
  background: var(--ht-surface-muted);
  border-top: 1px solid var(--ht-border);
}

.diary-container .meal-time-open-btn,
.diary-container .meal-time-form button[type="submit"] {
  background: var(--ht-primary-muted);
  border-color: #5eead4;
  color: var(--ht-primary-hover);
}

.diary-container .meal-time-open-btn:hover,
.diary-container .meal-time-form button[type="submit"]:hover {
  background: #ccfbf1;
}

.diary-container .meal-type-badge.dinner {
  background: var(--ht-accent-light);
  color: var(--ht-accent-hover);
}

.diary-container .empty-diary {
  background: var(--ht-surface);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
}

.diary-container .di-macro-row--section-head {
  background: var(--ht-surface-muted);
  border-bottom-color: var(--ht-border);
}

[data-theme="dark"] .diary-container .meal-time-open-btn:hover,
[data-theme="dark"] .diary-container .meal-time-form button[type="submit"]:hover {
  background: var(--ht-primary-light);
}

[data-theme="dark"] .diary-container .quick-stat.calories { background: #422006; color: #fcd34d; }
[data-theme="dark"] .diary-container .quick-stat.protein { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .diary-container .quick-stat.carbs { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .diary-container .quick-stat.fat { background: #431407; color: #fdba74; }

/* ============================================
   Add meal builder — commercial overrides
   ============================================ */
.add-meal-page-root .add-meal-phase-strip__step.is-active {
  background: var(--ht-primary-muted);
  box-shadow: inset 0 0 0 2px var(--ht-primary);
}

.add-meal-page-root .add-meal-phase-strip__step.is-active .add-meal-phase-strip__num {
  background: var(--ht-primary);
}

.add-meal-page-root .copy-header {
  background: linear-gradient(135deg, var(--ht-primary-hover), var(--ht-primary));
}

.add-meal-page-root .add-meal-suggestion-chip {
  border-color: #5eead4;
  color: var(--ht-primary-hover);
}

.add-meal-page-root .add-meal-suggestion-chip:hover {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
}

.add-meal-page-root .meal-builder-tab.is-active,
.add-meal-page-root .meal-builder-mode-btn.is-active {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
  box-shadow: inset 0 0 0 1px var(--ht-primary);
}

.add-meal-page-root .add-meal-search-panel {
  background: var(--ht-surface);
  border-color: var(--ht-border);
}

.add-meal-page-root .add-meal-search-panel__intro h2 {
  color: var(--ht-text);
}

[data-theme="dark"] .add-meal-page-root .add-meal-phase-strip {
  background: var(--ht-surface);
  border-color: var(--ht-border);
}

[data-theme="dark"] .add-meal-page-root .add-meal-phase-strip__step {
  background: var(--ht-surface-muted);
}

[data-theme="dark"] .add-meal-page-root .food-search-result:hover {
  background: var(--ht-accent-light);
}

[data-theme="dark"] .landing-hero__eyebrow {
  border-color: #115e59;
  color: #5eead4;
}

[data-theme="dark"] .landing-feature-card {
  background: var(--ht-surface);
}

[data-theme="dark"] .landing-mockup__stat {
  background: var(--ht-canvas);
}

[data-theme="dark"] .auth-card {
  background: var(--ht-surface);
  border-color: var(--ht-border);
}

[data-theme="dark"] .auth-layout__feature-icon {
  background: var(--ht-primary-muted);
  color: var(--ht-primary);
}

/* Dark mode — typography & content surfaces */
[data-theme="dark"] .app-main,
[data-theme="dark"] .app-guest-main {
  color: var(--ht-text);
}

[data-theme="dark"] .app-main h1,
[data-theme="dark"] .app-main h2,
[data-theme="dark"] .app-main h3,
[data-theme="dark"] .app-main h4,
[data-theme="dark"] .app-main h5,
[data-theme="dark"] .app-main h6,
[data-theme="dark"] .app-guest-main h1,
[data-theme="dark"] .app-guest-main h2,
[data-theme="dark"] .app-guest-main h3 {
  color: var(--ht-text);
}

[data-theme="dark"] .app-main p,
[data-theme="dark"] .app-main li,
[data-theme="dark"] .app-main dt,
[data-theme="dark"] .app-main dd,
[data-theme="dark"] .app-guest-main p {
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .text-muted,
[data-theme="dark"] .app-main small,
[data-theme="dark"] .app-main .help-text {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .contextual-nav {
  background: var(--ht-surface);
  border-color: var(--ht-border);
}

[data-theme="dark"] .app-workspace__toolbar {
  border-bottom-color: var(--ht-border);
}

[data-theme="dark"] .app-mobile-nav-toggle {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  color: var(--ht-text);
}

[data-theme="dark"] .app-mobile-nav-toggle span {
  background: var(--ht-text);
}

[data-theme="dark"] .app-workspace__mobile-brand {
  color: var(--ht-text);
}

[data-theme="dark"] .app-logo--guest {
  color: var(--ht-text);
}

[data-theme="dark"] .app-btn--ghost {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-btn--ghost:hover {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border-strong);
  color: var(--ht-text);
}

[data-theme="dark"] .app-sidebar__brand,
[data-theme="dark"] .app-sidebar__user,
[data-theme="dark"] .app-nav-group--foot {
  border-color: var(--ht-border);
}

[data-theme="dark"] .app-nav-link--muted {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .app-sidebar__profile-link {
  color: var(--ht-accent);
}

[data-theme="dark"] .app-sidebar__profile-link:hover,
[data-theme="dark"] .app-sidebar__profile-link:focus-visible,
[data-theme="dark"] .app-sidebar__profile-link.is-active {
  background: var(--ht-accent-light);
  color: var(--ht-accent-hover);
  border-color: var(--ht-border-strong);
}

[data-theme="dark"] .app-theme-toggle__label {
  color: var(--ht-text-secondary);
}

/* Dark mode — cards, panels, tables */
[data-theme="dark"] .page-header,
[data-theme="dark"] .search-section,
[data-theme="dark"] .results-section,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .form-container {
  background: var(--ht-surface);
  color: var(--ht-text);
}

[data-theme="dark"] .results-header h3,
[data-theme="dark"] .action-header h3,
[data-theme="dark"] .chart-header h3,
[data-theme="dark"] .table-header h3,
[data-theme="dark"] .modal-header h3,
[data-theme="dark"] .empty-state h3,
[data-theme="dark"] .empty-diary h3,
[data-theme="dark"] .diary-date-header h2,
[data-theme="dark"] .meal-type-header h3 {
  color: var(--ht-text);
}

[data-theme="dark"] .results-header p,
[data-theme="dark"] .food-serving,
[data-theme="dark"] .empty-diary p,
[data-theme="dark"] .empty-state p {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .app-main .chart-btn {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .chart-btn:hover {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .app-main .chart-btn.active {
  background: var(--ht-primary-light);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .app-main .nutrient-breakdown,
[data-theme="dark"] .app-main .workout-log-detail__notes,
[data-theme="dark"] .app-main .exercise-library-result-card {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
  color: var(--ht-text);
}

[data-theme="dark"] .app-main .workout-log-detail__notes-title,
[data-theme="dark"] .app-main .workout-log-detail__notes-body,
[data-theme="dark"] .app-main .exercise-library-result-card__head h4 {
  color: var(--ht-text);
}

[data-theme="dark"] .app-main .exercise-library-intro,
[data-theme="dark"] .app-main .exercise-library-breadcrumb,
[data-theme="dark"] .app-main .exercise-library-filter-note,
[data-theme="dark"] .app-main .exercise-library-result-card__desc,
[data-theme="dark"] .app-main .workout-log-met-hint {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .app-main .exercise-library-check {
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .exercise-library .meta-tag {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .exercise-library-result-card:hover {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
}

[data-theme="dark"] .app-main .dashboard-shell .stat-icon {
  background: var(--ht-accent-light);
}

[data-theme="dark"] .app-main .dashboard-shell .progress-bar-container {
  background: var(--ht-border);
}

[data-theme="dark"] .app-main .dashboard-shell .action-header,
[data-theme="dark"] .app-main .dashboard-shell .chart-header,
[data-theme="dark"] .app-main .workout-log-detail > .card .action-header,
[data-theme="dark"] .app-main .exercise-library-filters .action-header {
  border-bottom-color: var(--ht-border);
}

/* MuscleWiki exercise detail — dark mode */
[data-theme="dark"] .app-main .mw-exercise-panel {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  box-shadow: var(--ht-shadow-md);
}

[data-theme="dark"] .app-main .mw-exercise-steps__text {
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .mw-exercise-bodymap {
  background: var(--ht-surface-muted);
  border-bottom-color: var(--ht-border);
}

[data-theme="dark"] .app-main .mw-exercise-bodymap__image {
  background: var(--ht-canvas);
}

[data-theme="dark"] .app-main .mw-legend {
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .mw-bodymap-option {
  background: var(--ht-surface);
  border-color: var(--ht-border);
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .mw-bodymap-option.is-active {
  border-color: #5b8ab8;
  background: var(--ht-primary-muted);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .app-main .mw-attribute-row {
  border-top-color: var(--ht-border);
}

[data-theme="dark"] .app-main .mw-attribute-row__label {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .app-main .mw-attribute-row__value {
  color: var(--ht-text);
}

[data-theme="dark"] .app-main .exercise-library-detail__summary {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
}

[data-theme="dark"] .app-main .exercise-library-detail__summary p,
[data-theme="dark"] .app-main .exercise-library-detail__body {
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .exercise-library-tabs__link {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
  color: var(--ht-text-secondary);
}

[data-theme="dark"] .app-main .exercise-library-tabs__link:hover {
  background: var(--ht-primary-muted);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .app-main .exercise-library-tabs__link.active {
  background: var(--ht-primary-light);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .app-main .exercise-library-workout-item {
  background: var(--ht-surface-muted);
  border-color: var(--ht-border);
}

[data-theme="dark"] .app-main .exercise-library-workout-item__name {
  color: var(--ht-text);
}

[data-theme="dark"] .app-main a.exercise-library-workout-item__name:hover {
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .dashboard-notice {
  background: var(--ht-accent-light);
  border-color: var(--ht-border-strong);
}

[data-theme="dark"] .dashboard-notice__text {
  color: var(--ht-accent-hover);
}

[data-theme="dark"] .dashboard-notice__action {
  background: var(--ht-surface);
  border-color: var(--ht-border-strong);
  color: var(--ht-accent-hover);
}

[data-theme="dark"] .dashboard-notice__action:hover {
  background: var(--ht-surface-muted);
}

[data-theme="dark"] .dashboard-dash-mobile-disclosure__summary {
  background: var(--ht-primary-muted);
  border-color: #115e59;
  color: #5eead4;
}

[data-theme="dark"] .dashboard-dash-mobile-disclosure__chevron {
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .message.success {
  color: #6ee7b7;
}

[data-theme="dark"] .message.error {
  color: #fca5a5;
}

[data-theme="dark"] .message.warning {
  color: #fcd34d;
}

[data-theme="dark"] .message.info {
  color: #7dd3fc;
}

/* Dark mode — Tailwind-like utility remapping */
[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-slate-800 {
  color: var(--ht-text) !important;
}

[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-slate-700,
[data-theme="dark"] .text-slate-600 {
  color: var(--ht-text-secondary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-400 {
  color: var(--ht-text-muted) !important;
}

[data-theme="dark"] .bg-white {
  background-color: var(--ht-surface) !important;
}

[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-slate-50 {
  background-color: var(--ht-surface-muted) !important;
}

[data-theme="dark"] .bg-gray-100,
[data-theme="dark"] .bg-slate-100 {
  background-color: var(--ht-surface-muted) !important;
}

[data-theme="dark"] .bg-gray-200,
[data-theme="dark"] .bg-slate-200 {
  background-color: var(--ht-border) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-slate-300 {
  border-color: var(--ht-border) !important;
}

[data-theme="dark"] .hover\:bg-gray-100:hover,
[data-theme="dark"] .hover\:bg-slate-100:hover {
  background-color: var(--ht-surface-muted) !important;
}

[data-theme="dark"] .hover\:bg-gray-200:hover,
[data-theme="dark"] .hover\:bg-slate-200:hover {
  background-color: var(--ht-border) !important;
}

[data-theme="dark"] .hover\:text-gray-900:hover {
  color: var(--ht-text) !important;
}

[data-theme="dark"] .auth-card .auth-error {
  color: #fca5a5;
  border-color: #7f1d1d;
}

[data-theme="dark"] .add-meal-page-root .add-meal-search-panel,
[data-theme="dark"] .add-meal-page-root .add-meal-phase-strip,
[data-theme="dark"] .add-meal-page-root .food-search-result,
[data-theme="dark"] .add-meal-page-root .meal-builder-panel {
  background: var(--ht-surface);
  color: var(--ht-text);
  border-color: var(--ht-border);
}

[data-theme="dark"] .add-meal-page-root .add-meal-search-panel__intro h2,
[data-theme="dark"] .add-meal-page-root .food-search-result__name,
[data-theme="dark"] .add-meal-page-root .meal-builder-panel h3 {
  color: var(--ht-text);
}

[data-theme="dark"] .add-meal-page-root .food-search-result__meta,
[data-theme="dark"] .add-meal-page-root .add-meal-phase-strip__label {
  color: var(--ht-text-muted);
}

[data-theme="dark"] .add-meal-page-root .add-meal-suggestion-chip {
  background: var(--ht-surface-muted);
  border-color: var(--ht-primary);
  color: var(--ht-primary-hover);
}

[data-theme="dark"] .add-meal-page-root .add-meal-suggestion-chip:hover {
  background: var(--ht-primary-muted);
}

[data-theme="dark"] .profile-completion-banner,
[data-theme="dark"] .disclaimer {
  background: var(--ht-info-light);
  color: var(--ht-text-secondary);
  border-color: var(--ht-border-strong);
}