/* Dove l'ho messo — carta calda, inchiostro, salvia. Un solo gesto forte: l'evidenziatore sui risultati. */
:root {
  --paper: #f2ede4;      /* fondo */
  --sheet: #fbf8f2;      /* superfici sollevate */
  --ink: #2b2824;        /* testo */
  --ink-soft: #6f675d;   /* testo secondario */
  --line: #e2dacd;       /* bordi */
  --sage: #47604f;       /* accento */
  --sage-tint: #dfe6dc;
  --marker: #f3df8d;     /* evidenziatore */
  --danger: #a33b2c;
  --shadow: 0 1px 2px rgb(60 45 25 / .06), 0 6px 18px -8px rgb(60 45 25 / .18);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Tema: "sistema" segue il telefono; "chiaro"/"scuro" lo forzano (data-theme su <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1b18; --sheet: #272420; --ink: #ece6dc; --ink-soft: #a79e92; --line: #38342e;
    --sage: #9fbaa6; --sage-tint: #2f3a32; --marker: #6b5a1f; --danger: #e38b7c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 22px -10px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --paper: #1d1b18; --sheet: #272420; --ink: #ece6dc; --ink-soft: #a79e92; --line: #38342e;
    --sage: #9fbaa6; --sage-tint: #2f3a32; --marker: #6b5a1f; --danger: #e38b7c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 22px -10px rgb(0 0 0 / .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
html, body { overscroll-behavior: none; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
.sprite { position: absolute; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; flex: none; }
h1, h2, h3, p { margin: 0; }

/* ---------- Controlli ---------- */
button, .btn, .chip-btn, .icon-btn, .link-btn {
  font: inherit; color: inherit; cursor: pointer; touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--sheet); font-weight: 600;
  transition: transform 140ms var(--ease), background-color 160ms, opacity 160ms;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--sage); border-color: transparent; color: var(--paper); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-wide { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-soft); transition: background-color 160ms, transform 140ms var(--ease);
}
.icon-btn:active { transform: scale(.92); background: var(--line); }
.link-btn { white-space: nowrap; border: 0; background: none; color: var(--sage); font-weight: 600; padding: 8px 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--sage) 55%, transparent); outline-offset: 2px; border-radius: 12px; }

.field { display: grid; gap: 6px; }
.field span { font-size: .875rem; color: var(--ink-soft); font-weight: 600; }
input[type=text], input[type=password], input[type=search], input[type=email] {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  min-height: 50px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--paper);
  transition: border-color 160ms, background-color 160ms;
}
input::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }
input:focus { outline: none; border-color: var(--sage); background: var(--sheet); }
.form-error { color: var(--danger); min-height: 1.4em; font-size: .9rem; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 18px; padding: 32px 24px 24px;
  background: var(--sheet); border-radius: 28px; box-shadow: var(--shadow);
}
.login-mark { border-radius: 16px; }
.login-card h1 { font-size: 1.75rem; letter-spacing: -.01em; }
.login-card .login-lede { color: var(--ink-soft); margin-top: -10px; }
.login-step { display: grid; gap: 14px; }
.login-note { color: var(--ink-soft); font-size: .925rem; }
.login-alt { justify-self: center; font-size: .875rem; color: var(--ink-soft); }
#login-code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- App ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 16px calc(150px + env(safe-area-inset-bottom, 0px)); }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 0 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.wordmark { font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.count { color: var(--ink-soft); font-size: .9rem; margin-right: auto; }
.sync-count { padding: 3px 10px; border-radius: 999px; background: var(--marker); color: var(--ink); font-size: .8rem; font-weight: 600; white-space: nowrap; }

.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 2px 4px; }
.results-head p { color: var(--ink-soft); font-size: .95rem; }

