/* ─── Font scritto a mano di Paolo (ha gli accenti italiani; mancano á í ó ú ñ … ·) ─── */
@font-face {
  font-family: 'Myfont';
  src: url('assets/fonts/myfont.ttf') format('truetype');
  font-display: swap;
  /* Il disegno è piccolo rispetto al corpo: lo ingrandiamo qui, così le dimensioni nel resto del CSS restano confrontabili */
  size-adjust: 150%;
}

/* ─── Reset ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Tokens ─── */
:root {
  --bg: #F7F6F2;
  --panel: #FFFFFF;
  --panel2: #F2F1ED;
  --text: #1A1A18;
  --mid: #5A5A55;
  --muted: #9A9A92;
  --accent: #e95732;
  --accent-soft: #F0E8E4;
  --accent-tint: color-mix(in srgb, var(--accent) 28%, var(--window));
  --border: #E2E1DC;
  --border-d: #C8C7C0;
  --dot: #D0CFC8;
  --window: #FFFFFF;
  /* Tre font, ognuno con un ruolo:
     --type = contenuto (la voce di Paolo: testi e titoli delle finestre, risposte dell'AI)
     --sans = interfaccia (barra, pulsanti, tooltip, chat, etichette delle finestre)
     --hand = annotazioni a mano (post-it, didascalie, note sul canvas) */
  --type: 'Courier Prime', 'Courier New', monospace;
  --sans: 'DM Sans', sans-serif;
  --hand: 'Myfont', 'Comic Sans MS', cursive;

  /* Scala tipografica: note/etichette · testo · apertura/sottotitoli · titoli · titolo di About */
  --fs-note: 11px;
  --fs-body: 13px;
  --fs-lead: 15px;
  --fs-title: 20px;
  --fs-hero: 30px;
  /* Font a mano (già ingrandito da size-adjust) */
  --fs-hand-s: 15px;
  --fs-hand-m: 18px;
  --fs-hand-l: 28px;
  --fs-hand-xl: 40px;

  /* Angoli: etichette e dettagli · finestre, riquadri e pulsanti · pillole e pallini */
  --r-s: 4px;
  --r-m: 10px;
  --r-full: 999px;

  /* Spaziature */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
}

[data-theme="dark"] {
  --bg: #141412;
  --panel: #1E1E1C;
  --panel2: #252522;
  --text: #F0EFE9;
  --mid: #A0A098;
  --muted: #606058;
  --accent: #e95732;
  --accent-soft: #2A1F1A;
  --border: #2E2E2A;
  --border-d: #3E3E3A;
  --dot: #262622;
  --window: #1E1E1C;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Barra in alto (prototipo proto/topbar) ───
   Avatar = About, staccato; pillola con icona + nome delle sezioni (rif. jedmund.com). */
#topbar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100;
}

/* Avatar disegnato: al passaggio del mouse si ingrandisce e fa l'occhiolino (dissolvenza tra due immagini) */
.tb-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 20px rgba(0, 0, 0, .06);
  cursor: pointer;
  transition: transform .28s cubic-bezier(.34, 1.56, .64, 1), box-shadow .15s;
}

.tb-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
}

.tb-avatar-wink {
  opacity: 0;
  transition: opacity .15s ease-out;
}

.tb-avatar:hover {
  transform: scale(1.1);
}

.tb-avatar:hover .tb-avatar-wink {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tb-avatar {
    transition: none;
  }

  .tb-avatar:hover {
    transform: none;
  }
}

.tb-pill {
  display: flex;
  gap: 2px;
  padding: 5px;
  /* Semi-trasparente: le finestre che passano sotto si intravedono invece di sparire. */
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: 0 2px 20px rgba(0, 0, 0, .06);
}

.tb-item {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-full);
  background: none;
  font-family: var(--sans);
  font-size: var(--fs-body);
  color: var(--mid);
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tb-item svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex-shrink: 0;
}

.tb-item:hover {
  background: var(--panel2);
  color: var(--text);
}

/* Sezione già aperta sul canvas */
.tb-item.is-open {
  background: var(--accent-soft);
  color: var(--accent);
}

.tb-avatar.is-open {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 20px rgba(0, 0, 0, .06);
}

.tb-item:focus-visible,
.tb-avatar:focus-visible,
#bottom-right-controls .sb-btn:focus-visible,
#bottom-left-controls .sb-btn:focus-visible,
.brc-export:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sb-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: var(--r-m);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .15s;
  position: relative;
}

.sb-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.sb-btn:hover {
  background: var(--panel2);
  color: var(--text);
}

.sb-btn.sb-danger:hover {
  background: #FEE9E4;
  color: #C04030;
}

[data-theme="dark"] .sb-btn.sb-danger:hover {
  background: #2A1410;
  color: #E07055;
}

/* theme icon toggle */
[data-theme="light"] .icon-dark {
  display: none;
}

[data-theme="dark"] .icon-light {
  display: none;
}

/* ─── Tooltip ─── */
#tooltip {
  position: fixed;
  left: 0;
  top: 0;
  background: var(--text);
  color: var(--panel);
  font-family: var(--sans);
  font-size: var(--fs-note);
  padding: 5px 10px;
  border-radius: var(--r-m);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
  z-index: 9999;
}

#tooltip.show {
  opacity: 1;
}

/* ─── Canvas ─── */

#canvas-container:active {
  cursor: grabbing;
}

/* ─── Bottom Right Controls ─── */
#bottom-right-controls {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
}

/* Zoom: − percentuale + in un'unica pillola */
.zoom-control {
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  box-shadow: 0 2px 20px rgba(0, 0, 0, .06);
  overflow: hidden;
}

#zoom-indicator {
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--muted);
  min-width: 40px;
  text-align: center;
  user-select: none;
}

.zoom-btn {
  width: 30px;
  height: 100%;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: var(--fs-lead);
  line-height: 1;
  color: var(--mid);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.zoom-btn:hover {
  background: var(--panel2);
  color: var(--text);
}

.zoom-btn:disabled {
  opacity: .35;
  cursor: default;
  background: none;
}

.zoom-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ─── Chat trigger ─── */

@keyframes tring {
  0% {
    transform: translate(-50%, -50%) scale(.85);
    opacity: 0
  }

  30% {
    opacity: 1
  }

  100% {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 0
  }
}

/* ─── Why this portfolio: bottone "?" nascosto in fondo a destra ───
   Forma organica che cambia lentamente, nel colore del testo (l'arancione resta solo al pallino). */
#why-btn {
  position: absolute;
  left: 3000px;
  top: 540px;
  z-index: 5;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--bg);
}

.why-blob {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--text);
  border-radius: 58% 42% 55% 45% / 47% 56% 44% 53%;
  font-family: var(--hand);
  font-size: 36px;
  line-height: 1;
  padding-top: 6px;
  animation: why-morph 9s ease-in-out infinite alternate;
  transition: transform .25s cubic-bezier(.23, 1, .32, 1);
}

