/* SPDX-License-Identifier: AGPL-3.0-only — Copyright (C) 2026 Gabriele Falcinelli (https://gabrielefalcinelli.com)
   Termini aggiuntivi (attribuzione, nomi e loghi): ADDITIONAL-TERMS.md */
/* ── DESIGN RIGOROSO (prova, tutti i tool) ──
   Caricato per ultimo, sopra gli stili esistenti (che restano intatti: togliendo questo file si torna a prima).
   Stessi colori e stessi font; cambia l'uso:
   - il colore del tool è un segnale (logo, azione principale, fuoco, selezione), non la struttura;
   - la struttura è fatta di filetti neutri da 1 px, angoli di 2 px, nessun riquadro tratteggiato;
   - testo regolare e etichette medie invece di tutto in grassetto;
   - controlli compatti (32 px) su una griglia di 4/8 px, unità a destra del valore;
   - impostazioni in sezioni come in un pannello di ispezione, dati in colonne con cifre tabulari. */

:root {
  --line: color-mix(in srgb, var(--ink) 13%, var(--bg));
  --line-strong: color-mix(in srgb, var(--ink) 26%, var(--bg));
  --surface: color-mix(in srgb, var(--ink) 3.5%, var(--bg));
  --surface-2: color-mix(in srgb, var(--ink) 7%, var(--bg));
  --text-2: color-mix(in srgb, var(--ink) 72%, var(--bg));
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--bg));
  --radius: 2px;
  --control-h: 32px;
  --pad: 28px;
}

