/* ╔════════════════════════════════════════════════════════════════════╗
   ║  TravFriends — Design System v5.0                                   ║
   ║                                                                      ║
   ║  Layer aggiuntivo sopra il CSS esistente di ogni pagina.            ║
   ║  NON sostituisce — completa e armonizza.                            ║
   ║                                                                      ║
   ║  Contiene:                                                          ║
   ║  • Tokens (radius, motion, elevation, type scale, spacing)          ║
   ║  • Refinement palette (ombre più morbide, contrasti AA)             ║
   ║  • Componenti moderni: chip, badge, sheet, fab, segmented, ripple   ║
   ║  • Polish iOS: card glass, bottomsheet, action sheet                 ║
   ║  • Dark mode coerente (sovrascrive var senza rompere pagine)        ║
   ║  • Micro-interazioni: tap-scale, sheen, fade-in, slide-up           ║
   ╚════════════════════════════════════════════════════════════════════*/

:root {
  /* ── Spacing scale (8px base) ────────────────────────────────── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 48px; --sp-10: 64px;

  /* ── Radius scale ───────────────────────────────────────────── */
  --r-xs: 6px;  --r-sm: 10px; --r-md: 14px; --r-lg: 18px;
  --r-xl: 22px; --r-2xl: 28px; --r-pill: 999px;

  /* ── Type scale (fluid clamp per evitare zoom ridicolo) ─────── */
  --fs-xs:  clamp(0.72rem, 0.7rem + 0.1vw, 0.78rem);
  --fs-sm:  clamp(0.82rem, 0.78rem + 0.2vw, 0.9rem);
  --fs-md:  clamp(0.92rem, 0.88rem + 0.3vw, 1rem);
  --fs-lg:  clamp(1.05rem, 0.98rem + 0.4vw, 1.18rem);
  --fs-xl:  clamp(1.22rem, 1.1rem + 0.6vw, 1.5rem);
  --fs-2xl: clamp(1.5rem, 1.3rem + 1vw, 1.95rem);
  --fs-3xl: clamp(1.9rem, 1.6rem + 1.5vw, 2.6rem);

  /* ── Motion tokens (spring + easing) ────────────────────────── */
  --ease-snap: cubic-bezier(.22,1,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-soft: cubic-bezier(.4,0,.2,1);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;

  /* ── Elevation (ombre soft layered, no solid black) ─────────── */
  --el-1: 0 1px 2px rgba(15,59,58,0.05), 0 1px 3px rgba(15,59,58,0.04);
  --el-2: 0 2px 4px rgba(15,59,58,0.06), 0 4px 12px rgba(15,59,58,0.05);
  --el-3: 0 4px 8px rgba(15,59,58,0.07), 0 12px 24px rgba(15,59,58,0.07);
  --el-4: 0 8px 16px rgba(15,59,58,0.08), 0 24px 48px rgba(15,59,58,0.10);
  --el-5: 0 16px 32px rgba(15,59,58,0.10), 0 40px 80px rgba(15,59,58,0.14);
  --el-glow-teal: 0 0 0 1px rgba(10,191,188,0.15), 0 10px 30px -8px rgba(10,191,188,0.45);
  --el-glow-gold: 0 0 0 1px rgba(245,158,11,0.18), 0 10px 30px -8px rgba(245,158,11,0.45);

  /* ── Palette refinement (ridefinisce sse non già impostate) ── */
  --teal:        #0ABFBC;
  --teal-d:      #089A97;
  --teal-deep:   #057A78;
  --teal-pale:   #F0FEFE;
  --teal-soft:   #E0F9F9;
  --cyan:        #22D3EE;
  --ink:         #0F3B3A;
  --ink-2:       #1F4F4D;
  --mute:        #5A9A98;
  --mute-2:      #8FB8B6;
  --bg:          #F7FEFE;
  --bg-2:        #ECFAFA;
  --card:        #FFFFFF;
  --border:      rgba(10,191,188,0.16);
  --border-strong: rgba(10,191,188,0.28);
  --gold-d:      #D97706;
  --gold:        #F59E0B;
  --gold-l:      #FBBF24;
  --rose:        #F43F5E;
  --purple:      #7C3AED;
  --green:       #10B981;
}

/* ────────────────────────────────────────────────────────────────────
   Dark mode v5: completa le variabili senza forzare colori sui figli.
   Le pagine continuano a usare var(--teal), var(--card), ecc. — qui
   solo ridefiniamo i token al primo livello quando html.tf-dark è on.
   ──────────────────────────────────────────────────────────────────── */
html.tf-dark {
  --bg:          #0A1A1A;
  --bg-2:        #0F2424;
  --card:        #142323;
  --ink:         #E6F8F7;
  --ink-2:       #C4E7E5;
  --mute:        #7FB1AF;
  --mute-2:      #5A8E8C;
  --border:      rgba(10,191,188,0.22);
  --border-strong: rgba(10,191,188,0.38);
  --teal-pale:   #0E1D1D;
  --teal-soft:   #122727;
  --el-1: 0 1px 2px rgba(0,0,0,0.20), 0 1px 3px rgba(0,0,0,0.16);
  --el-2: 0 2px 4px rgba(0,0,0,0.24), 0 4px 12px rgba(0,0,0,0.18);
  --el-3: 0 4px 8px rgba(0,0,0,0.30), 0 12px 24px rgba(0,0,0,0.22);
  --el-4: 0 8px 16px rgba(0,0,0,0.36), 0 24px 48px rgba(0,0,0,0.28);
  --el-5: 0 16px 32px rgba(0,0,0,0.42), 0 40px 80px rgba(0,0,0,0.36);
}

/* ────────────────────────────────────────────────────────────────────
   Body baseline polish — applicato senza forzare overrides duri
   ──────────────────────────────────────────────────────────────────── */
body {
  font-feature-settings: 'cv11','ss01','ss03';
  text-rendering: optimizeLegibility;
}

/* iOS notch: tutte le topbar sticky della app già usano padding-top.
   Aggiungiamo helper se non lo fanno. */
.tf-v5-pad-top { padding-top: calc(env(safe-area-inset-top, 0) + var(--sp-3)); }
.tf-v5-pad-bot { padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--sp-3)); }

