/* ==========================================================================
   AG Meteo — components.css
   1. Layout pagina meteo
   2. (spostato in weather.css: card meteo, ricerca città, ora per ora)
   3. AG Assistant (chat)
   4. Form, campi, dialog di accesso
   5. Cookie banner, impostazioni e lingua
   6. Sezioni sotto la piega: FAQ e contatti
   ========================================================================== */

/* ---------- 1. LAYOUT HOME ---------- */
.app {
  padding-block: var(--s-5) var(--s-6);
}
@media (min-width: 64rem) {
  .app { padding-block: var(--s-6) var(--s-7); }
}

.forecast { display: grid; gap: var(--s-4); align-content: start; }
.forecast__head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
}
.forecast__head .h1 { margin-block: var(--s-1); }
.h1__sub { display: block; margin-top: 0.15em; font-size: 0.56em; font-weight: 600; letter-spacing: 0; color: var(--text-muted); }

/* Smartphone: titolo e ricerca città su due righe, spazi più stretti */
@media (max-width: 35.99rem) {
  .app { gap: var(--s-4); padding-block: var(--s-4) var(--s-5); }
  .forecast { gap: var(--s-3); }
  .forecast__head { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .forecast__head .eyebrow { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Card base */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- 3. AG ASSISTANT ---------- */
.assistant {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
/* Desktop: pannello FISSO a destra. Minimizzabile: scivola fuori dal bordo e resta solo la linguetta. */
@media (min-width: 64rem) {
  .assistant {
    position: fixed;
    z-index: 45;
    top: var(--s-3);
    right: var(--s-4);
    bottom: var(--s-3);
    width: var(--chat-w);
    transition: transform 0.4s var(--ease), opacity 0.3s var(--ease), visibility 0s;
  }
  .assistant[data-state='collapsed'] {
    transform: translateX(calc(100% + var(--s-5)));
    opacity: 0;
    visibility: hidden;
    transition: transform 0.4s var(--ease), opacity 0.3s var(--ease), visibility 0s linear 0.4s;
  }
  .assistant__close { display: none; }
  /* La pagina cede la colonna destra alla chat quando è aperta */
  body[data-chat='open'] .page { margin-right: calc(var(--chat-w) + var(--s-5)); }
}
@media (max-width: 63.99rem) {
  .assistant__collapse, .assistant-handle { display: none !important; }
}

/* Linguetta verticale sul bordo destro (chat minimizzata) */
.assistant-handle {
  position: fixed;
  z-index: 44;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 0.55rem;
  border: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  animation: handle-in 0.4s var(--ease);
  transition: padding var(--dur) var(--ease), background-color var(--dur-fast);
}
.assistant-handle:hover { padding-right: 0.95rem; background: var(--primary-hover); }
.assistant-handle__text { writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--fs-sm); letter-spacing: 0.04em; }
@keyframes handle-in { from { transform: translate(100%, -50%); } }
/* Mobile / tablet: bottom sheet */
@media (max-width: 63.99rem) {
  .assistant {
    position: fixed;
    z-index: 60;
    inset: auto 0 0 0;
    width: min(100%, 40rem);
    margin-inline: auto;
    height: min(88dvh, 44rem);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.38s var(--ease), visibility 0s linear 0.38s;
  }
  .assistant[data-state='open'] { transform: none; visibility: visible; transition: transform 0.38s var(--ease); }
}
body.has-sheet { overflow: hidden; }
.scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim); animation: fade 0.25s var(--ease); }

.fab {
  position: fixed;
  z-index: 50;
  right: max(var(--s-4), env(safe-area-inset-right));
  bottom: max(var(--s-4), env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 3.5rem;
  padding: 0 1.35rem 0 1.1rem;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur-fast);
  animation: rise 0.6s 0.4s var(--ease) both;
}
.fab:hover { background: var(--primary-hover); transform: translateY(-2px); }
.fab:active { transform: scale(0.96); }

.assistant__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.assistant__avatar {
  display: grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
}
.assistant__titles { flex: 1; min-width: 0; }
.assistant__titles h2 { font-size: var(--fs-md); font-weight: 720; letter-spacing: -0.01em; }
.assistant__status { font-size: var(--fs-xs); color: var(--text-muted); }

.chat__log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.msg { display: flex; max-width: 90%; animation: msg-in 0.35s var(--ease) both; }
.msg__bubble {
  padding: 0.65rem 0.95rem;
  border-radius: 1.1rem 1.1rem 1.1rem 0.3rem;
  background: var(--surface-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--user { align-self: flex-end; }
.msg--user .msg__bubble { border-radius: 1.1rem 1.1rem 0.3rem 1.1rem; background: var(--primary); color: var(--on-primary); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.msg--typing .msg__bubble { display: inline-flex; gap: 0.3rem; align-items: center; padding-block: 0.95rem; }
.msg--typing i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--text-muted); animation: bounce 1s infinite ease-in-out; }
.msg--typing i:nth-child(2) { animation-delay: 0.15s; }
.msg--typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0 var(--s-4) var(--s-3); }
.chip {
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--input-border);
  border-radius: var(--r-pill);
  background: transparent;
  font-size: var(--fs-xs);
  font-weight: 650;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast) var(--ease);
}
.chip:hover:not(:disabled) { background: var(--info-bg); border-color: var(--primary); color: var(--primary); }
.chip:active:not(:disabled) { transform: scale(0.96); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

.quota-banner {
  display: grid;
  gap: var(--s-3);
  justify-items: start;
  margin: 0 var(--s-4) var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: var(--fs-sm);
}
.quota-banner strong { font-weight: 720; }

.chat__form { display: flex; align-items: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-4) var(--s-2); border-top: 1px solid var(--border); }
.chat__field { position: relative; flex: 1; }
.chat__form textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  max-height: 7.5rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--input-border);
  border-radius: var(--r-md);
  background: var(--input-bg);
  resize: none;
  line-height: 1.4;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.chat__form textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.chat__count { position: absolute; right: 0.6rem; bottom: 0.2rem; font-size: 0.7rem; color: var(--text-muted); pointer-events: none; }
