/* ============================================================
   Magic Set AI — design system
   Palette: nero velluto + viola, tipografia display serif elegante
   (Cormorant Garamond) + sans per la UI (Inter) + mono per i dati
   numerici (JetBrains Mono), per un feeling "programma di sala"
   incontra "console da backstage".
   ============================================================ */

:root {
  --bg: #0B0710;
  --bg-elevated: #150F20;
  --surface: #1B1428;
  --surface-2: #241A38;
  --border: #33253F;
  --border-soft: #241A30;

  /* Token di accent dinamici — unica fonte di verità applicata via JS
     in js/appearance.js. I valori qui sotto sono il default (Viola
     mistico): servono come fallback per il primo paint prima che il
     JS applichi l'eventuale palette salvata, così anche senza
     JavaScript l'app mostra comunque un colore coerente. */
  --accent: #9B5DE5;
  --accent-rgb: 155, 93, 229;
  --accent-deep: #6C3CE0;
  --accent-deep-rgb: 108, 60, 224;
  --accent-glow: #C77DFF;

  /* Alias storici: tutte le ~32 regole del foglio di stile che già
     usano var(--violet), var(--violet-deep), var(--violet-glow)
     continuano a funzionare invariate e seguono automaticamente la
     palette scelta dall'utente, senza dover riscrivere ogni regola. */
  --violet: var(--accent);
  --violet-deep: var(--accent-deep);
  --violet-glow: var(--accent-glow);

  --gold: #E8C468;

  --text: #F3EEFA;
  --text-muted: #A79BC2;
  --text-faint: #6E6284;

  --success: #6FCF97;
  --danger: #E97A7A;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --shadow-card: 0 8px 28px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  background-image:
    radial-gradient(ellipse 700px 400px at 15% -10%, rgba(var(--accent-rgb), 0.16), transparent 60%),
    radial-gradient(ellipse 500px 500px at 100% 20%, rgba(var(--accent-deep-rgb), 0.10), transparent 55%);
  background-attachment: fixed;
}

/* ---------------- V3.3.1: fix visibilità sfondo foto ---------------- */
/* CAUSA DEL BUG: <body> ha un proprio background-color (da "html, body
   { background: var(--bg) }") e un proprio background-image (i due
   gradienti sopra). Per le regole di stacking CSS, lo sfondo di un
   elemento statico in-flow come <body> dipinge SOPRA agli elementi con
   z-index negativo (come .photo-background/.photo-overlay, entrambi
   position:fixed con z-index -2/-1): un elemento a z-index negativo
   NON basta a "passare dietro" allo sfondo proprio di body. Il layer
   foto aveva quindi sempre il background-image corretto impostato, ma
   restava visivamente coperto dallo sfondo opaco di body. Confermato
   con screenshot + pixel sampling: 0 pixel della foto (rosso puro di
   test) visibili in tutto lo screenshot prima di questa correzione.
   Fix: quando una foto è attiva (reale o in preview), body riceve la
   classe .has-photo-background che annulla SOLO il proprio sfondo,
   lasciando intatti tutti gli altri elementi (card, bottom nav, hero):
   nessuna trasparenza indesiderata, nessun redesign. Quando la classe
   non è presente (sfondo default), l'aspetto resta bit-per-bit quello
   della V3.2. */
body.has-photo-background {
  background-color: transparent;
  background-image: none;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: var(--violet-deep); color: #fff; }

/* Focus visibile ovunque, per accessibilità da tastiera */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--violet-glow);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

#app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------------- V3.3: layer sfondo foto ---------------- */

.photo-background {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.photo-background.active { display: block; }

.photo-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #000;
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.photo-overlay.active { display: block; }

.app-main {
  flex: 1;
  padding: calc(20px + var(--safe-top)) 18px calc(96px + var(--safe-bottom));
  animation: page-in 260ms ease;
}

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

/* ---------------- Bottom navigation ---------------- */

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom));
  width: calc(100% - 32px);
  max-width: 528px;
  display: flex;
  justify-content: space-around;
  background: rgba(21, 15, 32, 0.86);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  z-index: 50;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-faint);
  padding: 6px 10px;
  border-radius: 12px;
  transition: color 160ms ease, background 160ms ease;
  flex: 1;
}

.bottom-nav a .nav-icon svg { width: 22px; height: 22px; display: block; margin: 0 auto; }
.bottom-nav a .nav-label { font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }

.bottom-nav a.nav-active {
  color: var(--violet-glow);
  background: rgba(var(--accent-rgb), 0.12);
}

/* ---------------- Typography helpers ---------------- */

.page-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}

