/* ============================================================
   GUIA GLUCEMICA PWA — Complete Stylesheet
   Dra. Elizabeth Villanueva · Nefróloga e Internista
   Mobile-first, elderly-friendly, Dominican patients
   ============================================================ */

/* ── Custom Properties ───────────────────────────────────── */
:root {
  /* Brand */
  --primary:          #0CB7B5;
  --primary-dark:     #09918F;
  --primary-light:    #E0F7F7;
  --accent:           #F36D44;
  --accent-dark:      #D45830;
  --accent-light:     #FEF0EB;

  /* IG Level Colors */
  --bajo:             #2ECC71;
  --bajo-bg:          #E8F8F0;
  --bajo-border:      #A9DFBF;
  --moderado:         #F39C12;
  --moderado-bg:      #FEF9E7;
  --moderado-border:  #F8D99B;
  --alto:             #E74C3C;
  --alto-bg:          #FDEDEC;
  --alto-border:      #F5B7B1;

  /* Neutral Palette */
  --bg:               #F4F7FA;
  --surface:          #FFFFFF;
  --border:           #E2E8F0;
  --border-strong:    #CBD5E1;
  --text:             #1A2332;
  --text-2:           #4A5568;
  --text-muted:       #718096;
  --text-inverse:     #FFFFFF;
  --overlay:          rgba(0, 0, 0, 0.52);

  /* Typography */
  --f-heading:        'Bebas Neue', 'Arial Narrow', Arial, sans-serif;
  --f-body:           'Abel', Helvetica, Arial, sans-serif;

  /* Font sizes — 18px minimum body */
  --fs-xs:            14px;
  --fs-sm:            16px;
  --fs-base:          18px;
  --fs-lg:            20px;
  --fs-xl:            24px;
  --fs-2xl:           28px;
  --fs-3xl:           34px;
  --fs-4xl:           44px;

  /* Spacing */
  --s1:   4px;
  --s2:   8px;
  --s3:   12px;
  --s4:   16px;
  --s5:   20px;
  --s6:   24px;
  --s8:   32px;
  --s10:  40px;
  --s12:  48px;

  /* Layout */
  --max-w:            480px;
  --header-h:         56px;
  --tabbar-h:         64px;
  --radius-sm:        8px;
  --radius:           10px;
  --radius-lg:        14px;
  --radius-xl:        20px;
  --radius-full:      9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-lg:  0 16px 40px rgba(0,0,0,0.14), 0 8px 16px rgba(0,0,0,0.07);
  --shadow-primary: 0 4px 16px rgba(12,183,181,0.28);
  --shadow-accent:  0 4px 16px rgba(243,109,68,0.28);

  /* Transitions */
  --t-fast:   150ms ease;
  --t-base:   220ms ease;
  --t-slow:   340ms ease;

  /* Safe areas — notch support */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}


/* ── Reset & Base ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--f-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--f-heading);
  line-height: 1.1;
  letter-spacing: 0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--f-body);
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: var(--f-body);
  font-size: var(--fs-base);
}

img {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

/* Accessibility: visible focus ring */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}


/* ── App Shell ───────────────────────────────────────────── */
/*
  .app wraps everything — max 480px, centered on desktop.
  On mobile it fills the full viewport width.
*/
.app {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--bg);
  /* Creates a stacking context so fixed children (header, tabbar)
     stay within the 480px column on desktop */
}

/* Tablet/Desktop: wider layout, no phone-column feel */
@media (min-width: 768px) {
  .app {
    max-width: 100%;
  }
}


/* ── Header ──────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);  /* overridden at 768px */
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-inline: var(--s4);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(12,183,181,0.32);
}

.header__title {
  font-family: var(--f-heading);
  font-size: var(--fs-xl);
  letter-spacing: 0.07em;
  line-height: 1;
}

.header__subtitle {
  font-family: var(--f-body);
  font-size: var(--fs-xs);
  opacity: 0.82;
  letter-spacing: 0.04em;
  margin-top: 1px;
}


/* ── Tab Bar ─────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.07);
}

/* Each tab button */
.tabbar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--s2) var(--s1);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  min-height: 48px;   /* touch target */
  min-width: 48px;
  position: relative;
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

/* Active indicator bar at top */
.tabbar__btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--primary);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.tabbar__btn.active,
.tabbar__btn[aria-current="page"] {
  color: var(--primary);
}

.tabbar__btn.active::before,
.tabbar__btn[aria-current="page"]::before {
  opacity: 1;
}

.tabbar__btn:active {
  background: var(--primary-light);
  border-radius: var(--radius);
}

/* Icon inside tab button */
.tabbar__btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* Label inside tab button */
.tabbar__btn span {
  font-size: 10px;
  font-family: var(--f-body);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}


/* ── Screens ─────────────────────────────────────────────── */
/*
  Screens sit in the scrollable area between header and tabbar.
  JS toggles [hidden] to show/hide; we use display:block when visible.
*/
.screen {
  display: block;
  position: absolute;
  top: calc(var(--header-h) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg);
  padding: var(--s4);
  padding-bottom: var(--s8);
}

