:root {
  --primary: #6B4E34;
  --primary-dark: #4d3725;
  --bg: #FFF4E0;
  --bg-light: #e6dace;
  --card: #fffaf0;
  --muted: #a3927d;
  --shadow: 0 4px 18px rgba(107, 78, 52, 0.10);
  --shadow-sm: 0 2px 8px rgba(107, 78, 52, 0.08);
  --navh: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
.app {
  width: 100%; max-width: 540px; margin: 0 auto;
  /* spazio in fondo per la nav fissa */
  padding: 0 16px calc(78px + env(safe-area-inset-bottom));
}

/* Header */
header { padding: calc(28px + env(safe-area-inset-top)) 4px 6px; }
.saluto { font-size: 14px; font-weight: 500; color: var(--muted); margin: 0 0 2px; }
.appTitolo { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }

/* Sezioni pasto impilate */
.pasto { margin-top: 22px; scroll-margin-top: 14px; }
.pasto-head { display: flex; align-items: center; gap: 9px; padding: 0 4px 9px; }
.pasto-head .icona { font-size: 19px; }
.pasto-head .nome { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.pasto:not(.corrente) .pasto-head { opacity: .55; }
.ora-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: var(--primary); padding: 3px 9px; border-radius: 9999px;
}
.pasto.corrente .lista {
  border-color: var(--primary); border-width: 1.5px;
  box-shadow: 0 6px 22px rgba(107,78,52,.16);
}

/* Lista alimenti raggruppata, compatta */
.lista {
  background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(107,78,52,.06); overflow: hidden;
}
.card {
  padding: 12px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid rgba(107,78,52,.07); transition: background .12s;
}
.card:first-child { border-top: none; }
.card:active { background: var(--bg-light); }
.card .nome { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.card .nome .star { color: var(--primary); margin-left: 6px; font-size: 12px; vertical-align: 1px; }
.card .qta { flex: 0 0 auto; font-size: 14px; font-weight: 500; color: var(--muted); text-align: right; white-space: nowrap; }
.card.singola { cursor: default; }
.card.singola:active { background: transparent; }

.nota { margin-top: 22px; font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center; padding: 0 8px; }

/* Bottom sheet alternative (pagina piano) */
.overlay {
  position: fixed; inset: 0; background: rgba(40, 28, 18, .42);
  opacity: 0; pointer-events: none; transition: opacity .22s;
  z-index: 50; backdrop-filter: blur(2px);
}
.overlay.aperto { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; top: 50%; z-index: 51;
  transform: translate(-50%, -50%) scale(.96);
  width: calc(100% - 36px); max-width: 440px; max-height: 80dvh;
  background: var(--bg); border-radius: 24px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(40,28,18,.30);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .22s cubic-bezier(.32,.72,0,1);
}
.sheet.aperto { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.sheet h2 { margin: 20px 20px 2px; font-size: 20px; font-weight: 700; }
.sheet .sub { margin: 0 20px 14px; font-size: 13px; color: var(--muted); font-weight: 500; }
.opzioni { overflow-y: auto; padding: 0 16px 18px; -webkit-overflow-scrolling: touch; }
.opz-group { background: var(--card); border-radius: 16px; overflow: hidden; border: 1px solid rgba(107,78,52,.06); }
.opz {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: transparent; border: none; border-top: 1px solid rgba(107,78,52,.07);
  padding: 11px 14px; font-family: inherit; text-align: left; cursor: pointer; transition: background .12s;
}
.opz:first-child { border-top: none; }
.opz:active { background: var(--bg-light); }
.opz .n { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--primary); line-height: 1.3; }
.opz .q { flex: 0 0 auto; font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; text-align: right; }
.opz.preferita { background: #fff; }
.opz.preferita .n { font-weight: 700; }
.opz.originale .tag {
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); background: var(--bg-light); padding: 2px 7px; border-radius: 6px;
  margin-left: 8px; vertical-align: middle;
}
.check {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--bg-light); display: flex; align-items: center; justify-content: center;
}
.opz.preferita .check { background: var(--primary); border-color: var(--primary); }
.opz.preferita .check svg { display: block; }
.opz .check svg { display: none; }

/* Pagina consigli */
.info-sez { margin-top: 24px; }
.info-sez h3 { font-size: 17px; font-weight: 700; margin: 0 0 10px; padding-left: 4px; }
.info-card { background: var(--card); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-sm); border: 1px solid rgba(107,78,52,.06); }
.info-card p { font-size: 14px; line-height: 1.55; margin: 0 0 12px; }
.info-card ul { margin: 6px 0 12px; padding-left: 20px; }
.info-card li { font-size: 14px; line-height: 1.5; margin-bottom: 5px; }
.info-card b { font-weight: 700; }
.info-footer { margin-top: 28px; text-align: center; font-size: 12.5px; line-height: 1.6; color: var(--muted); padding: 0 8px; }

/* Pagina ricettario: shell a colonna a tutta altezza con scroller orizzontale */
body.ric { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.ric-top { max-width: 540px; margin: 0 auto; width: 100%; padding: 0 16px; flex: 0 0 auto; }
.cat-tabs { display: flex; gap: 8px; padding: 12px 0 10px; }
.cat-tab {
  flex: 1; border: none; cursor: pointer; background: var(--bg-light); color: var(--primary);
  padding: 9px 8px; border-radius: 9999px; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: transform .12s, background .15s;
}
.cat-tab:active { transform: scale(0.96); }
.cat-tab.attivo { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.ric-conta { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 6px; }

.ric-scroller {
  flex: 1 1 auto; min-height: 0;
  display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.ric-scroller::-webkit-scrollbar { display: none; }
.ric-card {
  flex: 0 0 100vw; scroll-snap-align: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 16px 24px;
}
.ric-inner { max-width: 520px; margin: 0 auto; }
.ric-box {
  background: var(--card); border-radius: 20px; padding: 18px 20px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(107,78,52,.06);
}
.ric-nome { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; line-height: 1.2; }
.ric-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.ric-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 9999px; background: var(--bg-light); color: var(--primary);
}
.ric-tag.stagione { background: var(--primary); color: #fff; }
.ric-box h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 16px 0 8px;
}
.ric-box h4:first-of-type { margin-top: 0; }
.ric-box ul, .ric-box ol { margin: 0; padding-left: 20px; }
.ric-box li { font-size: 14px; line-height: 1.5; margin-bottom: 6px; }
.ric-box ol li { padding-left: 4px; }
.ric-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }

/* Bottom nav (tabbar) — fissa in fondo allo schermo */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg);
  border-top: 1px solid rgba(107,78,52,.10);
  display: flex; justify-content: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
/* nel ricettario la nav resta statica in fondo alla colonna */
body.ric .tabbar { position: static; flex: 0 0 auto; }
.tabbar a {
  flex: 1; max-width: 150px; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted);
  opacity: .55; transition: opacity .15s, color .15s;
}
.tabbar a .ic { font-size: 21px; line-height: 1; }
.tabbar a.attivo { opacity: 1; color: var(--primary); }
