/* =====================================================
   OmniNeo — Site CSS  v2.0
   Design: futuristic medical · full dark · 3D logo
   ===================================================== */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand teal */
  --teal:        #2dd4c8;
  --teal-dim:    #1ba8a0;
  --teal-glow:   rgba(45, 212, 200, 0.18);

  /* Backgrounds — deep space */
  --bg-void:     #04070f;
  --bg-dark:     #070d1a;
  --bg-card:     #0c1628;
  --bg-card2:    #0a1220;
  --bg-glass:    rgba(12, 22, 40, 0.72);

  /* Borders */
  --bd:          rgba(45, 212, 200, 0.10);
  --bd-bright:   rgba(45, 212, 200, 0.30);

  /* Text — high contrast */
  --text:        #f0f4fc;
  --text-muted:  #7da4bc;
  --text-dim:    #3d5a72;

  /* Accent purple */
  --violet:      #a78bfa;
  --violet-glow: rgba(167, 139, 250, 0.15);

  /* Chapter accents */
  --ch-resp:    #06b6d4;
  --ch-neuro:   #818cf8;
  --ch-card:    #f87171;
  --ch-infect:  #34d399;
  --ch-metab:   #fbbf24;
  --ch-neo:     #60a5fa;
  --ch-hema:    #f472b6;
  --ch-util:    #a78bfa;
  --ch-genet:   #10b981;
  --ch-ecopolm: #14b8a6;
  --ch-ecopolm-2: #6366f1;

  /* Layout */
  --max-w:     1100px;
  --r-sm:      14px;
  --r-md:      20px;
  --r-lg:      28px;

  /* Shadows */
  --shadow:    0 20px 60px rgba(0,0,0,0.60);
  --shadow-sm: 0 6px 24px rgba(0,0,0,0.40);
  --glow-teal: 0 0 40px rgba(45, 212, 200, 0.20);

  /* Font */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================================================
   Light theme tokens (Avorio moderno)
   - data-theme="light"  → manual override
   - prefers-color-scheme: light + no data-theme → auto OS
   - Schede new-gen flagship hanno il proprio :root con override
     paralleli; questo blocco serve solo alle pagine site/
   ============================================================ */
:root[data-theme="light"] {
  /* Brand teal — variante navy-cyan profondo per max contrast su cream */
  --teal:        #0c4a6e;
  --teal-dim:    #075985;
  --teal-glow:   rgba(12, 74, 110, 0.18);

  /* Backgrounds — Avorio carta naturale (più giallo, distinct dai panel) */
  --bg-void:     #f4ecd8;
  --bg-dark:     #ede0c2;
  --bg-card:     #ffffff;
  --bg-card2:    #fff8e7;
  --bg-glass:    rgba(255, 255, 255, 0.92);

  /* Borders — visibili per delimitare card */
  --bd:          rgba(0, 0, 0, 0.12);
  --bd-bright:   #94a3b8;

  /* Text — quasi nero per max contrast, niente fantasma */
  --text:        #0a0e1a;
  --text-muted:  #475569;
  --text-dim:    #64748b;
  --text-strong: #000000;

  /* Accent purple */
  --violet:      #5b21b6;
  --violet-glow: rgba(91, 33, 182, 0.15);

  /* Chapter accents — più scuri per leggibilità su cream */
  --ch-resp:    #0891b2;
  --ch-neuro:   #6366f1;
  --ch-card:    #dc2626;
  --ch-infect:  #15803d;
  --ch-metab:   #d97706;
  --ch-neo:     #2563eb;
  --ch-hema:    #db2777;
  --ch-util:    #7c3aed;
  --ch-genet:   #15803d;
  --ch-ecopolm: #0d9488;
  --ch-ecopolm-2: #4f46e5;

  /* State colors — più scuri per contrast adeguato */
  --ok:        #15803d;
  --warn:      #b45309;
  --danger:    #b91c1c;

  /* Shadows — soft con grigio caldo invece di nero */
  --shadow:    0 20px 60px rgba(31, 41, 55, 0.10);
  --shadow-sm: 0 6px 24px rgba(31, 41, 55, 0.08);
  --glow-teal: 0 0 40px rgba(12, 74, 110, 0.20);

  /* Quote/disclaimer/info-box — sfondo distinct giallo carta antica */
  --bg-quote:  #fef3c7;
  --bd-quote:  #d97706;

  /* Btn glass + theme switcher */
  --btn-bg-from: rgba(255, 255, 255, 0.92);
  --btn-bg-to:   rgba(255, 248, 231, 0.75);
  --theme-btn-bg: rgba(0, 0, 0, 0.06);
  --theme-btn-bd: #94a3b8;
  --theme-btn-bg-hover: rgba(0, 0, 0, 0.10);
  --theme-btn-bd-hover: #64748b;
}

/* Auto OS light theme — applica i token v2 quando :root non ha data-theme manuale.
   Riattivato 2026-04-26 dopo light-readiness completa di tutte le 12 pagine site v2.0. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    /* Brand teal — variante navy-cyan profondo per max contrast su cream */
    --teal:        #0c4a6e;
    --teal-dim:    #075985;
    --teal-glow:   rgba(12, 74, 110, 0.18);

    /* Backgrounds — Avorio carta naturale */
    --bg-void:     #f4ecd8;
    --bg-dark:     #ede0c2;
    --bg-card:     #ffffff;
    --bg-card2:    #fff8e7;
    --bg-glass:    rgba(255, 255, 255, 0.92);

    /* Borders */
    --bd:          rgba(0, 0, 0, 0.12);
    --bd-bright:   #94a3b8;

    /* Text */
    --text:        #0a0e1a;
    --text-muted:  #475569;
    --text-dim:    #64748b;
    --text-strong: #000000;

    /* Accent purple */
    --violet:      #5b21b6;
    --violet-glow: rgba(91, 33, 182, 0.15);

    /* Chapter accents */
    --ch-resp:    #0891b2;
    --ch-neuro:   #6366f1;
    --ch-card:    #dc2626;
    --ch-infect:  #15803d;
    --ch-metab:   #d97706;
    --ch-neo:     #2563eb;
    --ch-hema:    #db2777;
    --ch-util:    #7c3aed;
    --ch-genet:   #15803d;

    /* State colors */
    --ok:        #15803d;
    --warn:      #b45309;
    --danger:    #b91c1c;

    /* Shadows */
    --shadow:    0 20px 60px rgba(31, 41, 55, 0.10);
    --shadow-sm: 0 6px 24px rgba(31, 41, 55, 0.08);
    --glow-teal: 0 0 40px rgba(12, 74, 110, 0.20);

    /* Quote/disclaimer/info-box */
    --bg-quote:  #fef3c7;
    --bd-quote:  #d97706;

    /* Btn glass + theme switcher */
    --btn-bg-from: rgba(255, 255, 255, 0.92);
    --btn-bg-to:   rgba(255, 248, 231, 0.75);
    --theme-btn-bg: rgba(0, 0, 0, 0.06);
    --theme-btn-bd: #94a3b8;
    --theme-btn-bg-hover: rgba(0, 0, 0, 0.10);
    --theme-btn-bd-hover: #64748b;
  }
}