/* Agenti: risposta diretta, riassunti e scadenze */
.answer-box { margin: 8px 0 4px; padding: 14px 16px; border-radius: 16px; background: var(--sheet); border: 1px solid var(--line); border-left: 5px solid var(--marker); box-shadow: var(--shadow); display: grid; gap: 4px; justify-items: start; }
.answer-label { font-size: .875rem; font-weight: 700; color: var(--ink-soft); }
.answer-text { font-size: 1rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.summarize-btn { justify-self: start; padding: 4px 2px; }
.deadline-bar { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0 2px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--sage-tint); color: var(--sage); font-weight: 700; font-size: .92rem; text-align: left; }
.dl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dl-item { display: grid; gap: 2px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); text-align: left; }
.dl-item b { font-size: .98rem; }
.dl-item span { color: var(--ink-soft); font-size: .85rem; }
.dl-item .dl-when { color: var(--ink); font-weight: 600; }
.dl-item.late .dl-when { color: var(--danger); }
.dl-item.soon .dl-when { background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); width: fit-content; padding: 0 3px; }

/* Archivio raggruppato per data, a mosaico */
.group { margin-top: 18px; }
.group-title {
  font-size: .9rem; font-weight: 700; color: var(--ink-soft); margin: 0 2px 10px;
}
.filters {
  display: flex; gap: 8px; overflow-x: auto; margin: 2px -16px 0; padding: 4px 16px 6px;
  scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 16px; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; scroll-snap-align: start; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--sheet); font-size: .875rem; font-weight: 600; color: var(--ink-soft);
  transition: background-color 160ms, color 160ms, transform 140ms var(--ease);
}
.filter-chip:active { transform: scale(.96); }
.filter-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.sentinel { height: 1px; }
.more, .center-text { text-align: center; color: var(--ink-soft); font-size: .9rem; padding: 16px 0; }




.masonry { display: flex; gap: 12px; align-items: flex-start; }
.mcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) { .masonry, .mcol { gap: 16px; } }
.card {
  margin-bottom: 0; display: block; width: 100%; padding: 0; text-align: left;
  border: 0; border-radius: 18px; overflow: hidden; background: var(--sheet); box-shadow: var(--shadow);
  transition: transform 160ms var(--ease);
}
.card:active { transform: scale(.98); }
.card-img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: cover; object-position: top; background: var(--line); }
.card-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.card-title { font-weight: 600; font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: .8rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.kind-pill { font-size: .65rem; font-weight: 700; letter-spacing: .02em; padding: 1px 6px; border-radius: 6px; background: var(--paper); color: var(--ink-soft); }
.cat-pill { font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: color-mix(in srgb, var(--marker) 55%, transparent); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.field select { font: inherit; font-size: 16px; min-height: 50px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.tag-more { background: var(--paper); color: var(--ink-soft); }
.card { content-visibility: auto; contain-intrinsic-size: auto 260px; }
.card-match { font-size: .85rem; line-height: 1.4; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-state { font-size: .8rem; color: var(--danger); }
.card-state.pending { color: var(--sage); }

/* Un PDF è una pagina: margini, righe di testo, angolo piegato */
.page {
  position: relative; margin: 10px 10px 0; padding: 14px 14px 16px; min-height: 96px;
  background: var(--paper); border-radius: 10px 22px 10px 10px;
  font-size: .72rem; line-height: 1.45; color: var(--ink-soft); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
}
.page::after {
  content: ""; position: absolute; top: 0; right: 0; width: 22px; height: 22px;
  background: linear-gradient(225deg, var(--sheet) 50%, var(--line) 50%);
  border-bottom-left-radius: 6px;
}
.page-kind { display: block; font-weight: 700; color: var(--ink); font-size: .75rem; margin-bottom: 4px; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tag { font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--sage-tint); color: var(--sage); font-weight: 600; }

mark { background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); color: inherit; padding: 0 2px; border-radius: 3px; }

/* Stato vuoto: tre fogli impilati */
.empty { text-align: center; padding: 15vh 24px 0; display: grid; justify-items: center; gap: 10px; }
.empty-art { position: relative; width: 92px; height: 104px; margin-bottom: 14px; }
.empty-art span { position: absolute; inset: 0; border-radius: 14px; background: var(--sheet); box-shadow: var(--shadow); }
.empty-art span:nth-child(1) { transform: rotate(-9deg) translate(-8px, 4px); }
.empty-art span:nth-child(2) { transform: rotate(6deg) translate(8px, 2px); }
.empty-art span:nth-child(3) { background: var(--marker); opacity: .85; inset: 34px 18px 50px; border-radius: 4px; box-shadow: none; }
.empty-title { font-weight: 700; font-size: 1.1rem; }
.empty-text { color: var(--ink-soft); max-width: 32ch; }

/* Barra in basso: ricerca a portata di pollice + aggiungi */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 10px; align-items: center; max-width: 720px; margin: 0 auto;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
}
.dock::before {
  content: ""; position: absolute; inset: -28px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--paper) 92%, transparent) 55%);
}
/* Casella sospesa: campo sopra, azioni sotto */
.composer {
  flex: 1; display: grid; gap: 2px; padding: 6px 8px 8px;
  background: var(--sheet); border-radius: 26px; border: 1px solid var(--line);
  box-shadow: 0 2px 4px rgb(60 45 25 / .05), 0 14px 34px -14px rgb(60 45 25 / .32);
  transition: box-shadow 200ms, border-color 200ms;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--sage) 45%, var(--line)); }
