/*
 * Bloom — foglio di stile unico, mobile-first.
 * Base = layout per schermi stretti (tab bar in basso, card a piena larghezza).
 * @media (min-width: 900px) potenzia progressivamente verso il layout desktop
 * (barra laterale fissa, contenitore più largo, griglie più ricche).
 */

/* Font inclusi nell'app (licenza SIL OFL, vedi assets/fonts/FONTS.md):
 * niente richieste esterne, funzionano offline e passano la CSP 'self'. */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond-500.woff2") format("woff2");
  font-weight: 300 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond-600.woff2") format("woff2");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond-500-italic.woff2") format("woff2");
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("../assets/fonts/dm-sans-variable.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

/* Solo per la scritta del marchio GiGa Labor (.maker-word). */
@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/jetbrains-mono-variable.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #fdf8f4;
  --cream-2: #f9eee8;
  --ink: #3b2c28;
  --muted: #7c6962;
  --line: #efdfd7;
  --rose: #d98c92;
  --rose-dark: #b9656f;
  --rose-soft: #f7e3df;
  --sage: #a9b08a;
  --sage-dark: #6f7b55;
  --sage-soft: #ebeedf;
  --gold: #c99a5c;
  --gold-soft: #f5e7cc;
  --lilac: #d6bdd6;
  --lilac-soft: #f3e7f2;
  --danger: #b4474f;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --surface: rgba(255, 255, 255, .58);
  --surface-line: rgba(236, 216, 206, .9);
  --shadow: 0 10px 30px rgba(150, 100, 80, .08);
  --rose-grad: linear-gradient(180deg, #e2a4a7 0%, #cf7f87 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(249, 226, 219, .75), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(233, 222, 196, .35), transparent 38%),
    #fbf5f1;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  /* Cormorant ha cifre "all'antica" di default: nel mockup sono allineate. */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Disegni botanici a linea negli angoli, come nel mockup: fissi, dietro a tutto. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    url("../assets/img/botanic-flower.webp") right -30px top -20px / 210px auto no-repeat,
    url("../assets/img/botanic-stem.webp") right -40px bottom 60px / 120px auto no-repeat;
  opacity: .45;
}

body.on-intro::before { display: none; }

button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }

:focus-visible { outline: 3px solid var(--rose-dark); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { top: 12px; }

/* ---------- App shell ---------- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  /* Nell'app Android la pagina arriva fin sotto la barra di stato: il margine
     in alto la tiene libera. Nel browser vale 0. */
  --top-inset: env(safe-area-inset-top, 0px);
  padding: calc(16px + var(--top-inset)) 16px calc(108px + env(safe-area-inset-bottom));
}

/* L'accoglienza gestisce da sé il margine in alto (.intro-hero). */
body.on-intro .app { --top-inset: 0px; padding-bottom: 24px; }

.workspace {
  width: 100%;
  max-width: 560px;
  min-width: 0;
}

.page {
  display: none;
  width: 100%;
  gap: 16px;
}

.page.active { display: grid; }

/* Bottom tab bar (mobile default) */
.brand,
.load-box { display: none; }

/* Tab bar agganciata al fondo, a tutta larghezza, come nel mockup. */
.sidebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--surface-line);
  border-radius: 24px 24px 0 0;
  background: rgba(255, 251, 248, .95);
  box-shadow: 0 -10px 30px rgba(150, 100, 80, .07);
}

body.on-intro .sidebar { display: none; }

@supports (backdrop-filter: blur(1px)) {
  .sidebar { background: rgba(255, 251, 248, .86); backdrop-filter: blur(14px); }
}

.nav {
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.nav button {
  height: 60px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  font-size: 11.5px;
  font-weight: 500;
}

.nav button.active {
  color: var(--rose-dark);
  background: linear-gradient(180deg, #fbe7e3, #f6d9d5);
  box-shadow: inset 0 0 0 1px rgba(233, 196, 190, .7);
}

.nav button.active .ico svg { fill: rgba(217, 140, 146, .28); }

.ico {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.ico svg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ---------- Buttons ---------- */

.btn {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 22px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  color: var(--rose-dark);
  background: rgba(255, 255, 255, .72);
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: .1px;
  text-decoration: none;
}

.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn:disabled { opacity: .55; }

.btn.primary {
  color: #fff;
  border-color: transparent;
  background: var(--rose-grad);
  box-shadow: 0 14px 26px rgba(196, 114, 122, .28), inset 0 1px 0 rgba(255, 255, 255, .35);
}

/* Pulsante principale con la freccia in un cerchio a destra (intro). */
.btn-cta {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 62px;
  padding: 0 56px;
  font-size: 19px;
  font-weight: 400;
}

.cta-arrow {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  transform: translateY(-50%);
}

.cta-arrow svg { width: 20px; height: 20px; }

/* Pulsanti tondi della barra in alto. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.round-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--surface-line);
  border-radius: 50%;
  color: var(--rose-dark);
  background: rgba(255, 255, 255, .75);
  box-shadow: 0 6px 16px rgba(150, 100, 80, .07);
}

.round-btn svg { width: 22px; height: 22px; stroke-width: 1.5; }
.topbar .round-btn:only-child { margin-right: auto; }

.btn.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--rose-dark);
}

.btn.danger {
  color: #fff;
  border-color: transparent;
  background: var(--danger);
}

.link-btn {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--rose-dark);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Due pulsanti affiancati solo se ci stanno su una riga; su telefono si impilano. */
.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.actions { display: grid; gap: 8px; }

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Surfaces ---------- */

.section,
.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--surface-line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Titolo di pagina senza riquadro, centrato: kicker, titolo serif, sottotitolo. */
.hero {
  position: relative;
  padding: 6px 8px 4px;
  text-align: center;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #a4724c;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.kicker:before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #d8a06b;
}

.hero h2 {
  margin: 8px 0 8px;
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.02;
  font-weight: 500;
  letter-spacing: -.2px;
}

.hero p {
  max-width: 34ch;
  margin: 0 auto;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.45;
}

.section { padding: 20px 18px; border-radius: 24px; }
.section h3 { margin: 0 0 8px; font-size: 16.5px; font-weight: 500; }
.section > p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.section.soft { background: linear-gradient(160deg, rgba(255, 252, 249, .8), rgba(247, 227, 223, .6)); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.brand-tag {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}

.card { padding: 14px; border-radius: 20px; }

.copy { color: var(--muted); font-size: 14px; line-height: 1.4; }

.demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 12px;
  padding: 4px 16px;
  border: 1px solid #f0dfbd;
  border-radius: 16px;
  background: rgba(248, 236, 212, .75);
  color: #6b5024;
  font-size: 13.5px;
}

.demo-banner .link-btn { min-height: 36px; color: #86602a; font-size: 13.5px; }

.empty { text-align: center; }
.empty .action-row { margin-top: 4px; }

.empty-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  margin: 6px auto 12px;
  border-radius: 20px;
  color: var(--sage-dark);
  background: #e8ead7;
}

.empty-icon svg { width: 28px; height: 28px; }

.summary-box summary {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-size: 15.5px;
  font-weight: 500;
}

.summary-box summary::-webkit-details-marker { display: none; }
.summary-box summary::after { content: "▾"; color: var(--rose-dark); transition: transform .2s ease; }
.summary-box[open] summary::after { transform: rotate(180deg); }
.summary-box p { margin: 12px 0 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }

/* ---------- Intro ---------- */

/* Intro a tutto schermo: la margherita dell'immagine resta nitida a metà
 * pagina (immagine larga quanto lo schermo, agganciata in alto; sotto,
 * lo stesso rosa del suo bordo inferiore). */
.intro-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-height: 100vh;
  min-height: 100svh;
  margin: -16px -16px 0;
  padding: calc(52px + env(safe-area-inset-top)) 24px calc(22px + env(safe-area-inset-bottom));
  overflow: hidden;
  background: #f1dcd1;
  text-align: center;
}

/* L'immagine sta in un livello con le sue proporzioni (900×1599): la
 * sfumatura ne copre il bordo inferiore, così non si vede lo stacco. */
.intro-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: 900 / 1599;
  background:
    linear-gradient(180deg, rgba(241, 220, 209, 0) 84%, #f1dcd1 99%),
    url("../assets/img/bg-intro-mobile.webp") center top / 100% auto no-repeat;
}

.intro-hero > * { position: relative; }

.intro-top { display: grid; justify-items: center; gap: 4px; }

/* Marchio di GiGa Labor: segno e colori sono i loro, non si adattano al tema. */
.maker-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 10px;
  padding: 0 14px;
  border: 1px solid rgba(120, 90, 80, .14);
  border-radius: 22px;
  background: rgba(255, 255, 255, .14);
  text-decoration: none;
}
.maker-badge img { width: 47px; height: 22px; }
.maker-word { color: #6c5841; font: 400 13px/1 "JetBrains Mono", ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.maker-word b { font-size: 15px; font-weight: 700; }
.maker-word .gi { color: #00a6ff; }
.maker-word .ga { color: #d88632; }

/* Fiore a linea sopra «Bloom»: il disegno fa da maschera, il colore è quello
 * del tema (chiaro o scuro). */
.intro-mark {
  display: block;
  width: 76px;
  height: 65px;
  background: var(--rose);
  -webkit-mask: url("../assets/img/bloom-flower-mark.png") center / contain no-repeat;
  mask: url("../assets/img/bloom-flower-mark.png") center / contain no-repeat;
}

.intro-title {
  max-width: 100%;
  margin: 6px 0 14px;
  color: #c16f78;
  font-family: var(--serif);
  font-size: clamp(84px, 27vw, 112px);
  line-height: .85;
  font-weight: 500;
  letter-spacing: -1px;
}

.intro-copy {
  max-width: 290px;
  margin: 0 auto;
  color: #4a3a35;
  font-size: 16.5px;
  line-height: 1.45;
}

.intro-actions { width: 100%; min-width: 0; display: grid; gap: 6px; }

.intro-actions .btn.ghost {
  color: #c16f78;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
}

/* Riga sotto «Scarica l'app Android» (solo Android nel browser). */
.intro-app-note { margin: 4px 0 2px; color: #8c7770; font-size: 14px; text-align: center; }
.intro-app-note b { color: var(--ink); font-weight: 500; }
a.btn { text-decoration: none; }

.intro-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 2px 0 0;
  color: #8c7770;
  font-size: 13px;
}

.intro-privacy svg,
.privacy-line svg { width: 16px; height: 16px; flex: 0 0 auto; color: #9a8a84; }

.intro-help { justify-self: center; font-size: 14px; text-align: center; }

/* Invito a installare, subito sotto l'intro */
.install-card {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border: 1px solid rgba(228, 198, 185, .82);
  border-radius: 22px;
  background: rgba(255, 255, 255, .7);
  box-shadow: var(--shadow);
}

.install-card.no-action { grid-template-columns: 44px minmax(0, 1fr); }

.install-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--rose-soft);
  color: var(--rose-dark);
}

.install-icon svg { width: 22px; height: 22px; }

.install-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.install-card strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 16px; font-weight: 600; }
.install-card b { color: var(--ink); font-weight: 500; }
.install-card .btn { min-height: 44px; padding: 0 18px; border-radius: 22px; }

.app-version {
  margin: 0;
  color: #8a7064;
  font-size: 12.5px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.app-version a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.sidebar .app-version { display: none; margin-top: 14px; }

/* ---------- Import ---------- */

.tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  margin: 8px 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream-2);
}

.tabs button {
  min-height: 40px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.tabs [aria-selected="true"] {
  background: #fff;
  color: var(--rose-dark);
  box-shadow: 0 4px 12px rgba(142, 86, 57, .12);
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: center;
  font-size: 15.5px;
  line-height: 1.4;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--rose-soft);
  color: var(--rose-dark);
  font-size: 14px;
  font-weight: 600;
}

.dropzone {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 26px 16px;
  border: 2px dashed #e2b9b5;
  border-radius: 22px;
  background: rgba(255, 255, 255, .65);
  text-align: center;
  transition: border-color .2s ease, background .2s ease;
}

.dropzone:hover,
body.dragging .dropzone { border-color: var(--rose); background: #fff4ef; }
.dropzone strong { font-size: 17px; }

.dropzone-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--rose-soft);
  color: var(--rose-dark);
}

.dropzone-icon svg { width: 26px; height: 26px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 10px;
  font-size: 15.5px;
  line-height: 1.35;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--rose-dark);
}

.check small { color: var(--muted); font-size: 13.5px; }

.privacy-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.warn-list { margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }

