/* ==========================================================================
   TagToCut — stile dell'interfaccia
   Palette: scuro #15171C · laser #FF5A1F · superfici #F6F5F2 / #FFFFFF ·
   testo secondario #6B7079. Solo font di sistema, nessuna risorsa remota.
   ========================================================================== */

/* ---------- Token ---------- */
:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --ink: #15171C;
  --laser: #FF5A1F;

  --bg: #F6F5F2;
  --bg-tint: #EFEDE8;
  --surface: #FFFFFF;
  --surface-2: #F8F7F4;
  --surface-3: #EFEDE8;
  --overlay: rgba(21, 23, 28, 0.42);

  --text: #15171C;
  --text-2: #3D4149;
  --muted: #6B7079;
  --muted-strong: #5A5F68; /* testo secondario su fondi grigi (AA) */
  --laser-text: #EB4A12;   /* arancio laser per testi grandi su fondo chiaro (>= 3:1) */

  --border: #E7E4DE;
  --border-strong: #D5D1C9;
  /* bordi che identificano un controllo o il suo stato (campi, interruttore, caselle): >= 3:1 */
  --control-border: #858A93;

  --accent: #FF5A1F;
  --accent-text: #C2410C;
  --accent-soft: #FFF0E8;
  --accent-soft-2: #FFE0CF;
  --on-accent: #15171C;

  --primary-bg: #15171C;
  --primary-fg: #FFFFFF;
  --primary-hover: #2D3039;

  --success: #157038;
  --success-soft: #E6F5EB;
  --warn: #9A4A06;
  --warn-soft: #FFF3E0;
  --warn-border: #F5D3A6;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --info: #1E4FD8;
  --info-soft: #EAF0FF;

  --tile-bg: #F3F1EC;
  --qr-frame: #FFFFFF;
  /* pallino del colore del materiale: bordo sottile, più marcato per i colori vicini al fondo */
  --dot-ring: rgba(21, 23, 28, 0.16);
  --dot-ring-light: rgba(21, 23, 28, 0.42);
  --dot-ring-dark: rgba(21, 23, 28, 0.16);
  /* etichetta MT/<id> sopra l'immagine del materiale */
  --media-badge-bg: rgba(255, 255, 255, 0.9);
  --media-badge-fg: #15171C;

  /* anello di focus: arancio scuro su fondo chiaro (4,4-5,2:1), laser su fondo scuro (5,3:1) */
  --focus-ring: #C2410C;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-ring);

  --r-xs: 8px;
  --r-s: 10px;
  --r: 12px;
  --r-l: 16px;
  --r-xl: 22px;

  --shadow-1: 0 1px 2px rgba(21, 23, 28, 0.05), 0 1px 1px rgba(21, 23, 28, 0.03);
  --shadow-2: 0 1px 2px rgba(21, 23, 28, 0.04), 0 6px 20px rgba(21, 23, 28, 0.06);
  --shadow-3: 0 2px 6px rgba(21, 23, 28, 0.06), 0 18px 48px rgba(21, 23, 28, 0.14);
  --shadow-page: 0 1px 2px rgba(21, 23, 28, 0.08), 0 10px 30px rgba(21, 23, 28, 0.10);

  --header-h: 64px;
  --container: 1240px;
  --gutter: clamp(16px, 3vw, 32px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Tema scuro: segue il sistema se l'utente non ha scelto, oppure l'interruttore. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15171C;
    --bg-tint: #1A1D23;
    --surface: #1C1F26;
    --surface-2: #20242C;
    --surface-3: #282C36;
    --overlay: rgba(5, 6, 8, 0.62);
    --text: #F3F2EF;
    --text-2: #D0D2D6;
    --muted: #A0A5AE;
    --muted-strong: #B4B8C0;
    --border: #2B2F39;
    --border-strong: #3A3F4B;
    --control-border: #6B7180;
    --focus-ring: #FF5A1F;
    --accent-text: #FF8A5C;
    --accent-soft: rgba(255, 90, 31, 0.13);
    --accent-soft-2: rgba(255, 90, 31, 0.24);
    --primary-bg: #FF5A1F;
    --primary-fg: #15171C;
    --primary-hover: #FF7643;
    --success: #4ADE80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --warn: #FBBF6A;
    --warn-soft: rgba(251, 191, 106, 0.10);
    --warn-border: rgba(251, 191, 106, 0.28);
    --danger: #FF8A80;
    --danger-soft: rgba(255, 138, 128, 0.12);
    --info: #93B4FF;
    --info-soft: rgba(147, 180, 255, 0.12);
    --tile-bg: #ECE9E3;
    --dot-ring: rgba(255, 255, 255, 0.18);
    --dot-ring-light: rgba(255, 255, 255, 0.18);
    --dot-ring-dark: rgba(255, 255, 255, 0.34);
    --media-badge-bg: rgba(28, 31, 38, 0.86);
    --media-badge-fg: #F3F2EF;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-3: 0 2px 8px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.5);
    --shadow-page: 0 2px 4px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171C;
  --bg-tint: #1A1D23;
  --surface: #1C1F26;
  --surface-2: #20242C;
  --surface-3: #282C36;
  --overlay: rgba(5, 6, 8, 0.62);
  --text: #F3F2EF;
  --text-2: #D0D2D6;
  --muted: #A0A5AE;
  --muted-strong: #B4B8C0;
  --border: #2B2F39;
  --border-strong: #3A3F4B;
  --control-border: #6B7180;
  --focus-ring: #FF5A1F;
  --accent-text: #FF8A5C;
  --accent-soft: rgba(255, 90, 31, 0.13);
  --accent-soft-2: rgba(255, 90, 31, 0.24);
  --primary-bg: #FF5A1F;
  --primary-fg: #15171C;
  --primary-hover: #FF7643;
  --success: #4ADE80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --warn: #FBBF6A;
  --warn-soft: rgba(251, 191, 106, 0.10);
  --warn-border: rgba(251, 191, 106, 0.28);
  --danger: #FF8A80;
  --danger-soft: rgba(255, 138, 128, 0.12);
  --info: #93B4FF;
  --info-soft: rgba(147, 180, 255, 0.12);
  --tile-bg: #ECE9E3;
  --dot-ring: rgba(255, 255, 255, 0.18);
  --dot-ring-light: rgba(255, 255, 255, 0.18);
  --dot-ring-dark: rgba(255, 255, 255, 0.34);
  --media-badge-bg: rgba(28, 31, 38, 0.86);
  --media-badge-fg: #F3F2EF;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-3: 0 2px 8px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-page: 0 2px 4px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Lingua diversa dall'italiano (script in <head>): la pagina resta nascosta finché js/i18n.js non l'ha
   tradotta, così non si vede il testo italiano per un attimo. Dopo 2 s si mostra comunque (script lenti o
   bloccati: meglio in italiano che vuota). */
html.i18n-pending body { visibility: hidden; animation: i18n-reveal 0s linear 2s forwards; }
@keyframes i18n-reveal { to { visibility: visible; } }
/* --topbar-h: altezza vera dell'intestazione (app.js), che su telefono va su due righe */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h, var(--header-h)) + 16px); }
html.has-modal { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-2); }

:focus { outline: none; }
/* Anello di focus: outline (segue gli angoli arrotondati e non si somma alle ombre). */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* Titoli e <main> ricevono il focus solo da script (cambio vista, skip link):
   non sono controlli, quindi niente anello arancione attorno al testo. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus, main[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }

.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 10px 14px; border-radius: var(--r-s);
  background: var(--primary-bg); color: var(--primary-fg); font-weight: 600; text-decoration: none;
  transition: top .15s var(--ease);
}
.skip-link:focus { top: 12px; }

.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; }

/* ---------- Pulsanti ---------- */
.btn {
  --btn-h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-s);
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
  user-select: none;
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--surface-3); color: var(--text); }
.btn-accent { background: var(--accent-soft); color: var(--accent-text); }
.btn-accent:hover:not(:disabled) { background: var(--accent-soft-2); }
.btn-lg { --btn-h: 48px; padding: 0 22px; font-size: 15px; border-radius: var(--r); }
.btn-sm { --btn-h: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-xs); gap: 6px; }
.btn-block { width: 100%; }
.btn.is-busy .ico { animation: spin 1s linear infinite; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-s);
  background: transparent; color: var(--text-2);
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.icon-btn.bordered:hover { background: var(--surface-2); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: var(--r-xs); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Intestazione ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .topbar { background: var(--bg); }
}
.topbar.is-scrolled { border-bottom-color: var(--border); box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 6px 18px rgba(21,23,28,.05); }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }

.brand { display: inline-flex; align-items: center; flex: none; text-decoration: none; color: var(--text); border-radius: var(--r-s); }
.brand-logo { height: 30px; width: auto; }
.brand-logo--dark { display: none; }
:root[data-theme="dark"] .brand-logo--light { display: none; }
:root[data-theme="dark"] .brand-logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo--light { display: none; }
  :root:not([data-theme="light"]) .brand-logo--dark { display: block; }
}
.brand-fallback { display: none; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-fallback svg { width: 30px; height: 30px; }
/* Marchio inline (#logo-mark): il riquadro prende il colore da `fill`, come icon.svg / icon-dark.svg. */
.brand-fallback svg, .footer-brand svg { fill: #15171C; }
:root[data-theme="dark"] .brand-fallback svg, :root[data-theme="dark"] .footer-brand svg { fill: #2A2E37; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-fallback svg, :root:not([data-theme="light"]) .footer-brand svg { fill: #2A2E37; }
}
.brand-fallback b { color: var(--laser); font-weight: 800; }
.brand.logo-failed .brand-logo { display: none !important; }
.brand.logo-failed .brand-fallback { display: inline-flex; }

.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 12px;
  margin-left: 8px;
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted-strong); text-decoration: none; white-space: nowrap;
  transition: color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--laser); color: var(--ink);
  font-size: 11.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.count-badge.is-empty { background: var(--border-strong); color: var(--text-2); }
.count-badge.bump { animation: bump .45s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.3); } 100% { transform: scale(1); } }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }

.device-picker {
  position: relative; display: inline-flex; align-items: center;
  height: 40px; padding: 0 10px 0 12px; gap: 8px;
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-s);
  box-shadow: var(--shadow-1); color: var(--text);
  transition: border-color .15s var(--ease);
}
.device-picker:hover { border-color: var(--muted); }
.device-picker:has(select:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.device-picker .ico { color: var(--muted); }
.device-picker select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  height: 38px; padding: 0 20px 0 0; font-size: 14px; font-weight: 600; cursor: pointer; outline: none;
  max-width: 200px; min-width: 64px; text-overflow: ellipsis; field-sizing: content;
}
.device-picker select:focus-visible { outline: none; }
.device-picker .chev { position: absolute; right: 10px; pointer-events: none; width: 16px; height: 16px; }
.device-picker-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.mode-badge {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap;
  background: var(--info-soft); color: var(--info); cursor: default;
}
.mode-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode-badge[data-mode="local"] { background: var(--success-soft); color: var(--success); }
.mode-badge[data-mode="local"]::before { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.mode-badge[data-mode="loading"] { background: var(--surface-3); color: var(--muted); }

.local-actions { display: inline-flex; gap: 4px; }
.topbar .local-actions .btn { --btn-h: 36px; padding: 0 12px; }

.sun { display: none; }
:root[data-theme="dark"] .sun { display: block; }
:root[data-theme="dark"] .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun { display: block; }
  :root:not([data-theme="light"]) .moon { display: none; }
}

