/* DuckDiet — UI mobile-first. Nessun font esterno (funziona offline). */
:root {
  --teal: #0f766e;
  --teal-soft: #14b8a6;
  --amber: #d97706;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .07);
  --radius: 18px;
  --ok: #16a34a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2b;
    --surface-2: #182338;
    --text: #e8eef6;
    --muted: #94a3b8;
    --line: #24314a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .35);
    --teal-soft: #2dd4bf;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.02em; }
.brand-icon { width: 26px; height: 26px; }
.view-switch { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.view-btn { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.view-btn.is-active { background: var(--teal); color: #fff; }

.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- navigazione giorno ---------- */
.daynav { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.arrow {
  flex: 0 0 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 26px; line-height: 1; display: grid; place-items: center;
  box-shadow: var(--shadow); transition: transform .1s ease;
}
.arrow:active { transform: scale(.94); }
.daynav-date {
  flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 8px 12px; text-align: center; box-shadow: var(--shadow);
}
.daynav-date strong { display: block; text-transform: capitalize; font-size: 17px; letter-spacing: -.01em; }
.daynav-date span { color: var(--muted); font-size: 13px; }
.date-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }

.weekstrip { display: flex; gap: 6px; margin: 14px 0 10px; overflow-x: auto; scrollbar-width: none; }
.weekstrip::-webkit-scrollbar { display: none; }
.daydot {
  flex: 1 0 auto; min-width: 42px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 6px 4px; text-align: center; font-size: 12px; color: var(--muted);
}
.daydot b { display: block; font-size: 15px; color: var(--text); }
.daydot.is-today { border-color: var(--teal-soft); }
.daydot.is-active { background: var(--teal); border-color: var(--teal); color: #eafffb; }
.daydot.is-active b { color: #fff; }

.kcal-strip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
#kcal-badge { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-weight: 700; color: var(--teal); }
.dot { opacity: .5; }
.ghost-btn { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- sezioni del menu ---------- */
.sections { display: grid; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.sezione { position: relative; overflow: hidden; }
.sezione::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent, var(--teal-soft));
}
.sezione[data-id="mattina"] { --accent: #f59e0b; }
.sezione[data-id="pranzo"] { --accent: #0ea5e9; }
.sezione[data-id="cena"] { --accent: #8b5cf6; }
.sezione[data-id="spuntino"] { --accent: #22c55e; }
.sezione h2 {
  margin: 0 0 10px; font-size: 19px; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.sezione h2 .emoji { font-size: 20px; }
.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px;
}
.badge.sede-ufficio { color: #0369a1; border-color: #7dd3fc; background: #e0f2fe; }
@media (prefers-color-scheme: dark) { .badge.sede-ufficio { color: #bae6fd; background: #0c2a3d; border-color: #155e75; } }

ul.voci { list-style: none; margin: 0; padding: 0; }
ul.voci li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0; border-top: 1px dashed var(--line);
}
ul.voci li:first-child { border-top: 0; padding-top: 2px; }
.voce-nome { flex: 1; }
.voce-nome small { display: block; color: var(--muted); font-size: 12px; }
.voce-q {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 17px; white-space: nowrap;
  color: var(--text);
}
.voce-q em { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 2px; }
.tag-sub { font-size: 11px; color: var(--amber); font-weight: 600; }

.notes summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.notes-list { color: var(--muted); font-size: 13px; padding-left: 18px; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--muted); background: var(--surface-2); }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; }

/* ---------- lista della spesa ---------- */
.spesa-head { margin-top: 6px; }
.tabs { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 9px 8px; font-weight: 700; font-size: 14px; }
.tab.is-active { background: var(--teal); color: #fff; }
.tabs.scope { margin-top: 8px; }
.week-range { color: var(--muted); font-size: 13px; text-align: center; margin: 10px 0 4px; }
.scope-note { color: var(--muted); font-size: 13px; text-align: center; margin: 0 0 14px; }

.categoria { margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.categoria > h3 {
  margin: 0; padding: 12px 16px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.categoria > h3 .n { margin-left: auto; font-size: 12px; }
.categoria ul { list-style: none; margin: 0; padding: 4px 0; }
.categoria li {
  display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--surface-2);
}
.categoria li:first-child { border-top: 0; }
.categoria li label { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; }
.categoria input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal); flex: 0 0 auto; }
.categoria .q { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.categoria .occ { color: var(--muted); font-size: 12px; }
li.done .nome { text-decoration: line-through; color: var(--muted); }
li.done .q { color: var(--muted); text-decoration: line-through; }

.spesa-actions { display: flex; gap: 10px; margin-top: 6px; }
.primary-btn {
  flex: 1; border: 0; border-radius: 14px; background: var(--teal); color: #fff;
  padding: 13px; font-weight: 700; box-shadow: var(--shadow);
}
.primary-btn:active { transform: scale(.99); }
.spesa-actions .ghost-btn { margin-left: 0; padding: 13px 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50;
}

@media (max-width: 380px) {
  .voce-q { font-size: 16px; }
  .view-btn { padding: 7px 9px; font-size: 12px; }
}
@media (min-width: 700px) {
  .sections { grid-template-columns: 1fr 1fr; align-items: start; }
  .notes { grid-column: 1 / -1; }
}