.screen[hidden] {
  display: none;
}

/* Slide-in animation when screen becomes visible */
.screen:not([hidden]) {
  animation: screenIn var(--t-base) ease both;
}

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

/* Screen section headings (h2 inside screens) */
.screen__title {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text);
  margin-bottom: var(--s4);
  letter-spacing: 0.03em;
}

.section-title {
  font-family: var(--f-heading);
  font-size: var(--fs-xl);
  color: var(--text);
  margin-bottom: var(--s4);
  letter-spacing: 0.03em;
}


/* ── Search Bar ──────────────────────────────────────────── */
/*
  HTML structure:
    .search-bar
      svg.search-bar__icon
      input#searchInput[type=search]
      button#searchClear.search-bar__clear
*/
.search-bar {
  position: relative;
  margin-bottom: var(--s4);
}

/* The native <input type=search> inside .search-bar */
.search-bar input[type="search"] {
  width: 100%;
  height: 52px;
  padding: 0 var(--s10) 0 52px;  /* room for icon left, clear btn right */
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  color: var(--text);
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

/* Remove native search cancel button */
.search-bar input[type="search"]::-webkit-search-cancel-button,
.search-bar input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

.search-bar input[type="search"]::placeholder {
  color: var(--text-muted);
}

.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(12,183,181,0.14);
}

/* Magnifier icon positioned left */
.search-bar__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--t-fast);
  stroke: currentColor;
}

.search-bar:focus-within .search-bar__icon {
  color: var(--primary);
}

/* Clear (X) button positioned right */
.search-bar__clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background var(--t-fast);
}

/* JS sets hidden attribute; when visible: */
.search-bar__clear:not([hidden]) {
  display: flex;
}

.search-bar__clear svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.search-bar__clear:active {
  background: var(--border-strong);
}


/* ── Category Pills ──────────────────────────────────────── */
/*
  Horizontal scrollable row of filter pill buttons.
  Pills generated by JS — they get .active class when selected.
*/
.category-pills {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  padding: var(--s1) 0 var(--s3);
  margin-bottom: var(--s3);
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

/* Individual pill — JS generates these as <button> elements */
.category-pills button,
.pill {
  flex-shrink: 0;
  height: 40px;
  min-height: 40px;
  padding: 0 var(--s4);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-family: var(--f-body);
  color: var(--text-2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  cursor: pointer;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast);
  scroll-snap-align: start;
}

.category-pills button:active,
.pill:active {
  transform: scale(0.95);
}

.category-pills button.active,
.category-pills button[aria-pressed="true"],
.pill.active,
.pill[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-primary);
}


/* ── Level Filter Buttons ────────────────────────────────── */
/*
  3 buttons: Bajo / Moderado / Alto
  Each has its color scheme; active = filled, inactive = tinted outline.
*/
.level-filters {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.level-btn {
  flex: 1;
  height: 48px;   /* minimum touch target */
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-size: var(--fs-sm);
  font-family: var(--f-body);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  cursor: pointer;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast);
}

.level-btn:active {
  transform: scale(0.95);
}

/* Bajo — green */
.level-btn--bajo {
  background: var(--bajo-bg);
  border-color: var(--bajo-border);
  color: #1e9e56;   /* darker green for contrast on white */
}

.level-btn--bajo[aria-pressed="true"],
.level-btn--bajo.active {
  background: var(--bajo);
  border-color: var(--bajo);
  color: white;
}

/* Moderado — amber */
.level-btn--moderado {
  background: var(--moderado-bg);
  border-color: var(--moderado-border);
  color: #c07a07;
}

.level-btn--moderado[aria-pressed="true"],
.level-btn--moderado.active {
  background: var(--moderado);
  border-color: var(--moderado);
  color: white;
}

/* Alto — red */
.level-btn--alto {
  background: var(--alto-bg);
  border-color: var(--alto-border);
  color: #b83229;
}

.level-btn--alto[aria-pressed="true"],
.level-btn--alto.active {
  background: var(--alto);
  border-color: var(--alto);
  color: white;
}


/* ── Results Count ───────────────────────────────────────── */
.results-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: var(--s3);
  padding-inline: var(--s1);
  min-height: 20px; /* prevents layout jump */
}


/* ── Food List & Cards ───────────────────────────────────── */
.food-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/*
  Food card — generated by JS as:
    .food-card[role=listitem]
      .food-card__body
        .food-card__name
        .food-card__category
      .ig-badge.ig-badge--{level}
        span (IG number)
      button.heart-btn
*/
.food-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s3) var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s2);
  transition:
    box-shadow var(--t-fast),
    border-color var(--t-fast),
    transform var(--t-fast);
  box-shadow: var(--shadow-sm);
  animation: slideUp var(--t-base) ease both;
}

.food-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.food-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow);
}

