:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a65;
  --line: #e6e3da;
  --brand: #0f7b4f;
  --brand-ink: #ffffff;
  --mercadona: #0f7b4f;
  --dia: #e1251b;
  --danger: #c0392b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121211; --card: #1d1d1b; --ink: #f1efe8; --muted: #a09d94; --line: #2e2d2a; --brand: #2fa36f; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
#app { max-width: 640px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 14px calc(110px + var(--safe-b)); }
h1 { font-size: 26px; margin: 6px 0 14px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 22px 0 8px; }
p { margin: 6px 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stack > * + * { margin-top: 10px; }
button, .btn {
  font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--brand); color: var(--brand-ink);
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.link { background: none; color: var(--brand); padding: 6px; min-height: 0; font-weight: 500; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button:disabled { opacity: .5; }
button.icon { width: 44px; padding: 0; }
input, textarea, select {
  font: inherit; color: inherit; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--card);
}
textarea { resize: none; min-height: 48px; max-height: 40vh; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.top { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.top h1 { margin: 0; flex: 1; font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lists a.card { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; margin-bottom: 10px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; color: #fff; text-transform: capitalize; }
.badge.mercadona { background: var(--mercadona); }
.badge.dia { background: var(--dia); }
.count { font-weight: 700; font-size: 20px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { background: transparent; color: var(--ink); border-radius: 0; font-weight: 500; padding: 8px 14px; min-height: 38px; }
.seg button[aria-pressed="true"].mercadona { background: var(--mercadona); color: #fff; }
.seg button[aria-pressed="true"].dia { background: var(--dia); color: #fff; }
.members { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--line); display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; }
.composer { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.composer .row { align-items: flex-end; }
.mic.on { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item .thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.item .thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.done .name { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; }
.qty button { background: none; color: var(--ink); min-height: 36px; width: 34px; padding: 0; font-size: 18px; }
.qty span { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); }
.bottom .inner { max-width: 640px; margin: 0 auto; }
.bottom button { width: 100%; font-size: 17px; min-height: 52px; }
.bottom button.dia { background: var(--dia); }
.bottom button.mercadona { background: var(--mercadona); }
.sheet-bg { position: fixed; inset: 0; background: #0006; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 90dvh; overflow: auto; }
.sheet h2 { margin-top: 0; }
ol.steps { padding-left: 20px; }
ol.steps li { margin: 8px 0; }
code.block { display: block; word-break: break-all; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 110px; overflow: auto; user-select: all; -webkit-user-select: all; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }
.empty-state { text-align: center; padding: 30px 10px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; min-height: 1em; }
