:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-500: #4caf50;
  --green-50: #e8f5e9;
  --bg: #f7faf7;
  --text: #1f2a1f;
  --muted: #6b7768;
  --card: #ffffff;
  --border: #e2e8e0;
  --danger: #c62828;
  --shadow: 0 4px 20px rgba(0, 60, 20, 0.08);
  --shadow-hover: 0 8px 30px rgba(0, 60, 20, 0.12);

  /* ===== Dimensioni fluide responsive (mobile-first) =====
     Il fattore vw permette scaling automatico tra i breakpoint,
     il clamp blocca i valori sui due estremi. */
  --app-max-width: 720px;
  --app-pad-x: clamp(0.9rem, 4vw, 2rem);
  --app-pad-top: calc(max(env(safe-area-inset-top), 0px) + clamp(1.2rem, 5vw, 3rem));
  --app-pad-bottom: clamp(1rem, 3vw, 2rem);

  --hero-size: clamp(150px, 48vw, 220px);
  --hero-icon: clamp(42px, 13vw, 56px);
  --hero-orbit-inset: clamp(-12px, -2.5vw, -7px);

  --title-fs: clamp(1.15rem, 3.8vw, 1.45rem);
  --score-big-fs: clamp(1.7rem, 5.5vw, 2.2rem);
  --section-heading-fs: clamp(0.98rem, 2.6vw, 1.1rem);

  --fab-size: clamp(54px, 13vw, 64px);
  --fab-back-size: clamp(46px, 11vw, 56px);
  --shutter-size: clamp(72px, 18vw, 86px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Niente caret di testo: non ci sono input testuali visibili, ma
     gli elementi focusable (<label tabindex=0>, <span tabindex=0>)
     possono mostrare un caret lampeggiante su alcuni browser. */
  caret-color: transparent;
  /* Mai scroll orizzontale: animazioni / orbit decorativi non devono
     allargare il viewport. `clip` blocca tutto senza creare contesto
     di scroll (a differenza di `hidden`). */
  overflow-x: clip;
  max-width: 100vw;
}

*, *::before, *::after { caret-color: transparent; }

h1, h2, h3,
.section-heading,
.title,
.health-title,
.combined-title,
.entry-title,
.unreliable-title,
.confidence-low-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  letter-spacing: -0.018em;
}

/* Numeri tabulari (allineamento delle cifre) */
.score-big,
.entry-score,
.score-mini,
#quota-chip-text,
.score-label {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}


body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

.app {
  max-width: var(--app-max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--app-pad-top) var(--app-pad-x) var(--app-pad-bottom);
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* In flex column i children hanno min-width: auto = intrinsic content
     width. Senza questo, una striscia di pillole più larga del viewport
     impedirebbe al body di shrinkare → niente wrap e overflow orizzontale. */
  min-width: 0;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.25s ease;
  min-width: 0;
}

#capture-view, #preview-view, #loading-view, #error-view {
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

button, .capture-btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.75rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
}

.primary {
  background: var(--green-700);
  color: white;
  box-shadow: 0 4px 14px rgba(46, 125, 50, 0.35);
}

.primary:hover { background: var(--green-900); }
.primary:active { transform: scale(0.97); }

.secondary {
  background: var(--green-50);
  color: var(--green-900);
}

.secondary:hover { background: #d6ead8; }

/* ========= CAMERA HERO (minimal) ========= */
.cam-hero {
  --hero-color: #4a7c59;
  --hero-border: #c8dccc;
  --hero-bg-from: #ffffff;
  --hero-bg-to: #f6fbf7;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: clamp(0.6rem, 2.5vw, 1.5rem) 0 0.6rem;
  background: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: auto;
  border: none;
  border-radius: 50%;
}

.cam-hero-circle {
  position: relative;
  width: var(--hero-size);
  height: var(--hero-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.9) 0%, transparent 60%),
    linear-gradient(180deg, var(--hero-bg-from) 0%, var(--hero-bg-to) 100%);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 1px 2px rgba(46, 125, 50, 0.04),
    0 10px 30px rgba(46, 125, 50, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1),
              box-shadow 0.4s ease;
  animation: heroBreath 7s ease-in-out infinite;
}

/* Cerchio interno tratteggiato: SVG con stroke-dasharray controllato.
   Sostituisce il vecchio border:dashed che non permetteva di scegliere
   la lunghezza dei trattini. */
.cam-hero-dashes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  animation: orbitRotateReverse 140s linear infinite;
  transition: opacity 0.4s ease;
}

