/* Nido · stile "glass" alla Apple TV.
   Layout: una colonna; pannelli traslucidi sfocati sopra uno sfondo profondo con luci colorate; barra a schede in basso. */
:root {
  --bg: #EEF1F8;
  --glow-1: #9FC2FF;
  --glow-2: #F6B8E6;
  --glow-3: #A8F0DE;
  --glass: rgba(255, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-soft: rgba(255, 255, 255, .32);
  --edge: rgba(255, 255, 255, .7);
  --edge-dim: rgba(20, 30, 60, .08);
  --ink: #0B0D12;
  --muted: rgba(20, 24, 36, .58);
  --line: rgba(20, 30, 60, .1);
  --accent: #0A7AFF;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(10, 122, 255, .14);
  --ok: #1E9E58;
  --ok-soft: rgba(48, 209, 88, .18);
  --warn: #B87400;
  --warn-soft: rgba(255, 179, 0, .2);
  --bad: #D7263D;
  --bad-soft: rgba(255, 69, 58, .16);
  --shadow: 0 10px 30px rgba(30, 40, 80, .12);
  --blur: saturate(180%) blur(28px);
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --r: 24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #05060A;
    --glow-1: #1F4BFF;
    --glow-2: #8A2BE2;
    --glow-3: #00B3A4;
    --glass: rgba(255, 255, 255, .08);
    --glass-strong: rgba(40, 42, 54, .72);
    --glass-soft: rgba(255, 255, 255, .05);
    --edge: rgba(255, 255, 255, .16);
    --edge-dim: rgba(255, 255, 255, .06);
    --ink: #F5F7FF;
    --muted: rgba(235, 240, 255, .6);
    --line: rgba(255, 255, 255, .1);
    --accent: #3D9BFF;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(61, 155, 255, .2);
    --ok: #4ADE80;
    --ok-soft: rgba(74, 222, 128, .16);
    --warn: #FFC94A;
    --warn-soft: rgba(255, 201, 74, .16);
    --bad: #FF6B6B;
    --bad-soft: rgba(255, 107, 107, .16);
    --shadow: 0 12px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #05060A; --glow-1: #1F4BFF; --glow-2: #8A2BE2; --glow-3: #00B3A4;
  --glass: rgba(255, 255, 255, .08); --glass-strong: rgba(40, 42, 54, .72); --glass-soft: rgba(255, 255, 255, .05);
  --edge: rgba(255, 255, 255, .16); --edge-dim: rgba(255, 255, 255, .06);
  --ink: #F5F7FF; --muted: rgba(235, 240, 255, .6); --line: rgba(255, 255, 255, .1);
  --accent: #3D9BFF; --accent-soft: rgba(61, 155, 255, .2);
  --ok: #4ADE80; --ok-soft: rgba(74, 222, 128, .16); --warn: #FFC94A; --warn-soft: rgba(255, 201, 74, .16);
  --bad: #FF6B6B; --bad-soft: rgba(255, 107, 107, .16); --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.42 var(--body);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
/* luci colorate sfocate dietro al vetro */
body::before {
  content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 10%, var(--glow-1), transparent 70%),
    radial-gradient(35% 30% at 90% 30%, var(--glow-2), transparent 70%),
    radial-gradient(45% 35% at 40% 95%, var(--glow-3), transparent 70%);
  opacity: .55; filter: blur(40px);
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: -.025em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 21px; letter-spacing: -.02em; }
h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 100px);
  display: flex; flex-direction: column; gap: 16px;
}
.boot { min-height: 70vh; display: grid; place-items: center; }
.boot-logo { font-size: 56px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); } }

/* ---------- Vetro ---------- */
.card, .stat, .item, .pcard, .chip, .add-bar .card, .day, .chore, .exp, .note {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--edge-dim);
  box-shadow: var(--shadow), inset 0 1px 0 var(--edge);
}
.card { border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head a, .link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 15px; background: none; border: 0; padding: 0; cursor: pointer; }
.card.flat, .stat.soon { background: var(--glass-soft); box-shadow: none; border: 1px dashed var(--line); }