.food-card__body {
  flex: 1;
  min-width: 0;
}

.food-card__name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: var(--s1);
  /* prevent overflow on very long names */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-card__category {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Staggered card entrance animation */
.food-list .food-card:nth-child(1)  { animation-delay:   0ms; }
.food-list .food-card:nth-child(2)  { animation-delay:  40ms; }
.food-list .food-card:nth-child(3)  { animation-delay:  80ms; }
.food-list .food-card:nth-child(4)  { animation-delay: 120ms; }
.food-list .food-card:nth-child(5)  { animation-delay: 160ms; }
.food-list .food-card:nth-child(n+6){ animation-delay: 200ms; }


/* ── IG Badge ────────────────────────────────────────────── */
/*
  Colored circle showing the IG number.
  Sizes: default (48px for cards), --lg (72px for detail view)
  Colors: --bajo, --moderado, --alto
*/
.ig-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--f-heading);
  flex-shrink: 0;
  border: 2.5px solid currentColor;
  line-height: 1;
}

.ig-badge span {
  font-size: 18px;
  letter-spacing: -0.02em;
  font-weight: 900;
  line-height: 1;
}

/* Small variant (40px) */
.ig-badge--sm {
  width: 40px;
  height: 40px;
}

.ig-badge--sm span {
  font-size: 15px;
}

/* Large variant (72px) for detail overlay */
.ig-badge--lg {
  width: 72px;
  height: 72px;
}

.ig-badge--lg span {
  font-size: 28px;
}

/* Color themes */
.ig-badge--bajo {
  color: var(--bajo);
  background: var(--bajo-bg);
  border-color: var(--bajo);
}

.ig-badge--moderado {
  color: var(--moderado);
  background: var(--moderado-bg);
  border-color: var(--moderado);
}

.ig-badge--alto {
  color: var(--alto);
  background: var(--alto-bg);
  border-color: var(--alto);
}


/* ── Heart / Favorite Button ─────────────────────────────── */
.heart-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border-strong);
  background: var(--bg);
  flex-shrink: 0;
  transition:
    color var(--t-fast),
    background var(--t-fast),
    transform var(--t-base);
}

.heart-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  transition: fill var(--t-fast);
}

.heart-btn:active {
  transform: scale(1.3);
}

.heart-btn.is-favorited {
  color: var(--accent);
}

.heart-btn.is-favorited svg {
  fill: var(--accent);
  stroke: var(--accent);
}

@keyframes heartPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.45); }
  100% { transform: scale(1); }
}

.heart-btn.is-animating {
  animation: heartPop 300ms ease both;
}

/* "Quitar" button in Favorites list (visible without swipe gesture) */
.remove-btn {
  height: 36px;
  padding: 0 var(--s3);
  border: 1.5px solid var(--alto-border);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-family: var(--f-body);
  font-weight: 600;
  color: var(--alto);
  background: var(--alto-bg);
  flex-shrink: 0;
  cursor: pointer;
  transition:
    background var(--t-fast),
    transform var(--t-fast);
}

.remove-btn:active {
  background: var(--alto);
  color: white;
  transform: scale(0.95);
}


/* ── Food Detail Overlay ─────────────────────────────────── */
/*
  HTML structure:
    #foodDetail.food-detail[hidden]
      .food-detail__backdrop
      .food-detail__sheet
        button.food-detail__close
        #foodDetailContent
*/

/* Outer wrapper — full-screen overlay */
.food-detail {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-slow);
}

.food-detail:not([hidden]) {
  pointer-events: all;
  opacity: 1;
}

/* Semi-transparent backdrop */
.food-detail__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  cursor: pointer;
}

/* Slide-up sheet — sits at bottom, max 72% height */
.food-detail__sheet {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: var(--max-w);
  max-height: 72dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: calc(var(--s6) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform var(--t-slow) cubic-bezier(0.34, 1.06, 0.64, 1);
  box-shadow: var(--shadow-lg);
}

/* Drag handle */
.food-detail__sheet::before {
  content: '';
  display: block;
  width: 44px;
  height: 5px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: var(--s3) auto var(--s2);
  flex-shrink: 0;
}

.food-detail:not([hidden]) .food-detail__sheet {
  transform: translateY(0);
}

/* Close X button — top right */
.food-detail__close {
  position: absolute;
  top: var(--s3);
  right: var(--s4);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  z-index: 1;
  transition: background var(--t-fast);
}

.food-detail__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.food-detail__close:active {
  background: var(--border);
}

/* Scrollable content area */
#foodDetailContent {
  overflow-y: auto;
  flex: 1;
  padding: var(--s2) var(--s5) var(--s5);
  -webkit-overflow-scrolling: touch;
}

/* Elements JS injects into #foodDetailContent */
.detail-title {
  font-family: var(--f-heading);
  font-size: var(--fs-3xl);
  color: var(--text);
  line-height: 1.05;
  margin-bottom: var(--s4);
  padding-right: 48px; /* avoid overlap with close button */
}