#why-btn:hover .why-blob,
#why-btn:focus-visible .why-blob {
  transform: scale(1.08) rotate(-4deg);
}

#why-btn:focus-visible {
  outline: none;
}

#why-btn:focus-visible .why-blob {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text);
}

.why-found {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  white-space: nowrap;
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--mid);
  opacity: 0;
  transform: translate(-50%, 6px) rotate(-3deg);
  transition: opacity .2s ease-out, transform .25s cubic-bezier(.23, 1, .32, 1);
  pointer-events: none;
}

#why-btn:hover .why-found,
#why-btn:focus-visible .why-found {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-3deg);
}

@keyframes why-morph {
  0%   { border-radius: 58% 42% 55% 45% / 47% 56% 44% 53%; }
  50%  { border-radius: 44% 56% 46% 54% / 56% 45% 55% 44%; }
  100% { border-radius: 52% 48% 41% 59% / 43% 52% 48% 57%; }
}

@media (prefers-reduced-motion: reduce) {
  .why-blob { animation: none; }
}

/* Finestra why-this-portfolio.md: una cartella "inversa" (colori del testo e dello sfondo scambiati,
   come la barra delle risposte dell'AI), con la linguetta come my-ai-setup.md in How I work.
   La barra della finestra fa da linguetta: si trascina e si chiude da lì. */
.cwin[data-section="why"] {
  --f-bg: var(--text);
  --f-fg: var(--bg);
  --f-mid: color-mix(in srgb, var(--f-fg) 68%, var(--f-bg));
  --f-line: color-mix(in srgb, var(--f-fg) 18%, var(--f-bg));
  background: none;
  border: 0;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .10));
}

.cwin[data-section="why"]:hover {
  box-shadow: none;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .14));
}

.cwin[data-section="why"] .cwin-bar {
  width: fit-content;
  max-width: 100%;
  gap: var(--s4);
  padding: 8px 10px 8px 14px;
  background: var(--f-bg);
  border: 0;
  border-radius: var(--r-m) var(--r-m) 0 0;
}

.cwin[data-section="why"] .cwin-label {
  color: var(--f-fg);
  flex: none;
}

.cwin[data-section="why"] .cwin-close {
  color: var(--f-mid);
}

.cwin[data-section="why"] .cwin-close:hover {
  color: var(--f-fg);
  background: var(--f-line);
}

.cwin[data-section="why"] .cwin-body {
  background: var(--f-bg);
  color: var(--f-fg);
  border-radius: 0 var(--r-m) var(--r-m) var(--r-m);
}

.cwin[data-section="why"] .cwin-body::-webkit-scrollbar-thumb {
  background: var(--f-line);
}

.wwhy {
  font-family: var(--type);
  color: var(--f-fg);
}

.wwhy .wy-opening {
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: var(--s5);
  text-wrap: balance;
}

.wwhy .wy-block + .wy-block {
  margin-top: var(--s5);
}

.wwhy h3 {
  font-size: var(--fs-lead);
  font-weight: 700;
  margin-bottom: var(--s2);
}

.wwhy p {
  font-size: var(--fs-body);
  line-height: 1.75;
  text-wrap: pretty;
}

.wwhy p + p {
  margin-top: var(--s2);
}

.wwhy mark {
  background: none;
  color: var(--f-fg);
  font-weight: 700;
}

.wwhy .wy-closing {
  margin-top: var(--s6);
  padding-top: var(--s4);
  border-top: 1px solid var(--f-line);
  color: var(--f-mid);
}

.wwhy .wy-link {
  font: inherit;
  font-weight: 700;
  color: var(--f-fg);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--f-mid);
  transition: text-decoration-color .15s ease;
}

.wwhy .wy-link:hover {
  text-decoration-color: currentColor;
}

/* ─── Canvas windows ─── */
#windows-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cwin {
  position: absolute;
  pointer-events: all;
  background: var(--window);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  box-shadow: 0 2px 18px rgba(0, 0, 0, .07);
  width: 280px;
  overflow: hidden;
  cursor: default;
  transition: box-shadow .15s;
  animation: winpop .28s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes winpop {
  from {
    opacity: 0;
    transform: scale(.88) translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.cwin:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, .11);
}

.cwin.dragging {
  box-shadow: 0 12px 40px rgba(0, 0, 0, .15);
}

.cwin.vibrate {
  animation: win-vibrate 0.4s ease-in-out;
}

@keyframes win-vibrate {

  0%,
  100% {
    translate: 0 0;
  }

  20% {
    translate: -6px 0;
  }

  40% {
    translate: 6px 0;
  }

  60% {
    translate: -4px 0;
  }

  80% {
    translate: 4px 0;
  }
}

.cwin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
  /* Si trascina dalla barra: manina aperta, pugno durante il trascinamento */
  cursor: grab;
  gap: 8px;
}

.cwin.dragging .cwin-bar,
body.is-dragging-window,
body.is-dragging-window * {
  cursor: grabbing !important;
}

/* Il corpo delle finestre si legge e si seleziona (es. per copiare l'email) */
.cwin-body {
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  padding: var(--s5);
}

.cwin-body a,
.cwin-body button {
  cursor: pointer;
}

.cwin-label {
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--text);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwin-ai {
  width: 360px;
}

.cwin-ai .cwin-bar {
  background: var(--text);
  border-bottom-color: var(--text);
}

.cwin-ai .cwin-label {
  color: var(--panel);
  font-size: var(--fs-note);
}

.cwin-ai .cwin-close {
  color: var(--panel);
}

.cwin-ai .cwin-close:hover {
  background: rgba(255, 255, 255, .14);
  color: var(--panel);
}

[data-theme="dark"] .cwin-ai .cwin-bar {
  background: var(--text);
  border-bottom-color: var(--text);
}

[data-theme="dark"] .cwin-ai .cwin-label,
[data-theme="dark"] .cwin-ai .cwin-close,
[data-theme="dark"] .cwin-ai .cwin-close:hover {
  color: var(--bg);
}

[data-theme="dark"] .cwin-ai .cwin-close:hover {
  background: rgba(20, 20, 18, .12);
}

.cwin-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-note);
  color: var(--muted);
  padding: 1px 4px;
  border-radius: var(--r-s);
  flex-shrink: 0;
}

.cwin-close:hover {
  background: var(--border);
  color: var(--text);
}

.cwin-body {
  padding: 15px;
}

/* ── Window: free (AI-generated) ── */
.wfree p {
  font-family: var(--type);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--text);
}

.wfree p+p {
  margin-top: var(--s3);
}

.wfree strong {
  font-weight: 700;
}

