:root {
  --brand: #c8511b;
  --brand-dark: #a63f12;
  --bg: #faf7f4;
  --card: #ffffff;
  --text: #1e1e1e;
  --muted: #7a7a7a;
  --line: #e6e0db;
  --ok: #2e7d32;
  --danger: #b3261e;
  --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.35; overscroll-behavior-y: contain; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* Cabecera */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { white-space: nowrap; }
.topbar .count { background: rgba(255,255,255,.22); border-radius: 12px; padding: 2px 10px; font-size: 14px; font-weight: 600; }
.status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #9be7a3; }
.status.off .dot { background: #ffcf70; }
.status.syncing .dot { background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* Contenido */
.page { padding: 12px 12px calc(96px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 8px; color: var(--brand); }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.center { text-align: center; }

/* Lista */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 10px 6px 6px; margin-bottom: 8px; min-height: var(--tap); }
.item .check { width: var(--tap); height: var(--tap); flex: none; border: none; background: transparent; display: grid; place-items: center; }
.item .check span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--brand); display: grid; place-items: center; color: #fff; font-weight: 700; }
.item.checked .check span { background: var(--ok); border-color: var(--ok); }
.item .body { flex: 1; min-width: 0; padding: 6px 0; }
.item .text { font-weight: 500; word-break: break-word; }
.item.checked .text { text-decoration: line-through; color: var(--muted); }
.item .meta { font-size: 12.5px; color: var(--muted); }
.item .note { font-size: 14px; color: #555; }
.item.pending { border-style: dashed; }
.item .undo { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; font-size: 14px; color: var(--brand); font-weight: 600; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 4px 8px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 44px; margin-bottom: 6px; }

/* Botón flotante */
.fab { position: fixed; right: 18px; bottom: calc(74px + var(--safe-bottom)); width: 60px; height: 60px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; font-size: 34px; line-height: 1; box-shadow: 0 6px 18px rgba(200,81,27,.35); z-index: 6; }
.fab:active { background: var(--brand-dark); }

/* Barra inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 0 calc(6px + var(--safe-bottom)); z-index: 5; }
.tabs button { background: none; border: none; color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px; padding: 4px; }
.tabs button .ico { font-size: 22px; }
.tabs button.on { color: var(--brand); font-weight: 700; }
.tabs button:disabled { opacity: .45; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; padding: 12px 14px; border: 1px solid #cfc7c0; border-radius: 12px; background: #fff; font-size: 17px; }
input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600; width: 100%; }
.btn:disabled { opacity: .5; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); width: auto; min-height: 40px; padding: 6px 10px; }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 15px; width: auto; }
.error { color: var(--danger); font-size: 14px; margin: 6px 0; }
.brand-title { font-size: 34px; font-weight: 800; color: var(--brand); margin: 26px 0 2px; letter-spacing: -.5px; }
.brand-sub { color: var(--muted); margin-bottom: 22px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; letter-spacing: 3px; font-weight: 700; color: var(--brand); }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: none; }
.badge { font-size: 11px; background: #f4e9e2; color: var(--brand); border-radius: 8px; padding: 2px 7px; font-weight: 600; }

/* Hoja de añadir / editar */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: #fff; width: 100%; max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + var(--safe-bottom)); }
.sheet h3 { margin: 0 0 10px; font-size: 17px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; max-height: 132px; overflow: auto; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 8px 12px; font-size: 15px; }
.chip.in { opacity: .45; text-decoration: line-through; }
.sheet .actions { display: flex; gap: 10px; margin-top: 12px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%); background: #333; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 30; max-width: 90vw; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.banner { background: #fff4e0; color: #7a4b00; border: 1px solid #f2d59b; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

/* ===== Fase 2: menú y platos ===== */
textarea { width: 100%; padding: 10px 12px; border: 1px solid #cfc7c0; border-radius: 12px; font-size: 16px; font: inherit; resize: vertical; }
.sheet.tall { max-height: 88vh; overflow: auto; }
.weeknav { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.weeknav .btn.ghost { font-size: 26px; min-width: 48px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; margin-bottom: 10px; }
.day.today { border-color: var(--brand); }
.dayhead { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.slotrow { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; border-top: 1px dotted var(--line); }
.slotname { width: 78px; flex: none; color: var(--muted); font-size: 13.5px; padding-top: 6px; }
.slotbody { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; }
.entry { display: inline-flex; align-items: center; gap: 4px; background: #fff3ea; border: 1px solid #f0cfbc; border-radius: 16px; padding: 4px 6px 4px 10px; font-size: 15px; }
.entry.leftover { background: #f1f1f1; border-color: #ddd; color: #555; }
.entry .x, .chip .x { border: none; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px; margin-left: 2px; }
.addslot { width: 32px; height: 32px; border-radius: 50%; border: 1px dashed var(--brand); background: transparent; color: var(--brand); font-size: 20px; line-height: 1; }
.picklist { max-height: 46vh; overflow: auto; margin: 6px 0; }
.pickrow { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; font-size: 16px; }
.pickrow.free { border-style: dashed; }
.ingrow { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 15.5px; }
.ingrow.in { color: var(--muted); }
.ingrow input { width: 22px; height: 22px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.on .muted { color: #fff; }
.suggest.big .chip { font-size: 16px; padding: 10px 6px 10px 14px; display: inline-flex; align-items: center; }
ul.plain { margin: 0 0 6px 18px; padding: 0; font-size: 15px; }
.tagline { display: inline-block; margin: 0 10px 6px 0; }
.slotedit { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.slotedit input[type=checkbox] { width: 22px; height: 22px; }
.catrow .badge { align-self: center; }
input[type=search] { -webkit-appearance: none; }

.taglink { color: var(--brand); text-decoration: none; padding: 1px 2px; border-radius: 4px; }
.taglink.on { background: var(--brand); color: #fff; }
a.badge { text-decoration: none; }

.eye { border: none; background: transparent; font-size: 20px; padding: 6px; flex: none; }
.chip.small { padding: 5px 10px; font-size: 13.5px; }
select { padding: 10px 12px; border: 1px solid #cfc7c0; border-radius: 12px; background: #fff; font-size: 16px; width: 100%; }
.weeknav .btn.small { min-height: 34px; }