.detail-ig-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--s5);
}

.detail-ig-row--bajo     { background: var(--bajo-bg); }
.detail-ig-row--moderado { background: var(--moderado-bg); }
.detail-ig-row--alto     { background: var(--alto-bg); }

.detail-ig-text h3 {
  font-family: var(--f-heading);
  font-size: var(--fs-xl);
  margin-bottom: 2px;
}

.detail-ig-text p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.5;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

.info-cell {
  background: var(--bg);
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
}

.info-cell__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.info-cell__value {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text);
  line-height: 1;
}

.info-cell__unit {
  font-family: var(--f-body);
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.detail-note {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--s4);
  margin-bottom: var(--s5);
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.65;
}

/* "Calcular" CTA inside detail */
.detail-calc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  height: 52px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-family: var(--f-body);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  transition: filter var(--t-fast), transform var(--t-fast);
}

.detail-calc-btn:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}


/* ── Calculator Screen ───────────────────────────────────── */
.calc-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.65;
}

.calc-info p + p {
  margin-top: var(--s3);
}

.calc-formula {
  display: block;
  margin-top: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--primary-dark);
  font-weight: 600;
  text-align: center;
}

.calc-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* Label above each field */
.calc-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s2);
}

/* Food picker: search input + dropdown */
.calc-food-picker {
  position: relative;
}

.calc-food-picker input[type="search"] {
  width: 100%;
  height: 52px;
  padding: 0 var(--s4);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.calc-food-picker input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.calc-food-picker input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(12,183,181,0.14);
}

/* Selected food chip */
.calc-food-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--primary-dark);
  font-weight: 600;
}

.calc-food-selected[hidden] {
  display: none;
}

/* Dropdown list for food search */
.calc-food-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
}

.calc-food-dropdown[hidden] {
  display: none;
}

/* Each dropdown item — JS generates these */
.calc-food-dropdown [role="option"] {
  padding: var(--s3) var(--s4);
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--text);
  transition: background var(--t-fast);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.calc-food-dropdown [role="option"]:hover,
.calc-food-dropdown [role="option"]:focus {
  background: var(--primary-light);
  outline: none;
}

.calc-food-dropdown [role="option"] + [role="option"] {
  border-top: 1px solid var(--border);
}

/* Number input row: input + unit label */
.calc-input-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.calc-input-row input[type="number"] {
  flex: 1;
  height: 52px;
  padding: 0 var(--s4);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-xl);
  font-family: var(--f-heading);
  color: var(--text);
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.calc-input-row input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(12,183,181,0.14);
}

/* Unit label ("g") */
.calc-unit {
  font-size: var(--fs-base);
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* Slider row: range input + number input + unit */
.calc-slider-row {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* Slider value display below the slider */
.calc-slider-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
}

.calc-slider-value input[type="number"] {
  width: 100px;
  height: 52px;
  padding: 0 var(--s3);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-xl);
  font-family: var(--f-heading);
  color: var(--text);
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.calc-slider-value input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(12,183,181,0.14);
}

/* Range Slider — large 32px thumb for elderly users */
.calc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--border);
  cursor: pointer;
  outline: none;
}

.calc-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: var(--radius-full);
}

.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(12,183,181,0.40);
  cursor: grab;
  margin-top: -11px;  /* vertically center on track */
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.calc-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(12,183,181,0.50);
}

.calc-slider::-moz-range-track {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--border);
}

.calc-slider::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(12,183,181,0.40);
  cursor: grab;
  transition: transform var(--t-fast);
}

.calc-slider::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.calc-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(12,183,181,0.30), 0 2px 8px rgba(12,183,181,0.40);
}

/* Glycemic Load Result Circle */
.calc-result {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s6) var(--s5);
  text-align: center;
  margin-bottom: var(--s5);
  transition:
    background var(--t-slow),
    border-color var(--t-slow);
}

.calc-result--bajo {
  background: var(--bajo-bg);
  border: 2px solid var(--bajo-border);
}

.calc-result--moderado {
  background: var(--moderado-bg);
  border: 2px solid var(--moderado-border);
}

.calc-result--alto {
  background: var(--alto-bg);
  border: 2px solid var(--alto-border);
}

.calc-result__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--s2);
}

.calc-result__value {
  font-family: var(--f-heading);
  font-size: 72px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text-muted);
  margin-bottom: var(--s2);
  transition: color var(--t-slow);
}

.calc-result--bajo     .calc-result__value { color: var(--bajo); }
.calc-result--moderado .calc-result__value { color: var(--moderado); }
.calc-result--alto     .calc-result__value { color: var(--alto); }

.calc-result__level {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text-muted);
  transition: color var(--t-slow);
}

.calc-result--bajo     .calc-result__level { color: var(--bajo); }
.calc-result--moderado .calc-result__level { color: var(--moderado); }
.calc-result--alto     .calc-result__level { color: var(--alto); }

/* Scale reference */
.calc-scale {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
  margin-bottom: var(--s6);
}