.composer input { border: 0; background: transparent; min-height: 46px; padding: 0 10px; }
.composer input:focus { background: transparent; }
.composer-row { display: flex; align-items: center; gap: 8px; }
.composer-hint { flex: 1; font-size: .8rem; color: var(--ink-soft); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attach, .go, .mic {
  position: relative; width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; transition: transform 140ms var(--ease), background-color 160ms, opacity 160ms;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.attach { border: 1px solid var(--line); color: var(--ink); background: var(--paper); cursor: pointer; }
.attach input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.attach:focus-within { outline: 3px solid color-mix(in srgb, var(--sage) 55%, transparent); outline-offset: 2px; }
.go { border: 0; background: var(--sage); color: var(--paper); }
.mic { border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.mic.rec { background: var(--danger); color: var(--sheet); animation: rec-pulse 1.4s ease-in-out infinite; }
.mic.busy { opacity: .5; pointer-events: none; }
@keyframes rec-pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--danger) 22%, transparent); } }
.go .ic, .attach .ic, .mic .ic { width: 20px; height: 20px; }
.composer:has(input:placeholder-shown) .go { opacity: .35; }
.attach:active, .go:active, .mic:active { transform: scale(.9); }

/* ---------- Pannelli dal basso ---------- */
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 26px 26px 0 0; background: var(--sheet); color: var(--ink);
  box-shadow: 0 -10px 40px -12px rgb(40 30 15 / .35);
  overflow: hidden; overscroll-behavior: contain;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 320ms var(--ease); }
.sheet.closing { animation: sheet-out 220ms ease-in forwards; }
.sheet::backdrop { background: rgb(30 24 16 / .38); animation: fade-in 240ms ease-out; }
.sheet.closing::backdrop { animation: fade-out 220ms ease-in forwards; }
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 26px; } }
.sheet-tall { height: 92dvh; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; flex: none; }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 18px; align-content: start;
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom, 0px)); flex: 1;
}
.sheet h2 { font-size: 1.25rem; line-height: 1.3; overflow-wrap: anywhere; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }

