:root {
  --fondo: #0a0a0a;
  --finestra: #101012;
  --superficie: #17171a;
  --superficie-2: #1d1d21;
  --inchiostro: #ededf0;
  --grigio: #8d8d96;
  --grigio-scuro: #5c5c64;
  --bordo: rgba(255, 255, 255, 0.08);
  --bordo-forte: rgba(255, 255, 255, 0.14);
  --accento: #9b8cff;
  --accento-2: #6ee7dd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.num { font-variant-numeric: tabular-nums; }

.palco {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.finestra {
  position: relative;
  width: min(760px, 94vw);
  height: min(500px, 90vh);
  background: var(--finestra);
  border: 1px solid var(--bordo);
  border-radius: 22px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* la chat */
.chat {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 3.4vmin, 20px);
  overflow: hidden;
}

.chat-testa {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: clamp(8px, 2.4vmin, 14px);
  border-bottom: 1px solid var(--bordo);
  white-space: nowrap;
}

.globo {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff 0 8%, #c9c0ff 20%, var(--accento) 52%, #3a2f8f 100%);
  box-shadow: 0 0 18px -4px rgba(155, 140, 255, 0.7);
}

.chat-nome { display: flex; flex-direction: column; line-height: 1.15; }
.chat-nome strong { font-size: 13.5px; font-weight: 620; }
.chat-nome span { font-size: 11.5px; color: var(--grigio); }

.messaggi {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(8px, 2.2vmin, 14px);
  padding: clamp(8px, 2.4vmin, 16px) 0;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  mask-image: linear-gradient(180deg, transparent 0, #000 22px);
}

.bolla--io {
  align-self: flex-end;
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px 16px 4px 16px;
  background: var(--superficie-2);
  border: 1px solid var(--bordo);
  font-size: clamp(12px, 3.2vmin, 13.5px);
  line-height: 1.4;
}

.risposta { display: flex; flex-direction: column; gap: clamp(6px, 1.8vmin, 10px); }
.risposta-testo, .risposta-piede { font-size: clamp(12px, 3.2vmin, 13.5px); line-height: 1.45; color: #d6d6db; }
.risposta-piede { color: var(--grigio); }

/* la card della bozza */
.scheda {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.8vmin, 10px);
  text-align: left;
  padding: clamp(10px, 2.8vmin, 14px);
  border-radius: 14px;
  background: var(--superficie);
  border: 1px solid var(--bordo);
  box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.9);
  transition: border-color 0.25s, background-color 0.25s, box-shadow 0.25s;
}

.scheda-testa { display: flex; align-items: center; gap: 10px; }

.icona-doc {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(155, 140, 255, 0.12);
  border: 1px solid rgba(155, 140, 255, 0.22);
}
.icona-doc svg { width: 17px; height: 17px; fill: none; stroke: var(--accento); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }

.scheda-titolo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.scheda-titolo strong { font-size: clamp(12.5px, 3.3vmin, 14px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scheda-titolo span { font-size: 11.5px; color: var(--grigio); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.apri {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--grigio);
  border: 1px solid var(--bordo);
  transition: color 0.25s, border-color 0.25s, transform 0.3s cubic-bezier(.3, 1.6, .5, 1);
}
.apri svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s cubic-bezier(.3, 1.6, .5, 1); }

.scheda-righe { display: flex; flex-direction: column; gap: 3px; padding-left: 40px; }
.scheda-righe span { font-size: clamp(11px, 3vmin, 12.5px); color: var(--grigio); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (hover: hover) {
  .scheda:hover { border-color: var(--bordo-forte); background: #1a1a1e; }
  .scheda:hover .apri { color: var(--inchiostro); border-color: var(--bordo-forte); }
  .scheda:hover .apri svg { transform: translate(1px, -1px); }
}
.scheda.e-sopra { border-color: var(--bordo-forte); background: #1a1a1e; box-shadow: 0 16px 30px -18px rgba(0, 0, 0, 0.95); }
.scheda.e-sopra .apri { color: var(--inchiostro); border-color: var(--bordo-forte); }
.scheda.e-sopra .apri svg { transform: translate(1px, -1px); }
.scheda.e-premuto { transform: scale(0.985); }
.scheda.e-attiva { border-color: rgba(155, 140, 255, 0.38); background: rgba(155, 140, 255, 0.07); }
.scheda.e-attiva .apri { color: var(--accento); border-color: rgba(155, 140, 255, 0.3); }
.scheda:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.scrivi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: clamp(36px, 9vmin, 44px);
  padding: 0 6px 0 14px;
  border-radius: 14px;
  background: var(--superficie);
  border: 1px solid var(--bordo);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  white-space: nowrap;
}
.scrivi-testo { font-size: 13px; color: var(--grigio-scuro); overflow: hidden; text-overflow: ellipsis; }
.invia {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--superficie-2);
  border: 1px solid var(--bordo);
}
.invia svg { width: 14px; height: 14px; fill: none; stroke: var(--grigio); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* il documento */
.doc {
  position: absolute;
  top: clamp(8px, 2vmin, 12px);
  right: clamp(8px, 2vmin, 12px);
  bottom: clamp(8px, 2vmin, 12px);
  left: calc(var(--colonna, 34%) + 4px);
  visibility: hidden;
  border-radius: 16px;
}

.doc-fondo {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--superficie);
  border: 1px solid var(--bordo);
}

/* il bordo di luce che passa una volta sul documento appena aperto */
.raggio {
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  padding: 1px;
  background: conic-gradient(from var(--angolo, 0deg), transparent 0 64%, var(--accento-2) 76%, var(--accento) 84%, transparent 94%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(155, 140, 255, 0.55));
}

.doc-corpo {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.7vmin, 10px);
  padding: clamp(10px, 2.8vmin, 18px) clamp(12px, 3.2vmin, 22px);
  overflow: hidden;
}

.doc-barra { display: flex; align-items: center; justify-content: space-between; }

.indietro {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px 0 7px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--grigio);
  border: 1px solid var(--bordo);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.25s, border-color 0.25s, transform 0.3s cubic-bezier(.3, 1.6, .5, 1);
}
.indietro svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s cubic-bezier(.3, 1.6, .5, 1); }
@media (hover: hover) {
  .indietro:hover { color: var(--inchiostro); border-color: var(--bordo-forte); }
  .indietro:hover svg { transform: translateX(-2px); }
}
.indietro.e-sopra { color: var(--inchiostro); border-color: var(--bordo-forte); }
.indietro.e-sopra svg { transform: translateX(-2px); }
.indietro.e-premuto { transform: scale(0.95); }
.indietro:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.bozza {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accento);
  background: rgba(155, 140, 255, 0.1);
  border: 1px solid rgba(155, 140, 255, 0.22);
}