/* ────────────────────────────────────────────────────────────────────
   COMPONENTI v5 (tutti prefissati .tfv5- per non collidere)
   ──────────────────────────────────────────────────────────────────── */

/* ── Card v5 ──────────────────────────────────────────────────────── */
.tfv5-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--el-1);
  transition: box-shadow var(--dur-base) var(--ease-soft), transform var(--dur-fast) var(--ease-soft);
}
.tfv5-card.tfv5-elevated { box-shadow: var(--el-2); }
.tfv5-card.tfv5-hover:hover { box-shadow: var(--el-3); transform: translateY(-2px); }
.tfv5-card.tfv5-glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
html.tf-dark .tfv5-card.tfv5-glass {
  background: rgba(20,35,35,0.68);
}

/* ── Buttons v5 ───────────────────────────────────────────────────── */
.tfv5-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 11px 20px;
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: var(--fs-sm);
  border-radius: var(--r-pill); border: none; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-soft),
              background var(--dur-base) var(--ease-soft);
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  position: relative; overflow: hidden; min-height: 44px;
}
.tfv5-btn:active { transform: scale(0.96); }
.tfv5-btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  color: #fff; box-shadow: var(--el-glow-teal);
}
.tfv5-btn-primary:hover { box-shadow: 0 0 0 1px rgba(10,191,188,0.25), 0 14px 36px -10px rgba(10,191,188,0.55); }
.tfv5-btn-ghost {
  background: var(--teal-pale); color: var(--teal-deep);
  border: 1px solid var(--border-strong);
}
.tfv5-btn-ghost:hover { background: var(--teal-soft); }
.tfv5-btn-gold {
  background: linear-gradient(135deg, var(--gold-l), var(--gold));
  color: #fff; box-shadow: var(--el-glow-gold);
}
.tfv5-btn-danger { background: var(--rose); color: #fff; }
.tfv5-btn-sm { padding: 7px 14px; font-size: var(--fs-xs); min-height: 36px; }
.tfv5-btn-lg { padding: 14px 28px; font-size: var(--fs-md); min-height: 52px; }
.tfv5-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Ripple effect (attivato da JS aggiungendo .tfv5-ripple-on) */
.tfv5-btn .tfv5-ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,0.45); transform: scale(0); opacity: 1;
  animation: tfv5RippleAnim 600ms var(--ease-soft);
}
@keyframes tfv5RippleAnim { to { transform: scale(4); opacity: 0; } }