.up-files { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.up-files li { scroll-snap-align: start; flex: none; width: 76px; display: grid; gap: 4px; font-size: .7rem; color: var(--ink-soft); }
.up-files .thumb { width: 76px; height: 96px; border-radius: 12px; background: var(--paper); object-fit: cover; object-position: top; display: grid; place-items: center; font-weight: 700; color: var(--ink-soft); }
.up-files span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.d-head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.d-meta { color: var(--ink-soft); font-size: .875rem; margin-top: 2px; }
.d-preview { border-radius: 16px; overflow: hidden; background: var(--paper); }
.d-preview img { display: block; width: 100%; height: auto; max-height: 60dvh; object-fit: contain; }
.d-preview iframe { display: block; width: 100%; height: 58dvh; border: 0; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 16px 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--paper); text-decoration: none;
  font-weight: 600; font-size: .9rem; transition: transform 140ms var(--ease), background-color 160ms;
}
.chip-btn .ic { width: 18px; height: 18px; }
.chip-btn:active { transform: scale(.96); }
.chip-danger { color: var(--danger); }
.chip-danger.armed, .chip-danger.armed:hover { background: var(--danger); color: var(--sheet); border-color: transparent; }
.d-form { display: grid; gap: 12px; }
.d-text h3 { font-size: .95rem; color: var(--ink-soft); margin-bottom: 8px; }
.d-text p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .925rem; line-height: 1.6; max-width: 70ch; }

/* ---------- Selezione multipla ---------- */
.select-bar {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: 0 2px 4px rgb(60 45 25 / .05), 0 14px 34px -14px rgb(60 45 25 / .32);
}
.select-count { flex: 1; text-align: center; font-weight: 600; font-size: .95rem; }
.btn-danger { background: var(--danger); border-color: transparent; color: var(--sheet); }
.btn-danger-soft { color: var(--danger); }
.btn.btn-danger.armed { color: var(--sheet); border-color: transparent; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 35%, transparent); }
.selecting .card { position: relative; }
.selecting .card::after {
  content: ""; position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--sheet) 85%, transparent); border: 2px solid var(--ink-soft);
}
.selecting .card.selected { outline: 3px solid var(--sage); outline-offset: -3px; }
.selecting .card.selected::after {
  background: var(--sage) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
  border-color: var(--sage);
}
.icon-btn.on { background: var(--sage-tint); color: var(--sage); }

/* ---------- Impostazioni ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.stats div { background: var(--paper); border-radius: 16px; padding: 12px; }
.stats dt { font-size: .8rem; color: var(--ink-soft); }
.stats dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; }
.s-block { display: grid; gap: 8px; justify-items: start; }
.s-block h3 { font-size: 1rem; }
.s-block p { color: var(--ink-soft); font-size: .9rem; max-width: 60ch; }
.s-progress { min-height: 1.4em; font-size: .9rem; color: var(--sage); font-weight: 600; }
#logout { margin-top: 8px; color: var(--ink-soft); }

/* Selettore tema a segmenti */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; width: 100%; background: var(--paper); border-radius: 16px; }
.segmented button {
  min-height: 42px; border: 0; border-radius: 12px; background: transparent; font-weight: 600; font-size: .9rem; color: var(--ink-soft);
  transition: background-color 180ms, color 180ms;
}
.segmented button[aria-checked="true"] { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }
.app-version { text-align: center; font-size: .8rem; color: var(--ink-soft); }

/* Passkey */
.pk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: 100%; }
.pk-list li { display: flex; align-items: center; gap: 10px; background: var(--paper); border-radius: 14px; padding: 8px 8px 8px 14px; }
.pk-list .pk-name { flex: 1; font-weight: 600; font-size: .925rem; }
.push-opt { display: flex; align-items: center; gap: 10px; flex: 1; padding: 6px 0; font-size: .925rem; cursor: pointer; }
.push-opt input { width: 18px; height: 18px; accent-color: var(--sage); }
.pk-list .pk-date { display: block; font-weight: 400; color: var(--ink-soft); font-size: .8rem; }
#passkey-login .ic, #pk-add .ic { width: 20px; height: 20px; }

.people-form { display: flex; gap: 8px; width: 100%; }
.people-form input { flex: 1; }
.support-form { display: grid; gap: 8px; width: 100%; }
.support-form textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); min-height: 110px; padding: 12px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--paper); resize: vertical;
}
.support-form textarea:focus { outline: none; border-color: var(--sage); background: var(--sheet); }
.support-form .btn { justify-self: start; }
.role-pill { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--sage-tint); color: var(--sage); margin-left: 6px; }