/* ---------- Saluto ---------- */
.hello { display: flex; flex-direction: column; gap: 6px; padding: 6px 2px 2px; }
.hello-top { display: flex; justify-content: space-between; align-items: center; }
.hello .house { font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hello-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 7px 13px;
  font-size: 14px; font-weight: 600; box-shadow: none;
}
.chip.ok { color: var(--ok); }
.chip.bad { color: var(--bad); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { border-radius: 22px; padding: 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat b { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; }
.stat .small { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.stat.wide { grid-column: 1 / -1; }

/* ---------- Bigliettini ---------- */
.notes { display: flex; flex-direction: column; gap: 8px; }
.note { border-radius: 18px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; box-shadow: none; background: var(--glass-soft); }
.note .who { font-weight: 700; font-size: 13px; }
.note p { white-space: pre-wrap; word-break: break-word; }
.note .x { margin-left: auto; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-weight: 600; font-size: 14px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--glass-soft);
  border-radius: 14px; padding: 12px 14px; font-size: 16px; outline: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent); background: var(--glass); }
textarea.input { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.pin { letter-spacing: .5em; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }

.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--glass-soft); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .45; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; font-size: 17px; color: var(--muted); flex: none;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line); background: var(--glass-soft); border-radius: 999px; padding: 8px 13px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Lista della spesa ---------- */
.add-bar { position: sticky; top: calc(env(safe-area-inset-top) + 6px); z-index: 5; }
.add-bar .card { padding: 10px; gap: 8px; background: var(--glass-strong); }
.suggest { display: flex; flex-direction: column; gap: 2px; }
.suggest button {
  display: flex; gap: 10px; align-items: center; text-align: left; border: 0; background: none;
  padding: 8px; border-radius: 14px; cursor: pointer; width: 100%;
}
.suggest button:hover, .suggest button:focus-visible { background: var(--glass-soft); }

