/* ═══════════════════════════════════════════════
   JAECOO 7 SHS — SMART MANUAL v5
   Senior UI · Glassmorphism · Dark
   ═══════════════════════════════════════════════ */

:root {
  --bg:            #080a0f;
  --bg2:           #0d1019;
  --panel:         #111520;
  --panel-2:       #161b27;
  --panel-border:  rgba(255,255,255,0.08);
  --panel-border-h:rgba(255,255,255,0.18);
  --text:          #eef0f4;
  --muted:         #7a8496;
  --muted-2:       #525d70;

  /* Blu principale */
  --blue:          #3b6ff5;
  --blue-dark:     #1e44c0;
  --blue-soft:     rgba(59,111,245,0.15);
  --blue-glow:     rgba(59,111,245,0.35);

  /* Verde SHS */
  --green:         #22d488;
  --green-dark:    #118a53;
  --green-soft:    rgba(34,212,136,0.12);
  --green-glow:    rgba(34,212,136,0.30);

  /* Giallo SHS */
  --yellow:        #f5c842;
  --yellow-soft:   rgba(245,200,66,0.12);

  /* Viola */
  --purple:        #9b6ff5;
  --purple-soft:   rgba(155,111,245,0.12);

  --radius:        16px;
  --radius-sm:     10px;
  --transition:    0.18s cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Bagliori fissi: rende visibile l'effetto glass ── */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  z-index: 0;
  pointer-events: none;
  will-change: opacity;
}
body::before {
  width: 520px; height: 520px;
  top: -180px; right: -140px;
  background: radial-gradient(circle, var(--blue-glow), transparent 70%);
}
body::after {
  width: 440px; height: 440px;
  bottom: -160px; left: -150px;
  background: radial-gradient(circle, var(--green-glow), transparent 70%);
}

/* Terzo bagliore al centro */
.app-shell::before {
  content: '';
  position: fixed;
  width: 300px; height: 300px;
  top: 45%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  filter: blur(120px);
  background: radial-gradient(circle, rgba(59,111,245,0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ── Utility glass mixin applicata a blocchi chiave ── */
.tile, .cat-card, .result-card, .cmd-card, .glass-card,
.ds-feature, .spec-card, .mode-card, .guide-card,
.glass-row, .stats-bar {
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.065) 0%,
    rgba(255,255,255,0.020) 100%
  );
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 12px 32px rgba(0,0,0,0.30),
    0 2px 8px rgba(0,0,0,0.18);
}

/* ════ FLAG STRIPE — tricolore tra il veicolo e il menu home ════ */
.home-flag-stripe {
  height: 5px;
  width: 100%;
  margin: 0;
  background: linear-gradient(90deg,
    #009246 0% 33.33%,
    #f0f0f0 33.33% 66.66%,
    #ce2b37 66.66% 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,0.32);
  border-radius: 0;
  flex-shrink: 0;
}

/* ════ TOPBAR ════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 4px; /* sotto la flag stripe */
  background: rgba(8,10,15,0.92);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  z-index: 10;
  min-height: 56px;
}

/* — Home mode: logo centrato — */
.topbar.home-mode {
  justify-content: center;
}
.topbar.home-mode .back { visibility: hidden; }
.topbar.home-mode .nav-title { display: none; }
.topbar.home-mode .home-brand { display: flex; }
.topbar.home-mode .topbar-actions {
  position: absolute;
  right: 18px;
  display: flex;
  gap: 6px;
}

/* — Nav mode (sotto-sezioni) — */
.topbar:not(.home-mode) .home-brand { display: none; }
.topbar:not(.home-mode) .nav-title  { display: flex; }

/* Home brand (logo centrato) */
.home-brand {
  display: none;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}
.hb-flag {
  display: inline-flex;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18);
  flex-shrink: 0;
  transition: transform 0.18s;
  cursor: default;
}
.hb-gear {
  filter: drop-shadow(0 0 8px rgba(59,111,245,0.7));
  flex-shrink: 0;
  transition: transform 0.3s ease, filter 0.3s;
  cursor: pointer;
}
.hb-gear:hover {
  transform: rotate(30deg) scale(1.12);
  filter: drop-shadow(0 0 14px rgba(59,111,245,1));
}