.cam-hero-dashes circle {
  fill: none;
  stroke: var(--hero-border);
  stroke-width: 0.65;
  /* Dash 4, gap 1.4 su pathLength=100 → ~19 trattini un filo più corti
     del passaggio precedente, ma stroke più grossa = trattini più "visibili". */
  stroke-dasharray: 4 1.4;
  stroke-linecap: butt;
  transition: stroke 0.4s ease;
}

@keyframes orbitRotateReverse {
  to { transform: rotate(-360deg); }
}

.cam-hero:hover .cam-hero-circle {
  transform: scale(1.025);
  box-shadow:
    0 1px 2px rgba(46, 125, 50, 0.06),
    0 18px 44px rgba(46, 125, 50, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cam-hero:hover .cam-hero-dashes circle {
  stroke: #a8c8b0;
}

.cam-hero:active .cam-hero-circle { transform: scale(0.97); }

.cam-hero:focus-visible { outline: none; }
.cam-hero:focus-visible .cam-hero-circle {
  outline: 2px solid rgba(76, 124, 89, 0.35);
  outline-offset: 6px;
}

@keyframes heroBreath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.012); }
}

/* Cerchio orbitale stretto, verdolino, tratteggio spesso.
   inset/border fluidi per evitare overflow su viewport stretti. */
.cam-hero-orbit {
  position: absolute;
  inset: var(--hero-orbit-inset);
  border-radius: 50%;
  border: clamp(3.5px, 1.2vw, 5px) dashed rgba(76, 175, 80, 0.32);
  pointer-events: none;
  animation: orbitRotate 80s linear infinite;
}

@keyframes orbitRotate { to { transform: rotate(360deg); } }

.cam-hero-content {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hero-color);
  transition: color 0.3s ease;
}

.cam-hero:hover .cam-hero-content { color: var(--green-900); }

.cam-hero-icon { width: var(--hero-icon); height: var(--hero-icon); }

/* Upload link (opzione discreta, tra hero camera e organ picker) */
.upload-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  color: var(--muted);
  font-size: clamp(0.74rem, 2.2vw, 0.82rem);
  font-weight: 400;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: auto;
  transition: color 0.2s ease, background 0.2s ease;
  margin: 0.5rem 0 0;
  letter-spacing: 0.01em;
  opacity: 0.85;
  text-align: center;
  max-width: 100%;
}

.upload-link:hover {
  color: var(--green-900);
  background: rgba(76, 124, 89, 0.06);
  opacity: 1;
}

.upload-link svg { flex-shrink: 0; opacity: 0.7; }

.organ-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: clamp(1.2rem, 5vw, 3rem);
  width: 100%;
  max-width: 460px;
  min-width: 0;
}

/* Riga "Automatico" — opzione consigliata, prominente */
.organ-primary-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Automatico: leggermente più grande degli altri organi ma con peso più discreto.
   Quando selected, niente shadow forte: si distingue per colore non per "rilievo". */
.organ-opt--primary {
  font-size: clamp(0.78rem, 2.4vw, 0.88rem) !important;
  font-weight: 600 !important;
  padding: clamp(0.45rem, 1.6vw, 0.55rem) clamp(0.95rem, 4vw, 1.3rem) !important;
  letter-spacing: 0.015em !important;
}

.organ-star {
  color: var(--green-500);
  font-size: 1.2em;
  line-height: 0;
  margin-right: 0.2rem;
  opacity: 1;
}

.organ-segmented {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.25rem, 1vw, 0.4rem);
  width: 100%;
  min-width: 0;
}

.organ-opt {
  font: inherit;
  font-size: clamp(0.72rem, 2.2vw, 0.82rem);
  font-weight: 500;
  padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.65rem, 2.8vw, 0.95rem);
  min-height: auto;
  border-radius: 999px;
  background: white;
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.organ-opt:hover {
  color: var(--green-900);
  border-color: #a8c8b0;
  background: #fbfdfb;
}

.organ-opt.selected {
  background: var(--green-700);
  color: white;
  border-color: var(--green-700);
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.22);
}

.organ-opt.selected:hover { background: var(--green-900); border-color: var(--green-900); }
.organ-opt:active { transform: scale(0.96); }

/* "Automatico" selezionato: niente fill verde pieno (troppo invasivo).
   Look ghost — sfondo bianco + bordo verde scuro più marcato + soft ring esterno. */
.organ-primary-row .organ-opt--primary.selected {
  background: white;
  color: var(--green-900);
  border: 2px solid var(--green-700);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.18);
}

.organ-primary-row .organ-opt--primary.selected:hover {
  background: #fbfffb;
  border-color: var(--green-900);
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.24);
}

.organ-primary-row .organ-opt--primary.selected .organ-star {
  color: var(--green-700);
}

#preview-img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 18px;
  box-shadow: var(--shadow);
  object-fit: cover;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Wave loader — onde concentriche pulsanti dal centro */