/* Default dark — alias per token nuovi (btn glass + theme switcher) */
:root {
  --btn-bg-from: rgba(30, 41, 59, 0.55);
  --btn-bg-to:   rgba(15, 23, 42, 0.45);
  --theme-btn-bg: rgba(255, 255, 255, 0.06);
  --theme-btn-bd: rgba(148, 163, 184, 0.22);
  --theme-btn-bg-hover: rgba(255, 255, 255, 0.10);
  --theme-btn-bd-hover: rgba(148, 163, 184, 0.40);
  --text-strong: #ffffff;
  --bg-quote: rgba(167, 139, 250, 0.06);
  --bd-quote: rgba(124, 58, 237, 0.22);
  --ok:     #34d399;
  --warn:   #fbbf24;
  --danger: #f87171;
}

/* Esplicito data-theme="dark" — override OS quando l'utente ha scelto dark */
:root[data-theme="dark"] {
  --teal:        #2dd4c8;
  --teal-dim:    #1ba8a0;
  --teal-glow:   rgba(45, 212, 200, 0.18);
  --bg-void:     #04070f;
  --bg-dark:     #070d1a;
  --bg-card:     #0c1628;
  --bg-card2:    #0a1220;
  --bg-glass:    rgba(12, 22, 40, 0.72);
  --bd:          rgba(45, 212, 200, 0.10);
  --bd-bright:   rgba(45, 212, 200, 0.30);
  --text:        #f0f4fc;
  --text-muted:  #7da4bc;
  --text-dim:    #3d5a72;
  --violet:      #a78bfa;
  --violet-glow: rgba(167, 139, 250, 0.15);
  --ch-resp:    #06b6d4;
  --ch-neuro:   #818cf8;
  --ch-card:    #f87171;
  --ch-infect:  #34d399;
  --ch-metab:   #fbbf24;
  --ch-neo:     #60a5fa;
  --ch-hema:    #f472b6;
  --ch-util:    #a78bfa;
  --ch-genet:   #10b981;
  --shadow:    0 20px 60px rgba(0,0,0,0.60);
  --shadow-sm: 0 6px 24px rgba(0,0,0,0.40);
  --glow-teal: 0 0 40px rgba(45, 212, 200, 0.20);
  --btn-bg-from: rgba(30, 41, 59, 0.55);
  --btn-bg-to:   rgba(15, 23, 42, 0.45);
  --theme-btn-bg: rgba(255, 255, 255, 0.06);
  --theme-btn-bd: rgba(148, 163, 184, 0.22);
  --theme-btn-bg-hover: rgba(255, 255, 255, 0.10);
  --theme-btn-bd-hover: rgba(148, 163, 184, 0.40);
  --text-strong: #ffffff;
  --bg-quote: rgba(167, 139, 250, 0.06);
  --bd-quote: rgba(124, 58, 237, 0.22);
  --ok:     #34d399;
  --warn:   #fbbf24;
  --danger: #f87171;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-void);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }


/* ══════════════════════════════════════════════
   HERO
══════════════════════════════════════════════ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg-void);
}

/* Grid background */
.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(45,212,200,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45,212,200,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
}

/* Ambient orbs */
.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orb-drift 12s ease-in-out infinite;
}
.hero-orb-1 {
  width: 600px; height: 600px;
  top: -200px; left: -150px;
  background: radial-gradient(circle, #0d7a8a 0%, transparent 70%);
  animation-duration: 14s;
}
.hero-orb-2 {
  width: 500px; height: 500px;
  top: -100px; right: -100px;
  background: radial-gradient(circle, #1a1065 0%, transparent 70%);
  animation-duration: 18s;
  animation-delay: -6s;
}
.hero-orb-3 {
  width: 400px; height: 400px;
  bottom: 0; left: 40%;
  background: radial-gradient(circle, #042b47 0%, transparent 70%);
  animation-duration: 20s;
  animation-delay: -10s;
}

@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -20px) scale(1.05); }
  66%       { transform: translate(-20px, 15px) scale(0.95); }
}

/* ── Hero inner ── */
.hero-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px 48px;
  max-width: 700px;
  width: 100%;
  gap: 0;
}

/* ── 3D Logo Scene ── */
.logo-scene {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Beta badge */
.beta-badge {
  position: absolute;
  top: -8px; right: -12px;
  z-index: 10;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #6d28d9, #2563eb);
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.45);
  animation: beta-pulse 3s ease-in-out infinite;
}
@keyframes beta-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(109, 40, 217, 0.45); }
  50%      { box-shadow: 0 4px 20px rgba(109, 40, 217, 0.70); }
}

/* Outer glow halo */
.logo-glow-outer {
  position: absolute;
  inset: -30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45,212,200,0.18) 0%, transparent 70%);
  animation: glow-pulse 4s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.08); }
}

/* Rotating rings */
.logo-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
  animation: ring-spin linear infinite;
}

.logo-ring-1 {
  inset: -16px;
  border-top-color:  rgba(45, 212, 200, 0.55);
  border-right-color: rgba(45, 212, 200, 0.20);
  animation-duration: 8s;
}
.logo-ring-2 {
  inset: -28px;
  border-top-color:    rgba(109, 40, 217, 0.45);
  border-bottom-color: rgba(109, 40, 217, 0.20);
  animation-duration: 14s;
  animation-direction: reverse;
}
.logo-ring-3 {
  inset: -42px;
  border-left-color:  rgba(45, 212, 200, 0.20);
  border-right-color: rgba(45, 212, 200, 0.35);
  animation-duration: 22s;
}

@keyframes ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* 3D logo image */
.logo-3d {
  position: relative;
  z-index: 2;
  width: 160px;
  height: 160px;
  animation: logo-float 7s ease-in-out infinite;
  filter:
    drop-shadow(0 0 20px rgba(45, 212, 200, 0.50))
    drop-shadow(0 12px 40px rgba(0, 0, 0, 0.70));
}