/* ── Window: about — testo battuto a macchina, parole chiave nel colore d'accento ── */
.wabout {
  font-family: var(--type);
  color: var(--text);
  padding: 0;
}

/* Saluto che si riscrive nelle tre lingue, ognuna col suo font */
.wabout .ab-hi {
  /* Altezza fissa: cambiando lingua e font il contenuto sotto non si sposta */
  height: 46px;
  line-height: 46px;
  display: flex;
  align-items: center;
  overflow: hidden;
  margin-bottom: 22px;
  color: var(--text);
  white-space: nowrap;
}

.ab-hi[data-font="type"] { font-family: var(--type); font-size: var(--fs-title); }
.ab-hi[data-font="hand"] { font-family: var(--hand); font-size: var(--fs-hand-l); }
.ab-hi[data-font="serif"] { font-family: var(--sans); font-style: italic; font-size: var(--fs-title); }

.ab-caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 3px;
  background: var(--accent);
  opacity: 0;
}

.ab-hi.is-typing .ab-caret {
  opacity: 1;
  animation: caret-blink .9s steps(1) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.wabout .ab-title {
  font-family: var(--type);
  font-weight: 700;
  font-size: var(--fs-hero);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin-bottom: 10px;
  /* Due righe bilanciate ("Technical Product & / Service Designer"), senza "Designer" da solo sotto */
  max-width: 20ch;
}

.wabout .ab-headline {
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 8px;
}

/* Scala: due estremi e il pallino arancione in mezzo */
.ab-scale {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 48px 0 40px;
  font-size: var(--fs-note);
  color: var(--mid);
}

.ab-scale-end {
  flex: 0 0 auto;
  max-width: 120px;
  line-height: 1.3;
}

.ab-scale-end:last-child {
  text-align: right;
}

.ab-scale-track {
  position: relative;
  flex: 1;
  height: 2px;
  background: var(--border-d);
  border-radius: var(--r-s);
}

.ab-scale-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.ab-scale-me {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%) rotate(-3deg);
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--accent);
  white-space: nowrap;
}

.wabout .ab-p {
  font-size: var(--fs-body);
  line-height: 1.8;
  margin-bottom: 18px;
}

.wabout mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

/* Firma finale, staccata dal testo */
.wabout .ab-sign {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px dashed var(--border-d);
  font-size: var(--fs-body);
  line-height: 1.8;
  font-style: italic;
}

.wabout .ab-sign-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-top: 14px;
  font-style: normal;
}

.wabout .ab-sign-row .cv-contact {
  gap: 4px;
}

.ab-signature {
  display: block;
  text-align: right;
  font-family: var(--hand);
  font-style: normal;
  font-size: var(--fs-hand-l);
  color: var(--accent);
  transform: rotate(-4deg);
  margin: 0 12px 4px 0;
}

.wabout .cv-link {
  font-family: var(--type);
  font-size: var(--fs-body);
}

/* Le sezioni più lunghe dello schermo scorrono dentro la finestra */
.cwin-section .cwin-body {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Album di About: polaroid (foto quadrate, cornice uguale) e bigliettini dei colleghi ── */
.polaroid {
  position: absolute;
  pointer-events: all;
  width: 150px;
  padding: 9px 9px 0;
  background: #FDFCF8;
  border-radius: var(--r-s);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10), 0 10px 26px rgba(0, 0, 0, .10);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  animation: polaroid-in .5s cubic-bezier(.22, 1, .36, 1) both;
}

.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 1px;
  pointer-events: none;
}

.polaroid figcaption {
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: #2A2A26;
  text-align: center;
  padding: 5px 0 7px;
  line-height: 1.2;
}

.polaroid.dragging {
  box-shadow: 0 4px 10px rgba(0, 0, 0, .12), 0 18px 40px rgba(0, 0, 0, .16);
}

[data-theme="dark"] .polaroid {
  background: #EAE8E1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 26px rgba(0, 0, 0, .35);
}

.album-note {
  position: absolute;
  pointer-events: all;
  width: 138px;
  padding: 16px 12px 10px;
  background: #FFF6CF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .08), 0 8px 20px rgba(0, 0, 0, .08);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  animation: polaroid-in .5s cubic-bezier(.22, 1, .36, 1) both;
}

/* Nastro adesivo */
.album-note::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 54px;
  height: 16px;
  margin-left: -27px;
  /* nastro di carta tortora, semitrasparente */
  background: rgba(168, 152, 132, .38);
  transform: rotate(-3deg);
}

.album-note-q {
  display: block;
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  line-height: 1.1;
  color: #2A2A26;
}

.album-note-by {
  display: block;
  margin-top: 8px;
  font-family: var(--type);
  font-size: var(--fs-note);
  color: #8A8578;
}

.album-note.dragging {
  box-shadow: 0 4px 10px rgba(0, 0, 0, .12), 0 16px 34px rgba(0, 0, 0, .14);
}

[data-theme="dark"] .album-note {
  background: #EDE3B8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 26px rgba(0, 0, 0, .35);
}

/* Caduta sul canvas: dall'alto, leggermente più grande, e si posa */
@keyframes polaroid-in {
  0% {
    opacity: 0;
    translate: 0 -18px;
    scale: 1.14;
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .polaroid,
  .album-note,
  .postit {
    animation: none;
  }
}

/* ── Window: Projects — i preferiti in alto (quelli con la pagina si aprono), gli altri in fondo, una riga ciascuno ── */
.wprojects {
  font-family: var(--type);
  color: var(--text);
}

.pr-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.pr-list li {
  border-bottom: 1px solid var(--border);
}

.pr-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4) var(--s3);
  margin: 0 calc(-1 * var(--s3));
  border-radius: var(--r-s);
  color: inherit;
  text-decoration: none;
  outline: none;
}

.pr-main {
  flex: 1;
  min-width: 0;
}

.pr-meta,
.pr-role {
  font-size: var(--fs-note);
  color: var(--muted);
}

.pr-name {
  margin-top: var(--s1);
  font-size: var(--fs-lead);
  font-weight: 700;
  line-height: 1.35;
}

.pr-line {
  margin-top: var(--s1);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--mid);
}

.pr-role {
  margin-top: var(--s2);
}

/* Con la pagina: al passaggio del mouse una fascia nel colore del progetto (--pc) entra da sinistra
   e la freccia si riempie dello stesso colore */
.pr-row.is-open {
  position: relative;
  isolation: isolate;
  cursor: pointer;
  --pcx: var(--pc, var(--accent));
  --pci: #fff;
}

/* Sul tema scuro un progetto può avere un suo colore (--pc-dark) e il colore della freccia (--pc-ink-dark):
   serve a Tree, il cui nero sparirebbe sul fondo scuro */