.hint-text {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.empty-hint {
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1.6;
  padding: 18px 4px;
}

.section { margin-top: 30px; }

/* ---------------- Hero (Home) ---------------- */

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 28px 22px 24px;
  background: linear-gradient(160deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.hero-glow {
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.35), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

.hero-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--violet-glow);
  margin: 0;
}

.hero-settings-btn {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.12;
  margin: 0 0 22px;
  max-width: 20ch;
  white-space: pre-line;
  background: linear-gradient(135deg, #FFFFFF 20%, var(--accent-glow) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-stats {
  display: flex;
  gap: 28px;
  position: relative;
}

.hero-stat { display: flex; flex-direction: column; }
.hero-stat-num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
}
.hero-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------------- Quick grid ---------------- */

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.quick-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 14.5px;
  font-weight: 500;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.quick-card:active { transform: scale(0.97); }
.quick-card:hover { border-color: var(--violet); background: var(--surface-2); }

.quick-icon svg { width: 20px; height: 20px; color: var(--violet-glow); }

.quick-card-accent {
  background: linear-gradient(135deg, var(--violet-deep), var(--violet));
  border-color: transparent;
  color: #fff;
  grid-column: span 2;
}
.quick-card-accent .quick-icon svg { color: #fff; }

/* ---------------- Stale list (Home) ---------------- */

.stale-list { display: flex; flex-direction: column; gap: 8px; }

.stale-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.stale-glyph {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--violet-glow);
  font-size: 16px;
  flex-shrink: 0;
}

.stale-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stale-name { font-weight: 500; font-size: 14.5px; }
.stale-meta { font-size: 12.5px; color: var(--text-faint); }

/* ---------------- Icon buttons ---------------- */

.icon-btn, .icon-btn-ghost {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
}
.icon-btn svg, .icon-btn-ghost svg { width: 19px; height: 19px; }
.icon-btn-ghost { background: transparent; border-color: transparent; color: var(--text-faint); }
.icon-btn-ghost:hover { color: var(--danger); }

/* ---------------- Search / filters (Repertorio) ---------------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.search-bar svg { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
}
.search-bar input:focus { outline: none; }
.search-bar input::placeholder { color: var(--text-faint); }

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

select {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 13px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
}

.result-count {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: 0 0 12px;
}

/* ---------------- Effect list / card ---------------- */

.effect-list { display: flex; flex-direction: column; gap: 10px; }

.effect-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  position: relative;
  transition: border-color 150ms ease, transform 150ms ease;
}
.effect-card:active { transform: scale(0.985); }
.effect-card:hover { border-color: var(--violet); }

.effect-card-glyph {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(155,93,229,0.22), rgba(108,60,224,0.08));
  display: flex; align-items: center; justify-content: center;
  color: var(--violet-glow);
  font-size: 18px;
  flex-shrink: 0;
}

.effect-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.effect-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.effect-card-name { font-weight: 600; font-size: 15.5px; }

.effect-card-meta { font-size: 12.5px; color: var(--text-muted); }

.effect-card-bottom { display: flex; align-items: center; justify-content: space-between; }
.stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.effect-card-last { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }

.effect-card .icon-btn-ghost { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; }
.effect-card .icon-btn-ghost svg { width: 16px; height: 16px; }

.badge {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px 3px;
  border-radius: 999px;
  white-space: nowrap;
  margin-right: 32px;
}
.badge-ready { background: rgba(111, 207, 151, 0.16); color: var(--success); }
.badge-training { background: rgba(232, 196, 104, 0.16); color: var(--gold); }
.badge-learned { background: rgba(167, 155, 194, 0.16); color: var(--text-muted); }

/* ---------------- Forms ---------------- */

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], textarea, select {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 15px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.checkbox-field input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--violet);
}
.checkbox-field span { font-size: 13.5px; }

.star-picker { display: flex; gap: 6px; }
.star-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
}

.last-performed-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--violet-glow);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

/* ---------------- Buttons ---------------- */

.btn-primary, .btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}
.btn-primary svg, .btn-secondary svg { width: 17px; height: 17px; }
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--violet-deep), var(--violet));
  color: #fff;
  box-shadow: 0 8px 24px rgba(var(--accent-deep-rgb), 0.35);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-block { width: 100%; }

/* ---------------- Create Set page ---------------- */

.situation-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  margin-bottom: 10px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 16px;
  color: var(--text-faint);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.chip-active {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: var(--violet);
  color: var(--violet-glow);
}

/* ---------------- Set result page ---------------- */