.plan-box { display: grid; gap: 10px; background: var(--paper); border-radius: 16px; padding: 14px; }
.plan-name { font-weight: 700; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .85rem; color: var(--ink-soft); }
.meter progress { grid-column: 1 / -1; width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
.meter progress::-webkit-progress-value { background: var(--sage); border-radius: 99px; }
.meter progress::-moz-progress-bar { background: var(--sage); }
.meter b { grid-row: 1; grid-column: 2; color: var(--ink); font-weight: 600; }

/* Amministrazione */
.admin { padding-bottom: 40px; }
.admin h2 { font-size: 1.1rem; }
.card-form { display: grid; gap: 12px; background: var(--sheet); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); margin: 8px 0 20px; }
select { font: inherit; font-size: 16px; min-height: 50px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.muted { color: var(--ink-soft); } .small { font-size: .85rem; }
.admin-h { margin: 8px 2px 10px; }
.org-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.org { background: var(--sheet); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 6px; justify-items: start; }
.org-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.org.is-suspended { opacity: .7; }
.tag-warn { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.btn.armed { border-color: var(--danger); color: var(--danger); }

.ai-left { font-size: .875rem; color: var(--ink-soft); background: var(--paper); border-radius: 12px; padding: 10px 12px; }
.plans-table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--paper); border-radius: 14px; overflow: hidden; }
.plans-table th, .plans-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.plans-table th { font-size: .75rem; color: var(--ink-soft); }
.plans-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.plans-table tr:last-child td { border-bottom: 0; }

/* Striscia del tempo e vista timeline */
.timebar { display: grid; gap: 6px; margin-top: 6px; }
.timebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.view-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--sheet); border-radius: 12px; border: 1px solid var(--line); }
.view-switch button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; touch-action: manipulation; }
.view-switch button[aria-checked="true"] { background: var(--sage-tint); color: var(--sage); }
.strip { display: flex; align-items: flex-end; gap: 2px; height: 64px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px 18px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; scroll-snap-type: x proximity; position: relative; }
.strip::-webkit-scrollbar { display: none; }
.day { position: relative; flex: none; width: 9px; height: 100%; border: 0; padding: 0; background: transparent; display: flex; align-items: flex-end; cursor: default; touch-action: manipulation; }
.day i { display: block; width: 100%; border-radius: 3px 3px 1px 1px; background: var(--line); transition: background-color 160ms, transform 140ms; }
.day.has { cursor: pointer; }
.day.has i { background: var(--sage); opacity: .75; }
.day.today i { outline: 2px solid var(--marker); outline-offset: 1px; }
.day.sel i { background: var(--ink); opacity: 1; }
.day .m { position: absolute; left: 0; bottom: -17px; font-size: .68rem; color: var(--ink-soft); white-space: nowrap; scroll-snap-align: start; }
@media (hover: hover) and (pointer: fine) { .day.has:hover i { opacity: 1; transform: scaleY(1.06); transform-origin: bottom; } }

.tl-month { margin-top: 18px; }
.tl-month-title { font-size: .95rem; font-weight: 700; color: var(--ink-soft); margin: 0 2px 8px; }
.tl-list { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; display: grid; gap: 10px; }
.tl-list::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--line); }
.tl-item { position: relative; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 22px; width: 10px; height: 10px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--sage); }
.tl-card { width: 100%; display: grid; grid-template-columns: 40px 64px 1fr; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border: 0; border-radius: 16px; background: var(--sheet); box-shadow: var(--shadow); font: inherit; color: var(--ink); cursor: pointer; transition: transform 140ms var(--ease); }
.tl-card:active { transform: scale(.98); }
.tl-date { display: grid; justify-items: center; line-height: 1.1; color: var(--ink-soft); font-size: .75rem; }
.tl-date b { font-size: 1.3rem; color: var(--ink); }
.tl-thumb { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--paper); display: grid; place-items: center; }
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tl-pdf { font-size: .75rem; font-weight: 700; color: var(--danger); }
.tl-body { display: grid; gap: 3px; min-width: 0; }
.tl-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-sub { font-size: .8rem; color: var(--ink-soft); }