.hero-logo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: contain;
  transform: perspective(500px) rotateY(-12deg) rotateX(6deg);
  transition: transform 0.5s ease;
}

.logo-scene:hover .hero-logo {
  transform: perspective(500px) rotateY(0deg) rotateX(0deg) scale(1.04);
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0px) perspective(500px) rotateY(-12deg) rotateX(6deg); }
  50%       { transform: translateY(-10px) perspective(500px) rotateY(12deg) rotateX(-4deg); }
}

/* ── Hero text ── */
.hero-title {
  font-size: 3.8rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 14px;
}

.hero-title-main {
  background: linear-gradient(135deg, #ffffff 0%, #2dd4c8 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
}

/* Status indicator */
.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: rgba(45, 212, 200, 0.07);
  border: 1px solid rgba(45, 212, 200, 0.20);
  border-radius: 999px;
  margin-bottom: 36px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2dd4c8;
  box-shadow: 0 0 8px #2dd4c8;
  animation: dot-blink 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.status-text {
  font-size: 0.80rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ── Search ── */
.hero-search {
  width: 100%;
  max-width: 580px;
  position: relative;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon-svg {
  position: absolute;
  left: 18px;
  color: var(--text-dim);
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 16px 20px 16px 50px;
  border-radius: 999px;
  border: 1.5px solid var(--bd);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  box-shadow: 0 4px 30px rgba(0,0,0,0.30);
}

.search-input::placeholder {
  color: var(--text-dim);
}

.search-input:focus {
  border-color: var(--bd-bright);
  /* background ereditato da regola base (var(--bg-glass)) — theme-aware (era hardcoded rgba(12,22,40,.9) → testo illeggibile in light) */
  box-shadow: 0 0 0 3px rgba(45,212,200,0.10), 0 4px 30px rgba(0,0,0,0.40);
}

/* Search results overlay — position:fixed per bypassare overflow:hidden di .hero */
.search-results {
  display: none;
  position: fixed;
  /* top/left/width settati dinamicamente da JS in base al search-input */
  background: #0c1628;
  border: 1px solid var(--bd-bright);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow), var(--glow-teal);
  z-index: 1000;
  max-height: min(60vh, 420px);
  overflow-y: auto;
}

.search-results.active { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(45, 212, 200, 0.06);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.selected { background: rgba(45, 212, 200, 0.08); }

.result-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.result-body { flex: 1; min-width: 0; }

.result-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.result-chapter {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.result-kw {
  font-size: 0.73rem;
  color: var(--teal);
  opacity: 0.8;
}

.result-arrow {
  font-size: 1.1rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.search-empty {
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}


/* ══════════════════════════════════════════════
   DARK BODY
══════════════════════════════════════════════ */
.body-dark {
  background: var(--bg-void);
  padding: 0 0 100px;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Section headers ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-top: 56px;
}

.section-label-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-label-icon.teal {
  background: rgba(45, 212, 200, 0.10);
  border: 1px solid rgba(45, 212, 200, 0.25);
  color: var(--teal);
}

.section-label-icon.violet {
  background: var(--violet-glow);
  border: 1px solid rgba(167, 139, 250, 0.25);
  color: var(--violet);
}

.section-label h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text);
}

.section-label span {
  font-size: 0.80rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}


/* ══════════════════════════════════════════════
   UTILITY STRIP
══════════════════════════════════════════════ */
.utility-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.util-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 10px 20px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--bd);
  transition: transform 0.20s, box-shadow 0.20s, border-color 0.20s;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  animation: fadeUp 0.4s ease both;
}

/* Top accent bar */
.util-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--teal));
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  opacity: 0.75;
}

/* Glow on hover */
.util-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-sm);
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent, var(--teal)) 15%, transparent) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
}

.util-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.50), 0 0 0 1px color-mix(in srgb, var(--accent, var(--teal)) 40%, transparent);
  border-color: color-mix(in srgb, var(--accent, var(--teal)) 30%, transparent);
}

.util-card:hover::after { opacity: 1; }
.util-card:active { transform: translateY(-1px); }

.util-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  color: color-mix(in srgb, var(--accent, var(--teal)) 90%, white);
  position: relative;
  z-index: 1;
}

.util-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  position: relative;
  z-index: 1;
}

.util-badge {
  display: inline-block;
  font-size: 0.60rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--violet-glow);
  border: 1px solid rgba(167, 139, 250, 0.30);
  color: var(--violet);
  position: relative;
  z-index: 1;
}


/* ══════════════════════════════════════════════
   CHAPTER CARDS
══════════════════════════════════════════════ */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.chapter-card {
  position: relative;
  border-radius: var(--r-md);
  padding: 26px 22px 24px;
  background: var(--bg-card);
  border: 1px solid var(--bd);
  transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.4s ease both;
}

/* Top-left gradient accent */
.chapter-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--r-md);
  background: radial-gradient(
    ellipse 200px 150px at -10% -10%,
    color-mix(in srgb, var(--ch-color) 14%, transparent) 0%,
    transparent 100%
  );
  pointer-events: none;
}

/* Bottom line */
.chapter-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ch-color), transparent 70%);
  opacity: 0.45;
}

.chapter-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px color-mix(in srgb, var(--ch-color) 35%, transparent);
  border-color: color-mix(in srgb, var(--ch-color) 30%, transparent);
}

.chapter-card:hover::after { opacity: 0.75; }
.chapter-card:active { transform: translateY(-2px); }

/* Locked / coming-soon cards */
.chapter-card--locked {
  pointer-events: none;
  opacity: 0.45;
  filter: grayscale(0.6);
}
.chapter-card--locked .chapter-locked-badge {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, rgba(109,40,217,0.85), rgba(37,99,235,0.75));
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 2;
}

.chapter-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 17px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.chapter-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 5px;
}

.chapter-count {
  font-size: 0.80rem;
  color: var(--text-muted);
  font-weight: 400;
}

.chapter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.chapter-pill {
  font-size: 0.70rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.chapter-arrow {
  position: absolute;
  right: 18px;
  top: 22px;
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
}
.chapter-card:hover .chapter-arrow {
  color: var(--ch-color);
  transform: translateX(4px);
}


/* ══════════════════════════════════════════════
   DISCLAIMER
══════════════════════════════════════════════ */
.disclaimer-bar {
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.16);
  border-radius: var(--r-sm);
  padding: 16px 20px;
  margin-top: 52px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  color: rgba(190, 205, 225, 0.70);
  font-size: 0.84rem;
  line-height: 1.6;
}

