/* ═══════════════════════════════════════════════════════════
   NutriSnap — Premium Apple iPhone PWA Design System
   OLED Dark Theme, iOS Glassmorphism, Native Health Aesthetics
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-app:        #000000;
  --bg-surface:    #0c0d10;
  --bg-card:       #14161c;
  --bg-card-hover: #1a1e27;
  --bg-input:      #1f232e;
  
  --text-main:     #ffffff;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;

  --accent-green:  #30d158;
  --accent-green-glow: rgba(48, 209, 88, 0.25);
  --protein:       #38bdf8;
  --protein-bg:    rgba(56, 189, 248, 0.12);
  --carbs:         #fbbf24;
  --carbs-bg:      rgba(251, 191, 36, 0.12);
  --fat:           #fb7185;
  --fat-bg:        rgba(251, 113, 133, 0.12);
  --fiber:         #2dd4bf;
  --sugar:         #c084fc;

  --border:        rgba(255, 255, 255, 0.08);
  --border-focus:  rgba(48, 209, 88, 0.5);

  --radius-xs:     8px;
  --radius-sm:     12px;
  --radius-md:     16px;
  --radius-lg:     22px;
  --radius-full:   9999px;

  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  
  --transition:    all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  user-select: none;
}

/* ── App Shell ─────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-surface);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

@media (min-width: 481px) {
  .app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.status-bar-spacer {
  height: var(--safe-top);
  flex-shrink: 0;
  background: rgba(12, 13, 16, 0.85);
}

/* ── Header ────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(12, 13, 16, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #30d158 0%, #10b981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  box-shadow: 0 0 16px rgba(48, 209, 88, 0.35);
}

.app-logo svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

.header-brand {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.15;
}

.app-title span {
  color: var(--accent-green);
}

.app-subtitle {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Daily Pill Button */
.daily-pill-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.8rem;
  transition: var(--transition);
}

.daily-pill-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.12);
}

.fire-icon {
  font-size: 0.85rem;
}

.daily-pill-val {
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #facc15;
}

.daily-pill-unit {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.icon-btn.sm {
  width: 30px;
  height: 30px;
}

.icon-btn.sm svg {
  width: 16px;
  height: 16px;
}

.history-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--accent-green);
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* ── Main Content Area ─────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 40px;
  padding-bottom: calc(40px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.main-content::-webkit-scrollbar {
  width: 0;
}

/* ── Section 1: Upload Hero & Actions ──────────────────── */
.upload-hero {
  text-align: center;
  padding: 18px 0 22px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(48, 209, 88, 0.12);
  border: 1px solid rgba(48, 209, 88, 0.28);
  color: var(--accent-green);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.upload-hero h2 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.upload-hero p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.45;
}

/* Upload Buttons */
.upload-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  text-align: left;
}

.upload-btn:active {
  transform: scale(0.98);
}

.btn-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-circle svg {
  width: 22px;
  height: 22px;
}

.btn-text-group {
  display: flex;
  flex-direction: column;
}

.btn-text-group strong {
  font-size: 1rem;
  font-weight: 700;
}

.btn-text-group span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.primary-btn {
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.22) 0%, rgba(16, 185, 129, 0.12) 100%);
  border-color: rgba(48, 209, 88, 0.45);
  box-shadow: 0 4px 20px rgba(48, 209, 88, 0.15);
}

.primary-btn .btn-icon-circle {
  background: var(--accent-green);
  color: #000;
}

.primary-btn strong {
  color: #ffffff;
}

.secondary-btn {
  background: var(--bg-card);
}

.secondary-btn .btn-icon-circle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Desktop Dropzone */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.dropzone svg {
  width: 18px;
  height: 18px;
}

.dropzone.dragover {
  border-color: var(--accent-green);
  background: rgba(48, 209, 88, 0.06);
  color: var(--accent-green);
}