.calc-scale__item {
  padding: var(--s3);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

.calc-scale__item--bajo {
  background: var(--bajo-bg);
  color: #1e9e56;
  border: 1px solid var(--bajo-border);
}

.calc-scale__item--moderado {
  background: var(--moderado-bg);
  color: #c07a07;
  border: 1px solid var(--moderado-border);
}

.calc-scale__item--alto {
  background: var(--alto-bg);
  color: #b83229;
  border: 1px solid var(--alto-border);
}


/* ── Favorites Screen ────────────────────────────────────── */
.favorites-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s12) var(--s6);
  text-align: center;
  min-height: 360px;
}

.favorites-empty svg {
  width: 120px;
  height: 120px;
  margin-bottom: var(--s5);
}

.favorites-empty__text {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text);
  margin-bottom: var(--s2);
}

.favorites-empty__hint {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.65;
  max-width: 280px;
  margin-bottom: var(--s6);
}


/* ── Tips Screen ─────────────────────────────────────────── */

/* Plate Rule visual */
.plate-rule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.plate-rule__svg {
  width: 240px;
  height: 240px;
  max-width: 100%;
  margin: 0 auto var(--s4);
  display: block;
}

.plate-rule__desc {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.55;
  max-width: 320px;
  margin: 0 auto;
}

/* Tips accordion list */
.tips-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-bottom: var(--s6);
}

/* Individual accordion tip card — generated by JS */
.tip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast);
}

.tip-card.is-open {
  border-color: var(--primary);
}

/* Toggle button (trigger) — min 48px height */
.tip-card__toggle {
  width: 100%;
  padding: var(--s4) var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s3);
  text-align: left;
  cursor: pointer;
  min-height: 64px;
  background: none;
  border: none;
  font-family: var(--f-body);
  transition: background var(--t-fast);
}

.tip-card__toggle:active {
  background: var(--bg);
}

/* Icon square */
.tip-card__icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}

.tip-card.is-open .tip-card__icon {
  background: var(--primary);
  color: white;
}

/* Title text */
.tip-card__title {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

/* Chevron arrow */
.tip-card__chevron {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  stroke: currentColor;
  flex-shrink: 0;
  transition: transform var(--t-base), color var(--t-fast);
}

.tip-card.is-open .tip-card__chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

/* Collapsible body */
.tip-card__body {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--t-slow) ease-out;
}

.tip-card.is-open .tip-card__body {
  max-height: 800px;
  transition: max-height var(--t-slow) ease-in;
}

.tip-card__content {
  padding: 0 var(--s5) var(--s5);
  padding-left: calc(var(--s5) + 44px + var(--s3));
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.7;
}

.tip-card__content p + p {
  margin-top: var(--s3);
}

.tip-card__content strong {
  color: var(--text);
  font-weight: 600;
}

.tip-card__content ul {
  list-style: disc;
  padding-left: var(--s5);
  margin-top: var(--s2);
}

.tip-card__content li {
  margin-bottom: var(--s1);
}

/* Typical dishes section */
.typical-dishes {
  margin-top: var(--s4);
}

.typical-dishes .section-title {
  margin-bottom: var(--s4);
}

/* Dish entry — generated by JS */
.dish-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s4) var(--s5);
  margin-bottom: var(--s3);
  box-shadow: var(--shadow-sm);
}

.dish-card__name {
  font-family: var(--f-heading);
  font-size: var(--fs-xl);
  color: var(--text);
  margin-bottom: var(--s2);
}

.dish-card__desc {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.6;
}

.dish-card__tip {
  margin-top: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--primary-dark);
  font-weight: 600;
}


/* ── Doctor Screen ───────────────────────────────────────── */
.doctor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--s6) var(--s5) var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow);
  text-align: center;
}

/* Avatar circle */
.doctor-card__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid var(--primary-light);
  overflow: hidden;
  margin: 0 auto var(--s4);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.doctor-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.doctor-card__name {
  font-family: var(--f-heading);
  font-size: var(--fs-3xl);
  color: var(--text);
  margin-bottom: var(--s1);
}

.doctor-card__specialty {
  font-size: var(--fs-sm);
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--s4);
  line-height: 1.5;
}

.doctor-card__text {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.7;
  max-width: 380px;
  margin-inline: auto;
}

/* Contact buttons container */
.doctor-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

/* Base contact button style — 52px tall, full width, pill shape */
.contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  height: 56px;   /* generous touch target for elderly */
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-family: var(--f-body);
  font-weight: 600;
  width: 100%;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition:
    transform var(--t-fast),
    filter var(--t-fast);
}

.contact-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.contact-btn:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}