/* Pill quota AI nel topbar home */
.hb-quota-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(0,200,150,0.10);
  border: 1px solid rgba(0,200,150,0.28);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  cursor: default;
  transition: color 0.3s, background 0.3s, border-color 0.3s;
}
.hb-quota-pill.quota-empty {
  color: #f4a429;
  background: rgba(244,164,41,0.09);
  border-color: rgba(244,164,41,0.32);
}
.hb-quota-pill:empty { display: none; }

/* Nav title (sotto-sezioni) */
.nav-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.it-flag {
  display: inline-flex;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--yellow);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform 0.18s, border-color 0.18s;
}
.icon-btn:hover  { background: var(--panel-2); border-color: var(--yellow); transform: scale(1.10); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn-lg { width: 42px; height: 42px; font-size: 20px; }

.back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  visibility: hidden;
  transition: background var(--transition);
}
.back.visible { visibility: visible; }
.back:hover { background: rgba(255,255,255,0.07); }

/* ════ PREFERITI RAPIDO (top-left, solo home) ════ */
.quick-fav-btn {
  display: none; /* mostrato via JS solo su home */
  align-items: center;
  justify-content: center;
  background: rgba(255,215,0,0.10);
  border: 1.5px solid rgba(255,215,0,0.30);
  color: #ffd700;
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), transform 0.15s;
  position: relative;
  z-index: 2;
}
.quick-fav-btn:hover { background: rgba(255,215,0,0.18); transform: scale(1.10); }

/* ════ ERROR BANNER ════ */
.load-error {
  background: rgba(180,30,30,0.18);
  border-bottom: 1px solid rgba(200,50,50,0.4);
  color: #ffb3b3;
  font-size: 13px;
  line-height: 1.6;
  padding: 14px 20px;
  backdrop-filter: blur(10px);
}
.load-error strong { color: #ff6b6b; }
.load-error code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ════ INSTALL BANNER ════ */
.install-banner {
  background: var(--blue-soft);
  border-bottom: 1px solid var(--blue-dark);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(10px);
}
.install-banner .install-icon { font-size: 24px; flex-shrink: 0; }
.install-banner .install-text { flex: 1; font-size: 13.5px; line-height: 1.5; }
.install-banner .install-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.install-banner .install-steps { color: var(--muted); font-size: 13px; }
.install-banner button.install-action {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--transition);
}
.install-banner button.install-action:hover { background: var(--blue-dark); }
.install-banner .install-dismiss {
  background: none; border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

/* ════ CONTENT & VIEWS ════ */
.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}
.view { display: none; animation: fadeIn 0.22s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ════ HOME ════ */
.hero {
  text-align: center;
  padding: 24px 10px 8px;
}
.badge {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.shs-badge {
  color: var(--green);
  border: 1px solid var(--green-dark);
  background: var(--green-soft);
}
.wordmark {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 6px 0 2px;
  text-transform: uppercase;
}
.wordmark span { color: var(--blue); }
.hero-sub {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 400px;
  margin: 8px auto 0;
  line-height: 1.6;
}

.hero-photo {
  margin: 22px auto 0;
  max-width: 500px;
  border-radius: 24px;
  padding: 20px;
  background: radial-gradient(ellipse at center, #111e38 0%, var(--bg) 72%);
  display: flex;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.hero-photo-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 80%, rgba(34,212,136,0.07), transparent 60%);
  pointer-events: none;
}
.hero-photo img {
  width: 100%; height: auto;
  display: block;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.5));
}