.live-chip { position: sticky; top: calc(70px + env(safe-area-inset-top, 0px)); z-index: 6; display: block; margin: 8px auto 0; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); font: inherit; font-size: .875rem; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }

/* Guida */
.guide { display: grid; gap: 8px; }
.guide details { background: var(--paper); border-radius: 16px; padding: 0 16px; }
.guide summary { list-style: none; cursor: pointer; padding: 14px 0; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "+"; color: var(--ink-soft); font-weight: 400; font-size: 1.2rem; line-height: 1; transition: transform 200ms var(--ease); }
.guide details[open] summary::after { transform: rotate(45deg); }
.guide .g-body { padding: 0 0 14px; color: var(--ink-soft); font-size: .925rem; display: grid; gap: 8px; }
.guide .g-body b { color: var(--ink); font-weight: 600; }
.guide ol, .guide ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.guide-lede { color: var(--ink-soft); }
.empty .link-btn { margin-top: 4px; }

/* ---------- Avvisi ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(130px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px;
  background: var(--ink); color: var(--paper); font-size: .9rem; font-weight: 500; box-shadow: var(--shadow);
  transition: opacity 200ms ease-out, transform 260ms var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Hover solo dove esiste un puntatore preciso */
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-2px); }
  .btn:hover, .chip-btn:hover { background-color: color-mix(in srgb, var(--line) 55%, var(--sheet)); }
  .btn-primary:hover { background-color: color-mix(in srgb, var(--sage) 88%, var(--ink)); }
  .icon-btn:hover { background: var(--line); }
}

