/* Fotocal — paleta de cocina: fondo oscuro neutro, tomate para actuar,
   y cada macro con el color de un alimento: arándano (proteína), yema (carbos), aguacate (grasa). */

/* Siempre oscura: gris carbón neutro, el color lo ponen los alimentos. */
:root {
  color-scheme: dark;
  --bg: #111112;
  --surface: #1b1b1d;
  --surface-2: #262628;
  --border: #303033;
  --text: #f4f4f5;
  --muted: #9b9ba1;

  --tomato: #ff5a36;
  --tomato-ink: #ffffff;
  --tomato-fill: #d93a17;   /* botones rellenos: blanco encima con contraste AA */
  --protein: #8aa2ff;   /* arándano */
  --carbs: #ffc23d;     /* yema */
  --fat: #8bd35b;       /* aguacate */

  --tomato-soft: #3a1c16;
  --protein-soft: #1f2440;
  --carbs-soft: #33290f;
  --fat-soft: #1c2d17;

  --display: "Unbounded", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--body);
  min-height: 100dvh;
  padding-bottom: calc(124px + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Cabecera ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 0 2px;
}
.brand { font: 700 19px/1 var(--display); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 26px; height: 26px; border-radius: 9px; background: var(--tomato); display: grid; place-items: center; color: #fff; }
.brand-dot svg { width: 15px; height: 15px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--surface-2); color: var(--muted); display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }

.daynav {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  margin: 12px auto 0; width: fit-content; min-width: 220px;
  background: var(--surface-2); border-radius: 999px; padding: 4px;
}
.daynav button { border: 0; background: none; width: 44px; height: 40px; color: var(--text); border-radius: 999px; font-size: 20px; line-height: 1; }
.daynav button:not(:disabled):active { background: var(--surface); }
.daynav button:disabled { opacity: .2; }
.daynav .label { font-weight: 700; text-align: center; text-transform: capitalize; padding: 0 6px; }