#loading-view {
  gap: 1.6rem;
}

.wave-loader {
  position: relative;
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
}

.wave-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border: 1.6px solid var(--green-700);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  animation: waveRing 2.4s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

.wave-ring--2 { animation-delay: 0.8s; }
.wave-ring--3 { animation-delay: 1.6s; }

.wave-core {
  width: 10px;
  height: 10px;
  background: var(--green-700);
  border-radius: 50%;
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.12);
  animation: waveCorePulse 2.4s ease-in-out infinite;
}

@keyframes waveRing {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; border-width: 1.8px; }
  80%  { opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(8.5); opacity: 0; border-width: 0.6px; }
}

@keyframes waveCorePulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.12); }
  50%      { transform: scale(0.85); box-shadow: 0 0 0 8px rgba(46, 125, 50, 0.06); }
}

.loading-text {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition: opacity 0.28s ease;
  text-align: center;
  margin: 0;
}

/* ========= RESULTS ========= */
#results-view { align-items: stretch; }

.section-heading {
  margin: 1.2rem 0 0.5rem;
  font-size: var(--section-heading-fs);
  color: var(--green-900);
  letter-spacing: -0.01em;
}

#results-view > .section-heading:first-child { margin-top: 0; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: clamp(1rem, 3vw, 1.4rem);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card.best {
  border: 2px solid var(--green-500);
  background: linear-gradient(180deg, #fbfffb 0%, #ffffff 100%);
}

/* Confidenza < 50%: tutta la card adotta i toni avviso (arancione) —
   bordi, titoli, chip, bottoni, separatori — coerenza totale del box. */
.card.best--low {
  border-color: #ef6c00;
  background: linear-gradient(180deg, #fff7ef 0%, #ffffff 100%);
}

.card.best--low .score-big,
.card.best--low .title,
.card.best--low .title-leaf {
  color: #ef6c00;
}

.card.best--low .best-badge {
  background: #ef6c00;
}

.card.best--low .alias-chip {
  background: rgba(239, 108, 0, 0.08);
  color: #d84315;
  border-color: rgba(239, 108, 0, 0.3);
}

.card.best--low .best-footer {
  border-top-color: rgba(239, 108, 0, 0.4);
}

/* DEBUG button: resta sempre azzurro a prescindere dall'affidabilità.
   La sua identità visiva non deve cambiare con lo stato della card,
   perché è uno strumento di sviluppo neutro. */

/* Approfondisci: hover in warning invece di verde */
.card.best--low .approfondisci-btn:hover {
  color: #d84315;
  border-color: #ef6c00;
  background: rgba(239, 108, 0, 0.06);
}

.card.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

.best-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.title-block { flex: 1; min-width: 0; }

.title {
  margin: 0;
  font-size: var(--title-fs);
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.25;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* Foglia decorativa accanto al nome della pianta: stesso path del section-heading,
   dimensione proporzionata al titolo. Solo nel best match per evitare ripetizione. */
.title-leaf {
  width: 22px;
  height: 22px;
  color: var(--green-700);
  flex-shrink: 0;
  opacity: 0.85;
}

.title-text { word-break: break-word; }

.best-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--green-700);
  color: white;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sci-name {
  font-style: italic;
  color: var(--text);
  margin-top: 0.2rem;
  font-size: 1rem;
}

.sci-name .author {
  font-style: normal;
  color: var(--muted);
  font-size: 0.85rem;
}

.aliases-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  margin-top: 0.55rem;
}

.alias-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--green-900);
  background: var(--green-50);
  border: 1px solid #c8dccc;
  border-radius: 999px;
  line-height: 1.25;
  letter-spacing: 0.005em;
}

.score-block {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}


.score-big {
  font-size: var(--score-big-fs);
  font-weight: 800;
  color: var(--green-700);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-bar {
  height: 8px;
  background: var(--green-50);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.6rem 0 0;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-500), var(--green-700));
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* ========= CONFIDENCE STATES ========= */
.confidence-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-chip.medium {
  background: #fff3e0;
  color: #ef6c00;
  border: 1px solid #ffcc80;
}

/* Banner sopra il best match quando confidenza 10-25% */
.card.confidence-low {
  background: linear-gradient(135deg, #fff8e1 0%, #fffdf5 100%);
  border: 1px solid #ffcc80;
  margin-bottom: 0.7rem;
  padding: 1rem 1.2rem;
}

.confidence-low-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.7rem;
}

.confidence-low-icon { font-size: 1.6rem; flex-shrink: 0; line-height: 1; }

.confidence-low-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #b25500;
}

