/* chiAPPulito — stile mobile-first.
   Token → base → shell → componenti → viste → animazioni → movimento ridotto. */

/* Font sul nostro server (licenza in fonts/OFL.txt): nessuna richiesta a Google, quindi nessun IP passato a terzi. */
@font-face { font-family: 'Inter'; font-weight: 400 700; font-display: swap; src: url(../fonts/inter.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 600 800; font-display: swap; src: url(../fonts/plus-jakarta-sans.woff2) format('woff2'); }

:root {
  --canvas: #F8F9FA;
  --card: #FFFFFF;
  --line: #E9ECEF;
  --line-strong: #DDE2E7;
  --ink: #1E293B;
  --ink-2: #475569;
  --ink-3: #94A3B8;
  --sage: #2D6A4F;
  --sage-soft: #E4F0E9;
  --amber: #D97706;
  --amber-ink: #B45309;
  --amber-soft: #FDF1DF;
  --cobalt: #2563EB;
  --cobalt-ink: #1D4ED8;
  --cobalt-soft: #E8F0FE;
  --danger: #B42318;
  /* Sage, cobalto e ambra fanno anche da fondo con il testo bianco: per testi e tratti c'è la versione
     "-text", che nel tema scuro si schiarisce. --ink-bg è la superficie scura (pillole, toast): resta scura. */
  --sage-text: var(--sage);
  --cobalt-text: var(--cobalt);
  --amber-text: var(--amber-ink);
  --ink-bg: #1E293B;
  --scrim: rgba(30, 41, 59, .38);

  --r-xl: 28px;
  --r-l: 20px;
  --r-m: 15px;
  --r-s: 11px;

  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  --display: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --gutter: 20px;
  --nav-h: 70px;
  color-scheme: light;
}

/* Tema scuro: segue il telefono. Cambiano solo i token; i componenti non lo sanno. */
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0F172A;
    --card: #1B2537;
    --line: #2A3649;
    --line-strong: #3A4860;
    --ink: #F1F5F9;
    --ink-2: #CBD5E1;
    --ink-3: #8696AD;
    --sage-soft: #1C3A2E;
    --amber-soft: #42301A;
    --cobalt-soft: #1D3461;
    --cobalt-ink: #A9C8FF;
    --danger: #F97066;
    --sage-text: #6CC9A0;
    --cobalt-text: #7EB0FF;
    --amber-text: #F2B25C;
    --ink-bg: #37465F;
    --scrim: rgba(2, 6, 23, .62);
    color-scheme: dark;
  }
  .avatar { box-shadow: 0 0 0 1px var(--line-strong); } /* i colori scuri delle persone non spariscono nel fondo */
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; } /* nota 38: niente zoom al doppio tocco, resta quello con due dita */
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-family: var(--display); letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ico.tiny { width: 13px; height: 13px; vertical-align: -2px; }
.ico.big { width: 44px; height: 44px; stroke-width: 1.5; color: var(--cobalt-text); }

/* ---------- Shell: cornice dispositivo, header, viste, barra schede ---------- */

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: var(--canvas);
}

/* Cornice solo su schermi davvero grandi: un telefono in orizzontale resta nel layout a tutto schermo (nota 24). */
@media (min-width: 560px) and (min-height: 521px) {
  body { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background: var(--line); }
  .app {
    height: min(900px, calc(100dvh - 48px));
    border-radius: 44px;
    box-shadow: 0 0 0 10px var(--card), 0 0 0 11px var(--line-strong), 0 50px 100px -40px rgba(30, 41, 59, .45);
  }
}

/* Header solido e "sticky": su iOS 26 le web app sfocano il bordo alto se non trovano un header fisso (nota beta). */
.topbar {
  position: sticky; top: 0;
  background: var(--canvas);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--gutter) 10px;
}
.brand {
  display: flex; align-items: center; gap: 8px; margin-right: auto;
  font: 800 19px/1 var(--display); letter-spacing: -0.035em;
}
.brand svg { width: 26px; height: 26px; }
.brand b, .wordmark span { color: var(--cobalt-text); font-weight: inherit; }

.lang {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}
.lang button {
  position: relative; z-index: 1;
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--ink-2);
  font: 600 12px/1 var(--ui);
  transition: color .3s;
}
.lang button[aria-pressed="true"] { color: #FFFFFF; }
.lang-knob {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--ink-bg);
  transition: transform .5s var(--spring);
}
.lang[data-lang="en"] .lang-knob { transform: translateX(100%); }
.lang:not(.ready) .lang-knob, .lang:not(.ready) button { transition: none; }
.me-btn { display: grid; border-radius: 50%; }

.view {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--gutter) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
}
.view:focus { outline: none; }
.view.enter-r > .screen { animation: enter-r .4s var(--ease-out) both; }
.view.enter-l > .screen { animation: enter-l .4s var(--ease-out) both; }

.tabbar {
  position: absolute; z-index: 6;
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(var(--n, 4), 1fr);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 18px 40px -18px rgba(30, 41, 59, .35);
}
.tab-pill {
  position: absolute; top: 6px; bottom: 6px; left: 6px;
  width: calc((100% - 12px) / var(--n, 4));
  border-radius: 20px;
  background: var(--ink-bg);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform .55s var(--spring);
}
.tab {
  position: relative; z-index: 1;
  display: grid; justify-items: center; gap: 3px;
  padding: 8px 4px 7px;
  color: var(--ink-2);
  font: 600 11px/1.1 var(--ui);
  transition: color .3s;
}
.tab .ico { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: #FFFFFF; }

/* ---------- Tipografia di pagina ---------- */

.hello { padding: 14px 0 6px; }
.hello h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.035em; }
.hello p { margin-top: 6px; color: var(--ink-2); }
.block { margin-top: 26px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-head h2 { font-size: 19px; font-weight: 700; }
.count {
  min-width: 26px; padding: 2px 9px;
  border-radius: 999px; background: var(--ink-bg); color: #FFFFFF;
  font: 600 12px/1.5 var(--ui); text-align: center;
}
.fine { margin-top: 8px; color: var(--ink-2); font-size: 13px; }
.empty {
  padding: 22px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-m);
  color: var(--ink-2); font-size: 14px; text-align: center;
}
.empty-state { display: grid; justify-items: center; gap: 14px; padding: 64px 12px; color: var(--ink-2); text-align: center; }

/* ---------- Pulsanti, chip, avatar ---------- */