/* ── Chip / Tag ───────────────────────────────────────────────────── */
.tfv5-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; font-size: var(--fs-xs); font-weight: 700;
  border-radius: var(--r-pill); background: var(--teal-pale); color: var(--teal-deep);
  border: 1px solid var(--border); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-soft);
}
.tfv5-chip:hover { background: var(--teal-soft); }
.tfv5-chip-solid { background: var(--teal); color: #fff; border-color: transparent; }
.tfv5-chip-gold { background: #FEF3C7; color: #92400E; border-color: rgba(245,158,11,0.30); }
.tfv5-chip-pro {
  background: linear-gradient(135deg, var(--gold-l), var(--gold)); color: #fff;
  border-color: transparent; box-shadow: 0 2px 8px rgba(245,158,11,0.35);
}

/* ── Badge counter ────────────────────────────────────────────────── */
.tfv5-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  background: var(--rose); color: #fff; border-radius: var(--r-pill);
  font-size: 0.68rem; font-weight: 800; line-height: 1; font-family: 'Nunito', sans-serif;
}

/* ── Input v5 ─────────────────────────────────────────────────────── */
.tfv5-input,
.tfv5-textarea,
.tfv5-select {
  width: 100%; padding: 13px 16px;
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  font-family: inherit; font-size: var(--fs-md);
  transition: border-color var(--dur-base) var(--ease-soft),
              box-shadow var(--dur-base) var(--ease-soft);
  -webkit-appearance: none; appearance: none;
}
.tfv5-input:focus,
.tfv5-textarea:focus,
.tfv5-select:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(10,191,188,0.14);
}
.tfv5-input::placeholder, .tfv5-textarea::placeholder { color: var(--mute-2); }

/* ── Segmented control (stile iOS) ───────────────────────────────── */
.tfv5-seg {
  display: inline-flex; padding: 3px; background: var(--teal-pale);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  gap: 2px;
}
.tfv5-seg-item {
  padding: 7px 14px; font-size: var(--fs-sm); font-weight: 700;
  border-radius: var(--r-pill); cursor: pointer; border: none;
  background: transparent; color: var(--mute); white-space: nowrap;
  transition: background var(--dur-base) var(--ease-soft), color var(--dur-base) var(--ease-soft);
}
.tfv5-seg-item.active { background: var(--card); color: var(--teal-deep); box-shadow: var(--el-1); }

/* ── FAB (Floating Action Button) ────────────────────────────────── */
.tfv5-fab {
  position: fixed; right: calc(env(safe-area-inset-right, 0) + var(--sp-4));
  bottom: calc(env(safe-area-inset-bottom, 0) + 80px);
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--cyan)); color: #fff;
  border: none; cursor: pointer; z-index: 200;
  box-shadow: var(--el-4), 0 0 0 0 rgba(10,191,188,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  transition: transform var(--dur-base) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-soft);
  animation: tfv5FabPulse 2.4s var(--ease-soft) infinite;
}
.tfv5-fab:hover { transform: scale(1.08); }
.tfv5-fab:active { transform: scale(0.92); }
@keyframes tfv5FabPulse {
  0%,100% { box-shadow: var(--el-4), 0 0 0 0 rgba(10,191,188,0.4); }
  50% { box-shadow: var(--el-4), 0 0 0 14px rgba(10,191,188,0); }
}

/* ── Bottomsheet (gestito da JS, qui solo skin) ─────────────────── */
.tfv5-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,59,58,0.42);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-soft);
  z-index: 9990;
}
.tfv5-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.tfv5-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); color: var(--ink);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--el-5);
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-spring);
  z-index: 9995; max-height: 90vh; overflow: hidden;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--sp-3));
  display: flex; flex-direction: column;
}
.tfv5-sheet.open { transform: translateY(0); }
.tfv5-sheet-grabber {
  width: 38px; height: 4px; border-radius: var(--r-pill);
  background: var(--mute-2); opacity: 0.4;
  margin: 9px auto 6px; flex-shrink: 0;
}
.tfv5-sheet-header {
  padding: var(--sp-2) var(--sp-5) var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tfv5-sheet-title {
  font-family: 'Nunito', sans-serif; font-weight: 900; font-size: var(--fs-lg);
  color: var(--ink);
}
.tfv5-sheet-close {
  background: var(--teal-pale); border: none; color: var(--teal-deep);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.tfv5-sheet-body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1;
}

/* ── Action sheet (lista azioni stile iOS) ──────────────────────── */
.tfv5-actions { display: flex; flex-direction: column; gap: 2px; }
.tfv5-action {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-2); background: transparent; border: none;
  text-align: left; cursor: pointer; font-family: inherit; font-size: var(--fs-md);
  color: var(--ink); border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease-soft);
}
.tfv5-action:hover, .tfv5-action:active { background: var(--teal-pale); }
.tfv5-action-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--teal-pale); color: var(--teal-deep);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
  flex-shrink: 0;
}
.tfv5-action-danger { color: var(--rose); }
.tfv5-action-danger .tfv5-action-icon { background: rgba(244,63,94,0.10); color: var(--rose); }