/* ---------- El plato (anillo por macros) ---------- */
.ring-box { position: relative; width: 252px; height: 252px; margin: 14px auto 2px; }
.ring-box svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { stroke: var(--surface-2); }
.seg { transition: stroke-dasharray .9s cubic-bezier(.2,.8,.2,1), stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.seg-p { stroke: var(--protein); }
.seg-c { stroke: var(--carbs); }
.seg-f { stroke: var(--fat); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-big { font: 700 52px/1 var(--display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.ring-small { color: var(--muted); font-size: 14px; margin-top: 8px; }
.ring-sub {
  margin: 10px auto 0; font-size: 13px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border-radius: 999px; padding: 4px 12px; width: fit-content;
}
.ring-sub b { font-weight: 800; }
.ring-box.done .ring-small { color: var(--fat); font-weight: 700; }

/* ---------- Macros ---------- */
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.macro { border-radius: var(--r-md); padding: 11px 12px 12px; }
.macro.p { background: var(--protein-soft); --c: var(--protein); }
.macro.c { background: var(--carbs-soft); --c: var(--carbs); }
.macro.f { background: var(--fat-soft); --c: var(--fat); }
.macro .k { font-size: 12px; font-weight: 700; color: var(--c); }
.macro .v { font: 700 22px/1.1 var(--display); letter-spacing: -.03em; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.macro .v small { display: block; font: 500 12px/1.3 var(--body); color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.bar { height: 6px; background: color-mix(in srgb, var(--c) 18%, transparent); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c); transition: width .9s cubic-bezier(.2,.8,.2,1); }

/* ---------- Semana ---------- */
.week {
  display: flex; justify-content: space-between; gap: 0; margin: 10px 0 0; padding: 12px 4px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.wd { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; }
.wd .col { width: 100%; max-width: 24px; height: 44px; background: var(--surface-2); border-radius: 8px; position: relative; overflow: hidden; }
.wd .col i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--tomato); border-radius: 8px; }
.wd .col i.done { background: var(--fat); }
.wd span { font-size: 12px; font-weight: 600; color: var(--muted); width: 24px; height: 22px; display: grid; place-items: center; border-radius: 999px; }
.wd.today span { color: var(--tomato); }
.wd.sel span { background: var(--text); color: var(--bg); }
.wd:disabled { opacity: .35; cursor: default; }

h2 { font: 700 15px/1.2 var(--display); letter-spacing: -.01em; margin: 26px 0 10px; }

/* ---------- Habituales ---------- */
.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.preset {
  flex: none; display: flex; align-items: center; gap: 10px; border: 0;
  background: var(--carbs-soft); border-radius: var(--r-md); padding: 8px 16px 8px 8px; min-height: 56px; text-align: left;
}
.preset .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; font-size: 22px; line-height: 1; }
.preset b { display: block; font-size: 14px; }
.preset small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.preset.add { background: none; border: 1.5px dashed var(--border); color: var(--muted); padding: 8px 16px; font-weight: 600; }

/* ---------- Comidas ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.card.new { animation: pop .25s ease-out; }
.card.open { border-color: color-mix(in srgb, var(--tomato) 45%, var(--border)); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; width: 100%; border: 0; background: none; text-align: left; }
.thumb { width: 60px; height: 60px; border-radius: 16px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); }
.thumb.ico { font-size: 30px; background: var(--carbs-soft); }
.meta { flex: 1; min-width: 0; }
.name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 5px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { border-radius: 6px; padding: 1px 6px; font-weight: 700; font-size: 12px; }
.tag.p { background: var(--protein-soft); color: var(--protein); }
.tag.c { background: var(--carbs-soft); color: var(--carbs); }
.tag.f { background: var(--fat-soft); color: var(--fat); }
.kcal { font: 700 20px/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; text-align: right; }
.kcal small { display: block; font: 500 12px var(--body); color: var(--muted); letter-spacing: 0; margin-top: 3px; }

.detail { padding: 0 14px 14px; display: none; }
.card.open .detail { display: block; }
.items { margin: 0 0 12px; padding: 0; list-style: none; font-size: 13px; }
.items li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); color: var(--muted); font-variant-numeric: tabular-nums; }
.items li b { color: var(--text); font-weight: 600; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  border: 0; background: var(--surface-2); color: var(--text); border-radius: 12px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; min-height: 44px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:active { filter: brightness(.95); transform: translateY(1px); }
.chip.tomato { background: var(--tomato-soft); color: var(--tomato); }
.chip.blue { background: var(--protein-soft); color: var(--protein); }
.chip.yolk { background: var(--carbs-soft); color: var(--carbs); }
.chip.green { background: var(--fat-soft); color: var(--fat); }
.chip.end { margin-left: auto; }
.seg-ctl { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg-ctl .chip { background: none; min-height: 40px; min-width: 44px; padding: 6px 10px; border-radius: 9px; justify-content: center; }
.seg-ctl .chip:active { background: var(--surface); }
.seg-ctl .chip.on { background: var(--tomato-fill); color: var(--tomato-ink); }

.fix { display: flex; gap: 6px; margin-bottom: 10px; }
.fix input { flex: 1; min-width: 0; height: 42px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); padding: 0 12px; font-size: 16px; }
.fix input:focus { border-color: var(--protein); outline: none; }

.shimmer { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
           background-size: 200% 100%; animation: sh 1.1s linear infinite; border-radius: 6px; }
@keyframes sh { to { background-position: -200% 0; } }
.pending .name { color: var(--muted); }
.err { border-color: color-mix(in srgb, var(--tomato) 40%, var(--border)); }
.err .name { color: var(--tomato); }

.empty { text-align: center; color: var(--muted); padding: 30px 20px; border: 1.5px dashed var(--border); border-radius: var(--r-lg); }
.empty b { color: var(--text); display: block; margin-bottom: 4px; font-family: var(--display); font-size: 15px; }
.empty .chip { margin-top: 14px; }

/* ---------- Barra inferior ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.dock-row { display: flex; align-items: center; justify-content: center; gap: 30px; }
.shoot {
  width: 78px; height: 78px; border-radius: 50%; background: var(--tomato-fill); color: var(--tomato-ink);
  display: grid; place-items: center; cursor: pointer; transition: transform .12s;
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--tomato) 70%, transparent), inset 0 -4px 0 rgba(0,0,0,.12);
}
.shoot:active { transform: scale(.93); }
.shoot svg { width: 34px; height: 34px; }
.side { width: 52px; height: 52px; border-radius: 18px; border: 0; display: grid; place-items: center; cursor: pointer; }
.side svg { width: 22px; height: 22px; }
.side.blue { background: var(--protein-soft); color: var(--protein); }
.side.yolk { background: var(--carbs-soft); color: var(--carbs); }
.side:active { transform: scale(.94); }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.textbar { display: none; gap: 8px; margin: 0 auto 12px; max-width: 448px; }
.textbar.show { display: flex; }
.textbar input { flex: 1; min-width: 0; height: 50px; border-radius: 16px; border: 1.5px solid var(--carbs); background: var(--surface); padding: 0 14px; font-size: 16px; }
.textbar input:focus-visible { outline: 2.5px solid var(--protein); outline-offset: 1px; }
.textbar button { height: 50px; border-radius: 16px; border: 0; background: var(--carbs); color: #2a1d00; padding: 0 18px; font-weight: 800; }

/* ---------- Diálogos ---------- */
dialog { border: 1px solid var(--border); border-radius: 26px; background: var(--surface); color: var(--text); padding: 22px; width: min(92vw, 380px);
         box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog h3 { margin: 0 0 16px; font: 700 18px var(--display); letter-spacing: -.02em; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.field label { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.field label i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.field input { width: 110px; height: 44px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); padding: 0 12px; text-align: right; font-size: 16px; font-weight: 700; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.btn { height: 48px; padding: 0 20px; border-radius: 14px; border: 0; background: var(--surface-2); font-weight: 700; }
.btn.primary { background: var(--tomato-fill); color: var(--tomato-ink); }
.btn:active { transform: translateY(1px); }

/* ---------- Editor de habituales: hoja que sube desde abajo ---------- */
#presetDlg {
  padding: 0; width: 100%; max-width: 480px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 28px 28px 0 0; border-bottom: 0;
  animation: sheet-in .25s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 600px) { #presetDlg { margin: auto; border-radius: 28px; border-bottom: 1px solid var(--border); } }
#presetDlg .in { overflow-y: auto; max-height: 92dvh; padding: 0 16px; }
.grab { width: 40px; height: 5px; border-radius: 99px; background: var(--border); margin: 10px auto 6px; }

.pd-head { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.pd-emoji {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 16px; background: var(--carbs-soft);
  text-align: center; font-size: 24px; padding: 0;
}
.pd-name {
  flex: 1; min-width: 0; height: 48px; border: 0; border-bottom: 2px solid transparent; background: none; border-radius: 0;
  padding: 0 4px; font: 700 20px var(--display); letter-spacing: -.02em;
}
.pd-name:focus-visible { outline: none; border-bottom-color: var(--protein); }
.x { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.x svg { width: 18px; height: 18px; }

/* Resumen arriba: total grande + barra de macros */
.pd-sum { padding: 10px 2px 16px; }
.pd-kcal { display: flex; align-items: baseline; gap: 6px; }
.pd-kcal b { font: 700 40px/1 var(--display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.pd-kcal span { color: var(--muted); font-weight: 600; }
.pd-bar { display: flex; gap: 3px; height: 10px; margin: 12px 0 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.pd-bar i { flex: 0 1 0; min-width: 0; transition: flex-grow .3s ease; }
.pd-bar .p { background: var(--protein); } .pd-bar .c { background: var(--carbs); } .pd-bar .f { background: var(--fat); }
.pd-macros { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pd-macros span { display: inline-flex; align-items: center; gap: 6px; }
.pd-macros i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.pd-macros .p i { background: var(--protein); } .pd-macros .c i { background: var(--carbs); } .pd-macros .f i { background: var(--fat); }
.pd-macros b { color: var(--text); font-weight: 700; }

/* Lista de ingredientes */
.pd-list { background: var(--surface-2); border-radius: 20px; padding: 4px 14px; margin-bottom: 12px; }
.ing { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ing:last-of-type { border-bottom: 0; }
.ing-top { display: flex; align-items: flex-start; gap: 10px; }
.ing-name { flex: 1; min-width: 0; }
.ing-name b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ing-name small { color: var(--muted); font-size: 12px; }
.ing-kcal { font: 700 17px var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ing-kcal small { font: 500 12px var(--body); color: var(--muted); letter-spacing: 0; }
.ing-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.stepper { display: flex; align-items: center; background: var(--surface); border-radius: 14px; padding: 3px; }
.stepper button { width: 44px; height: 42px; border-radius: 11px; border: 0; background: none; color: var(--text); font-size: 22px; font-weight: 600; }
.stepper button:active { background: var(--surface-2); }
.stepper .amt { display: flex; align-items: baseline; justify-content: center; gap: 3px; min-width: 84px; }
.stepper input { width: 52px; height: 42px; text-align: right; border: 0; background: none; font: 700 18px var(--display); letter-spacing: -.02em; padding: 0; }
.stepper .amt span { color: var(--muted); font-weight: 600; font-size: 13px; }
.ing-edit {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  background: none; color: var(--muted); font-weight: 600; font-size: 13px;
}
.ing-edit svg { width: 15px; height: 15px; }
.ing-edit[aria-expanded="true"] { background: var(--surface); color: var(--text); }
.per100 { display: none; margin-top: 12px; padding: 12px; background: var(--surface); border-radius: 14px; }
.ing.edit .per100 { display: block; }
.per100 .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.per100 label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.per100 label.p { color: var(--protein); } .per100 label.c { color: var(--carbs); } .per100 label.f { color: var(--fat); }
.per100 input { width: 100%; height: 42px; border-radius: 10px; border: 0; background: var(--surface-2); text-align: center; font-size: 15px; font-weight: 700; }
.per100 .hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.per100-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }

.pd-add {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0; border: 0; background: none;
  color: var(--fat); font-weight: 700; border-top: 1px solid var(--border);
}
.pd-add span { width: 30px; height: 30px; border-radius: 10px; background: var(--fat-soft); display: grid; place-items: center; font-size: 20px; line-height: 1; }
.ing + .pd-add, .ing + .addbox { border-top: 1px solid var(--border); }
.addbox { padding: 12px 0; }
.addbox-t { margin: 0 0 10px; font-weight: 700; }
.cat { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cat .chip { min-height: 40px; padding: 6px 12px; font-size: 13px; background: var(--fat-soft); color: var(--fat); }
.other { display: flex; gap: 6px; margin-bottom: 10px; }
.other input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); padding: 0 12px; font-size: 16px; }

/* Botones fijos abajo de la hoja */
.pd-foot {
  position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--surface) 80%, transparent);
}
.pd-actions { display: grid; grid-template-columns: 1fr 1.7fr; gap: 8px; }
.pd-actions .btn { width: 100%; height: 54px; font-size: 16px; }
.pd-help { margin: 8px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.linkbtn { border: 0; background: none; color: var(--tomato); font-size: 13px; font-weight: 700; padding: 0 4px; min-height: 44px; white-space: nowrap; }
.busy { opacity: .55; pointer-events: none; }

/* ---------- Aviso ---------- */
/* Abajo, encima de la barra (cerca del pulgar). Va en "popover" para verse también sobre los diálogos. */
.toast {
  position: fixed; inset: auto; margin: 0; border: 0;
  left: 50%; bottom: calc(112px + env(safe-area-inset-bottom)); transform: translate(-50%, 0);
  display: none; align-items: center; gap: 14px; width: max-content; max-width: min(92vw, 440px);
  background: var(--text); color: var(--bg); padding: 10px 10px 10px 18px; border-radius: 16px; font-size: 14px; font-weight: 600;
  z-index: 20; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .6);
}
.toast.show { display: flex; animation: toast-in .2s ease-out; }
.toast:not(:has(.toast-btn)) { padding-right: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast-btn { border: 0; background: var(--tomato-fill); color: var(--tomato-ink); font-weight: 800; padding: 0 16px; min-height: 40px; border-radius: 10px; font-size: 14px; }

/* ---------- Entrada con PIN ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gate { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; }
.gate-in { max-width: 380px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 20px 32px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.gate-brand { display: flex; align-items: center; gap: 10px; font: 700 18px var(--display); margin-bottom: 36px; }
.gate-brand .brand-dot svg { width: 16px; height: 16px; }
.gate h1 { font: 700 26px/1.15 var(--display); letter-spacing: -.03em; margin: 0 0 8px; }
.gate-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.gate-err { color: var(--tomato); font-weight: 600; font-size: 14px; min-height: 20px; margin: 6px 0; }
.gate-form { width: 100%; display: flex; flex-direction: column; text-align: left; gap: 6px; }
.gate-form label { font-weight: 700; font-size: 14px; margin-top: 8px; }
.gate-form input { height: 52px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); padding: 0 14px; font-size: 18px; }
.gate-form .btn { height: 54px; margin-top: 6px; }
.who { width: 100%; display: grid; gap: 10px; margin-top: 14px; }
.who-btn { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 16px 8px 8px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); font-weight: 700; font-size: 17px; text-align: left; }
.gate-back { align-self: flex-start; border: 0; background: none; color: var(--muted); font-weight: 600; min-height: 44px; padding: 0; margin: -20px 0 8px; }
.dots { display: flex; gap: 16px; margin: 8px 0 4px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--tomato); border-color: var(--tomato); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; margin-top: 10px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--surface-2); font: 600 26px var(--display); }
.keypad button:active { background: var(--border); }
.keypad [data-key="back"] { background: none; font-size: 22px; color: var(--muted); }

/* Avatar con la inicial */
.head-actions { display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--protein-soft); color: var(--protein); font: 700 17px var(--display); position: relative;
}
.avatar.big { width: 48px; height: 48px; }
.avatar.online::after { content: ""; position: absolute; right: 1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: var(--fat); border: 2px solid var(--surface); }

/* Hoja de Personas (mismo estilo que el editor de habituales) */
dialog.sheet {
  padding: 0; width: 100%; max-width: 480px; max-height: 92dvh; margin: auto auto 0;
  border-radius: 28px 28px 0 0; border-bottom: 0; animation: sheet-in .25s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 28px; border-bottom: 1px solid var(--border); } }
dialog.sheet .in { overflow-y: auto; max-height: 92dvh; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-t { flex: 1; margin: 0; font: 700 20px var(--display); letter-spacing: -.02em; }
.people { list-style: none; margin: 10px 0 14px; padding: 4px 14px; background: var(--surface-2); border-radius: 20px; }
.people li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.people li:last-child { border-bottom: 0; }
.pp-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pp-meta b small { color: var(--muted); font-weight: 500; }
.pp-meta small { color: var(--muted); font-size: 12.5px; }
.pp-bar { height: 6px; border-radius: 99px; background: var(--surface); overflow: hidden; margin: 4px 0 2px; }
.pp-bar i { display: block; height: 100%; background: var(--tomato); border-radius: inherit; }
.add-person { background: var(--surface-2); border-radius: 20px; padding: 12px 14px; margin-bottom: 6px; }
.add-person .gate-sub { margin: 8px 0 0; font-size: 12.5px; }
.ap-row { display: flex; gap: 6px; }
.ap-row input { min-width: 0; height: 44px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); padding: 0 12px; font-size: 16px; }
.ap-row input:first-of-type { flex: 1.6; }
.ap-row input + label + input { flex: 1; }
.pp-pin { align-self: center; min-height: 40px; padding: 0 12px; font-size: 13px; }
.pin-row { margin-top: 8px; flex-wrap: wrap; }
.pin-row input { flex: 1; min-width: 90px; }

/* ---------- Cámara propia ---------- */
dialog.cam {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; background: #000; color: #fff; overflow: hidden; box-shadow: none;
}
dialog.cam::backdrop { background: #000; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* El marco: todo lo de fuera se oscurece con una sombra enorme. */
.cam-frame {
  --fw: min(84vw, 420px); --fh: var(--fw);
  position: absolute; left: 50%; top: 44%; width: var(--fw); height: var(--fh);
  transform: translate(-50%, -50%); border-radius: 26px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .55);
  transition: width .25s ease, height .25s ease;
}
.cam[data-mode="barcode"] .cam-frame { --fw: min(86vw, 440px); --fh: calc(var(--fw) * .42); border-radius: 18px; }
.cam[data-mode="label"] .cam-frame { --fw: min(78vw, 400px); --fh: min(calc(var(--fw) * 1.3), 58dvh); border-radius: 18px; }
.cn { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.cn.tl { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 26px; }
.cn.tr { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 26px; }
.cn.bl { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 26px; }
.cn.br { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 26px; }
.cam[data-mode="barcode"] .cn { border-color: var(--carbs); }
.cam[data-mode="label"] .cn { border-color: var(--protein); }
.scan { display: none; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--tomato); box-shadow: 0 0 12px var(--tomato); }
.cam[data-mode="barcode"] .scan { display: block; animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateY(calc(var(--fh) * -.38)); } to { transform: translateY(calc(var(--fh) * .38)); } }
.cam.detected .cn { border-color: var(--fat); }

.cam-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
}
.cam-ic {
  width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: none;
}
.cam-ic svg { width: 22px; height: 22px; }
.cam-ic.big { width: 52px; height: 52px; }
.cam-ic.ghost { background: none; }
.cam-ic[aria-pressed="true"] { background: var(--carbs); color: #2a1d00; }
.cam-hint {
  position: absolute; left: 0; right: 0; top: calc(44% + var(--hint-off, 0px)); margin: 0; text-align: center;
  font-weight: 700; font-size: 15px; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); pointer-events: none;
}
.cam-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 16px calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.cam-modes { display: flex; gap: 4px; background: rgba(0, 0, 0, .55); padding: 4px; border-radius: 999px; }
.cam-modes button {
  border: 0; background: none; color: rgba(255, 255, 255, .8); font-weight: 700; font-size: 14px;
  min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
}
.cam-modes button[aria-checked="true"] { background: #fff; color: #111; }
.cam-modes.locked { display: none; }
.cam-row { width: 100%; max-width: 360px; display: flex; align-items: center; justify-content: space-between; }
.cam-shutter {
  width: 80px; height: 80px; border-radius: 50%; border: 4px solid #fff; background: none; padding: 5px; cursor: pointer;
}
.cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.cam-shutter:active span { transform: scale(.88); }
.cam[data-mode="barcode"].live .cam-shutter { opacity: .55; }

:focus-visible { outline: 2.5px solid var(--protein); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