/* Sample Foods Strip */
.samples-wrapper {
  margin-bottom: 24px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.section-hint {
  font-size: 0.72rem;
  color: var(--accent-green);
  font-weight: 600;
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent-green);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.sample-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.sample-card:active {
  transform: scale(0.94);
  border-color: var(--accent-green);
}

.sample-img-wrap {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.sample-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Recent Scans Strip */
.recent-section {
  margin-top: 10px;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.recent-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  background: var(--bg-card);
}

.recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recent-thumb:active {
  transform: scale(0.93);
}

/* ── Section 2: Preview & Scanning ─────────────────────── */
.preview-section {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.preview-card {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.preview-image-wrap {
  position: relative;
  width: 100%;
  height: 320px;
  background: #000;
  overflow: hidden;
}

.preview-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Laser Scanner Animation */
.analyzing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.scan-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--accent-green) 50%, transparent 100%);
  box-shadow: 0 0 15px var(--accent-green), 0 0 35px var(--accent-green);
  animation: laserScan 2s ease-in-out infinite;
}

@keyframes laserScan {
  0%   { top: 5%; opacity: 0.8; }
  50%  { top: 92%; opacity: 1; }
  100% { top: 5%; opacity: 0.8; }
}

.scan-reticle {
  position: absolute;
  inset: 24px;
}

.reticle-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--accent-green);
}

.reticle-corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 8px; }
.reticle-corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 8px; }
.reticle-corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 8px; }
.reticle-corner.br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 8px; }

.preview-status {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
}

.status-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.status-texts {
  display: flex;
  flex-direction: column;
}

.status-texts strong {
  font-size: 0.95rem;
}

.status-texts span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.cancel-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.cancel-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Section 3: Results Dashboard ──────────────────────── */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-image-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 200px;
  background: #000;
  border: 1px solid var(--border);
}

.result-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-image-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
}

.result-tag-pill {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.result-tag-pill svg {
  width: 14px;
  height: 14px;
  color: var(--accent-green);
}

/* Dietary Tags */
.dietary-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diet-tag {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Summary Card */
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.summary-heading {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.summary-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Portion Multiplier Card */
.portion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.portion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.portion-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.portion-title svg {
  width: 15px;
  height: 15px;
  color: var(--accent-green);
}

.portion-active-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-green);
  font-family: 'JetBrains Mono', monospace;
}

.portion-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.portion-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.portion-chip.active {
  background: var(--accent-green);
  color: #000;
  font-weight: 800;
  border-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(48, 209, 88, 0.3);
}

/* Totals Card */
.totals-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
}

.totals-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.daily-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-green);
  font-family: 'JetBrains Mono', monospace;
}

/* Circular Calorie Gauge */
.calorie-display {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.calorie-ring {
  position: relative;
  width: 130px;
  height: 130px;
}

.calorie-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 9;
}

.ring-fill {
  fill: none;
  stroke: var(--accent-green);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.calorie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cal-number {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}

.cal-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}

/* Macro Percentage Distribution Bar */
.macro-bar-wrapper {
  margin-bottom: 20px;
}