.show-summary-bar {
  display: flex;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.warning-box {
  background: rgba(232, 196, 104, 0.10);
  border: 1px solid rgba(232, 196, 104, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.warning-box p { margin: 0 0 6px; font-size: 13px; color: var(--gold); line-height: 1.5; }
.warning-box p:last-child { margin-bottom: 0; }

.set-block {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 18px 14px;
  margin-top: 14px;
}

.set-block-finale {
  border-color: var(--violet);
  background: linear-gradient(160deg, rgba(155,93,229,0.14), var(--surface));
}

.set-effect-list {
  list-style: none;
  counter-reset: item;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.set-effect-list li {
  counter-increment: item;
  font-size: 15px;
  padding-left: 30px;
  position: relative;
}
.set-effect-list li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--violet-glow);
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex; align-items: center; justify-content: center;
}
.set-effect-dur {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.checklist li {
  font-size: 14px;
  color: var(--text);
  padding-left: 16px;
  position: relative;
}
.checklist li::before {
  content: '';
  position: absolute;
  left: 0; top: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--violet-glow);
}

.prep-line { font-size: 13.5px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.5; }
.prep-warning { font-size: 13px; color: var(--gold); margin: 8px 0 0; }

/* ---------------- Training page ---------------- */

.training-target-row { align-items: flex-end; margin-bottom: 20px; }
.training-target-row .btn-secondary { height: 44px; margin-top: 20px; }

.training-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.training-item { border-bottom: 1px solid var(--border-soft); padding-bottom: 12px; }
.training-item:last-child { border-bottom: none; padding-bottom: 0; }
.training-item-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.training-item-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--violet);
  flex-shrink: 0;
}
.training-item-main { display: flex; align-items: baseline; gap: 10px; }
.training-item-dur {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--violet-glow);
  min-width: 44px;
}
.training-item-name { font-size: 15.5px; font-weight: 500; }
.training-item-meta { font-size: 12px; color: var(--text-faint); margin-top: 3px; padding-left: 82px; }

/* ---------------- V2: form avanzato collassabile ---------------- */

.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--violet-glow);
  font-size: 14px;
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
}
.advanced-toggle-icon svg { width: 16px; height: 16px; transition: transform 180ms ease; }
.advanced-toggle-open .advanced-toggle-icon svg { transform: rotate(45deg); }

.advanced-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  max-height: 4000px;
  opacity: 1;
  transition: max-height 260ms ease, opacity 200ms ease, margin 200ms ease;
  margin-top: 2px;
}
.advanced-section.advanced-collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: -16px;
  pointer-events: none;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-chip input[type="checkbox"] {
  accent-color: var(--violet);
  width: 14px; height: 14px;
}
.checkbox-chip:has(input:checked) {
  border-color: var(--violet);
  color: var(--violet-glow);
  background: rgba(var(--accent-rgb), 0.12);
}

.hint-text-small {
  font-size: 12px;
  color: var(--text-faint);
  margin: -8px 0 0;
  line-height: 1.5;
}

/* ---------------- V2: diagnosi repertorio insufficiente ---------------- */

.diagnostic-box {
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.diagnostic-box p {
  margin: 0;
  font-size: 13px;
  color: var(--violet-glow);
  line-height: 1.5;
}

/* ---------------- V2: motivazioni per effetto ---------------- */

.set-effect-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reason-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.reason-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  padding-left: 0;
}
.reason-list li::before { content: none; }
.reason-list svg { width: 12px; height: 12px; color: var(--success); flex-shrink: 0; }

/* ---------------- V2: rotazione walk-around ---------------- */

.rotation-sequence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}
.rotation-step {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--violet-glow);
  background: rgba(var(--accent-rgb), 0.14);
  padding: 6px 11px;
  border-radius: 8px;
}
.rotation-arrow {
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------------- V2.1: readiness "Da riallenare" ---------------- */

.stale-readiness-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--gold);
  margin: 2px 0 4px;
}
.stale-readiness-hint svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ---------------- V2.1: partecipazione MIN/MAX ---------------- */

.participant-range-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.participant-range-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 76px;
  flex-shrink: 0;
}
.participant-range-field input { width: 100%; text-align: center; }
.participant-unlimited-field {
  flex: 1;
  margin-bottom: 0;
}

/* ---------------- V2.1: Descrizione / Metodo ---------------- */

.method-textarea {
  min-height: 140px;
  line-height: 1.6;
}

/* ---------------- V2.1: Training — feedback, completato, ripassa metodo ---------------- */

.training-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(111, 207, 151, 0.12);
  border: 1px solid rgba(111, 207, 151, 0.35);
  color: var(--success);
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.training-feedback svg { width: 16px; height: 16px; flex-shrink: 0; }

