:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --border: #e6e1da;
  --text: #4a453f;
  --text-muted: #8a8378;
  --accent: #b98b73;

  /* tonos suaves para las 4 fases */
  --c-desayuno: #e7c9a9;
  --c-comida: #a9c1ab;
  --c-merienda: #c3b5d6;
  --c-cena: #9db4c4;

  --c-desayuno-bg: #f3e7da;
  --c-comida-bg: #e3ecE4;
  --c-merienda-bg: #ece6f2;
  --c-cena-bg: #e2eaf0;

  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 50, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #232120;
    --surface: #2c2a28;
    --border: #3a3733;
    --text: #ece7e0;
    --text-muted: #a89f93;

    /* versiones oscuras de los tintes por fase, para que el texto claro siga
       siendo legible encima (en claro son pasteles pensados para texto oscuro) */
    --c-desayuno-bg: #3a2f26;
    --c-comida-bg: #253028;
    --c-merienda-bg: #2e2836;
    --c-cena-bg: #212c33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 90px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

header.top h1 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

header.top .date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

nav.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

nav.tabs a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 10px;
  border-radius: 10px;
}

nav.tabs a.active {
  color: var(--accent);
  background: var(--c-desayuno-bg);
}

/* Anillo de progreso */
.ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.ring-center-text {
  font-size: 1.6rem;
  font-weight: 700;
}

.ring-center-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
}

.meal-section h2 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.entry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

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

.entry-row .name { font-weight: 500; }
.entry-row .meta { color: var(--text-muted); font-size: 0.78rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.small { padding: 6px 10px; font-size: 0.78rem; }
.btn.danger { background: #c98a7d; }

input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

label {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.field { margin-bottom: 12px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 80px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: var(--c-comida-bg);
  color: var(--text);
}

.empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.photo-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
}

.photo-drop img {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.toast.show { opacity: 0.92; }