/* ---------- Hero ---------- */
/* Solo verticale: il padding orizzontale (margini laterali) viene da .container. */
.hero { padding-top: 28px; padding-bottom: 8px; }
/* Introduzione già chiusa: la nasconde lo script in <head> prima del primo disegno. */
.hero-dismissed #hero { display: none; }
.hero-card {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 28px; background: #F3F0EB; /* stesso fondo delle illustrazioni */
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.hero-card::before {
  /* bagliore laser morbido */
  content: ""; position: absolute; z-index: -1; inset: auto -10% -60% 35%; height: 120%;
  background: radial-gradient(closest-side, rgba(255, 90, 31, 0.16), rgba(255, 90, 31, 0) 70%);
  pointer-events: none;
}
.hero-bg {
  position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  transition: opacity .4s var(--ease);
}
:root[data-theme="dark"] .hero-bg.is-loaded { opacity: .9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-bg.is-loaded { opacity: .9; } }
:root[data-theme="dark"] .hero-card { background: #121419; border-color: #262A33; }
.hero-card::after {
  /* velo che calma lo sfondo dietro al testo (solo tema scuro) */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, rgba(18, 20, 25, .88) 0%, rgba(18, 20, 25, .55) 45%, rgba(18, 20, 25, 0) 75%);
}
:root[data-theme="dark"] .hero-card::after { opacity: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-card::after { opacity: 1; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-card { background: #121419; border-color: #262A33; } }

.hero-main {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 24px;
  padding: clamp(28px, 4.5vw, 60px) clamp(24px, 4.5vw, 56px) 12px;
  min-height: 420px;
}
.hero-copy { position: relative; z-index: 1; max-width: 600px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px;
  padding: 5px 12px 5px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 650;
}
.hero-eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--laser); box-shadow: 0 0 0 4px rgba(255, 90, 31, .18); }
.hero h1 {
  font-size: clamp(32px, 4.6vw, 54px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.04;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--laser-text); }
:root[data-theme="dark"] .hero h1 em { color: var(--laser); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero h1 em { color: var(--laser); } }
.hero-lead { margin-top: 18px; max-width: 34em; font-size: clamp(15.5px, 1.4vw, 17.5px); color: var(--text-2); text-wrap: pretty; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-art { position: relative; align-self: stretch; min-height: 240px; }
.hero-art img {
  /* l'illustrazione ha già il fondo della card: può scorrere sotto il testo */
  position: absolute; right: calc(clamp(24px, 4.5vw, 56px) * -1 - 2%); top: 50%; transform: translateY(-50%);
  width: 150%; max-width: none; height: auto; z-index: 0;
}
:root[data-theme="dark"] .hero-art img {
  position: relative; right: auto; top: auto; transform: none; width: 100%;
  border-radius: 20px; box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 24px 60px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-art img {
    position: relative; right: auto; top: auto; transform: none; width: 100%;
    border-radius: 20px; box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 24px 60px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] .hero-art { display: grid; align-items: center; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-art { display: grid; align-items: center; } }
.hero-close { position: absolute; top: 14px; right: 14px; z-index: 3; background: rgba(255, 255, 255, .7); color: var(--ink); }
.hero-close:hover { background: #fff; color: var(--ink); }
:root[data-theme="dark"] .hero-close { background: rgba(28, 31, 38, .8); color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-close { background: rgba(28, 31, 38, .8); color: var(--text); } }

.steps {
  position: relative; z-index: 1; margin: 0; list-style: none;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  padding: 18px clamp(16px, 3vw, 32px) clamp(16px, 3vw, 32px);
  counter-reset: step;
}
.step {
  display: flex; align-items: center; gap: 14px; padding: 12px; min-width: 0;
  background: rgba(255, 255, 255, .78); border: 1px solid rgba(21, 23, 28, .07); border-radius: var(--r-l);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
:root[data-theme="dark"] .step { background: rgba(28, 31, 38, .82); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .step { background: rgba(28, 31, 38, .82); } }
.step-art {
  position: relative; flex: none; width: 96px; height: 72px; border-radius: 12px; overflow: hidden; background: #F2F1ED;
  display: grid; place-items: center; color: #6B7079;
}
.step-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.step-head { display: flex; align-items: center; gap: 8px; }
.step-num {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px;
  border-radius: 7px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
}
:root[data-theme="dark"] .step-num { background: var(--laser); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .step-num { background: var(--laser); color: var(--ink); } }
.step h3 { font-size: 15px; font-weight: 700; }
.step p { margin-top: 4px; font-size: 13.5px; color: var(--muted); line-height: 1.4; }

/* ---------- Catalogo ---------- */
.catalog { padding-top: 32px; padding-bottom: 48px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.025em; }
.section-head h2 span { color: var(--muted); font-weight: 650; }
.section-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.section-sub strong { color: var(--text-2); font-weight: 600; }

.local-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 14px; border-radius: var(--r);
  background: var(--success-soft); color: var(--text-2); font-size: 13.5px;
}
.local-strip > .ico { color: var(--success); flex: none; }
/* testo accanto all'icona a ogni larghezza (con una base fissa l'icona finiva da sola su una riga) */
.local-strip > .local-strip-text { flex: 1 1 0; min-width: 0; }
.local-strip-main { display: block; }
.local-strip-main::first-letter { text-transform: uppercase; } /* «cache…» quando «Server locale» è nascosto */
.local-strip-actions { display: none; gap: 8px; flex-wrap: wrap; }
.local-strip a { font-weight: 600; }
.local-strip-actions .btn { --btn-h: 34px; padding: 0 12px; font-size: 13px; background: var(--surface); border-color: var(--border-strong); }
.local-strip-actions .ls-short { display: none; }
.local-strip.is-warn { background: var(--warn-soft); }
.local-strip.is-warn > .ico { color: var(--warn); }
/* «Dettagli»: chiuso di base, così l'elenco (che dipende dai dati) non sposta la pagina */
.local-strip-more { margin-top: 2px; }
.local-strip-more > summary {
  display: flex; width: fit-content; align-items: center; gap: 4px; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--text); border-radius: 4px;
}
.local-strip-more > summary::-webkit-details-marker { display: none; }
.local-strip-more > summary .ico { transform: rotate(-90deg); transition: transform .15s var(--ease); }
.local-strip-more[open] > summary .ico { transform: none; }
.local-strip-more > summary .ls-count { font-weight: 500; color: var(--text-2); }
.local-strip-more > p { margin-top: 4px; }
/* segnaposto di «Dettagli»: stessa altezza della riga (1,5 em) e dello stesso margine */
.local-strip-more-sk { display: block; width: 92px; height: 1.5em; margin-top: 2px; }
/* Su localhost (classe messa dallo script in <head>, prima del primo disegno) striscia, interruttore
   «Solo con parametri» e pulsanti di aggiornamento occupano già il loro posto mentre api/status
   risponde: la pagina non salta. app.js toglie la classe appena conosce la modalità. */
.is-localhost #local-strip[hidden] { display: flex !important; }
.is-localhost #only-params-wrap[hidden] { display: inline-flex !important; }
@media (min-width: 901px) {
  .is-localhost #local-actions[hidden] { display: inline-flex !important; }
}

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.search {
  position: relative; flex: 1 1 320px; min-width: 0; display: flex; align-items: center;
}
.search > .ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 46px; padding: 0 84px 0 44px;
  border: 1px solid var(--control-border); border-radius: var(--r);
  background: var(--surface-2); font-size: 15.5px;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:hover { border-color: var(--muted); }
.search input:focus, .search input:focus-visible { background: var(--surface); border-color: var(--focus-ring); box-shadow: 0 0 0 1px var(--focus-ring), 0 0 0 5px var(--accent-soft); outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search-tools { position: absolute; right: 8px; display: inline-flex; align-items: center; gap: 4px; }
.kbd {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--surface);
}

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.select {
  position: relative; display: inline-flex; align-items: center;
}
.select select {
  appearance: none; -webkit-appearance: none; height: 46px; padding: 0 38px 0 14px;
  border: 1px solid var(--control-border); border-radius: var(--r); background: var(--surface);
  font-size: 14px; font-weight: 550; color: var(--text); cursor: pointer;
}
.select select:hover { border-color: var(--muted); }
.select select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.select .ico { position: absolute; right: 12px; pointer-events: none; color: var(--muted); width: 16px; height: 16px; }

.switch {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  font-size: 14px; font-weight: 550; cursor: pointer; user-select: none; white-space: nowrap;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--control-border); flex: none;
  transition: background-color .2s var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); } /* ripiego senza :has() */
.switch:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.switch:has(input:focus-visible) .switch-track { box-shadow: none; }

.chips {
  display: flex; gap: 8px; margin: 16px calc(var(--gutter) * -1) 0; padding: 2px var(--gutter) 6px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent 100%);
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 900px) {
  /* su schermi larghi le categorie vanno a capo: tutte visibili a colpo d'occhio */
  .chips { flex-wrap: wrap; overflow: visible; margin: 16px 0 0; padding: 0; -webkit-mask-image: none; mask-image: none; }
}
/* Categoria senza risultati per la ricerca attuale: attenuata ma con testo ancora AA. */
.chip[data-zero="true"] { color: var(--muted); border-style: dashed; }
.chip[data-zero="true"] .cat-tile { opacity: .45; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none; scroll-snap-align: start;
  height: 40px; padding: 0 14px 0 5px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-1); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
:root[data-theme="dark"] .chip[aria-pressed="true"] { background: #F3F2EF; border-color: #F3F2EF; color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"] { background: #F3F2EF; border-color: #F3F2EF; color: var(--ink); } }
.chip-all { padding-left: 14px; }
/* Segnaposto durante il caricamento: larghezze delle categorie del catalogo P3. */
.chip.chip-sk { width: 124px; padding: 0; border-color: transparent; border-radius: 999px; pointer-events: none; box-shadow: none; }
.chip.chip-sk:nth-child(1) { width: 97px; }
.chip.chip-sk:nth-child(2), .chip.chip-sk:nth-child(10) { width: 141px; }
.chip.chip-sk:nth-child(3) { width: 144px; }
.chip.chip-sk:nth-child(5), .chip.chip-sk:nth-child(14) { width: 116px; }
.chip.chip-sk:nth-child(6), .chip.chip-sk:nth-child(8) { width: 120px; }
.chip.chip-sk:nth-child(7) { width: 136px; }
.chip.chip-sk:nth-child(9) { width: 111px; }
.chip.chip-sk:nth-child(11) { width: 128px; }
.chip.chip-sk:nth-child(12) { width: 127px; }
.chip.chip-sk:nth-child(13) { width: 115px; }
.chip:disabled { cursor: progress; opacity: .6; }
.chip .chip-count {
  font-size: 12px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] .chip-count { color: inherit; opacity: .7; }
.chip .cat-tile { width: 30px; height: 30px; border-radius: 50%; }

/* Tessera icona di categoria (immagine PNG con ripiego CSS). */
.cat-tile {
  --h: 24;
  position: relative; display: inline-grid; place-items: center; flex: none; overflow: hidden;
  width: 48px; height: 48px; border-radius: 14px;
  background: hsl(var(--h) 45% 95%);
  color: hsl(var(--h) 45% 30%);
}
:root[data-theme="dark"] .cat-tile { background: hsl(var(--h) 30% 88%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cat-tile { background: hsl(var(--h) 30% 88%); } }
.cat-tile::after {
  /* ripiego: iniziale della categoria in un piccolo diamante */
  content: attr(data-letter);
  display: grid; place-items: center; width: 56%; height: 56%;
  border-radius: 32%; background: hsl(var(--h) 55% 42%); color: #fff;
  font-size: 0.42em; font-weight: 800; line-height: 1;
  font-size: calc(var(--tile-size, 48px) * 0.28);
}
.cat-tile img {
  position: absolute; inset: 12%; width: 76%; height: 76%; object-fit: contain; z-index: 1;
  opacity: 0; transition: opacity .2s var(--ease);
}
.cat-tile img.is-loaded { opacity: 1; }
.cat-tile.has-img::after { opacity: 0; }
.cat-tile[data-cat="wood"] { --h: 30; }
.cat-tile[data-cat="metal"] { --h: 214; }
.cat-tile[data-cat="plastic"] { --h: 192; }
.cat-tile[data-cat="leather"] { --h: 18; }
.cat-tile[data-cat="paper"] { --h: 44; }
.cat-tile[data-cat="fabric"] { --h: 280; }
.cat-tile[data-cat="glass"] { --h: 200; }
.cat-tile[data-cat="stone"] { --h: 30; }
.cat-tile[data-cat="vinyl"] { --h: 330; }
.cat-tile[data-cat="rubber"] { --h: 0; }
.cat-tile[data-cat="silicone"] { --h: 160; }
.cat-tile[data-cat="screen-printing"] { --h: 250; }
.cat-tile[data-cat="other"] { --h: 220; }

/* Immagine del materiale, a strati: sotto l'immagine della famiglia (o l'icona della categoria al
   centro), sopra, solo in locale, la foto ufficiale, che compare in dissolvenza quando è caricata.
   Le immagini riempiono il riquadro (object-fit: cover). */
.mat-tile {
  position: relative; display: block; flex: none; overflow: hidden;
  border-radius: var(--r); background: var(--tile-bg);
}
.mat-tile .mat-img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: center;
  opacity: 0; transition: opacity .25s var(--ease);
}
.mat-tile .mat-img.is-loaded { opacity: 1; }
/* La foto copre il fondo: sfondo opaco (i PNG con i margini trasparenti non lasciano vedere la
   famiglia sotto); finché non è caricata ha opacità 0, sfondo compreso, e si vede il fondo. */
.mat-tile .mat-photo { position: absolute; inset: 0; background: var(--tile-bg); }
/* Foto caricata: il fondo sparisce a dissolvenza finita (niente lampo tra i due strati). */
.mat-tile.has-photo .mat-img[data-kind="family"],
.mat-tile.has-photo > .cat-tile { visibility: hidden; transition: visibility 0s linear .25s; }
/* Le foto xTool sono quadrate con circa il 12,5% di margine intorno al campione: nelle card (4:3 e
   quadrato da 64 px su mobile) si ingrandiscono oltre il margine, così il campione riempie il
   riquadro come le immagini delle famiglie. Nel dettaglio (1:1) la foto si vede intera. */
.card-media .mat-img[data-kind="photo"] { transform: scale(1.34); transform-origin: center; }
.mat-tile.is-icon { display: grid; place-items: center; }
.mat-tile.is-icon .cat-tile { width: 34%; height: auto; aspect-ratio: 1; border-radius: 22%; --tile-size: 64px; }
/* Tema scuro: immagini chiare attenuate e un filo di bordo, così i riquadri non abbagliano. */
:root[data-theme="dark"] .mat-tile .mat-img { filter: brightness(.85) contrast(.95); }
:root[data-theme="dark"] .card-media::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--border);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mat-tile .mat-img { filter: brightness(.85) contrast(.95); }
  :root:not([data-theme="light"]) .card-media::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    box-shadow: inset 0 0 0 1px var(--border);
  }
}

