:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --card-bg: rgba(30, 41, 59, 0.85);
  --card-border: rgba(148, 163, 184, 0.14);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-emerald: #10b981;
  --accent-emerald-dark: #059669;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --protein-color: #3b82f6;
  --carbs-color: #f59e0b;
  --fat-color: #ec4899;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top right, #132a3e 0%, #0f172a 55%, #090e1a 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.auth-pending .app-shell,
.auth-pending .voice-dock,
.auth-required .app-shell,
.auth-required .voice-dock {
  display: none;
}

.auth-gate {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at top right, #132a3e 0%, #0f172a 55%, #090e1a 100%);
}

.auth-pending .auth-gate,
.auth-required .auth-gate,
.authenticated .auth-gate {
  display: flex;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(100%, 430px);
  text-align: center;
}

.auth-card h1 {
  margin-top: 12px;
  font-size: 1.7rem;
}

.auth-card .stacked-form {
  text-align: right;
  margin-top: 20px;
}

.auth-private-note {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.account-chip {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.admin-users-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.admin-users-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.42);
}

.app-shell {
  --shell-spacing: 16px;
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--shell-spacing) + env(safe-area-inset-top, 0px))
    calc(var(--shell-spacing) + env(safe-area-inset-right, 0px))
    var(--shell-spacing)
    calc(var(--shell-spacing) + env(safe-area-inset-left, 0px));
}

/* Header & Date Navigator */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-emerald), #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.brand-titles h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
}

.brand-titles .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.65);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.date-picker-wrap {
  position: relative;
}

.date-display-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  cursor: pointer;
  padding: 2px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.date-display-btn span {
  font-weight: 700;
  font-size: 0.95rem;
}

.date-display-btn small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

#date-picker-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.today-pill {
  background: var(--accent-emerald);
  color: #052e16;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Main Navigation */
.main-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  background: var(--card-bg);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  margin-bottom: 20px;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 5px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-emerald-dark));
  color: #042f2e;
  font-weight: 800;
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Summary Card */
.hero-card {
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
}

.calorie-overview {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.cal-stat {
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 10px;
  border-radius: var(--radius-md);
}

.cal-stat-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cal-stat-val {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
}

.burned-text {
  color: var(--accent-amber);
}

.cal-stat small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Ring Progress */
.ring-container {
  position: relative;
  width: 175px;
  height: 175px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.ring-bg {
  stroke: rgba(148, 163, 184, 0.15);
}

.ring-fill {
  stroke: var(--accent-emerald);
  transition: stroke-dashoffset 0.55s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
}

.ring-fill.over-limit {
  stroke: var(--accent-rose);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.ring-status-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.ring-main-number {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.1;
  margin: 2px 0;
  color: #fff;
}

.ring-main-number.over-limit {
  color: var(--accent-rose);
}

.ring-sub-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Macros Progress */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.macro-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.macro-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.macro-name {
  font-weight: 700;
}

.macro-nums {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.macro-nums strong {
  color: var(--text-main);
  font-size: 0.9rem;
}

.bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.macro-box.protein .bar-fill { background: var(--protein-color); }
.macro-box.carbs .bar-fill { background: var(--carbs-color); }
.macro-box.fat .bar-fill { background: var(--fat-color); }

/* Quick Actions & Fast Strip */
.quick-actions-bar {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-emerald-dark));
  color: #042f2e;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px var(--accent-emerald-glow);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.secondary-btn {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: var(--bg-tertiary);
  border-color: rgba(255, 255, 255, 0.25);
}

.danger-btn {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.35);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.danger-btn:hover {
  background: rgba(244, 63, 94, 0.28);
}

.outline-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  font-family: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.86rem;
}

.full-width {
  width: 100%;
}

/* Fast Add Strip */
.fast-add-strip {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.strip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.strip-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
}

.strip-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.quick-chip {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.quick-chip:hover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
}

.quick-chip small {
  color: var(--accent-emerald);
  font-weight: 700;
}

/* Meals Grid */
.meals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.meal-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.meal-card.exercise-card {
  grid-column: 1 / -1;
}

.meal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 10px;
}

.meal-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-emoji {
  font-size: 1.3rem;
}

.meal-title-wrap h3 {
  font-size: 1.02rem;
  font-weight: 700;
}

.meal-cal-total {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 3px 10px;
  border-radius: 999px;
}

.meal-items-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 44px;
}

.meal-empty {
  color: var(--text-muted);
  font-size: 0.83rem;
  font-style: italic;
  padding: 10px 0;
  text-align: center;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.log-item-info {
  display: flex;
  flex-direction: column;
}

.log-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.log-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.log-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-item-cal {
  font-weight: 700;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.delete-entry-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.delete-entry-btn:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.12);
}

