:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --text: #16181a;
  --muted: #7a7e83;
  --line: #e7e7e2;
  --dot: #d9dad5;
  --accent: #1f9d61;
  --accent-soft: #e4f4ea;
  --danger: #c2413b;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1110;
    --card: #181b1a;
    --text: #eef0ee;
    --muted: #8b918e;
    --line: #262a28;
    --dot: #343936;
    --accent: #3cc583;
    --accent-soft: #17291f;
    --danger: #ef6b64;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 28px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 32px)
    calc(env(safe-area-inset-left) + 16px);
}

/* Resumen */

.resumen {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 4px 4px 24px;
}

.resumen-texto { flex: 1; min-width: 0; }

.fecha {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 14px;
}

h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.conteo {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}
.conteo strong { color: var(--text); font-weight: 600; }

.proteina-etiqueta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.proteina-etiqueta strong { color: var(--text); font-weight: 600; }

.barra {
  height: 6px;
  border-radius: 99px;
  background: var(--dot);
  overflow: hidden;
}
.barra-relleno {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.anillo-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}
.anillo { width: 100%; height: 100%; transform: rotate(-90deg); }
.anillo circle { fill: none; stroke-width: 7; }
.anillo-fondo { stroke: var(--dot); }
.anillo-valor {
  stroke: var(--accent);
  stroke-linecap: round;
  /* 2π·38 */
  stroke-dasharray: 238.76;
  stroke-dashoffset: 238.76;
  transition: stroke-dashoffset 0.4s ease, opacity 0.2s ease;
}
.anillo-valor.vacio { opacity: 0;
}
.porcentaje {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Tarjetas */

.comidas { display: grid; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 0;
  transition: border-color 0.3s ease;
}
.card.completa { border-color: var(--accent); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
}
.card-titulo { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.card-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.card-sub { color: var(--muted); font-size: 13px; }
.card-contador {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.card.completa .card-contador { color: var(--accent); font-weight: 600; }

.card-nota {
  margin: 4px 16px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
}

/* Filas */

.fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-top: 1px solid var(--line);
}
.card-head + .fila { border-top: 0; }

.fila-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.fila-info:disabled { cursor: default; }

.fila-nombre { font-size: 15px; font-weight: 550; transition: color 0.2s ease; }
.fila.completa .fila-nombre { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--dot); }

.fila-cantidad { color: var(--muted); font-size: 13px; }

.fila-sugerencia {
  display: none;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  opacity: 0.8;
}
.fila.abierta .fila-sugerencia { display: block; }

.puntos {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 132px;
  flex-shrink: 0;
}

.punto {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.punto::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--dot);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.punto.lleno::before {
  background: var(--accent);
  border-color: var(--accent);
  animation: pop 0.25s ease;
  /* palomita */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E");
  background-size: 16px;
  background-position: center;
  background-repeat: no-repeat;
}
.punto:active::before { transform: scale(0.88); }

@keyframes pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Reiniciar */

.acciones { padding: 28px 0 8px; display: flex; justify-content: center; }

.boton-reiniciar {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--danger);
  font-size: 15px;
  font-weight: 550;
  padding: 12px 28px;
  border-radius: 99px;
  cursor: pointer;
}
.boton-reiniciar:active { transform: scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