.confidence-low-sub {
  color: #7a5500;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

/* Card "Non riesco a riconoscere" — sostituisce il best match */
.card.unreliable {
  background: linear-gradient(180deg, #fffbf9 0%, #ffffff 100%);
  border: 2px solid #ffab91;
  text-align: center;
  padding: 2rem 1.5rem;
}

.unreliable-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.unreliable-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  color: #c62828;
  font-weight: 700;
}

.unreliable-sub {
  color: var(--muted);
  margin: 0 0 1.2rem;
  font-size: 0.92rem;
}

.unreliable .suggestions {
  text-align: left;
  max-width: 380px;
  margin: 0 auto 1.2rem;
}

.unreliable-retry {
  padding: 0.85rem 1.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(180deg, #ff9800 0%, #ef6c00 100%);
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(239, 108, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.unreliable-retry:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 18px rgba(239, 108, 0, 0.45);
  transform: translateY(-1px);
}

.unreliable-retry:active { transform: scale(0.97); }

/* Lista suggerimenti contestuali condivisa */
.suggestions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.suggestions li {
  position: relative;
  padding-left: 1.4rem;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.suggestions li::before {
  content: "•";
  position: absolute;
  left: 0.4rem;
  color: var(--green-700);
  font-weight: 700;
}

/* ===== Best card footer: IUCN indicator + Verify link ===== */
.best-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1.1rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed #d4e3d6;
}

/* Approfondisci: pulsante circolare con sola icona di lente.
   Contiene i dati IUCN nei data-attributes; click apre il modal. */
.approfondisci-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  min-height: auto;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.approfondisci-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.85;
}

.approfondisci-btn:hover {
  color: var(--green-900);
  border-color: var(--green-500);
  background: rgba(76, 175, 80, 0.06);
}

.approfondisci-btn:hover svg { opacity: 1; }

/* ===== Verify link — strumento di DEBUG, sarà rimosso in produzione ===== */
.verify-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem 0.3rem 0.45rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #1565c0;
  background: rgba(25, 118, 210, 0.07);
  border: 1px dashed rgba(25, 118, 210, 0.42);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  line-height: 1.2;
  white-space: nowrap;
}

.verify-link:hover {
  background: rgba(25, 118, 210, 0.13);
  border-color: rgba(25, 118, 210, 0.6);
}

.verify-link:active { transform: scale(0.97); }

.verify-tag {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  background: #1976d2;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.verify-bug {
  width: 16px;
  height: 16px;
  color: #1976d2;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.verify-link:hover .verify-bug {
  transform: rotate(-8deg) scale(1.06);
}

.verify-arrow {
  width: 12px;
  height: 12px;
  opacity: 0.75;
  transition: transform 0.2s ease;
}

.verify-link:hover .verify-arrow {
  transform: translate(2px, -2px);
}

.verify-text { font-weight: 600; }

/* ===== IUCN modal explainer ===== */
.iucn-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(31, 42, 31, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.iucn-modal-content {
  position: relative;
  max-width: min(420px, 92vw);
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px;
  padding: clamp(1.2rem, 4vw, 1.6rem) clamp(1.1rem, 3.5vw, 1.5rem) clamp(1.1rem, 3vw, 1.4rem);
  box-shadow: 0 18px 48px rgba(0, 60, 20, 0.18);
  border: 1px solid var(--border);
}

.iucn-modal-close {
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  min-height: auto;
  border-radius: 8px;
}

.iucn-modal-close:hover { color: var(--text); background: var(--green-50); }

.iucn-modal-title {
  margin: 0 0 0.9rem;
  font-family: 'Manrope', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--text);
}

.iucn-modal-section-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.iucn-modal-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
  font-family: 'Manrope', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.iucn-modal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #757575;
  flex-shrink: 0;
}

.iucn-modal-explain {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0 0 0.9rem;
}

.iucn-modal-explain strong { color: var(--green-900); font-weight: 600; }
.iucn-modal-explain em { font-style: italic; }

.iucn-modal-link {
  display: inline-block;
  font-size: 0.84rem;
  color: var(--green-700);
  text-decoration: none;
  border-bottom: 1px dashed #c8dccc;
  padding-bottom: 1px;
}

.iucn-modal-link:hover { color: var(--green-900); border-bottom-color: var(--green-700); }

/* ===== Vine separator (linea con foglia al centro) ===== */
.vine-separator {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.6rem 0;
  opacity: 0.65;
}

/* Distanze omogenee tra il separator e ciò che lo segue (threshold settings o diagnosi) */
.vine-separator + .threshold-settings { margin-top: 0; }
.vine-separator + #diseases-results { margin-top: 0; }

.vine-separator svg {
  width: min(220px, 60%);
  height: 22px;
}