.disclaimer-bar svg {
  flex-shrink: 0;
  color: var(--violet);
  margin-top: 2px;
}


/* ══════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════ */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 11px 24px;
  padding-bottom: max(11px, env(safe-area-inset-bottom));
  background: rgba(4, 7, 15, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 50;
}

.footer-link {
  font-size: 0.80rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--teal); }

.footer-version {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-left: auto;
}

.footer-sep {
  width: 1px; height: 14px;
  background: var(--bd);
}


/* ══════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chapters-grid .chapter-card:nth-child(1) { animation-delay: 0.04s; }
.chapters-grid .chapter-card:nth-child(2) { animation-delay: 0.08s; }
.chapters-grid .chapter-card:nth-child(3) { animation-delay: 0.12s; }
.chapters-grid .chapter-card:nth-child(4) { animation-delay: 0.16s; }
.chapters-grid .chapter-card:nth-child(5) { animation-delay: 0.20s; }
.chapters-grid .chapter-card:nth-child(6) { animation-delay: 0.24s; }
.chapters-grid .chapter-card:nth-child(7) { animation-delay: 0.28s; }
.chapters-grid .chapter-card:nth-child(8) { animation-delay: 0.32s; }

.utility-strip .util-card:nth-child(1) { animation-delay: 0.08s; }
.utility-strip .util-card:nth-child(2) { animation-delay: 0.12s; }
.utility-strip .util-card:nth-child(3) { animation-delay: 0.16s; }
.utility-strip .util-card:nth-child(4) { animation-delay: 0.20s; }
.utility-strip .util-card:nth-child(5) { animation-delay: 0.24s; }
.utility-strip .util-card:nth-child(6) { animation-delay: 0.28s; }


/* ══════════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-void); }
::-webkit-scrollbar-thumb {
  background: rgba(45, 212, 200, 0.20);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(45, 212, 200, 0.38);
}


/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .chapters-grid   { grid-template-columns: repeat(2, 1fr); }
  .utility-strip   { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .hero-title       { font-size: 2.8rem; }
  .hero-tagline     { font-size: 1rem; }
  .logo-3d          { width: 130px; height: 130px; }
  .hero-logo        { width: 130px; height: 130px; }
  .logo-scene       { width: 160px; height: 160px; }

  .chapters-grid    { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .chapter-card     { padding: 18px 14px 16px; }
  .chapter-name     { font-size: 0.92rem; }
  .chapter-pills    { display: none; }

  .utility-strip    { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .status-text      { font-size: 0.73rem; }

  .site-footer      { gap: 14px; }
  .footer-version   { display: none; }
}

@media (max-width: 400px) {
  .hero-title { font-size: 2.2rem; }
}

/* ════════════════════════════════════════════════════════
   Trial Badge — promo trial + referral, 4 stati adattivi
   ════════════════════════════════════════════════════════ */