/* Pallino del colore (SVG con fill: la CSP non ammette style="" inline) */
.color-dot { display: inline-flex; flex: none; width: 12px; height: 12px; }
.color-dot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.color-dot circle { stroke: var(--dot-ring); stroke-width: 1; }
.color-dot.is-light circle { stroke: var(--dot-ring-light); }
.color-dot.is-dark circle { stroke: var(--dot-ring-dark); }

.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 14px; flex-wrap: wrap; }
.results-count { font-size: 14px; color: var(--muted); min-height: 21px; }
.results-count strong { color: var(--text); font-weight: 700; }
.results-bar .btn-ghost { --btn-h: 30px; padding: 0 10px; font-size: 13px; }

/* Griglia card */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0;
  padding: 16px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.card:focus-within { border-color: var(--border-strong); }
.card-top { position: relative; display: block; }
.card-media { width: 100%; aspect-ratio: 4 / 3; }
.card-id {
  margin-left: auto; padding: 3px 8px; border-radius: 7px;
  background: var(--surface-3); color: var(--text-2);
  font-family: var(--mono); font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* sopra l'immagine, in alto a destra */
.card-top > .card-id {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  background: var(--media-badge-bg); color: var(--media-badge-fg);
  box-shadow: 0 1px 2px rgba(21, 23, 28, .12);
}
.card-family {
  display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: -4px;
  font-size: 13px; font-weight: 550; color: var(--muted-strong); line-height: 1.3;
}
.card-family-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-size: 15px; font-weight: 700; line-height: 1.32; letter-spacing: -0.005em; }
.card-open {
  all: unset; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.card-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-l); z-index: 0; }
.card-open:focus-visible { outline: none; }
.card-open:focus-visible::after { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px;
  border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 550; color: var(--text-2); white-space: nowrap;
}
.tag.mono { font-size: 12px; }
.tag-params { background: var(--success-soft); border-color: transparent; color: var(--success); font-weight: 650; }
.tag-flame { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); font-weight: 650; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.card-cat { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.card .btn-add { position: relative; z-index: 1; }
.btn-add.is-added { background: var(--success-soft); color: var(--success); }

.load-more-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 24px; }
.load-more-wrap p { font-size: 13px; color: var(--muted); }

/* Scheletri di caricamento */
/* Stessa altezza della card vera (immagine 4:3, nome su una riga, famiglia, etichette, pulsante):
   lo spazio del pulsante è ::after (più alto fino a 760 px, pulsante da 44 px); nella versione
   compatta per telefono un'altezza fissa. */
.card.skeleton { pointer-events: none; }
.card.skeleton::after { content: ""; display: block; height: 33px; }
.sk-media { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--r) !important; }
.sk-id { width: 56px; height: 22px; margin-left: auto; }
.card-top > .sk-id { position: absolute; top: 8px; right: 8px; }
.sk-line { display: block; width: 85%; height: 16px; }
.sk-tag { width: 72px; height: 24px; }
.sk-short { width: 55%; }
.sk-tag.sk-short { width: 48px; }
.params-note { margin-top: 12px; }
.notice .btn { margin-top: 10px; }
.params-err { display: block; margin: 4px 0; font-family: var(--mono); font-size: 12px; color: var(--muted-strong); overflow-wrap: anywhere; }
.page-card { margin: 0; }
.pages-more { justify-content: center; }
.noscript { padding-top: 24px; padding-bottom: 24px; }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Stato vuoto / errore */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 40px 20px 48px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px dashed var(--border-strong);
}
.empty img { width: 168px; height: 168px; object-fit: cover; border-radius: 28px; margin-bottom: 8px; }
.empty h3 { font-size: 18px; font-weight: 750; }
.empty p { max-width: 30em; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ---------- Avvisi ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r);
  background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--text);
  font-size: 14px; line-height: 1.45;
}
.notice > .ico { color: var(--warn); margin-top: 1px; }
.notice > div, .notice > p { min-width: 0; }
.notice strong { font-weight: 700; }
.notice.is-info { background: var(--info-soft); border-color: transparent; }
.notice.is-info > .ico { color: var(--info); }
.notice.is-neutral { background: var(--surface-2); border-color: var(--border); }
.notice.is-neutral > .ico { color: var(--muted); }
.notice.is-error { background: var(--danger-soft); border-color: transparent; }
.notice.is-error > .ico { color: var(--danger); }
.notice.is-success { background: var(--success-soft); border-color: transparent; }
.notice.is-success > .ico { color: var(--success); }
/* macchine diverse dal P3: sotto il titolo del catalogo e su tutta la larghezza delle note del foglio */
.device-notice { margin-bottom: 16px; }
.sheet-device-note { grid-column: 1 / -1; }
.cache-only-search { margin-top: 8px; }
/* pulsante con un testo lungo (es. un codice materiale): va a capo invece di uscire dal riquadro */
.btn.btn-wrap { height: auto; min-height: var(--btn-h); max-width: 100%; padding-top: 7px; padding-bottom: 7px; white-space: normal; line-height: 1.25; text-align: left; }

/* ---------- Pannello dettaglio (dialog) ---------- */
dialog.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0 0 0 auto;
  width: min(580px, 100vw); max-width: 100vw; height: 100%; max-height: 100dvh;
  padding: 0; border: 0; border-radius: 22px 0 0 22px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-3);
  overflow: hidden;
}
dialog.drawer::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.drawer[open] { animation: drawer-in .32s var(--ease); }
dialog.drawer[open]::backdrop { animation: fade-in .25s var(--ease); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer-inner { display: flex; flex-direction: column; height: 100%; max-height: 100dvh; }
.drawer-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-head .cat-tile { width: 36px; height: 36px; border-radius: 11px; --tile-size: 36px; }
.drawer-kicker { font-size: 13px; color: var(--muted); font-weight: 600; }
.drawer-kicker strong { color: var(--text); }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 22px 28px; }
.drawer-body > * + * { margin-top: 20px; }
.detail-title { font-size: 23px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; overflow-wrap: anywhere; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
/* Immagine del materiale accanto al nome, con la didascalia sull'origine sotto */
.detail-head { display: grid; grid-template-columns: 152px minmax(0, 1fr); gap: 18px; align-items: start; }
.detail-figure { margin: 0; min-width: 0; }
.detail-media { width: 100%; aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--border); }
.detail-caption { margin-top: 6px; font-size: 11.5px; line-height: 1.35; color: var(--muted-strong); text-wrap: balance; }
.detail-headtext { min-width: 0; }
.detail-family {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 2px; margin-top: 8px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
}
.detail-family .color-dot { width: 14px; height: 14px; }
.detail-color { font-weight: 500; color: var(--muted-strong); }
/* il "·" separa colore e famiglia sulla stessa riga; senza famiglia non serve */
.detail-family-label + .detail-color::before { content: "·"; margin-right: 8px; color: var(--muted); }

.qr-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center;
  padding: 16px; border-radius: var(--r-l); background: var(--surface-2); border: 1px solid var(--border);
}
.qr-box {
  width: 196px; height: 196px; padding: 6px; border-radius: 14px; background: #fff;
  box-shadow: 0 1px 2px rgba(21,23,28,.08), inset 0 0 0 1px rgba(21,23,28,.06);
}
.qr-box svg { width: 100%; height: 100%; }
.qr-box.is-missing { display: grid; place-items: center; color: #6B7079; font-size: 13px; text-align: center; padding: 16px; }
.qr-info { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* «Compatibile con i laser xTool»: al posto del testo del QR, che non si mostra */
.qr-compat {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; max-width: 100%;
  padding: 6px 13px 6px 7px; border-radius: 999px;
  background: var(--success-soft); color: var(--success); font-size: 14px; font-weight: 700; line-height: 1.25;
}
.qr-compat .ico { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: var(--success); color: var(--surface); stroke-width: 3; }
.qr-how { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.qr-downloads { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.in-sheet { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13.5px; color: var(--text-2); }
.in-sheet .ico { color: var(--success); }

.detail-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.params-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.params-head h3 { font-size: 17px; font-weight: 750; }
.params-head span { font-size: 12.5px; color: var(--muted); }
.laser-group { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--r-l); overflow: hidden; }
.laser-group + .laser-group { margin-top: 12px; }
.laser-title {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface-2); font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--border);
}
.laser-title .ico { color: var(--laser); }
.mode-block + .mode-block { border-top: 1px solid var(--border); }
.mode-title { padding: 10px 14px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
/* Altre modalità (batch, rilievo, accessori): chiuse, sotto la prima */
.mode-more { border-top: 1px solid var(--border); }
.mode-more > summary {
  display: flex; align-items: flex-start; gap: 6px; padding: 11px 14px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 650; color: var(--text-2); line-height: 1.35;
}
.mode-more > summary::-webkit-details-marker { display: none; }
.mode-more > summary:hover { color: var(--text); background: var(--surface-2); }
.mode-more > summary:focus-visible { outline-offset: -2px; } /* .laser-group taglia ciò che sporge */
.mode-more > summary .ico { margin-top: 1px; color: var(--muted); transform: rotate(-90deg); transition: transform .15s var(--ease); }
.mode-more[open] > summary .ico { transform: none; }
.mode-more-hint { padding: 0 14px 10px 35px; font-size: 12.5px; color: var(--muted-strong); }
.mode-more .mode-block { border-top: 1px solid var(--border); }
.ptable-wrap { overflow-x: auto; }
.ptable { width: 100%; min-width: 440px; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.ptable col.c-proc { width: 31%; }
.ptable col.c-pow { width: 14%; }
.ptable col.c-speed { width: 18%; }
.ptable col.c-pass { width: 13%; }
.ptable col.c-extra { width: 24%; }
.ptable th, .ptable td { padding: 8px 14px; text-align: left; vertical-align: top; }
.ptable thead th { font-size: 12px; font-weight: 650; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ptable tbody tr + tr td { border-top: 1px solid var(--border); }
.ptable td.num { white-space: nowrap; font-weight: 650; }
.ptable td.proc { font-weight: 650; }
.ptable td.extra { color: var(--muted); font-size: 12.5px; min-width: 120px; }
.ptable .unit { color: var(--muted); font-weight: 500; margin-left: 2px; }
/* riga con i valori di «Altro» sotto la lavorazione: solo su telefono (vedi max-width 560px) */
.ptable tr.ptable-sub { display: none; }

.atomm-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }

/* ---------- Foglio etichette ---------- */
.sheet-view { padding-top: 32px; padding-bottom: 56px; }
.sheet-layout { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.sheet-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--topbar-h, var(--header-h)) + 16px); }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.panel-head h3 { font-size: 15px; font-weight: 750; }
.panel-head .btn-ghost { --btn-h: 30px; padding: 0 8px; font-size: 13px; color: var(--muted); }
.panel-body { padding: 0 16px 16px; }

.sheet-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.stat b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 550; }