.meal-add-trigger {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.meal-add-trigger:hover {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

/* Cards Generic */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 1.12rem;
  font-weight: 800;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Water Tracker */
.water-counter-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.water-glasses-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.water-glass {
  width: 48px;
  height: 56px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(59, 130, 246, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s ease;
}

.water-glass.filled {
  opacity: 1;
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.water-controls {
  display: flex;
  gap: 10px;
}

.water-add-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  font-family: inherit;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
}

/* Food Database View */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  right: 14px;
  font-size: 1rem;
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--accent-emerald);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill.active {
  background: var(--accent-emerald);
  color: #052e16;
  border-color: var(--accent-emerald);
  font-weight: 700;
}

.food-db-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 12px;
}

.food-db-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.food-db-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.food-db-title {
  font-weight: 700;
  font-size: 0.96rem;
}

.food-db-unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.food-db-cal-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.food-db-macros {
  display: flex;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.food-db-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Stats View */
.stats-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat-mini-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
}

.stat-mini-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-mini-val {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
}

.emerald-text { color: var(--accent-emerald); }
.orange-text { color: var(--accent-amber); }
.purple-text { color: #c084fc; }

.weekly-chart-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: end;
  height: 210px;
  padding-top: 24px;
  border-bottom: 1px solid var(--card-border);
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.chart-bar-val {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-bar-wrap {
  width: 100%;
  max-width: 38px;
  height: 140px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.chart-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-emerald), var(--accent-emerald-dark));
  border-radius: 8px 8px 0 0;
  transition: height 0.4s ease;
}

.chart-bar-fill.over {
  background: linear-gradient(180deg, var(--accent-rose), #be123c);
}

.chart-day-label {
  font-size: 0.78rem;
  font-weight: 600;
  padding-bottom: 8px;
  color: var(--text-main);
}

/* Weight & Backup */
.weight-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.weight-form .input-group {
  flex: 1;
  min-width: 180px;
}

.weight-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weight-pill {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-label {
  cursor: pointer;
}

/* Forms & Inputs */
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #cbd5e1;
}

input[type="text"],
input[type="number"],
input[type="search"],
select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-emerald);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.calc-result-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 0.88rem;
}

.ai-log-card {
  border-color: rgba(16, 185, 129, 0.28);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), var(--card-bg) 45%);
}

.ai-recommendation-card {
  border-color: rgba(59, 130, 246, 0.28);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.09), var(--card-bg) 48%);
}

.recommendation-budget {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 12px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.6);
}

.recommendation-budget strong {
  color: #93c5fd;
  font-size: 1.15rem;
}

.recommendation-budget small {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.recommendation-quick-prompts,
.recommendation-chat-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.recommendation-quick-prompts {
  margin-bottom: 12px;
}

.recommendation-chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  min-height: 96px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(7, 14, 27, 0.55);
  overscroll-behavior: contain;
}

.recommendation-message {
  width: fit-content;
  max-width: min(92%, 680px);
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(51, 65, 85, 0.5);
  color: #e2e8f0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.recommendation-message.user {
  align-self: flex-start;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.13);
}

.recommendation-message.assistant {
  align-self: flex-end;
  border-color: rgba(59, 130, 246, 0.25);
}

.recommendation-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.recommendation-suggestion {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.6);
  font-size: 0.84rem;
}

.recommendation-suggestion strong {
  color: #bfdbfe;
}

.recommendation-chat-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recommendation-chat-form textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 11px 13px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  font: inherit;
  font-size: 0.94rem;
}

.recommendation-chat-form textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.recommendation-chat-actions {
  justify-content: space-between;
}

.recommendation-disclaimer {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.ai-model-badge {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.13);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.ai-log-card textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  font: inherit;
  font-size: 0.94rem;
}

.ai-log-card textarea:focus {
  outline: none;
  border-color: var(--accent-emerald);
}

.ai-progress,
.ai-result,
.ai-key-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.58);
  color: #cbd5e1;
  font-size: 0.86rem;
}

.ai-progress {
  color: #a7f3d0;
}

.ai-error {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.35);
}

.ai-result a {
  color: #93c5fd;
  text-decoration: underline;
}

.ai-result ul {
  margin: 8px 22px 0 0;
}

.ai-security-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.08);
  color: #fde68a;
  font-size: 0.84rem;
}

.ai-settings-card {
  margin-top: 18px;
}