/* ── Skeleton v5 (ridefinisce .tf-skel con curve migliori) ─────── */
.tfv5-skel {
  background: linear-gradient(90deg, rgba(10,191,188,0.05) 0%, rgba(10,191,188,0.14) 50%, rgba(10,191,188,0.05) 100%);
  background-size: 200% 100%;
  animation: tfv5SkelMove 1.5s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes tfv5SkelMove { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
html.tf-dark .tfv5-skel { background: linear-gradient(90deg, rgba(10,191,188,0.08) 0%, rgba(10,191,188,0.22) 50%, rgba(10,191,188,0.08) 100%); }

/* ── Divider ──────────────────────────────────────────────────────── */
.tfv5-divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; border: none; }
.tfv5-divider-thick { height: 8px; background: var(--bg-2); margin: var(--sp-4) calc(var(--sp-4) * -1); border: none; }

/* ── Micro-animations utility ─────────────────────────────────────── */
.tfv5-fade-in { animation: tfv5FadeIn var(--dur-slow) var(--ease-soft) both; }
@keyframes tfv5FadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.tfv5-slide-up { animation: tfv5SlideUp var(--dur-slow) var(--ease-spring) both; }
@keyframes tfv5SlideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.tfv5-pop-in { animation: tfv5PopIn var(--dur-slow) var(--ease-spring) both; }
@keyframes tfv5PopIn { 0% { opacity: 0; transform: scale(0.7); } 60% { opacity: 1; transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }

/* ── Tap-scale (utility da aggiungere a qualsiasi elemento) ─────── */
[data-tfv5-tap] {
  transition: transform var(--dur-fast) var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
[data-tfv5-tap]:active { transform: scale(0.96); }

/* ── Pull-to-refresh indicator (gestito da JS) ───────────────────── */
.tfv5-ptr {
  position: fixed; left: 50%; transform: translate(-50%, -100%);
  top: calc(env(safe-area-inset-top, 0) + 8px);
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--el-3);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  transition: transform var(--dur-base) var(--ease-soft), opacity var(--dur-base) var(--ease-soft);
  opacity: 0; pointer-events: none;
}
.tfv5-ptr.visible { opacity: 1; }
.tfv5-ptr-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--teal); border-top-color: transparent;
  animation: tfv5Spin 0.8s linear infinite;
}
@keyframes tfv5Spin { to { transform: rotate(360deg); } }

/* ── Toast v5 (riusa selettore tf-mob-toast esistente per non rompere) ─ */
.tf-mob-toast {
  background: rgba(15,59,58,0.96) !important;
  box-shadow: var(--el-4) !important;
  border: 1px solid rgba(255,255,255,0.06);
  font-family: 'Nunito', sans-serif !important;
}
html.tf-dark .tf-mob-toast {
  background: rgba(230,248,247,0.96) !important;
  color: #0F3B3A !important;
}

/* ── Empty-state (riusabile) ─────────────────────────────────────── */
.tfv5-empty {
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--mute);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.tfv5-empty .ic {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--teal-pale); color: var(--teal-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}
.tfv5-empty h4 {
  font-family: 'Nunito', sans-serif; font-weight: 900;
  color: var(--ink); font-size: var(--fs-lg); margin: 0;
}
.tfv5-empty p { font-size: var(--fs-sm); line-height: 1.5; max-width: 320px; }

/* ── Avatar v5 (con presence dot armonizzato) ────────────────────── */
.tfv5-avatar {
  position: relative; display: inline-block;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--teal-pale); flex-shrink: 0;
}
.tfv5-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tfv5-avatar-online::after {
  content: ''; position: absolute; bottom: 1px; right: 1px;
  width: 11px; height: 11px; background: var(--green);
  border: 2px solid var(--card); border-radius: 50%;
}
.tfv5-avatar-lg { width: 64px; height: 64px; }
.tfv5-avatar-xl { width: 96px; height: 96px; }
.tfv5-avatar-sm { width: 32px; height: 32px; }
.tfv5-avatar-xs { width: 24px; height: 24px; }

