:root {
  box-sizing: border-box;
  --paper: #F2F5F1;
  --surface: #FFFFFF;
  --ink: #12281D;
  --muted: #5A6D62;
  --line: #D3DDD5;
  --leaf: #1F5C3E;
  --on-leaf: #FFFFFF;
  --tag: #FFD23F;
  --on-tag: #2A2300;
  --plum: #3E2247;
  --danger: #B3261E;
  --radius: 14px;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1A14;
    --surface: #17261E;
    --ink: #EAF2EC;
    --muted: #97AB9F;
    --line: #2B3E32;
    --leaf: #7BD6A0;
    --on-leaf: #0B2015;
    --plum: #CDB4D6;
    --danger: #FF8A80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1A14; --surface: #17261E; --ink: #EAF2EC; --muted: #97AB9F; --line: #2B3E32;
  --leaf: #7BD6A0; --on-leaf: #0B2015; --plum: #CDB4D6; --danger: #FF8A80;
}

*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%;
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--body);
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

/* Cabecera */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 640px; margin: 0 auto; padding: 14px 16px 10px;
  background: var(--paper);
}
.top h1 { font-size: 30px; font-weight: 800; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: var(--line); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 24px; display: grid; gap: 16px; }

/* Navegación inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabs button {
  position: relative; border: 0; background: transparent; cursor: pointer;
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 12px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.tabs button[aria-current="page"] { color: var(--leaf); font-weight: 700; }
.tabs button[aria-current="page"] svg { stroke-width: 2.4; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--tag); color: var(--on-tag);
  font: 700 11px/18px var(--body); font-style: normal; text-align: center;
}

/* Bloques */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.panel h2 { font-size: 20px; font-weight: 700; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: grid; gap: 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.field small { font-weight: 400; }
input, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font-size: 16px;
}
textarea { resize: vertical; min-height: 84px; }
.hint { font-size: 14px; color: var(--muted); }
.error { color: var(--danger); font-weight: 500; font-size: 15px; }

button.primary, button.big, .btn, dialog button {
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 11px 16px; font-weight: 700; cursor: pointer; min-height: 44px;
}
button.primary { background: var(--leaf); color: var(--on-leaf); border-color: var(--leaf); }
button.big { width: 100%; font-size: 17px; }
button:disabled { opacity: .6; cursor: progress; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn { display: block; text-align: center; }
.inline { display: grid; grid-template-columns: 1fr 96px auto; gap: 8px; }
.stack { display: grid; gap: 10px; margin: 16px 0; }

/* Etiqueta de precio: lo memorable de la app */
.tag {
  position: relative; display: grid; gap: 2px; padding: 16px 20px 16px 52px;
  background: var(--tag); color: var(--on-tag);
  clip-path: polygon(28px 0, 100% 0, 100% 100%, 28px 100%, 0 50%);
  border-radius: 6px;
}
.tag::before {
  content: ""; position: absolute; left: 30px; top: 50%; width: 12px; height: 12px;
  margin-top: -6px; border-radius: 50%; background: var(--paper);
}
.tag .label { font-size: 14px; font-weight: 500; }
.tag strong { font: 800 40px/1 var(--display); letter-spacing: -0.02em; }
.tag .sub { font-size: 14px; font-weight: 700; }
.tag.over .sub { color: #8A1C14; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: 14px; }
.list .done .grow { text-decoration: line-through; color: var(--muted); }
.list input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--leaf); flex: none; }
.ghost { border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 20px; line-height: 1; flex: none; }
.ghost:active { background: var(--line); }
.ghost.on { color: #B98A00; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); overflow: hidden; }
.chip button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; }
.chip button + button { padding: 8px 10px 8px 4px; color: var(--muted); }

details { border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); }
details > summary { cursor: pointer; padding: 12px 0; font-weight: 700; min-height: 44px; }
details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details > :last-child { margin-bottom: 14px; }
details ul, details ol { margin: 0 0 12px; padding-left: 20px; }
.recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.menu { display: grid; }
.menu > div { display: grid; grid-template-columns: 84px 1fr; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.menu > div:last-child { border-bottom: 0; }
.menu dt { font-weight: 700; }
.menu dd { margin: 0; }
.menu dd span { display: block; }
.cat { font: 700 15px var(--display); margin: 10px 0 0; color: var(--plum); }
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* Diálogo y aviso */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); width: min(92vw, 420px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin-bottom: 14px; font-size: 22px; }
dialog .primary { width: 100%; }
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--paper);
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

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