.group-title { font-weight: 700; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 4px 4px 0; }
.items { display: flex; flex-direction: column; gap: 8px; }
.item { border-radius: 20px; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; }
.item.done { opacity: .5; box-shadow: none; background: var(--glass-soft); }
.item.done .iname { text-decoration: line-through; }
.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); background: transparent;
  flex: none; cursor: pointer; display: grid; place-items: center; font-weight: 900; color: transparent; opacity: .7;
}
.done .check, .check.on { background: var(--ok); border-color: var(--ok); color: #fff; opacity: 1; }
.thumb { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; background: var(--glass-soft); flex: none; display: grid; place-items: center; font-size: 22px; }
.ibody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.iname { font-weight: 600; line-height: 1.25; }
.imeta { font-size: 13px; color: var(--muted); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tag.esatto { background: var(--bad-soft); color: var(--bad); }
.tag.simile { background: var(--ok-soft); color: var(--ok); }
.tag.chiedi { background: var(--warn-soft); color: var(--warn); }
.tag.who { background: var(--glass-soft); color: var(--ink); border: 1px solid var(--line); }
.tag.late { background: var(--bad-soft); color: var(--bad); }
.tag.today { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 28px 16px; align-items: center; }
.empty .big { font-size: 40px; }

/* ---------- Catalogo ---------- */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard { border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer; }
.pcard .pimg { aspect-ratio: 1 / 1; background: var(--glass-soft); display: grid; place-items: center; font-size: 40px; width: 100%; object-fit: cover; }
.pcard .pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.pcard .pname { font-weight: 600; line-height: 1.2; }

.photo-pick {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 20px; background: var(--glass-soft); border: 1px dashed var(--line);
  display: grid; place-items: center; overflow: hidden; cursor: pointer;
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick span { color: var(--muted); font-weight: 600; }

/* ---------- Controllo prodotto ---------- */
.verdict { border-radius: var(--r); padding: 16px; display: flex; gap: 12px; align-items: center; }
.verdict.ok { background: var(--ok-soft); }
.verdict.no { background: var(--bad-soft); }
.verdict .big { font-size: 34px; }
.scanner { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 28% 12%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* ---------- Menu della settimana ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.days { display: flex; flex-direction: column; gap: 10px; }
.day { border-radius: 22px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.day.today { border-color: var(--accent); box-shadow: var(--shadow), inset 0 1px 0 var(--edge), 0 0 0 1px var(--accent); }
.day-head { display: flex; align-items: baseline; gap: 8px; }
.day-head b { text-transform: capitalize; }
.slot { display: flex; gap: 10px; align-items: center; }
.slot .when { width: 54px; flex: none; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meals { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.meal { border: 1px solid var(--line); background: var(--glass-soft); border-radius: 12px; padding: 6px 10px; font-weight: 600; font-size: 14px; cursor: pointer; text-align: left; }
.meal small { color: var(--muted); font-weight: 500; }
.add-meal { border: 1px dashed var(--line); background: none; border-radius: 12px; padding: 6px 10px; color: var(--muted); cursor: pointer; font-size: 14px; }
.ing-list { display: flex; flex-direction: column; gap: 6px; }
.ing { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: var(--glass-soft); }

/* ---------- Faccende ---------- */
.chores { display: flex; flex-direction: column; gap: 8px; }
.chore { border-radius: 20px; padding: 12px; display: flex; gap: 12px; align-items: center; }
.chore .ico { font-size: 26px; width: 44px; height: 44px; border-radius: 14px; background: var(--glass-soft); display: grid; place-items: center; flex: none; }
.balance { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--glass-soft); }
.balance span { display: block; height: 100%; }

/* ---------- Spese ---------- */
.big-money { font-family: var(--display); font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; }
.exps { display: flex; flex-direction: column; gap: 8px; }
.exp { border-radius: 18px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; text-align: left; width: 100%; }
.exp .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-bars { display: flex; flex-direction: column; gap: 8px; }
.cat-bar { display: grid; grid-template-columns: 110px 1fr 80px; gap: 8px; align-items: center; font-size: 14px; }
.cat-bar .track { height: 8px; border-radius: 5px; background: var(--glass-soft); overflow: hidden; }
.cat-bar .fill { height: 100%; background: var(--accent); border-radius: 5px; }
.cat-bar .v { text-align: right; font-variant-numeric: tabular-nums; }
.money-input { font-size: 28px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Pannello in basso (sheet) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; animation: fade .2s; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92%; overflow-y: auto;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--edge);
  border-radius: 28px 28px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 20px);
  max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--muted); opacity: .4; margin: 0 auto 4px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Barra schede ---------- */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--edge-dim); border-radius: 26px; box-shadow: var(--shadow), inset 0 1px 0 var(--edge);
  padding: 6px;
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; border-radius: 20px;
}
.tabs a .ti { font-size: 20px; filter: grayscale(1); opacity: .65; }
.tabs a.on { color: var(--accent); background: var(--accent-soft); }
.tabs a.on .ti { filter: none; opacity: 1; }
.badge {
  position: absolute; top: 1px; left: calc(50% + 7px); background: var(--bad); color: #fff;
  font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-weight: 700;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 96px);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  color: var(--ink); padding: 10px 16px; border-radius: 16px; z-index: 60; border: 1px solid var(--edge-dim);
  font-weight: 600; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}

.auth { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth .logo { font-size: 54px; text-align: center; }
.auth h1 { text-align: center; }
.auth .lead { text-align: center; color: var(--muted); }
.list-plain { display: flex; flex-direction: column; gap: 10px; }
.member { display: flex; align-items: center; gap: 10px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 24px; font-weight: 700; letter-spacing: .1em; text-align: center; padding: 10px; background: var(--glass-soft); border-radius: 14px; }

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