/* Stats bar */
.stats-bar {
  display: flex;
  border-radius: 14px;
  padding: 14px 20px;
  margin-top: 16px;
  justify-content: space-around;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-divider {
  width: 1px;
  background: var(--panel-border);
  align-self: stretch;
}

/* ════ TILE BADGES ════ */
.tile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}
.tbadge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
  line-height: 1.5;
}
.tbadge-ai    { background: rgba(59,111,245,0.18); color: #8eb0ff; border: 1px solid rgba(59,111,245,0.3); }
.tbadge-hot   { background: rgba(255,100,40,0.14);  color: #ff8c60; border: 1px solid rgba(255,100,40,0.25); }
.tbadge-voice { background: rgba(34,212,136,0.13);  color: #5fe8b0; border: 1px solid rgba(34,212,136,0.25); }
.tbadge-shs   { background: rgba(245,200,66,0.14);  color: #f5c842; border: 1px solid rgba(245,200,66,0.25); }
.tbadge-guide { background: rgba(155,111,245,0.14); color: #c4a0ff; border: 1px solid rgba(155,111,245,0.25); }
.tbadge-ds    { background: rgba(59,111,245,0.12);  color: #7aa0f0; border: 1px solid rgba(59,111,245,0.22); }
.tbadge-note  { background: rgba(255,200,50,0.12);  color: #ffc832; border: 1px solid rgba(255,200,50,0.22); }

/* Priority tile highlight */
.tile-priority {
  border-color: rgba(59,111,245,0.25);
  box-shadow:
    0 0 0 1px rgba(59,111,245,0.08) inset,
    0 12px 32px rgba(0,0,0,0.30),
    0 0 20px rgba(59,111,245,0.06);
}

/* Note tile */
.tile-note { border-color: rgba(255,200,50,0.18); }
.icon-note { background: rgba(255,200,50,0.12); color: #ffc832; font-size: 21px; }

/* Tiles */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
}
.tile {
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.tile:hover {
  border-color: var(--panel-border-h);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.07) inset;
}
.tile:active { transform: scale(0.98); }

.icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  flex-shrink: 0;
}
.icon-blue  { background: var(--blue-soft);   color: var(--blue);   }
.icon-green { background: var(--green-soft);  color: var(--green);  }
.icon-yellow{ background: var(--yellow-soft); color: var(--yellow); }
.icon-purple{ background: var(--purple-soft); color: var(--purple); }
.icon-gear  { background: var(--blue-soft); }
.icon-gear img { filter: drop-shadow(0 0 6px rgba(59,111,245,0.5)); }

.tile .tile-text h3 { margin: 0 0 3px; font-size: 15.5px; font-weight: 700; }
.tile .tile-text p  { margin: 0; font-size: 12.5px; color: var(--muted); }
.tile .chevron { margin-left: auto; color: var(--muted-2); font-size: 20px; }

.tile-driversmart {
  position: relative;
  overflow: hidden;
}
.tile-driversmart::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 90% 20%, rgba(59,111,245,0.12), transparent 60%);
  pointer-events: none;
}

/* ════ SEARCH ROW ════ */
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-box.glass-input {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 11px 16px;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition);
}
.search-box.glass-input:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,111,245,0.15);
}
.search-box.glass-input input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.search-box.glass-input input::placeholder { color: var(--muted); }
.search-icon { color: var(--muted); font-size: 15px; }

.mic-btn, .go-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.mic-btn:hover { border-color: var(--blue); }
.mic-btn.listening {
  background: var(--blue);
  border-color: var(--blue);
  animation: pulse 1s infinite;
}
.mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.go-btn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59,111,245,0.35);
}
.go-btn:hover { background: var(--blue-dark); box-shadow: 0 4px 20px rgba(59,111,245,0.5); }

/* Pulsante AI (robot) */
.ai-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--green-dark);
  background: var(--green-soft);
  color: var(--green);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: 0 0 12px var(--green-glow);
}
.ai-btn:hover {
  background: rgba(34,212,136,0.22);
  box-shadow: 0 0 20px var(--green-glow);
  border-color: var(--green);
}
.ai-btn:active { transform: scale(0.94); }