.ai-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-panel {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.close-modal-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 5px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.modal-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.modal-tab.active {
  background: var(--accent-emerald);
  color: #052e16;
  font-weight: 800;
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

.meal-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.meal-selector-row label {
  white-space: nowrap;
}

.modal-food-results {
  max-height: 220px;
  overflow-y: auto;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-food-option {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-food-option:hover,
.modal-food-option.selected {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.14);
}

.selected-food-config {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 10px;
}

.selected-food-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.quantity-picker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-stepper input {
  width: 75px;
  text-align: center;
  font-weight: 700;
}

.step-btn {
  width: 34px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.live-calc-preview {
  text-align: left;
}

.live-calc-preview strong {
  font-size: 1.35rem;
  color: var(--accent-emerald);
}

.preview-macros {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.exercise-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.ex-preset-chip {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.ex-preset-chip:hover {
  border-color: var(--accent-amber);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #065f46;
  color: #ecfdf5;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border: 1px solid #10b981;
  animation: fadeIn 0.2s ease;
}

/* Responsive */
@media (max-width: 720px) {
  .calorie-overview {
    grid-template-columns: 1fr 1fr;
  }
}

  #view-dashboard.active {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    gap: 14px;
    align-items: stretch;
  }

  #view-dashboard > section {
    min-width: 0;
    margin: 0;
  }

  #view-dashboard .ai-log-card {
    grid-column: 1 / -1;
    padding: 18px;
  }

  #view-dashboard .ai-recommendation-card {
    grid-column: 1 / -1;
    min-width: 0;
  }

  #view-dashboard .ai-log-card .card-header {
    margin-bottom: 12px;
  }

  #view-dashboard .ai-log-card textarea {
    min-height: 68px;
  }

  #view-dashboard .ai-result {
    max-height: 240px;
    overflow-y: auto;
  }

  .body-card {
    background: radial-gradient(ellipse at 50% 60%, #173f4f, #132033 70%);
    padding: 14px;
    text-align: center;
    overflow: hidden;
  }

  .body-heading h2 {
    font-size: 1rem;
  }

  .body-live-badge {
    display: inline-block;
    font-size: .72rem;
    color: #89e8cf;
  }

  .body-avatar {
    display: block;
    height: 230px;
    max-width: 100%;
    margin: 0 auto;
  }

  .body-model {
    animation: body-breathe 5s ease-in-out infinite;
    transform-origin: 120px 300px;
  }

  #body-food-fill,
  #body-water-fill {
    transition: y .8s ease, height .8s ease;
  }

  .sweat-drops {
    opacity: 0;
    transition: opacity .3s;
  }

  .body-figure.is-active .sweat-drops {
    opacity: 1;
  }

  .body-figure.is-active .sweat-drop {
    animation: sweat-fall 1.8s ease-in infinite;
  }

  .sweat-drop:nth-child(2) { animation-delay: .6s !important; }
  .sweat-drop:nth-child(3) { animation-delay: 1.2s !important; }

  .body-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .8rem;
  }

  .food-legend { color: #67edb5; }
  .water-legend { color: #73dbff; }
  .body-legend strong { margin-inline-start: 3px; }
  .body-disclaimer { color: var(--text-muted); font-size: .65rem; margin-top: 5px; }

  #view-dashboard .hero-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #view-dashboard .calorie-overview {
    gap: 8px;
    margin-bottom: 14px;
  }

  #view-dashboard .ring-container {
    width: 132px;
    height: 132px;
  }

  #view-dashboard .progress-ring {
    width: 100%;
    height: 100%;
  }

  #view-dashboard .ring-main-number { font-size: 1.75rem; }
  #view-dashboard .ring-sub-text { font-size: .68rem; }
  #view-dashboard .cal-stat { padding: 9px 4px; }
  #view-dashboard .cal-stat-val { font-size: 1.3rem; }
  #view-dashboard .cal-stat-label { font-size: .72rem; }
  #view-dashboard .macros-grid { grid-template-columns: 1fr; gap: 10px; }
  #view-dashboard .macro-box { padding: 0; }
  #view-dashboard .macro-head { margin-bottom: 4px; }

  .voice-dock {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: max(16px, env(safe-area-inset-left));
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: calc(100vw - 32px);
  }

  .voice-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 52px;
    padding: 12px 18px;
    border: 1px solid #6ee7b7;
    border-radius: 999px;
    background: #047857;
    color: #fff;
    font: 600 .9rem 'Heebo', sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 28px #0007;
  }

  .voice-toggle:focus-visible,
  .nav-tab:focus-visible {
    outline: 3px solid #bae6fd;
    outline-offset: 3px;
  }

  .voice-toggle.is-recording {
    background: #b91c1c;
    border-color: #fca5a5;
  }

  .voice-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a7f3d0;
  }

  .is-recording .voice-indicator {
    background: #fff;
    animation: mic-pulse 1s ease-in-out infinite;
  }

  .voice-panel {
    width: min(340px, calc(100vw - 32px));
    padding: 12px 16px;
    background: #132236;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    font-size: .85rem;
  }

  #voice-transcript {
    color: #a5e9f7;
    max-height: 95px;
    overflow-y: auto;
    overflow-wrap: anywhere;
  }

  .voice-panel.is-error { border-color: #fb7185; }

  .voice-dismiss {
    float: left;
    width: 28px;
    height: 28px;
    margin-inline-start: 4px;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
  }
  .voice-dismiss:disabled { visibility: hidden; }

  @keyframes body-breathe {
    50% { transform: scaleY(1.012); }
  }
  @keyframes sweat-fall {
    0% { transform: translateY(-4px); opacity: 0; }
    25% { opacity: 1; }
    100% { transform: translateY(22px); opacity: 0; }
  }
  @keyframes mic-pulse {
    50% { opacity: .35; }
  }

  @media (max-width: 720px) {
    .app-shell { --shell-spacing: 10px; }
    .top-header { padding: 10px 12px; gap: 8px; margin-bottom: 10px; }
    .brand-logo { width: 34px; height: 34px; font-size: 1.2rem; }
    .brand-titles h1 { font-size: 1.05rem; }
    .brand-titles { display: none; }
    .brand { gap: 7px; }
    .date-navigator { gap: 2px; flex: 1; justify-content: space-between; padding: 4px; }
    .date-display-btn { padding-inline: 4px; }
    .main-nav { gap: 2px; margin-bottom: 10px; padding: 4px; }
    .nav-tab { min-height: 48px; }
    #view-dashboard.active { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 8px; }
    #view-dashboard .hero-card { padding: 10px; }
    .body-card { padding: 10px 5px; }
    .body-heading h2 { font-size: .83rem; }
    .body-avatar { height: 185px; }
    .body-legend { gap: 6px; font-size: .7rem; }
    .body-disclaimer { font-size: .6rem; }
    #view-dashboard .calorie-overview { gap: 5px; margin-bottom: 9px; }
    #view-dashboard .ring-container { width: 95px; height: 95px; }
    #view-dashboard .ring-main-number { font-size: 1.4rem; }
    #view-dashboard .ring-status-label { font-size: .65rem; }
    #view-dashboard .ring-sub-text { font-size: .57rem; }
    #view-dashboard .cal-stat-val { font-size: 1.05rem; }
    #view-dashboard .cal-stat-label, #view-dashboard .cal-stat small { font-size: .62rem; }
    #view-dashboard .cal-stat { padding: 4px 2px; font-size: .7rem; line-height: 1.3; }
    #view-dashboard .macros-grid { gap: 6px; }
    #view-dashboard .macro-name, #view-dashboard .macro-nums { font-size: .65rem; }
    #view-dashboard .macro-head { line-height: 1.3; }
    #view-dashboard .macro-nums strong { font-size: .72rem; }
    #view-dashboard .bar-track { height: 4px; }
    #view-dashboard .ai-log-card { padding: 12px; }
    #view-dashboard .ai-log-card h2 { font-size: 1rem; }
    #view-dashboard .ai-log-card .card-subtitle { font-size: .73rem; }
    #view-dashboard .ai-log-card .card-header { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 8px; }
    #view-dashboard .ai-model-badge { font-size: .6rem; padding: 4px 6px; }
    #view-dashboard .stacked-form { gap: 7px; }
    #view-dashboard .stacked-form label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    #view-dashboard .ai-log-card textarea { padding: 9px; font-size: .9rem; }
  }

  @media (max-width: 360px) {
    .top-header { justify-content: center; }
    .brand { display: none; }
    .nav-tab span:not(.nav-icon) { font-size: .61rem; }
    .body-avatar { height: 145px; }
    #view-dashboard .ai-model-badge { display: none; }
    #view-dashboard .ai-log-card .card-header { grid-template-columns: 1fr; }
  }

  @media (prefers-reduced-motion: reduce) {
    .body-model, .body-figure.is-active .sweat-drop, .is-recording .voice-indicator { animation: none; }
    #body-food-fill, #body-water-fill, .sweat-drops { transition: none; }
  }
@media (max-width: 720px) {
  .ring-container {
    grid-column: 1 / -1;
    order: -1;
    margin: 0 auto;
  }
  .macros-grid,
  .meals-grid,
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  .stats-summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .quick-actions-bar {
    grid-template-columns: 1fr;
  }
  .nav-tab span:not(.nav-icon) {
    font-size: 0.68rem;
    white-space: nowrap;
  }
  .nav-tab {
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px;
  }
}