.section.issue { border-color: #ecd3a3; background: linear-gradient(160deg, #fffaf0, #fbefd8); }
.section.issue p { margin: 0 0 10px; }
.section.issue .steps { margin: 4px 0 16px; }

.issue-shape {
  margin: 0 0 12px;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 14px;
  background: rgba(255, 255, 255, .8);
  color: var(--ink-2);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

.section .btn.danger { width: 100%; margin-top: 4px; }

/* ---------- Margherita ---------- */

.flower-sheet { justify-items: center; text-align: center; }
.flower-sheet h2 { margin-top: -6px; }

.bloom-card {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.flower-playground {
  position: relative;
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
}

.flower-glow {
  position: absolute;
  inset: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 131, 136, .22), rgba(201, 154, 92, .10) 58%, transparent 76%);
  filter: blur(14px);
  opacity: .82;
}

@media (prefers-reduced-motion: no-preference) {
  .flower-glow { animation: breathe 3.6s ease-in-out infinite; }
}

/* transform/opacity only: cheap to animate continuously, unlike filter/blur. */
@keyframes breathe {
  50% { transform: scale(1.07); opacity: .62; }
}

#flowerSvg { width: 100%; height: 100%; overflow: visible; }

.petal-shape {
  transform-origin: 100px 100px;
  transition: opacity 1.1s ease, transform 1.5s cubic-bezier(.16, .82, .22, 1);
}

.petal-shape.plucked {
  opacity: 0;
  transform: var(--base) translate(var(--fall-x), var(--fall-y)) rotate(var(--fall-r)) scale(.68);
}

@media (prefers-reduced-motion: reduce) {
  .petal-shape { transition: opacity .3s ease; }
  .petal-shape.plucked { transform: var(--base); }
}

.flower-score {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
}

.flower-score strong {
  font-family: var(--serif);
  font-size: 38px;
  line-height: .9;
  font-weight: 500;
}

.flower-score span {
  margin-top: 2px;
  color: #6b3f2a;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.bloom-card .btn {
  min-width: 210px;
  min-height: 50px;
  border-radius: 999px;
}

.petals-word {
  min-height: 24px;
  margin-top: 10px;
  color: var(--rose-dark);
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
}

.mini-note { margin-top: 6px; color: #8a7064; font-size: 13px; line-height: 1.4; }

/* ---------- Metrics / lists ---------- */

.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }

.metric { min-height: 110px; padding: 14px 6px 12px; border-radius: 20px; text-align: center; }

.metric .icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border-radius: 50%;
  color: var(--rose-dark);
  background: var(--rose-soft);
}

.metric .icon svg { width: 19px; height: 19px; stroke-width: 1.5; }

.metric strong {
  display: block;
  margin: 2px 0 1px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
}

.metric span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.metric .metric-label { color: var(--ink); font-size: 12px; }
.metric .metric-word { color: var(--muted); font-size: 11.5px; }

/* Le quattro metriche della Home stanno sempre su una riga, come nel mockup. */
.metrics-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

/* Righe icona · nome · valore · barra (altre dimensioni, legenda del radar). */
.metric-rows { display: grid; gap: 14px; margin: 6px 0 0; padding: 0; list-style: none; }

.metric-rows li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 6px;
  align-items: center;
}

.metric-row-icon {
  grid-row: span 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--rose-dark);
  background: var(--rose-soft);
}

.metric-row-icon svg { width: 18px; height: 18px; stroke-width: 1.5; }
.metric-row-label { font-size: 14px; }
.metric-rows strong { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1; }
.metric-rows .bar { grid-column: 2 / 4; height: 4px; }

.relation-list,
.stack { display: grid; gap: 10px; }

/* Righe elenco: avatar tondo, titolo e sottotitolo, pillola o freccia a destra. */
.relation-card {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--surface-line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

button.relation-card:hover { background: rgba(255, 255, 255, .8); }
.relation-body { display: grid; gap: 2px; min-width: 0; }
.relation-card .copy { font-size: 13px; }

.row-chevron { display: grid; place-items: center; color: #c7aaa3; }
.row-chevron svg { width: 18px; height: 18px; }

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--rose);
  font-size: 13px;
  font-weight: 600;
}

.avatar svg { width: 20px; height: 20px; stroke-width: 1.5; }
.avatar.tone-rose { color: var(--rose-dark); }
.avatar.tone-sage { color: var(--sage-dark); }
.avatar.tone-gold { color: #946a28; }
.avatar.tone-lilac { color: #8e5f8e; }

.relation-title { font-size: 15px; font-weight: 500; }

.subnav {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 0 16px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.subnav::-webkit-scrollbar { display: none; }

.subnav .chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .6);
  color: #6f5d56;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
}

.subnav .chip.active {
  color: var(--rose-dark);
  border-color: #efc9c4;
  background: linear-gradient(180deg, #fbe9e6, #f7dcd8);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 13px;
  border: 1px solid rgba(213, 220, 190, .9);
  border-radius: 999px;
  color: #56623f;
  background: var(--sage-soft);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.pill:before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--sage);
}

.pill.warn { color: #87601f; border-color: #f0dcb4; background: var(--gold-soft); }
.pill.warn:before { background: #d6a863; }
.pill.rose { color: #a0545e; border-color: #f1cfca; background: var(--rose-soft); }
.pill.rose:before { background: var(--rose); }

/* ---------- Home ---------- */

.greeting { padding: 4px 2px 0; }

.greeting h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 500;
  line-height: 1.05;
}

.greeting-heart { display: inline-grid; color: var(--rose); }
.greeting-heart svg { width: 18px; height: 18px; fill: var(--rose); stroke-width: 1.2; }
.greeting p { margin: 0; color: var(--ink-2); font-size: 15px; }

.home-block { display: grid; gap: 10px; }
.block-title { margin: 6px 2px 0; font-size: 15.5px; font-weight: 500; }

/* Card della relazione principale: tutta cliccabile, apre l'analisi. */
.main-relation {
  position: relative;
  width: 100%;
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 18px 18px 12px;
  overflow: hidden;
  border: 1px solid var(--surface-line);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .72), rgba(251, 236, 231, .62));
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
}

/* Fiore a linea nell'angolo, più tenue del resto: sta dietro al contenuto. */
.main-relation::after {
  content: "";
  position: absolute;
  right: -64px;
  bottom: -54px;
  width: 230px;
  height: 200px;
  background: url("../assets/img/botanic-flower.webp") center / contain no-repeat;
  opacity: .5;
  pointer-events: none;
}

.main-relation > * { position: relative; z-index: 1; }

.main-relation-top {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.relation-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--surface-line);
  border-radius: 50%;
  color: var(--rose);
  background: rgba(255, 255, 255, .85);
}

.relation-icon svg { width: 24px; height: 24px; stroke-width: 1.4; }
.main-relation-head { display: grid; gap: 3px; min-width: 0; }
.main-relation-name { font-size: 18px; font-weight: 500; }
.main-relation-meta { color: var(--muted); font-size: 12.5px; }
.main-relation-text { max-width: 30ch; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.sparkline { display: block; width: 100%; height: auto; margin-top: -6px; }

/* Margherita, storie e card: tre pulsanti tondi con etichetta. */
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.quick-actions button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13px;
}

.quick-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--surface-line);
  border-radius: 50%;
  color: var(--rose-dark);
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow);
}

.quick-icon svg { width: 24px; height: 24px; stroke-width: 1.4; }

/* ---------- Come sta andando ---------- */

.trend-card { display: grid; gap: 12px; }
.trend-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.trend-sentence { margin: 0; color: var(--ink); font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.25; }

.trend-bands {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 360px;
}

.trend-band { display: grid; gap: 6px; justify-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.trend-band-track { width: 100%; height: 96px; display: flex; align-items: flex-end; }
.trend-band-bar { width: 100%; border-radius: 14px 14px 6px 6px; background: var(--rose-soft); }
.trend-band.now { color: var(--rose-dark); }
.trend-band.now .trend-band-bar { background: var(--rose-grad); }

/* ---------- Charts ---------- */

.chart-wrap { margin: 16px 0 0; }
.chart { display: block; width: 100%; height: auto; }

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.report-card .section-head { margin-bottom: 4px; }

.gauge-row { display: flex; align-items: center; gap: 18px; margin-top: 8px; }
.gauge-wrap { position: relative; width: 112px; height: 112px; flex: 0 0 auto; }
.gauge { width: 100%; height: 100%; }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-center strong { font-family: var(--serif); font-size: 40px; font-weight: 500; line-height: .9; }
.gauge-center span { color: var(--muted); font-size: 11.5px; }
.gauge-side { display: grid; justify-items: start; gap: 10px; }
.gauge-title { font-family: var(--serif); font-size: 21px; font-weight: 500; }

.radar-wrap { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: center; }
.radar { width: 100%; max-width: 230px; height: auto; margin: 0 auto; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 104px) 1fr 44px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  font-size: 14px;
}

.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row strong { font-family: var(--serif); font-size: 19px; font-weight: 600; text-align: right; }
.bar { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(214, 196, 186, .38); }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--rose); }

/* ---------- Timeline, quotes, advice, signals ---------- */

.timeline { position: relative; display: grid; gap: 10px; }