.sheet-items { list-style: none; margin: 0; padding: 0 8px 8px; max-height: 360px; overflow-y: auto; }
.sheet-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r);
}
.sheet-item:hover { background: var(--surface-2); }
.sheet-item .cat-tile { width: 36px; height: 36px; border-radius: 11px; --tile-size: 36px; }
.sheet-item-name {
  font-size: 13.5px; font-weight: 650; line-height: 1.3; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sheet-item-text { min-width: 0; }
.sheet-item-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item-ctrl { display: flex; align-items: center; gap: 4px; }
.stepper {
  display: inline-flex; align-items: center; height: 32px; border: 1px solid var(--control-border); border-radius: 9px; background: var(--surface);
}
.stepper button {
  display: grid; place-items: center; width: 28px; height: 30px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px;
}
.stepper button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper input {
  width: 34px; height: 30px; border: 0; background: transparent; text-align: center;
  font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline-offset: 0; border-radius: 4px; }
.sheet-item .icon-btn-sm { color: var(--muted); }
.sheet-item .icon-btn-sm:hover { color: var(--danger); background: var(--danger-soft); }

.field + .field { margin-top: 16px; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13.5px; font-weight: 650; margin-bottom: 8px; }
.field-label output { font-family: var(--mono); font-weight: 700; color: var(--text); font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); }
.range-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 28px; background: transparent; cursor: pointer;
  --pct: 27%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--laser) 0 var(--pct), var(--border-strong) var(--pct) 100%);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--border-strong); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--laser); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: #fff; border: 2px solid var(--laser); box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--laser); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
.range-hint { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 2px; }
.presets { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.preset {
  height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12.5px; font-weight: 650; color: var(--text-2);
}
.preset:hover { border-color: var(--border-strong); color: var(--text); }
.preset[aria-pressed="true"] { border-color: var(--laser); background: var(--accent-soft); color: var(--accent-text); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font-size: 13.5px; font-weight: 600; cursor: pointer; user-select: none;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--control-border); background: var(--surface); transition: all .15s var(--ease);
}
.check-box .ico { width: 13px; height: 13px; stroke-width: 3; opacity: 0; color: #fff; }
.check input:checked + .check-box { background: var(--ink); border-color: var(--ink); }
:root[data-theme="dark"] .check input:checked + .check-box { background: var(--laser); border-color: var(--laser); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .check input:checked + .check-box { background: var(--laser); border-color: var(--laser); } }
:root[data-theme="dark"] .check-box .ico { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .check-box .ico { color: var(--ink); } }
.check input:checked + .check-box .ico { opacity: 1; }
.check input:focus-visible + .check-box { box-shadow: var(--focus); } /* ripiego senza :has() */
.check:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.check:has(input:focus-visible) .check-box { box-shadow: none; }
.check:has(input:checked) { border-color: var(--text-2); }

.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-actions .btn { min-width: 150px; }
.preview-notes { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px 20px; align-items: center; margin-bottom: 22px; }
.print-tip { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted-strong); line-height: 1.45; }
.print-tip .ico { margin-top: 2px; flex: none; }
.print-tip strong { color: var(--text-2); }

.preview {
  min-height: 420px; padding: clamp(16px, 3vw, 32px); border-radius: var(--r-xl);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 22%, transparent) 1px, transparent 0) 0 0 / 18px 18px,
    var(--bg-tint);
  border: 1px solid var(--border);
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.preview-head h3 { font-size: 17px; }
.preview-head h3 { font-size: 15px; font-weight: 750; }
.preview-head p { font-size: 13px; color: var(--muted-strong); }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 24px; }
.pages[data-count="1"] { grid-template-columns: minmax(0, 520px); justify-content: center; }
.pages[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .pages[data-count="2"] { grid-template-columns: minmax(0, 1fr); } }
.page-card { display: flex; flex-direction: column; gap: 10px; }
.page-paper {
  position: relative; aspect-ratio: 210 / 297; background: #fff; border-radius: 4px; overflow: hidden;
  box-shadow: var(--shadow-page);
}
.page-paper svg { width: 100%; height: 100%; }
.page-meta { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted-strong); font-weight: 550; }
.page-meta .btn { --btn-h: 28px; padding: 0 8px; font-size: 12.5px; }

.sheet-empty { margin-top: 0; }

/* ---------- Barra mobile del foglio ---------- */
.sheet-fab {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 0);
  display: none; align-items: center; gap: 10px; height: 50px; padding: 0 8px 0 18px;
  border: 0; border-radius: 999px; background: var(--ink); color: #fff; box-shadow: var(--shadow-3);
  font-size: 14.5px; font-weight: 650; text-decoration: none; white-space: nowrap;
}
:root[data-theme="dark"] .sheet-fab { background: #F3F2EF; color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet-fab { background: #F3F2EF; color: var(--ink); } }
.sheet-fab .fab-go { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--laser); color: var(--ink); }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; z-index: 60; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: var(--r);
  background: var(--ink); color: #F3F2EF; box-shadow: var(--shadow-3); pointer-events: auto;
  font-size: 14px; animation: toast-in .28s var(--ease);
}
:root[data-theme="dark"] .toast { background: #2A2E38; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #2A2E38; } }
.toast .ico { color: var(--laser); }
.toast.is-error .ico { color: #FF8A80; }
.toast.is-success .ico { color: #4ADE80; }
.toast-msg { flex: 1; min-width: 0; line-height: 1.35; }
.toast-msg small { display: block; color: #B9BCC3; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-action {
  flex: none; height: 32px; padding: 0 12px; border-radius: 8px; border: 0;
  background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 650;
}
.toast-action:hover { background: rgba(255,255,255,.2); }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

/* ---------- Accesso (solo sito web con account) ---------- */
/* Senza sessione: niente catalogo, foglio, selettore della macchina. La classe auth-locked la mette
   lo script in <head> (sito con account e nessuna sessione salvata: niente catalogo al primo
   disegno) e poi app.js; viene dopo le regole is-localhost, che a parità di peso perdono. */
.auth-locked #view-catalog, .auth-locked #view-sheet, .auth-locked #view-topper, .auth-locked #view-tools, .auth-locked #view-gen,
.auth-locked .tabs, .auth-locked .device-picker,
.auth-locked .mode-badge, .auth-locked #local-actions, .auth-locked #local-actions[hidden],
.auth-locked .sheet-fab, .auth-locked #show-intro, .auth-locked #account,
.auth-locked #guest-actions { display: none !important; }
.auth-locked #view-auth[hidden] { display: block !important; }

/* Senza account (classe is-guest dallo script in <head> e da app.js): solo gli esempi della home,
   niente filtri e categorie (con tre materiali non servono); «Accedi» e «Registrati» in alto. */
.is-guest .filters, .is-guest #category-chips, .is-guest #reset-filters { display: none !important; }
.is-guest #guest-actions[hidden] { display: flex !important; }
html:not(.is-guest) #guest-cta { display: none !important; }
.guest-actions { display: flex; align-items: center; gap: 6px; }
.guest-actions .btn { --btn-h: 40px; white-space: nowrap; }
.guest-cta {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center;
  margin-top: 20px; padding: 22px 24px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px dashed var(--border-strong);
}
.guest-cta-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent-text);
}
.guest-cta-text h3 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; }
.guest-cta-text p { margin-top: 4px; color: var(--muted-strong); }
.guest-cta-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.auth-back { margin: -4px 0 14px; font-size: 14px; }
.auth-back .link-btn { display: inline-flex; align-items: center; gap: 6px; }
.auth-back .ico { transform: rotate(180deg); }
@media (max-width: 760px) {
  .guest-cta { grid-template-columns: minmax(0, 1fr); text-align: left; padding: 20px 18px; }
  .guest-cta-icon { display: none; }
  .guest-cta-actions { justify-content: flex-start; }
  .guest-cta-actions .btn { --btn-h: 44px; flex: 1 1 auto; }
}
@media (max-width: 1023px) {
  /* tablet e telefono: in intestazione c'è posto solo per «Registrati» («Accedi» è sotto gli esempi e
     nel modulo di registrazione) */
  .guest-actions .btn-ghost, .is-guest .mode-badge { display: none; }
}
@media (max-width: 560px) {
  .guest-actions .btn { --btn-h: 44px; padding: 0 14px; }
}