.trial-badge{
  --tb-accent: #2dd4c8;
  --tb-rgb: 45,212,200;
  display:flex;align-items:center;gap:14px;
  padding:14px 16px;
  border-radius:14px;
  background:linear-gradient(135deg,rgba(30,41,59,0.7),rgba(15,23,42,0.5));
  border:1px solid rgba(148,163,184,0.18);
  border-left:4px solid var(--tb-accent);
  -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
  margin:12px 0 16px;
  animation:tb-fade-in 400ms ease-out both;
}
@keyframes tb-fade-in{from{opacity:0;transform:translateY(-6px);}to{opacity:1;transform:translateY(0);}}
.trial-badge[data-state="anonymous"], .trial-badge[data-state="free-no-trial"]{
  --tb-accent:#2dd4c8; --tb-rgb:45,212,200;
}
.trial-badge[data-state="free-post-trial"]{
  --tb-accent:#a78bfa; --tb-rgb:167,139,250;
}
.trial-badge[data-state="trial-active"]{
  --tb-accent:#fbbf24; --tb-rgb:251,191,36;
}
.trial-badge .tb-icon{
  flex:0 0 auto;width:42px;height:42px;border-radius:50%;
  display:inline-flex;align-items:center;justify-content:center;
  background:rgba(var(--tb-rgb),0.16);
  border:1px solid rgba(var(--tb-rgb),0.35);
  box-shadow:inset 0 0 12px rgba(var(--tb-rgb),0.18);
  color:var(--tb-accent);
}
.trial-badge .tb-icon svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.trial-badge .tb-body{flex:1;min-width:0;}
.trial-badge .tb-title{font-size:0.92rem;font-weight:700;letter-spacing:-0.01em;color:#f1f5f9;line-height:1.25;}
.trial-badge .tb-sub{font-size:0.74rem;color:#9ca3af;margin-top:3px;line-height:1.4;}
.trial-badge .tb-cta{
  flex:0 0 auto;
  background:linear-gradient(135deg,rgba(var(--tb-rgb),0.18),rgba(var(--tb-rgb),0.10));
  border:1px solid rgba(var(--tb-rgb),0.4);
  color:var(--tb-accent);
  padding:7px 14px;border-radius:10px;
  font-size:0.78rem;font-weight:600;letter-spacing:-0.005em;
  cursor:pointer;display:inline-flex;align-items:center;gap:6px;
  transition:transform 180ms cubic-bezier(.2,.7,.2,1),background 200ms ease,border-color 200ms ease;
}
.trial-badge .tb-cta:hover{
  transform:translateY(-1px);
  background:linear-gradient(135deg,rgba(var(--tb-rgb),0.30),rgba(var(--tb-rgb),0.18));
  border-color:rgba(var(--tb-rgb),0.7);
}
.trial-badge .tb-cta svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
@media (max-width:480px){
  .trial-badge{flex-wrap:wrap;}
  .trial-badge .tb-body{flex-basis:100%;}
}

/* Light theme overrides for trial-badge */
:root[data-theme="light"] .trial-badge{
  background:linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,248,231,0.85));
  border-color: var(--bd);
}
:root[data-theme="light"] .trial-badge .tb-title{
  color: var(--text);
}
:root[data-theme="light"] .trial-badge .tb-sub{
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════════
   Referral Modal — invita amico
   ════════════════════════════════════════════════════════ */
.referral-modal-backdrop{
  position:fixed;inset:0;z-index:9500;
  background:rgba(4,7,15,0.85);
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);
  display:none;align-items:center;justify-content:center;padding:16px;
}
.referral-modal-backdrop.active{display:flex;}
.referral-modal{
  background:linear-gradient(160deg,#0b1220,#0f172a);
  border:1px solid rgba(148,163,184,0.22);
  border-radius:18px;
  max-width:440px;width:100%;max-height:90vh;
  overflow-y:auto;
  padding:22px 22px 18px;
  color:#e5e7eb;
  font-size:0.92rem;
  box-shadow:0 20px 60px rgba(0,0,0,0.6);
}
.referral-modal h3{font-size:1.05rem;font-weight:700;color:#f1f5f9;margin:0 0 4px 0;letter-spacing:-0.01em;}
.referral-modal .rm-close{
  position:absolute;top:14px;right:14px;
  background:none;border:none;cursor:pointer;color:#9ca3af;
  width:32px;height:32px;border-radius:50%;
  display:inline-flex;align-items:center;justify-content:center;
  transition:background 150ms,color 150ms;
}
.referral-modal .rm-close:hover{background:rgba(248,113,113,0.16);color:#fca5a5;}
.referral-modal .rm-close svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.referral-modal .rm-info{
  background:rgba(45,212,200,0.08);border:1px solid rgba(45,212,200,0.22);
  border-radius:10px;padding:10px 12px;font-size:0.82rem;color:#a7f3d0;
  margin:12px 0 14px;line-height:1.45;
}
.referral-modal .rm-link-row{
  display:flex;gap:6px;align-items:center;
  background:rgba(0,0,0,0.32);border:1px solid rgba(148,163,184,0.22);
  border-radius:10px;padding:6px 6px 6px 12px;margin:6px 0 14px;
}
.referral-modal .rm-link-input{
  flex:1;background:none;border:none;color:#cbd5e1;font-family:monospace;font-size:0.82rem;outline:none;
}
.referral-modal .rm-copy-icon{
  background:rgba(45,212,191,0.18);border:1px solid rgba(45,212,191,0.4);
  color:#5eead4;border-radius:8px;padding:6px 10px;cursor:pointer;
  display:inline-flex;align-items:center;gap:5px;font-size:0.75rem;font-weight:600;
}
.referral-modal .rm-copy-icon svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.referral-modal .rm-divider{
  text-align:center;font-size:0.72rem;color:#6b7280;margin:14px 0 10px;letter-spacing:0.05em;text-transform:uppercase;
}
.referral-modal label{display:block;font-size:0.78rem;color:#9ca3af;margin:8px 0 4px;}
.referral-modal input[type=email],.referral-modal input[type=text]{
  width:100%;background:rgba(0,0,0,0.32);border:1px solid rgba(148,163,184,0.22);
  border-radius:10px;padding:8px 12px;color:#e5e7eb;font-size:0.88rem;
  font-family:inherit;outline:none;transition:border-color 150ms;
}
.referral-modal input[type=email]:focus,.referral-modal input[type=text]:focus{border-color:rgba(45,212,200,0.55);}
.referral-modal .rm-status{
  margin-top:14px;padding-top:12px;border-top:1px solid rgba(148,163,184,0.12);
  font-size:0.78rem;color:#9ca3af;
}
.referral-modal .rm-status strong{color:#cbd5e1;}
.referral-modal .rm-toast{
  position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
  background:#0b1220;border:1px solid rgba(34,197,94,0.5);color:#86efac;
  padding:8px 16px;border-radius:10px;font-size:0.82rem;font-weight:600;
  z-index:9600;animation:rm-toast-in 200ms ease-out;
}
@keyframes rm-toast-in{from{opacity:0;transform:translate(-50%,12px);}to{opacity:1;transform:translate(-50%,0);}}

/* ============================================================
   Theme switcher button (nav-bar)
   ============================================================ */
.omni-theme-btn {
  background: var(--theme-btn-bg);
  border: 1px solid var(--theme-btn-bd);
  color: var(--text);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}
.omni-theme-btn:hover {
  background: var(--theme-btn-bg-hover);
  border-color: var(--theme-btn-bd-hover);
}
.omni-theme-btn:active { transform: scale(0.94); }
.omni-theme-btn svg { width: 18px; height: 18px; display: block; }
.omni-theme-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ============================================================
   Componenti universali Level 3 (Strategy C → A)
   Estratti da pattern condivisi tra schede new-gen.
   ============================================================ */

/* === Card primaria === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bd);
  border-radius: var(--r-md);
  padding: 14px 12px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* Border-left categoria */
.card[data-cat="eg"]         { border-left: 4px solid var(--ch-neuro); }
.card[data-cat="neonato"]    { border-left: 4px solid var(--ch-neo); }
.card[data-cat="postnatale"] { border-left: 4px solid var(--ch-resp); }
.card[data-cat="risultati"]  { border-left: 4px solid var(--ch-genet); }
.card[data-cat="cardio"]     { border-left: 4px solid var(--ch-card); }
.card[data-cat="genet"]      { border-left: 4px solid var(--ch-genet); }

/* === Field / form layout === */
.field {
  margin-bottom: 10px;
}
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.field > input,
.field > select,
.field > textarea {
  width: 100%;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 0.92rem;
  font-family: inherit;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
}
.field-full { margin-bottom: 12px; }
.helper-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* === Btn glass 2026 === */
.btn {
  --btn-tint: 148, 163, 184;
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 11px 18px 11px 12px;
  min-height: 52px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  background: linear-gradient(135deg, var(--btn-bg-from), var(--btn-bg-to));
  border: 1px solid var(--bd-bright);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 180ms cubic-bezier(.2,.7,.2,1), border-color 200ms ease, background 200ms ease;
}
.btn span.icon {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--btn-tint), 0.16);
  border: 1px solid rgba(var(--btn-tint), 0.35);
  color: rgb(var(--btn-tint));
}
.btn span.icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn > span:not(.icon) { flex: 1 1 auto; text-align: left; line-height: 1.2; }
.btn:hover:not([disabled]) {
  transform: translateY(-1px);
  border-color: rgba(var(--btn-tint), 0.55);
}
.btn:active:not([disabled]) { transform: translateY(0) scale(0.985); transition: transform 80ms ease; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; filter: saturate(0.5); }
.btn[data-action="save"]   { --btn-tint: 96, 165, 250; }
.btn[data-action="load"]   { --btn-tint: 251, 191, 36; }
.btn[data-action="copy"]   { --btn-tint: 45, 212, 191; }
.btn[data-action="reset"]  { --btn-tint: 248, 113, 113; }
.btn[data-action="print"]  { --btn-tint: 167, 139, 250; }
.btn-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 10px;
}

/* === Alert banner === */
.alert-box {
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 0.85rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-box.alert-warn   { background: rgba(180, 83, 9, 0.10); border: 1px solid var(--warn); color: var(--warn); }
.alert-box.alert-danger { background: rgba(185, 28, 28, 0.12); border: 1px solid var(--danger); color: var(--danger); }
.alert-box.alert-info   { background: rgba(12, 74, 110, 0.10); border: 1px solid var(--teal); color: var(--teal); }
.alert-box svg { flex: 0 0 auto; width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-top: 2px; }

/* === Quote / disclaimer box === */
.quote-box,
.disclaimer-box {
  background: var(--bg-quote);
  border: 1px solid var(--bd-quote);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
}

/* === Output result box (calcoli) === */
.output-eg {
  background: var(--bg-card2);
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-top: 10px;
}
.output-eg-main {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}
.output-eg-secondary {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Section block === */
.section-block {
  margin: 18px 0;
}
.section-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 8px;
}

/* === Chip === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-card2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* === Segmented / age-pill === */
.segmented {
  display: inline-flex;
  background: var(--bg-card2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}
.seg-btn,
.age-pill {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 200ms, color 200ms;
}
.seg-btn.active,
.age-pill.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Nav-bar chassis (uniformata 2026)
   Tutti i bottoni 32×32 con stesso shape, stesso pattern hover.
   ============================================================ */

/* Gap uniforme tra bottoni */
.omni-nav-bar {
  gap: 6px;
}

/* ── iPhone/notch/Dynamic Island: la barra fissa superiore non deve finire sotto
   la status bar (orario, wifi, batteria) ──
   Le pagine usano apple-mobile-web-app-status-bar-style: black-translucent +
   viewport-fit=cover, quindi il contenuto parte da y=0 sotto la status bar.
   La barra estende la sua altezza nella safe-area e spinge i pulsanti sotto la
   status bar (padding-top). Su desktop env(safe-area-inset-top)=0 → nessun effetto.
   Altezza unificata a 52px (vince sugli height inline per-pagina). */
.omni-nav-bar {
  padding-top: env(safe-area-inset-top) !important;
  height: calc(52px + env(safe-area-inset-top)) !important;
  box-sizing: border-box !important;
}
/* Offset del contenuto pari alla barra, solo sulle pagine che HANNO la barra fissa
   (evita gap sulle pagine senza barra). :has() è supportato da iOS Safari 15.4+. */
body:has(.omni-nav-bar) {
  padding-top: calc(52px + env(safe-area-inset-top)) !important;
}

/* Pagine SENZA barra fissa (teoria, schede, utility): con viewport-fit=cover il
   contenuto parte da y=0, quindi titolo e link "indietro" finiscono sotto la
   status bar / Dynamic Island. Al 27/07/2026 erano 219 pagine su 223.
   :where() azzera la specificita': le pagine che gestiscono gia' la safe-area
   per conto proprio (es. le admin) mantengono la loro regola.

   28/07/2026 — tolta l'esclusione :not(:has(.hero)). Era inutile e dannosa:
   le 57 pagine con .hero che avrebbero potuto averne bisogno hanno anche
   .omni-nav-bar, quindi sono gia' escluse dalla prima condizione e gestite a
   runtime da auth.js; in cambio l'esclusione lasciava scoperte 37 pagine
   (landing, tutte le «rapida» e «valori», ecopolmonare, cute), dove il primo
   elemento finiva sotto la status bar. */
body:where(:not(:has(.omni-nav-bar))) {
  padding-top: env(safe-area-inset-top, 0px);
}

/* Pulsante tema flottante: 114 pagine lo posizionano con stile INLINE
   (position:fixed;top:14px), quindi finisce sotto la status bar / Dynamic
   Island. Lo stile inline si puo' scavalcare solo con !important; il selettore
   di attributo colpisce SOLO le istanze fisse, non quelle dentro .omni-nav-bar. */
.omni-theme-btn[style*="position:fixed"] {
  top: calc(14px + env(safe-area-inset-top, 0px)) !important;
}

/* ═══ Altri elementi fissi in alto (31/07/2026) ═══
   Stessa storia del pulsante tema: `position:fixed` con un `top` in pixel
   secchi, deciso quando la safe-area non esisteva. Su iPhone finiscono sotto
   la status bar o la Dynamic Island.
   Il caso che si notava di piu' e' la X per chiudere le immagini a tutto
   schermo: sta in alto a destra, cioe' proprio sotto la fotocamera, ed e'
   l'unico modo per uscire dal visualizzatore — se non si vede, l'utente
   resta bloccato. Vale su 12 schede (ecografia cerebrale, CFM, percentili,
   ittero, NPT...). */
#omni-lb-close {
  top: calc(14px + env(safe-area-inset-top, 0px)) !important;
}

/* Riquadro col paziente in uso (Assistente NPT): appena sotto la barra. */
.patient-chip {
  top: calc(48px + env(safe-area-inset-top, 0px)) !important;
}

/* Avviso «nuova versione disponibile» del service worker. */
.sw-update-banner {
  top: calc(64px + env(safe-area-inset-top, 0px)) !important;
}

/* Pulsante tema della pagina di accesso (ha una classe propria). */
.login-theme-btn {
  top: calc(14px + env(safe-area-inset-top, 0px)) !important;
}

/* ═══ ALTEZZA UNIFICATA della barra superiore (28/07/2026) ═══
   Sull'elemento agivano CINQUE regole in conflitto (site.css, due in
   site-refresh.css e due inline nelle pagine): il risultato era una barra di
   52px + safe-area con padding-bottom 9px, quindi pulsanti da 32px con 5px
   sopra e 15px sotto — scentrati e con spreco verticale. Su iPhone il totale
   arrivava a ~111px, il 13% dello schermo.
   Il selettore usa `body .omni-nav-bar` (specificita' 0,1,1) per battere anche
   le regole inline delle pagine, che sono `.omni-nav-bar !important` (0,1,0). */
body .omni-nav-bar {
  height: calc(44px + env(safe-area-inset-top, 0px)) !important;
  padding-top: env(safe-area-inset-top, 0px) !important;
  padding-bottom: 0 !important;
  box-sizing: border-box !important;
}
body:has(.omni-nav-bar) {
  padding-top: calc(44px + env(safe-area-inset-top, 0px)) !important;
}

/* Back link e Istruzioni link — trasformati in icon-button 32×32 dopo upgradeNavbar() */
.omni-nav-bar .omni-nav-back {
  background: var(--theme-btn-bg);
  border: 1px solid var(--theme-btn-bd);
  color: var(--text);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}
.omni-nav-bar .omni-nav-back:hover {
  background: var(--theme-btn-bg-hover);
  border-color: var(--theme-btn-bd-hover);
}
.omni-nav-bar .omni-nav-back:active { transform: scale(0.94); }
.omni-nav-bar .omni-nav-back svg { width: 18px; height: 18px; display: block; }
.omni-nav-bar .omni-nav-back:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Brand center con gradient text */
.omni-nav-bar .omni-nav-brand {
  flex: 1 1 auto;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.2px;
}
.omni-nav-bar .omni-nav-brand-gradient {
  background: linear-gradient(135deg, var(--teal), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* Fav button — icon 32×32 con tint warn (oro) */
.omni-nav-bar .omni-fav-btn {
  background: var(--theme-btn-bg);
  border: 1px solid var(--theme-btn-bd);
  color: var(--warn);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  flex: 0 0 auto;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}
.omni-nav-bar .omni-fav-btn:hover {
  background: var(--theme-btn-bg-hover);
  border-color: var(--theme-btn-bd-hover);
}
.omni-nav-bar .omni-fav-btn:active { transform: scale(0.94); }
.omni-nav-bar .omni-fav-btn svg { width: 18px; height: 18px; display: block; }
.omni-nav-bar .omni-fav-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Admin link in profilo — icon 32×32 con tint ok (verde) */
.omni-nav-bar #navAdminLink {
  background: rgba(52, 211, 153, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--ok);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  flex: 0 0 auto;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}
.omni-nav-bar #navAdminLink:hover {
  background: rgba(52, 211, 153, 0.28);
  border-color: rgba(52, 211, 153, 0.65);
}
.omni-nav-bar #navAdminLink svg { width: 18px; height: 18px; display: block; }

/* Light mode override — admin bg/border più scuri per contrast */
:root[data-theme="light"] .omni-nav-bar #navAdminLink {
  background: rgba(21, 128, 61, 0.14);
  border: 1px solid rgba(21, 128, 61, 0.45);
  color: #15803d;
}
:root[data-theme="light"] .omni-nav-bar #navAdminLink:hover {
  background: rgba(21, 128, 61, 0.22);
  border-color: rgba(21, 128, 61, 0.65);
}

/* Generic nav-bar icon-link button — usato per AI/Community/Admin con data-tint */
.omni-nav-bar .omni-nav-link-btn {
  --link-bg: rgba(255, 255, 255, 0.06);
  --link-bd: rgba(148, 163, 184, 0.22);
  --link-color: var(--text);
  --link-bg-hover: rgba(255, 255, 255, 0.10);
  --link-bd-hover: rgba(148, 163, 184, 0.40);
  background: var(--link-bg);
  border: 1px solid var(--link-bd);
  color: var(--link-color);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  flex: 0 0 auto;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease, transform 120ms ease;
}
.omni-nav-bar .omni-nav-link-btn:hover {
  background: var(--link-bg-hover);
  border-color: var(--link-bd-hover);
}
.omni-nav-bar .omni-nav-link-btn:active { transform: scale(0.94); }
.omni-nav-bar .omni-nav-link-btn svg { width: 18px; height: 18px; display: block; stroke: currentColor; fill: none; }
.omni-nav-bar .omni-nav-link-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Tint variants — colore icona per categoria */
.omni-nav-bar .omni-nav-link-btn[data-tint="violet"] {
  --link-color: var(--violet);
  --link-bg: rgba(167, 139, 250, 0.14);
  --link-bd: rgba(167, 139, 250, 0.40);
  --link-bg-hover: rgba(167, 139, 250, 0.22);
  --link-bd-hover: rgba(167, 139, 250, 0.60);
}
.omni-nav-bar .omni-nav-link-btn[data-tint="ok"] {
  --link-color: var(--ok);
  --link-bg: rgba(52, 211, 153, 0.14);
  --link-bd: rgba(52, 211, 153, 0.40);
  --link-bg-hover: rgba(52, 211, 153, 0.22);
  --link-bd-hover: rgba(52, 211, 153, 0.60);
}
.omni-nav-bar .omni-nav-link-btn[data-tint="teal"] {
  --link-color: var(--teal);
  --link-bg: rgba(45, 212, 200, 0.14);
  --link-bd: rgba(45, 212, 200, 0.40);
  --link-bg-hover: rgba(45, 212, 200, 0.22);
  --link-bd-hover: rgba(45, 212, 200, 0.60);
}

/* Light mode: stesse tint ma con colori v2 più scuri */
:root[data-theme="light"] .omni-nav-bar .omni-nav-link-btn[data-tint="violet"] {
  --link-color: #5b21b6;
  --link-bg: rgba(91, 33, 182, 0.10);
  --link-bd: rgba(91, 33, 182, 0.40);
  --link-bg-hover: rgba(91, 33, 182, 0.18);
  --link-bd-hover: rgba(91, 33, 182, 0.60);
}
:root[data-theme="light"] .omni-nav-bar .omni-nav-link-btn[data-tint="ok"] {
  --link-color: #15803d;
  --link-bg: rgba(21, 128, 61, 0.10);
  --link-bd: rgba(21, 128, 61, 0.40);
  --link-bg-hover: rgba(21, 128, 61, 0.18);
  --link-bd-hover: rgba(21, 128, 61, 0.60);
}
:root[data-theme="light"] .omni-nav-bar .omni-nav-link-btn[data-tint="teal"] {
  --link-color: #0c4a6e;
  --link-bg: rgba(12, 74, 110, 0.10);
  --link-bd: rgba(12, 74, 110, 0.40);
  --link-bg-hover: rgba(12, 74, 110, 0.18);
  --link-bd-hover: rgba(12, 74, 110, 0.60);
}


/* ============================================================
   Fase 1.5 — Professional Verification badges
   ============================================================ */
.badge-verified,
.badge-pending,
.badge-unverified {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    vertical-align: middle;
    white-space: nowrap;
}
.badge-verified {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.4);
}
.badge-pending {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
}
.badge-unverified {
    background: rgba(148, 163, 184, 0.15);
    color: rgba(148, 163, 184, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Mini-button modifiers per admin actions (Fase 1.5) */
.btn-plan.btn-success {
    background: rgba(52, 211, 153, 0.18);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.45);
}
.btn-plan.btn-warn {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.4);
}
.btn-plan.btn-secondary {
    background: rgba(148, 163, 184, 0.15);
    color: rgba(148, 163, 184, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Light theme overrides */
:root[data-theme="light"] .badge-verified {
    background: rgba(21, 128, 61, 0.12);
    color: #15803d;
    border-color: rgba(21, 128, 61, 0.4);
}
:root[data-theme="light"] .badge-pending {
    background: rgba(202, 138, 4, 0.12);
    color: #ca8a04;
    border-color: rgba(202, 138, 4, 0.4);
}
:root[data-theme="light"] .badge-unverified {
    background: rgba(75, 85, 99, 0.10);
    color: #4b5563;
    border-color: rgba(75, 85, 99, 0.3);
}

/* ============================================================
   Fase 1.5 — Modal overlay (auth.js nudge legacy users)
   ============================================================ */
.omni-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(4, 7, 15, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}
.omni-modal {
    background: #0b1220;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
    color: #e2e8f0;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.omni-modal h3 {
    color: #67e8f9;
    margin-top: 0;
}
:root[data-theme="light"] .omni-modal {
    background: #fefdf8;
    color: #0f172a;
    border-color: rgba(99, 102, 241, 0.2);
}
:root[data-theme="light"] .omni-modal h3 {
    color: #5b21b6;
}


/* ── Fix overflow tabelle nelle pagine teoria (mobile/iPhone) ──
   I grid item di .teoria-wrap hanno min-width:auto di default: una tabella
   larga (contenuto non spezzabile) espande il grid item oltre il viewport,
   allargando la pagina e provocando lo zoom-fit di Safari. Con min-width:0
   il grid item resta vincolato e la tabella (display:block; overflow-x:auto)
   scrolla internamente invece di allargare la pagina. */
.teoria-wrap > * { min-width: 0; }

/* Stesso problema nei moduli di servizio con layout a griglia (Valori: .val-layout
   240px/1fr): il grid item 1fr non deve espandersi oltre il viewport per una tabella
   larga. Le tabelle stanno già in wrapper .tbl-scroll (overflow-x:auto) → con
   min-width:0 sul grid item scrollano internamente invece di allargare la pagina. */
.val-layout > *, .val-grid > * { min-width: 0; }

/* Tabelle non incapsulate in un wrapper scrollabile (calcolatori/strumenti): le
   rendiamo scroll-container esse stesse così non allargano la pagina su mobile.
   Scoped alle classi note (nessun impatto su eventuali tabelle di layout). */
.sdo-table, .calc-result table, .res-table, .audit-table {
  display: block; max-width: 100%;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* Scheda Rapida: il wrapper .rapida-tbl-wrap aveva "overflow-x:auto" seguito da
   "overflow:hidden" nella stessa dichiarazione (overflow:hidden vinceva → tabella
   larga TAGLIATA e non scrollabile su mobile). Forziamo lo scroll orizzontale. */
.rapida-tbl-wrap { overflow-x: auto !important; overflow-y: hidden; max-width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   TABELLE — due difetti distinti trovati nell'audit del 01/08/2026.
   Entrambi si correggono da qui: tutte le 80 pagine di teoria e farmaci.html
   includono questo foglio, quindi non serve toccare i singoli file.
   ═══════════════════════════════════════════════════════════════════════ */

/* (1) Prima colonna schiacciata a 1-2 lettere per riga (foto utente, tabella
   della sifilide congenita in Infettive).

   Causa: `.teoria-accordion-body { word-break: break-word }`, scritto identico
   in 74 pagine di teoria. Quel valore e' deprecato e per specifica CSS equivale
   a `overflow-wrap: anywhere` — l'unica variante che entra nel calcolo della
   larghezza MINIMA. La larghezza minima di ogni cella diventa cosi' un singolo
   carattere, la proprieta' si eredita nelle celle e l'auto-layout ripartisce lo
   spazio in proporzione al solo contenuto massimo: la colonna di prosa si
   prende tutto, quella corta collassa. E siccome il minimo e' ~0, la tabella
   `display:block; overflow-x:auto` non ha mai bisogno di scorrere → nemmeno lo
   scorrimento la salva.

   Controprova: le pagine di teoria vecchia maniera (cardiologia, cute,
   ecocardio, ecopolmonare, emodinamica, genetica) NON hanno quella riga e le
   loro tabelle scorrono correttamente.

   Perche' basta questo e non serve `!important`: qui il valore e' dichiarato
   DIRETTAMENTE sulla cella, mentre la pagina lo dichiara sul contenitore. Un
   valore diretto batte sempre uno ereditato, a prescindere dall'ordine di
   caricamento e dalla specificita'.

   Volutamente NON si aggiunge `min-width` sulle celle ne' `hyphens:auto`: il
   primo gonfia le tabelle a 8-12 colonne dove una colonna contiene solo un
   numero o "Si/No", il secondo sillaba male sigle e nomi propri. Con
   `word-break: normal` la larghezza minima torna a essere la parola piu' lunga,
   che e' esattamente quel che serve; se dopo il rilascio qualche colonna
   risultasse ancora stretta, il minimo si aggiunge come secondo passo mirato. */
.teoria-accordion-body th,
.teoria-accordion-body td {
  word-break: normal;
  overflow-wrap: break-word;
}

/* (2) Prontuario farmaci: schema posologico tagliato sul bordo destro
   (foto utente, colonna "20 mg/kg/do..." troncata).

   Causa diversa dalla precedente: la tabella viene generata SENZA un
   contenitore scorrevole (`farmaci.html:759`), sta dentro `.drug-card`, che ha
   `overflow: hidden`, e la pagina impedisce lo scorrimento orizzontale con
   `html, body { overflow-x: hidden }`. Risultato: se le tre colonne non ci
   stanno, la parte eccedente viene semplicemente tagliata e non c'e' modo di
   raggiungerla.

   La tabella diventa qui un blocco che scorre per conto proprio — lo stesso
   schema gia' usato nelle pagine di teoria. La pagina dichiara per
   `.dosing-table` solo width, border-collapse e font-size: `display` e
   `overflow-x` non li tocca, quindi queste righe sopravvivono senza forzature. */
.dosing-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