.macro-bar-track {
  height: 8px;
  border-radius: var(--radius-full);
  display: flex;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.bar-segment {
  height: 100%;
  transition: width 0.8s ease;
}

.bar-protein { background: var(--protein); }
.bar-carbs   { background: var(--carbs); }
.bar-fat     { background: var(--fat); }

.macro-bar-legend {
  display: flex;
  justify-content: space-around;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-item.protein .dot { background: var(--protein); }
.legend-item.carbs .dot   { background: var(--carbs); }
.legend-item.fat .dot     { background: var(--fat); }

.legend-item strong {
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

/* Core Macros Grid */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.macro-pill {
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.macro-pill.protein { background: var(--protein-bg); color: var(--protein); }
.macro-pill.carbs   { background: var(--carbs-bg); color: var(--carbs); }
.macro-pill.fat     { background: var(--fat-bg); color: var(--fat); }

.macro-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.macro-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

.macro-cals {
  font-size: 0.7rem;
  opacity: 0.75;
}

/* Secondary Micro Stats */
.secondary-grid {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.micro-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.micro-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.micro-val {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.micro-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* Items Card */
.items-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.items-count-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}

.items-list {
  display: flex;
  flex-direction: column;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.item-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.item-row:first-child {
  padding-top: 4px;
}

.item-info {
  flex: 1;
}

.item-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.item-portion {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.item-macros-mini {
  display: flex;
  gap: 8px;
  margin-top: 3px;
}

.mini-macro {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.mini-macro span {
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.mini-macro.p span { color: var(--protein); }
.mini-macro.c span { color: var(--carbs); }
.mini-macro.f span { color: var(--fat); }

.item-cals {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-green);
  margin-left: 10px;
}

/* Tip Card */
.tip-card {
  background: rgba(48, 209, 88, 0.08);
  border: 1px solid rgba(48, 209, 88, 0.22);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.tip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(48, 209, 88, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-green);
  flex-shrink: 0;
}

.tip-icon svg {
  width: 18px;
  height: 18px;
}

.tip-content strong {
  font-size: 0.88rem;
  display: block;
  margin-bottom: 2px;
}

.tip-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Ask AI Card */
.ask-ai-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.ask-ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ask-ai-header svg {
  width: 22px;
  height: 22px;
  color: var(--accent-green);
}

.ask-ai-header strong {
  font-size: 0.92rem;
  display: block;
  line-height: 1.2;
}

.ask-ai-header span {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.ask-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.ask-prompt-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.ask-prompt-chip:active {
  background: rgba(48, 209, 88, 0.15);
  color: #fff;
  border-color: var(--accent-green);
}

.ask-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ask-form input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.ask-form input:focus {
  border-color: var(--border-focus);
}

.ask-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-green);
  border: none;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.ask-btn svg {
  width: 16px;
  height: 16px;
}

.ask-btn:active {
  transform: scale(0.92);
}

.ask-response-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-green);
}

.ask-response-spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.ask-response-text {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Result Action Buttons */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

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

.log-btn {
  background: linear-gradient(135deg, #30d158 0%, #10b981 100%);
  color: #000;
  box-shadow: 0 4px 18px rgba(48, 209, 88, 0.35);
}

.secondary-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.share-btn {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}

.scan-again-btn {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}

/* ── Section 4: Error Card ─────────────────────────────── */
.error-section {
  padding-top: 40px;
}

.error-card {
  text-align: center;
  padding: 30px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.error-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(251, 113, 133, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--fat);
}

.error-icon svg {
  width: 28px;
  height: 28px;
}

.error-card h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.error-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 22px;
}

/* ── Drawers (Daily Log & History) ─────────────────────── */
.drawer {
  position: absolute;
  inset: 0;
  background: var(--bg-app);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0 18px 24px;
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow: hidden;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.drawer-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
}

.drawer-subtitle {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-body::-webkit-scrollbar {
  width: 0;
}

/* Daily Tracker Card in Drawer */
.daily-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.daily-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.daily-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.daily-stat-big {
  font-size: 2rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #fff;
  margin-right: 4px;
}

.daily-stat-target {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.daily-cal-pct-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-green);
}

.daily-bars-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bar-labels span:last-child {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  font-weight: 600;
}

.daily-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.daily-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.protein-fill { background: var(--protein); }
.carbs-fill   { background: var(--carbs); }
.fat-fill     { background: var(--fat); }

/* Daily Meals List */
.daily-meals-list, .history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logged-meal-item, .history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.logged-meal-item:active, .history-item:active {
  background: var(--bg-card-hover);
  transform: scale(0.98);
}

.item-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.item-details strong {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 0.74rem;
  color: var(--text-dim);
}

.item-cal-badge {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-green);
  white-space: nowrap;
}

.delete-meal-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
}

.delete-meal-btn:hover {
  color: var(--fat);
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-dim);
}

.danger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: var(--fat);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Modal: iPhone Install Guide ───────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

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

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.modal-icon svg {
  width: 20px;
  height: 20px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  flex: 1;
}

.modal-lead {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.install-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-text {
  display: flex;
  flex-direction: column;
}

.step-text strong {
  font-size: 0.88rem;
}

.step-text span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.install-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(48, 209, 88, 0.1);
  border: 1px solid rgba(48, 209, 88, 0.25);
  color: var(--accent-green);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 18px;
}

.install-tip svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Toast Pill ────────────────────────────────────────── */
.toast-pill {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.toast-pill svg {
  width: 16px;
  height: 16px;
  color: var(--accent-green);
}

.toast-pill.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}
