:root {
  --fondo: #ffffff;
  --card: #ffffff;
  --inchiostro: #111113;
  --grigio: #6f6f77;
  --grigio-chiaro: #a1a1aa;
  --bordo: rgba(17, 17, 19, 0.09);
  --campo: #f4f4f5;
  --binario: #ececef;
  --accento: #2f6bff;
  --alta: 64px;
  --spazio: 8px;
}

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

html, body { height: 100%; }

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

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

/* the box is as tall as the fanned pile, so the open state never leaves it */
.wrap {
  position: relative;
  width: min(340px, calc(100vw - 32px));
  height: calc(var(--alta) * 3 + var(--spazio) * 2 + 14px);
}

.pile { list-style: none; position: absolute; inset: 0; }

.toast {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--alta);
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--bordo);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 8px 24px -10px rgba(17, 17, 19, 0.16);
  transform-origin: 50% 100%;
  overflow: hidden;
  will-change: transform;
}

.toast__in {
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 14px 4px 12px;
}

.file { position: relative; width: 28px; height: 34px; flex: none; }
.file svg, .sum__files svg { width: 100%; height: 100%; overflow: visible; }
.file__sheet { fill: var(--campo); stroke: #d4d4d8; stroke-width: 1.4; }
.file__fold { fill: #fff; stroke: #d4d4d8; stroke-width: 1.4; stroke-linejoin: round; }
.file__line { fill: none; stroke: var(--grigio-chiaro); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.file__tag {
  position: absolute; left: -3px; bottom: 4px;
  padding: 1px 3px; border-radius: 3px;
  background: var(--inchiostro); color: #fff;
  font-size: 7.5px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2;
}

.toast__text { min-width: 0; }
.toast__name {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast__meta {
  margin-top: 2px;
  font-size: 12px; color: var(--grigio);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast__meta.is-error { color: var(--inchiostro); }

.toast__end { position: relative; display: grid; place-items: center end; min-width: 52px; height: 30px; }
.toast__end > * { grid-area: 1 / 1; }
.toast__pct { font-size: 12.5px; font-weight: 600; color: var(--grigio); font-stretch: 100%; }
.toast__check { width: 20px; height: 20px; opacity: 0; overflow: visible; }
.toast__check circle { fill: var(--accento); }
.toast__check path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.retry, .view {
  height: 28px; padding: 0 11px;
  border-radius: 8px; border: 1px solid var(--bordo);
  background: #fff; color: var(--inchiostro);
  font: inherit; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.06);
  cursor: pointer;
}
.retry { opacity: 0; visibility: hidden; }
.retry.is-hover, .view.is-hover { background: var(--campo); }
@media (hover: hover) { .retry:hover, .view:hover { background: var(--campo); } }
.retry:focus-visible, .view:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.bar {
  position: absolute; left: 12px; right: 12px; bottom: 7px;
  height: 3px; border-radius: 3px;
  background: var(--binario);
  overflow: hidden;
}
.bar i {
  display: block; height: 100%; width: 100%;
  border-radius: inherit;
  background: var(--accento);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.bar.is-error i { background: var(--grigio-chiaro); }

.toast--sum { opacity: 0; visibility: hidden; }
.sum__files { position: relative; display: block; width: 44px; height: 34px; }
.sum__files svg { position: absolute; top: 0; width: 26px; height: 32px; }
.sum__files svg:nth-child(1) { left: 0; transform: rotate(-8deg); }
.sum__files svg:nth-child(2) { left: 8px; transform: rotate(-2deg); }
.sum__files svg:nth-child(3) { left: 16px; transform: rotate(5deg); }
.sum__tick { fill: none; stroke: var(--accento); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: var(--inchiostro); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  pointer-events: none; opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  z-index: 50;
}

@media (max-width: 380px) {
  .toast__in { gap: 10px; padding: 0 12px 4px 10px; }
  .toast__name { font-size: 13px; }
  .toast__meta { font-size: 11.5px; }
}