[data-theme="dark"] .pr-row.is-open {
  --pcx: var(--pc-dark, var(--pc, var(--accent)));
  --pci: var(--pc-ink-dark, #fff);
}

.pr-row.is-open::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: color-mix(in srgb, var(--pcx) 16%, var(--window));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s cubic-bezier(.23, 1, .32, 1);
}

.pr-row.is-open .pr-line {
  color: var(--text);
}

.pr-row.is-open:focus-visible {
  box-shadow: 0 0 0 2px var(--pcx);
}

.pr-row.is-open:hover::before,
.pr-row.is-open:focus-visible::before {
  transform: scaleX(1);
}

.pr-row.is-open:hover .sq-arrow,
.pr-row.is-open:focus-visible .sq-arrow {
  background: var(--pcx);
  border-color: var(--pcx);
  color: var(--pci);
}

@media (prefers-reduced-motion: reduce) {
  .pr-row.is-open::before {
    transition: opacity .2s ease-out;
    transform: none;
    opacity: 0;
  }

  .pr-row.is-open:hover::before,
  .pr-row.is-open:focus-visible::before {
    opacity: 1;
  }
}

.pr-note {
  margin: var(--s6) 0 var(--s2);
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--mid);
  transform: rotate(-2deg);
  transform-origin: left;
}

.pr-others {
  list-style: none;
  border-top: 1px solid var(--border);
}

.pr-others li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-note);
  line-height: 1.5;
}

.pr-o-name {
  color: var(--text);
}

.pr-o-meta {
  flex: 0 0 auto;
  color: var(--muted);
  text-align: right;
}

/* ── Window: Side quest — la storia di arrampico.male e i prodotti nati dentro la community ── */
.wside {
  font-family: var(--type);
  color: var(--text);
}

.wside .sq-title {
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.wside .sq-role {
  font-size: var(--fs-note);
  color: var(--mid);
  margin: var(--s2) 0 var(--s5);
}

.wside .sq-p {
  font-size: var(--fs-body);
  line-height: 1.8;
}

.wside mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

.wside .sq-note {
  margin: var(--s6) 0 var(--s2);
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--mid);
  transform: rotate(-2deg);
  transform-origin: left;
}

/* Lista dei prodotti: righe separate da una linea; al passaggio del mouse compaiono le foto */
.sq-list {
  list-style: none;
  border-top: 1px solid var(--border);
  margin-bottom: var(--s5);
}

.sq-list li {
  border-bottom: 1px solid var(--border);
}

.sq-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4) var(--s3);
  margin: 0 calc(-1 * var(--s3));
  border-radius: var(--r-s);
  color: inherit;
  text-decoration: none;
  cursor: default;
  outline: none;
}

.sq-row:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.sq-row-main {
  flex: 1;
  min-width: 0;
}

.sq-name {
  font-size: var(--fs-lead);
  font-weight: 700;
  line-height: 1.35;
}

.sq-row .hw-tools {
  margin-top: var(--s1);
}

.sq-text {
  margin-top: var(--s2);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--mid);
}

/* Grab: l'unica riga che si apre. Più alta, freccia sempre visibile, colore al passaggio del mouse */
.sq-row.is-open {
  padding-top: var(--s5);
  padding-bottom: var(--s5);
  cursor: pointer;
  transition: background-color .2s ease-out;
}

.sq-row.is-open .sq-name {
  font-size: var(--fs-title);
}

.sq-row.is-open .sq-text {
  color: var(--text);
}

.sq-open {
  display: inline-block;
  margin-top: var(--s2);
  font-size: var(--fs-note);
  color: var(--accent);
}

.sq-arrow {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-d);
  color: var(--text);
  transition: background-color .2s ease-out, border-color .2s ease-out, color .2s ease-out;
}

.sq-arrow svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sq-row.is-open:hover,
.sq-row.is-open:focus-visible {
  background: var(--accent-tint);
}

.sq-row.is-open:hover .sq-arrow,
.sq-row.is-open:focus-visible .sq-arrow {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Le foto della riga: dentro la card, sopra o sotto la riga, affiancate e appena sovrapposte; non intercettano il mouse */
#sq-preview {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  pointer-events: none;
  translate: var(--px, 0) var(--py, 0);
}

#sq-preview img {
  flex: 0 0 auto;
  height: 150px;
  width: auto;
  max-width: 230px;
  border: 6px solid #FDFCF8;
  border-radius: var(--r-s);
  /* ombra leggera e larga: le foto sembrano appoggiate, non incollate sopra */
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px -6px rgba(0, 0, 0, .10);
  rotate: 0deg;
  scale: .92;
  opacity: 0;
  transition: opacity .2s ease-out, scale .3s cubic-bezier(.22, 1, .36, 1), rotate .3s cubic-bezier(.22, 1, .36, 1);
}

/* Sovrapposizione leggera: ogni foto copre solo il bordo della precedente */
#sq-preview img + img {
  margin-left: -20px;
}

#sq-preview.is-shown img {
  opacity: 1;
  scale: 1;
  rotate: var(--r);
  transition-delay: var(--d);
}

@media (prefers-reduced-motion: reduce) {
  #sq-preview,
  #sq-preview img {
    transition: none;
  }
}

.wside .sp-links {
  display: flex;
  gap: var(--s2);
}

.sp-link {
  font-family: var(--type);
  font-size: var(--fs-body);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border-d);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-full);
  transition: all .15s;
}

.sp-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Window: workstyle (sidebar) ── */
/* ── Window: How I work — prima (catena con i muri) e dopo (tappe che si sovrappongono) ── */
.whow {
  font-family: var(--type);
  color: var(--text);
  padding: 0;
}

.whow .hw-p {
  font-size: var(--fs-body);
  line-height: 1.8;
  margin-bottom: 22px;
}

.whow mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

.hw-steps {
  list-style: none;
  position: relative;
}

/* Filo che unisce le tappe */
.hw-steps::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 14px;
  bottom: 40px;
  border-left: 1px dashed var(--border-d);
}

.hw-step {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

.hw-num {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--window);
  border: 1px solid var(--border-d);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-body);
  display: grid;
  place-items: center;
}

/* Il ciclo: freccia di ritorno dalla tappa 4 alla 1, sul lato sinistro */
.hw-steps {
  padding-left: 34px;
}

.hw-steps::before {
  left: 47px;
}

.hw-return {
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 60px;
  width: 30px;
  border: 1px dashed var(--border-d);
  border-right: none;
  border-radius: 16px 0 0 16px;
}

/* Punta della freccia, entra nel pallino 1 */
.hw-return::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--mid);
  border-right: 1px solid var(--mid);
  transform: rotate(45deg);
}

.hw-return span {
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-family: var(--hand);
  font-size: var(--fs-hand-s);
  color: var(--mid);
  white-space: nowrap;
  background: var(--window);
  padding: 0 6px;
}