/* Phone — teal */
.contact-btn--phone {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

/* WhatsApp — brand green */
.contact-btn--whatsapp {
  background: #25D366;
  color: white;
  box-shadow: 0 4px 16px rgba(37,211,102,0.32);
}

/* Cita (appointment) — accent orange */
.contact-btn--cita {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}

/* Web — outlined, neutral */
.contact-btn--web {
  background: transparent;
  color: var(--text-2);
  border: 2px solid var(--border-strong);
}

.contact-btn--web:hover {
  background: var(--bg);
}

/* Credits / footer note */
.doctor-credits {
  padding: var(--s4) var(--s5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.65;
  text-align: center;
}

.doctor-credits em {
  font-style: italic;
}

.doctor-credits__version {
  margin-top: var(--s2);
  color: var(--border-strong);
  font-size: 12px;
}


/* ── Register Banner ─────────────────────────────────────── */
/*
  Fixed above tabbar. Slides up from below when shown.
  HTML structure:
    #registerBanner.register-banner[hidden]
      p.register-banner__text
      .register-banner__actions
        button.btn.btn--teal.btn--sm
        button.btn.btn--ghost.btn--sm
*/
.register-banner {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s3));
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: calc(100% - var(--s8));
  max-width: calc(var(--max-w) - var(--s8));
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: var(--s4) var(--s5);
  z-index: 90;
  box-shadow: var(--shadow-md);
  transition: transform var(--t-slow), opacity var(--t-slow);
}

.register-banner[hidden] {
  display: none;
}

.register-banner.is-dismissed {
  transform: translateX(-50%) translateY(130%);
  opacity: 0;
  pointer-events: none;
}

.register-banner__text {
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: var(--s3);
  line-height: 1.4;
}

.register-banner__actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

/* Override btn colors for dark background context */
.register-banner .btn--teal {
  background: white;
  color: var(--primary-dark);
  box-shadow: none;
}

.register-banner .btn--teal:hover {
  background: var(--primary-light);
}

.register-banner .btn--ghost {
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.5);
  background: transparent;
}

.register-banner .btn--ghost:hover {
  background: rgba(255,255,255,0.15);
}


/* ── Register Modal ──────────────────────────────────────── */
/*
  HTML structure:
    #registerModal.register-modal[hidden]
      .register-modal__backdrop
      .register-modal__content
        h3#registerModalTitle
        p
        form#registerForm
          label + input (regName)
          label + input (regPhone)
          button[type=submit]
        button.register-modal__close
*/
.register-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base);
}

.register-modal:not([hidden]) {
  pointer-events: all;
  opacity: 1;
}

/* Semi-transparent backdrop */
.register-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  cursor: pointer;
}

/* Centered modal card */
.register-modal__content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  padding: var(--s6);
  box-shadow: var(--shadow-lg);
  transform: scale(0.92) translateY(12px);
  transition: transform var(--t-slow) cubic-bezier(0.34, 1.06, 0.64, 1);
}

.register-modal:not([hidden]) .register-modal__content {
  transform: scale(1) translateY(0);
}

/* Title */
.register-modal__content h3 {
  font-family: var(--f-heading);
  font-size: var(--fs-3xl);
  color: var(--text);
  margin-bottom: var(--s2);
}

/* Subtitle paragraph */
.register-modal__content > p {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: var(--s5);
}

/* Form labels */
.register-modal__content label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s2);
  margin-top: var(--s4);
}

.register-modal__content label:first-of-type {
  margin-top: 0;
}

/* Form inputs */
.register-modal__content input[type="text"],
.register-modal__content input[type="tel"] {
  width: 100%;
  height: 52px;
  padding: 0 var(--s4);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
  margin-bottom: var(--s4);
}

.register-modal__content input::placeholder {
  color: var(--text-muted);
}

.register-modal__content input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(12,183,181,0.14);
  background: var(--surface);
}

/* Close text button at the bottom */
.register-modal__close {
  display: block;
  width: 100%;
  margin-top: var(--s3);
  padding: var(--s3);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--f-body);
  transition: color var(--t-fast);
}

.register-modal__close:hover {
  color: var(--text-2);
}


/* ── Generic Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 48px;
  padding: 0 var(--s6);
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-family: var(--f-body);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform var(--t-fast),
    filter var(--t-fast),
    background var(--t-fast),
    border-color var(--t-fast);
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn--teal {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}

.btn--teal:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn--orange {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}

.btn--orange:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn--ghost:hover {
  background: var(--primary-light);
}

.btn--sm {
  height: 40px;
  padding: 0 var(--s4);
  font-size: var(--fs-sm);
}

.btn--full {
  width: 100%;
}


/* ── Empty States ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s10) var(--s6);
  text-align: center;
  min-height: 280px;
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: var(--s5);
  color: var(--border-strong);
}

.empty-state__title {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text);
  margin-bottom: var(--s2);
}

.empty-state__text {
  font-size: var(--fs-base);
  color: var(--text-2);
  line-height: 1.65;
  max-width: 260px;
  margin-bottom: var(--s5);
}


/* ── Skeleton Loading ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border)    25%,
    var(--bg)        50%,
    var(--border)    75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--text {
  height: 18px;
  margin-bottom: var(--s2);
}

.skeleton--card {
  height: 82px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--s3);
}


/* ── Toast Notification ──────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + var(--s3));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: calc(var(--max-w) - var(--s8));
  width: max-content;
  background: var(--text);
  color: white;
  border-radius: var(--radius-full);
  padding: var(--s3) var(--s5);
  font-size: var(--fs-sm);
  font-weight: 600;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--t-base),
    transform var(--t-base);
  display: flex;
  align-items: center;
  gap: var(--s2);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

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

.toast--success { background: var(--bajo); }
.toast--error   { background: var(--alto); }
.toast--info    { background: var(--primary); }


/* ── IG Scale Bar ────────────────────────────────────────── */
/* Gradient bar used in detail/info views */
.ig-scale-bar {
  height: 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--bajo) 0%,
    var(--moderado) 50%,
    var(--alto) 100%
  );
  position: relative;
  margin-block: var(--s3);
}