.press { transition: transform .45s var(--spring), background-color .25s, color .25s; }
.press:active:not(:disabled) { transform: scale(.955); transition-duration: .12s; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px;
  border-radius: 999px;
  font: 600 14px/1 var(--ui);
  text-decoration: none; white-space: nowrap;
}
.btn .ico { width: 18px; height: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-primary { background: var(--cobalt); color: #FFFFFF; }
.btn-ink { background: var(--ink-bg); color: #FFFFFF; }
.btn-sage { background: var(--sage); color: #FFFFFF; }
.btn-amber { background: var(--amber-ink); color: #FFFFFF; }
.btn-quiet { border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn-done { min-width: 88px; }
.btn-done.is-done { background: var(--sage); }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 2px;
  color: var(--cobalt-ink); font-size: 14px; font-weight: 600;
}
.link-btn .ico { width: 18px; height: 18px; }
.link-btn:disabled { color: var(--ink-3); }

.icon-btn { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; color: var(--ink-2); }
.icon-btn:hover:not(:disabled) { background: var(--line); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--canvas); color: var(--ink-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip .ico { width: 14px; height: 14px; }
.chip-amber { border-color: transparent; background: var(--amber-soft); color: var(--amber-text); font-weight: 600; }
.chip.on { border-color: transparent; background: var(--sage-soft); color: var(--sage-text); font-weight: 600; }

.status {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status.s-pending, .status.s-due { background: var(--cobalt-soft); color: var(--cobalt-ink); }
.status.s-approved, .status.s-settled { background: var(--sage-soft); color: var(--sage-text); }
.status.s-disputed, .status.s-overdue { background: var(--amber-soft); color: var(--amber-text); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c); color: #FFFFFF;
  font: 700 14px/1 var(--display);
}
.avatar.xs { width: 18px; height: 18px; font-size: 10px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.xl { width: 76px; height: 76px; font-size: 30px; }

/* ---------- Casa: stanze ---------- */

.rooms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room {
  display: grid; align-content: start; gap: 3px;
  min-height: 150px; padding: 16px;
  border: 1px solid var(--line); border-radius: var(--r-l);
  background: var(--card);
  text-align: left;
}
.room:first-child { grid-column: span 2; min-height: 122px; }
.room-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.room-ico { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.room-badge {
  min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; background: var(--amber-soft); color: var(--amber-text);
  font: 700 12px/24px var(--ui); text-align: center;
}
.room-name { font: 700 17px/1.2 var(--display); letter-spacing: -0.02em; }
.room-meta { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.room-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 12px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.dot.s-fresh { background: var(--sage); }
.dot.s-growing { background: var(--ink-3); }
.dot.s-due { background: var(--cobalt); }
.dot.s-overdue { background: var(--amber); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; color: var(--ink-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Schede attività ---------- */

.task-list { display: grid; gap: 10px; }
.task {
  padding: 16px 16px 14px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
}
.task.s-overdue { border-color: color-mix(in srgb, var(--amber) 32%, var(--card)); }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-text h3 { font: 600 16px/1.3 var(--ui); letter-spacing: -0.01em; }
.task-text p { margin-top: 3px; color: var(--ink-2); font-size: 13px; }
.task-value { line-height: 1; text-align: right; white-space: nowrap; }
.task-value strong { font: 800 25px/1 var(--display); letter-spacing: -0.035em; }
.task-value span { margin-left: 3px; color: var(--ink-2); font-size: 12px; font-weight: 600; }

/* Barra del valore: 0–120%, la tacca segna il 100% (= frequenza raggiunta). */
.growth {
  position: relative;
  height: 6px; margin: 14px 0 12px;
  border-radius: 999px; background: var(--line);
  overflow: hidden;
}
.growth i {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: calc(var(--f) * 100%);
  border-radius: inherit; background: var(--ink-2);
}
.growth::after { content: ''; position: absolute; top: 0; bottom: 0; left: 83.333%; width: 2px; background: var(--card); }
.s-fresh .growth i { background: var(--sage); }
.s-due .growth i { background: var(--cobalt); }
.s-overdue .growth i { background: var(--amber); }

.task-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.task-actions { display: flex; flex: none; align-items: center; gap: 4px; }

.tick { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tick path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.is-done .tick path, .ok-badge .tick path { stroke-dashoffset: 0; }
.just-done .tick path { animation: draw .5s .05s var(--ease-out) both; }

/* ---------- Convalide ---------- */

.reviews {
  display: flex; gap: 10px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter) 6px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none;
}
.reviews::-webkit-scrollbar { display: none; }
.review {
  flex: 0 0 86%;
  padding: 14px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
  scroll-snap-align: start;
}
.review:only-child { flex-basis: 100%; }
.review-who { display: flex; align-items: center; gap: 10px; }
.review-who div { flex: 1; min-width: 0; }
.review-who h3 { overflow: hidden; font: 600 15px/1.3 var(--ui); text-overflow: ellipsis; white-space: nowrap; }
.review-who p { color: var(--ink-2); font-size: 12px; }
.review-who strong { color: var(--sage-text); font: 800 16px/1 var(--display); white-space: nowrap; }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* ---------- Collaboratrice: lista di oggi ---------- */

.checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.toggle {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  width: 100%; padding: 16px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
  text-align: left;
}
.toggle:disabled { cursor: default; }
.toggle-box {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 2px solid var(--line-strong); border-radius: 11px;
  color: #FFFFFF;
  transition: background-color .25s, border-color .25s;
}
.is-done .toggle-box { border-color: var(--sage); background: var(--sage); }
.check-text { display: grid; min-width: 0; }
.check-text strong { font-size: 16px; font-weight: 600; }
.check-text small { color: var(--ink-2); font-size: 13px; }
.is-done .check-text strong { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }

/* ---------- Equità: arco del tiro alla fune ---------- */

.seg {
  position: relative;
  display: inline-grid; grid-template-columns: 1fr 1fr;
  margin-top: 14px; padding: 3px;
  border-radius: 999px; background: var(--line);
}
.seg button { position: relative; z-index: 1; padding: 7px 16px; color: var(--ink-2); font-size: 13px; font-weight: 600; transition: color .3s; }
.seg button[aria-checked="true"] { color: var(--ink); }
.seg-knob {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px; background: var(--card);
  box-shadow: 0 1px 3px rgba(30, 41, 59, .14);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform .5s var(--spring);
}

.arc {
  margin: 18px 0 0; padding: 22px 18px 18px;
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--card);
}
.arc-stage { position: relative; }
.arc-svg { display: block; width: 100%; height: auto; overflow: visible; }
.arc-svg path { fill: none; stroke-width: 18; stroke-linecap: round; }
.arc-track { stroke: var(--line); }
.arc-a { stroke: var(--ca); stroke-dasharray: 50 200; }
.arc-b { stroke: var(--cb); stroke-dasharray: 50 200; }
.arc-mid { stroke: var(--ink-3); stroke-width: 2; stroke-dasharray: 3 4; }
.arc-knot { fill: var(--card); stroke: var(--ink); stroke-width: 3.5; }
.arc.is-balanced .arc-knot { fill: var(--sage-soft); stroke: var(--sage-text); }
.arc.is-balanced .arc-mid { stroke: var(--sage-text); stroke-dasharray: none; }
.arc-status {
  position: absolute; left: 50%; bottom: 2px;
  width: 64%;
  transform: translateX(-50%);
  color: var(--ink-2); font: 600 14px/1.35 var(--ui); text-align: center; text-wrap: balance;
}
.arc.is-balanced .arc-status { color: var(--sage-text); }
.arc-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.arc-side { display: grid; justify-items: start; gap: 3px; }
.arc-side.right { justify-items: end; text-align: right; }
.arc-big { color: var(--ca); font: 800 54px/.95 var(--display); letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.arc-side.right .arc-big { color: var(--cb); }
.arc-big small { margin-left: 2px; font-size: 24px; letter-spacing: 0; }
.arc-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.arc-side.right .arc-name { flex-direction: row-reverse; }
.arc-meta { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Nota 36, coinquilini: con tre o più adulti una barra a testa e la tacca della parte giusta */
.shares {
  margin: 18px 0 0; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--card);
}
.shares-status { color: var(--ink-2); font: 600 15px/1.35 var(--ui); }
.shares.is-balanced .shares-status { color: var(--sage-text); }
.shares ul { display: grid; gap: 14px; margin: 14px 0 12px; padding: 0; list-style: none; }
.shares li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; }
.shares li strong { color: var(--c); font: 800 28px/1 var(--display); letter-spacing: -0.04em; }
.shares li strong small { margin-left: 1px; font-size: 15px; letter-spacing: 0; }
.shares .arc-meta { grid-column: 1 / -1; }
.share-bar { position: relative; grid-column: 1 / -1; height: 10px; border-radius: 999px; background: var(--line); }
.share-bar::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w);
  border-radius: 999px; background: var(--c);
  transform-origin: left; animation: share-grow .9s var(--ease-out) both;
}
.share-bar::after { content: ''; position: absolute; top: -4px; bottom: -4px; left: var(--fair); width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink-3); }
.shares.is-balanced .share-bar::after { background: var(--sage); }
@keyframes share-grow { from { transform: scaleX(0); } }

/* Nota 37: filtro per persona sopra le ultime attività */
.feed-filter { margin: 0 0 10px; }
.feed-filter .chip { height: 34px; padding: 0 12px 0 8px; font-size: 13px; cursor: pointer; }
.feed-filter .chip:first-child { padding-left: 12px; }
.feed-filter .chip.on { background: var(--ink); color: var(--card); }
.feed-more { margin-top: 10px; }

.proposal { margin-top: 14px; }
.proposal > p { color: var(--ink-2); font-size: 14px; }
.suggestions { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.suggestion {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 14px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
}
.suggestion h3 { font: 600 15px/1.3 var(--ui); }
.suggestion p { color: var(--ink-2); font-size: 12px; }
.suggestion strong { font: 800 22px/1 var(--display); letter-spacing: -0.03em; }
.suggestion strong small { margin-left: 3px; color: var(--ink-2); font: 600 12px/1 var(--ui); letter-spacing: 0; }
.suggestion .btn { grid-column: 1 / -1; justify-self: start; margin-top: 8px; }
.reveal .suggestion { animation: rise .55s calc(var(--i) * 90ms) var(--spring) both; }

.feed, .log, .tags {
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
}
.feed-item { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 12px; padding: 12px 14px; }
.feed-item + .feed-item, .log-item + .log-item, .tags li + li { border-top: 1px solid var(--line); }
.feed-text { min-width: 0; }
.feed-text p { font-size: 14px; line-height: 1.35; }
.feed-text small { color: var(--ink-2); font-size: 12px; }
.feed-text blockquote {
  margin: 6px 0 0; padding: 6px 10px;
  border-radius: 9px; background: var(--amber-soft); color: var(--amber-text);
  font-size: 13px;
}
.feed-side { display: grid; justify-items: end; gap: 4px; font-size: 13px; }
.feed-side .link-btn { padding: 0; font-size: 13px; }

/* ---------- Famiglia: portafogli ---------- */

.wallets { display: grid; gap: 12px; margin-top: 18px; }
.wallet { padding: 18px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); }
.wallet header { display: flex; align-items: center; gap: 12px; }
.wallet header div { flex: 1; }
.wallet h2 { font-size: 18px; }
.wallet header p { color: var(--ink-2); font-size: 13px; }
.wallet-balance { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 16px 0; }
.wallet-balance small { width: 100%; color: var(--ink-2); font-size: 13px; }
.wallet-balance strong { font: 800 40px/1 var(--display); letter-spacing: -0.045em; }
.wallet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }

.wallet-hero {
  display: grid; gap: 6px;
  margin-top: 14px; padding: 20px;
  border-radius: var(--r-xl);
  background: var(--ink-bg); color: #FFFFFF;
}
.wallet-who { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.wallet-hero h2 { font-size: 18px; }
.wallet-hero p, .wallet-hero small { color: #CBD5E1; font-size: 13px; }
.num.huge { font: 800 50px/1 var(--display); letter-spacing: -0.05em; }
.wallet-hero .chip { justify-self: start; border-color: transparent; background: rgba(255, 255, 255, .12); color: #E2E8F0; }
.wallet-hero .btn { justify-self: start; margin-top: 10px; background: #FFFFFF; color: var(--ink); }
.wallet-hero .btn:disabled { background: rgba(255, 255, 255, .14); color: #CBD5E1; opacity: 1; }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav h3 { font-size: 17px; text-transform: capitalize; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 14px; }
.totals div { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card); }
.totals dt { color: var(--ink-2); font-size: 12px; }
.totals dd { margin: 5px 0 0; font: 700 19px/1 var(--display); letter-spacing: -0.02em; }

.log-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 12px 14px; font-size: 14px; }
.log-item div { display: grid; min-width: 0; }
.log-item strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.log-item small { color: var(--ink-2); font-size: 12px; }


/* ---------- NFC & Extra ---------- */

.card { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); }
.card h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.card p { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.nfc-card { display: grid; justify-items: center; padding-top: 24px; text-align: center; }
.radar-mini { width: 92px; height: 92px; margin-bottom: 10px; }
.radar-mini circle { fill: none; stroke: var(--cobalt); stroke-width: 1.5; opacity: .25; }
.radar-mini circle:nth-child(2) { opacity: .5; }
.radar-mini .core { fill: var(--cobalt); stroke: none; opacity: 1; }
.radar-mini use, .radar .radar-ico { fill: none; stroke: #FFFFFF; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tags li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.tags li > span { display: grid; flex: 1; min-width: 0; font-size: 14px; font-weight: 500; }
.tags small { color: var(--ink-2); font-size: 12px; font-weight: 400; }
.tags .link-btn { font-size: 13px; }

.profile-row { display: flex; align-items: center; gap: 14px; }
.profile-row > div { flex: 1; }
.profile-row p { margin-top: 2px; }

/* ---------- Configura la casa ---------- */

.setup-cta {
  display: flex; align-items: center; gap: 14px;
  width: 100%; margin-top: 16px; padding: 16px;
  border: 1px solid var(--line); border-radius: var(--r-l);
  background: var(--card);
  text-align: left;
}
.setup-cta > .ico:first-child { width: 26px; height: 26px; color: var(--cobalt-text); }
.setup-cta > span { display: grid; flex: 1; }
.setup-cta strong { font: 700 16px/1.25 var(--display); }
.setup-cta small { color: var(--ink-2); font-size: 13px; }
.setup-cta > .ico:last-child { color: var(--ink-3); }
.screen > .setup-cta { margin-top: 10px; }

.sheet-title { margin-bottom: 4px; font-size: 24px; font-weight: 800; }
.steps { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.step {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 14px;
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--card);
  text-align: left;
}
.step-num {
  grid-row: span 2;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%; background: var(--ink-bg); color: #FFFFFF;
  font: 800 15px/1 var(--display);
}
.step-text { display: grid; }
.step-text strong { font: 700 16px/1.25 var(--display); }
.step-text small { color: var(--ink-2); font-size: 13px; }
.step-status { display: inline-flex; align-items: center; gap: 6px; color: var(--cobalt-ink); font-size: 13px; font-weight: 600; }
.step-status .ico { width: 16px; height: 16px; }

.rooms-list { margin-top: 14px; }
.rooms-list .room-ico, .pick-list legend .room-ico { width: 24px; height: 24px; flex: none; }

.icon-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; border: 0; }
.icon-pick legend { margin-bottom: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.icon-pick label {
  display: grid; justify-items: center; gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
  font-size: 11px; color: var(--ink-2); text-align: center; cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick label:has(input:checked) { border-color: var(--cobalt); background: var(--cobalt-soft); color: var(--cobalt-ink); }
.icon-pick label:has(input:focus-visible) { outline: 2px solid var(--cobalt); outline-offset: 2px; }

.pick-list, .price-list { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.pick-list legend, .price-list legend { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; font: 700 15px/1 var(--display); }
.pick {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}
.pick input { width: 20px; height: 20px; flex: none; accent-color: var(--cobalt); }
.pick span { display: grid; }
.pick strong { font-size: 14px; font-weight: 600; }
.pick small { color: var(--ink-2); font-size: 12px; }
.pick:has(input:checked) { border-color: var(--cobalt); background: var(--cobalt-soft); }

.growth-chart { margin: 4px 0 6px; padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); }
.growth-chart svg { display: block; width: 100%; height: auto; }
.gc-axis { stroke: var(--line-strong); stroke-width: 1.5; }
.gc-full { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; }
.gc-line { fill: none; stroke: var(--sage-text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.gc-dot { fill: var(--card); stroke: var(--sage-text); stroke-width: 2.5; }
.gc-bonus { stroke: var(--amber); }
.growth-chart figcaption { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; color: var(--ink-2); font-size: 12px; line-height: 1.3; }
.growth-chart figcaption span { display: grid; gap: 2px; }
.growth-chart figcaption b { color: var(--ink); font: 800 17px/1 var(--display); }
.growth-chart figcaption span:last-child b { color: var(--amber-text); }

.price-row {
  display: grid; grid-template-columns: 1fr 86px 86px; align-items: end; gap: 6px 8px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
}
.price-row > strong { align-self: center; font-size: 14px; font-weight: 600; }
.field.mini { gap: 3px; font-size: 11px; }
.field.mini input { min-height: 40px; padding: 8px 10px; font-size: 16px; font-variant-numeric: tabular-nums; }
.price-hint { grid-column: 1 / -1; color: var(--ink-2); font-size: 12px; }


/* ---------- Wizard di prima configurazione ---------- */

.view.bare { padding-bottom: 24px; }
.wz-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.wz-progress i { height: 5px; border-radius: 999px; background: var(--line-strong); transition: background-color .4s; }
.wz-progress i.on { background: var(--cobalt); }
.wz-count { margin-top: 8px; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.wizard .hello { padding-top: 6px; }
.wizard .login-hero { margin-bottom: 26px; }
.wz-plan { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.wz-plan li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); }
.wz-plan li > span:last-child { display: grid; }
.wz-plan strong { font: 700 15px/1.25 var(--display); }
.wz-plan small { color: var(--ink-2); font-size: 13px; }
.center { text-align: center; }

.wz-people { display: grid; gap: 10px; margin-top: 16px; }
.person-card { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); }
.person-head { display: flex; align-items: center; gap: 10px; }
.person-head strong { flex: 1; font: 700 16px/1.2 var(--display); }
.person-card .fine { margin-top: -2px; }
.wz-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.wz-add > span { width: 100%; color: var(--ink-2); font-size: 13px; font-weight: 600; }

.wz-rooms { margin-top: 16px; }
.icon-pick label { position: relative; }
.wz-room-add {
  display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 10px;
  margin-top: 16px; padding: 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-m);
}
.wz-room-add .btn { grid-column: 1 / -1; }

.wz-loads { display: grid; gap: 6px; margin-top: 16px; }
.load-row { grid-template-columns: 1fr 96px; }
.load-row.no-euro { grid-template-columns: 1fr; }
.load-row > strong { display: grid; grid-column: 1 / -1; }
.load-row > strong small { color: var(--ink-2); font-size: 12px; font-weight: 400; }
.field.mini select { min-height: 40px; padding: 8px 10px; font-size: 15px; }

.wz-totals { margin-top: 16px; }
.wz-person { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; }
.wz-person + .wz-person { border-top: 1px solid var(--line); }
.wz-person div { display: grid; }
.wz-person small { color: var(--ink-2); font-size: 12px; }
.wz-error { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--amber-soft); color: var(--amber-text); font-size: 14px; font-weight: 600; }
.wz-nav {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; gap: 10px;
  margin: 22px calc(-1 * var(--gutter)) 0;
  padding: 14px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 72%, transparent);
}
.wz-nav .btn { flex: 1; }
.wz-nav .btn-primary { flex: 2; }

/* ---------- Note beta e zona pericolosa ---------- */

.beta-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--cobalt-ink);
  font: 700 12px/1 var(--ui);
}
.beta-btn .ico { width: 16px; height: 16px; }
.seg-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; }
.seg-pick label { position: relative; }
.seg-pick input { position: absolute; opacity: 0; pointer-events: none; }
.seg-pick span {
  display: grid; place-items: center; height: 40px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--card); color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-pick input:checked + span { border-color: var(--cobalt); background: var(--cobalt-soft); color: var(--cobalt-ink); }
.seg-pick input:focus-visible + span { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.notes { margin-top: 14px; }
.note-item { display: grid; gap: 6px; padding: 12px 14px; }
.note-item + .note-item { border-top: 1px solid var(--line); }
.note-item p { font-size: 14px; white-space: pre-wrap; }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-head small, .note-ctx { color: var(--ink-2); font-size: 12px; }
.note-item .link-btn { justify-self: start; padding: 0; font-size: 13px; }
.note-item.is-closed p { color: var(--ink-3); text-decoration: line-through; }
.note-item blockquote { margin: 0; padding: 6px 10px; border-radius: 9px; background: var(--cobalt-soft); color: var(--cobalt-ink); font-size: 13px; white-space: pre-wrap; }
.note-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.notes-house { margin: 18px 0 8px; font-size: 16px; }
.notes-closed summary { padding: 10px 2px; color: var(--ink-2); font-size: 14px; cursor: pointer; }
.notes-closed .notes { margin-top: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 26%, var(--card)); }
.danger-zone h2 { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Agenda, porzioni, gesti (note beta) ---------- */

.days { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin-bottom: 12px; }
.day-pill {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: calc((100% - 35px) / 8);
  border-radius: 14px; background: var(--ink-bg);
  transform: translateX(calc(var(--d, 0) * (100% + 5px)));
  transition: transform .45s var(--spring);
}
.day {
  position: relative;
  display: grid; justify-items: center; gap: 2px;
  padding: 8px 0 10px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink-2);
  transition: background-color .25s, color .25s, border-color .25s;
}
.day small { font-size: 11px; font-weight: 600; text-transform: capitalize; }
.day strong { color: var(--ink); font: 800 18px/1 var(--display); }
.day-count { min-height: 14px; color: var(--amber-text); font-size: 11px; font-weight: 700; }
.day { z-index: 1; }
.day.on { border-color: transparent; background: transparent; color: #CBD5E1; }
.day.on strong { color: #FFFFFF; }
.day.on .day-count { color: #FCD34D; }
.agenda-list { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card); }
.agenda-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.agenda-row + .agenda-row { border-top: 1px solid var(--line); }
.agenda-row .room-ico { width: 22px; height: 22px; }
.agenda-row > div { display: grid; flex: 1; min-width: 0; }
.agenda-row .icon-btn { width: 34px; height: 34px; }
.agenda-row strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row small { color: var(--ink-2); font-size: 12px; }
.agenda-row.s-overdue small { color: var(--amber-text); }
.agenda-pts { font: 800 16px/1 var(--display); white-space: nowrap; }
.agenda-pts small { margin-left: 2px; color: var(--ink-2); font: 600 11px/1 var(--ui); }
.agenda-row .btn.sm { min-height: 34px; min-width: 0; padding: 0 12px; }
.agenda-sub { margin: 16px 0 8px; font-size: 15px; }
.agenda-list.is-done strong { color: var(--ink-2); }
.ico.ok { color: var(--sage-text); }

.chip-cobalt { border-color: transparent; background: var(--cobalt-soft); color: var(--cobalt-ink); font-weight: 600; }
.portion-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; width: 100%; margin-top: 4px; }
.check-line { display: flex; align-items: flex-start; gap: 10px; color: var(--ink); font-size: 14px; cursor: pointer; }
.check-line input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--cobalt); }

.pick-row { display: grid; }
.pick-tune {
  display: none; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 8px 14px 12px;
  border: 1px solid var(--cobalt); border-top: 0; border-radius: 0 0 12px 12px;
  background: var(--cobalt-soft);
}
.pick-row:has(input[type="checkbox"]:checked) .pick { border-radius: 12px 12px 0 0; }
.pick-row:has(input[type="checkbox"]:checked) .pick-tune { display: grid; }

.pull {
  position: absolute; z-index: 4; left: 50%; top: calc(66px + env(safe-area-inset-top));
  display: grid; place-items: center;
  width: 38px; height: 38px; margin-left: -19px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--cobalt-text);
  box-shadow: 0 6px 18px -8px rgba(30, 41, 59, .35);
  opacity: var(--pull, 0);
  transform: translateY(calc(var(--pull, 0) * 26px - 26px)) rotate(calc(var(--pull, 0) * 300deg));
  pointer-events: none;
}
.pull.ready { color: var(--sage-text); }
.pull.loading { opacity: 1; transform: translateY(0); transition: opacity .2s; }
.pull.loading .ico { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.agenda-body.slide-r { animation: agenda-in-r .32s var(--ease-out) both; }
.agenda-body.slide-l { animation: agenda-in-l .32s var(--ease-out) both; }
@keyframes agenda-in-r { from { opacity: 0; transform: translateX(22px); } }
@keyframes agenda-in-l { from { opacity: 0; transform: translateX(-22px); } }

.lang-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pick .avatar { flex: none; }

/* Solo verticale: su iPhone il manifest non basta, in orizzontale copriamo l'app con un invito a ruotare. */
.rotate-hint { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  .rotate-hint {
    position: absolute; inset: 0; z-index: 100; /* non fixed: vedi nota 31 */
    display: grid; place-content: center; justify-items: center; gap: 14px;
    background: var(--canvas); color: var(--ink);
    font: 700 18px/1.3 var(--display); text-align: center;
  }
  .rotate-hint .ico { width: 54px; height: 54px; color: var(--cobalt-text); animation: tilt 1.6s ease-in-out infinite; }
}
@keyframes tilt { 50% { transform: rotate(-90deg); } }

/* La pagina non scorre mai, scorre solo l'area centrale: su iOS il documento non rimbalza
   e la barra in alto resta ferma anche quando il contenuto è corto (note beta 2 e 15).
   Nota 31: niente position: fixed. Su iOS, dopo una rotazione, WebKit sposta i tocchi rispetto a dove
   disegna gli elementi fixed (bug WebKit 235684) e la barra in basso smetteva di rispondere.
   Il guscio sta nel flusso normale e occupa l'altezza della pagina. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
@media (max-width: 559px), (max-height: 520px) {
  .app { height: 100%; }
}
.view > .screen { min-height: calc(100% + 1px); } /* sempre scrollabile: il gesto resta dentro la vista */

.push-state { margin-top: 12px; }
.push-on { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--sage-text); font-size: 14px; font-weight: 600; }

/* Equità: al cambio periodo i testi si dissolvono invece di saltare (nota 17). */
.arc-status.swap { animation: status-swap .45s var(--ease-out) both; }
.arc-meta.swap { animation: meta-swap .45s var(--ease-out) both; }
@keyframes status-swap { from { opacity: 0; transform: translate(-50%, 4px); } }
@keyframes meta-swap { from { opacity: 0; } }

.people-list { margin-top: 12px; }
.people-list .avatar { flex: none; }

/* ---------- Bottom sheet e moduli ---------- */

.sheet-layer { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .3s; }
.sheet {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-height: 90%;
  border-radius: 28px 28px 0 0;
  background: var(--canvas);
  box-shadow: 0 -20px 50px -20px rgba(30, 41, 59, .4);
  transform: translateY(105%);
  transition: transform .42s cubic-bezier(.32, .72, 0, 1);  /* curva tipo iOS: arriva e si aggancia, senza rimbalzo */
}
.sheet:focus { outline: none; }
.sheet-layer:not(.open) { pointer-events: none; } /* mentre si chiude non trattiene i tocchi (nota 28) */
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet-layer.open .sheet { transform: none; }
.sheet-top { position: relative; flex: none; display: grid; place-items: center; height: 36px; touch-action: none; cursor: grab; }
.sheet-grip { width: 44px; height: 5px; border-radius: 999px; background: var(--line-strong); }
.sheet-x { position: absolute; top: 2px; right: 8px; width: 34px; height: 34px; }
.sheet-x .ico { width: 18px; height: 18px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 10px var(--gutter) calc(26px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.sheet-head h2 { font-size: 24px; font-weight: 800; }
.sheet-body .wallet-hero { margin-top: 0; }

.form { display: grid; gap: 12px; }
.form + .form { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.form h2 { font-size: 22px; font-weight: 800; }
.form h3 { font-size: 17px; }
.form .fine { margin-top: 0; }
.field { display: grid; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-size: 16px; font-weight: 400;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: transparent; outline: 2px solid var(--cobalt); outline-offset: -1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-extra { display: flex; flex-wrap: wrap; gap: 8px; }

.survey fieldset { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.survey legend { margin: 10px 0 8px; font: 700 15px/1 var(--display); }
.scale-legend { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 12px; }
.vote {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
}
.vote-name { display: grid; color: var(--ink); font-size: 14px; font-weight: 600; }
.vote-name small { color: var(--ink-2); font-size: 12px; font-weight: 400; }
.vote output { min-width: 2ch; color: var(--cobalt-text); font: 800 22px/1 var(--display); text-align: right; }
.vote input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--cobalt); }

.confirm, .tag-link, .radar-wrap { display: grid; justify-items: center; gap: 10px; padding-top: 6px; text-align: center; }
.confirm h2, .tag-link h2, .radar-wrap h2 { font-size: 22px; }
.confirm p, .tag-link p { color: var(--ink-2); }
.ok-badge { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--sage); color: #FFFFFF; }
.ok-badge .tick { width: 28px; height: 28px; }
.link-box {
  display: block; width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
  font: 500 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left; word-break: break-all; user-select: all;
}

.radar { width: 210px; height: 210px; }
.radar .wave {
  fill: none; stroke: var(--cobalt); stroke-width: 1.5;
  opacity: 0;
  transform-box: fill-box; transform-origin: center;
  animation: ping 2.4s var(--ease-out) infinite;
}
.radar .wave:nth-child(2) { animation-delay: .8s; }
.radar .wave:nth-child(3) { animation-delay: 1.6s; }
.radar-core { fill: var(--cobalt); animation: pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

/* ---------- Accesso ---------- */

.login { padding-top: 5vh; }
.login-hero { display: grid; justify-items: center; margin-bottom: 34px; text-align: center; }
.mark-hero { width: 84px; height: 84px; overflow: visible; }
.mark-hero .mk-bubble { fill: var(--cobalt); }
.mark-hero .mk-check { fill: none; stroke: #FFFFFF; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.mark-hero .mk-glint { fill: var(--amber); stroke: var(--canvas); stroke-width: 1.6; stroke-linejoin: round; }
.wordmark { margin-top: 14px; font: 800 clamp(40px, 12.5vw, 54px)/1 var(--display); letter-spacing: -0.05em; }
.tagline { margin-top: 10px; color: var(--ink-2); font-size: 16px; }
.login-q { margin-bottom: 12px; font-size: 18px; }
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile {
  display: grid; justify-items: center; gap: 6px;
  padding: 18px 10px;
  border: 1px solid var(--line); border-radius: var(--r-l);
  background: var(--card);
}
.profile strong { font: 700 16px/1.2 var(--display); }
.profile small { color: var(--ink-2); font-size: 12px; }

.pin { display: grid; justify-items: center; gap: 14px; padding-top: 4px; }
.pin > .link-btn { justify-self: start; }
.pin-head { display: grid; justify-items: center; gap: 12px; margin-top: 6px; }
.pin-head h2 { font-size: 22px; }
.pin-dots { display: flex; align-items: center; gap: 14px; height: 20px; margin-top: 4px; }
.pin-dots i {
  width: 14px; height: 14px;
  border: 2px solid var(--ink-3); border-radius: 50%;
  transition: background-color .2s, border-color .2s, transform .35s var(--spring);
}
.pin-dots i.on { border-color: var(--ink); background: var(--ink); transform: scale(1.12); }
.pin-dots.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both; }
.pin-dots.checking i { animation: breathe .9s ease-in-out infinite; }
.pin-dots.checking i:nth-child(2) { animation-delay: .15s; }
.pin-dots.checking i:nth-child(3) { animation-delay: .3s; }
.pin-dots.checking i:nth-child(4) { animation-delay: .45s; }
.pin-error { min-height: 20px; color: var(--amber-text); font-size: 14px; font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 24px; }
.key {
  display: grid; place-items: center;
  width: 72px; height: 72px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card);
  font: 600 26px/1 var(--display); font-variant-numeric: tabular-nums;
}
.key .ico { width: 26px; height: 26px; }
.key-soft { border-color: transparent; background: transparent; }
.key-go { border-color: var(--cobalt); background: var(--cobalt); color: #FFFFFF; }

/* ---------- Toast ed effetti ---------- */

.toast {
  position: absolute; z-index: 30;
  left: 16px; right: 16px; bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px 13px 16px;
  border-radius: 16px;
  background: var(--ink-bg); color: #FFFFFF;
  box-shadow: 0 16px 40px -16px rgba(30, 41, 59, .6);
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transform: translateY(20px);
  transition: transform .45s var(--spring), opacity .25s;
}
/* Nota 28: il toast copre la fascia dei tasti sopra la barra; prende i tocchi solo il suo pulsante, il resto passa sotto. */
.toast.show { opacity: 1; transform: none; }
.toast.show .toast-btn { pointer-events: auto; }
/* Con un pannello aperto il toast sale in alto, per non coprire campi e pulsanti. */
.sheet-layer:not([hidden]) ~ .toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
.sheet-layer:not([hidden]) ~ .toast:not(.show) { transform: translateY(-20px); }
.toast[data-tone="warn"] { background: var(--amber-ink); }
.toast span { flex: 1; }
.toast-btn { color: #BFDBFE; font-weight: 700; }
.toast[data-tone="warn"] .toast-btn { color: #FFFFFF; }

.fx { position: absolute; inset: 0; z-index: 40; overflow: hidden; pointer-events: none; }
.particle { position: absolute; width: 8px; height: 8px; border-radius: 2px; }
.fx-badge {
  position: absolute;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--sage); color: #FFFFFF;
  box-shadow: 0 10px 24px -10px rgba(45, 106, 79, .75);
  font: 800 15px/1 var(--display); white-space: nowrap;
  transform: translate(-50%, -50%);
}

.sk {
  border-radius: var(--r-m);
  background: linear-gradient(90deg, var(--line) 0%, var(--canvas) 45%, var(--line) 90%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk-title { width: 62%; height: 34px; margin: 18px 0 18px; border-radius: 10px; }
.sk-card { height: 112px; margin-top: 10px; }

/* ---------- Animazioni ---------- */

@keyframes enter-r { from { opacity: 0; transform: translateX(28px); } }
@keyframes enter-l { from { opacity: 0; transform: translateX(-28px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes ping { 0% { opacity: .9; transform: scale(.36); } 100% { opacity: 0; transform: scale(1); } }
@keyframes breathe { 50% { transform: scale(.7); opacity: .5; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
@keyframes bubble-pop {
  0% { opacity: 0; transform: scale(.4); }
  60% { opacity: 1; transform: scale(1.08); }
  80% { transform: scale(.97); }
}
@keyframes glint {
  0% { opacity: 0; transform: scale(0) rotate(-120deg); }
  70% { opacity: 1; transform: scale(1.35) rotate(12deg); }
}

/* Unico momento orchestrato: il fumetto "chi?" si apre, la spunta risponde, poi la scintilla e il nome. */
.mark-hero .mk-bubble { transform-box: fill-box; transform-origin: 25% 100%; animation: bubble-pop .7s var(--ease-out) both; }
.mark-hero .mk-check { stroke-dasharray: 1; animation: draw .45s .5s var(--ease-out) both; }
.mark-hero .mk-glint { transform-box: fill-box; transform-origin: center; animation: glint .6s .7s var(--spring) both; }
.login-hero .wordmark { animation: rise .6s .85s var(--spring) both; }
.login-hero .tagline { animation: rise .6s .95s var(--spring) both; }
.no-intro .login-hero *, .no-intro .mark-hero * { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .radar .wave { animation: none; opacity: .3; transform: scale(.7); }
  .radar .wave:nth-child(2) { transform: scale(.85); }
  .radar .wave:nth-child(3) { transform: scale(1); }
}

/* ---------- Al bisogno, paghetta e guadagni (note beta 22 e 23) ---------- */

.dot.s-ready { background: var(--card); box-shadow: inset 0 0 0 2px var(--cobalt); }
.s-ready .growth i { background: var(--cobalt); }
.form [data-kid] { display: grid; gap: 12px; }
.suggest-row { display: flex; align-items: flex-end; gap: 10px; }
.suggest-row .field { flex: 1; }
.suggest-row .btn { min-height: 40px; }
.wz-loads { margin-top: 12px; }

/* Barre dei guadagni: una tinta, estremità arrotondate di 4px ancorate alla base, 2px tra le barre. */
.bars {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px;
  height: 132px; padding: 12px 8px 8px;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--card);
}
.bar { display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: 6px; min-width: 0; height: 100%; }
.bar i {
  align-self: end; width: 100%; max-width: 16px;
  height: calc(var(--h) * 100%); min-height: 2px;
  border-radius: 4px 4px 0 0; background: var(--sage); opacity: .4;
  transition: opacity .2s;
}
.bar.on i, .bar:hover i { opacity: 1; }
.bar small { color: var(--ink-3); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.bar.on small { color: var(--ink); }
.bars + .log { margin-top: 10px; }

/* Cerca attività (nota 27) */
.search { position: relative; display: flex; align-items: center; margin-top: 12px; }
.search .ico { position: absolute; left: 14px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; min-height: 46px; padding: 10px 14px 10px 42px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); font-size: 16px;
}
.search input:focus { border-color: transparent; outline: 2px solid var(--cobalt); outline-offset: -1px; }
#search-results .block { margin-top: 14px; }

/* Pesantezza al "Fatto" (nota 29) */
.weight-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; margin-top: 4px; }
.weight-grid .btn { flex-direction: column; gap: 3px; min-height: 60px; padding: 8px 2px; border-radius: 16px; }
.weight-grid strong { font-size: 17px; }
.weight-grid small { font-size: 11px; font-weight: 600; opacity: .8; }
/* Punti scritti a mano (nota 33) */
.manual-points { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; width: 100%; margin-top: 6px; text-align: left; }
.manual-points .btn { min-height: 48px; }
.seg-pick legend { margin-bottom: 6px; padding: 0; color: var(--ink-2); font-size: 13px; font-weight: 600; }
/* Elenco di persone dentro un modulo: il titolo come le altre etichette, non come un titolo di sezione */
.pick-list legend.field-legend { margin: 0 0 6px; padding: 0; color: var(--ink-2); font: 600 13px/1.3 var(--ui); }
.seg-tall { grid-template-columns: repeat(5, 1fr); } /* pesantezza con anteprima dei punti (note 32 e 33) */
.seg-tall span { height: 56px; align-content: center; gap: 2px; }
.seg-tall strong { font-size: 16px; color: var(--ink); }
.seg-tall small { font-size: 11px; font-weight: 600; opacity: .8; }

/* Note 34 e 35: si tocca tutta la riga. Il pulsante principale si allarga sulla riga (::after),
   gli altri tasti restano sopra e funzionano come prima. */
.task, .agenda-row, .feed-item { position: relative; }
.stretch::after { content: ''; position: absolute; inset: 0; }
.stretch { text-align: left; }
.task-actions > *, .agenda-row .btn, .agenda-row .icon-btn, .feed-side .link-btn:not(.stretch) { position: relative; z-index: 1; }
.agenda-row .row-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.stretch:active::after { background: color-mix(in srgb, var(--ink) 6%, transparent); } /* tocco visibile su tutta la riga */
.task .stretch::after { border-radius: var(--r-m); }
.agenda-list, .feed { overflow: hidden; }

/* Spesa: lista condivisa e conti tra coinquilini */
.shop-add { display: flex; gap: 8px; }
.shop-add label { flex: 1; min-width: 0; }
.shop-add input {
  width: 100%; min-height: 46px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); font-size: 16px;
}
.shop-add input:focus { border-color: transparent; outline: 2px solid var(--cobalt); outline-offset: -1px; }
.shop-add .btn { width: 46px; min-height: 46px; padding: 0; }
#shop-list { margin-top: 12px; }
#shop-list .pick:has(input:checked) { border-color: var(--line); background: transparent; }
#shop-list .pick:has(input:checked) strong { color: var(--ink-3); text-decoration: line-through; }
.expenses h3 { margin: 18px 0 8px; font-size: 15px; }

/* Codice casa: schermata per i telefoni nuovi e scheda in Impostazioni */
.code-input { font-weight: 700; letter-spacing: .14em; text-align: center; text-transform: uppercase; }
.code-input::placeholder { color: var(--ink-3); font-weight: 500; }
.card .house-code { margin: 14px 0; color: var(--ink); font: 800 28px/1 var(--display); letter-spacing: .12em; text-align: center; user-select: all; }

/* Tema scuro: i colori delle persone sono scelti per il fondo chiaro (c'è anche un blu notte);
   dove fanno da testo o da tratto dei grafici si schiariscono, così nessuno sparisce. */
@media (prefers-color-scheme: dark) {
  .arc-a { stroke: color-mix(in srgb, var(--ca) 62%, white); }
  .arc-b { stroke: color-mix(in srgb, var(--cb) 62%, white); }
  .arc-big { color: color-mix(in srgb, var(--ca) 62%, white); }
  .arc-side.right .arc-big { color: color-mix(in srgb, var(--cb) 62%, white); }
  .shares li strong { color: color-mix(in srgb, var(--c) 62%, white); }
  .share-bar::before { background: color-mix(in srgb, var(--c) 62%, white); }
}

/* ---------- Ritocchi e funzioni del 15 novembre ---------- */

/* Agenda: il nome dell'attività va a capo invece di troncarsi */
.agenda-row .row-name, .agenda-row strong { overflow: visible; line-height: 1.25; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }

/* Scheda attività: le etichette stanno in riga, i pulsanti sotto a destra */
.task-foot { flex-wrap: wrap; }
.task-foot .chips { flex: 1 1 100%; }
.task-actions { margin-left: auto; }

/* Il contenuto sfuma prima di passare sotto la barra delle schede */
.app:has(.tabbar:not([hidden]))::after {
  content: ''; position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 40%, transparent);
  pointer-events: none;
}

/* Spiegazioni dietro un "?" */
.help { margin-top: 8px; }
.help summary {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer; list-style: none;
}
.help summary::-webkit-details-marker { display: none; }
.help summary::before {
  content: '?'; display: grid; place-items: center; width: 18px; height: 18px;
  border: 1.5px solid currentColor; border-radius: 50%; font-size: 11px; line-height: 1;
}

/* Ultime attività: tutta la riga apre la modifica, resta solo una freccia */
.feed-side .stretch { color: var(--ink-3); }

/* Andamento dell'equità: una barra per mese */
.trend { display: grid; gap: 10px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); list-style: none; }
.trend li { display: grid; grid-template-columns: 3em 1fr; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; font-weight: 600; text-transform: capitalize; }
.trend-bar { display: flex; gap: 2px; height: 24px; overflow: hidden; border-radius: 8px; }
.trend-bar i { display: grid; place-items: center; flex-basis: 0; min-width: 4px; background: var(--c); color: #FFFFFF; font: 700 11px/1 var(--ui); }

/* Conti di casa: riga che apre la correzione, quote scritte a mano */
.log-item { position: relative; }
.log-item .row-name { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.log-item .icon-btn, .log-item .btn { position: relative; z-index: 1; }
.pick .share-amount {
  display: none; width: 96px; height: auto; min-height: 38px; margin-left: auto; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card);
  font-size: 16px; font-variant-numeric: tabular-nums; text-align: right;
}
form[data-form="expense"]:has(input[name="custom"]:checked) .pick:has(input[name="among"]:checked) .share-amount { display: block; }

/* Codice di recupero e PIN dimenticato */
.card .card-sub { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; }
.card .house-code.small { font-size: 19px; letter-spacing: .08em; }
.pin > .pin-forgot { justify-self: center; margin-top: 16px; text-align: center; }

@media (prefers-color-scheme: dark) {
  .trend-bar i { background: color-mix(in srgb, var(--c) 62%, white); color: #0F172A; }
}

/* Nota 48: guida all'installazione (Opzioni e pagina della casa nuova) */
.signup .card { display: grid; gap: 10px; }
.signup .card-sub { margin-top: 8px; }

/* Nota 49: guida all'installazione con i disegni del telefono; iPhone o Android scelti dalle radio (:has) */
.install-guide { display: grid; gap: 16px; }
.install-guide .os-pick { grid-template-columns: 1fr 1fr; }
.install-guide:has(input[value="ios"]:checked) .os-android,
.install-guide:has(input[value="android"]:checked) .os-ios { display: none; }
.install-steps { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.install-steps li { display: grid; grid-template-columns: 88px 1fr; gap: 16px; align-items: center; padding: 12px; border-radius: var(--r-l); background: var(--card); border: 1px solid var(--line); }
.install-steps p { margin: 0; font-size: 15px; line-height: 1.45; }
.install-steps .step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px; border-radius: 50%; background: var(--ink-bg); color: #fff; font-size: 13px; font-weight: 700; vertical-align: 1px; }
.phone-ill { width: 88px; height: auto; display: block; }
.ph-body { fill: var(--ink-bg); }
.ph-screen { fill: var(--canvas); }
.ph-ink { fill: var(--ink-3); }
.ph-soft { fill: var(--cobalt-soft); }
.ph-soft2 { fill: var(--line-strong); }
.ph-bar, .ph-card { fill: var(--card); stroke: var(--line-strong); stroke-width: 1; }
.ph-card { filter: drop-shadow(0 4px 6px rgba(15, 23, 42, .18)); }
.ph-pick { fill: var(--cobalt-soft); }
.ph-app { fill: var(--cobalt); }
.ph-tick { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ph-hit { fill: none; stroke: var(--amber); stroke-width: 3; animation: ph-pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ph-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(1.18); } }
.install-screen { display: grid; gap: 18px; }
.wz-resumed { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-m); background: var(--sage-soft); color: var(--sage-text); font-size: 14px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .ph-hit { animation: none; } }

/* Trasloco su chiappulito.it: l'avviso in cima alla home, visibile solo dal vecchio indirizzo */
.move-card { border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: var(--amber-soft); }
.move-card h2 .ico { color: var(--amber-text); }
.move-card .form-extra { margin-top: 12px; }

/* Nota 51: invito alle notifiche in home. Una riga, non una card: si legge, si tocca o si chiude. */
.nudge { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 8px 6px 8px 14px; border-radius: var(--r-m);
  background: var(--cobalt-soft); color: var(--ink-2); font-size: 14px; line-height: 1.35; animation: nudge-in .35s var(--ease-out); }
.nudge[hidden] { display: none; }
.nudge > .ico { flex: none; color: var(--cobalt-text); }
.nudge p { flex: 1; min-width: 0; margin: 0; }
.nudge .nudge-x { width: 36px; height: 36px; }
@keyframes nudge-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .nudge { animation: none; } }