.hw-step h3 {
  font-family: var(--type);
  font-size: var(--fs-lead);
  font-weight: 700;
  line-height: 28px;
  margin-bottom: 4px;
}

.hw-step p {
  font-size: var(--fs-body);
  line-height: 1.75;
}

.hw-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.hw-tools span {
  font-size: var(--fs-note);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--mid);
}

/* my-ai-setup.md: un piccolo file dentro la card */
.hw-file {
  margin-bottom: 24px;
}

.hw-file-tab {
  display: inline-block;
  font-size: var(--fs-note);
  padding: 5px 12px;
  background: var(--panel2);
  border: 1px solid var(--border-d);
  border-bottom: none;
  border-radius: var(--r-m) var(--r-m) 0 0;
  color: var(--text);
}

.hw-file-body {
  border: 1px solid var(--border-d);
  border-radius: 0 var(--r-m) var(--r-m) var(--r-m);
  padding: 14px 16px;
  background: var(--panel2);
}

.hw-file-body p {
  font-size: var(--fs-body);
  line-height: 1.75;
}

.whow .hw-file-body .hw-limits {
  font-weight: 700;
  margin-top: 12px;
}

/* Nota a mano in fondo a How I work */
.whow .hw-note {
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  line-height: 1.35;
  color: var(--accent);
  margin-top: 22px;
  transform: rotate(-1deg);
}

/* ── Post-it attorno a How I work ── */
.postit {
  position: absolute;
  pointer-events: all;
  width: 180px;
  padding: 16px 16px 18px;
  color: #2A2A26;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .08), 0 10px 22px rgba(0, 0, 0, .09);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  animation: polaroid-in .5s cubic-bezier(.22, 1, .36, 1) both;
}

.postit-t {
  display: block;
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  line-height: 1.2;
  margin-bottom: 7px;
  /* Myfont non ha il grassetto: lo simula un contorno */
  -webkit-text-stroke: .6px currentColor;
}

.postit-b {
  display: block;
  font-family: var(--hand);
  font-size: var(--fs-hand-s);
  line-height: 1.3;
}

.postit-blue { background: #D5EAF8; }
.postit-green { background: #DCF1C9; }
.postit-pink { background: #F9D8EA; }
.postit-lilac { background: #E4DCF6; }
.postit-peach { background: #FFE0C4; }
.postit-mint { background: #CDEFE3; }

.postit.dragging {
  box-shadow: 0 4px 10px rgba(0, 0, 0, .12), 0 16px 34px rgba(0, 0, 0, .14);
}

[data-theme="dark"] .postit {
  filter: brightness(.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 26px rgba(0, 0, 0, .35);
}

/* ── Window: Experience + contatti in About ── */
.wcv .cv-section {
  margin-bottom: var(--s5);
}

.wcv .cv-section:last-child {
  margin-bottom: 0;
}

.cv-heading {
  font-family: var(--type);
  font-size: var(--fs-note);
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: var(--s3);
}

.cv-item {
  font-family: var(--type);
  font-size: var(--fs-body);
  color: var(--text);
  margin-bottom: var(--s3);
  line-height: 1.45;
}

.cv-item span {
  font-family: var(--type);
  color: var(--muted);
  font-size: var(--fs-note);
  display: block;
  margin-top: 2px;
}

.cv-contact {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cv-link {
  font-family: var(--type);
  font-size: var(--fs-body);
  color: var(--accent);
  text-decoration: none;
}

/* ─── Chat dialog ─── */

.dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.dots span {
  width: 4px;
  height: 4px;
  background: var(--muted);
  border-radius: 50%;
  animation: db 1.2s ease-in-out infinite;
}

.dots span:nth-child(2) {
  animation-delay: .15s;
}

.dots span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes db {

  0%,
  60%,
  100% {
    transform: translateY(0)
  }

  30% {
    transform: translateY(-4px)
  }
}

#chat-input:focus {
  border-color: var(--border-d);
}

::-webkit-scrollbar {
  width: 3px;
}

/* Il binario si ferma prima degli angoli stondati, così la barra non esce dai bordi */
::-webkit-scrollbar-track {
  background: transparent;
  margin: var(--r-m) 0;
}

::-webkit-scrollbar-thumb {
  background: var(--border-d);
  border-radius: var(--r-s);
}

/* ─── Chat bar — bottom anchored ─── */
#chat-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 580px;
  max-width: calc(100vw - 48px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: bar-rise .25s cubic-bezier(.34, 1.56, .64, 1) both;
}

#chat-bar.hidden {
  display: none;
}

#chat-bar.closing {
  animation: bar-fall .22s cubic-bezier(.36, 0, .66, -0.56) both;
}

@keyframes bar-rise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes bar-fall {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
}

#chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  /* 14px + i 2px del campo: il cursore a campo vuoto non finisce sul bordo e non viene tagliato */
  padding: 10px 10px 10px 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .1);
}

#chat-input-wrap.is-multiline {
  align-items: flex-end;
}

#chat-input {
  transition: border-color .15s;
  border-radius: var(--r-m);
  flex: 1;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: var(--fs-lead);
  color: var(--text);
  outline: none;
  padding: 0 0 0 2px;
  margin: 0;
  resize: none;
  overflow-y: hidden;
  height: 21px;
  max-height: 160px;
  line-height: 21px;
  caret-color: var(--text);
  display: block;
  box-sizing: content-box;
}

#chat-input::placeholder {
  color: var(--muted);
}

#chat-loading {
  flex-direction: row;
  gap: 10px;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

/* Testo d'attesa accanto ai puntini (compare dopo qualche secondo, vedi WAIT_MESSAGES) */
#chat-wait {
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--muted);
  white-space: nowrap;
}

#chat-wait:empty {
  display: none;
}

/* Domande suggerite sopra la barra di scrittura */
#chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

#chat-suggestions[hidden] {
  display: none;
}

.chat-suggestion {
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--mid);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .05);
  transition: color .15s, border-color .15s, background .15s;
}

.chat-suggestion:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--panel);
}

.chat-suggestion:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#chat-loading.hidden {
  display: none;
}

#chat-send {
  width: 36px;
  height: 36px;
  background: var(--text);
  border: none;
  border-radius: var(--r-m);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}

#chat-send:hover {
  background: var(--accent);
}

/* Icona nel colore dello sfondo: scura sul pulsante chiaro del tema scuro, chiara sul tema chiaro */
#chat-send svg {
  width: 13px;
  height: 13px;
  stroke: var(--bg);
  transition: stroke .15s;
}

#chat-send:hover svg {
  stroke: white;
}

#chat-footer {
  border-top: 1px solid var(--border);
  border-radius: 0 0 20px 20px;
  text-align: center;
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--muted);
  border: none;
  background: none;
  padding: 0;
}