/* Hint sotto la search row */
/* ════ QUOTA AI BADGE ════ */
.ai-quota-badge {
  display: inline-block;
  font-size: 11.5px;
  color: var(--accent);
  background: rgba(0,200,150,0.08);
  border: 1px solid rgba(0,200,150,0.22);
  border-radius: 20px;
  padding: 3px 10px;
  margin: 8px 0 2px 0;
  letter-spacing: 0.02em;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.ai-quota-badge:empty { display: none; }
.ai-quota-badge.quota-empty {
  color: #ff6b6b;
  background: rgba(220,50,50,0.10);
  border-color: rgba(220,50,50,0.35);
  font-weight: 600;
}
/* Messaggio quota esaurita (legacy) */
.result-card.quota-msg {
  border-color: rgba(244,164,41,0.30);
  background: rgba(244,164,41,0.06);
}
.result-card.quota-msg p { color: #e8b76a; }
.result-card.quota-msg small { opacity: 0.65; font-size: 11px; }

/* ════ QUOTA ESAURITA — card rossa ════ */
.result-card.quota-error-card {
  border: 1.5px solid rgba(220,50,50,0.45);
  background: rgba(180,20,20,0.12);
  border-radius: 14px;
  padding: 14px 16px 12px;
  margin-bottom: 12px;
}
.result-card.quota-error-card p {
  color: #ff8585;
  margin: 0;
  line-height: 1.6;
}
.result-card.quota-error-card strong { color: #ff5555; }
.result-card.quota-error-card small { opacity: 0.70; font-size: 11.5px; }
.quota-reset-line {
  display: inline-block;
  margin-top: 4px;
  color: #ffb347;
  font-size: 13px;
}
.quota-reset-line strong { color: #ffe066; }

/* ════ MODALE DETTAGLIO COMANDO ════ */
.cmd-detail-body {
  padding: 20px 18px 28px;
  overflow-y: auto;
}
.cmd-detail-how {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}
.cmd-detail-step {
  background: var(--blue);
  color: #fff;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
}
.cmd-detail-wake {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 14px 0 0;
  gap: 4px;
}
.cmd-detail-wake-word {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.cmd-detail-wake small { color: var(--muted-2); font-size: 12px; }
.cmd-detail-phrase-box {
  background: rgba(255,255,255,0.04);
  border: 1.5px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 10px;
  line-height: 1.4;
  word-break: break-word;
}
.cmd-detail-area {
  margin-bottom: 18px;
  min-height: 20px;
}
.cmd-detail-btns {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.cmd-detail-fav-btn,
.cmd-detail-copy-btn {
  flex: 1;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 10px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  border: 1.5px solid;
}
.cmd-detail-fav-btn {
  background: rgba(255,215,0,0.09);
  border-color: rgba(255,215,0,0.28);
  color: #c8a800;
}
.cmd-detail-fav-btn.active {
  background: rgba(255,215,0,0.18);
  border-color: rgba(255,215,0,0.55);
  color: var(--yellow);
}
.cmd-detail-fav-btn:hover { background: rgba(255,215,0,0.18); }
.cmd-detail-copy-btn {
  background: rgba(74,144,226,0.12);
  border-color: rgba(74,144,226,0.30);
  color: var(--blue);
}
.cmd-detail-copy-btn:hover { background: rgba(74,144,226,0.22); }

/* cmd-card clickable feedback */
.cmd-card { cursor: pointer; }
.cmd-card:hover { background: rgba(255,255,255,0.05); }

/* ════ TASTO SALVA E ESCI (topbar) ════ */
.save-exit-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px 6px 9px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.save-exit-btn:hover,
.save-exit-btn:active {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
  color: var(--text);
}
.save-exit-icon { font-size: 14px; line-height: 1; }
/* Su schermi stretti mostra solo l'icona */
@media (max-width: 380px) {
  .save-exit-label { display: none; }
  .save-exit-btn { padding: 6px 8px; }
}

/* ════ MODALE CONFERMA USCITA (Android back) ════ */
.exit-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.exit-box {
  background: var(--card-bg);
  border: 1.5px solid var(--panel-border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.exit-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.exit-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 24px;
}
.exit-btns {
  display: flex;
  gap: 12px;
}
.exit-btn {
  flex: 1;
  padding: 13px 10px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.exit-btn:active { opacity: 0.75; }
.exit-btn-no {
  background: rgba(74,144,226,0.18);
  color: #6eb5ff;
  border: 1.5px solid rgba(74,144,226,0.35);
}
.exit-btn-yes {
  background: rgba(220,50,50,0.20);
  color: #ff7070;
  border: 1.5px solid rgba(220,50,50,0.40);
}
/* Badge "✓ Tutto salvato" nel modale uscita */
.exit-saved-badge {
  display: none;
  background: rgba(0,180,100,0.15);
  border: 1px solid rgba(0,200,120,0.35);
  color: #4ddb97;
  font-size: 13px;
  font-weight: 700;
  border-radius: 20px;
  padding: 5px 14px;
  margin: 0 auto 16px;
  width: fit-content;
  letter-spacing: 0.02em;
}

.ai-hint {
  font-size: 11.5px;
  color: var(--muted-2);
  margin: 6px 0 0 2px;
  letter-spacing: 0.01em;
}

/* Badge AI sulle card risposta */
.ai-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-result {
  border-color: rgba(34,212,136,0.2);
  box-shadow:
    0 0 0 1px rgba(34,212,136,0.08) inset,
    0 12px 32px rgba(0,0,0,0.30);
}
.ai-loading { opacity: 0.8; }

/* Toggle locale risultati */
.ai-local-toggle {
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  margin-top: 10px;
  display: inline-block;
  padding: 4px 0;
  transition: color var(--transition);
}
.ai-local-toggle:hover { color: var(--text); }

/* Card comandi AI raggruppate */
.ai-cmd-cards {
  margin-top: 4px;
  border-left: 2px solid var(--green-dark);
  padding-left: 10px;
}

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(59,111,245,0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(59,111,245,0); }
}

/* ════ CHIP DOMANDE FREQUENTI ════ */
.chip-section { margin: 14px 0 4px; }
.chip-label { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.freq-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.freq-chip {
  background: rgba(59,111,245,0.10);
  border: 1px solid rgba(59,111,245,0.25);
  color: #a8bcff;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.freq-chip:hover {
  background: rgba(59,111,245,0.22);
  border-color: var(--blue);
  color: #fff;
}

/* Cronologia ricerche */
.history-box { margin: 12px 0 0; }
.history-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.history-items { display: flex; flex-wrap: wrap; gap: 6px; }
.history-item {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.history-item:hover { color: var(--text); border-color: var(--panel-border-h); }
.history-item::before { content: '↺ '; font-size: 11px; }

/* Query chip mostrata dopo la ricerca */
.query-chip {
  display: inline-block;
  background: linear-gradient(90deg, var(--blue), #5b8fff);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 999px;
  margin: 16px 0 6px;
  box-shadow: 0 4px 14px rgba(59,111,245,0.35);
}
.chip-row { text-align: right; }

/* ════ RESULT / ANSWER CARD ════ */
.result-card {
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 12px;
}
.result-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}
.result-card mark {
  background: var(--blue-soft);
  color: #c0d0ff;
  padding: 0 2px;
  border-radius: 3px;
}

.sources-toggle {
  font-size: 12.5px;
  color: var(--blue);
  cursor: pointer;
  margin-top: 10px;
  display: inline-block;
  opacity: 0.8;
  transition: opacity var(--transition);
}
.sources-toggle:hover { opacity: 1; }
.source-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.source-item .page-tag {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
/* Riga pagina + tasto "Leggi pagina" */
.source-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.source-item-head .page-tag { margin-bottom: 0; }
.source-snippet {
  line-height: 1.55;
  margin: 0;
  font-size: 13px;
}
/* Pulsante "Leggi pagina N" sui risultati */
.open-page-btn {
  background: rgba(74,144,226,0.12);
  border: 1px solid rgba(74,144,226,0.30);
  color: var(--blue);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.open-page-btn:hover { background: rgba(74,144,226,0.22); }

/* ════ EVIDENZIAZIONE PAROLA CERCATA ════ */
mark.hl {
  background: rgba(255, 210, 50, 0.28);
  color: #ffe066;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
  font-style: normal;
}

/* ════ MODALE PAGINA MANUALE ════ */
.page-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.70);
  z-index: 9000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.page-modal-box {
  background: var(--panel-bg, #1a1f2e);
  border: 1px solid var(--panel-border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  background: var(--panel-bg, #1a1f2e);
}
.page-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.page-modal-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-modal-close:hover { background: rgba(255,255,255,0.15); }
.page-modal-body {
  padding: 16px 18px 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.70;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.7;
}
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════ COMANDI VOCALI ════ */
.section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px;
}
.section-lead {
  font-size: 12.5px;
  color: var(--muted);
  margin: 14px 0 10px;
}

.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.cat-card {
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.cat-card:hover { border-color: var(--panel-border-h); transform: translateY(-1px); }
.cat-card:active { transform: scale(0.97); }
.cat-card .cat-icon { font-size: 20px; margin-bottom: 8px; }
.cat-card h4 { margin: 0 0 3px; font-size: 14px; font-weight: 700; }
.cat-card > span { color: var(--muted); font-size: 12px; }

.show-all-btn {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--panel-border);
  color: var(--muted);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 14px;
  transition: border-color var(--transition), color var(--transition);
}
.show-all-btn:hover { border-color: var(--blue); color: var(--text); }

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--text); }
.breadcrumb .current { color: var(--text); font-weight: 700; }

.cat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 4px;
}
.cat-header-row .cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.cat-header-row .chiudi {
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
}

/* Comando card */
.cmd-card {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
  position: relative;
  transition: border-color var(--transition);
}
.cmd-card:hover { border-color: var(--panel-border-h); }
.cmd-card .cmd-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; display: block; }
.cmd-card .cmd-phrase { color: var(--green); font-weight: 700; font-size: 14.5px; }
.cmd-card .cat-tag { color: var(--muted); font-size: 11.5px; margin-top: 6px; display: block; }

/* Azioni su ogni comando: copia + preferiti — SEMPRE visibili */
.cmd-actions {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  gap: 4px;
  opacity: 1;
}
.cmd-action-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.45);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.cmd-action-btn:hover { border-color: var(--panel-border-h); color: var(--text); }
.cmd-action-btn.fav-btn { color: var(--muted); }
.cmd-action-btn.fav-btn.active { color: var(--yellow); border-color: rgba(255,215,0,0.5); background: rgba(255,215,0,0.10); }
.cmd-action-btn.copied { color: var(--green); border-color: var(--green); }

/* ════ PREFERITI ════ */

/* ════ SPECIFICHE SHS ════ */
.shs-header {
  text-align: center;
  padding: 16px 10px 20px;
}
.shs-badge-big {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  border: 1px solid var(--green-dark);
  background: var(--green-soft);
  padding: 6px 18px;
  border-radius: 999px;
  margin-bottom: 12px;
  box-shadow: 0 0 20px var(--green-glow);
}
.shs-header h2 { margin: 0 0 4px; font-size: 26px; font-weight: 900; }
.shs-tagline { margin: 0; color: var(--muted); font-size: 14px; }

.spec-group { margin-bottom: 24px; }
.spec-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.spec-card {
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spec-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.spec-val   { font-size: 15px; font-weight: 700; color: var(--text); }

.mode-list { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.mode-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.mode-body h4 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.mode-body p  { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ════ GUIDE RAPIDE ════ */
.guide-list { display: flex; flex-direction: column; gap: 12px; }
.guide-card {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.guide-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}
.guide-icon { font-size: 22px; flex-shrink: 0; }
.guide-card-head > div { flex: 1; }
.guide-card-head h4 { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.guide-teaser { margin: 0; font-size: 12.5px; color: var(--muted); }
.guide-chev {
  font-size: 20px;
  color: var(--muted-2);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.guide-card.open .guide-chev { transform: rotate(90deg); color: var(--blue); }
.guide-body {
  display: none;
  padding: 0 16px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
  border-top: 1px solid var(--panel-border);
}
.guide-card.open .guide-body { display: block; }
.guide-body p { margin: 10px 0 0; }
.guide-body p:first-child { margin-top: 0; }
.guide-body ul { margin: 8px 0 0; padding-left: 18px; }
.guide-body li { margin-bottom: 6px; }
.guide-body strong { color: var(--text); }
.guide-body em { font-style: normal; color: var(--text); }

/* ════ DRIVER SMART ════ */
.ds-hero { text-align: center; padding: 10px 10px 4px; }
.ds-gear {
  width: 72px; height: 72px;
  filter: drop-shadow(0 0 18px var(--blue-glow));
  margin-bottom: 10px;
}
.ds-hero h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.ds-tagline { margin: 0; color: var(--muted); font-size: 14px; }

.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
}
.section-divider span {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue-dark), transparent);
}
.section-divider em {
  font-style: normal;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,111,245,0.2), rgba(59,111,245,0.04));
  border: 1px solid var(--blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 16px rgba(59,111,245,0.3);
}

.glass-card {
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.glass-card h4 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.glass-card p  { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }

.ds-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.ds-compare-col {
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--panel-border);
}
.ds-compare-col.ds-compare-highlight {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.ds-compare-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
}
.ds-compare-highlight .ds-compare-label { color: var(--blue); }
.ds-compare-row {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 6px 0;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.ds-compare-row:first-of-type { border-top: none; }

.ds-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.ds-feature {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 0;
}
.ds-feature-icon { font-size: 20px; display: block; margin-bottom: 8px; }
.ds-feature h5   { margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.ds-feature p    { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* ════ NOTICE ════ */
.notice {
  background: rgba(59,111,245,0.08);
  border: 1px solid rgba(59,111,245,0.2);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 16px;
  line-height: 1.6;
}
.notice.tight { margin-top: 0; margin-bottom: 16px; }

/* ════ FOOTER ════ */
footer.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted-2);
  padding: 14px 14px 18px;
  border-top: 1px solid var(--panel-border);
  letter-spacing: 0.02em;
  line-height: 1.8;
}
.footer-credits {
  font-size: 10.5px;
  color: rgba(120,135,160,0.7);
  letter-spacing: 0.01em;
}

/* ════ TOAST ════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(30,36,50,0.95);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  z-index: 999;
  backdrop-filter: blur(16px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ════ NOTE PERSONALI — struttura a sezioni ════ */
.note-intro {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0 18px;
}
.note-intro-icon { font-size: 30px; flex-shrink: 0; }
.note-title      { margin: 0 0 3px; font-size: 20px; font-weight: 800; }
.note-subtitle   { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Card sezione */
.ncard {
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
}
.ncard-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
}
.ncard-icon  { font-size: 18px; flex-shrink: 0; }
.ncard-title { margin: 0; font-size: 14px; font-weight: 700; flex: 1; }
.ncard-saved {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity 0.4s;
}
.ncard-saved.visible { opacity: 1; }

/* Body dei campi */
.ncard-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }

/* Etichetta di gruppo dentro una card */
.nfield-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 4px 0 0;
}
.nfield-group-label:first-child { margin-top: 0; }

/* Riga singolo campo */
.nfield-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}
/* Riga a 2 colonne */
.nfield-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.nfield-row-2 > div { display: flex; flex-direction: column; gap: 4px; }

.nfield-label {
  font-size: 12.5px;
  color: var(--muted);
  flex-shrink: 0;
  width: 160px;
  line-height: 1.3;
}
.nfield-row-2 .nfield-label { width: auto; }

.nfield-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.nfield-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(59,111,245,0.15);
}
.nfield-input::placeholder { color: var(--muted-2); }
.nfield-input[readonly], .nfield-readonly {
  opacity: 0.55;
  cursor: default;
  border-color: rgba(255,255,255,0.04);
}
.nfield-input:not([readonly]):not(:placeholder-shown) {
  border-color: rgba(34,212,136,0.3);
}

/* Textarea campi liberi */
.nfield-textarea {
  width: 100%;
  min-height: 100px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
.nfield-textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,111,245,0.12); }
.nfield-textarea::placeholder { color: var(--muted-2); }

/* Divisore leggero tra sottogruppi */
.nfield-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 4px 0;
}

/* ════ RESPONSIVE ════ */
@media (max-width: 400px) {
  .spec-grid, .ds-compare, .ds-feature-grid, .cat-grid {
    grid-template-columns: 1fr;
  }
  .tile { padding: 14px; }
  .note-actions { flex-direction: column; align-items: stretch; }
  .note-char-count { text-align: center; }
}
