/* ===========================
   CALTRACK — STYLE.CSS
   Aesthetic: Industrial Dark / Neon Health
   =========================== */

:root {
  --bg: #0e0f11;
  --bg2: #16181c;
  --bg3: #1e2128;
  --border: #2a2d35;
  --text: #f0f0f0;
  --text-muted: #6b7280;
  --accent: #c6f135;
  --accent2: #ff6b35;
  --accent3: #35d4ff;
  --desayuno: #fbbf24;
  --almuerzo: #34d399;
  --cena: #818cf8;
  --otros: #fb7185;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 8px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --glow: 0 0 24px rgba(198, 241, 53, 0.15);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 100px;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
  opacity: 0.6;
}

/* ===========================
   HEADER
   =========================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 15, 17, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.5px;
}

.logo-icon { font-size: 1.4rem; }

.logo-text {
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  background: var(--bg3);
  border-radius: 100px;
  padding: 4px;
  border: 1px solid var(--border);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn.active {
  background: var(--accent);
  color: #0e0f11;
}

.btn-settings {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-settings:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===========================
   MAIN LAYOUT
   =========================== */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ===========================
   SUMMARY CARD (Ring)
   =========================== */
.summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(198,241,53,0.07) 0%, transparent 70%);
  border-radius: 50%;
}

.summary-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.summary-date {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
}

.summary-tope {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 100px;
}

.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto;
}

.ring-svg {
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: var(--bg3);
  stroke-width: 18;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 18;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
  filter: drop-shadow(0 0 8px rgba(198,241,53,0.5));
}