.doc-titolo { font-size: clamp(19px, 5.4vmin, 28px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; }
.doc-titolo .lettera { display: inline-block; white-space: pre; }
.doc-meta { font-size: 11.5px; color: var(--grigio); margin-top: -4px; }

.sezione h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--grigio);
  margin-bottom: 5px;
}
.sezione h3 span { text-transform: none; letter-spacing: 0; font-weight: 450; color: var(--grigio-scuro); margin-left: 4px; }
.sezione p { font-size: clamp(12px, 3.1vmin, 13.5px); line-height: 1.45; color: #d6d6db; }

.tabella { width: 100%; border-collapse: collapse; font-size: clamp(11.5px, 3vmin, 12.5px); }
.tabella th { text-align: left; font-weight: 500; color: var(--grigio-scuro); padding: 0 0 4px; border-bottom: 1px solid var(--bordo); }
.tabella td { padding: clamp(3px, 0.9vmin, 5px) 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); color: #d6d6db; }
.tabella td:last-child, .tabella th:last-child { text-align: right; }
.tabella tbody tr { transition: background-color 0.25s; }
.tabella tbody tr td { transition: color 0.25s; }
@media (hover: hover) { .tabella tbody tr:hover td { color: #ffffff; } .tabella tbody tr:hover { background: rgba(255, 255, 255, 0.03); } }
.tabella tbody tr.e-sopra td { color: #ffffff; }
.tabella tbody tr.e-sopra { background: rgba(255, 255, 255, 0.03); }

.sezione--grafico { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grafico {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 1.2vmin, 7px);
  padding-top: 4px;
}
.barra-g {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.barra-g i {
  display: block;
  width: 100%;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, rgba(155, 140, 255, 0.55), rgba(155, 140, 255, 0.18));
  transform-origin: 50% 100%;
}
.barra-g.e-forte i { background: linear-gradient(180deg, var(--accento-2), var(--accento)); box-shadow: 0 0 16px -6px rgba(110, 231, 221, 0.8); }
.barra-g b { font-size: 9.5px; font-weight: 450; color: var(--grigio-scuro); font-variant-numeric: tabular-nums; }

/* la card che vola fino al documento */
.volo {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  border-radius: 14px;
  background: var(--superficie);
  border: 1px solid var(--bordo-forte);
  box-shadow: 0 24px 50px -28px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  pointer-events: none;
}
.volo-titolo {
  position: absolute;
  top: 14px;
  left: 52px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.puntatore {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 5;
  fill: #ffffff;
  stroke: #0a0a0a;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

@media (max-width: 600px) {
  .finestra { border-radius: 18px; }
  .scheda-righe { padding-left: 0; }
}

@media (max-height: 460px) {
  .risposta-piede { display: none; }
  .doc-meta { display: none; }
  .tabella tbody tr:nth-child(3) { display: none; }
}