.ig-scale-bar__marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  background: white;
  border: 3px solid var(--text);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: left var(--t-slow);
}

.ig-scale-bar__labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--s1);
}


/* ── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s4) 0;
}


/* ── Chip / Tag ──────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 var(--s3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: nowrap;
}

.chip--teal {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.chip--bajo     { background: var(--bajo-bg);    border-color: var(--bajo-border);    color: #1e9e56; }
.chip--moderado { background: var(--moderado-bg); border-color: var(--moderado-border); color: #c07a07; }
.chip--alto     { background: var(--alto-bg);    border-color: var(--alto-border);    color: #b83229; }


/* ── Animations (shared keyframes) ──────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes pulseOpacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

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

.animate-fade-in  { animation: fadeIn var(--t-base) both; }
.animate-slide-up { animation: slideUp var(--t-base) both; }
.animate-pulse    { animation: pulseOpacity 2s infinite; }
.animate-spin     { animation: spin 700ms linear infinite; }


/* ── Scroll helpers ──────────────────────────────────────── */
.scroll-x {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scroll-x::-webkit-scrollbar { display: none; }


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

/* JS uses this to show/hide elements alongside [hidden] */
.is-hidden { display: none !important; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-primary   { color: var(--primary); }
.text-accent    { color: var(--accent); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-2); }
.font-heading   { font-family: var(--f-heading); }

.mt-auto { margin-top: auto; }
.mb-4    { margin-bottom: var(--s4); }
.mb-6    { margin-bottom: var(--s6); }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1        { flex: 1; }
.gap-2         { gap: var(--s2); }
.gap-3         { gap: var(--s3); }
.gap-4         { gap: var(--s4); }


/* ── Desktop/Tablet Responsive (≥ 768px) ────────────────── */
@media (min-width: 768px) {
  /* Header stretches full width */
  .header {
    max-width: 100%;
    left: 0;
    transform: none;
    width: 100%;
  }

  .header__title {
    font-size: var(--fs-2xl);
  }

  /* Tabbar stretches full width */
  .tabbar {
    max-width: 100%;
    left: 0;
    transform: none;
    width: 100%;
  }

  .tabbar__btn {
    flex-direction: row;
    gap: var(--s2);
  }

  .tabbar__btn span {
    font-size: var(--fs-sm);
  }

  /* Screens get more breathing room */
  .screen {
    padding: var(--s6) var(--s8);
    padding-bottom: var(--s10);
  }

  /* Food list: 2-column grid */
  .food-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s4);
  }

  /* Category pills row doesn't need scroll on wider screens */
  .category-pills {
    flex-wrap: wrap;
    gap: var(--s2);
    overflow-x: visible;
  }

  /* Level filter row can sit inline */
  .level-filters {
    flex-wrap: wrap;
  }

  /* Search bar wider */
  .search-bar input[type="search"] {
    font-size: var(--fs-lg);
    height: 56px;
  }

  /* Food detail sheet wider + centered */
  .food-detail__sheet {
    max-width: 600px;
    max-height: 80dvh;
    border-radius: var(--radius-xl);
    margin-bottom: var(--s8);
  }

  /* Calculator: constrain width on desktop for readability */
  .calc-form {
    max-width: 600px;
  }

  .calc-info {
    max-width: 700px;
  }

  .calc-result {
    max-width: 600px;
  }

  .calc-scale {
    max-width: 600px;
  }

  /* Doctor card: horizontal layout */
  .doctor-card {
    flex-direction: row;
    text-align: left;
    gap: var(--s6);
    align-items: center;
  }

  .doctor-card__avatar {
    flex-shrink: 0;
  }

  .doctor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s3);
  }

  /* Tips: 2-column grid */
  .tips-section .tip-card,
  .tips-list {
    max-width: 100%;
  }

  /* Typical dishes: 2 columns */
  .typical-dishes > div {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s3);
  }

  /* Register banner centered */
  .register-banner {
    max-width: 600px;
  }

  /* Register modal content wider */
  .register-modal__content {
    max-width: 500px;
  }

  /* Plate rule SVG can be bigger */
  .plate-rule__svg {
    max-width: 360px;
  }

  /* Favorites list also grid */
  #favoritesList .food-list,
  .favorites-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s4);
  }
}