.vine-separator svg path,
.vine-separator svg line {
  fill: none;
  stroke: #7ba384;
  stroke-width: 1;
  stroke-linecap: round;
}

.vine-separator svg g path {
  stroke-width: 1.2;
}

/* ========= GALLERY (solo patologie ora) ========= */
.gallery-wrapper { margin-top: 1rem; }

.gallery-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(85px, 22vw, 130px), 1fr));
  gap: clamp(0.4rem, 1.2vw, 0.6rem);
}

.gallery-item {
  position: relative;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--green-50);
  min-height: auto;
  cursor: zoom-in;
  border: 1px solid var(--border);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img { transform: scale(1.05); }

.gallery-organ {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* ========= SECONDARY RESULTS ========= */
#other-results {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card.secondary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: default;
}

/* Card delle alternative: nessun hover, non sono cliccabili.
   Override del .secondary:hover (pensato per i bottoni utility). */
.card.secondary:hover {
  background: var(--card);
}

.summary-text { flex: 1; min-width: 0; }

.summary-text .title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-text .sci-name { font-size: 0.8rem; margin-top: 0; }

.score-mini {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--green-700);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.details-body { padding: 1rem; }

.meta-line {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.meta-line strong { color: var(--muted); font-weight: 600; }

/* ========= DISEASES + THRESHOLD SETTINGS ========= */
.threshold-settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1.1rem;
  margin: 1rem 0 0.7rem;
  padding: 0;
  background: transparent;
  border: none;
}

.preset-icon {
  width: 13px;
  height: 13px;
  color: var(--muted);
  opacity: 0.55;
  flex-shrink: 0;
  margin-right: -0.4rem;
}

.preset-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.preset-group {
  display: inline-flex;
  gap: 0.95rem;
  align-items: center;
  justify-content: flex-start;
}