.chat__meta { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4) var(--s-3); font-size: 0.75rem; color: var(--text-muted); }

.pill {
  flex: none;
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  background: var(--info-bg);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 720;
  white-space: nowrap;
  transition: background-color var(--dur), color var(--dur);
}
.pill[data-level='low'] { background: var(--warning-bg); color: var(--warning); }
.pill[data-level='empty'] { background: var(--danger-bg); color: var(--danger); }

/* ---------- 4. FORM, CAMPI, DIALOG ---------- */
.field { display: grid; gap: 0.35rem; }
.field > label, .field__row label, .field__label { font-size: var(--fs-sm); font-weight: 650; }
.field input:not([type='checkbox']), .field select, .field textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--input-border);
  border-radius: var(--r-md);
  background: var(--input-bg);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field textarea { min-height: 7.5rem; resize: vertical; line-height: 1.5; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .chat__form textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}
[aria-invalid='true'] { border-color: var(--danger) !important; }
.field__error { display: flex; gap: 0.4rem; font-size: var(--fs-xs); font-weight: 650; color: var(--danger); }
.field__error::before { content: '⚠'; }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__row { display: flex; justify-content: space-between; gap: var(--s-3); }

.password { position: relative; }
.password input { padding-right: 3rem !important; }
.password button { position: absolute; top: 50%; right: 0.2rem; transform: translateY(-50%); width: 2.5rem; min-height: 2.5rem; }