/* ── Large Desktop (≥ 1200px) ────────────────────────────── */
@media (min-width: 1200px) {
  /* Food list: 3-column grid */
  .food-list {
    grid-template-columns: repeat(3, 1fr);
  }

  #favoritesList .food-list,
  .favorites-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .typical-dishes > div {
    grid-template-columns: repeat(3, 1fr);
  }

  .doctor-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}


/* ── High Contrast ───────────────────────────────────────── */
@media (prefers-contrast: high) {
  :root {
    --border:        #94A3B8;
    --border-strong: #475569;
    --text-muted:    #475569;
  }

  .food-card    { border-width: 2px; }
  .level-btn    { border-width: 2px; }
  .search-bar input[type="search"] { border-width: 2px; }
}


/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  /* Keep accordion max-height transition disabled for a11y */
  .tip-card__body {
    transition: none !important;
  }
}


/* ── Print ───────────────────────────────────────────────── */
/* ── JS-generated class mappings ──────────────────────────── */
/* food-card structure from ui.js renderFoodCard() */
.food-card__main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-width: 0;
  cursor: pointer;
}

.food-card__info {
  flex: 1;
  min-width: 0;
}

.food-card__info .food-card__name {
  display: block;
}

.food-card__info .food-card__category {
  display: block;
}

.food-card__actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.food-card__fav {
  background: none;
  border: none;
  padding: var(--s2);
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--t-fast), transform var(--t-fast);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.food-card__fav svg {
  width: 24px;
  height: 24px;
}

.food-card__fav.is-active {
  color: var(--alto);
}

.food-card__fav:hover {
  color: var(--alto);
  background: var(--alto-bg);
}

.food-card__remove {
  background: var(--alto-bg);
  color: var(--alto);
  border: 1px solid var(--alto-border);
  border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3);
  font-family: var(--f-body);
  font-size: var(--fs-sm);
  cursor: pointer;
  min-height: 40px;
  transition: background var(--t-fast);
}

.food-card__remove:hover {
  background: var(--alto);
  color: white;
}

/* Calculator food picker options */
.calc-food-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--f-body);
  font-size: var(--fs-base);
  text-align: left;
  color: var(--text);
}

.calc-food-option:hover,
.calc-food-option:focus {
  background: var(--primary-light);
}

.calc-food-option:last-child {
  border-bottom: none;
}

.calc-food-option__name {
  flex: 1;
  min-width: 0;
}

.calc-food-selected__name {
  font-weight: 600;
  flex: 1;
}

.calc-food-selected__clear {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.calc-food-selected__clear:hover {
  background: var(--bg);
  color: var(--alto);
}

/* Food detail overlay content (generated by ui.js showDetail()) */
.detail__header {
  margin-bottom: var(--s5);
}

.detail__name {
  font-family: var(--f-heading);
  font-size: var(--fs-2xl);
  color: var(--text);
  margin-bottom: var(--s1);
}

.detail__category {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.detail__ig-section {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s5);
  padding: var(--s4);
  background: var(--bg);
  border-radius: var(--radius);
}

.detail__ig-label {
  display: flex;
  flex-direction: column;
}

.detail__ig-text {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.detail__ig-level {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.detail__ig-level--bajo { color: var(--bajo); }
.detail__ig-level--moderado { color: var(--moderado); }
.detail__ig-level--alto { color: var(--alto); }

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

.detail__label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.detail__value {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
}

.detail__notes {
  font-size: var(--fs-sm);
  color: var(--text-2);
  background: var(--bg);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--s5);
  line-height: 1.5;
}

.detail__actions {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-top: var(--s5);
}

/* Tip card header (generated by ui.js renderTips()) */
.tip-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: var(--s4);
  cursor: pointer;
  text-align: left;
  font-family: var(--f-body);
  font-size: var(--fs-base);
  color: var(--text);
  min-height: 56px;
}

.tip-card__header:hover {
  background: var(--bg);
}

.tip-card__header[aria-expanded="true"] .tip-card__chevron {
  transform: rotate(180deg);
}

.tip-card__chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--t-base);
}

.tip-card__title {
  flex: 1;
  font-weight: 600;
}

.tip-card__body {
  padding: 0 var(--s4) var(--s4);
}

.tip-card__body p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.6;
}

/* Dish card notes */
.dish-card__info {
  flex: 1;
  min-width: 0;
}

.dish-card__notes {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--s1);
  line-height: 1.4;
}

/* Outline button variant */
.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn--outline:hover {
  background: var(--primary-light);
}

@media print {
  .header,
  .tabbar,
  .register-banner,
  .register-modal,
  .food-detail {
    display: none !important;
  }

  .screen[hidden] {
    display: block !important;
  }

  .screen {
    position: static !important;
    overflow: visible !important;
    height: auto !important;
  }
}