/* Preset buttons: testo delicato in linea con la label, niente pillole */
.preset-btn {
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0;
  min-height: auto;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

/* Colore del preset selezionato — cambia in base alla severity corrente
   (impostata via classe .severity-* sul wrapper .threshold-settings).
   Default (nessuna analisi ancora): grigio standard. */
.threshold-settings { --preset-accent: var(--muted); }
.threshold-settings.severity-healthy  { --preset-accent: #2e7d32; }
.threshold-settings.severity-mild     { --preset-accent: #1976d2; }
.threshold-settings.severity-moderate { --preset-accent: #ef6c00; }
.threshold-settings.severity-severe   { --preset-accent: var(--danger); }

.preset-btn:hover { color: var(--preset-accent); }

.preset-btn.selected {
  color: var(--preset-accent);
}

.preset-btn.selected::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1.5px;
  background: var(--preset-accent);
  border-radius: 1px;
  transition: background 0.2s ease;
}

@media (max-width: 460px) {
  .preset-group { gap: 0.7rem; }
}

.diagnosis-disclaimer {
  margin: 0.7rem 0 0;
  padding: 0;
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.55;
  text-align: center;
}

#diseases-results {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.health-ok {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #e8f5e9 0%, #ffffff 100%);
  border: 2px solid #66bb6a;
}

.health-unknown {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #eef3f7 0%, #ffffff 100%);
  border: 2px solid #b0bec5;
}

.health-unknown .health-icon { color: #607d8b; }
.health-unknown .health-title { color: #455a64; }

.health-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--green-700);
  width: 36px;
  height: 36px;
}

.health-icon .severity-svg { width: 36px; height: 36px; }

.health-title {
  font-weight: 700;
  color: var(--green-900);
  font-size: 1.1rem;
}

.health-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.card.disease-combined { padding: 0; overflow: hidden; }

.card.disease-combined.severity-severe {
  border: 2px solid #ef5350;
  background: linear-gradient(180deg, #fff8f8 0%, #ffffff 30%);
}

.card.disease-combined.severity-moderate {
  border: 2px solid #ffb74d;
  background: linear-gradient(180deg, #fffaf0 0%, #ffffff 30%);
}

.card.disease-combined.severity-mild {
  border: 2px solid #64b5f6;
  background: linear-gradient(180deg, #f4f9fd 0%, #ffffff 30%);
}

.combined-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
}

.severity-severe .combined-header { background: linear-gradient(135deg, #ffebee 0%, #fff8f8 100%); }
.severity-moderate .combined-header { background: linear-gradient(135deg, #fff8e1 0%, #fffdf5 100%); }
.severity-mild .combined-header { background: linear-gradient(135deg, #e3f2fd 0%, #f8fbfd 100%); }

.combined-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.combined-icon .severity-svg { width: 32px; height: 32px; }

.severity-severe .combined-icon { color: #c62828; }
.severity-moderate .combined-icon { color: #ef6c00; }
.severity-mild .combined-icon { color: #1976d2; }

.combined-text { flex: 1; min-width: 0; }

.combined-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.combined-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.combined-divider {
  height: 1px;
  background: var(--border);
}

.combined-body {
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.disease-entry + .disease-entry {
  padding-top: 1.2rem;
  border-top: 1px dashed var(--border);
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.entry-title-block { flex: 1; min-width: 0; }

.entry-rank {
  font-size: 0.7rem;
  color: #ef6c00;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.entry-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.25;
}

.entry-code {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.entry-code code {
  background: #f1f5f1;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text);
}

.entry-score {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--green-700);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  line-height: 1;
}

.severity-severe .entry-score { color: #d84315; }
.severity-moderate .entry-score { color: #ef6c00; }
.severity-mild .entry-score { color: #1976d2; }

.score-bar-fill.severity-high {
  background: linear-gradient(90deg, #ff9800, #d84315);
}

.score-bar-fill.severity-mid {
  background: linear-gradient(90deg, #ffd54f, #ff9800);
}

.score-bar-fill.severity-low {
  background: linear-gradient(90deg, #90caf9, #64b5f6);
}

/* ========= ERROR ========= */
.error-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 90%;
}

.error-card h2 { margin-top: 0; color: var(--danger); }
.error-card p { color: var(--muted); margin: 0.5rem 0 1.2rem; }

/* ========= FOOTER ========= */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  text-align: center;
  box-sizing: border-box;
}

.site-footer::before {
  content: "";
  display: block;
  width: clamp(48px, 14vw, 80px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green-500), transparent);
  margin: 0 auto 1rem;
  opacity: 0.7;
}

.site-footer p {
  margin: 0 auto;
  max-width: 42rem;
  font-size: clamp(0.74rem, 1.9vw, 0.82rem);
  color: var(--muted);
  line-height: 1.6;
  letter-spacing: 0.005em;
  text-wrap: balance;
  text-wrap: pretty;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Preserva l'integrità di frasi che non devono spezzarsi a metà */
.site-footer .nb {
  white-space: nowrap;
}

.site-footer .footer-text { display: inline; }

/* ===== Leaf mark — firma vegetale tra il contenuto e la chip quota ===== */
.leaf-mark {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0 0.35rem;
  pointer-events: none;
  flex-shrink: 0;
}

.leaf-mark-svg {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  color: var(--green-700);
  transform-origin: 50% 92%;
  filter: drop-shadow(0 4px 10px rgba(46, 125, 50, 0.16));
  animation: leafMarkSway 4s ease-in-out infinite;
}

/* Outer "halo" che pulsa: dà profondità senza affollare. */
.leaf-mark-aura {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(76, 175, 80, 0.18) 0%, rgba(76, 175, 80, 0) 65%);
  animation: leafMarkAura 4.6s ease-in-out infinite;
}

/* Container fa un float verticale + opacity, con durata diversa
   rispetto al sway dell'SVG → effetto organico non sincronizzato. */
.leaf-mark { animation: leafMarkBreath 5s ease-in-out infinite; }

@keyframes leafMarkSway {
  0%, 100% { transform: rotate(-12deg); }
  50%      { transform: rotate(12deg); }
}

@keyframes leafMarkBreath {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes leafMarkAura {
  0%, 100% { opacity: 0.35; transform: scale(0.82); }
  50%      { opacity: 1;    transform: scale(1.2); }
}

/* ========= CAMERA VIEW ========= */
#camera-view {
  padding: 0;
  margin: 0;
  align-items: stretch;
  justify-content: stretch;
}

.camera-frame {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-shutter {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(1rem, 3vh, 2rem));
  left: 50%;
  transform: translateX(-50%);
  width: var(--shutter-size);
  height: var(--shutter-size);
  min-height: var(--shutter-size);
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 4px solid rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.camera-shutter:hover {
  border-color: white;
  transform: translateX(-50%) scale(1.04);
}

.camera-shutter:active {
  transform: translateX(-50%) scale(0.92);
}

.shutter-inner {
  width: calc(var(--shutter-size) - 20px);
  height: calc(var(--shutter-size) - 20px);
  border-radius: 50%;
  background: white;
  transition: background 0.15s ease;
}

.camera-shutter.flash .shutter-inner { background: var(--green-500); }

.camera-cancel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + clamp(0.6rem, 2vw, 1rem));
  right: calc(env(safe-area-inset-right, 0px) + clamp(0.6rem, 2vw, 1rem));
  width: clamp(40px, 10vw, 48px);
  height: clamp(40px, 10vw, 48px);
  min-height: clamp(40px, 10vw, 48px);
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.camera-cancel:hover { background: rgba(0, 0, 0, 0.55); }

/* ========= LIGHTBOX ========= */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.lightbox img {
  max-width: min(100%, 1200px);
  max-height: 80vh;
  max-height: 80dvh;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  margin-top: 0.8rem;
  text-align: center;
  max-width: 600px;
}

.lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + clamp(0.7rem, 2vw, 1.2rem));
  right: calc(env(safe-area-inset-right, 0px) + clamp(0.7rem, 2vw, 1.2rem));
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  width: clamp(40px, 10vw, 50px);
  height: clamp(40px, 10vw, 50px);
  min-height: clamp(40px, 10vw, 50px);
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

/* ========= QUOTA SECTION (in basso al centro, sopra al footer) ========= */
.quota-section {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.quota-chip {
  position: static;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem 0.35rem 0.55rem;
  min-height: 32px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

.quota-chip:hover { background: white; }

.quota-chip-icon { font-size: 0.85rem; line-height: 1; }
.quota-chip-text { color: var(--green-900); }

.quota-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-500);
}
.quota-chip-dot[data-level="mid"] { background: #ffb74d; }
.quota-chip-dot[data-level="high"] { background: #ef5350; }

.quota-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  width: min(340px, calc(100vw - 1.5rem));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 12px 36px rgba(0, 60, 20, 0.18);
  animation: fadeIn 0.18s ease;
}

.quota-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

#quota-popover-title {
  font-weight: 700;
  color: var(--green-900);
  font-size: 0.9rem;
}

.quota-day {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.75rem;
}

.quota-refresh {
  padding: 0.2rem 0.55rem;
  min-height: 30px;
  font-size: 1rem;
  background: var(--green-50);
  color: var(--green-900);
  border-radius: 8px;
  transition: transform 0.6s ease;
}

.quota-refresh.spinning { transform: rotate(360deg); }

.quota-bars {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quota-row { font-size: 0.82rem; }

.quota-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.22rem;
  gap: 0.5rem;
}

.quota-row-name { font-weight: 600; color: var(--text); }

.quota-row-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}

.quota-row-num strong { color: var(--green-900); font-weight: 700; }
.quota-remaining { opacity: 0.7; }

.quota-bar {
  height: 5px;
  background: #eef3ed;
  border-radius: 999px;
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.quota-bar-fill.level-low { background: linear-gradient(90deg, var(--green-500), var(--green-700)); }
.quota-bar-fill.level-mid { background: linear-gradient(90deg, #ffb74d, #fb8c00); }
.quota-bar-fill.level-high { background: linear-gradient(90deg, #ef5350, #c62828); }

/* ========= FAB nuova ricerca ========= */
.fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(0.85rem, 3vw, 1.5rem));
  right: calc(env(safe-area-inset-right, 0px) + clamp(0.85rem, 3vw, 1.5rem));
  z-index: 100;
  width: var(--fab-size);
  height: var(--fab-size);
  min-height: var(--fab-size);
  padding: 0;
  border-radius: 50%;
  background: var(--green-700);
  color: white;
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.fab:hover {
  background: var(--green-900);
  box-shadow: 0 12px 30px rgba(46, 125, 50, 0.5);
  transform: translateY(-2px);
}

.fab:active { transform: scale(0.95); }

/* ========= BACK FAB (verde, top-left) ========= */
.fab.back-fab {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + clamp(0.55rem, 2vw, 1rem));
  left: calc(env(safe-area-inset-left, 0px) + clamp(0.55rem, 2vw, 1rem));
  bottom: auto;
  right: auto;
  z-index: 100;
  width: var(--fab-back-size);
  height: var(--fab-back-size);
  min-height: var(--fab-back-size);
  font-size: clamp(1.25rem, 3.6vw, 1.55rem);
}

.fab.back-fab:hover {
  transform: translateY(-2px);
}

/* =========================================================
   RESPONSIVE BREAKPOINTS
   Approccio mobile-first: i valori base sopra coprono già
   smartphone piccoli via clamp(). Qui ottimizziamo i casi
   specifici dove servono regole diverse, non solo scaling.
   ========================================================= */

/* ----- Smartphone molto piccoli (≤360px: iPhone SE, Galaxy S8) ----- */
@media (max-width: 360px) {
  :root {
    /* Hero leggermente più piccolo per non rubare tutta la pagina */
    --hero-size: clamp(140px, 46vw, 165px);
  }
  .organ-primary-row .organ-opt--primary.selected {
    /* Ring esterno meno invadente */
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.18);
  }
  .preset-group { gap: 0.55rem; }
  .vine-separator svg { width: min(180px, 70%); }
}

/* ----- Smartphone portrait standard (361–599px) -----
   Già coperto dai clamp() di base; nessuna regola aggiuntiva. */

/* ----- Phablet / smartphone landscape (≥600px) ----- */
@media (min-width: 600px) {
  :root {
    --hero-size: clamp(190px, 32vw, 230px);
    --hero-icon: clamp(50px, 8vw, 60px);
  }
  .organ-picker { max-width: 520px; }
}

/* ----- Tablet portrait (≥768px: iPad, Galaxy Tab) ----- */
@media (min-width: 768px) {
  :root {
    --app-max-width: 760px;
    --hero-size: clamp(220px, 30vw, 280px);
    --hero-icon: clamp(58px, 7.5vw, 68px);
    --hero-orbit-inset: -12px;
    --title-fs: 1.5rem;
    --score-big-fs: 2.3rem;
    --section-heading-fs: 1.12rem;
    --fab-size: 64px;
    --fab-back-size: 56px;
    --shutter-size: 86px;
  }
  .organ-picker {
    max-width: 560px;
    margin-top: 2.8rem;
  }
  .organ-opt { font-size: 0.85rem; padding: 0.5rem 1rem; }
  .organ-opt--primary {
    font-size: 0.9rem !important;
    padding: 0.55rem 1.4rem !important;
  }
}

/* ----- Tablet large / small desktop (≥1024px: iPad Pro, laptop) ----- */
@media (min-width: 1024px) {
  :root {
    --app-max-width: 880px;
    --hero-size: 290px;
    --hero-icon: 72px;
    --hero-orbit-inset: -14px;
    --title-fs: 1.55rem;
    --score-big-fs: 2.4rem;
    --section-heading-fs: 1.15rem;
    --shutter-size: 96px;
  }
  .organ-picker { max-width: 600px; }
  /* Hover effects più ricchi solo dove c'è puntatore vero */
  .cam-hero:hover .cam-hero-circle { transform: scale(1.04); }
  .leaf-mark-svg { width: 38px; height: 38px; }
}

/* ----- Desktop large (≥1440px) -----
   Mantengo width contenuta per leggibilità (no walls of cards),
   ma rendo l'hero più presente. */
@media (min-width: 1440px) {
  :root {
    --app-max-width: 960px;
    --hero-size: 320px;
    --hero-icon: 80px;
  }
}

/* ----- Landscape smartphone (orientamento orizzontale, altezza ridotta) -----
   Su un iPhone Pro Max in landscape (932×430) il base layout fa scrollare
   subito. Comprimiamo padding-top e hero per mostrare almeno hero+organi
   senza scroll. */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --app-pad-top: calc(max(env(safe-area-inset-top), 0px) + 0.6rem);
    --app-pad-bottom: 0.6rem;
    --hero-size: clamp(110px, 28vh, 150px);
    --hero-icon: clamp(34px, 8vh, 44px);
    --hero-orbit-inset: -6px;
  }
  .cam-hero { margin: 0.3rem 0 0.3rem; }
  .organ-picker { margin-top: 0.9rem; gap: 0.5rem; }
  .upload-link { margin: 0.25rem 0 0; padding: 0.3rem 0.7rem; }
  /* Sposta il leaf+quota inline col footer in alto a destra
     così non scrollano fuori. */
  .leaf-mark { padding: 0.3rem 0 0; }
  .leaf-mark-svg { width: 24px; height: 24px; }
  .leaf-mark-aura { width: 44px; height: 44px; }
  .site-footer { padding: 0.6rem 1rem; }
  .site-footer::before { margin: 0 auto 0.5rem; }
  /* Mai una camera-shutter gigante che ruba metà schermo */
  .camera-shutter {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
    width: 60px; height: 60px; min-height: 60px;
  }
  .shutter-inner { width: 44px; height: 44px; }
  /* Modal centrati con altezza utile */
  .iucn-modal-content { padding: 1rem 1.1rem 0.9rem; }
}

/* ----- Tablet/desktop con puntatore: hover più pronunciato ----- */
@media (hover: hover) and (pointer: fine) {
  .organ-opt:hover { transform: translateY(-1px); }
  .alias-chip { transition: background 0.2s ease, color 0.2s ease; }
}

/* ----- Riduzione movimento (utenti che lo preferiscono) ----- */
@media (prefers-reduced-motion: reduce) {
  .cam-hero-circle,
  .cam-hero-dashes,
  .cam-hero-orbit,
  .leaf-mark,
  .leaf-mark-svg,
  .leaf-mark-aura,
  .wave-ring,
  .wave-core {
    animation: none !important;
  }
  * { transition-duration: 0.01ms !important; }
}