@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- Pagina di presentazione (visitatori non collegati) ---------- */
.landing { max-width: 1040px; margin: 0 auto; padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px)); }
.l-top { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top, 0px)) 0 8px; }
.l-top-btn { min-height: 40px; padding: 0 16px; text-decoration: none; }
.landing a.btn { text-decoration: none; }
.l-hero { display: grid; gap: 36px; padding: 40px 0 56px; align-items: center; }
.l-hero h1 { font-size: clamp(2.1rem, 6.4vw, 3.4rem); line-height: 1.05; letter-spacing: -.025em; margin: 0; max-width: 14ch; }
.l-lede { font-size: 1.125rem; color: var(--ink-soft); max-width: 46ch; margin: 18px 0 26px; }
.l-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.l-demo { margin: 0; display: grid; gap: 14px; max-width: 420px; justify-self: center; width: 100%; }
.l-demo-card { background: var(--sheet); border-radius: 22px; padding: 20px 22px; box-shadow: var(--shadow); transform: rotate(-1.2deg); transition: opacity .35s var(--ease), transform .45s var(--ease); }
.l-demo-card.out { opacity: 0; transform: rotate(-1.2deg) translateY(10px); }
.l-caret { width: 2px; height: 1.2em; background: var(--sage); margin-left: -8px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.l-demo-note { font-size: .85rem; color: var(--ink-soft); text-align: center; transition: opacity .35s; }
.l-pain { display: grid; gap: 4px 28px; align-items: start; }
.l-big { font-size: clamp(3.6rem, 14vw, 7rem); font-weight: 800; letter-spacing: -.04em; line-height: .9; margin: 0; color: var(--sage) !important; }
.l-pain h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); line-height: 1.15; max-width: 22ch; }
.l-asks { display: flex; flex-wrap: wrap; gap: 8px; }
.l-asks .filter-chip { font-size: .95rem; }
.l-sticky { position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 20; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) { .l-caret { animation: none; } .l-demo-card { transition: none; } }
.l-demo-kind { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.l-demo-title { font-weight: 700; font-size: 1.1rem; margin: 6px 0 4px; }
.l-demo-text { margin: 0; color: var(--ink-soft); }
.l-demo-text mark { background: var(--marker); color: var(--ink); padding: 1px 4px; border-radius: 5px; font-weight: 700; }
.l-demo-ask { display: flex; align-items: center; gap: 12px; background: var(--sheet); border: 1px solid var(--line); border-radius: 999px; padding: 14px 20px; font-size: 1.05rem; box-shadow: var(--shadow); }
.l-demo-ask .ic { color: var(--sage); flex: none; }
/* Fasce a tutta larghezza: il colore esce dal contenitore senza creare scorrimento laterale. */
.l-band { position: relative; background: var(--sage-tint); box-shadow: 0 0 0 100vmax var(--sage-tint); clip-path: inset(0 -100vmax); }
.landing h2 { font-size: clamp(1.45rem, 3.2vw, 2rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 14px; }
.landing p { color: var(--ink-soft); max-width: 60ch; }

/* Telefono: cornice d'inchiostro, la schermata vera dentro. */
.l-phone { position: relative; width: 100%; max-width: 230px; aspect-ratio: 460 / 826; border-radius: 30px; padding: 7px; background: #2b2824; box-shadow: 0 2px 4px rgb(40 30 15 / .12), 0 24px 48px -18px rgb(40 30 15 / .45); }
.l-phone img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 23px; background: #f2ede4; }
.l-phone-hero { max-width: 300px; border-radius: 38px; padding: 9px; }
.l-phone-hero img { border-radius: 29px; }
:root[data-theme="dark"] .l-phone { background: #0f0e0c; box-shadow: 0 0 0 1px #3a352e, 0 24px 48px -18px rgb(0 0 0 / .8); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .l-phone { background: #0f0e0c; box-shadow: 0 0 0 1px #3a352e, 0 24px 48px -18px rgb(0 0 0 / .8); } }

/* Hero: la striscia d'evidenziatore dietro il telefono è il gesto forte della pagina. */
.l-hero-shot { position: relative; margin: 0; display: grid; justify-items: center; gap: 12px; isolation: isolate; }
.l-hero-shot::before { content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 34%; height: 30%; background: var(--marker); border-radius: 14px; transform: rotate(-4deg); opacity: .9; }
.l-hero-shot figcaption { font-size: .8rem; color: var(--ink-soft); }

.l-pain { display: grid; gap: 4px 28px; align-items: start; padding: 24px 0 56px; }

.l-try { display: grid; gap: 22px; padding: 28px 22px; margin-bottom: 64px; background: var(--sheet); border-radius: 28px; box-shadow: var(--shadow); }
.l-try .l-demo { max-width: none; }
.l-try .l-demo-ask { background: var(--paper); box-shadow: none; }
.l-try .l-demo-card { background: var(--paper); box-shadow: none; border: 1px solid var(--line); }

.l-how { padding: 56px 0 64px; }
.l-steps { margin: 26px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 40px; }
.l-steps li { counter-increment: s; display: grid; justify-items: center; gap: 18px; text-align: center; }
.l-steps li p { max-width: 32ch; position: relative; }
.l-steps li p::before { content: counter(s); display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 10px; border-radius: 50%; background: var(--sage); color: var(--paper); font-weight: 700; font-size: .95rem; }
.l-steps strong { color: var(--ink); }

.l-own { display: grid; gap: 36px; align-items: center; justify-items: center; padding: 72px 0; }
.l-own-text { justify-self: stretch; }
.l-facts { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 0; }
.l-facts li { padding: 12px 0 12px 30px; border-top: 1px solid var(--line); position: relative; }
.l-facts li::before { content: ""; position: absolute; left: 4px; top: 19px; width: 12px; height: 7px; border-left: 2.5px solid var(--sage); border-bottom: 2.5px solid var(--sage); transform: rotate(-45deg); }
.l-phone-tilt { transform: rotate(3deg); }

.l-more { display: grid; gap: 40px; padding: 8px 0 72px; }
.l-plans { padding: 24px 22px; border-radius: 24px; border: 1.5px dashed var(--line); align-self: start; }
.landing details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.landing summary { cursor: pointer; font-weight: 600; }
.landing details p { margin: 8px 0 0; }

.l-join { padding: 64px 0 72px; text-align: center; }
.l-join p { margin: 0 auto; }
.l-form { display: grid; gap: 14px; max-width: 420px; margin: 26px auto 0; text-align: left; }
.l-msg { min-height: 1.5em; margin: 0; font-weight: 600; color: var(--sage) !important; }
.l-foot { color: var(--ink-soft); font-size: .85rem; padding: 24px 0 0; }

/* Accesso in un pannello: stessi moduli di prima. */
.l-login-sheet { position: fixed; max-width: 460px; }
.l-login-sheet .login-card { width: 100%; background: none; box-shadow: none; padding: 8px 24px calc(24px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; max-width: 420px; overflow-y: auto; }
.l-login-sheet .login-card h2 { font-size: 1.5rem; margin: 0; }
.l-login-close { position: absolute; top: 10px; right: 12px; }

@media (max-width: 819px) {
  .l-phone-hero { max-width: 250px; }
  .l-hero-shot::before { left: 2%; right: 2%; }
  .l-steps { gap: 28px; }
  .l-steps li { grid-template-columns: 132px 1fr; justify-items: start; text-align: left; align-items: center; gap: 16px; }
  .l-steps li p::before { margin: 0 0 8px; }
  .l-steps .l-phone { border-radius: 20px; padding: 5px; }
  .l-steps .l-phone img { border-radius: 16px; }
  .l-own .l-phone { max-width: 200px; }
  .l-pain { padding-bottom: 40px; }
  .l-own { padding: 56px 0; }
}
@media (min-width: 820px) {
  .l-hero { grid-template-columns: 1.2fr 1fr; padding: 64px 0 80px; }
  .l-pain { grid-template-columns: auto 1fr; }
  .l-try { grid-template-columns: 1fr 1.1fr; align-items: center; padding: 40px; }
  .l-steps { grid-template-columns: repeat(3, 1fr); gap: 32px; }
  .l-steps li:nth-child(2) { margin-top: 36px; }
  .l-own { grid-template-columns: 1.3fr 1fr; }
  .l-more { grid-template-columns: 1fr 1.4fr; }
  .l-sticky { display: none; }
}

.update-chip { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 40; margin: 0; }
.ts-box:empty { display: none; }

/* Pulsante in attesa (login) */
.btn.is-busy { cursor: progress; opacity: .85; }
.btn.is-busy::before { content: ""; display: inline-block; width: 1em; height: 1em; margin-right: .5em; vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: btn-spin .7s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.is-busy::before { animation-duration: 2s; } }

/* Informativa breve nei moduli (lista d'attesa e accesso) */
.l-privacy, .login-privacy { font-size: .8rem; color: var(--ink-soft); max-width: 60ch; margin: 0 auto; line-height: 1.45; }
.login-privacy { text-align: left; margin: 0; }
.l-privacy a, .login-privacy a { color: inherit; text-decoration: underline; }

/* Pagina informativa privacy */
.privacy-page { max-width: 680px; margin: 0 auto; padding: 48px 16px 64px; display: grid; gap: 16px; }
.privacy-page h1 { font-size: 1.6rem; }
.privacy-page p { color: var(--ink-soft); line-height: 1.55; }
.privacy-page a { color: inherit; text-decoration: underline; }

/* Beta gratuita, età minima e trasparenza AI */
.beta-pill { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: .7rem; font-weight: 700; letter-spacing: .02em; color: var(--ink-soft); }
.l-beta { color: var(--ink-soft); font-size: .95rem; max-width: 52ch; margin-bottom: 20px; }
.check-field { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: .925rem; }
.check-field input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
.check-field a { color: inherit; text-decoration: underline; }
.ai-note { font-size: .78rem; color: var(--ink-soft); font-style: italic; }
.top .wordmark { white-space: nowrap; }
.top .count { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 400px) { .top .beta-pill { margin-left: 4px; padding: 0 6px; } }
@media (max-width: 400px) { .top .count { font-size: .8rem; } .top .beta-pill { font-size: .62rem; letter-spacing: 0; } }