.chat-notice {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  z-index: 420;
  max-width: min(460px, calc(100vw - 48px));
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .14);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.35;
  text-align: center;
  animation: notice-in .18s ease-out both;
}

.chat-notice.is-leaving {
  animation: notice-out .16s ease-in both;
}

/* L'AI chiede un'informazione che manca: al centro, nella voce dell'AI (Courier), resta finché non si risponde */
.chat-ask {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 420;
  width: min(480px, calc(100vw - 48px));
  padding: var(--s6) var(--s6) var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
  text-align: center;
  animation: ask-in .24s cubic-bezier(.2, .8, .2, 1) both;
}

.chat-ask-dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto var(--s4);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-tint);
}

.chat-ask-text {
  font-family: var(--type);
  font-size: var(--fs-lead);
  line-height: 1.5;
  text-wrap: pretty;
}

.chat-ask-hint {
  display: block;
  margin-top: var(--s4);
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--mid);
}

.chat-ask-close {
  position: absolute;
  top: var(--s2);
  right: var(--s3);
  border: none;
  background: none;
  color: var(--mid);
  font-size: 20px;
  line-height: 1;
  padding: var(--s1);
  cursor: pointer;
}

.chat-ask-close:hover {
  color: var(--text);
}

@keyframes ask-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 10px)) scale(.98);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-ask {
    animation: none;
  }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 26, 24, .18);
  animation: confirm-fade .16s ease-out both;
}

.confirm-overlay.hidden {
  display: none;
}

.confirm-dialog {
  width: min(360px, calc(100vw - 48px));
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .18);
}

.confirm-title {
  font-family: var(--type);
  font-size: var(--fs-title);
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 8px;
}

.confirm-copy {
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.4;
  color: var(--mid);
  margin-bottom: 18px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 0 13px;
  font-family: var(--sans);
  font-size: var(--fs-note);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.confirm-secondary {
  background: var(--panel);
  color: var(--mid);
}

.confirm-secondary:hover {
  background: var(--panel2);
  color: var(--text);
}

.confirm-danger {
  background: #C04030;
  border-color: #C04030;
  color: #fff;
}

.confirm-danger:hover {
  background: #A93629;
  border-color: #A93629;
}

@keyframes confirm-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes notice-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

/* ─── Infinite canvas fix — grid lives on container, updated via JS ─── */

/* The container holds the dot grid, JS updates backgroundPosition on pan/zoom */
#canvas-container {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  cursor: grab;
  background-color: var(--bg);
}

/* Griglia a puntini su un livello a sé: così può sfumare (intro) in qualunque browser.
   Dimensione e posizione arrivano da app.js (applyT) come variabili CSS. */
#canvas-container::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1px);
  background-size: var(--grid-size, 28px 28px);
  background-position: var(--grid-pos, 0 0);
  opacity: var(--grid-opacity, 1);
}

/* ─── Home button ─── */
#home-btn svg {
  width: 15px;
  height: 15px;
}

/* ─── PATCH: canvas — no background grid here, handled by container via JS ─── */
#canvas {
  position: absolute;
  transform-origin: 0 0;
  user-select: none;
  background-attachment: local;
  width: 12000px !important;
  height: 8000px !important;
  background-image: none !important;
  background-color: transparent !important;
}

/* ─── PATCH: trigger redesign — matches mockup ─── */
#chat-trigger {
  justify-content: center;
  position: absolute;
  left: 1000px;
  top: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: pointer;
  z-index: 10;
  transform: translateX(-50%) !important;
}

.tr-circle-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

/* Move rings inside circle-wrap */
.tr-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: tring 3s ease-out infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tr-r1 {
  width: 112px;
  height: 112px;
  opacity: .18;
  animation-delay: 0s;
}

.tr-r2 {
  width: 84px;
  height: 84px;
  opacity: .28;
  animation-delay: .7s;
}

.tr-core {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--accent) !important;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 24px rgba(196, 87, 58, .4);
}

#chat-trigger:hover .tr-core {
  transform: scale(1.07);
  box-shadow: 0 6px 32px rgba(196, 87, 58, .55);
  background: var(--accent) !important;
}

/* Ensure trigger hover doesn't override the centering transform */
#chat-trigger:hover {
  transform: translateX(-50%) !important;
}

.tr-text-main {
  text-align: center;
  font-family: var(--type);
  font-size: var(--fs-title);
  color: var(--text);
  line-height: 1.2;
  pointer-events: none;
}

.tr-hint {
  margin-top: 2px;
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--muted);
  letter-spacing: 0.03em;
  pointer-events: none;
}

/* ─── Pulsanti in basso a destra (home, tema, svuota canvas) ─── */
#bottom-right-controls .sb-btn,
#bottom-left-controls .sb-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0, 0, 0, .06);
  color: var(--muted);
}

#bottom-right-controls .sb-btn:hover,
#bottom-left-controls .sb-btn:hover {
  color: var(--text);
  background: var(--panel2);
}

#bottom-left-controls .sb-btn.sb-danger:hover {
  background: #FEE9E4;
  color: #C04030;
}

[data-theme="dark"] #bottom-left-controls .sb-btn.sb-danger:hover {
  background: #2A1410;
  color: #E07055;
}

/* ─── In basso a sinistra: svuota canvas + salva in PDF ─── */
#bottom-left-controls {
  position: fixed;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
}

.brc-export {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--panel);
  box-shadow: 0 2px 20px rgba(0, 0, 0, .06);
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--mid);
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, border-color .15s, opacity .15s;
}

.brc-export svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex-shrink: 0;
}

.brc-export:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.brc-export[aria-disabled="true"] {
  opacity: .45;
  cursor: default;
}

.brc-export[aria-disabled="true"]:hover {
  color: var(--mid);
  border-color: var(--border);
}

/* Sotto questa larghezza l'etichetta finirebbe sotto la barra della chat: resta l'icona */
@media (max-width: 1100px) {
  .brc-export span {
    display: none;
  }

  .brc-export {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

#home-btn.is-away {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 24px rgba(233, 87, 50, .36);
}

#home-btn.is-away:hover {
  background: #d94f2d;
  border-color: #d94f2d;
  color: #fff;
  box-shadow: 0 8px 30px rgba(233, 87, 50, .44);
}

/* ─── AI navigatore: pulsanti sotto le risposte ─── */
.ai-related {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.ai-open {
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color .15s;
}

.ai-open:hover {
  border-color: var(--accent);
}

.ai-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Intro della prima visita ───
   Con html.first-visit (decisa nell'<head>, prima del primo paint) si vede SOLO lo sfondo pieno:
   tutto il resto è nascosto e compare a tappe, una frase alla volta (INTRO_STEPS in content.js),
   con frecce a tratto che si disegnano verso l'elemento di cui parla la frase.
     intro-grid   → griglia + "Drag to move around" (frecce nelle 4 direzioni)
     intro-bar    → barra in alto + "Open a section directly on the canvas" (freccia verso la barra)
     intro-dot    → pallino (quello vero del canvas) + "Ask the orange dot anything" (freccia verso il pallino)
     intro-reveal → tutto il resto; poi si apre About
   Non si salta. Stesso comportamento in chiaro e scuro. I :where() tengono bassa la specificità,
   così le regole di rivelazione vincono senza !important. */
#intro {
  display: none;
}

.first-visit #intro {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 5000;
  cursor: default;
}