.auth-view { padding-top: 36px; padding-bottom: 56px; }
.auth-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 460px); gap: 28px; align-items: start; }
.auth-side {
  position: relative; overflow: hidden; isolation: isolate;
  padding: clamp(28px, 3.6vw, 48px); border-radius: 28px;
  background: #F3F0EB; /* stesso fondo dell'introduzione e delle illustrazioni */
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
}
.auth-side::before {
  content: ""; position: absolute; z-index: -1; inset: auto -30% -50% 20%; height: 90%;
  background: radial-gradient(closest-side, rgba(255, 90, 31, 0.16), rgba(255, 90, 31, 0) 70%);
  pointer-events: none;
}
:root[data-theme="dark"] .auth-side { background: #121419; border-color: #262A33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-side { background: #121419; border-color: #262A33; } }
.auth-intro h1 { font-size: clamp(30px, 3.4vw, 44px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.06; text-wrap: balance; }
.auth-intro h1 em { font-style: normal; color: var(--laser-text); }
:root[data-theme="dark"] .auth-intro h1 em { color: var(--laser); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-intro h1 em { color: var(--laser); } }
.auth-lead { margin-top: 16px; max-width: 34em; font-size: clamp(15px, 1.3vw, 17px); color: var(--text-2); text-wrap: pretty; }
.auth-steps { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; }

.auth-card {
  padding: 30px 28px 26px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2);
}
.auth-panel { display: flex; flex-direction: column; gap: 16px; }
.auth-badge {
  display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 14px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-text);
}
.auth-badge .ico { width: 22px; height: 22px; }
.auth-badge.is-warn { background: var(--warn-soft); color: var(--warn); }
.auth-head h2 { font-size: 25px; font-weight: 800; letter-spacing: -0.025em; }
.auth-sub { margin-top: 6px; font-size: 14.5px; line-height: 1.5; color: var(--muted-strong); }
.auth-email { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.auth-note { font-size: 14px; line-height: 1.5; color: var(--muted-strong); }
.auth-note a { font-weight: 600; }
.auth-alert:empty { display: none; }

.auth-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.auth-field > label:not(.auth-consent) { font-size: 13.5px; font-weight: 650; color: var(--text); }
.auth-field input[type="email"], .auth-field input[type="text"], .auth-field input[type="password"] {
  width: 100%; min-width: 0; height: 46px; padding: 0 14px;
  border: 1px solid var(--control-border); border-radius: var(--r); background: var(--surface-2);
  font-size: 16px; /* 16 px: iOS non ingrandisce la pagina al focus */
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.auth-field input:hover { border-color: var(--muted); }
.auth-field input:focus, .auth-field input:focus-visible {
  background: var(--surface); border-color: var(--focus-ring); outline: none;
  box-shadow: 0 0 0 1px var(--focus-ring), 0 0 0 5px var(--accent-soft);
}
.auth-field input[aria-invalid="true"] { border-color: var(--danger); }
.auth-field input[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger), 0 0 0 5px var(--danger-soft); }
.field-hint { font-size: 12.5px; color: var(--muted-strong); }
.field-error { font-size: 13px; font-weight: 600; color: var(--danger); }
.field-error:empty { display: none; }

.pw-wrap { position: relative; display: flex; align-items: center; }
.auth-field .pw-wrap input { padding-right: 96px; }
.pw-toggle {
  position: absolute; right: 5px; height: 36px; min-width: 80px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 650;
}
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.pw-toggle:focus-visible { outline-offset: -2px; }

/* Casella «Ho letto l'informativa privacy»: stessa casella dei filtri del foglio (.check-box) */
.auth-consent { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 2px 0; font-size: 14px; line-height: 1.45; color: var(--text-2); cursor: pointer; }
.auth-consent input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.auth-consent .check-box { flex: none; margin-top: 1px; }
.auth-consent a { font-weight: 650; }
.auth-consent input:checked + .check-box { background: var(--ink); border-color: var(--ink); }
:root[data-theme="dark"] .auth-consent input:checked + .check-box { background: var(--laser); border-color: var(--laser); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-consent input:checked + .check-box { background: var(--laser); border-color: var(--laser); } }
.auth-consent input:checked + .check-box .ico { opacity: 1; }
.auth-consent input:focus-visible + .check-box { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.auth-consent input[aria-invalid="true"] + .check-box { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Invio in corso: rotellina al posto dell'icona, il pulsante resta leggibile */
.auth-panel .btn { margin-top: 2px; }
.auth-panel .btn.is-busy { cursor: progress; }
.auth-panel .btn.is-busy[aria-disabled="true"] { opacity: .85; }
.auth-panel .btn.is-busy .ico { display: none; }
.auth-panel .btn.is-busy::after {
  content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
.link-btn {
  all: unset; cursor: pointer; border-radius: 4px;
  color: var(--accent-text); font-weight: 650; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-thickness: 2px; }
.link-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.link-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.auth-links { margin-top: -2px; text-align: center; font-size: 14px; }
.auth-switch { padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 14px; color: var(--muted-strong); }

/* Pulsante dell'account in intestazione e il suo menu */
.account { position: relative; min-width: 0; }
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; max-width: 240px; padding: 0 10px 0 11px;
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-s); box-shadow: var(--shadow-1);
  color: var(--text); font-size: 13.5px; font-weight: 600;
  transition: border-color .15s var(--ease);
}
.account-btn:hover { border-color: var(--muted); }
.account-btn .ico { color: var(--muted-strong); }
.account-btn .chev { width: 16px; height: 16px; transition: transform .15s var(--ease); }
.account-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.account-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute; z-index: 50; right: 0; top: calc(100% + 8px); width: 280px; padding: 14px;
  border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3);
}
.account-menu-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.account-menu-name { margin-top: 6px; font-size: 14.5px; font-weight: 700; overflow-wrap: anywhere; }
.account-menu-email { margin-top: 2px; font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.account-menu-label + .account-menu-email { margin-top: 6px; }
.account-menu .btn { margin-top: 14px; }

@media (max-width: 960px) {
  /* una colonna: il titolo, la scheda di accesso, poi i passi (il riquadro di sinistra si scioglie) */
  .auth-layout { grid-template-columns: minmax(0, 1fr); max-width: 560px; margin: 0 auto; gap: 20px; }
  .auth-side { display: contents; }
  .auth-side::before { display: none; } /* senza riquadro il bagliore uscirebbe dalla pagina */
  .auth-intro { order: 1; }
  .auth-card { order: 2; }
  .auth-steps { order: 3; margin-top: 0; }
}

/* ---------- Dashboard dell'amministratore (js/admin.js) ---------- */
.admin-view { padding-top: 32px; padding-bottom: 56px; }
.admin-view.is-loading #admin-body { opacity: .55; transition: opacity .2s var(--ease); }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-head h2 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.025em; }
.admin-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-periods { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-kpi {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 16px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.admin-kpi-label { font-size: 13px; font-weight: 600; color: var(--muted-strong); }
.admin-kpi strong { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.admin-kpi-hint { font-size: 12.5px; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.admin-card {
  min-width: 0; padding: 18px 18px 20px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.admin-card.admin-wide { margin-bottom: 16px; }
.admin-card h3 { font-size: 16px; font-weight: 750; letter-spacing: -0.01em; margin-bottom: 10px; }
.admin-card h4 { margin: 14px 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.admin-card-head h3 { margin-bottom: 4px; }
.admin-note { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.admin-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.admin-top-name { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; }
.admin-top-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.admin-top-nums div { padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.admin-top-nums dt { font-size: 12.5px; color: var(--muted-strong); }
.admin-top-nums dd { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.admin-chart-box { position: relative; padding-top: 18px; }
.admin-chart { display: block; width: 100%; height: 170px; }
.admin-chart-max { position: absolute; top: 0; left: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.admin-chart-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.admin-bar { fill: var(--accent); }
.admin-grid-line { stroke: var(--border); stroke-width: 1; }
.admin-bars { list-style: none; display: grid; gap: 8px; }
.admin-bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: 14px; }
.admin-bars-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-bars-num { font-variant-numeric: tabular-nums; font-weight: 650; }
.admin-bars-num small { font-weight: 500; color: var(--muted); }
.admin-bars-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.admin-bars-track span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); }
.admin-flag { display: inline-block; width: 1.6em; }
.admin-table-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.admin-search { flex: 1 1 240px; display: block; }
.admin-search input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-s); font: inherit; font-size: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--control-border);
}
.admin-search input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted-strong); padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-mat-name { display: block; font-weight: 650; }
.admin-mat-meta { display: block; font-size: 12.5px; color: var(--muted); }
.admin-more { margin-top: 12px; text-align: center; }
.admin-examples { list-style: none; display: grid; gap: 8px; margin-bottom: 12px; }
.admin-examples li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.admin-examples li.admin-empty { display: block; background: none; border-style: dashed; }
.admin-ex-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; }
.admin-ex-actions { display: flex; gap: 2px; }
.admin-up { transform: rotate(180deg); }
.admin-picks { list-style: none; display: grid; gap: 4px; margin-top: 8px; }
.admin-pick {
  all: unset; box-sizing: border-box; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: var(--r-s); cursor: pointer; border: 1px solid var(--border);
}
.admin-pick:hover { background: var(--surface-2); }
.admin-pick:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.admin-pick .ico { grid-row: 1 / span 2; grid-column: 2; }
.admin-ex-save { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.admin-missing { padding: 24px 0; color: var(--muted); }
.admin-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin: 1px 4px 1px 0; border-radius: 7px;
  font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.admin-badge.is-active { background: var(--success-soft); border-color: transparent; color: var(--success); }
.admin-badge.is-pending, .admin-badge.is-unconfirmed { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.admin-badge.is-blocked { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.admin-badge.is-admin { background: var(--info-soft); border-color: transparent; color: var(--info); }
.admin-user-email { font-weight: 600; overflow-wrap: anywhere; }
.admin-users tr.is-open > td { border-bottom-color: transparent; background: var(--surface-2); }
.admin-user-edit-row > td { background: var(--surface-2); }
.admin-user-edit { display: grid; gap: 14px; padding: 4px 2px 8px; }
.admin-user-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.admin-user-fields label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted-strong); min-width: 0; }
.admin-user-fields input[type="text"], .admin-user-fields select {
  width: 100%; height: 40px; padding: 0 10px; border-radius: var(--r-s); font: inherit; font-size: 14px; font-weight: 500;
  background: var(--surface); color: var(--text); border: 1px solid var(--control-border);
}
.admin-user-fields select:disabled { opacity: .6; }
.admin-user-fields input:focus-visible, .admin-user-fields select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.admin-user-fields .admin-check { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
.admin-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.admin-user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-delete { color: var(--danger); justify-self: start; }
.admin-danger { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--danger-soft); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
@media (max-width: 760px) {
  .admin-user-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .admin-ex-num { background: #F3F2EF; color: var(--ink); } }
:root[data-theme="dark"] .admin-ex-num { background: #F3F2EF; color: var(--ink); }
@media (max-width: 960px) {
  .admin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .admin-kpi strong { font-size: 24px; }
  .admin-top-nums dd { font-size: 18px; }
}

/* ---------- Informativa privacy (privacy.html) ---------- */
.legal-top .topbar-inner { justify-content: space-between; }
.legal { max-width: 800px; padding-top: 36px; padding-bottom: 64px; }
.legal h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.legal-meta { margin-top: 10px; font-size: 14px; color: var(--muted-strong); }
.legal-langs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 14px; }
.legal-langs a { color: var(--text-2); text-underline-offset: 3px; border-radius: 4px; }
.legal-langs a[aria-current="page"] { color: var(--text); font-weight: 700; text-decoration: none; }
.legal-note { margin-top: 14px; padding: 10px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; color: var(--muted-strong); }
.legal-intro { margin-top: 18px; font-size: 16.5px; line-height: 1.6; color: var(--text-2); }
.legal h2 { margin-top: 36px; font-size: 19px; font-weight: 750; letter-spacing: -0.015em; }
.legal p, .legal li { font-size: 15.5px; line-height: 1.65; color: var(--text-2); }
.legal h2 + p, .legal p + p, .legal p + ul, .legal ul + p { margin-top: 10px; }
.legal ul { margin: 10px 0 0; padding-left: 22px; }
.legal li + li { margin-top: 6px; }
.legal strong { color: var(--text); font-weight: 650; }
.legal code { font-family: var(--mono); font-size: .88em; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text); overflow-wrap: anywhere; }
.legal .todo { padding: 0 4px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-weight: 650; }
.legal-card { margin-top: 14px; padding: 18px 20px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.legal-card p { margin: 0; }
.legal-card p + p { margin-top: 6px; }
.legal-back { margin-top: 40px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; padding-top: 32px; padding-bottom: 32px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.footer-brand img, .footer-brand svg { width: 28px; height: 28px; border-radius: 8px; }
.footer-brand b { color: var(--laser); }
.footer p { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.footer-col p + p { margin-top: 8px; }
.footer-lead { margin-top: 10px; }
.footer .disclaimer { color: var(--text-2); font-weight: 550; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.footer-meta button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; color: var(--text-2); border-radius: 4px; }
.footer-meta button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.footer-meta a { color: var(--text-2); text-underline-offset: 2px; border-radius: 4px; }
.lang-picker { display: inline-flex; align-items: center; gap: 6px; }
.lang-picker select {
  height: 28px; padding: 0 6px; border: 1px solid var(--control-border); border-radius: 7px;
  background: var(--surface); color: var(--text); font-size: 12.5px;
}
.lang-picker select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Area di stampa (nascosta a schermo) ---------- */
#print-root { display: none; }

/* ---------- Cake topper ---------- */
/* Font del generatore (web/fonts, licenza OFL): nomi propri, così il canvas non usa per sbaglio un
   font con lo stesso nome installato sul computer. Il browser li scarica solo quando servono. */
@font-face { font-family: "TTC Style Script"; src: url("../fonts/style-script.woff") format("woff"); font-display: swap; }
@font-face { font-family: "TTC Pacifico"; src: url("../fonts/pacifico.woff") format("woff"); font-display: swap; }
@font-face { font-family: "TTC Lobster"; src: url("../fonts/lobster.woff") format("woff"); font-display: swap; }
@font-face { font-family: "TTC Dancing Script"; src: url("../fonts/dancing-script-bold.woff") format("woff"); font-display: swap; }
@font-face { font-family: "TTC Great Vibes"; src: url("../fonts/great-vibes.woff") format("woff"); font-display: swap; }
@font-face { font-family: "TTC Fredoka"; src: url("../fonts/fredoka-semibold.woff") format("woff"); font-display: swap; }

.topper-view { padding-top: 32px; padding-bottom: 56px; }
.topper-layout { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
/* colonne fissate: su una colonna js/genui.js (previewFirst) mette l'anteprima prima dei comandi anche nel
   DOM, per l'ordine del Tab; su due colonne i comandi restano a sinistra qualunque sia l'ordine */
.topper-layout > .topper-side, .gen-layout > .gen-side { grid-column: 1; grid-row: 1; }
.topper-layout > .topper-preview, .gen-layout > .gen-preview-panel { grid-column: 2; grid-row: 1; }
.topper-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* l'anteprima resta in vista mentre si regolano i cursori della colonna a sinistra */
.topper-preview { position: sticky; top: calc(var(--topbar-h, var(--header-h)) + 16px); min-height: 0; }

.topper-lines { display: grid; gap: 8px; }
.topper-lines input {
  width: 100%; min-width: 0; height: 44px; padding: 0 14px;
  border: 1px solid var(--control-border); border-radius: var(--r); background: var(--surface-2);
  font-size: 16px; font-weight: 600; color: var(--text);
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.topper-lines input:hover { border-color: var(--muted); }
.topper-lines input:focus, .topper-lines input:focus-visible {
  background: var(--surface); border-color: var(--focus-ring); outline: none;
  box-shadow: 0 0 0 1px var(--focus-ring), 0 0 0 5px var(--accent-soft);
}
.topper-lines input::placeholder { color: var(--muted); font-weight: 500; }

.topper-fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.topper-font { position: relative; cursor: pointer; }
.topper-font input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.topper-font-name {
  display: grid; place-items: center; height: 56px; padding: 0 8px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 22px; line-height: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.topper-font:hover .topper-font-name { border-color: var(--muted); }
.topper-font input:checked + .topper-font-name { border-color: var(--laser); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--laser); }
.topper-font input:focus-visible + .topper-font-name { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.topper-font-name[data-font="style-script"] { font-family: "TTC Style Script", cursive; font-size: 26px; }
.topper-font-name[data-font="pacifico"] { font-family: "TTC Pacifico", cursive; font-size: 19px; }
.topper-font-name[data-font="lobster"] { font-family: "TTC Lobster", cursive; }
.topper-font-name[data-font="dancing-script"] { font-family: "TTC Dancing Script", cursive; font-size: 24px; }
.topper-font-name[data-font="great-vibes"] { font-family: "TTC Great Vibes", cursive; font-size: 27px; }
.topper-font-name[data-font="fredoka"] { font-family: "TTC Fredoka", sans-serif; font-size: 20px; }

.topper-switch { display: flex; justify-content: space-between; width: 100%; white-space: normal; }
.topper-switch + .field, .topper-switch + #topper-stake-fields { margin-top: 14px; }
.field + .topper-switch { margin-top: 18px; }
.topper-view .is-off { opacity: .45; }

.topper-stage {
  position: relative; display: grid; place-items: center; min-height: 280px;
  border-radius: var(--r-l); background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--border);
}
.topper-canvas { width: 100%; padding: clamp(12px, 3vw, 28px); transition: opacity .2s var(--ease); }
.topper-canvas.is-busy { opacity: .55; }
.topper-svg { display: block; width: 100%; height: auto; max-height: min(56vh, 560px); margin: 0 auto; }
.topper-status { position: absolute; inset: auto 16px 16px; text-align: center; font-size: 14px; color: var(--muted-strong); }
.topper-canvas:empty + .topper-status { position: static; }
.topper-warn { margin-top: 12px; }

.topper-bottom { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-top: 16px; }
.topper-colors { display: grid; gap: 10px; min-width: 0; }
.topper-color-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.topper-color-label { font-size: 13px; font-weight: 650; color: var(--text-2); min-width: 9.5em; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch-dot { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .2); box-shadow: inset 0 1px 2px rgba(255, 255, 255, .4); }
.swatch input:checked + .swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
.swatch-dot[data-color="rosa"] { background: #F2A7C3; }
.swatch-dot[data-color="lilla"] { background: #B9A6E0; }
.swatch-dot[data-color="oro"] { background: linear-gradient(135deg, #E8CB6A, #B08A1E); }
.swatch-dot[data-color="argento"] { background: linear-gradient(135deg, #E4E7EB, #9AA0A8); }
.swatch-dot[data-color="nero"] { background: #2A2A30; }
.swatch-dot[data-color="bianco"] { background: #F4F4F2; }
.swatch-dot[data-color="azzurro"] { background: #8EC5E8; }
.swatch-dot[data-color="legno"] { background: linear-gradient(135deg, #D9A86E, #A9733F); }
.topper-layer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.topper-layer-actions .btn { --btn-h: 36px; padding: 0 10px; font-size: 13px; color: var(--text-2); }

.topper-help {
  margin-top: 24px; padding: 18px 20px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--border); max-width: 980px;
}
.topper-help h4 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 750; margin-bottom: 8px; }
.topper-help ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; font-size: 14px; line-height: 1.5; color: var(--text-2); }

/* ---------- Strumenti: galleria e generatori (js/genui.js) ---------- */
/* Livelli del file nelle anteprime: rosso taglio, blu incisione, verde segno, come nell'SVG scaricato
   (js/svgexport.js); più chiari nel tema scuro. Il tratto non cambia spessore con lo zoom. */
:root { --layer-cut: #E53935; --layer-engrave: #1E88E5; --layer-score: #43A047; }
:root[data-theme="dark"] { --layer-cut: #FF7A75; --layer-engrave: #6CB8F6; --layer-score: #6FCF73; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --layer-cut: #FF7A75; --layer-engrave: #6CB8F6; --layer-score: #6FCF73; }
}
.gen-layer path { fill: none; stroke-width: 1.3px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.gen-layer-cut path { stroke: var(--layer-cut); }
.gen-layer-engrave path { stroke: var(--layer-engrave); stroke-width: 1px; }
.gen-layer-score path { stroke: var(--layer-score); stroke-dasharray: 5 3; }

.tools-view, .gen-view { padding-top: 32px; padding-bottom: 56px; }
.tools-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px;
}
.tool-item { min-width: 0; }
.tool-card {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  color: var(--text); text-decoration: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.tool-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.tool-art {
  position: relative; display: block; aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 22%, transparent) 1px, transparent 0) 0 0 / 14px 14px,
    var(--bg-tint);
  border-bottom: 1px solid var(--border);
}
/* fuori dal flusso: tutte le miniature alte uguali, qualunque sia la forma del disegno */
.tool-thumb-svg { position: absolute; inset: 16px 20px; width: calc(100% - 40px); height: calc(100% - 32px); max-width: none; }
.tool-thumb-svg .gen-layer path { stroke-width: 1.4px; }
.tool-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1; padding: 14px 18px 18px; }
.tool-cat {
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text);
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
}
.tool-name { font-size: 17px; font-weight: 750; }
.tool-summary { font-size: 14px; line-height: 1.45; color: var(--muted-strong); }
.tool-go { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; font-size: 14px; font-weight: 650; color: var(--accent-text); }
/* categoria della galleria con il suo titolo (Cristallo e 3D): le schede dentro non ripetono la categoria */
.tools-group { margin-top: 32px; }
.tools-group[hidden] { display: none; }
.tools-group-head { margin-bottom: 14px; max-width: 760px; }
.tools-group-title { font-size: 19px; font-weight: 800; letter-spacing: -0.015em; }
.tools-group-sub { margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.tools-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--muted-strong); max-width: 760px; }
.tools-note .ico { margin-top: 2px; }

.gen-back { margin: -8px 0 12px; font-size: 14px; }
.gen-back a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
.gen-back a:hover { text-decoration: underline; }
.gen-back .ico { transform: rotate(180deg); }
.gen-eyebrow { margin-bottom: 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-text); }
/* stesse colonne del cake topper: tutte le pagine di «Strumenti» hanno lo stesso schema */
.gen-layout { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.gen-side, .gen-groups { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gen-preview-panel { position: sticky; top: calc(var(--topbar-h, var(--header-h)) + 16px); min-height: 0; min-width: 0; }

/* auto-fit: niente colonne vuote, le schede dei modelli si allargano fino a riempire la riga (al massimo
   560 px in tutto, su una colonna); larghe almeno 100 px, così i nomi non si spezzano a metà parola */
.gen-templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 100px), 1fr)); gap: 8px; max-width: 560px; }
.gen-tpl { position: relative; display: block; min-width: 0; cursor: pointer; }
.gen-tpl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gen-tpl-card {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 8px;
  border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface); text-align: center;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.gen-tpl:hover .gen-tpl-card { border-color: var(--muted); }
.gen-tpl input:checked + .gen-tpl-card { border-color: var(--laser); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--laser); }
.gen-tpl input:focus-visible + .gen-tpl-card { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.gen-tpl-art { position: relative; display: block; aspect-ratio: 3 / 2; border-radius: 8px; background: var(--bg-tint); }
.gen-tpl-svg { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); max-width: none; }
/* parole lunghe (Fingerzinken, Kreuzverbindung): a capo con il trattino della lingua della pagina, mai a
   metà parola senza trattino (break-word solo se una sillaba non ci sta) */
.gen-tpl-name { font-size: 13px; font-weight: 650; line-height: 1.25; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }

.gen-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.gen-toolbar .btn-ghost { --btn-h: 36px; padding: 0 10px; color: var(--text-2); }
.gen-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-3); max-width: 100%; }
.gen-seg-opt { position: relative; display: flex; min-width: 0; cursor: pointer; }
.gen-seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gen-seg-opt span {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 32px; padding: 0 14px;
  border-radius: 8px; font-size: 13.5px; font-weight: 650; color: var(--muted-strong); white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.gen-seg-opt:hover span { color: var(--text); }
.gen-seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.gen-seg-opt input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.gen-field .gen-seg { display: flex; flex-wrap: wrap; width: 100%; }
.gen-field .gen-seg-opt { flex: 1 1 auto; }
.gen-field .gen-seg-opt span { white-space: normal; text-align: center; line-height: 1.2; }
.gen-field .field-label { align-items: center; }
.gen-field .field-label label, .gen-field .field-label > span:first-child { min-width: 0; }
.gen-num {
  display: inline-flex; align-items: center; flex: none; height: 32px; padding: 0 8px 0 2px;
  border: 1px solid var(--control-border); border-radius: 8px; background: var(--surface);
}
.gen-num:focus-within { border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.gen-num-input {
  width: 66px; height: 30px; padding: 0 4px; border: 0; background: transparent; outline: none;
  text-align: right; font-family: var(--mono); font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.gen-num-input:focus-visible { outline: none; }
.gen-num-unit { min-width: 1.5em; font-size: 12px; font-weight: 600; color: var(--muted); }
.gen-num-unit:empty { display: none; }
.gen-help { margin-top: 6px; }
.gen-switch { display: flex; justify-content: space-between; width: 100%; white-space: normal; }
.gen-select { display: flex; }
.gen-select select { width: 100%; }

.gen-stage {
  position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: 22px minmax(0, 1fr);
  height: clamp(300px, 58vh, 600px); overflow: hidden;
  border-radius: var(--r-l); border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.gen-ruler-corner, .gen-ruler { background: var(--surface-2); }
.gen-ruler-corner {
  grid-column: 1; grid-row: 1; display: grid; place-items: center;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  font-size: 9.5px; font-weight: 700; color: var(--muted-strong);
}
.gen-ruler { overflow: hidden; min-width: 0; min-height: 0; }
.gen-ruler--x { grid-column: 2; grid-row: 1; border-bottom: 1px solid var(--border); }
.gen-ruler--y { grid-column: 1; grid-row: 2; border-right: 1px solid var(--border); }
.gen-ruler-svg { max-width: none; }
.gen-ruler-minor { fill: none; stroke: var(--border-strong); stroke-width: 1; }
.gen-ruler-major { fill: none; stroke: var(--muted); stroke-width: 1; }
.gen-ruler-num text { fill: var(--muted-strong); font-family: var(--font); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.gen-canvas {
  position: relative; grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; overflow: hidden;
  cursor: grab; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none;
}
/* ingrandita: un dito sposta il disegno invece di far scorrere la pagina */
.gen-canvas.is-zoomed { touch-action: none; }
.gen-canvas.is-dragging { cursor: grabbing; }
.gen-canvas:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.gen-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; }
.gen-sheet { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.gen-zoom {
  position: absolute; left: 32px; bottom: 10px; z-index: 1; display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-2);
}
.gen-zoom .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.gen-zoom-value { min-width: 50px; text-align: center; font-family: var(--mono); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gen-fit { --btn-h: 32px; padding: 0 10px; color: var(--text-2); }
.gen-status {
  position: absolute; left: 22px; right: 0; top: 50%; padding: 0 20px; transform: translateY(-50%);
  text-align: center; font-size: 14px; color: var(--muted-strong); pointer-events: none;
}
.gen-under { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 12px; }
.gen-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.gen-legend:empty { display: none; }
.gen-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.gen-legend-swatch { width: 18px; height: 0; border-top: 2px solid; }
.gen-legend-item--cut .gen-legend-swatch { border-color: var(--layer-cut); }
.gen-legend-item--engrave .gen-legend-swatch { border-color: var(--layer-engrave); }
.gen-legend-item--score .gen-legend-swatch { border-color: var(--layer-score); border-top-style: dashed; }
.gen-hint { font-size: 12.5px; color: var(--muted-strong); } /* --muted-strong: contrasto AA (4,5:1) anche sotto l'anteprima */
.gen-hint--touch { display: none; }
@media (pointer: coarse) {
  .gen-hint--mouse { display: none; }
  .gen-hint--touch { display: block; }
}
.gen-warn { margin-top: 12px; }
.gen-warn-list { display: grid; gap: 4px; margin: 0; padding-left: 1.1em; min-width: 0; }
.gen-warn-list li:only-child { list-style: none; margin-left: -1.1em; }

/* ---------- Generatori «Vetro e 3D»: anteprima 3D (js/gen3d.js, js/view3d.js) ---------- */
.gen-stage3d { display: grid; gap: 10px; min-width: 0; }
.gen-stage3d[hidden] { display: none; }
.gen3d-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.gen3d-views { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); }
.gen3d-bar .btn-sm { --btn-h: 32px; padding: 0 10px; }
.gen3d-bar [aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.gen3d-light select { height: 34px; font-size: 13px; }
.gen3d-view {
  position: relative; height: clamp(320px, 60vh, 640px); min-width: 0; overflow: hidden;
  border-radius: var(--r-l); border: 1px solid var(--border); background: #0E1013;
}
.gen3d-canvas { display: block; width: 100%; height: 100%; max-width: none; cursor: grab; touch-action: none; outline: none; }
/* due colonne: il pannello fisso resta dentro la finestra e l'anteprima 3D lascia posto sotto di sé agli
   avvisi e alla prima riga della scheda, che così si vedono mentre si cambiano i parametri; se il
   contenuto è più alto (molti avvisi) scorre il pannello */
@media (min-width: 1081px) {
  .gen-preview-panel { max-height: calc(100vh - var(--topbar-h, var(--header-h)) - 32px); overflow-y: auto; }
  .gen3d-view { height: clamp(240px, calc(100vh - 560px), 600px); }
}
.gen3d-canvas:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
/* anteprima piatta (immagini per il laser, js/gen3d.js setFlat): niente barra né canvas 3D, l'immagine in mm
   su un fondo chiaro; il foglio resta bianco anche nel tema scuro (è la carta o il materiale) */
.gen-stage3d.is-flat .gen3d-bar, .gen-stage3d.is-flat .gen-hint, .gen-stage3d.is-flat .gen3d-canvas { display: none; }
.gen-stage3d.is-flat .gen3d-view { background: var(--bg-tint); }
.gen3d-flat { position: absolute; inset: 0; padding: 10px; }
.gen3d-flat[hidden] { display: none; }
.gen3d-flat-svg { display: block; width: 100%; height: 100%; max-width: none; }
.gen3d-flat-sheet { fill: #FFFFFF; stroke: var(--border-strong); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.gen3d-flat-frame { stroke: var(--border-strong); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.gen3d-check-a { fill: #FFFFFF; }
.gen3d-check-b { fill: #E2E5EA; }
.gen3d-flat .gen-layer path { stroke-width: 1.6px; }
.gen3d-flat-fill path { vector-effect: non-scaling-stroke; }
/* messaggio sopra la scena (errore, calcolo annullato): su un fondo scuro, così gli spigoli del blocco
   non lo attraversano */
.gen3d-view .gen-status {
  left: 50%; right: auto; width: max-content; max-width: calc(100% - 32px); padding: 10px 14px; transform: translate(-50%, -50%);
  border-radius: 10px; background: rgba(14, 16, 19, .88); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); color: #DDE3EE;
}
.gen3d-view .gen-status.is-info { color: #C7CFDC; }
.gen3d-info.is-stale { opacity: .55; }
.gen3d-progress {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 10px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-2);
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.gen3d-progress[hidden] { display: none; }
.gen3d-progress progress { flex: 1 1 120px; min-width: 0; height: 8px; accent-color: var(--laser); }
.gen3d-notes { display: grid; gap: 10px; margin-top: 12px; min-width: 0; }
.gen3d-notes[hidden] { display: none; }
.gen3d-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.gen3d-info[hidden] { display: none; }
.gen3d-info--main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gen3d-info-row { min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
/* le etichette lunghe (tedesco a 320 px, due colonne) vanno a capo dentro la scheda: sillabate con lang, o spezzate */
.gen3d-info dt { font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted-strong); overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.gen3d-info dd { margin: 2px 0 0; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); overflow-wrap: anywhere; }
.gen3d-info-row.is-warn { border-color: var(--warn-border); background: var(--warn-soft); }
.gen3d-info-row.is-warn dd { color: var(--warn); }
.gen3d-chip {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--success-soft); color: var(--success); font-size: 12.5px; font-weight: 700;
}
.gen3d-chip[hidden] { display: none; }
.gen-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--text-2); font-size: 13px; line-height: 1.45; }
.gen-note[hidden] { display: none; }
.gen-note > .ico { flex: none; margin-top: 2px; color: var(--info); }
.gen-under[hidden] { display: none; }

/* Download: «Altri formati» */
.gen-more { position: relative; }
.gen-more[hidden] { display: none; }
.gen-more > summary { list-style: none; cursor: pointer; }
.gen-more > summary::-webkit-details-marker { display: none; }
.gen-more > summary .ico { margin-left: 4px; }
.gen-more-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; display: grid; gap: 2px; min-width: 240px; max-width: calc(100vw - 32px);
  padding: 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-2);
}
.gen-more-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.gen-more-item:hover, .gen-more-item:focus-visible { background: var(--surface-2); }
.gen-more-item:disabled { opacity: .5; cursor: not-allowed; }
.gen-more-ext { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* Parametri: testo, file, seme */
.gen-text-input { width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--control-border); background: var(--surface); color: var(--text); font: inherit; font-size: 15px; }
textarea.gen-text-input { resize: vertical; line-height: 1.4; }
.gen-text-input:focus-visible { outline: none; box-shadow: var(--focus); }
.gen-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.gen-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.gen-file-name { min-width: 0; font-size: 13px; color: var(--muted-strong); overflow-wrap: anywhere; }
.gen-file .btn:focus-within { box-shadow: var(--focus); }
/* «Al massimo {n} righe.» sotto un campo di testo su più righe (js/genui.js): c'è solo quando serve */
.gen-text-limit:empty { display: none; }
.gen-num-row { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.gen-dice { flex: none; }
.gen-field[hidden] { display: none; }

dialog.gen-tips {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0;
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-page);
}
dialog.gen-tips::backdrop { background: var(--overlay); }
.gen-tips-inner { display: flex; flex-direction: column; gap: 10px; padding: 18px 22px 20px; }
.gen-tips-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-right: -8px; }
.gen-tips-step { font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-text); }
.gen-tips-title { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; }
.gen-tips-text { min-height: 4.8em; font-size: 15px; line-height: 1.55; color: var(--text-2); white-space: pre-line; }
.gen-tips-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.gen-dots { display: flex; gap: 8px; }
.gen-dot { position: relative; width: 9px; height: 9px; padding: 0; border: 0; border-radius: 999px; background: var(--border-strong); transition: width .15s var(--ease), background-color .15s var(--ease); }
.gen-dot::after { content: ""; position: absolute; inset: -12px -4px; }
.gen-dot[aria-current="step"] { width: 22px; background: var(--laser); }
.gen-tips-nav { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .local-actions .btn-label { display: none; }
  .topbar .local-actions .btn { width: 36px; padding: 0; }
  /* in intestazione restano solo le icone: i pulsanti con il testo («Aggiorna parametri»,
     citato dai messaggi) stanno nel riquadro sotto il titolo */
  .local-strip { align-items: flex-start; }
  .local-strip-actions { display: flex; width: 100%; padding-left: 28px; }
}
@media (max-width: 1240px) {
  .preview-notes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1080px) {
  .sheet-layout { grid-template-columns: minmax(0, 1fr); }
  .sheet-side { position: static; }
  /* una colonna: prima l'anteprima, poi i comandi */
  .topper-layout { grid-template-columns: minmax(0, 1fr); }
  .topper-preview { position: static; order: -1; }
  .gen-layout { grid-template-columns: minmax(0, 1fr); }
  .gen-preview-panel { position: static; order: -1; }
  .topper-layout > .topper-side, .gen-layout > .gen-side,
  .topper-layout > .topper-preview, .gen-layout > .gen-preview-panel { grid-column: auto; grid-row: auto; }
  /* una colonna: l'anteprima alta quanto serve al disegno (--gen-stage-h da js/genui.js), entro i limiti */
  .gen-stage { height: max(200px, min(var(--gen-stage-h, 600px), clamp(300px, 58vh, 600px))); }
  /* anteprima piatta: alta quanto l'immagine alla larghezza piena (--gen-flat-h da js/gen3d.js), da 200 px
     al 60% dello schermo; senza misure (nessun risultato) resta al 60% */
  .gen-stage3d.is-flat .gen3d-view { height: max(200px, min(var(--gen-flat-h, 60vh), 60vh, 640px)); min-height: 200px; }
  .sheet-items { max-height: none; }
}
@media (max-width: 960px) {
  .hero-main { grid-template-columns: 1fr; }
  .hero-main { min-height: 0; }
  .hero-art { min-height: 0; margin: -8px -24px 0; }
  .hero-art img, :root .hero-art img { position: relative; right: auto; top: auto; transform: none; width: 100%; }
  :root[data-theme="dark"] .hero-art { margin: 4px 0 0; }
  .steps { grid-template-columns: 1fr; }
  .device-picker-label { display: none; }
}
@media (max-width: 960px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-art { margin: 4px 0 0; }
}
@media (max-width: 1023px) {
  /* account: solo l'icona anche sui tablet in verticale (761-1023 px), altrimenti il pulsante con
     l'email esce dall'intestazione e copre il tema; per i lettori di schermo resta «Account: <email>» */
  .account-btn { width: 44px; padding: 0; justify-content: center; max-width: none; }
  .account-btn .account-email, .account-btn .chev { display: none; }
}
@media (pointer: coarse) {
  /* touch (anche tablet e portatili sopra i 760 px): bersagli da toccare di almeno 40-44 px.
     Il blocco max-width 760px qui sotto ha le stesse regole e quelle proprie del telefono. */
  .stepper { height: 44px; }
  .stepper button { width: 44px; height: 42px; }
  .stepper input { width: 44px; height: 42px; font-size: 16px; }
  .card .btn-add, .qr-downloads .btn { --btn-h: 44px; }
  .tab { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .search-tools .icon-btn { width: 40px; height: 40px; }
  .device-picker { height: 44px; }
  .device-picker select { height: 42px; }
  .preset { height: 40px; padding: 0 12px; }
  .check { height: 40px; }
  .panel-head .btn-ghost, .results-bar .btn-ghost, .page-meta .btn { --btn-h: 40px; }
  .toast-action { height: 40px; }
  .footer-meta button, .footer-meta a { padding: 12px 0; margin: -12px 0; }
  .lang-picker select { height: 40px; font-size: 16px; }
  .account-btn { height: 44px; }
  .pw-toggle { height: 40px; }
  .gen-seg-opt span { height: 40px; }
  .gen-num { height: 40px; }
  .gen-num-input { height: 38px; font-size: 16px; }
  .gen-zoom .icon-btn-sm { width: 40px; height: 40px; }
  .gen-fit, .gen-toolbar .btn-ghost, .gen-file-clear { --btn-h: 40px; }
  .link-btn { padding: 10px 4px; margin: -10px -4px; }
}
@media (max-width: 760px) {
  :root { --header-h: 58px; }
  body { font-size: 15px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 10px; column-gap: 8px; }
  .brand-logo { height: 26px; }
  /* le schede si allargano a tutta la riga; se non ci stanno (amministratori: quattro schede) la
     barra scorre di lato invece di uscire dallo schermo */
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1 0 auto; justify-content: center; padding: 0 12px; }
  .topbar-actions { gap: 6px; }
  .device-picker { height: 36px; padding: 0 8px 0 10px; }
  .device-picker select { height: 34px; max-width: 120px; font-size: 13.5px; }
  .device-picker > .ico:first-child { display: none; }
  .mode-badge { height: 26px; padding: 0 9px; font-size: 12px; }
  .icon-btn { width: 36px; height: 36px; }
  .topbar .local-actions .btn { --btn-h: 36px; }
  .hero { padding-top: 16px; }
  .hero-card { border-radius: 22px; }
  .hero-main { padding: 26px 20px 0; }
  .hero-close { top: 10px; right: 10px; }
  .hero-ctas .btn { flex: 1 1 auto; }
  .steps { padding: 14px; gap: 10px; }
  .step-art { width: 80px; height: 62px; }
  .catalog { padding-top: 24px; }
  .toolbar { padding: 8px; }
  .search { flex-basis: 100%; }
  .search input { height: 46px; font-size: 16px; }
  .kbd { display: none; }
  .filters { width: 100%; }
  .filters .select { flex: 1 1 140px; }
  .filters .select select { width: 100%; height: 42px; }
  .switch { height: 42px; flex: 1 1 100%; justify-content: space-between; }
  .grid { gap: 10px; }
  .card { padding: 14px; }
  dialog.drawer {
    inset: auto 0 0 0; margin: auto 0 0 0; width: 100vw; height: auto; max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }
  dialog.drawer[open] { animation-name: sheet-up; }
  .drawer-inner { max-height: 92dvh; }
  .drawer-body { padding: 18px 16px 28px; }
  .qr-panel { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .qr-info { width: 100%; align-items: stretch; }
  .qr-downloads { justify-content: center; }
  .qr-downloads .btn { flex: 1; }
  .detail-actions { grid-template-columns: 1fr; }
  .sheet-view { padding-top: 20px; }
  .tools-view, .gen-view { padding-top: 20px; }
  .gen-stage { height: max(200px, min(var(--gen-stage-h, 380px), clamp(240px, 44vh, 380px))); }
  .gen-zoom { left: 30px; bottom: 8px; }
  .gen3d-view { height: 60vh; min-height: 260px; }
  .gen3d-bar { gap: 4px; }
  .gen3d-bar .btn-sm { --btn-h: 40px; padding: 0 8px; }
  .gen3d-light select { height: 40px; font-size: 16px; } /* 16 px: iOS non ingrandisce la pagina al tocco */
  /* «Altri formati» accanto al download quando c'è posto, altrimenti a capo; la lista si apre larga
     quanto la riga dei pulsanti (#gen-actions), non quanto il pulsante */
  #gen-actions { position: relative; }
  .gen-more { flex: 1 1 auto; position: static; }
  .gen-more > summary { width: 100%; }
  .gen-more-list { left: 0; right: 0; width: auto; min-width: 0; max-width: none; }
  .tool-art { aspect-ratio: 2 / 1; }
  .gen-seg-opt span { height: 40px; }
  .gen-num { height: 40px; }
  .gen-num-input { height: 38px; font-size: 16px; }
  .gen-zoom .icon-btn-sm { width: 40px; height: 40px; }
  .gen-fit, .gen-toolbar .btn-ghost, .gen-file-clear { --btn-h: 40px; }
  .sheet-actions { width: 100%; }
  /* il pulsante largo almeno quanto il suo testo (icona compresa): se due non stanno su una riga, il
     secondo va a capo; un testo più largo della riga intera va su due righe invece di uscire */
  .sheet-actions .btn {
    flex: 1 1 auto; min-width: auto; height: auto; min-height: var(--btn-h); padding-top: 6px; padding-bottom: 6px;
    white-space: normal; line-height: 1.2; text-align: center;
  }
  .preview { padding: 16px; border-radius: var(--r-l); }
  .sheet-fab.is-visible { display: inline-flex; }
  /* spazio sotto il piè di pagina per il pulsante flottante (50 px + 16 px + il suo margine dal
     fondo): le avvertenze si possono sempre leggere scorrendo fino in fondo */
  .has-fab .footer { padding-bottom: calc(66px + max(16px, env(safe-area-inset-bottom))); }
  .toasts { right: 16px; left: 16px; width: auto; bottom: 80px; }
  .footer-inner { grid-template-columns: 1fr; gap: 16px; }
  .ptable th, .ptable td { padding: 8px 10px; }

  .card.skeleton::after { height: 44px; }
  /* Bersagli da toccare di almeno 40-44 px */
  .stepper { height: 44px; }
  .stepper button { width: 44px; height: 42px; }
  .stepper input { width: 44px; height: 42px; font-size: 16px; } /* 16 px: iOS non ingrandisce la pagina al focus */
  .card .btn-add, .qr-downloads .btn { --btn-h: 44px; }
  .tab { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  /* in intestazione l'interruttore del tema resta 36 px (a 320 px l'intestazione andrebbe su tre
     righe) ma l'area sensibile è di 44 px */
  .topbar .icon-btn { width: 36px; height: 36px; position: relative; }
  .topbar .icon-btn::after { content: ""; position: absolute; inset: -4px; }
  .search-tools .icon-btn { width: 40px; height: 40px; }
  .device-picker { height: 44px; }
  .device-picker select { height: 42px; }
  .preset { height: 40px; padding: 0 12px; }
  .check { height: 40px; }
  .panel-head .btn-ghost, .results-bar .btn-ghost, .page-meta .btn { --btn-h: 40px; }
  .toast-action { height: 40px; }
  .footer-meta button, .footer-meta a { padding: 12px 0; margin: -12px 0; }
  .lang-picker select { height: 40px; font-size: 16px; }
  .qr-compat { align-self: center; }
  /* accesso: una colonna, prima il titolo, poi la scheda, in fondo i tre passi */
  .auth-view { padding-top: 20px; padding-bottom: 32px; }
  .auth-intro h1 { font-size: clamp(27px, 7.4vw, 34px); }
  .auth-card { padding: 22px 18px 20px; border-radius: 20px; }
  .auth-head h2 { font-size: 22px; }
  /* account: solo l'icona (per i lettori di schermo il nome resta «Account: <email>»), alto come
     il selettore della macchina accanto */
  .account-btn { width: 44px; height: 44px; padding: 0; justify-content: center; max-width: none; }
  .account-btn .account-email, .account-btn .chev { display: none; }
  .account { position: static; }
  .account-menu { left: var(--gutter); right: var(--gutter); width: auto; top: 54px; }
  .has-auth .mode-badge { display: none; }
}
@media (max-width: 900px) {
  /* in locale i pulsanti di aggiornamento stanno solo nel riquadro sotto il titolo: in intestazione
     non c'è posto (tra 761 e 900 px la pagina scorreva di lato) */
  .topbar .local-actions { display: none !important; }
}
@media (max-width: 560px) {
  .card.skeleton { min-height: 174px; }
  .card.skeleton::after { display: none; }
  .detail-head { grid-template-columns: 104px minmax(0, 1fr); gap: 14px; }
  .detail-caption { font-size: 11px; }
  /* colore su una riga sua (a capo il "·" finiva in testa alla riga) */
  .detail-color { flex-basis: 100%; }
  .detail-family-label + .detail-color::before { content: none; }
  .detail-title { font-size: 20px; }
  .local-strip-name { display: none; }
  /* striscia del server locale compatta: testo breve accanto all'icona, pulsanti affiancati */
  .local-strip { padding: 10px 12px; gap: 6px 8px; }
  .local-strip .ls-lead { display: none; }
  .local-strip-actions { padding-left: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .local-strip-actions .btn { padding: 0 8px; min-width: 0; }
  /* tabella dei parametri senza scorrimento laterale: «Altro» va su una riga sotto la lavorazione */
  .ptable { min-width: 0; table-layout: auto; }
  .ptable col { width: auto; }
  .ptable col.c-extra, .ptable th.extra, .ptable td.extra { display: none; }
  .ptable tr.ptable-sub { display: table-row; }
  .ptable tbody tr.ptable-sub td {
    border-top: 0; padding-top: 0; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.35;
  }
  /* card compatte: immagine quadrata a sinistra, testo a destra */
  .card {
    display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px;
    grid-template-areas: "tile title id" "tile fam fam" "tile meta meta" "foot foot foot";
    grid-template-rows: auto auto 1fr auto;
    padding: 14px;
  }
  .card-top { display: contents; }
  .card > .card-top > .card-media, .card > .card-top > .sk-media {
    grid-area: tile; width: 64px; height: 64px; aspect-ratio: auto; border-radius: 12px !important; align-self: start;
  }
  .card-media.is-icon .cat-tile { width: 60%; }
  .card-id, .card-top > .card-id, .card-top > .sk-id { grid-area: id; align-self: start; margin-left: 0; position: static; box-shadow: none; }
  .card-top > .card-id { background: var(--surface-3); color: var(--text-2); }
  .card-title { grid-area: title; align-self: center; }
  .card-family { grid-area: fam; margin-top: 0; }
  .card-meta { grid-area: meta; align-self: start; }
  .card-foot { grid-area: foot; padding-top: 2px; }
  .card:hover { transform: none; }
  .hero-art img, :root .hero-art img { max-height: 230px; object-fit: contain; object-position: center; }
  .sheet-item { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tile text" "ctrl ctrl"; row-gap: 8px; padding: 10px 8px; }
  .sheet-item > .cat-tile { grid-area: tile; }
  .sheet-item-text { grid-area: text; }
  .sheet-item-ctrl { grid-area: ctrl; justify-content: space-between; padding-left: 46px; }
  .sheet-items { padding: 0 8px 4px; }
  .sheet-item + .sheet-item { border-top: 1px solid var(--border); border-radius: 0; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 380px) {
  /* telefoni stretti: logo e controlli più compatti, così «Locale»/«Web» resta scritto e
     l'intestazione sta su due righe; se non basta si accorcia il nome della macchina */
  .brand-logo { height: 22px; }
  .topbar-inner { column-gap: 6px; }
  .topbar-actions { gap: 4px; flex: 1 1 0; min-width: 0; justify-content: flex-end; }
  .device-picker { flex: 0 1 auto; min-width: 0; padding: 0 6px 0 8px; }
  .device-picker select { flex: 0 1 auto; min-width: 48px; }
  .card.skeleton { min-height: 174px; }
  /* le quattro colonne dei parametri stanno anche in 286 px (telefono da 320 px) */
  .ptable { font-size: 13px; }
  .ptable th, .ptable td { padding: 8px 5px; }
  .ptable thead th { font-size: 11.5px; }
}
@media (max-width: 400px) {
  /* le tre schede sopra l'anteprima 3D o piatta: due per riga (la terza sotto), così il testo non va a
     capo su tre o quattro righe dentro 90 px */
  .gen3d-info--main { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  /* barra dello zoom più compatta: anche «Einpassen» (tedesco) resta dentro l'anteprima da 288 px */
  .gen-zoom { left: 26px; max-width: calc(100% - 30px); }
  .gen-zoom-value { min-width: 42px; }
  .gen-fit { padding: 0 8px; }
  /* pulsanti affiancati della striscia locale: a vista «Catalogo» / «Parametri», per i lettori di
     schermo resta «Aggiorna …» */
  .local-strip-actions .ls-full {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .local-strip-actions .ls-short { display: inline; }
}
@media (max-width: 1180px) {
  /* tre schede (quattro per gli amministratori): «Foglio etichette» diventa «Foglio», le schede e il
     pulsante dell'account si stringono, così l'intestazione sta in una riga sui portatili piccoli e sui
     tablet e le schede in una riga anche su un telefono da 320 px */
  .tab-more { display: none; }
  .tab { padding: 0 12px; }
  .account-btn { max-width: 160px; }
}
@media (min-width: 761px) and (max-width: 900px) {
  /* tablet in verticale: anche così le schede non stanno accanto ai comandi, vanno su una riga sotto
     come sul telefono */
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 10px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1 0 auto; justify-content: center; }
}
@media (max-width: 420px) {
  /* «Locale» / «Web» restano scritti: un pallino colorato da solo non dice nulla */
  .mode-badge { padding: 0 8px; gap: 5px; font-size: 11.5px; }
  .sheet-summary .stat b { font-size: 19px; }
  .chip { height: 38px; }
}

/* ---------- Movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
  .card:hover, .tool-card:hover { transform: none; }
}

/* ---------- Contrasto elevato ---------- */
@media (forced-colors: active) {
  .chip[aria-pressed="true"], .tab[aria-current="page"] { outline: 2px solid CanvasText; }
  .check input, .switch input, .auth-consent input { opacity: 1; position: static; width: auto; height: auto; }
  .count-badge { border: 1px solid CanvasText; }
}

/* ==========================================================================
   Stampa: solo il foglio etichette, a grandezza reale.
   ========================================================================== */
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; min-height: 0 !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .print-page {
    position: relative; width: 210mm; height: 296.8mm; overflow: hidden; margin: 0; padding: 0;
    break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;
  }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page svg { display: block; width: 210mm; height: 297mm; }
  .print-empty { padding: 20mm; font: 14pt/1.4 Helvetica, Arial, sans-serif; color: #15171C; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