.check { display: flex; align-items: flex-start; gap: 0.65rem; font-size: var(--fs-sm); }
.check input { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.12rem; accent-color: var(--primary); }
.form { display: grid; gap: var(--s-4); }
.form-status {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.form-status[data-tone='error'] { background: var(--danger-bg); color: var(--danger); }
.form-status[data-tone='success'] { background: var(--success-bg); color: var(--success); }
.form-status[data-tone='info'] { background: var(--info-bg); color: var(--text); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; } /* honeypot anti-spam */

/* Dialog nativo */
.dialog {
  width: min(100% - 1.5rem, 26.5rem);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(5px); animation: fade 0.25s var(--ease); }
.dialog__panel {
  position: relative;
  display: grid;
  gap: var(--s-4);
  max-height: calc(100dvh - 1.5rem);
  overflow-y: auto;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.dialog[open] .dialog__panel { animation: pop 0.32s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.dialog__close { position: absolute; top: var(--s-2); right: var(--s-2); }
.dialog__head { padding-right: 2.5rem; }
.dialog__head p { margin-top: var(--s-1); font-size: var(--fs-sm); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; padding: 0.25rem; border-radius: var(--r-md); background: var(--surface-2); }
.tab {
  min-height: 2.5rem;
  border: 0;
  border-radius: calc(var(--r-md) - 0.2rem);
  background: transparent;
  font-weight: 650;
  color: var(--text-muted);
  transition: background-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.oauth { display: grid; gap: var(--s-2); }
.divider { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-xs); font-weight: 650; color: var(--text-muted); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.tabpanel { display: grid; gap: var(--s-4); }

/* ---------- 5. COOKIE BANNER — pannello in basso a sinistra (desktop), cassetto dal basso (telefono) ---------- */
.cookie {
  position: fixed;
  z-index: 90;
  left: var(--s-4);
  bottom: max(var(--s-4), env(safe-area-inset-bottom));
  width: min(27.5rem, calc(100vw - 2 * var(--s-4)));
  max-height: calc(100dvh - 2 * var(--s-4));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition: opacity 0.35s var(--ease), transform 0.4s var(--ease);
}
.cookie.is-visible { opacity: 1; transform: none; }
.cookie__inner { display: grid; gap: var(--s-4); padding: var(--s-5); }
.cookie__title { font-size: var(--fs-lg); font-weight: 720; margin-bottom: var(--s-1); }
.cookie__text p { font-size: var(--fs-sm); color: var(--text-muted); }
.cookie__text p a { color: var(--primary); font-weight: 650; }
.cookie__reason { margin-top: var(--s-3); padding: 0.6rem 0.75rem; border-radius: var(--r-sm); background: var(--info-bg); font-weight: 600; }
.cookie__reason:not([hidden]) { color: var(--text) !important; }
.cookie__details { display: grid; gap: var(--s-2); margin: 0; padding: 0; border: 0; min-width: 0; animation: fade 0.3s var(--ease); }
.cookie__cat { padding: 0.75rem 0.85rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.cookie__always { margin-left: 0.4rem; font-size: 0.7rem; font-style: normal; font-weight: 700; color: var(--primary); }
.cookie__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.cookie__actions .btn { min-height: 2.75rem; padding-inline: 0.8rem; justify-content: center; }
.cookie__actions [data-cookie-customize], .cookie__actions [data-cookie-save] { grid-column: 1 / -1; }
.cookie__actions[hidden], .cookie__actions [hidden] { display: none; }
.cookie__actions[data-when='ask'] { display: none; }
.cookie[data-mode='ask'] .cookie__actions[data-when='ask'] { display: grid; }
.cookie[data-mode='ask'] .cookie__actions[data-when='choose'] { display: none; }
@media (max-width: 36rem) {
  .cookie {
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 88dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border-width: 1px 0 0;
    border-radius: 1.4rem 1.4rem 0 0;
    transform: translateY(100%);
  }
  .cookie::before { content: ''; display: block; width: 2.5rem; height: 0.3rem; margin: 0.6rem auto 0; border-radius: var(--r-pill); background: var(--border); }
  .cookie__inner { padding: var(--s-4) var(--s-4) var(--s-5); }
}
@media (prefers-reduced-motion: reduce) { .cookie { transition: opacity 0.2s; transform: none; } }

.switch { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1.5rem; height: 1.5rem; }
.switch__ui {
  position: relative;
  flex: none;
  width: 2.75rem; height: 1.6rem;
  border-radius: var(--r-pill);
  background: var(--input-border);
  transition: background-color var(--dur) var(--ease);
}
.switch__ui::after {
  content: '';
  position: absolute;
  top: 0.2rem; left: 0.2rem;
  width: 1.2rem; height: 1.2rem;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__ui { background: var(--primary); }
[data-theme='dark'] .switch input:checked + .switch__ui::after { background: var(--on-primary); }
.switch input:checked + .switch__ui::after { transform: translateX(1.15rem); }
.switch input:disabled + .switch__ui { opacity: 0.6; }
.switch input:focus-visible + .switch__ui { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch__text { display: grid; font-size: var(--fs-sm); }
.switch__text small { color: var(--text-muted); font-size: var(--fs-xs); }

/* ---------- 6. SEZIONI SOTTO LA PIEGA ---------- */
/* content-visibility: il browser salta il rendering finché la sezione non è vicina al viewport. */
.section { padding-block: var(--s-7); content-visibility: auto; contain-intrinsic-size: auto 36rem; }
.section__head { max-width: 40rem; margin-bottom: var(--s-6); }
.section__head .h2 { margin-block: var(--s-2); }
.section--alt { background: var(--surface); border-block: 1px solid var(--border); }

.faq { display: grid; gap: var(--s-3); max-width: 50rem; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.section--alt .faq details { background: var(--bg); }
.faq details:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.faq details[open] { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 3.25rem;
  padding: var(--s-3) var(--s-5);
  font-weight: 680;
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary .icon { color: var(--primary); transition: transform var(--dur) var(--ease); }
.faq details[open] summary .icon { transform: rotate(180deg); }
.faq__body { padding: 0 var(--s-5) var(--s-4); color: var(--text-muted); animation: fade 0.3s var(--ease); }
.faq__body a { font-weight: 600; }

.contact { display: grid; gap: var(--s-6); }
@media (min-width: 56rem) { .contact { grid-template-columns: 1fr 1.25fr; align-items: start; } }
.contact__form { padding: var(--s-5); display: grid; gap: var(--s-4); }
.points { display: grid; gap: var(--s-3); margin-top: var(--s-5); list-style: none; }
.points li { display: flex; gap: var(--s-3); align-items: flex-start; }
.points .icon { margin-top: 0.15rem; color: var(--primary); }

/* "Perché AG Meteo è diverso" */
.section__head--center { margin-inline: auto; text-align: center; }
.features { display: grid; grid-template-columns: 1fr; gap: var(--s-4); list-style: none; }
@media (min-width: 40rem) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62rem) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature {
  position: relative;
  display: grid;
  align-content: start;
  gap: var(--s-3);
  padding: var(--s-5);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
@media (hover: hover) {
  .feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
  .feature:hover .feature__icon { background: var(--primary); color: var(--on-primary); }
}
.feature__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.9rem;
  background: var(--info-bg);
  color: var(--primary);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.feature__icon .icon { width: 1.5rem; height: 1.5rem; }
.feature h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--fs-lg); font-weight: 720; }
.feature p { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; }
.badge {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  padding: 0.12rem 0.6rem;
  border-radius: var(--r-pill);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Chip usabili anche come link (città più cercate) */
.chip { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.chip:hover { color: var(--primary); }

/* Skeleton e stati (condivisi da meteo, notizie, ...) */
.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.state-card { display: grid; gap: var(--s-3); justify-items: start; padding: var(--s-5); }

/* Selettore lingua nelle impostazioni */
.langs { display: grid; gap: var(--s-3); border: 0; }
.langs legend { padding: 0; margin-bottom: var(--s-1); font-weight: 720; }
.langs__grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
/* Con 14 lingue restano due colonne anche su telefono: schede più compatte, il nome può andare a capo */
@media (max-width: 30rem) {
  .langs__grid .lang__ui { gap: 0.5rem; padding: 0.55rem 0.6rem; height: 100%; }
  .langs__grid .lang__code { display: none; } /* il nome basta: il codice a due lettere toglierebbe solo spazio */
  .langs__grid .lang__name { min-width: 0; font-size: var(--fs-sm); line-height: 1.2; overflow-wrap: anywhere; }
  .langs__grid .lang__check { width: 1rem; }
}
.lang { position: relative; cursor: pointer; }
.lang input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lang__ui {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--input-border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background-color var(--dur-fast);
}
.lang:hover .lang__ui { border-color: var(--text); }
.lang__code { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: 0.6rem; background: var(--info-bg); color: var(--primary); font-size: 0.8rem; font-weight: 800; }
.lang__name { flex: 1; font-weight: 650; }
.lang__check { color: var(--primary); opacity: 0; transition: opacity var(--dur-fast); }
.lang input:checked + .lang__ui { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); box-shadow: 0 0 0 1px var(--primary); }
.lang input:checked + .lang__ui .lang__check { opacity: 1; }
.lang input:focus-visible + .lang__ui { outline: 3px solid var(--focus); outline-offset: 2px; }

.auth__note { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; }

/* Ricerca città (combobox): usata da landing e pagina meteo */
.citysearch { position: relative; width: min(100%, 20rem); }
.citysearch__box { position: relative; display: flex; align-items: center; }
.citysearch__box > [data-icon] { position: absolute; left: 0.85rem; display: inline-flex; color: var(--text-muted); pointer-events: none; }
.citysearch input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 3rem 0.55rem 2.6rem; /* a destra spazio per il pulsante GPS */
  border: 1px solid var(--input-border);
  border-radius: var(--r-md);
  background: var(--input-bg);
  font-weight: 650;
  text-overflow: ellipsis;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.citysearch input::placeholder { color: var(--text-muted); font-weight: 500; opacity: 1; }
.citysearch input:hover { border-color: var(--text); }
.citysearch input:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}
.citysearch__list {
  position: absolute;
  z-index: 80; /* sopra qualunque scheda successiva */
  inset: calc(100% + 0.35rem) 0 auto 0;
  max-height: min(19rem, 55dvh);
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
  list-style: none;
  background: var(--surface); /* opaco */
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s var(--ease);
}
.citysearch__opt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 2.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm);
  font-weight: 650;
  cursor: pointer;
}
.citysearch__opt .opt__rest { color: var(--text-muted); font-weight: 500; }
.citysearch__opt[aria-selected='true'] { background: var(--info-bg); box-shadow: inset 3px 0 0 var(--primary); }
.citysearch__group { padding: 0.4rem 0.75rem 0.25rem; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.citysearch__empty { padding: var(--s-4) 0.75rem; color: var(--text-muted); font-size: var(--fs-sm); }


/* Pulsante GPS dentro la barra di ricerca */
.citysearch__geo {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  transform: translateY(-50%);
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: 0.75rem;
  transition: background-color var(--dur-fast), transform var(--dur-fast) var(--ease);
}
.citysearch__geo:hover { background: var(--info-bg); }
.citysearch__geo:active { transform: translateY(-50%) scale(0.92); }
.citysearch__geo[aria-busy='true'] .icon { animation: gps-pulse 1s ease-in-out infinite; }
@keyframes gps-pulse { 50% { transform: scale(1.25); opacity: 0.55; } }
.citysearch__empty.is-loading { color: var(--text-muted); }
.citysearch__empty.is-error { color: var(--danger); font-weight: 600; }
.spinner--sm { display: inline-block; width: 1rem; height: 1rem; margin-right: 0.5rem; vertical-align: -0.2em; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.opt__text { overflow-wrap: anywhere; }

/* Menu a tendina della lingua (solo desktop) */
.langmenu { position: relative; }
.langbtn { gap: 0.4rem; padding-inline: 0.7rem; }
.langbtn__code { font-size: 0.85rem; font-weight: 750; letter-spacing: 0.02em; }
.langbtn__chev .icon { width: 1em; height: 1em; transition: transform var(--dur) var(--ease); }
.langbtn[aria-expanded='true'] .langbtn__chev .icon { transform: rotate(180deg); }
.langmenu__list { position: absolute; z-index: 70; top: calc(100% + 0.4rem); right: 0; min-width: 12.5rem; margin: 0; padding: 0.35rem; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); animation: pop 0.18s var(--ease); }
.langmenu__list button { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 2.5rem; padding: 0.45rem 0.65rem; background: none; border: 0; border-radius: 0.6rem; text-align: left; font-weight: 600; transition: background-color var(--dur-fast); }
.langmenu__list button:hover { background: var(--surface-2); }
.langmenu__list button[aria-checked='true'] { background: var(--info-bg); }
.langmenu__list .lang__check { margin-left: auto; opacity: 0; }
.langmenu__list button[aria-checked='true'] .lang__check { opacity: 1; }

/* Menu Impostazioni: gruppi a scelta singola (tema, unità) */
.dialog--settings { width: min(100% - 1.5rem, 30rem); }
.dialog__panel--settings { gap: var(--s-5); }
.settings__units { display: grid; gap: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--border); }
@media (min-width: 48rem) { .settings__units { padding-top: 0; border-top: 0; } } /* lingua e tema non ci sono: niente separatore in testa */
.settings__title { font-size: var(--fs-md); font-weight: 720; }
.seg { display: grid; gap: 0.4rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.seg legend { padding: 0; margin-bottom: 0.15rem; font-size: var(--fs-sm); font-weight: 720; }
.seg__row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.seg__opt { position: relative; flex: 1 1 7rem; }
.seg__opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg__ui { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.1rem 0.5rem; min-height: 2.75rem; padding: 0.45rem 0.75rem; text-align: center; font-weight: 650; background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--r-md); transition: border-color var(--dur-fast), background-color var(--dur-fast), box-shadow var(--dur-fast); }
.seg__ui small { width: 100%; font-size: 0.7rem; font-weight: 500; color: var(--text-muted); }
.seg__ui .icon { width: 1.1em; height: 1.1em; }
.seg__opt:hover .seg__ui { border-color: var(--text); }
.seg__opt input:checked + .seg__ui { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); box-shadow: 0 0 0 1px var(--primary); }
.seg__opt input:focus-visible + .seg__ui { outline: 3px solid var(--focus); outline-offset: 2px; }


/* ==========================================================================
   Glossario: termini tecnici con spiegazione (js/features/glossary.js)
   Desktop → scheda ancorata al termine · Touch/mobile → bottom sheet dal basso.
   ========================================================================== */
.term {
  position: relative;
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: help;
  text-decoration: underline dotted color-mix(in srgb, currentColor 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
}
.term::after { content: ''; position: absolute; inset: -0.55rem -0.35rem; } /* area di tocco comoda senza ingrandire il testo */
.term:hover, .term[aria-expanded='true'] { color: var(--primary); text-decoration-style: solid; }
.term__i {
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  margin-left: 0.3em;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--primary);
  font-size: 0.66em;
  font-weight: 800;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  vertical-align: 0.14em;
  text-decoration: none;
}

.gloss { position: fixed; z-index: 3000; }
.gloss[hidden], .gloss-scrim[hidden] { display: none; }
.gloss__card {
  display: grid;
  gap: 0.45rem;
  padding: 0.95rem 1.05rem 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.gloss__title { font-size: var(--fs-base); font-weight: 760; letter-spacing: -0.01em; }
.gloss__text { font-size: var(--fs-sm); line-height: 1.55; color: var(--text); }
.gloss__tip { padding: 0.5rem 0.65rem; border-radius: var(--r-sm); background: var(--info-bg); font-size: var(--fs-xs); line-height: 1.45; color: var(--text); }
.gloss__tip::before { content: '💡 '; }
.gloss__grab, .gloss__ok { display: none; }

.gloss[data-mode='popover'] { width: min(22.5rem, calc(100vw - 1rem)); animation: pop 0.14s var(--ease); }
.gloss[data-mode='popover'] .gloss__card { border-radius: var(--r-md); }

.gloss-scrim { position: fixed; inset: 0; z-index: 2999; background: rgb(3 10 18 / 0.5); animation: fade-in 0.2s var(--ease); }
.gloss[data-mode='sheet'] { inset: auto 0 0 0; animation: sheet-up 0.28s var(--ease); }
.gloss[data-mode='sheet'] .gloss__card {
  max-height: 72dvh;
  overflow-y: auto;
  padding: 0.7rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  border-width: 1px 0 0;
  border-radius: 1.5rem 1.5rem 0 0;
  gap: 0.7rem;
}
.gloss[data-mode='sheet'] .gloss__grab { display: block; width: 2.6rem; height: 0.3rem; margin: 0 auto 0.3rem; border-radius: var(--r-pill); background: var(--border-strong, var(--border)); }
.gloss[data-mode='sheet'] .gloss__title { font-size: var(--fs-lg); }
.gloss[data-mode='sheet'] .gloss__text { font-size: var(--fs-base); }
.gloss[data-mode='sheet'] .gloss__tip { font-size: var(--fs-sm); }
.gloss[data-mode='sheet'] .gloss__ok { display: inline-flex; justify-self: stretch; justify-content: center; min-height: 2.9rem; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .gloss, .gloss-scrim { animation: none !important; }
}


/* ==========================================================================
   Footer: slogan + social · Sezione Applicazioni · Tutorial iPhone
   ========================================================================== */
.footer__brand .footer__tagline { max-width: 22rem; margin-top: var(--s-3); font-size: var(--fs-base); font-weight: 760; letter-spacing: -0.01em; color: var(--text); }
.social { display: flex; gap: 0.6rem; margin-top: var(--s-4); list-style: none; }
.footer__brand .social__link { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast), transform var(--dur-fast) var(--ease); }
.footer__brand .social__link:hover { color: var(--on-primary); background: var(--primary); border-color: var(--primary); transform: translateY(-2px); }
.social__link .icon { width: 1.3rem; height: 1.3rem; }

/* ---------- Applicazioni ---------- */
.appgrid { display: grid; gap: var(--s-4); }
@media (min-width: 48rem) { .appgrid { grid-template-columns: 1fr 1fr; gap: var(--s-5); } }
.appcard { position: relative; display: grid; gap: 0.6rem; align-content: start; justify-items: start; padding: var(--s-6) var(--s-5); overflow: hidden; }
.appcard::before { content: ''; position: absolute; inset: 0; z-index: 0; opacity: 0.55; pointer-events: none; background: radial-gradient(circle at 100% 0%, var(--info-bg), transparent 62%); }
.appcard > * { position: relative; z-index: 1; }
.appcard__kicker { font-size: var(--fs-xs); font-weight: 780; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.appcard__icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: var(--info-bg); color: var(--primary); }
.appcard__icon .icon { width: 1.6rem; height: 1.6rem; }
.appcard__title { font-size: 1.3rem; font-weight: 780; letter-spacing: -0.02em; line-height: 1.2; }
.appcard__text { max-width: 30rem; color: var(--text-muted); }
.appcard .btn, .appcard .gplay { margin-top: var(--s-2); }

/* Badge "Disponibile su Google Play": realizzato in HTML/SVG per essere tradotto; sostituibile con la grafica ufficiale di Google */
.gplay { display: inline-flex; align-items: center; gap: 0.7rem; padding: 0.55rem 1.15rem 0.55rem 0.95rem; color: #fff; text-decoration: none; background: #000; border: 1px solid #a6a6a6; border-radius: 0.7rem; transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast); }
.gplay:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 8px 22px rgb(0 0 0 / 0.3); }
.gplay:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.gplay__logo { width: 2rem; height: 2rem; flex: none; }
.gplay__text { display: grid; line-height: 1.1; }
.gplay__text small { font-size: 0.66rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.9; }
.gplay__text strong { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Tutorial iPhone ---------- */
.dialog--ios { width: min(100% - 1rem, 46rem); }
.dialog__panel--ios { gap: var(--s-4); padding: var(--s-5); }
.iossteps { display: grid; gap: var(--s-3); list-style: none; counter-reset: none; }
.iosstep { display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'n text' 'fig fig'; gap: var(--s-2) var(--s-3); align-items: center; padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.iosstep--done { border-color: var(--success); }
.iosstep__n { grid-area: n; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; }
.iosstep--done .iosstep__n { background: var(--success); color: var(--bg); }
.iosstep__text { grid-area: text; }
.iosstep__text h3 { font-size: var(--fs-base); font-weight: 760; }
.iosstep__text p { margin-top: 0.15rem; font-size: var(--fs-sm); color: var(--text-muted); }
.iosstep__fig { grid-area: fig; display: grid; place-items: center; }
.iosfig { width: min(100%, 11rem); height: auto; filter: drop-shadow(0 10px 18px rgb(0 0 0 / 0.22)); }
.iosfig__pulse { transform-origin: center; transform-box: fill-box; animation: ios-pulse 1.8s var(--ease) infinite; }
@keyframes ios-pulse { 0% { transform: scale(0.85); opacity: 0.9; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .iosfig__pulse { animation: none; } }
.iosnote { padding: 0.7rem 0.9rem; border-radius: var(--r-md); background: var(--info-bg); font-size: var(--fs-sm); }
@media (min-width: 40rem) {
  .iossteps { grid-template-columns: 1fr 1fr; }
  .iosstep { grid-template-columns: auto 1fr; align-items: start; }
  .iosstep--done { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; grid-template-areas: 'n text fig'; align-items: center; }
  .iosstep--done .iosfig { width: 8rem; }
}


/* ==========================================================================
   Account: checklist della password · le tue città (home)
   ========================================================================== */
.tabs[hidden] { display: none; }

/* Checklist e barra di forza: ogni requisito diventa verde appena è soddisfatto */
.pwmeter { --pw: var(--danger); display: grid; gap: 0.5rem; margin-top: 0.55rem; padding: 0.7rem 0.8rem; border-radius: var(--r-md); background: var(--surface-2); }
.pwmeter[data-score='3'], .pwmeter[data-score='4'] { --pw: var(--warning); }
.pwmeter[data-score='5'] { --pw: var(--success); }
.pwmeter[data-empty='true'] { --pw: var(--text-muted); }
.pwmeter__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; font-size: var(--fs-xs); font-weight: 700; }
.pwmeter__title { color: var(--text-muted); }
.pwmeter__label { color: var(--pw); }
.pwmeter__bar { height: 0.4rem; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
.pwmeter__bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--pw); transition: width 0.3s var(--ease), background-color 0.3s; }
.pwmeter__list { display: grid; gap: 0.3rem 0.9rem; list-style: none; font-size: var(--fs-xs); }
@media (min-width: 30rem) { .pwmeter__list { grid-template-columns: 1fr 1fr; } }
.pwmeter__list li { display: flex; align-items: center; gap: 0.45rem; color: var(--text-muted); transition: color 0.2s; }
.pwmeter__tick { display: grid; place-items: center; flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1.5px solid currentColor; color: transparent; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.pwmeter__tick .icon { width: 0.7rem; height: 0.7rem; stroke-width: 3; }
.pwmeter__list li[data-ok='true'] { color: var(--success); font-weight: 650; }
.pwmeter__list li[data-ok='true'] .pwmeter__tick { background: var(--success); border-color: var(--success); color: var(--bg); }


/* ==========================================================================
   Card di condivisione (js/features/share-card.js)
   ========================================================================== */
.dialog--share { width: min(100% - 1rem, 60rem); }
.dialog__panel--share { gap: var(--s-4); }
.share { display: grid; gap: var(--s-5); }
@media (min-width: 52rem) { .share { grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); align-items: start; } }
.share__preview { display: grid; place-items: center; padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-2); }
.share__preview canvas { display: block; width: auto; max-width: 100%; max-height: min(62dvh, 40rem); height: auto; border-radius: 1rem; box-shadow: var(--shadow-lg); }
.share__panel { display: grid; gap: var(--s-4); min-width: 0; }
.share__sentence { padding: 0.7rem 0.9rem; border-left: 4px solid var(--primary); border-radius: var(--r-sm); background: var(--info-bg); font-weight: 650; line-height: 1.45; }
.share__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.share__actions .btn { flex: 1 1 auto; justify-content: center; }
@media (max-width: 51.99rem) { .share__preview canvas { max-height: 46dvh; } }


/* ==========================================================================
   Profilo (js/features/profile-ui.js) e pulsante dell'header con avatar
   ========================================================================== */
.avatar--lg { width: 3.4rem; height: 3.4rem; font-size: 1.45rem; flex: none; }
.btn--has-user { gap: 0.5rem; padding-inline: 0.5rem 0.9rem; }
.auth__name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 35rem) {
  .btn--has-user { padding-inline: 0.4rem; }
  .auth__name { display: none; } /* su telefono resta solo l'avatar: libera spazio nella barra */
}
.dialog--profile { width: min(100% - 1.5rem, 30rem); }
.dialog__panel--profile { gap: var(--s-5); }
.profile__head { display: flex; align-items: center; gap: var(--s-4); padding-right: 2.5rem; }
.profile__who { min-width: 0; }
.profile__who .h2 { overflow-wrap: anywhere; line-height: 1.15; }
.profile__who .muted { margin-top: 0.15rem; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.profile__sec { display: grid; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.profile__h { display: flex; align-items: baseline; gap: 0.5rem; font-size: var(--fs-base); font-weight: 760; }
.profile__h small { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.profile__row { display: flex; gap: 0.6rem; }
.profile__row input { flex: 1; min-width: 0; }
.profile__cities { display: grid; gap: 0.45rem; list-style: none; }
.profile__city { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.profile__pin { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 0.65rem; background: var(--info-bg); color: var(--primary); }
.profile__pin .icon { width: 1.1rem; height: 1.1rem; }
.profile__cityname { display: grid; flex: 1; min-width: 0; }
.profile__cityname strong { overflow-wrap: anywhere; }
.profile__cityname small { font-size: var(--fs-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.profile__remove { color: var(--danger); flex: none; }
.profile__remove .icon { width: 1rem; height: 1rem; }
.profile__empty { padding: 0.4rem 0; }
.profile__full { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.6rem 0.8rem; border-radius: var(--r-md); background: var(--info-bg); font-size: var(--fs-sm); }
.profile__full .icon { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.1rem; color: var(--primary); }
.profile__signout { margin-top: var(--s-1); }

/* La regola generica dei campi (".field input", più specifica) azzerava lo spazio a sinistra della ricerca città:
   l'icona della posizione finiva SOPRA il testo. Qui si ripristina lo spazio per l'icona (sinistra) e per il pulsante GPS (destra). */
.field .citysearch { width: 100%; }
.field .citysearch input:not([type='checkbox']) { padding: 0.55rem 3rem 0.55rem 2.6rem; font-weight: 650; text-overflow: ellipsis; }

/* ---------- Username: vista e editor guidato (profile-ui.js) ---------- */
.uname { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.uname[hidden] { display: none; }
.uname__current { display: flex; align-items: baseline; gap: 0.15rem; min-width: 0; font-size: 1.15rem; }
.uname__current strong { overflow-wrap: anywhere; letter-spacing: -0.01em; }
.uname__at { color: var(--primary); font-weight: 800; }
.uname__edit { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: var(--r-md); background: var(--surface-2); animation: pop 0.2s var(--ease); }
.uname__edit[hidden] { display: none; }
.uname__field { position: relative; display: flex; align-items: center; }
.uname__prefix { position: absolute; left: 0.9rem; font-weight: 800; font-size: 1.05rem; color: var(--primary); pointer-events: none; }
.uname__field input { width: 100%; min-height: 3rem; padding: 0.6rem 3.6rem 0.6rem 2rem; font-size: 1.05rem; font-weight: 700; border: 1.5px solid var(--input-border); border-radius: var(--r-md); background: var(--input-bg); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.uname__field input:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
.uname__count { position: absolute; right: 0.8rem; font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.uname__rules { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; list-style: none; font-size: var(--fs-xs); }
.uname__rules li { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); transition: color 0.2s; }
.uname__tick { display: grid; place-items: center; flex: none; width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 1.5px solid currentColor; color: transparent; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.uname__tick .icon { width: 0.65rem; height: 0.65rem; stroke-width: 3; }
.uname__rules li[data-ok='true'] { color: var(--success); font-weight: 650; }
.uname__rules li[data-ok='true'] .uname__tick { background: var(--success); border-color: var(--success); color: var(--bg); }
.uname__label { margin-bottom: 0.35rem; font-size: var(--fs-xs); font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.uname__card { display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.8rem; border-radius: var(--r-md); background: var(--surface); border: 1px dashed var(--border); }
.uname__cardname { font-weight: 750; overflow-wrap: anywhere; }
.uname__cardmeta { font-size: var(--fs-xs); color: var(--text-muted); }
.uname__chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.uname__chip { min-height: 2.4rem; padding: 0.3rem 0.8rem; font: inherit; font-size: var(--fs-sm); font-weight: 650; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); cursor: pointer; transition: border-color var(--dur-fast), background-color var(--dur-fast), color var(--dur-fast); }
.uname__chip:hover { border-color: var(--primary); color: var(--primary); }
.uname__chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.uname__chip--dice { display: inline-grid; place-items: center; width: 2.4rem; padding: 0; color: var(--primary); }
.uname__chip--dice .icon { width: 1.1rem; height: 1.1rem; }
.uname__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }


/* Ricerca città dentro una finestra: l'elenco scorre nel pannello (niente taglio) invece di fluttuare fuori da esso */
.dialog .citysearch { width: 100%; }
.dialog .citysearch__list { position: static; margin-top: 0.5rem; max-height: min(18rem, 42dvh); box-shadow: none; animation: none; }


/* ---------- Cronologia delle conversazioni (dentro AG Assistant) ---------- */
.assistant--history > :is(.chat__log, .chat__chips, .quota-banner, .chat__form, .chat__meta) { display: none; }
.chathist { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.chathist[hidden] { display: none; }
.chathist__head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); }
.chathist__head h3 { flex: 1; min-width: 0; font-size: var(--fs-md); font-weight: 720; letter-spacing: -0.01em; }
.chathist__head .btn--sm { flex: none; gap: 0.3rem; }
.chathist__head .btn--sm .icon { width: 1rem; height: 1rem; }
.chathist__head .btn[hidden] { display: none; }
.chathist__body { flex: 1; min-height: 0; padding: var(--s-2) var(--s-3) var(--s-3); overflow-y: auto; overscroll-behavior: contain; }
.chathist__where { padding: var(--s-2) var(--s-4) var(--s-3); border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--text-muted); text-align: center; }
.chathist__where:empty { display: none; }
.chathist__msg { padding: var(--s-5) var(--s-3); color: var(--text-muted); font-size: var(--fs-sm); text-align: center; }
.chathist__empty { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
.chathist__emptyicon { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--info-bg); color: var(--primary); }
.chathist__emptyicon .icon { width: 1.5rem; height: 1.5rem; }
.chathist__list { display: grid; gap: var(--s-2); list-style: none; margin: 0; padding: 0; }
.chathist__item { position: relative; display: flex; align-items: stretch; gap: 0.25rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); transition: border-color var(--dur-fast), background-color var(--dur-fast); }
.chathist__item:hover { border-color: var(--primary); }
.chathist__item.is-current { border-color: var(--primary); background: var(--info-bg); }
.chathist__open { flex: 1; display: grid; gap: 0.15rem; min-width: 0; padding: 0.7rem 0.2rem 0.7rem 0.85rem; font: inherit; color: inherit; text-align: left; background: none; border: 0; border-radius: var(--r-md); cursor: pointer; }
.chathist__open:focus-visible, .chathist__del:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.chathist__title { font-size: var(--fs-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chathist__preview { font-size: var(--fs-xs); color: var(--text-muted-strong, var(--text-muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chathist__meta { font-size: 0.7rem; color: var(--text-muted); }
.chathist__del { flex: none; display: grid; place-items: center; min-width: 2.75rem; margin: 0.3rem 0.3rem 0.3rem 0; padding: 0 0.4rem; font: inherit; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); background: none; border: 0; border-radius: var(--r-sm); cursor: pointer; transition: color var(--dur-fast), background-color var(--dur-fast); }
.chathist__del .icon { width: 1.1rem; height: 1.1rem; }
.chathist__del:hover { color: var(--danger); background: var(--danger-bg); }
.chathist__del.is-confirm { color: var(--danger); background: var(--danger-bg); }


/* ---------- Beta tester (profiles.is_beta_tester): anello dorato sull'avatar, badge e ringraziamento nel Profilo ---------- */
.avatar--beta { position: relative; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #f0b323; }
.avatar--lg.avatar--beta::after {
  content: '★';
  position: absolute; right: -0.45rem; bottom: -0.45rem;
  display: grid; place-items: center;
  width: 1.35rem; height: 1.35rem;
  border-radius: 50%;
  background: #f0b323; color: #4a2f00;
  font-size: 0.8rem; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.betabadge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.3rem; padding: 0.15rem 0.7rem 0.15rem 0.5rem;
  font-size: var(--fs-xs); font-weight: 760; letter-spacing: 0.01em; color: var(--text);
  background: color-mix(in srgb, #f0b323 24%, var(--surface));
  border: 1px solid color-mix(in srgb, #f0b323 65%, transparent);
  border-radius: var(--r-pill);
}
.betabadge .icon { width: 0.95rem; height: 0.95rem; color: #d99100; fill: currentColor; }
.profile__beta {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  font-size: var(--fs-sm); color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, #f0b323 20%, var(--surface)), color-mix(in srgb, #f0b323 6%, var(--surface)));
  border: 1px solid color-mix(in srgb, #f0b323 45%, transparent);
  border-radius: var(--r-md);
}
.profile__beta[hidden] { display: none; }
.profile__beta .icon { width: 1.2rem; height: 1.2rem; flex: none; color: #d99100; fill: currentColor; }


/* ---------- Nome della conversazione (al posto della riga di stato, per chi ha un account) ---------- */
.assistant__status[hidden] { display: none; }
.assistant__chatname {
  display: inline-flex; align-items: center; gap: 0.35rem;
  max-width: 100%; padding: 0.05rem 0.35rem 0.05rem 0; margin-left: -0.1rem;
  font: inherit; font-size: var(--fs-xs); color: var(--text-muted);
  background: none; border: 0; border-radius: var(--r-sm);
  cursor: text;
}
.assistant__chatname[hidden] { display: none; }
.assistant__chattitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant__chatname .icon { flex: none; width: 0.8rem; height: 0.8rem; opacity: 0.55; transition: opacity var(--dur-fast), color var(--dur-fast); }
.assistant__chatname:hover, .assistant__chatname:focus-visible { color: var(--text); }
.assistant__chatname:hover .icon, .assistant__chatname:focus-visible .icon { opacity: 1; color: var(--primary); }
.assistant__chatname:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.assistant__chatinput {
  width: 100%; min-height: 0; padding: 0.1rem 0.4rem; margin-left: -0.4rem;
  font: inherit; font-size: max(16px, var(--fs-xs)); /* 16px: iOS non ingrandisce la pagina */
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--focus); border-radius: var(--r-sm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}
.assistant__chatinput:focus-visible { outline: none; }


/* ---------- Menu lingua con molte lingue: due colonne (si legge dall'alto in basso), scorre se lo schermo è basso ---------- */
.langmenu__list { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--lang-rows, 7), auto); grid-auto-columns: minmax(10.5rem, 1fr); gap: 0.1rem 0.3rem; min-width: 0; width: max-content; max-width: calc(100vw - 2rem); max-height: min(28rem, calc(100dvh - 6rem)); overflow-y: auto; overscroll-behavior: contain; }
.langmenu__list[hidden] { display: none; }
.langmenu__list li { display: contents; }
.langmenu__list button { white-space: nowrap; }
.langmenu__list .lang__name, .langmenu__list button > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }


/* ---------- Ruoli speciali (site_roles): owner viola, admin verde acqua. Anello nell'avatar, badge nel Profilo e sui post ---------- */
.avatar--owner, .rolebadge[data-role='owner'], .post__role[data-role='owner'], .profile__beta--owner { --role: #8b5cf6; }
.avatar--admin, .rolebadge[data-role='admin'], .post__role[data-role='admin'], .profile__beta--admin { --role: #0d9488; }
.avatar--owner, .avatar--admin { position: relative; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--role); color: #fff; }
.avatar--lg.avatar--owner, .avatar--lg.avatar--admin { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--role); }
.avatar--owner { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar--admin { background: linear-gradient(135deg, #0f766e, #2dd4bf); }
.avatar--lg.avatar--owner::after, .avatar--lg.avatar--admin::after {
  position: absolute; right: -0.45rem; bottom: -0.45rem;
  display: grid; place-items: center;
  width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: var(--role); color: #fff; font-size: 0.8rem; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.avatar--lg.avatar--owner::after { content: '✦'; }
.avatar--lg.avatar--admin::after { content: '✓'; font-weight: 800; }
.rolebadge, .post__role {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--fs-xs); font-weight: 760; letter-spacing: 0.01em; color: var(--text);
  background: color-mix(in srgb, var(--role) 22%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--role) 60%, transparent);
  border-radius: var(--r-pill);
}
.rolebadge { margin-top: 0.3rem; padding: 0.15rem 0.7rem 0.15rem 0.5rem; }
.rolebadge .icon { width: 0.95rem; height: 0.95rem; color: color-mix(in srgb, var(--role) 60%, var(--text)); }
.post__role { flex: none; margin-left: 0.4rem; padding: 0.05rem 0.5rem 0.05rem 0.35rem; font-size: 0.68rem; }
.post__role .icon { width: 0.8rem; height: 0.8rem; color: color-mix(in srgb, var(--role) 60%, var(--text)); }
.post__author { flex-wrap: nowrap; }
/* il nome si accorcia con i puntini (non il badge, che resta sempre intero) */
.post__author .post__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post__author .post__role, .post__author .post__role span { overflow: visible; text-overflow: clip; }
.post__author .post__role { white-space: nowrap; }
.profile__beta--owner, .profile__beta--admin {
  background: linear-gradient(135deg, color-mix(in srgb, var(--role) 20%, var(--surface)), color-mix(in srgb, var(--role) 6%, var(--surface)));
  border-color: color-mix(in srgb, var(--role) 45%, transparent);
}
.profile__beta--owner .icon, .profile__beta--admin .icon { color: color-mix(in srgb, var(--role) 60%, var(--text)); fill: none; }