.ring-fill.danger { stroke: var(--danger); filter: drop-shadow(0 0 8px rgba(239,68,68,0.6)); }
.ring-fill.warning { stroke: var(--accent2); filter: drop-shadow(0 0 8px rgba(255,107,53,0.5)); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-kcal {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  transition: color 0.4s;
}

.ring-kcal.danger { color: var(--danger); }
.ring-kcal.warning { color: var(--accent2); }

.ring-label {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.summary-remaining {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.summary-remaining strong { color: var(--accent); }
.summary-remaining.danger strong { color: var(--danger); }

/* ===========================
   BARS SECTION
   =========================== */
.bars-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.bars-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bar-item {}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.bar-kcal {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg3);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-desayuno { background: linear-gradient(90deg, var(--desayuno), #f59e0b); box-shadow: 0 0 10px rgba(251,191,36,0.4); }
.bar-almuerzo { background: linear-gradient(90deg, var(--almuerzo), #10b981); box-shadow: 0 0 10px rgba(52,211,153,0.4); }
.bar-cena     { background: linear-gradient(90deg, var(--cena), #6366f1); box-shadow: 0 0 10px rgba(129,140,248,0.4); }
.bar-otros    { background: linear-gradient(90deg, var(--otros), #f43f5e); box-shadow: 0 0 10px rgba(251,113,133,0.4); }

/* ===========================
   ENTRIES LIST
   =========================== */
.entries-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }

.entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: slideIn 0.3s ease;
  transition: border-color 0.2s;
}

.entry-item:hover { border-color: var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.dot-desayuno { background: var(--desayuno); box-shadow: 0 0 6px var(--desayuno); }
.dot-almuerzo { background: var(--almuerzo); box-shadow: 0 0 6px var(--almuerzo); }
.dot-cena     { background: var(--cena);     box-shadow: 0 0 6px var(--cena); }
.dot-otros    { background: var(--otros);    box-shadow: 0 0 6px var(--otros); }

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

.entry-desc {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.entry-kcal {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

.entry-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.entry-delete:hover { color: var(--danger); }

/* ===========================
   FAB BUTTON
   =========================== */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #0e0f11;
  font-size: 1.8rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(198,241,53,0.4), 0 0 0 0 rgba(198,241,53,0.3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fabPulse 3s infinite;
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(198,241,53,0.4), 0 0 0 0 rgba(198,241,53,0); }
  50%       { box-shadow: 0 4px 24px rgba(198,241,53,0.5), 0 0 0 12px rgba(198,241,53,0); }
}

.fab:hover {
  transform: scale(1.1) rotate(45deg);
  box-shadow: 0 8px 32px rgba(198,241,53,0.6);
}

.fab-plus { line-height: 1; transition: transform 0.2s; }

/* ===========================
   MODALS
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 481px) {
  .modal {
    max-width: 480px;
    position: relative;
    margin: auto;
  }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.modal-close:hover { border-color: var(--danger); color: var(--danger); }

.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.modal-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.modal-input, .food-textarea, .override-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.modal-input:focus, .food-textarea:focus, .override-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198,241,53,0.1);
}

/* Prevent iOS zoom on input focus */
.modal-input, .food-textarea, .override-input {
  font-size: 16px;
}

.food-textarea {
  resize: vertical;
  min-height: 90px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn-cancel {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.btn-save, .btn-ai {
  background: var(--accent);
  border: none;
  color: #0e0f11;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

.btn-ai {
  background: var(--bg3);
  border: 1px solid var(--accent3);
  color: var(--accent3);
}

.btn-save:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-ai:hover { background: rgba(53,212,255,0.1); }

.btn-save:disabled, .btn-ai:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Meal type selector */
.meal-type-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.meal-type-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.meal-type-btn.active[data-meal="desayuno"] { border-color: var(--desayuno); color: var(--desayuno); background: rgba(251,191,36,0.1); }
.meal-type-btn.active[data-meal="almuerzo"] { border-color: var(--almuerzo); color: var(--almuerzo); background: rgba(52,211,153,0.1); }
.meal-type-btn.active[data-meal="cena"]     { border-color: var(--cena);     color: var(--cena);     background: rgba(129,140,248,0.1); }
.meal-type-btn.active[data-meal="otros"]    { border-color: var(--otros);    color: var(--otros);    background: rgba(251,113,133,0.1); }

/* Add tabs */
.add-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}

.add-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.add-tab.active {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Photo drop */
.photo-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.photo-drop:hover { border-color: var(--accent); color: var(--text); }
.photo-drop.dragover { border-color: var(--accent); background: rgba(198,241,53,0.05); }

.photo-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.photo-drop p { font-size: 0.82rem; }

.photo-preview-wrap { margin-bottom: 10px; }

.photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.btn-remove-photo {
  background: none;
  border: none;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 6px;
}

/* AI Status */
.ai-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--accent3);
  font-family: var(--font-mono);
}

.ai-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent3);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* AI Result */
.ai-result {
  margin-top: 12px;
  background: var(--bg3);
  border: 1px solid var(--accent3);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(53,212,255,0.1);
  border: 1px solid var(--accent3);
  color: var(--accent3);
  padding: 3px 8px;
  border-radius: 100px;
}

.ai-kcal {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}

.ai-explanation {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.override-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.override-input {
  max-width: 140px;
}

/* ===========================
   HISTORY VIEW
   =========================== */
.history-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-day {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-day:hover { border-color: var(--accent); }

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

.history-day-date {
  font-weight: 700;
  font-size: 0.9rem;
}

.history-day-kcal {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
}

.history-day-bar-wrap {
  height: 6px;
  background: var(--bg2);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 6px;
}

.history-day-bar {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  transition: width 0.6s;
}

.history-day-bar.danger { background: linear-gradient(90deg, var(--accent2), var(--danger)); }

.history-day-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.history-entries {
  margin-top: 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.history-entries.open { display: flex; }

.history-entry-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.history-entry-kcal {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
  font-size: 0.8rem;
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 500px) {
  .header-inner { padding: 12px 14px; }
  .main { padding: 16px 14px; }
  /* Full-screen modal on mobile — prevents iOS zoom completely */
  .modal-overlay {
    align-items: stretch !important;
  }
  .modal, .modal.modal-add {
    padding: 20px !important;
    padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    position: relative !important;
    animation: fadeIn 0.2s ease !important;
  }
  .fab { bottom: 20px; right: 20px; width: 54px; height: 54px; }
  .meal-type-btn { font-size: 0.7rem; padding: 6px 10px; }
  .modal-actions { flex-direction: column; }
  .btn-save, .btn-ai { flex: none; width: 100%; }
  /* font-size 16px is mandatory — never override below this on mobile to prevent iOS zoom */
  .modal-input, .food-textarea, .override-input { font-size: 16px !important; }
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* iPhone 14 Pro Max (430px viewport) */
@media (width: 430px) {
  html {
    font-size: 15px;
  }
  
  body {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
  
  .header-inner {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  
  .main {
    padding: 20px 16px;
    gap: 24px;
  }
  
  .logo {
    font-size: 1.1rem;
  }
  
  .logo-icon {
    font-size: 1.3rem;
  }
  
  .nav-btn {
    font-size: 0.78rem;
    padding: 5px 14px;
  }
  
  .btn-settings {
    font-size: 0.7rem;
    padding: 6px 10px;
  }
  
  .summary-card {
    padding: 24px 20px;
  }
  
  .ring-wrap {
    width: 170px;
    height: 170px;
  }
  
  .ring-kcal {
    font-size: 2rem;
  }
  
  .summary-date {
    font-size: 1rem;
  }
  
  .summary-tope {
    font-size: 0.68rem;
  }
  
  .summary-remaining {
    font-size: 0.8rem;
  }
  
  .bars-section {
    padding: 20px;
  }
  
  .entries-section {
    padding: 20px;
  }
  
  .entry-item {
    padding: 11px 12px;
  }
  
  .entry-desc {
    font-size: 0.82rem;
  }
  
  .entry-kcal {
    font-size: 0.9rem;
  }
  
  .fab {
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 24px;
    width: 56px;
    height: 56px;
    font-size: 1.7rem;
  }
  
  .modal {
    padding: 24px 18px;
    border-radius: 20px;
  }
  
  .modal-title {
    font-size: 1.15rem;
  }
  
  .modal-input, .food-textarea, .override-input {
    padding: 11px 12px;
    /* font-size must stay at 16px minimum to prevent iOS auto-zoom — do NOT set below 16px */
    font-size: 16px !important;
  }
  
  .meal-type-btn {
    font-size: 0.72rem;
    padding: 6px 11px;
  }
  
  .food-textarea {
    min-height: 85px;
  }
  
  .photo-drop {
    padding: 24px;
  }
  
  .modal-actions {
    gap: 10px;
  }
  
  .btn-cancel, .btn-save, .btn-ai {
    padding: 9px 16px;
    font-size: 0.82rem;
  }
  
  .history-section {
    padding: 20px;
  }
  
  .history-day {
    padding: 14px;
  }
}

/* Safe area insets for notch (Dynamic Island) */
@supports (padding: max(0px)) {
  .header-inner {
    padding-left: max(16px, calc(14px + env(safe-area-inset-left, 0px)));
    padding-right: max(16px, calc(14px + env(safe-area-inset-right, 0px)));
  }
  
  .main {
    padding-left: max(16px, calc(14px + env(safe-area-inset-left, 0px)));
    padding-right: max(16px, calc(14px + env(safe-area-inset-right, 0px)));
  }
  
  .modal {
    padding-left: max(20px, calc(16px + env(safe-area-inset-left, 0px)));
    padding-right: max(20px, calc(16px + env(safe-area-inset-right, 0px)));
  }
}