/* ────────────────────────────────────────────────────────────────────
   POLISH GLOBALE (selector-light) — applica miglioramenti a pattern
   ricorrenti senza riscrivere i CSS di pagina.
   ──────────────────────────────────────────────────────────────────── */

/* Click feedback più "vivo" sulle classi azione comuni del progetto */
button:not(:disabled), [role="button"]:not(.no-feedback) {
  -webkit-tap-highlight-color: transparent;
}
html.tf-mobile .pact-btn:active,
html.tf-mobile .btn:active,
html.tf-mobile .cta-btn:active {
  transform: scale(0.97);
  transition: transform 90ms var(--ease-soft);
}

/* Cards generiche: ombra più morbida e bordo più sottile */
html.tf-v5-polish .stat,
html.tf-v5-polish .cta-card,
html.tf-v5-polish .milestones,
html.tf-v5-polish .next {
  box-shadow: var(--el-1);
}

/* Bottom navigation (se presente): glass + safe-area */
.tf-bottom-nav, .bottom-nav, .tabbar {
  padding-bottom: env(safe-area-inset-bottom, 0) !important;
}
html.tf-pwa .tf-bottom-nav,
html.tf-pwa .bottom-nav,
html.tf-pwa .tabbar {
  background: rgba(255,255,255,0.85) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
}
html.tf-pwa.tf-dark .tf-bottom-nav,
html.tf-pwa.tf-dark .bottom-nav,
html.tf-pwa.tf-dark .tabbar {
  background: rgba(20,35,35,0.85) !important;
}

/* Topbar: glass su PWA */
html.tf-pwa .topbar,
html.tf-pwa .app-topbar {
  background: rgba(10,191,188,0.92) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
}

/* Status bar overlay padding per app nativa */
html.tf-native .topbar,
html.tf-pwa .topbar {
  padding-top: calc(env(safe-area-inset-top, 0) + 12px) !important;
}

/* Form inputs polish leggero (selettori generici, ignorano già stilizzati) */
input[type="text"]:not(.tfv5-input):not([class*="custom"]),
input[type="email"]:not(.tfv5-input):not([class*="custom"]),
input[type="password"]:not(.tfv5-input):not([class*="custom"]),
input[type="search"]:not(.tfv5-input):not([class*="custom"]),
textarea:not(.tfv5-textarea):not([class*="custom"]) {
  transition: border-color var(--dur-base) var(--ease-soft),
              box-shadow var(--dur-base) var(--ease-soft);
}
input[type="text"]:focus:not(.tfv5-input),
input[type="email"]:focus:not(.tfv5-input),
input[type="password"]:focus:not(.tfv5-input),
input[type="search"]:focus:not(.tfv5-input),
textarea:focus:not(.tfv5-textarea) {
  box-shadow: 0 0 0 4px rgba(10,191,188,0.12);
}

/* Lazy-load fade-in immagini */
img.tfv5-lazy {
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-soft);
}
img.tfv5-lazy.loaded { opacity: 1; }

/* iOS safe area utility globale per pagine senza topbar */
@supports (padding: max(0px)) {
  .tfv5-page-pad {
    padding-top: max(var(--sp-4), env(safe-area-inset-top));
    padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom));
  }
}

/* Selezione testo: armonizzata con teal */
::selection { background: rgba(10,191,188,0.28); color: inherit; }

/* Performance: lazy paint per elementi off-screen */
.tfv5-card, .post, .feed-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
}

/* Print: nascondi UI di chrome */
@media print {
  .topbar, .tf-bottom-nav, .tfv5-fab, .tfv5-sheet, .tfv5-sheet-backdrop,
  .bottom-nav, .tabbar, button { display: none !important; }
}

/* Reduce motion override per tutte le animazioni v5 */
@media (prefers-reduced-motion: reduce) {
  .tfv5-fade-in, .tfv5-slide-up, .tfv5-pop-in,
  .tfv5-fab, .tfv5-sheet, .tfv5-skel, .tfv5-ptr-spinner {
    animation: none !important; transition: none !important;
  }
}