/* Tutto nascosto tranne lo sfondo */
.first-visit :where(body > *:not(#intro, #canvas-container, #mobile-gate, #access-gate)),
.first-visit :where(#canvas > *),
.first-visit :where(.tr-text-main, .tr-hint, .tr-ring, .tr-core),
.first-visit #canvas-container::before {
  opacity: 0;
  transition: opacity .6s ease;
}

/* Rivelazione a tappe */
.first-visit.intro-grid #canvas-container::before,
.first-visit.intro-bar #topbar,
.first-visit.intro-dot #chat-trigger,
.first-visit.intro-dot .tr-core,
.first-visit.intro-dot .tr-ring,
.first-visit.intro-reveal :where(body > *, #canvas > *, .tr-text-main, .tr-hint, .tr-ring, .tr-core) {
  opacity: 1;
}

/* Gli anelli hanno un'animazione che imposta l'opacità: parte solo alla loro tappa */
.first-visit:not(.intro-dot) .tr-ring {
  animation: none;
}

/* Il pallino entra con un piccolo rimbalzo e poi pulsa una volta */
.first-visit.intro-dot .tr-core {
  animation: intro-dot 1.3s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes intro-dot {
  0% { transform: scale(.3); }
  40% { transform: scale(1); }
  70% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* Una tappa = frase + frecce, posizionata da app.js sugli elementi veri */
.intro-step {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--mid);
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity .45s ease, transform .45s ease;
}

.intro-step.is-centered {
  transform: translate(-50%, calc(-50% + 6px));
}

.intro-step.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.intro-step.is-centered.is-visible {
  transform: translate(-50%, -50%);
}

/* Prima tappa: le due frasi si scrivono al centro; l'avatar grande compare sopra, con aria,
   verso la fine della prima frase, e fa l'occhiolino prima che parta la guida */
.intro-avatar {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 40px;
  opacity: 0;
  transform: translateY(8px) scale(.92);
  transition: opacity .5s ease-out, transform .5s cubic-bezier(.22, 1, .36, 1);
}

.intro-avatar.is-shown {
  opacity: 1;
  transform: none;
}

.intro-avatar.is-shown.is-winking {
  transform: scale(1.08);
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.intro-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.intro-avatar-wink {
  opacity: 0;
  transition: opacity .15s ease-out;
}

.intro-avatar.is-winking .intro-avatar-wink {
  opacity: 1;
}

.intro-line.intro-hello {
  font-size: var(--fs-hand-xl);
  color: var(--text);
  min-height: 1.3em;
}

.intro-write {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  opacity: 0;
}

.intro-write.is-writing {
  opacity: 1;
}

.intro-write.is-erasing {
  opacity: 0;
  transition: opacity .3s ease;
}

/* A: la frase si scopre da sinistra, un pennino arancione ne segue il bordo */
.intro-write.is-writing {
  animation: write-reveal var(--write-ms) cubic-bezier(.45, .05, .55, .95) both;
}

@keyframes write-reveal {
  from { clip-path: inset(-20% 100% -20% 0); }
  to { clip-path: inset(-20% -4px -20% 0); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-avatar,
  .intro-avatar.is-shown.is-winking {
    transition: opacity .3s;
    transform: none;
  }

  .intro-write.is-writing {
    animation: none;
    opacity: 1;
  }
}

.intro-row {
  display: flex;
  align-items: center;
}

.intro-line {
  font-family: var(--hand);
  font-size: var(--fs-hand-l);
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin: 0 6px;
}

/* Frecce a tratto: si "disegnano" quando la tappa compare */
.ia {
  display: flex;
}

.ia svg {
  overflow: visible;
}

.ia path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset .7s ease .2s;
}

.ia path + path {
  transition-delay: .75s;
  transition-duration: .3s;
}

.intro-step.is-visible .ia path {
  stroke-dashoffset: 0;
}

/* "Drag to move around": frecce nelle 4 direzioni che si allontanano piano, come a dire "ovunque" */
.ia-left { transform: scaleX(-1); }   /* freccia orizzontale specchiata */
.ia-down { transform: scaleY(-1); }   /* freccia verticale specchiata */
.ia-up { margin-bottom: 6px; }
.ia-down { margin-top: 6px; }

.intro-step[data-step="grid"].is-visible .ia-h svg {
  animation: ia-nudge-x 1.2s ease-in-out .9s infinite;
}

.intro-step[data-step="grid"].is-visible .ia-v svg {
  animation: ia-nudge-y 1.2s ease-in-out .9s infinite;
}

@keyframes ia-nudge-x {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

@keyframes ia-nudge-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* "Riduci movimento": stessa sequenza e tempi, solo dissolvenze */
@media (prefers-reduced-motion: reduce) {
  .first-visit.intro-dot .tr-core,
  .first-visit .tr-ring,
  .intro-step[data-step="grid"].is-visible .ia svg {
    animation: none;
  }

  .intro-step,
  .intro-step.is-centered,
  .intro-step.is-visible,
  .intro-step.is-centered.is-visible {
    transform: translate(-50%, 0);
  }

  .intro-step.is-centered,
  .intro-step.is-centered.is-visible {
    transform: translate(-50%, -50%);
  }

  .ia path {
    stroke-dashoffset: 0;
  }
}

/* ─── Password d'accesso ───
   Sopra a tutto: alla prima visita compare dopo la presentazione, sullo sfondo dell'intro;
   alle visite successive copre il canvas, che si intravede sfocato dietro.
   Quattro caselle bianche con il bordo tortora dei bigliettini, ognuna un po' diversa, come disegnate. */
#access-gate {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: ag-in .5s ease-out both;
}

.first-visit #access-gate {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#access-gate.is-leaving {
  opacity: 0;
  transition: opacity .45s ease;
}

.ag-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 460px;
  text-align: center;
}

.ag-text {
  font-family: var(--type);
  font-size: var(--fs-title);
  line-height: 1.5;
  color: var(--text);
  text-wrap: balance;
}

.ag-pin {
  display: flex;
  gap: 14px;
  margin-top: var(--s6);
}

.ag-box {
  width: 62px;
  height: 74px;
  padding: 0;
  border: 2px solid #A89884;
  border-radius: 14px 9px 16px 8px / 9px 15px 8px 14px;
  background: #fff;
  color: #1A1A18;
  font-family: var(--type);
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  caret-color: var(--accent);
  outline: none;
  transition: border-color .15s ease, transform .15s ease;
}

.ag-box:nth-child(2) { border-radius: 9px 15px 8px 16px / 15px 8px 14px 9px; rotate: .8deg; }
.ag-box:nth-child(3) { border-radius: 16px 8px 13px 10px / 8px 13px 10px 16px; rotate: -.6deg; }
.ag-box:nth-child(4) { border-radius: 8px 14px 9px 15px / 14px 9px 16px 8px; rotate: .5deg; }
.ag-box:nth-child(1) { rotate: -.7deg; }

.ag-box:focus {
  border-color: var(--accent);
  transform: translateY(-2px);
}

#access-gate.is-checking .ag-box {
  opacity: .6;
}

#access-gate.is-wrong .ag-pin {
  animation: ag-shake .4s cubic-bezier(.36, .07, .19, .97) both;
}