.training-item-completed { opacity: 0.6; }
.training-item-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--success);
  background: rgba(111, 207, 151, 0.14);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.training-item-done-badge svg { width: 10px; height: 10px; }

.training-method-toggle { margin-top: 6px; padding-left: 54px; }
.training-method-text {
  margin: 8px 0 0 54px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------- Toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  padding: 12px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- V3.0/V3.1: pagina Impostazioni ---------------- */

.tagline-textarea {
  min-height: 90px;
  line-height: 1.6;
}

/* ---------------- V3.2: selettore palette accent ---------------- */

.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0 20px;
}

.palette-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 8px 12px;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}
.palette-chip:active { transform: scale(0.97); }

.palette-chip-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
}

.palette-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}
.palette-swatch svg {
  width: 18px;
  height: 18px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.palette-chip-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}
.palette-chip-active .palette-chip-label {
  color: var(--text);
  font-weight: 600;
}

/* ---------------- V3.3: sezione Sfondo ---------------- */

.background-type-row {
  display: flex;
  gap: 10px;
  margin: 14px 0 18px;
}

.background-type-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 150ms ease;
}
.background-type-chip svg { width: 16px; height: 16px; }
.background-type-chip-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
  color: var(--text);
  font-weight: 600;
}

.photo-picker-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.photo-thumbnail {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.photo-thumbnail svg { width: 22px; height: 22px; }

.photo-picker-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photo-file-input {
  display: none;
}

.photo-processing-hint {
  font-size: 12.5px;
  color: var(--violet-glow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.privacy-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 0 0 16px;
  line-height: 1.5;
}

.overlay-slider-row {
  margin-bottom: 18px;
}

.overlay-slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.overlay-slider-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--violet-glow);
  font-weight: 500;
}

.overlay-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--border-soft);
  outline: none;
}
.overlay-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.overlay-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  cursor: pointer;
}

/* ---------------- V3.4: gestione categorie in Impostazioni ---------------- */

.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 16px;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  flex-wrap: wrap;
}

.category-label-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.category-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-hidden-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.category-row-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.category-delete-btn { color: var(--danger); }

.category-row-editing {
  flex-wrap: nowrap;
  gap: 8px;
}

.category-rename-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 14.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.category-row-save-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
}

.add-category-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.add-category-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 14.5px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
}

.add-category-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---------------- V3.5: chip suggerimento materiali nel form ---------------- */

.material-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 16px;
}

/* ---------------- V3.6B: schermate autenticazione ---------------- */

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: var(--shadow-card);
}

.auth-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--violet-glow);
  margin: 0 0 10px;
  text-align: center;
}

.auth-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  color: var(--text);
  margin: 0 0 18px;
  text-align: center;
}

.auth-body-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 20px;
  text-align: center;
}
.auth-body-text strong { color: var(--text); font-weight: 600; }

.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: rgba(233, 122, 122, 0.12);
  border: 1px solid rgba(233, 122, 122, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  margin: 0;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-card .link-btn {
  display: block;
  margin: 14px auto 0;
  text-align: center;
}
.auth-switch .link-btn { margin: 0; }

.auth-loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent);
  animation: auth-spin 800ms linear infinite;
}
@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* ---------------- V3.6B: sezione Account in Impostazioni ---------------- */

.account-email {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  margin: 0 0 14px;
  word-break: break-all;
}

/* ---------------- V3.6B hotfix2: toggle mostra/nascondi password ---------------- */

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrap input {
  flex: 1;
  padding-right: 44px; /* spazio per il pulsante occhio, mai sovrapposto al testo digitato */
}

.password-toggle-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: 50%;
}
.password-toggle-btn:active { background: rgba(255, 255, 255, 0.06); }
.password-toggle-btn svg { width: 19px; height: 19px; }

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: -2px;
}

/* V3.6C.1 hotfix2: stato disabilitato per "Salva modifiche" (nessuna modifica in sospeso) */
.btn-primary:disabled {
  opacity: 0.45;
  cursor: default;
}

/* V3.6C.1 hotfix4: pannelli temporanei per lo swipe interattivo tra
   sezioni. Stesso padding di .app-main, ma SENZA l'animazione page-in
   (che confliggerebbe con il transform impostato via JS durante il
   drag) e con position:fixed applicato/rimosso dinamicamente da
   swipeNav.js solo per la durata del gesto. */
.swipe-panel {
  position: fixed;
  top: 0;
  z-index: 5;
  padding: calc(20px + var(--safe-top)) 18px calc(96px + var(--safe-bottom));
  background: var(--bg, #0B0710);
  overflow: hidden;
  animation: none; /* annulla page-in ereditata da .app-main: confliggerebbe col transform del drag */
}