.timeline:before {
  content: "";
  position: absolute;
  left: 18px;
  top: 24px;
  bottom: 24px;
  width: 1px;
  background: linear-gradient(#efcfca, #d9dfc6);
}

.moment,
.quote,
.advice,
.signal {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  padding: 6px 0;
}

.dot,
.quote-mark,
.advice-num,
.signal-dot {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 212, 206, .9);
  border-radius: 13px;
  color: var(--rose-dark);
  background: #fbeae6;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.quote-mark svg { width: 18px; height: 18px; stroke-width: 1.5; }
.signal-dot { color: #7f5716; background: var(--gold-soft); }

.moment:nth-child(2) .dot,
.advice:nth-child(2) .advice-num { color: #946a28; background: #f4e3bf; }
.moment:nth-child(3) .dot,
.advice:nth-child(3) .advice-num { color: #66734d; background: #e8ead7; }

.item-title { margin-bottom: 2px; font-size: 14.5px; font-weight: 500; }
.when { margin-left: 4px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.advice .copy { align-self: center; font-size: 14.5px; color: var(--ink-2); }

.mini-quote {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 3px solid var(--rose-soft);
  color: #5b4a42;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  line-height: 1.4;
}

.suggested-message {
  margin: 0 0 12px;
  padding: 16px 18px;
  border-left: 4px solid var(--rose);
  border-radius: 18px;
  background: #fff;
  font-family: var(--serif);
  font-size: 21px;
  font-style: italic;
  line-height: 1.45;
}

.helplines { display: grid; gap: 10px; margin: 4px 0 14px; }

.helpline {
  min-height: 60px;
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.helpline strong { color: var(--rose-dark); font-family: var(--serif); font-size: 28px; font-weight: 500; }
.helpline span { color: var(--ink-2); font-size: 14px; line-height: 1.35; }
.helpline.urgent strong { color: var(--danger); }

.topic-cloud {
  position: relative;
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .45);
}

.bubble {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #5f4c43;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.b0 { left: 30%; top: 22%; width: 118px; height: 118px; color: #974e57; background: #f8ded9; }
.b1 { left: 5%; top: 6%; width: 92px; height: 92px; background: #e8ead7; }
.b2 { right: 6%; top: 6%; width: 96px; height: 96px; background: #f4e3bf; }
.b3 { left: 8%; bottom: 7%; width: 90px; height: 90px; background: #f1e2ef; }
.b4 { right: 8%; bottom: 6%; width: 92px; height: 92px; background: #fff5ee; }

/* Elenco con icona in un quadrato morbido, titolo e riga di spiegazione
 * (come "Cosa include" nel mockup). */
.feature-list { display: grid; gap: 14px; margin: 4px 0 0; padding: 0; list-style: none; }
.feature-list li { display: grid; grid-template-columns: 38px 1fr; gap: 14px; align-items: center; }
.feature-list strong { display: block; font-size: 14.5px; font-weight: 500; }
.feature-list li > span:last-child > span { color: var(--muted); font-size: 13px; }

.feature-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 212, 206, .9);
  border-radius: 13px;
  color: var(--rose-dark);
  background: #fbeae6;
}

.feature-icon svg { width: 19px; height: 19px; stroke-width: 1.5; }

/* ---------- Le persone ---------- */

.tone-rose { background: #f8e1dd; }
.tone-sage { background: #e9ecdb; }
.tone-gold { background: #f6e8cc; }
.tone-lilac { background: #f1e4f0; }

.avatar.flower { font-size: 22px; }

.person-picker {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 2px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.person-picker::-webkit-scrollbar { display: none; }

.person-picker button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .75);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.person-picker [aria-selected="true"] {
  border-color: #e6b8b8;
  background: #fff;
  color: var(--rose-dark);
  box-shadow: 0 6px 16px rgba(142, 86, 57, .12);
}

.person-card { padding: 22px 18px; }
.person-head { display: grid; justify-items: center; gap: 6px; margin-bottom: 16px; text-align: center; }

.person-avatar {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 38px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .7);
}

.person-head h3 { margin: 4px 0 0; font-family: var(--serif); font-size: 26px; font-weight: 500; }

.person-motto {
  margin: 0;
  color: var(--rose-dark);
  font-family: var(--serif);
  font-size: 23px;
  font-style: italic;
}

.person-empty { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; text-align: center; }

.trait-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.trait-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-radius: 20px;
}

.trait-emoji {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .75);
  font-size: 22px;
}

.trait-card strong { display: block; margin-top: 2px; font-size: 16px; }
.trait-card p { margin: 3px 0 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.4; }

.trait-card blockquote {
  margin: 8px 0 0;
  color: #5b4a42;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  line-height: 1.4;
}

.person-block h4 { margin: 20px 0 10px; font-size: 15.5px; }

.drive-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.drive-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14.5px;
  font-weight: 500;
}

.focus-bubbles {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.focus-bubble {
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 17px;
}

.focus-bubble:nth-child(1) { background: #f8e1dd; }
.focus-bubble:nth-child(2) { background: #e9ecdb; }
.focus-bubble:nth-child(3) { background: #f1e4f0; }

.focus-lead { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; text-align: center; }

.duel-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 16px; font-size: 15px; font-weight: 500; }
.duel-legend span { display: inline-flex; align-items: center; gap: 6px; }

.duel-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.duel-row { display: grid; gap: 6px; }
.duel-label { font-size: 15px; font-weight: 500; }
.duel-sentence { color: var(--muted); font-size: 14px; }

.dots { display: flex; gap: 5px; }

.dots i,
.duel-legend i {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #eadfd6;
}

.dots i.a,
.duel-legend i.a { background: var(--rose); }
.dots i.b,
.duel-legend i.b { background: var(--sage); }

.story-people { display: grid; gap: 22px; width: 100%; }
.story-people > div { display: grid; gap: 6px; padding: 16px; border-radius: 22px; background: rgba(255, 255, 255, .55); }
.story-person { font-size: 16px; font-weight: 600; }
.story-people strong { font-family: var(--serif); font-size: 26px; font-weight: 500; line-height: 1.2; }

/* ---------- Toast & drag ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(39, 33, 30, .92);
  color: #fff;
  font-size: 14.5px;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  background: rgba(255, 244, 239, .86);
  pointer-events: none;
}

.drop-overlay span {
  padding: 24px 36px;
  border: 2px dashed var(--rose);
  border-radius: 24px;
  color: var(--rose-dark);
  font-family: var(--serif);
  font-size: 28px;
}

body.dragging .drop-overlay { display: grid; }

/* ---------- Sheets (dialog) ---------- */

dialog::backdrop { background: rgba(39, 33, 30, .45); }

dialog.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 -12px 40px rgba(80, 50, 35, .25);
}

.sheet-body {
  display: grid;
  gap: 14px;
  padding: 26px 20px calc(24px + env(safe-area-inset-bottom));
}

.sheet-body h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500; }
.sheet-body .copy { margin: 0; font-size: 15px; }

.who-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.btn.who {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px;
  color: var(--ink);
}

.btn.who strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.btn.who span { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.card-preview {
  width: min(250px, 62vw);
  aspect-ratio: 9 / 16;
  justify-self: center;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card-loading { background: linear-gradient(160deg, #fff8f1, #f5ded9); }

@media (prefers-reduced-motion: no-preference) {
  .card-loading { animation: breathe 1.4s ease-in-out infinite; }
}

/* ---------- Stories ---------- */

dialog.stories {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--ink);
  background: linear-gradient(160deg, #fff8f1, #fbe9df);
}

dialog.stories[data-theme="rose"] { background: linear-gradient(160deg, #fdeae6, #f3c9c9); }
dialog.stories[data-theme="sage"] { background: linear-gradient(160deg, #f1f3e6, #d9dfc4); }
dialog.stories[data-theme="gold"] { background: linear-gradient(160deg, #fcf2de, #f1d9ae); }
dialog.stories[data-theme="lilac"] { background: linear-gradient(160deg, #f8eef7, #e3cde2); }

.stories-bars {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 16px;
  right: 64px;
  z-index: 2;
  display: flex;
  gap: 4px;
}

.stories-bars span {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(39, 33, 30, .16);
}

.stories-bars i { display: block; width: 0; height: 100%; background: rgba(39, 33, 30, .75); }
.stories-bars .done i { width: 100%; }
.stories-bars .active i { animation: story-progress 6s linear forwards; }
dialog.stories.last .stories-bars .active i { width: 100%; animation: none; }
dialog.stories.paused .stories-bars .active i { animation-play-state: paused; }

@keyframes story-progress { to { width: 100%; } }

.stories-close {
  position: absolute;
  top: calc(4px + env(safe-area-inset-top));
  right: 8px;
  z-index: 3;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
}

.stories-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 28px calc(96px + env(safe-area-inset-bottom));
  text-align: center;
  user-select: none;
  touch-action: manipulation;
}

.story-slide { display: grid; justify-items: center; gap: 14px; width: 100%; max-width: 420px; }

@media (prefers-reduced-motion: no-preference) {
  .story-slide { animation: story-in .45s ease both; }
}

@keyframes story-in {
  from { opacity: 0; transform: translateY(14px); }
}

.story-kicker {
  color: #8a5535;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.story-big { font-family: var(--serif); font-size: 104px; line-height: .95; }
.story-big.long { font-size: clamp(56px, 18vw, 96px); }
.story-word { font-family: var(--serif); font-size: 44px; line-height: 1.05; }
.story-title { margin: 0; font-family: var(--serif); font-size: 28px; line-height: 1.2; }
.story-sub { margin: 0; color: var(--ink-2); font-size: 18px; line-height: 1.4; }
.story-note { margin: 0; color: var(--muted); font-size: 14.5px; }

.story-ring { position: relative; width: 200px; height: 200px; display: grid; place-items: center; }
.story-ring .gauge { position: absolute; inset: 0; }
.story-ring strong { font-family: var(--serif); font-size: 64px; font-weight: 500; }

.story-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }

.story-split div {
  display: grid;
  gap: 4px;
  padding: 18px 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .6);
}

.story-split strong { font-family: var(--serif); font-size: 44px; font-weight: 500; }
.story-split span { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

.story-quote {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-style: italic;
  line-height: 1.35;
}

.story-actions { display: grid; gap: 10px; width: 100%; max-width: 300px; margin-top: 8px; }

.stories-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.stories-nav button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(39, 33, 30, .12);
  border-radius: 50%;
  background: rgba(255, 255, 255, .6);
  font-size: 24px;
  line-height: 1;
}

.stories-nav button:disabled { opacity: .35; }
.stories-count { min-width: 48px; color: var(--muted); font-size: 14px; font-weight: 500; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .stories-bars .active i { width: 100%; animation: none; }
}

/* ---------- Tablet ---------- */

@media (min-width: 600px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  dialog.sheet { margin: auto; border-radius: 28px; }

  dialog.stories {
    width: 430px;
    height: min(880px, calc(100vh - 40px));
    margin: auto;
    border-radius: 30px;
    box-shadow: 0 30px 80px rgba(60, 35, 25, .35);
  }
}

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr);
    justify-items: stretch;
    gap: 24px;
    padding: 24px;
  }

  body.on-intro .app { padding-bottom: 24px; }
  body.on-intro .sidebar { display: block; }

  .workspace { max-width: none; }
  .page { max-width: 900px; margin: 0 auto; }

  .brand { display: flex; }
  .load-box { display: block; }
  .sidebar .app-version { display: block; }

  .sidebar {
    position: sticky;
    left: auto;
    right: auto;
    bottom: auto;
    top: 24px;
    width: auto;
    height: calc(100vh - 48px);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--surface-line);
    border-radius: 28px;
    box-shadow: var(--shadow);
  }

  .brand { align-items: center; gap: 10px; margin-bottom: 20px; }

  .brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(180deg, #fff8f1, #f7ddd8);
  }

  .brand-mark img { width: 100%; height: 100%; object-fit: contain; }

  .brand h1 {
    margin: 0;
    color: var(--rose-dark);
    font-family: var(--serif);
    font-size: 30px;
    line-height: .95;
    font-weight: 500;
  }

  .brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

  .nav {
    max-width: none;
    height: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 0 0 18px;
  }

  .nav button {
    height: 46px;
    grid-template-columns: 30px 1fr;
    justify-items: start;
    align-items: center;
    padding: 0 10px;
    font-size: 14.5px;
    text-align: left;
  }

  .ico { width: 28px; height: 28px; background: rgba(255, 255, 255, .5); }

  .load-box {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, .5);
  }

  .load-box h2 { margin: 0 0 8px; font-size: 16px; }
  .load-box p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.4; }

  .subnav { margin: 0; padding: 0 0 2px; }
  .person-picker { margin: 0; padding: 2px 0; }

  .hero { padding: 12px 0 4px; }
  .hero h2 { font-size: 48px; }

  /* Su schermo largo l'intro è una grande card con l'immagine orizzontale. */
  .intro-hero {
    max-width: 900px;
    width: 100%;
    min-height: 620px;
    justify-content: center;
    gap: 36px;
    margin: 0 auto;
    padding: 56px 48px;
    border: 1px solid var(--surface-line);
    border-radius: 32px;
    background: url("../assets/img/bg-intro-wide.webp") 18% center / cover no-repeat, #f6e5dd;
    box-shadow: var(--shadow);
  }

  .intro-hero::before { display: none; }

  .intro-title { font-size: 120px; }
  .intro-copy { max-width: 380px; font-size: 18px; }
  .intro-actions { width: 100%; max-width: 380px; margin: 0 auto; }

  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(300px, .74fr); align-items: start; }


  /* La linea in miniatura non deve crescere in altezza con la card. */
  .sparkline { max-width: 520px; justify-self: end; }

  .radar-wrap { grid-template-columns: 240px 1fr; }
  .radar { max-width: 240px; }
  .bar-row { grid-template-columns: minmax(0, 140px) 1fr 48px; }
  .topic-cloud { height: 340px; }

  .toast { bottom: 28px; }
}

/* ---------- Contesti (che legame è) ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.block-head .block-title { margin-top: 0; }

.context-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  color: var(--rose-dark);
  background: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 500;
}

.context-chip svg { width: 16px; height: 16px; }
.context-chip svg:last-child { width: 13px; height: 13px; transform: rotate(90deg); }

.quick-actions.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.btn.context-option strong { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.context-option[aria-pressed="true"] { border-color: var(--rose); background: var(--rose-soft); }
.who-list .context-option:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Settimana: griglia giorno × fascia oraria (figura del contesto Lavoro). */
.week-grid { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.week-grid thead th { color: var(--muted); font-size: 12px; font-weight: 500; }
.week-grid thead td { width: 86px; }
.week-grid abbr { text-decoration: none; }
.week-grid tbody th { padding-right: 6px; color: var(--muted); font-size: 12.5px; font-weight: 400; text-align: left; }

.week-cell {
  --cell: var(--work-in, #5f7896);
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--cell) calc(var(--fill, 0) * 1%), transparent);
}

.week-cell.off { --cell: var(--work-off, #c98a4b); }
.week-cell[data-level="1"] { --fill: 25; }
.week-cell[data-level="2"] { --fill: 50; }
.week-cell[data-level="3"] { --fill: 75; }
.week-cell[data-level="4"] { --fill: 100; }
.week-cell:not([data-level="0"]) { border-color: transparent; }

.week-legend { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12.5px; }
.week-key { width: 12px; height: 12px; border-radius: 3px; background: var(--work-in, #5f7896); }
.week-key.off { margin-left: 12px; background: var(--work-off, #c98a4b); }
.week-sentence { margin: 0; font-size: 15px; line-height: 1.45; }

/* Tema Lavoro: ardesia, card squadrate, niente decori botanici, titoli e
 * numeri in DM Sans. Ridefinisce i colori di base: il resto li eredita. */
body[data-context="work"] {
  --cream: #f6f7f9;
  --cream-2: #eceff3;
  --ink: #232a33;
  --muted: #66707c;
  --line: #dde2e8;
  --rose: #6f86a3;
  --rose-dark: #44597a;
  --rose-soft: #e3e9f1;
  --serif: var(--sans);
  --surface: rgba(255, 255, 255, .8);
  --surface-line: rgba(208, 215, 224, .95);
  --shadow: 0 6px 18px rgba(40, 60, 90, .06);
  --rose-grad: linear-gradient(180deg, #6f86a3 0%, #536a8a 100%);
  --work-in: #5f7896;
  --work-off: #c98a4b;
  background: #f3f5f8;
}

body[data-context="work"]::before,
body[data-context="work"] .main-relation::after,
body[data-context="work"] .greeting-heart { display: none; }

body[data-context="work"] .greeting h2 { font-size: 30px; font-weight: 600; letter-spacing: -.3px; }
body[data-context="work"] .greeting p,
body[data-context="work"] .quick-actions button { color: var(--muted); }
body[data-context="work"] .main-relation-text { color: var(--ink); }

body[data-context="work"] .main-relation { border-radius: 12px; background: #fff; }
body[data-context="work"] .card,
body[data-context="work"] .section,
body[data-context="work"] .metric { border-radius: 10px; }
body[data-context="work"] .relation-icon,
body[data-context="work"] .quick-icon { border-radius: 12px; }
body[data-context="work"] .metric strong { font-weight: 600; }
body[data-context="work"] .btn.primary { box-shadow: 0 8px 18px rgba(68, 89, 122, .22); }
body[data-context="work"] dialog.sheet { background: var(--cream); }
body[data-context="work"] .pill.rose { color: var(--rose-dark); border-color: var(--line); background: var(--rose-soft); }
body[data-context="work"] .row-chevron,
body[data-context="work"] .nav button { color: var(--muted); }
body[data-context="work"] .nav button.active {
  color: var(--rose-dark);
  background: var(--rose-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
body[data-context="work"] .nav button.active .ico svg { fill: rgba(111, 134, 163, .25); }

.context-guess { color: var(--ink); }
.btn.context-option.suggested span { color: var(--rose-dark); font-weight: 600; }
.btn.context-option.suggested:not([aria-pressed="true"]) { border-style: dashed; border-color: var(--rose); }

/* ---------- Figure: Albero, Anno, Ritmo ---------- */

.figure-svg { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; }
.figure-sheet .figure-svg[preserveAspectRatio="none"] { max-width: none; height: 150px; }

.tree-trunk, .tree-branch, .tree-ground { fill: none; stroke: var(--rose-dark); stroke-linecap: round; }
.tree-trunk { stroke-width: 7; }
.tree-branch { stroke-width: 3.5; }
.tree-ground { stroke-width: 2; opacity: .35; }
.tree-crown { fill: var(--rose); opacity: .85; }
.tree-name { fill: var(--ink); font-size: 12px; font-weight: 500; }

.year-dot { fill: none; stroke: var(--line); stroke-width: 1.5; }
.year-dot.on { fill: var(--rose); stroke: none; }
.year-label { fill: var(--muted); font-size: 11px; }
.year-center { fill: var(--ink); font-family: var(--serif); font-size: 46px; font-weight: 600; }
.year-center-label { fill: var(--muted); font-size: 12px; }

.rhythm-area { fill: var(--rose-soft); }
.rhythm-line { fill: none; stroke: var(--rose-dark); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.rhythm-range { display: flex; justify-content: space-between; margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- Temi Famiglia, Parenti, Amicizia ---------- */
/* Ridefiniscono il colore d'accento (le variabili "rose" di base): il resto
 * dell'app lo eredita. Lo scheletro delle pagine resta quello di sempre. */

body[data-context="family"] {
  --rose: #8f9a6c;
  --rose-dark: #5f6b45;
  --rose-soft: #ebeedf;
  --line: #e2e5d3;
  --surface-line: rgba(214, 220, 194, .95);
  --shadow: 0 10px 28px rgba(95, 107, 69, .09);
  --rose-grad: linear-gradient(180deg, #a3ad80 0%, #7f8a5c 100%);
  background: radial-gradient(circle at 12% 0%, rgba(226, 232, 205, .8), transparent 42%), #f8f8f1;
}

body[data-context="relatives"] {
  --rose: #c99a5c;
  --rose-dark: #8a6427;
  --rose-soft: #f5e7cc;
  --line: #efe2c8;
  --surface-line: rgba(235, 220, 190, .95);
  --shadow: 0 10px 28px rgba(138, 100, 39, .07);
  --rose-grad: linear-gradient(180deg, #d6ab70 0%, #b88645 100%);
  background: radial-gradient(circle at 100% 0%, rgba(245, 231, 204, .7), transparent 40%), #fbf8f0;
}

body[data-context="friends"] {
  --rose: #b58fb8;
  --rose-dark: #7d5682;
  --rose-soft: #f3e7f2;
  --line: #ecdcea;
  --surface-line: rgba(228, 208, 227, .95);
  --shadow: 0 10px 28px rgba(125, 86, 130, .09);
  --rose-grad: linear-gradient(180deg, #c8a5ca 0%, #a57ba8 100%);
  background: radial-gradient(circle at 0% 0%, rgba(243, 231, 242, .9), transparent 42%), radial-gradient(circle at 100% 100%, rgba(232, 214, 236, .5), transparent 40%), #fbf6fa;
}

/* I disegni botanici sono rosa: fuori dalla coppia non si mostrano. */
body:not([data-context="couple"])::before,
body:not([data-context="couple"]) .main-relation::after,
body:not([data-context="couple"]) .greeting-heart { display: none; }

body:not([data-context="couple"]) .main-relation { background: var(--surface); }
body:not([data-context="couple"]) .pill.rose { color: var(--rose-dark); border-color: var(--line); background: var(--rose-soft); }
body:not([data-context="couple"]) .nav button.active {
  color: var(--rose-dark);
  background: var(--rose-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
body:not([data-context="couple"]) .nav button.active .ico svg { fill: color-mix(in srgb, var(--rose) 28%, transparent); }
body:not([data-context="couple"]) .kicker { color: var(--rose-dark); }
body:not([data-context="couple"]) .btn.primary { box-shadow: 0 12px 24px color-mix(in srgb, var(--rose-dark) 22%, transparent); }

/* Famiglia: forme piene. Parenti: tratto sottile, più aria. Amicizia: tondo e giocoso. */
body[data-context="family"] .metric .icon,
body[data-context="family"] .relation-icon { color: #fff; border-color: transparent; background: var(--rose); }
body[data-context="relatives"] .workspace { letter-spacing: .1px; }
body[data-context="relatives"] .card,
body[data-context="relatives"] .main-relation { box-shadow: none; }
body[data-context="relatives"] .home-block { gap: 14px; }
body[data-context="friends"] .card,
body[data-context="friends"] .metric { border-radius: 28px; }
body[data-context="friends"] .main-relation { border-radius: 32px; }
body[data-context="friends"] .metric strong { color: var(--rose-dark); }

dialog.stories[data-theme="slate"] { background: linear-gradient(160deg, #eef1f5, #cfd8e3); }

.link-row { grid-template-columns: minmax(0, 1fr) auto; cursor: default; }

/* ====================================================================
 * Grafica per contesto (mockup del 2026-10-03): cinque identità visive
 * più Parenti. body[data-look] = stile della pagina (vedi bodyLook() in
 * app.js): ridefinisce colore d'accento, sfondo, decoro e marchio.
 * ==================================================================== */

/* ---------- Home: testata, punteggio, "Cosa emerge" ---------- */

.home-top { align-items: center; }
.home-top-actions { display: flex; gap: 10px; }
.topbar.home-top .round-btn:only-child { margin-right: 0; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--rose-dark);
  font-family: var(--brand-font, var(--serif));
  font-size: 36px;
  font-style: var(--brand-style, normal);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.3px;
}

.wordmark svg { width: 28px; height: 28px; stroke-width: 1.9; }

.home-hero { display: grid; justify-items: start; gap: 6px; padding: 2px 2px 0; }

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rose-dark);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hero-kicker svg { width: 12px; height: 12px; transform: rotate(90deg); }

.hero-title {
  margin: 0;
  max-width: 78%;
  color: var(--title, var(--ink));
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.hero-meta { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.home-hero .pill { min-height: 34px; padding: 0 16px; font-size: 14px; }

.score-card {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 16px 18px 12px;
  border: 1px solid var(--surface-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
}

.score-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.score-label { font-size: 15.5px; font-weight: 500; }
.score-dir { color: var(--rose-dark); font-size: 12.5px; font-weight: 600; }
.score-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: end; }
.score-value { display: inline-flex; align-items: baseline; gap: 3px; }
.score-value strong { color: var(--title, var(--ink)); font-family: var(--serif); font-size: 58px; font-weight: 600; line-height: .95; }
.score-value small { color: var(--muted); font-size: 14px; }
.score-card .sparkline { margin: 0; }

.spark-line { fill: none; stroke: var(--rose); stroke-width: 2.2; stroke-linecap: round; }
.spark-area { fill: var(--rose-soft); opacity: .7; }
.spark-dot { fill: var(--rose); stroke: #fff; stroke-width: 1.6; }

.score-bars { height: 70px; display: flex; align-items: flex-end; justify-content: flex-end; gap: 7px; }
.score-bars i { width: 14px; border-radius: 8px; background: var(--rose-grad); }

.emerge { padding: 16px 18px; border-radius: 22px; background: rgba(255, 255, 255, .78); }
.emerge h3 { margin: 0 0 10px; font-size: 15.5px; font-weight: 500; }
.emerge ul { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.emerge li { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: center; }
.emerge li > span:last-child { display: grid; gap: 2px; }
.emerge strong { font-size: 14.5px; font-weight: 600; }
.emerge li span span { color: var(--muted); font-size: 13px; line-height: 1.35; }

.emerge-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--rose-dark);
  background: var(--rose-soft);
}

.emerge-icon svg { width: 19px; height: 19px; }

.home-cta { width: 100%; min-height: 54px; justify-content: center; gap: 12px; font-size: 16px; }
.home-cta svg { width: 20px; height: 20px; }

.metrics-row .metric { background: rgba(255, 255, 255, .78); }

/* ---------- Gli stili ---------- */

body[data-look="couple"] {
  --rose: #e2607a;
  --rose-dark: #b83a58;
  --rose-soft: #fde3e8;
  --title: #7a2338;
  --line: #f6d3da;
  --surface-line: rgba(246, 205, 214, .95);
  --shadow: 0 10px 28px rgba(184, 58, 88, .09);
  --rose-grad: linear-gradient(180deg, #ef8198 0%, #d94f70 100%);
  --deco: url("../assets/img/photo-couple-hearts.webp");
  background: radial-gradient(circle at 10% 0%, rgba(253, 220, 227, .9), transparent 44%), radial-gradient(circle at 100% 100%, rgba(252, 226, 231, .7), transparent 42%), #fff6f7;
}

body[data-look="friends"] {
  --rose: #1fb5a3;
  --rose-dark: #0f8576;
  --rose-soft: #dcf5f0;
  --title: #0f3f3a;
  --ink: #17403b;
  --muted: #5d7a75;
  --line: #cfece6;
  --surface-line: rgba(196, 232, 224, .95);
  --shadow: 0 10px 28px rgba(15, 133, 118, .1);
  --rose-grad: linear-gradient(180deg, #34c6b3 0%, #129987 100%);
  --brand-style: italic;
  --deco: url("../assets/img/photo-friends-group.webp");
  background: radial-gradient(circle at 0% 0%, rgba(213, 245, 238, .95), transparent 44%), radial-gradient(circle at 100% 30%, rgba(255, 236, 179, .55), transparent 36%), #f4fcfa;
}

body[data-look="groups"] {
  --rose: #ff6b5e;
  --rose-dark: #d83e3a;
  --rose-soft: #ffe4de;
  --title: #3d1b2c;
  --ink: #3d1b2c;
  --muted: #7d5b66;
  --line: #ffd6cd;
  --surface-line: rgba(255, 210, 200, .95);
  --shadow: 0 10px 28px rgba(216, 62, 58, .12);
  --rose-grad: linear-gradient(180deg, #ff8a5c 0%, #ff4f6d 100%);
  --brand-style: italic;
  --deco: url("../assets/img/photo-groups-large.webp");
  background: linear-gradient(180deg, rgba(255, 138, 92, .30) 0, rgba(255, 126, 179, .16) 230px, transparent 420px), #fff5f1;
}

body[data-look="work"] {
  --rose: #2f6db5;
  --rose-dark: #1c3a66;
  --rose-soft: #e2ecf8;
  --title: #14233b;
  --ink: #14233b;
  --muted: #5d6b80;
  --line: #d6e0ee;
  --surface-line: rgba(204, 216, 233, .95);
  --shadow: 0 8px 22px rgba(28, 58, 102, .08);
  --rose-grad: linear-gradient(180deg, #25467a 0%, #17305a 100%);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --deco: url("../assets/img/photo-work-team.webp");
  background: radial-gradient(circle at 100% 0%, rgba(214, 228, 246, .9), transparent 46%), #f4f7fb;
}

body[data-look="family"] {
  --rose: #c8704a;
  --rose-dark: #94492a;
  --rose-soft: #f9e6d8;
  --title: #5a2a17;
  --ink: #4a2a1b;
  --muted: #86685a;
  --line: #f0dccb;
  --surface-line: rgba(238, 214, 194, .95);
  --shadow: 0 10px 28px rgba(148, 73, 42, .09);
  --rose-grad: linear-gradient(180deg, #d5835b 0%, #b05c38 100%);
  --deco: url("../assets/img/photo-family-group.webp");
  background: radial-gradient(circle at 100% 0%, rgba(249, 226, 205, .9), transparent 46%), radial-gradient(circle at 0% 100%, rgba(226, 232, 205, .5), transparent 40%), #fcf5ec;
}

body[data-look="relatives"] { --title: #5b3f12; --deco: url("../assets/img/photo-relatives.webp"); }

/* Decoro in alto a destra, al posto dei disegni botanici. */
body[data-look]::before {
  display: block;
  /* In cima alla pagina, non fisso: scorrendo se ne va con la testata. */
  position: absolute;
  inset: 0 0 auto 0;
  height: 260px;
  background: var(--deco, none) right -26px top -8px / 230px auto no-repeat;
  opacity: .92;
}

body[data-look="relatives"]::before,
body.on-intro[data-look]::before { display: none; }

/* Elementi che avevano il rosa scritto a mano: ora seguono lo stile. */
body[data-look] .greeting-heart { display: none; }
body[data-look] .kicker { color: var(--rose-dark); }
body[data-look] .kicker:before { background: var(--rose); }
body[data-look] .hero h2 { color: var(--title, var(--ink)); }
body[data-look] .pill.rose { color: var(--rose-dark); border-color: var(--line); background: var(--rose-soft); }
body[data-look] .pill.rose:before { background: var(--rose); }
body[data-look] .row-chevron { color: var(--rose); }
body[data-look] .btn.primary { box-shadow: 0 12px 24px color-mix(in srgb, var(--rose-dark) 24%, transparent), inset 0 1px 0 rgba(255, 255, 255, .3); }
body[data-look] .subnav .chip.active { color: #fff; border-color: transparent; background: var(--rose-grad); }
body[data-look] .sidebar { background: rgba(255, 255, 255, .92); border-top-color: var(--line); }
body[data-look] .nav button { color: var(--muted); }
body[data-look] .nav button.active { color: #fff; background: var(--rose-grad); box-shadow: 0 8px 18px color-mix(in srgb, var(--rose-dark) 26%, transparent); }
body[data-look] .nav button.active .ico svg { fill: rgba(255, 255, 255, .25); }
body[data-look="couple"] .nav button.active { color: var(--rose-dark); background: var(--rose-soft); box-shadow: none; }
body[data-look="couple"] .nav button.active .ico svg { fill: color-mix(in srgb, var(--rose) 30%, transparent); }
body[data-look] .metric .icon,
body[data-look] .relation-icon { color: var(--rose-dark); border-color: transparent; background: var(--rose-soft); }
body[data-look] .metric strong { color: var(--title, var(--ink)); }

/* Carattere di ogni stile. */
body[data-look="friends"] .card,
body[data-look="groups"] .card,
body[data-look="friends"] .score-card,
body[data-look="groups"] .score-card { border-radius: 26px; }
body[data-look="friends"] .home-hero .pill { color: #0f8576; border-color: #ffe08a; background: #fff3c4; transform: rotate(-2deg); }
body[data-look="friends"] .home-hero .pill:before { background: #ffc94d; }
body[data-look="friends"] .metric .icon { color: #0f8576; background: #fff3c4; }
body[data-look="groups"] .home-hero .pill { color: #fff; border-color: transparent; background: var(--rose-grad); }
body[data-look="groups"] .home-hero .pill:before { background: #fff; }
body[data-look="groups"] .wordmark { color: #d83e3a; }
body[data-look="groups"] .score-bars i:nth-child(odd) { background: linear-gradient(180deg, #ff9ecb, #c77dff); }
body[data-look="work"] .card,
body[data-look="work"] .section,
body[data-look="work"] .metric,
body[data-look="work"] .score-card,
body[data-look="work"] .emerge { border-radius: 14px; }
body[data-look="work"] .home-cta,
body[data-look="work"] .btn { border-radius: 14px; }
body[data-look="work"] .home-hero .pill { color: var(--rose-dark); border-color: transparent; background: var(--rose-soft); }
body[data-look="work"] .home-hero .pill:before { background: var(--rose); }
body[data-look="work"] .greeting h2 { font-weight: 600; }
body[data-look="family"] .home-hero .pill { color: var(--rose-dark); border-color: transparent; background: var(--rose-soft); }
body[data-look="family"] .home-hero .pill:before { background: #7f9a63; }

dialog.stories[data-theme="teal"] { background: linear-gradient(160deg, #e3f8f3, #b9ebe1); }
dialog.stories[data-theme="terra"] { background: linear-gradient(160deg, #fdf0e3, #f1cfb4); }
dialog.stories[data-theme="slate"] { background: linear-gradient(160deg, #eaf1fa, #c3d5ec); }

dialog.stories[data-theme="coral"] { background: linear-gradient(160deg, #ffe9df, #ffc3b3); }

/* ---------- Home: riquadri, schede, iniziali, gruppi (mockup) ---------- */

.metrics-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics-row .metric { min-height: 104px; }
.metrics-row .metric strong { margin-top: 4px; font-family: var(--sans); font-size: 21px; font-weight: 600; }
.metrics-row .metric .metric-label { font-size: 11.5px; }

.home-tabs { margin: -4px 0 -2px; }

.hero-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-members { color: var(--muted); font-size: 12.5px; }

.avatar-stack { display: inline-flex; }
.avatar-stack i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-left: -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--rose);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}
.avatar-stack i:first-child { margin-left: 0; }
.avatar-stack .tone-1 { background: var(--rose-dark); }
.avatar-stack .tone-2 { background: #f0b429; }
.avatar-stack .more { color: var(--rose-dark); background: var(--rose-soft); }

.score-value.stacked { display: grid; gap: 0; }
.score-value.stacked small { font-size: 13px; }
.score-bars.labelled { align-items: stretch; gap: 8px; }
.score-bars.labelled span { display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: 3px; }
.score-bars.labelled span i { align-self: end; width: 12px; }
.score-bars.labelled b { color: var(--muted); font-size: 10px; font-weight: 500; }
body[data-look="groups"] .score-bars.labelled span:nth-child(odd) i { background: linear-gradient(180deg, #ff9ecb, #c77dff); }

.emerge-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.emerge-head h3 { margin: 0; }
.emerge-head .link-btn { color: var(--rose-dark); font-size: 13px; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
}
.topic-chip b { color: var(--rose); }
.topic-chip i { color: var(--muted); font-size: 12px; font-style: normal; }

.mood { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 18px; border-radius: 22px; background: rgba(255, 255, 255, .78); }
.mood-face { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: #8a5a00; background: #ffd166; }
.mood-face svg { width: 28px; height: 28px; }
.mood-body { display: grid; gap: 3px; font-size: 13px; }
.mood-body strong { color: var(--rose-dark); font-size: 15px; }
.mood-body .bar { height: 8px; overflow: hidden; border-radius: 8px; background: var(--rose-soft); }
.mood-body .bar span { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #ff7eb3, #ffb347); }
.mood-value { font-size: 15px; font-weight: 600; }

/* ---------- Report (pagina Analisi, mockup "Report & Insight") ---------- */

.chart-line { fill: none; stroke: var(--rose); stroke-width: 5; stroke-linecap: round; }
.chart-dot { fill: var(--rose); stroke: #fff; stroke-width: 4; }

.report-score-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.report-score h3, .report-block h3, .report-insight h3 { margin: 0 0 4px; font-size: 15.5px; font-weight: 500; }
.report-score .score-value strong { font-size: 64px; }
.report-score-side { display: grid; justify-items: end; gap: 4px; text-align: right; }
.report-score-side small { color: var(--muted); font-size: 11.5px; }
.report-change { font-size: 14px; font-weight: 600; }
.report-change.up { color: #2f9e6b; }
.report-change.down { color: var(--danger); }
.mood-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--rose-dark); font-weight: 600; }
.mood-inline svg { width: 30px; height: 30px; padding: 3px; border-radius: 50%; color: #8a5a00; background: #ffd166; }

.report-radar { display: block; width: 100%; max-width: 360px; height: auto; margin: 4px auto 0; }
.radar-grid { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-shape { fill: var(--rose-soft); stroke: var(--rose); stroke-width: 2; stroke-linejoin: round; opacity: .92; }
.radar-dot { fill: var(--rose); stroke: #fff; stroke-width: 1.5; }
.radar-label { fill: var(--muted); font-size: 11.5px; }
.radar-value { fill: var(--title, var(--ink)); font-family: var(--serif); font-size: 17px; font-weight: 600; }

.dims-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; text-align: center; }
/* Dimensioni per legame: 5 in fila, 6 su due righe da 3. */
.dims-row.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dims-row.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; }
.dims-row.cols-5 .dim-icon { width: 40px; height: 40px; }
/* Pochi dati per dire qualcosa: il riquadro resta, più tenue, con "—". */
.metric.is-empty strong, .dim.is-empty strong { color: var(--muted); }
.metrics-row .metric .metric-note { color: var(--muted); font-size: 10.5px; line-height: 1.2; }
.dim { display: grid; justify-items: center; gap: 4px; }
.dim-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: var(--rose-dark); background: var(--rose-soft); }
.dim-icon svg { width: 22px; height: 22px; }
.dim-label { color: var(--muted); font-size: 11.5px; }
.dim strong { color: var(--title, var(--ink)); font-size: 20px; font-weight: 600; }
body[data-look="friends"] .dim-icon { color: #0f8576; background: #fff3c4; }
body[data-look="work"] .dim-icon { border-radius: 12px; }

.report-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.report-split .section { padding: 14px; }
.report-split .score-bars { margin-top: 8px; justify-content: space-between; }
.member-list { display: grid; gap: 8px; margin: 6px 0 0; padding: 0; list-style: none; }
.member-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.member-list i { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--rose); font-size: 10px; font-style: normal; font-weight: 600; }
.member-list .tone-1 { background: var(--rose-dark); }
.member-list .tone-2 { background: #f0b429; }
.member-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.report-insight { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.report-insight p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.insight-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--rose-dark); background: var(--rose-soft); }
.insight-icon svg { width: 22px; height: 22px; }
.report-insight .row-chevron { border: 0; background: none; padding: 6px; }
body[data-look="work"] .report-insight { border-color: transparent; background: linear-gradient(135deg, #25467a, #17305a); }
body[data-look="work"] .report-insight h3 { color: #fff; }
body[data-look="work"] .report-insight p { color: rgba(255, 255, 255, .82); }
body[data-look="work"] .report-insight .insight-icon { color: #fff; background: rgba(255, 255, 255, .16); }
body[data-look="work"] .report-insight .row-chevron { color: #fff; }

/* ---------- Onboarding (pagina Importa, mockup "Onboarding & Setup") ---------- */

.onb-progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
.onb-back { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--ink); }
.onb-back svg { width: 20px; height: 20px; }
.onb-bar { width: 120px; height: 4px; border-radius: 4px; background: var(--line); }
.onb-bar i { display: block; width: 33%; height: 100%; border-radius: 4px; background: var(--rose-grad); }

.onb-head h2 { margin: 0 0 6px; max-width: 80%; color: var(--title, var(--ink)); font-family: var(--serif); font-size: 31px; font-weight: 600; line-height: 1.08; }
.onb-head p { margin: 0; max-width: 78%; color: var(--muted); font-size: 14px; line-height: 1.4; }

.onb-card { display: grid; gap: 10px; padding: 16px; border-radius: 22px; background: rgba(255, 255, 255, .8); }
.onb-card h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.onb-card h3 b { margin-right: 6px; color: var(--rose-dark); }

.onb-row {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
  list-style: none;
}
.onb-row::-webkit-details-marker { display: none; }
.onb-row.alt { grid-template-columns: 44px minmax(0, 1fr); border-style: dashed; background: transparent; color: var(--rose-dark); }
.onb-row strong, .onb-option strong, .switch-row strong { display: block; font-size: 14.5px; font-weight: 600; }
.onb-row small, .onb-option small, .switch-row small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.onb-details[open] .onb-row .row-chevron { transform: rotate(90deg); }
.onb-details .tabs { margin-top: 12px; }

.onb-ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--rose-dark); background: var(--rose-soft); }
.onb-ico svg { width: 22px; height: 22px; }
.onb-ico.wa { color: #fff; background: #25d366; }

.onb-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.onb-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 60px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-align: left;
}
.onb-option[aria-pressed="true"] { border-color: var(--rose); background: var(--rose-soft); box-shadow: 0 6px 14px color-mix(in srgb, var(--rose-dark) 14%, transparent); }
.onb-option-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--rose-dark); background: var(--rose-soft); }
.onb-option[aria-pressed="true"] .onb-option-icon { color: #fff; background: var(--rose); }
.onb-option-icon svg { width: 18px; height: 18px; }

.switch-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; cursor: pointer; }
.switch { appearance: none; width: 48px; height: 28px; margin: 0; border-radius: 28px; background: #d9d4d0; position: relative; cursor: pointer; transition: background .2s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .2s ease; }
.switch:checked { background: var(--rose); }
.switch:checked::after { transform: translateX(20px); }

.onb-demo { justify-self: center; }
.onb-tagline { margin: 4px 0 0; color: var(--rose-dark); font-family: var(--serif); font-size: 21px; font-style: italic; text-align: center; transform: rotate(-2deg); }
body[data-look="work"] .onb-card, body[data-look="work"] .onb-row, body[data-look="work"] .onb-option { border-radius: 14px; }

@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

body[data-look] .report-score .pill { color: var(--rose-dark); border-color: var(--line); background: var(--rose-soft); }
body[data-look] .report-score .pill:before { background: var(--rose); }
.dim-label { font-size: 10.5px; white-space: nowrap; }

/* ---------- Pagine interne: tutto segue lo stile ---------- */

:root { --ink-2: #4f413a; --second: var(--sage); }
body[data-look] { --ink-2: color-mix(in srgb, var(--ink) 84%, #fff); }
body[data-look="couple"] { --second: #c99a5c; }
body[data-look="friends"] { --second: #ffc94d; }
body[data-look="groups"] { --second: #c77dff; }
body[data-look="work"] { --second: #8fb0dc; }
body[data-look="family"] { --second: #7f9a63; }
body[data-look="relatives"] { --second: #a9b08a; }

.dots i.b, .duel-legend i.b { background: var(--second); }

body[data-look] .section { border-radius: 22px; background: rgba(255, 255, 255, .78); }
body[data-look] .section.soft { background: var(--rose-soft); }
body[data-look] .hero h2,
body[data-look] .person-head h3,
body[data-look] .gauge-center strong,
body[data-look] .trend-sentence { color: var(--title, var(--ink)); }
body[data-look] .tabs button[aria-selected="true"],
body[data-look] .person-picker button[aria-selected="true"] { color: #fff; border-color: transparent; background: var(--rose-grad); }
body[data-look] .advice-num,
body[data-look] .moment .dot,
body[data-look] .quote-mark,
body[data-look] .feature-icon,
body[data-look] .empty-icon,
body[data-look] .dropzone-icon { color: var(--rose-dark); background: var(--rose-soft); }
body[data-look] .summary-box summary::after,
body[data-look] .link-btn { color: var(--rose-dark); }
body[data-look] .suggested-message { border-color: var(--line); background: var(--rose-soft); }
body[data-look] .trend-band.now .trend-band-bar { background: var(--rose-grad); }
body[data-look] .round-btn { color: var(--rose-dark); border-color: var(--surface-line); }
body[data-look] .quick-icon { color: var(--rose-dark); }
body[data-look] .demo-banner { border-color: var(--line); background: rgba(255, 255, 255, .7); }
body[data-look] dialog.sheet { background: var(--cream); }
body[data-look="work"] .section,
body[data-look="work"] dialog.sheet { border-radius: 14px; }
body[data-look="work"] .trait-card,
body[data-look="work"] .relation-card { border-radius: 12px; }

/* Rifinitura visiva aderente ai mockup: le illustrazioni restano sullo sfondo,
 * mentre testata e contenuti mantengono contrasto e leggibilità. */
body[data-look]::before {
  z-index: 0;
  height: min(480px, 64vh);
  background-position: right -30px top -14px;
  background-size: min(390px, 78vw) auto;
  opacity: .72;
}
body.on-intro[data-look]::before { display: block; }

.app { position: relative; z-index: 1; }

body[data-look] .topbar.home-top { min-height: 48px; }
body[data-look] .wordmark {
  font-size: 39px;
  letter-spacing: -1.3px;
  text-shadow: 0 1px rgba(255, 255, 255, .75);
}
body[data-look] .home-hero { position: relative; padding-top: 8px; }
body[data-look] .hero-title { max-width: 88%; font-size: clamp(34px, 9vw, 42px); }
body[data-look] .score-card,
body[data-look] .report-score,
body[data-look] .report-block,
body[data-look] .onb-card,
body[data-look] .emerge {
  border-color: var(--surface-line);
  background: linear-gradient(145deg, rgba(255, 255, 255, .94), rgba(255, 255, 255, .72));
  box-shadow: var(--shadow);
}
body[data-look] .metric {
  border-color: var(--surface-line);
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--rose-dark) 8%, transparent);
}
body[data-look] .subnav { padding: 5px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .76); }
body[data-look] .subnav .chip { min-height: 34px; }
body[data-look] .home-cta { box-shadow: 0 10px 24px color-mix(in srgb, var(--rose-dark) 25%, transparent); }
body[data-look] .onb-head { padding-top: 5px; }
body[data-look] .onb-head h2 { max-width: 90%; font-size: 34px; }
body[data-look] .onb-option[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--rose), 0 7px 16px color-mix(in srgb, var(--rose-dark) 12%, transparent); }

body[data-look="couple"] .report-score,
body[data-look="couple"] .score-card { background: linear-gradient(145deg, #fff 8%, #fff0f2 100%); }
body[data-look="couple"] .report-insight { background: linear-gradient(110deg, #fff, #fce7eb); }
body[data-look="friends"] .report-score,
body[data-look="friends"] .score-card { background: linear-gradient(145deg, #fff 8%, #e2f7f1 100%); }
body[data-look="friends"] .report-insight { border-color: #d4efe8; background: linear-gradient(110deg, #f0fcf8, #fff7d8); }
body[data-look="groups"] .report-score,
body[data-look="groups"] .score-card { background: linear-gradient(145deg, #fff 8%, #ffe5df 55%, #ffe6f0 100%); }
body[data-look="groups"] .report-insight { border-color: #ffd6cd; background: linear-gradient(110deg, #fff1e8, #ffe5ef); }
body[data-look="work"] .report-score,
body[data-look="work"] .score-card { background: linear-gradient(145deg, #fff 8%, #e7f0fb 100%); }
body[data-look="work"] .report-block { background: rgba(255, 255, 255, .9); }
body[data-look="family"] .report-score,
body[data-look="family"] .score-card { background: linear-gradient(145deg, #fff 8%, #fbebdc 100%); }
body[data-look="family"] .report-insight { border-color: #f0dccb; background: linear-gradient(110deg, #fff5e9, #f0f0df); }

@media (min-width: 600px) {
  body[data-look]::before { background-size: 390px auto; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-look] *, body[data-look] *::before, body[data-look] *::after { scroll-behavior: auto; }
}

/* La stessa identità accompagna anche le schermate interne, i fogli e i
 * dialoghi: cambiano accento, superfici e stati attivi, non la semantica. */
body[data-look] .section,
body[data-look] .card,
body[data-look] .relation-card,
body[data-look] .trait-card,
body[data-look] .trend-card,
body[data-look] .bloom-card,
body[data-look] .install-card,
body[data-look] .demo-banner,
body[data-look] .person-card,
body[data-look] dialog.sheet {
  border-color: var(--surface-line);
  box-shadow: var(--shadow);
}

body[data-look] .section,
body[data-look] .card,
body[data-look] .relation-card,
body[data-look] .trait-card,
body[data-look] .trend-card,
body[data-look] .bloom-card,
body[data-look] .install-card,
body[data-look] .demo-banner,
body[data-look] .person-card {
  background-color: rgba(255, 255, 255, .82);
}

body[data-look] .feature-icon,
body[data-look] .empty-icon,
body[data-look] .quick-icon,
body[data-look] .metric-row-icon,
body[data-look] .quote-mark,
body[data-look] .advice-num,
body[data-look] .signal-dot,
body[data-look] .dot,
body[data-look] .person-avatar,
body[data-look] .trait-emoji,
body[data-look] .drive-chip,
body[data-look] .focus-bubble,
body[data-look] .dim-icon,
body[data-look] .insight-icon {
  color: var(--rose-dark);
  border-color: var(--line);
  background-color: var(--rose-soft);
}

body[data-look] .feature-list li,
body[data-look] .moment,
body[data-look] .quote,
body[data-look] .advice,
body[data-look] .signal,
body[data-look] .helpline,
body[data-look] .drive-chip,
body[data-look] .focus-bubble,
body[data-look] .person-picker button,
body[data-look] .tabs button,
body[data-look] .btn.who,
body[data-look] .context-chip,
body[data-look] .topic-chip {
  border-color: var(--line);
}

body[data-look] .person-picker button[aria-selected="true"],
body[data-look] .tabs button[aria-selected="true"],
body[data-look] .btn.context-option[aria-pressed="true"],
body[data-look] .btn.who[aria-pressed="true"],
body[data-look] .context-chip[aria-pressed="true"] {
  color: var(--rose-dark);
  border-color: var(--rose);
  background: var(--rose-soft);
}

body[data-look] .chart-line,
body[data-look] .spark-line,
body[data-look] .rhythm-line { stroke: var(--rose); }
body[data-look] .chart-dot,
body[data-look] .spark-dot,
body[data-look] .radar-dot { fill: var(--rose); }
body[data-look] .spark-area,
body[data-look] .radar-shape,
body[data-look] .rhythm-area { fill: var(--rose-soft); }
body[data-look] .radar-grid,
body[data-look] .year-dot { stroke: var(--line); }
body[data-look] .radar-shape { stroke: var(--rose); }
body[data-look] .bar { --bar-accent: var(--rose); }
body[data-look] .bar span { background: var(--rose-grad); }
body[data-look="work"] { --work-in: #2f6db5; --work-off: #c98a4b; }
body[data-look] .trend-band-bar { background: var(--rose-soft); }
body[data-look] .trend-band.now .trend-band-bar { background: var(--rose-grad); }

body[data-look] .link-btn,
body[data-look] .summary-box summary::after,
body[data-look] .person-motto,
body[data-look] .drive-chip strong,
body[data-look] .quote-mark { color: var(--rose-dark); }
body[data-look] .suggested-message,
body[data-look] .duel-row,
body[data-look] .week-grid-wrap { border-color: var(--line); }
body[data-look] dialog.sheet { background: var(--cream); }

body[data-look="friends"] .feature-icon,
body[data-look="friends"] .quick-icon,
body[data-look="friends"] .dim-icon { color: #0f8576; background: #fff3c4; }
body[data-look="groups"] .section.soft,
body[data-look="groups"] .suggested-message { background: linear-gradient(145deg, #fff2e8, #ffe6ef); }
body[data-look="work"] .section,
body[data-look="work"] .card,
body[data-look="work"] .relation-card,
body[data-look="work"] .trait-card,
body[data-look="work"] .trend-card,
body[data-look="work"] .bloom-card,
body[data-look="work"] .install-card { border-radius: 14px; }
body[data-look="work"] .section.soft,
body[data-look="work"] .suggested-message { background: linear-gradient(145deg, #f4f8fd, #e6eef8); }
body[data-look="family"] .section.soft,
body[data-look="family"] .suggested-message { background: linear-gradient(145deg, #fff7eb, #f0f0df); }
body[data-look="family"] .feature-icon,
body[data-look="family"] .quick-icon,
body[data-look="family"] .dim-icon { color: #94492a; background: #f9e6d8; }

body[data-look="couple"] dialog.stories { --story-accent: #b83a58; }
body[data-look="friends"] dialog.stories { --story-accent: #0f8576; }
body[data-look="groups"] dialog.stories { --story-accent: #d83e3a; }
body[data-look="work"] dialog.stories { --story-accent: #1c3a66; }
body[data-look="family"] dialog.stories { --story-accent: #94492a; }

/* Direzione cromatica e decorativa completa per ogni schermata. */
body[data-look="couple"] {
  background:
    radial-gradient(ellipse at 100% 12%, rgba(242, 157, 174, .32), transparent 42%),
    radial-gradient(ellipse at 0% 72%, rgba(255, 221, 226, .62), transparent 44%),
    #fff7f8;
}
body[data-look="friends"] {
  background:
    radial-gradient(ellipse at 100% 12%, rgba(255, 222, 113, .30), transparent 35%),
    radial-gradient(ellipse at 0% 58%, rgba(117, 220, 202, .28), transparent 48%),
    #f3fcf9;
}
body[data-look="groups"] {
  background:
    radial-gradient(ellipse at 100% 8%, rgba(255, 175, 78, .35), transparent 34%),
    radial-gradient(ellipse at 0% 52%, rgba(255, 106, 155, .20), transparent 46%),
    #fff5f2;
}
body[data-look="work"] {
  background:
    radial-gradient(ellipse at 100% 10%, rgba(130, 174, 226, .34), transparent 40%),
    radial-gradient(ellipse at 0% 70%, rgba(214, 228, 246, .48), transparent 44%),
    #f5f8fc;
}
body[data-look="family"] {
  background:
    radial-gradient(ellipse at 100% 10%, rgba(238, 196, 151, .36), transparent 42%),
    radial-gradient(ellipse at 0% 75%, rgba(179, 194, 144, .24), transparent 43%),
    #fcf6ed;
}

body[data-look]::before {
  height: min(350px, 48vh);
  background-position: right -82px top 4px;
  background-size: min(270px, 66vw) auto;
  opacity: .96;
}
body[data-look="couple"]::before { background-position: right -78px top 10px; background-size: min(260px, 64vw) auto; }
body[data-look="friends"]::before { background-position: right -86px top 10px; background-size: min(300px, 72vw) auto; }
body[data-look="groups"]::before { background-image: var(--deco), url("../assets/img/photo-groups-deco.webp"); background-position: right -90px top 8px, left -90px top -50px; background-size: min(290px, 70vw) auto, min(240px, 58vw) auto; }
body[data-look="work"]::before { background-position: right -42px top 16px; background-size: min(300px, 72vw) auto; }
body[data-look="family"]::before { background-position: right -90px top 12px; background-size: min(300px, 72vw) auto; }

/* Le quattro voci della panoramica e del report restano interamente visibili
 * sul telefono, come nelle barre a schede dei mockup. */
#page-home .home-tabs .chip,
#page-relation .subnav .chip {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  padding-inline: 6px;
  font-size: clamp(11px, 3vw, 13px);
}

body[data-look="couple"] .metric,
body[data-look="couple"] .person-card { border-radius: 22px; }
body[data-look="friends"] .metric,
body[data-look="friends"] .person-card,
body[data-look="friends"] .trait-card { border-radius: 26px; }
body[data-look="friends"] .metric { border-color: #c8eae3; background: linear-gradient(155deg, #fff 10%, #e9faf5); }
body[data-look="groups"] .metric,
body[data-look="groups"] .person-card,
body[data-look="groups"] .trait-card { border-radius: 20px; }
body[data-look="groups"] .metric { border-color: #ffd3c9; background: linear-gradient(155deg, #fff 10%, #fff0e9); }
body[data-look="work"] .metric,
body[data-look="work"] .person-card,
body[data-look="work"] .trait-card { border-radius: 14px; }
body[data-look="work"] .metric { border-color: #d1deef; background: linear-gradient(155deg, #fff 10%, #edf3fb); }
body[data-look="family"] .metric,
body[data-look="family"] .person-card,
body[data-look="family"] .trait-card { border-radius: 20px; }
body[data-look="family"] .metric { border-color: #ead5c1; background: linear-gradient(155deg, #fff 10%, #fcf0e3); }

body[data-look="couple"] .section h3,
body[data-look="couple"] .block-title { color: #7a2338; }
body[data-look="friends"] .section h3,
body[data-look="friends"] .block-title { color: #0f625b; }
body[data-look="groups"] .section h3,
body[data-look="groups"] .block-title { color: #96384d; }
body[data-look="work"] .section h3,
body[data-look="work"] .block-title { color: #1c3a66; }
body[data-look="family"] .section h3,
body[data-look="family"] .block-title { color: #794020; }

body[data-look] .quick-actions button {
  border-color: var(--line);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--rose-dark) 9%, transparent);
}
body[data-look] .person-picker button,
body[data-look] .onb-option,
body[data-look] .btn.who,
body[data-look] .context-chip { background-color: rgba(255, 255, 255, .84); }
body[data-look] .person-picker button[aria-selected="true"],
body[data-look] .onb-option[aria-pressed="true"],
body[data-look] .btn.context-option[aria-pressed="true"],
body[data-look] .btn.who[aria-pressed="true"] { background: var(--rose-soft); }

@media (min-width: 900px) {
  body[data-look]::before { background-size: min(500px, 42vw) auto; }
  body[data-look="groups"]::before { background-size: min(500px, 42vw) auto, min(360px, 30vw) auto; }
  .app { background: transparent; }
}

body[data-look]:not([data-look="couple"]) .trait-card.tone-rose,
body[data-look]:not([data-look="couple"]) .person-avatar.tone-rose,
body[data-look]:not([data-look="couple"]) .avatar.tone-rose { background: var(--rose-soft); }

/* ---------- Il giardino (archivio delle chat analizzate) ---------- */

body.on-garden .app { padding-bottom: 24px; }
body.on-garden .sidebar { display: none; }

.garden-hero .hero-title { max-width: none; }
.garden-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

/* Ogni card è un'anteprima della Home di quella chat: colori, carattere del
   titolo e immagine del suo legame, qualunque sia il tema della pagina. */
.garden-item { --c: #d98c92; --c-dark: #b9656f; --c-soft: #f7e3df; --g-title: var(--ink); --g-style: normal; --g-img: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.garden-item[data-look="couple"], .quad[data-look="couple"], .quad-cta[data-look="couple"] { --c: #e2607a; --c-dark: #b83a58; --c-soft: #fde3e8; --g-title: #7a2338; --g-img: url("../assets/img/photo-couple-hearts.webp"); }
.garden-item[data-look="friends"], .quad[data-look="friends"], .quad-cta[data-look="friends"] { --c: #1fb5a3; --c-dark: #0f8576; --c-soft: #dcf5f0; --g-title: #0f3f3a; --g-style: italic; --g-img: url("../assets/img/photo-friends-group.webp"); }
.garden-item[data-look="groups"], .quad[data-look="groups"], .quad-cta[data-look="groups"] { --c: #ff6b5e; --c-dark: #d83e3a; --c-soft: #ffe4e0; --g-title: #3d1b2c; --g-style: italic; --g-img: url("../assets/img/photo-groups-large.webp"); }
.garden-item[data-look="work"], .quad[data-look="work"], .quad-cta[data-look="work"] { --c: #2f6db5; --c-dark: #1c4f8c; --c-soft: #dfeaf7; --g-title: #14233b; --g-img: url("../assets/img/photo-work-team.webp"); }
.garden-item[data-look="family"], .quad[data-look="family"], .quad-cta[data-look="family"] { --c: #c8704a; --c-dark: #96492a; --c-soft: #f7e4d8; --g-title: #5a2a17; --g-img: url("../assets/img/photo-family-group.webp"); }
.garden-item[data-look="relatives"], .quad[data-look="relatives"], .quad-cta[data-look="relatives"] { --c: #8f9a6c; --c-dark: #5f6b3f; --c-soft: #ebeedf; --g-title: #5b3f12; --g-img: url("../assets/img/photo-relatives.webp"); }

.garden-row {
  position: relative;
  width: 100%;
  min-height: 136px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 3px;
  padding: 14px 42% 12px 18px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--c) 30%, #fff);
  border-radius: 24px;
  background: linear-gradient(105deg, #fff 0%, color-mix(in srgb, var(--c-soft) 70%, #fff) 55%, var(--c-soft) 100%);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--c-dark) 11%, transparent);
  color: var(--ink);
  text-align: left;
}

/* L'immagine del legame, intera e centrata nella metà destra della card. */
.garden-row::after {
  content: "";
  position: absolute;
  inset: 8px 8px 0 54%;
  background: var(--g-img) center bottom / contain no-repeat;
  pointer-events: none;
}

.garden-row > * { position: relative; z-index: 1; }
.garden-kicker { color: var(--c-dark); font-size: 10.5px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; }
.garden-name { max-width: 100%; overflow: hidden; color: var(--g-title); font-family: var(--serif); font-size: 27px; font-style: var(--g-style); font-weight: 600; line-height: 1.08; text-overflow: ellipsis; white-space: nowrap; }
.garden-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.garden-foot { display: inline-flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.garden-foot strong { color: var(--c-dark); font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; }
.garden-foot small { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.garden-foot small.up, .since-chip.up b, .change-delta.up { color: #4f7a3a; }
.garden-foot small.down, .since-chip.down b, .change-delta.down { color: #b4474f; }
.garden-spark { width: 58px; height: 22px; align-self: center; overflow: visible; }
.garden-spark polyline { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.garden-spark circle { fill: var(--c-dark); }

.plant { width: 18px; height: 23px; flex: none; overflow: visible; }
.plant-stem { fill: none; stroke: var(--c-dark); stroke-width: 2.4; stroke-linecap: round; opacity: .7; }
.plant-leaf { fill: color-mix(in srgb, var(--c) 45%, #9fb07a); opacity: .9; }
.plant-head { fill: var(--c); }
.plant-eye { fill: #fff3c9; stroke: var(--c-dark); stroke-width: .8; }

.garden-remove { width: 40px; height: 40px; color: var(--danger); font-size: 22px; line-height: 1; }
.garden-note { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.garden-edit { justify-self: center; font-size: 13.5px; }

/* ---------- Dall'ultima volta ---------- */

.since-card {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--rose-soft), rgba(255, 255, 255, .86) 62%);
  color: inherit;
  text-align: left;
}

.since-card.quiet { background: rgba(255, 255, 255, .7); }
.since-card p { margin: 0; font-size: 14px; }
.since-head { display: inline-flex; align-items: center; gap: 7px; color: var(--rose-dark); font-size: 12.5px; font-weight: 600; letter-spacing: .2px; }
.since-head svg { width: 15px; height: 15px; }
.since-count { font-size: 15px; font-weight: 500; }
.since-count b { color: var(--title, var(--ink)); font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1; }
.since-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.since-chip { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .8); font-size: 12.5px; }
.since-chip b { font-weight: 600; }
.since-topics { color: var(--muted); font-size: 13px; }
.since-more { display: inline-flex; align-items: center; gap: 6px; justify-self: end; color: var(--rose-dark); font-size: 13.5px; font-weight: 500; }
.since-more svg { width: 16px; height: 16px; }

.change-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.change-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto 62px; gap: 4px 12px; align-items: baseline; }
.change-label { font-size: 14.5px; font-weight: 500; }
.change-values { display: inline-flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 14px; }
.change-values i { font-style: normal; opacity: .6; }
.change-values strong { color: var(--title, var(--ink)); font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1; }
.change-delta { color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
.change-track { position: relative; grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--rose-soft); }
.change-track i { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: var(--rose); opacity: .45; }
.change-track b { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border: 2px solid #fff; border-radius: 50%; background: var(--rose-dark); }

.history { display: flex; align-items: flex-end; gap: 10px; margin: 0 0 8px; padding: 0; overflow-x: auto; list-style: none; }
.history li { flex: 0 0 44px; display: grid; justify-items: center; gap: 3px; }
.history .bar { width: 14px; height: 72px; display: flex; align-items: flex-end; border-radius: 8px; background: var(--rose-soft); }
.history .bar span { width: 100%; border-radius: 8px; background: var(--rose); opacity: .55; }
.history li.current .bar span { opacity: 1; }
.history strong { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1; }
.history small { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------- Conferma del legame ---------- */

.context-guess-card { display: grid; justify-items: center; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--rose-soft); text-align: center; }
.context-guess-kicker { color: var(--muted); font-size: 13px; }
.context-guess-name { display: inline-flex; align-items: center; gap: 10px; color: var(--rose-dark); font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1.1; }
.context-guess-name svg { width: 26px; height: 26px; }
.context-guess-why { color: var(--ink); font-size: 13px; line-height: 1.4; }
.context-confirm { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.context-more summary { min-height: 44px; display: flex; align-items: center; color: var(--rose-dark); font-size: 15px; font-weight: 500; cursor: pointer; }
.context-more .who-list { margin-top: 6px; }

/* ---------- Ingresso nelle pagine ---------- */

@media (prefers-reduced-motion: no-preference) {
  .page.enter > * { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .page.enter > :nth-child(2) { animation-delay: 50ms; }
  .page.enter > :nth-child(3) { animation-delay: 100ms; }
  .page.enter > :nth-child(4) { animation-delay: 150ms; }
  .page.enter > :nth-child(5) { animation-delay: 200ms; }
  .page.enter > :nth-child(6) { animation-delay: 250ms; }
  .page.enter > :nth-child(7) { animation-delay: 300ms; }
  .page.enter > :nth-child(n + 8) { animation-delay: 350ms; }
  .page.enter .garden-item { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .page.enter .garden-item:nth-child(2) { animation-delay: 70ms; }
  .page.enter .garden-item:nth-child(3) { animation-delay: 140ms; }
  .page.enter .garden-item:nth-child(n + 4) { animation-delay: 210ms; }
  .page.enter .spark-line { stroke-dasharray: 1; animation: draw 1.1s .25s ease-out both; }
  .page.enter .spark-area, .page.enter .spark-dot { animation: fade .6s .9s both; }
  .page.enter .plant { transform-origin: 50% 100%; animation: grow .7s .15s cubic-bezier(.2, .9, .3, 1.2) both; }
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes grow { from { transform: scale(.3); opacity: 0; } }

@media (min-width: 900px) {
  body.on-garden .sidebar { display: block; }
}

/* ---------- Ingresso: lo schermo diviso in quattro legami ---------- */

.garden-top { display: inline-flex; align-items: center; gap: 12px; }
.start-hero .hero-title { max-width: none; }
.start-kicker { color: var(--rose-dark); font-size: 12.5px; font-weight: 600; letter-spacing: .3px; }

.quads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  /* Occupa lo schermo: via barra, titolo, pulsante e margini. */
  min-height: max(420px, calc(100dvh - 300px));
}

.quad {
  --c: #d98c92; --c-dark: #b9656f; --c-soft: #f7e3df; --g-title: var(--ink); --g-style: normal; --g-img: none;
  position: relative;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 3px;
  min-height: 190px;
  padding: 16px 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--c) 30%, #fff);
  border-radius: 26px;
  background: linear-gradient(180deg, #fff 0%, color-mix(in srgb, var(--c-soft) 75%, #fff) 45%, var(--c-soft) 100%);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--c-dark) 12%, transparent);
  color: var(--ink);
  text-align: left;
  transition: transform .25s ease, opacity .25s ease, filter .25s ease, box-shadow .25s ease;
}

/* La foto del legame riempie la parte bassa del riquadro. */
.quad::after {
  content: "";
  position: absolute;
  inset: 36% 6px 0 6px;
  background: var(--g-img) center bottom / contain no-repeat;
  pointer-events: none;
}

.quad > * { position: relative; z-index: 1; }
.quad-name { color: var(--g-title); font-family: var(--serif); font-size: 32px; font-style: var(--g-style); font-weight: 600; line-height: 1.05; }
.quad-note { color: var(--c-dark); font-size: 12.5px; font-weight: 500; }
.quad:active { transform: scale(.98); }

/* Chat in arrivo: il riquadro riconosciuto in evidenza, gli altri attenuati. */
.quads.arrival.has-guess .quad:not(.suggested) { opacity: .5; filter: saturate(.45); transform: scale(.95); box-shadow: none; }
.quad.suggested {
  z-index: 2;
  border: 3px solid var(--c);
  transform: scale(1.04);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 22%, transparent), 0 18px 40px color-mix(in srgb, var(--c-dark) 30%, transparent);
}
.quad-badge { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 4px; padding: 5px 10px; border-radius: 999px; background: var(--c); color: #fff; font-size: 11.5px; font-weight: 600; line-height: 1.1; }
.quad-badge svg { width: 13px; height: 13px; flex: none; }
.start-why { margin: 0; font-size: 14px; line-height: 1.45; text-align: center; }

@media (prefers-reduced-motion: no-preference) {
  .quad.suggested { animation: quad-glow 1.8s ease-in-out infinite; }
  .page.enter .quad { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .page.enter .quad:nth-child(2) { animation-delay: 70ms; }
  .page.enter .quad:nth-child(3) { animation-delay: 140ms; }
  .page.enter .quad:nth-child(4) { animation-delay: 210ms; }
  .page.enter .quad.suggested { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both, quad-glow 1.8s .5s ease-in-out infinite; }
}

@keyframes quad-glow {
  50% { box-shadow: 0 0 0 11px color-mix(in srgb, var(--c) 12%, transparent), 0 18px 40px color-mix(in srgb, var(--c-dark) 30%, transparent); }
}

@media (min-width: 900px) {
  .quads { min-height: 560px; }
}

/* Il pulsante di conferma prende il colore del riquadro riconosciuto. */
.btn.primary.quad-cta { border-color: transparent; background: linear-gradient(180deg, var(--c), var(--c-dark)); box-shadow: 0 12px 26px color-mix(in srgb, var(--c-dark) 28%, transparent); }

/* ---------- Sintesi completa a sezioni e proposte di Cura ---------- */

.summary-box.long h4 { margin: 18px 0 0; color: var(--rose-dark); font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.15; }
.summary-box.long h4 + p { margin-top: 6px; }

.care { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, .72); }
.care-head { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: center; }
.care-head h4 { margin: 0; color: var(--title, var(--ink)); font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.15; }
.care p { margin: 0; }
.care-text { color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.care-why { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.care-why strong { color: var(--rose-dark); font-weight: 600; }
.care-say { display: grid; gap: 3px; margin: 0; padding: 10px 14px; border-left: 3px solid var(--rose); border-radius: 0 14px 14px 0; background: var(--rose-soft); font-family: var(--serif); font-size: 18px; font-style: italic; line-height: 1.3; }
.care-say span { color: var(--rose-dark); font-family: var(--sans); font-size: 11px; font-style: normal; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; }

/* ---------- Livelli dei moduli: pallini pieni e vuoti ---------- */

.level-dots { display: inline-flex; align-items: center; gap: 4px; }
.level-dots i { width: 9px; height: 9px; border: 1.5px solid var(--rose-dark); border-radius: 50%; }
.level-dots i.on { background: var(--rose-dark); }

.hero-kicker-row { display: flex; align-items: center; gap: 10px; }
.level-btn { min-width: 44px; min-height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border: 0; border-radius: 999px; background: none; }

.module-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.module-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.module-list li:first-child { border-top: 0; }
.module-list strong { font-size: 15.5px; font-weight: 600; }
.module-list li > span:nth-child(2) { color: var(--muted); font-size: 13.5px; }
.module-levels summary { min-height: 44px; display: flex; align-items: center; color: var(--rose-dark); font-size: 15px; font-weight: 500; cursor: pointer; }
.module-levels ol { display: grid; gap: 12px; margin: 4px 0 12px; padding-left: 20px; }
.module-levels li strong { font-weight: 600; }
.module-levels li > span:last-child { display: block; margin-top: 2px; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.module-levels .pill { min-height: 22px; margin-left: 6px; padding: 0 9px; font-size: 11.5px; vertical-align: middle; }

/* Il livello del modulo anche nei quattro riquadri, nel colore del legame. */
.quad-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quad .level-dots i { border-color: var(--c-dark); }
.quad .level-dots i.on { background: var(--c-dark); }

/* "AI ●○○ Essenziale": i pallini con la sigla e il nome del livello. */
.level-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid color-mix(in srgb, var(--rose-dark) 30%, transparent); border-radius: 999px; background: rgba(255, 255, 255, .7); color: var(--rose-dark); font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap; }
.level-badge b { font-weight: 700; letter-spacing: .6px; }
.hero-kicker-row { flex-wrap: wrap; gap: 4px 10px; }
.level-btn { padding: 0; }
.quad .level-badge { margin-top: 4px; border-color: color-mix(in srgb, var(--c-dark) 30%, transparent); color: var(--c-dark); }

/* ---------- Foto del legame: dentro la testata, mai sotto i pulsanti ---------- */

/* Prima la foto stava nell'angolo della pagina, in parte fuori dallo schermo
   e dietro la barra in alto: andava bene per i ritagli stretti, non per le
   foto di gruppo. Ora sta intera nella testata di Home, Analisi e Importa,
   a destra del titolo; nelle altre pagine non compare. */
body[data-look]::before,
body.on-intro[data-look]::before { background-image: none; }

body[data-look]:not([data-look="garden"]) .home-hero,
body[data-look]:not([data-look="garden"]) .onb-head {
  position: relative;
  min-height: 128px;
  padding-right: min(42%, 180px);
}

body[data-look]:not([data-look="garden"]) .home-hero::after,
body[data-look]:not([data-look="garden"]) .onb-head::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(40%, 170px);
  background: var(--deco, none) center / contain no-repeat;
  pointer-events: none;
}

body[data-look] .home-hero .hero-title { max-width: none; font-size: clamp(28px, 8.4vw, 36px); }
body[data-look] .home-hero .hero-row { flex-wrap: wrap; }
body[data-look] .onb-head h2,
body[data-look] .onb-head p { max-width: none; }
body[data-look] .home-hero .hero-kicker { text-align: left; }

/* ---------- Lettura approfondita: avanzamento e interruttore di prova ---------- */

.read-chip {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  min-width: min(280px, 80vw);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 30px rgba(80, 50, 35, .18);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
}
.read-chip[hidden] { display: none; }
.read-chip b { height: 5px; overflow: hidden; border-radius: 5px; background: var(--rose-soft); }
.read-chip i { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--rose-dark); transition: width .3s ease; }

.module-list li { grid-template-columns: minmax(0, 1fr) auto auto; }
.module-trial { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.module-trial small { color: var(--muted); }

/* Lettura approfondita su richiesta: riquadro in Home e «Annulla» durante la lettura. */
.read-card { display: grid; gap: 8px; padding: 14px 18px; border-radius: 22px; background: rgba(255, 255, 255, .78); }
.read-card p { margin: 0; font-size: 14px; line-height: 1.45; }
.read-card .read-warn { color: #87601f; font-size: 13px; font-weight: 500; }
.read-card .btn { justify-self: start; min-height: 42px; }
.read-card .link-btn { min-height: 36px; padding: 4px 0; font-size: 13.5px; justify-self: start; }
.read-card.done { background: linear-gradient(135deg, var(--rose-soft), rgba(255, 255, 255, .86) 62%); }
.read-chip .link-btn { min-height: 30px; padding: 2px 0; font-size: 13px; justify-self: center; }

/* ---------- Scelta del livello di analisi ---------- */
.level-list { display: grid; gap: 10px; }
.level-option { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .84); color: var(--ink); text-align: left; }
.level-option.current { border-color: var(--rose); background: var(--rose-soft); }
.level-option:disabled { opacity: .55; }
.level-option-head { display: flex; align-items: center; gap: 10px; }
.level-option-head strong { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.1; }
.level-option-head .pill { min-height: 22px; margin: 0 0 0 auto; padding: 0 9px; font-size: 11.5px; }
.level-option-text { color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.level-option-note { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; }
.level-option-note.warn { color: #87601f; }

/* ---------- Aspetto: Automatico, Chiaro, Scuro (Profilo) ---------- */
/* La versione scura di tutto il resto è in dark.css. */

:root { --gauge-fill: rgba(255, 255, 255, .55); }

.theme-pick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream-2);
}

.theme-pick button {
  min-height: 42px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.theme-pick [aria-checked="true"] { color: #fff; background: var(--rose-grad); box-shadow: 0 6px 14px color-mix(in srgb, var(--rose-dark) 20%, transparent); }
.theme-note { margin: 10px 2px 0; color: var(--muted); font-size: 13.5px; }
body[data-look="work"] .theme-pick,
body[data-look="work"] .theme-pick button { border-radius: 12px; }

/* ---------- Testi che restano nei loro spazi (2026-11-02) ----------
 * Sul telefono le scritte possono crescere (carattere grande di Android:
 * nell'app arriva fino al 120%, vedi MainActivity) mentre pulsanti e
 * riquadri restano larghi uguali. Come nelle app grandi:
 * 1. un'etichetta può andare a capo, con la sillabazione italiana (lang="it");
 * 2. i numeri si rimpiccioliscono con la larghezza del riquadro (unità cqi);
 * 3. una fila di schede che non ci sta scorre di lato invece di schiacciarsi;
 * 4. solo dove niente di questo basta, i puntini (…). */
.chip, .pill, .btn, .metric-label, .metric-note, .dim-label, .theme-pick button,
.quad-name, .quad-note, .report-score-side small, .since-chip, .topic-chip, .hero-kicker {
  overflow-wrap: break-word;
  hyphens: auto;
}

/* 3. Schede di panoramica e report: riempiono la riga se ci stanno, altrimenti scorrono. */
#page-home .home-tabs .chip,
#page-relation .subnav .chip { flex: 1 0 auto; min-width: max-content; }

/* 2. Riquadri della Home: il numero segue la larghezza del riquadro. */
.metrics-row .metric { min-width: 0; container-type: inline-size; }
.metrics-row .metric strong { font-size: clamp(15px, 28cqi, 21px); white-space: nowrap; }
.metrics-row .metric .metric-label { line-height: 1.2; }

/* 1. Fila delle dimensioni (report): nomi su due righe, carattere in scala con la fila. */
.dims-row { container-type: inline-size; }
.dim { min-width: 0; }
.dim-label { max-width: 100%; white-space: normal; line-height: 1.15; }
/* Ultima rete: una parola che da sola non ci sta si spezza invece di uscire. */
.dim-label, .metrics-row .metric .metric-label, .theme-pick button { overflow-wrap: anywhere; }
.dims-row.cols-5 .dim-label { font-size: clamp(10px, 3.6cqi, 11.5px); }

/* Intestazione del punteggio: il lato destro va a capo invece di uscire dalla card. */
.report-score-head > :first-child { min-width: 0; }
.report-score-side { min-width: 0; max-width: 55%; grid-template-columns: minmax(0, auto); }
.report-score-side .pill { max-width: 100%; height: auto; padding-block: 4px; white-space: normal; text-align: right; line-height: 1.2; }

/* Etichetta del livello di AI nei quattro riquadri d'ingresso. */
.quad { container-type: inline-size; }
.quad-name { font-size: clamp(22px, 20cqi, 32px); }
.quad .level-badge { max-width: 100%; font-size: clamp(10px, 8cqi, 11.5px); }
.level-badge > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Scelta del tema in Profilo: tre pulsanti uguali, il testo si adatta. */
.theme-pick { container-type: inline-size; }
.theme-pick button { min-width: 0; font-size: clamp(12px, 4.4cqi, 14px); line-height: 1.15; }

/* Nomi delle persone (lunghi a piacere): vanno a capo, anche dentro la parola. */
.relation-title { min-width: 0; overflow-wrap: anywhere; }
/* Report dei gruppi: due colonne se ci stanno, altrimenti una (in em: segue anche il carattere grande). */
.report-split { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5em), 1fr)); }

/* Fila delle dimensioni stretta (telefono piccolo o carattere grande):
 * 3 + 2 invece di 5 in fila, così i nomi restano parole intere. La soglia è
 * in em, quindi cresce insieme al carattere. */
.report-block { container: blocco / inline-size; }
@container blocco (max-width: 16em) {
  .dims-row.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; }
  .dims-row.cols-5 .dim-label { font-size: 11.5px; }
  .dims-row.cols-5 .dim-icon { width: 46px; height: 46px; }
}

/* Coppie di persone nel gruppo: se i nomi sono lunghi, il conteggio va sotto. */
.link-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.link-row > :first-child { flex: 1 1 9em; min-width: 0; }

/* Varianti di un testo per larghezza (come fanno le app native): la forma
 * intera finché ci sta, quella breve quando il contenitore è stretto.
 * Il nome intero resta in aria-label per chi usa il lettore dello schermo. */
.fit-short { display: none; }
@container (max-width: 17em) {
  .theme-pick .fit-full { display: none; }
  .theme-pick .fit-short { display: inline; }
}

/* Quattro riquadri della Home: in fila se c'è spazio, 2 × 2 su telefoni
 * stretti o col carattere grande (soglia in em, cresce col carattere). */
.metrics-wrap { container: riquadri / inline-size; }
@container riquadri (max-width: 18.5em) {
  .metrics-row.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-row.cols-4 .metric { min-height: 0; }
}