body { font-weight: 400; font-size: 13px; line-height: 1.5; }
strong, b { font-weight: 600; }
a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { color: inherit; text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── STRUTTURA ── */
.app { grid-template-columns: minmax(380px, 400px) 1fr; }
.pane-left { border-right: 1px solid var(--line); background: var(--bg); }
/* Scrollbar nel colore del tool, sottili */
.pane::-webkit-scrollbar { width: 12px; }
.pane::-webkit-scrollbar-track { margin: 0; }
.pane::-webkit-scrollbar-thumb { background: var(--accent); border: 3px solid transparent; border-radius: 99px; background-clip: padding-box; }
@supports not selector(::-webkit-scrollbar) {
  .pane { scrollbar-color: var(--accent) transparent; }
}

/* ── INTESTAZIONE ── */
.site-header { padding: 28px var(--pad) 20px; border-bottom: 1px solid var(--line); }
/* Onda del nome del tool sempre attiva, un po' più veloce della versione 0.2.0 (3 s invece di 4, lettere a 0,15 s
   l'una dall'altra invece di 0,2) */
.logo .tool-word span { animation-duration: 3s; }
.logo .tool-word span:nth-child(2) { animation-delay: 0.15s; }
.logo .tool-word span:nth-child(3) { animation-delay: 0.3s; }
.logo .tool-word span:nth-child(4) { animation-delay: 0.45s; }
.logo .tool-word span:nth-child(5) { animation-delay: 0.6s; }
.logo .tool-word span:nth-child(6) { animation-delay: 0.75s; }
.logo .tool-word span:nth-child(7) { animation-delay: 0.9s; }
.lead { margin-top: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.55; font-weight: 400; }
.lead a { color: var(--ink); }
.donate-btn {
  margin-top: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
}
.donate-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
.instructions-bar { margin-top: 10px; }
.instructions-bar + .instructions-bar { margin-top: 4px; }
.instructions-toggle { color: var(--text-2); font-size: 12px; font-weight: 500; }
.instructions-toggle:hover { color: var(--ink); }
.why-panel, .instructions-panel { padding-top: 12px; }
.why-text, .step-text { color: var(--text-2); font-size: 12px; line-height: 1.55; font-weight: 400; }
.step-text > strong { color: var(--ink); font-weight: 600; }
.step-num {
  width: 16px; height: 16px; margin-bottom: 6px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font-size: 9.5px; font-weight: 600;
}
.instr-warning { color: var(--ink); font-size: 11.5px; font-weight: 500; padding: 8px 10px; border-left: 2px solid var(--accent); background: var(--surface); }
.caps { font-weight: 600; letter-spacing: 0.04em; }

/* ── IMPOSTAZIONI: sezioni separate da filetti ── */
.controls { padding: 0 0 32px; }
.controls > .dropzone { margin: 20px var(--pad) 0; }
.controls > .field-group,
.controls > .toggles,
.controls > .field,
.controls > .grid-2,
.controls > .cover-settings,
.controls > .toggle-row,
.controls > .subsection-title,
.controls > .actions,
.controls > .status,
.controls > .notices,
.controls > footer { margin-left: var(--pad); margin-right: var(--pad); }
.controls > .field-group,
.controls > .toggles { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.field-group + .field-group, .toggles + .field-group { margin-top: 20px; }

.group-title, .subsection-title {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-2);
}
.field { gap: 6px; margin-bottom: 12px; }
.grid-2 { gap: 12px; }
.hint { font-size: 11px; color: var(--muted); }

/* Riquadri tratteggiati → superfici neutre */
.cover-settings {
  padding: 12px 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  animation: none;
}

/* ── "?" ── */
.tooltip-icon {
  width: 14px; height: 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}
.tooltip-icon:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
.tooltip-icon::after {
  border-radius: var(--radius);
  font-weight: 400;
  font-size: 11.5px;
  line-height: 1.5;
  width: 240px;
}

/* ── CAMPI: unità a destra del valore ── */
.input-unit {
  height: var(--control-h);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
}
.input-unit:hover { border-color: var(--muted); }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.unit {
  order: 2;
  flex: 0 0 auto;
  min-width: 44px;
  padding: 0 10px;
  border-right: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
.unit:empty { display: none; }
input[type="number"], input[type="text"] {
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: var(--muted); }

select, .cselect-btn {
  height: var(--control-h);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 30px 0 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: calc(var(--control-h) - 2px);
}
.cselect-btn:hover { border-color: var(--muted); }
.cselect-btn::after {
  content: '';
  right: 11px;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}
.cselect.open .cselect-btn::after { content: ''; transform: translateY(-20%) rotate(-135deg); }
.cselect-btn:focus-visible, .cselect.open .cselect-btn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* Elenco delle scelte: pieno nel colore del tool (come nella versione 0.2.0), forma e misure del nuovo design */
.cselect-list {
  top: calc(100% + 4px);
  padding: 4px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.cselect-list li { padding: 6px 8px; border-radius: var(--radius); }
.cselect-list li:hover,
.cselect-list li[aria-selected="true"]:hover { background: rgba(0, 0, 0, 0.16); }
.cselect-list li[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--on-accent); font-weight: 700; }

/* ── CARICAMENTO DEL PDF ── */
.dropzone {
  gap: 14px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}
.dropzone:hover { border-color: var(--muted); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { flex-basis: 36px; height: 36px; border-radius: var(--radius); background: transparent; color: var(--accent); border: 1px solid var(--line-strong); }
.dz-text strong, #fileName { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.dz-drag, .dropzone small { font-size: 12px; font-weight: 400; color: var(--text-2); }
body.has-file .dropzone { border-style: solid; border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
body.has-file .dz-icon { color: var(--accent); }
body.has-file #fileName { color: var(--ink); }

/* ── INTERRUTTORI ── */
.toggles { margin-top: 0; }
.toggle-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.toggle-row label { color: var(--ink); }
input[type="checkbox"] {
  width: 16px; height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-size: 10px;
}
input[type="checkbox"]:hover { border-color: var(--muted); }
input[type="checkbox"]:checked { border-color: var(--accent); }

/* ── PULSANTI ── */
.actions { margin-top: 28px; gap: 8px; }
.actions button, .wide-btn {
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
button.secondary, .wide-btn.secondary { border-color: var(--line-strong); background: var(--bg); color: var(--ink); }
button.secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
button.primary:hover:not(:disabled) { opacity: 1; filter: brightness(1.06); }
.actions button:disabled, .wide-btn:disabled { opacity: 0.4; }
.small-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.small-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }

/* ── STATO, AVVISI, FOOTER ── */
.status { font-size: 11.5px; }
.notice { padding: 6px 10px; border-left-width: 2px; font-size: 11.5px; background: var(--surface); color: var(--ink); }
.notice.warning { border-left-color: var(--accent); color: var(--ink); }
.notice.err { border-left-color: var(--danger); color: var(--danger); }
.controls > footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  justify-content: flex-start;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 11px;
}
footer a, .footer-popover-trigger { color: var(--muted); text-decoration: none; }
footer a:hover, .footer-popover-trigger:hover { color: var(--ink); }
.version-link { margin-left: auto; }
.footer-popover-content {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.footer-popover-content p, .changelog-popover li { font-weight: 400; font-size: 11.5px; line-height: 1.5; }
.footer-popover-content::-webkit-scrollbar-thumb { background: var(--accent); }
.changelog-popover h5 { color: var(--ink); font-weight: 600; font-size: 12px; }

/* ── COLONNA DESTRA ── */
.pane-right { padding: 24px 16px 48px 40px; gap: 24px; background: var(--bg); }
.panel { padding-top: 0; }
.tool-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
}
.tool-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
.top-tools { gap: 6px; }

/* Riepilogo: una striscia di valori, etichette piccole e cifre tabulari, divisori sottili */
.metrics,
.pane-right .metrics {
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--ink);
}
.metric, .pane-right .metric { padding: 10px 12px; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span, .pane-right .metric span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.35;
}
.metric strong { display: block; margin-top: 4px; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Anteprima: il foglio su un fondo neutro, cornice sottile */
.preview-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.preview-placeholder { font-size: 12.5px; }
.preview-status { border-radius: var(--radius); background: var(--ink); color: var(--bg); font-size: 11px; }
#previewCanvas, #pdfPreviewCanvas { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.12); }

/* Frecce: neutre, il colore solo al passaggio */
.pager { margin-top: 12px; gap: 6px; color: var(--ink); }
.pager button { width: 32px; height: 32px; border-radius: var(--radius); }
.pager button:hover:not(:disabled) { background: var(--surface-2); opacity: 1; }
.pager button:disabled { color: var(--line-strong); }
.pager-label { min-width: 64px; color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.pager button svg { width: 14px; height: 14px; }
.pager-title { color: var(--muted); font-size: 11.5px; }

/* Tabella: intestazioni piccole, righe divise da filetti, cifre tabulari, allineata a sinistra come il riepilogo */
.signature-table { margin-top: 20px; text-align: left; font-variant-numeric: tabular-nums; }
.signature-table th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.signature-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 400; }
.table-empty { text-align: left; padding: 10px 12px; font-size: 12px; }

/* La finestra di Ko-fi resta senza cornice (booklet/switch.css): solo la scheda di Ko-fi sulla pagina scurita */

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  :root { --pad: 20px; }
  .app { display: block; }
  .pane-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane-right { padding: 20px var(--pad) 40px; gap: 12px; }
}
@media (max-width: 540px) {
  .grid-2 { gap: 0; }
  .metric + .metric { border-left: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--line); }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ── PARTI DI BOOK ── */
.page-tracker { gap: 4px 16px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; }
.page-tracker strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.sig-box { margin-top: 12px; padding-bottom: 12px; }
.box-title { color: var(--ink); font-size: 11.5px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.marks-grid { column-gap: 16px; }
.marks-grid .toggle-row label { font-size: 11.5px; }
/* Schede delle segnature: filetto, titolo nel colore del testo */
.sig-item { padding: 10px 12px 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); animation: none; }
.sig-item h4 { color: var(--ink); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; }
.btn-remove { font-weight: 500; text-decoration: underline; text-decoration-color: var(--line-strong); }
.sig-advanced summary { color: var(--text-2); font-size: 12px; font-weight: 500; }
.sig-advanced summary:hover { color: var(--ink); }
/* Piano dei fogli */
.sheet-table tbody tr.sig-row td { border-top: 1px solid var(--line-strong); font-weight: 600; }
.sheet-table tbody tr.sheet-row td { color: var(--text-2); }
.sheet-table tbody tr.sheet-row.first-side td { border-top: 1px solid var(--line); }
.sheet-table td:nth-child(4) { font-weight: inherit; }
.sig-arrow { color: var(--muted); }
.sheet-table tbody tr:hover td { color: var(--ink); background: var(--surface); }
.sheet-table tbody tr.selected td { background: var(--accent-soft); color: var(--ink); }
.sheet-table tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
/* Book allinea le cinque voci del riepilogo alle colonne della tabella */
.pane-right .metric span { margin-bottom: 0; }

/* ── MENU DEI TOOL ── come gli elenchi delle scelte: pieno nel colore del tool, il tool aperto sottolineato */
.mode-menu {
  left: var(--pad);
  right: var(--pad);
  margin-top: 8px;
  padding: 4px;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.mode-menu li { padding: 8px 10px; border-radius: var(--radius); font-size: 22px; }
.mode-menu li[data-href]:hover { background: rgba(0, 0, 0, 0.16); }
.mode-menu .soon-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; }

/* "?" anche con il tocco e da tastiera: il fumetto compare quando il "?" ha il fuoco (shared/design.js) */
.tooltip-icon:focus { outline: none; border-color: var(--ink); color: var(--ink); }
.tooltip-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tooltip-icon:focus::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* ── TELEFONO E TABLET ──
   Una colonna sola, nell'ordine del lavoro: intestazione, PDF, impostazioni, riepilogo e anteprima,
   esportazione, footer. Le due colonne diventano trasparenti (display: contents) e i loro pezzi vengono
   riordinati; lingua e tema stanno in alto accanto al nome del tool. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 900px) {
  body { height: auto; overflow-x: hidden; }
  .app { display: flex; flex-direction: column; position: relative; height: auto; }
  .pane-left, .pane-right, .controls { display: contents; }
  .site-header { order: 1; padding: 20px var(--pad) 18px; }
  .site-header .logo { margin-right: 80px; }
  .controls > * { order: 3; }
  .controls > .dropzone { order: 2; }
  .controls > .actions { order: 5; }
  .controls > .status, .controls > .notices { order: 6; }
  .controls > footer { order: 7; margin-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .pane-right > .panel { order: 4; margin: 28px var(--pad) 0; padding-top: 20px; border-top: 1px solid var(--line); }
  .pane-right > .top-tools { position: absolute; z-index: 5; top: 20px; right: var(--pad); display: flex; gap: 8px; }
  .controls > .actions { margin-top: 24px; }
  /* Tablet: campi da 40 px e testo da 16 px (anche iPad ingrandisce la pagina sotto questa misura) */
  :root { --control-h: 40px; }
  input[type="number"], input[type="text"], select, .cselect-btn { font-size: 16px; }
  .btn-remove { padding: 10px 0 10px 12px; margin: -10px 0; }
  .pager button { width: 44px; height: 44px; }
  .actions button, .wide-btn { height: 44px; }
  .tool-btn { width: 32px; height: 32px; }
  /* Piano dei fogli in un riquadro alto al massimo mezzo schermo, che scorre con le intestazioni ferme:
     un opuscolo lungo non spinge l'esportazione in fondo alla pagina */
  .table-scroll { max-height: 55vh; overflow-y: auto; margin-top: 16px; border-bottom: 1px solid var(--line); }
  .table-scroll .signature-table { margin-top: 0; }
  .table-scroll th { position: sticky; top: 0; z-index: 1; background: var(--bg); }
  .table-scroll::-webkit-scrollbar { width: 6px; }
  .table-scroll::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 99px; }
}
@media (max-width: 540px) {
  :root { --pad: 16px; --control-h: 44px; }
  /* Campi da 16 px: sotto questa misura iPhone ingrandisce la pagina quando li tocchi */
  input[type="number"], input[type="text"], select, .cselect-btn { font-size: 16px; }
  .unit { min-width: 48px; font-size: 13px; }
  .cselect-list { font-size: 15px; }
  .cselect-list li { padding: 10px; }
  .lead { font-size: 13px; }
  .site-header .logo { margin-right: 80px; }
  /* Comandi da toccare almeno 44 px */
  .tool-btn { width: 32px; height: 32px; }
  .donate-btn { padding: 10px 12px; }
  .instructions-toggle { min-height: 36px; }
  .dropzone { padding: 12px; }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 12px; }
  label { font-size: 12px; }
  .toggle-row { min-height: 48px; padding: 6px 0; }
  .toggle-row label { font-size: 13px; }
  input[type="checkbox"] { width: 22px; height: 22px; background-size: 14px; }
  .tooltip-icon { width: 20px; height: 20px; font-size: 11px; }
  .tooltip-icon::after { width: min(260px, calc(100vw - 48px)); font-size: 12.5px; }
  .actions button, .wide-btn { height: 48px; font-size: 12px; }
  .small-btn { height: 40px; padding: 0 14px; font-size: 11px; }
  .controls > footer { gap: 10px 16px; font-size: 12px; }
  .version-link { margin-left: 0; }
  /* Riepilogo su due colonne; con un numero dispari di voci l'ultima occupa tutta la riga */
  .metrics, .pane-right .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metric strong { font-size: 15px; }
  .preview-wrap { padding: 12px; margin-top: 12px; }
  .pager { gap: 4px; }
  .pager button { width: 44px; height: 44px; }
  .pager button svg { width: 16px; height: 16px; }
  .signature-table th { padding: 8px 6px; font-size: 9.5px; letter-spacing: 0.04em; }
  .signature-table td { padding: 10px 6px; font-size: 12px; }
  .table-empty { padding: 10px 6px; }
  .instr-warning { font-size: 12px; }
}
@media (max-width: 360px) {
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
}

/* ── FINESTRA AL DOWNLOAD ── stessa scheda, con i pesi e gli angoli del nuovo design */
.thanks-card { border-radius: var(--radius); }
.thanks-title { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.thanks-text { font-weight: 400; }
.thanks-text a { font-weight: 600; }
.thanks-donate { border-radius: var(--radius); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.thanks-notes { font-weight: 400; border-top-color: var(--line); }
.thanks-copy { font-weight: 600; }