.ag-msg {
  min-height: 1.4em;
  white-space: pre-line;
  margin-top: var(--s4);
  font-family: var(--hand);
  font-size: var(--fs-hand-m);
  color: var(--accent);
}

.ag-help {
  margin-top: var(--s2);
  font-family: var(--sans);
  font-size: var(--fs-note);
  color: var(--mid);
}

.ag-help a {
  color: var(--accent);
}

@keyframes ag-in {
  from { opacity: 0; }
}

@keyframes ag-shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@media (prefers-reduced-motion: reduce) {
  #access-gate,
  #access-gate.is-wrong .ag-pin {
    animation: none;
  }
}

/* Su mobile non c'è mai (vedi app.js): rete di sicurezza */
@media (pointer: coarse), (max-width: 767px) {
  #access-gate {
    display: none;
  }
}

/* ─── Mobile gate ───
   Il canvas funziona solo con mouse + schermo grande (nessun supporto touch).
   Su dispositivi con puntatore "coarse" o schermi stretti il canvas resta visibile dietro,
   sfocato e non interattivo, con sopra una finestra che rimanda al desktop e ai contatti.
   I colori seguono i token di [data-theme], quindi anche il tema scuro. */
#mobile-gate {
  display: none;
}

@media (pointer: coarse), (max-width: 767px) {
  body > *:not(#mobile-gate) {
    pointer-events: none !important;
    user-select: none;
  }

  #chat-bar,
  #tooltip,
  #clear-confirm,
  #intro,
  .chat-notice,
  .chat-ask {
    display: none !important;
  }

  #mobile-gate {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  .mg-window {
    width: 100%;
    max-width: 380px;
    margin: auto;
    background: var(--window);
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    box-shadow: 0 12px 48px rgba(0, 0, 0, .12);
    overflow: hidden;
    animation: winpop .4s cubic-bezier(.34, 1.56, .64, 1) both;
  }

  .mg-bar {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--panel2);
  }

  .mg-label {
    font-family: var(--sans);
    font-size: var(--fs-note);
    font-weight: 500;
    color: var(--text);
  }

  .mg-body {
    padding: 16px;
  }

  .mg-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 26px 12px 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background-color: var(--bg);
    background-image: radial-gradient(circle, var(--dot) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center;
  }

  .mg-welcome {
    font-family: var(--sans);
    font-size: var(--fs-note);
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 6px;
  }

  .mg-title {
    font-family: var(--sans);
  font-style: italic;
  line-height: 1.2;
      font-size: var(--fs-title);
    line-height: 1.1;
    color: var(--text);
    text-align: center;
    margin-bottom: 8px;
  }

  .mg-circle {
    transform: scale(.8);
    margin-bottom: 0;
  }

  .mg-text {
  font-family: var(--type);
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--mid);
    text-align: center;
  }

  .mg-text + .mg-text {
    margin-top: 10px;
  }

  .mg-url {
    font-family: var(--type);
    font-size: var(--fs-body);
    color: var(--accent);
    white-space: nowrap;
  }

  .mg-contacts {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .mg-contacts-title {
    font-family: var(--sans);
    font-size: var(--fs-note);
    letter-spacing: .06em;
    color: var(--muted);
    text-align: center;
    margin-bottom: 10px;
  }

  .mg-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mg-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-m);
    background: var(--panel2);
    font-family: var(--type);
    font-size: var(--fs-body);
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  .mg-link span {
    color: var(--muted);
    font-size: var(--fs-note);
    flex-shrink: 0;
  }

  .mg-link:active {
    background: var(--accent-soft);
  }

  @media (prefers-reduced-motion: reduce) {
    .mg-window,
    .mg-circle .tr-ring {
      animation: none;
    }
  }
}

/* ─── Stampa / "Salva come PDF" (Fase 3.1) ───
   Le finestre aperte, una sotto l'altra nell'ordine di apertura, con un'intestazione.
   Sempre in chiaro, indipendentemente dal tema scelto. */
#print-header {
  display: none;
}

@media print {
  #sq-preview {
    display: none;
  }

  @page {
    margin: 16mm;
  }

  :root,
  [data-theme="dark"] {
    --bg: #FFFFFF;
    --panel: #FFFFFF;
    --panel2: #F4F3EF;
    --window: #FFFFFF;
    --text: #1A1A18;
    --mid: #4A4A45;
    --muted: #7A7A72;
    --border: #DDDCD6;
    --accent-soft: #F6E9E4;
  }

  html,
  body {
    height: auto;
    overflow: visible;
    background: #FFFFFF;
  }

  #topbar,
  #bottom-right-controls,
  #bottom-left-controls,
  #chat-bar,
  #chat-trigger,
  #why-btn,
  #tooltip,
  #clear-confirm,
  #intro,
  #mobile-gate,
  #access-gate,
  .chat-notice,
  .chat-ask,
  .polaroid,
  .album-note,
  .postit,
  .cwin-close,
  .ai-related {
    display: none !important;
  }

  #print-header {
    display: block;
    margin-bottom: 8mm;
    padding-bottom: 4mm;
    border-bottom: 1px solid var(--border);
  }

  .ph-name {
    font-family: var(--type);
    font-size: var(--fs-title);
    color: var(--text);
  }

  .ph-meta {
    font-family: var(--type);
    font-size: var(--fs-note);
    color: var(--muted);
    margin-top: 2px;
  }

  #canvas-container::before {
    display: none;
  }

  #canvas-container,
  #canvas,
  #windows-layer {
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    background: none !important;
  }

  #windows-layer {
    display: flex;
    flex-direction: column;
    gap: 6mm;
  }

  .cwin {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    box-shadow: none !important;
    animation: none !important;
    break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .cwin-body {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Testo solo per lettori di schermo e motori di ricerca (es. l'h1 della home) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
