/* Componenti riutilizzabili. Nomi in stile BEM: blocco__elemento--variante */

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.btn:hover {
  background: var(--surface-2);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent);
  opacity: 0.88;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
}

/* Pulsante piccolo: resta alto 36px ma l'area cliccabile arriva a 44px grazie al margine negativo del contenitore */
.btn--sm {
  min-height: 36px;
  padding: 0 var(--s-3);
  font-size: var(--fs-sm);
}

.btn--block {
  width: 100%;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-2);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* ---------- FAB (pulsante aggiungi) ---------- */
.fab {
  position: fixed;
  right: var(--s-4);
  bottom: calc(var(--nav-h) + var(--s-4) + env(safe-area-inset-bottom));
  z-index: 11;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-float);
  transition: transform var(--dur) var(--ease);
}

.fab:active {
  transform: scale(0.95);
}

.fab svg {
  width: 26px;
  height: 26px;
}

@media (min-width: 1024px) {
  .fab {
    right: var(--s-7);
    bottom: var(--s-7);
  }
}

/* ---------- Campo di testo ---------- */
.field {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-md); /* 16px: sotto questa misura iOS fa lo zoom quando tocchi il campo */
}

.field::placeholder {
  color: var(--text-3);
}

.field:focus-visible {
  outline-offset: 0;
  border-color: var(--focus);
}

/* ---------- Chip (area, filtri) ---------- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--area-c, var(--text-3));
}

/* Chip-radio: l'input resta nel DOM (e riceve il focus) ma è invisibile */
.chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip:has(input:checked),
.chip[aria-pressed="true"] {
  border-color: var(--area-c, var(--text));
  background: var(--area-soft, var(--surface-2));
  color: var(--text);
}

.chip:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Checkbox ---------- */
.check {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  margin: -10px -8px -10px -10px; /* area di tocco 44px senza allargare la riga */
  cursor: pointer;
}

.check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.check__box {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 7px;
  color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.check__box svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.check:hover .check__box {
  border-color: var(--area-c, var(--text-2));
}

.check input:checked + .check__box {
  border-color: var(--area-c, var(--accent));
  background: var(--area-c, var(--accent));
  color: var(--surface);
}

.check input:focus-visible + .check__box {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Sezione con titolo ---------- */
.section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.section__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
}

.section__head svg {
  width: 16px;
  height: 16px;
}

.section__range {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-3);
}

.count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  text-align: center;
}

.count--warning {
  background: color-mix(in oklab, var(--warning) 16%, var(--surface));
  color: var(--warning);
}

/* ---------- Lista di elementi (un solo contenitore, non una card per riga) ---------- */
.group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}

.item:last-child {
  border-bottom: 0;
}

/* Barretta colorata dell'area a sinistra */
.item::before {
  content: '';
  position: absolute;
  top: var(--s-3);
  bottom: var(--s-3);
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--area-c);
}

.item__time {
  width: 44px;
  flex: none;
  padding-top: 1px;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.3;
}

.item__time small {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
}

/* Segnaposto per gli appuntamenti al posto della checkbox (stessa larghezza, righe allineate) */
.item__marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  flex: none;
  color: var(--area-c);
}

.item__marker svg {
  width: 18px;
  height: 18px;
}

.item__body {
  flex: 1;
  min-width: 0;
}

.item__title {
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--s-3);
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.item__meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.item__meta svg {
  width: 14px;
  height: 14px;
}

.item__meta .is-late {
  color: var(--warning);
  font-weight: 600;
}

.item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.item__flag {
  flex: none;
  padding-top: 2px;
}

.item__flag svg {
  width: 16px;
  height: 16px;
}

.item__flag--high { color: var(--danger); }
.item__flag--medium { color: var(--warning); }
.item__flag--low { color: var(--text-3); }

/* Elemento completato: resta visibile ma passa in secondo piano */
.item.is-done .item__title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.item.is-done .item__time,
.item.is-done .item__flag {
  opacity: 0.5;
}

/* Input data nascosto: il pulsante "Sposta" apre il suo calendario con showPicker() */
.date-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Linea dell'ora attuale ---------- */
.now-line {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  margin: -1px 0;
  color: var(--now);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.now-line::after {
  content: '';
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--now);
}

/* ---------- Fascia (lavoro / dopo lavoro) ---------- */
.slot--work {
  padding: var(--s-3);
  margin: 0 calc(var(--s-3) * -1);
  border-radius: calc(var(--r-lg) + var(--s-2));
  background: var(--surface-2);
}

/* ---------- Barra di avanzamento ---------- */
.progress {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.progress__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.progress__label strong {
  color: var(--text);
}

.progress__track {
  height: 6px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--surface-2);
}

.progress__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--text);
  transition: width 300ms var(--ease);
}

/* ---------- Riquadro "Adesso / Dopo" ---------- */
.now-card {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

@media (min-width: 480px) {
  .now-card {
    grid-template-columns: 1.4fr 1fr;
  }
}

.now-card__col + .now-card__col {
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

@media (min-width: 480px) {
  .now-card__col + .now-card__col {
    padding: 0 0 0 var(--s-4);
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

.eyebrow {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-3);
}

.now-card__title {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-top: var(--s-1);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
}

.now-card__col:first-child .now-card__title {
  font-size: var(--fs-xl);
}

.now-card__title .dot {
  position: relative;
  top: -2px;
}

.now-card__sub {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* ---------- Stato vuoto ---------- */
.empty {
  padding: var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.placeholder {
  padding: var(--s-7) var(--s-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  text-align: center;
  color: var(--text-2);
}

.placeholder p + p {
  margin-top: var(--s-1);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ---------- Pannello (dialog): dal basso su mobile, centrato su desktop ---------- */
.sheet {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-float);
}

.sheet::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom));
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: calc(var(--s-2) * -1);
}

.sheet__title {
  font-size: var(--fs-lg);
}

.sheet__hint {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

@media (min-width: 640px) {
  .sheet {
    max-width: 480px;
    margin: auto;
    border-radius: var(--r-lg);
  }

  .sheet__body {
    padding: var(--s-5);
  }
}

/* ---------- Pagina componenti (solo sviluppo) ---------- */
.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.swatch {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
}

.swatch span:first-child {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--sw);
}

/* ---------- Campo con etichetta ---------- */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.form-field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.sheet__hint.is-error {
  color: var(--danger);
}

/* ---------- Avviso in basso (toast) ---------- */
.toast {
  position: fixed;
  left: var(--s-4);
  right: var(--s-4);
  bottom: calc(var(--nav-h) + 88px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-float);
}

@media (min-width: 1024px) {
  .toast {
    bottom: var(--s-7);
  }
}

/* ---------- Schermata di accesso ---------- */
.login {
  display: grid;
  min-height: 100dvh;
  padding: calc(var(--s-8) + env(safe-area-inset-top)) var(--s-4) var(--s-8);
}

.login__inner {
  width: 100%;
  max-width: 380px;
  margin: auto;
}

/* Tre binari di lunghezza diversa, uno per area: come tre vite che scorrono in parallelo */
.login__mark {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-6);
}

.login__mark span {
  display: block;
  height: 10px;
  border-radius: var(--r-full);
}

.login__mark span:nth-child(1) { width: 72px; background: color-mix(in oklab, var(--mark-1), white var(--area-lift)); }
.login__mark span:nth-child(2) { width: 112px; margin-left: 24px; background: color-mix(in oklab, var(--mark-2), white var(--area-lift)); }
.login__mark span:nth-child(3) { width: 56px; margin-left: 52px; background: color-mix(in oklab, var(--mark-3), white var(--area-lift)); }

.login__title {
  /* il nome è lungo: sul telefono si rimpicciolisce invece di spezzarsi in tre righe */
  font-size: clamp(2rem, 9vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.login__lead {
  margin-top: var(--s-2);
  color: var(--text-2);
}

.login__notice {
  margin-top: var(--s-6);
  padding: var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-top: var(--s-7);
}

.login__message {
  min-height: 1.5em;
  margin-bottom: calc(var(--s-2) * -1);
  font-size: var(--fs-sm);
  color: var(--danger);
}

.login__message:empty {
  min-height: 0;
}

.topbar__actions {
  display: flex;
  margin-right: calc(var(--s-2) * -1);
}

/* ---------- Titolo cliccabile nelle righe (apre il dettaglio) ---------- */
button.item__title {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  text-align: left;
  color: inherit;
}

button.item__title:hover {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

/* ---------- Filtri ---------- */
.filters {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* ---------- Pannello di dettaglio ---------- */
.sheet--tall {
  max-height: 92dvh;
}

.sheet--tall .sheet__body {
  padding-bottom: 0;
}

/* I pulsanti Elimina/Salva restano sempre visibili in fondo, anche scorrendo */
.sheet__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  margin: 0 calc(var(--s-4) * -1);
  padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

@media (min-width: 640px) {
  .sheet__footer {
    margin: 0 calc(var(--s-5) * -1);
    padding: var(--s-3) var(--s-5);
  }
}

.form-field legend {
  margin-bottom: var(--s-1);
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.form-hint {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.form-error {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--danger);
}

.form-error:empty {
  display: none;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-2);
}

.field-row > .field {
  flex: 1;
  min-width: 0;
}

.field-inline {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--s-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.field--area {
  min-height: 112px;
  padding: var(--s-3) var(--s-4);
  line-height: 1.5;
  resize: vertical;
}

select.field {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* Scelta tra opzioni (tipo, orario, priorità): radio button con l'aspetto di una barra a segmenti */
.segmented {
  display: flex;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.segmented__option {
  position: relative;
  flex: 1;
}

.segmented__option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented__option span {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 var(--s-2);
  border-radius: calc(var(--r-md) - 3px);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  color: var(--text-2);
}

.segmented__option input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-subtle);
}

.segmented__option input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.segmented__option input:disabled + span {
  opacity: 0.4;
}

.btn--danger {
  color: var(--danger);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Sotto-elementi nel dettaglio ---------- */
.subitems {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.subitems__title {
  display: flex;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.subitems__list {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.subitem {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: 0 var(--s-1) 0 var(--s-3);
  border-bottom: 1px solid var(--border);
}

.subitem:last-child {
  border-bottom: 0;
}

.subitem .check {
  margin: 0 -8px 0 -10px;
}

.subitem__title {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
}

.subitem.is-done .subitem__title {
  color: var(--text-3);
  text-decoration: line-through;
}

/* ---------- Azione dentro l'avviso (es. Annulla) ---------- */
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.toast__action {
  flex: none;
  min-height: 36px;
  margin: calc(var(--s-2) * -1) calc(var(--s-2) * -1) calc(var(--s-2) * -1) 0;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-weight: 700;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Vista Oggi: frase del giorno ---------- */
.quote {
  max-width: 48ch;
  margin-top: calc(var(--s-3) * -1); /* resta vicina al titolo, è parte dell'intestazione */
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-2);
  text-wrap: pretty;
}

/* ---------- Il punto della situazione ---------- */
.situation__text {
  max-width: 60ch;
  color: var(--text-2);
  text-wrap: pretty;
}

.situation__text strong {
  color: var(--text);
}

/* ---------- Prima di tutto: stessa lista, bordo più marcato ---------- */
.group--focus {
  border-color: var(--border-strong);
}

/* ---------- Buco libero nella timeline ---------- */
.gap {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  /* tratteggio: è tempo vuoto, non un impegno */
  background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--surface-2) 6px 7px);
}

.gap:last-child {
  border-bottom: 0;
}

.gap__head {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.gap__empty {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.gap__list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

.suggestion {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.suggestion__title {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
}

/* Schede (Settimana / Mese): stesso aspetto della barra a segmenti, ma con pulsanti */
.segmented__tab {
  flex: 1;
  min-height: 38px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: calc(var(--r-md) - 3px);
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.segmented__tab[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-subtle);
}

/* ---------- Obiettivi ---------- */
.goal-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Ogni obiettivo è un blocco a sé (non una riga di lista): ha più respiro e la barra in evidenza */
.goal {
  border: 1px solid var(--border);
  border-left: 4px solid var(--area-c, var(--border-strong));
  border-radius: var(--r-lg);
  background: var(--surface);
}

.goal__open {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
  padding: var(--s-4);
  border: 0;
  border-radius: inherit;
  background: none;
  font: inherit;
  text-align: left;
  color: inherit;
}

.goal__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
}

.goal__progress {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.goal__progress .progress__track {
  flex: 1;
}

.goal__fill {
  display: block;
  background: var(--area-c, var(--text));
}

.goal__amount {
  flex: none;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}

.archive summary {
  min-height: var(--tap);
  cursor: pointer;
  list-style-position: inside;
}

.archive .goal-list {
  margin-top: var(--s-2);
}

.sheet__footer-group {
  display: flex;
  gap: var(--s-1);
}

/* Nome dell'obiettivo nelle righe e nei suggerimenti */
.item__meta .item__goal {
  color: var(--text-2);
}

.suggestion__goal {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
}

.suggestion__goal svg,
.situation__text > svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.situation__text > svg {
  display: inline;
  margin-right: 6px;
  vertical-align: -2px;
}

.situation__goal {
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.situation__why {
  padding-left: var(--s-3);
  border-left: 2px solid var(--border-strong);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* ---------- Soldi ---------- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 calc(var(--s-2) * -1);
}

.month-nav__label {
  font-weight: 700;
}

/* Riepilogo del mese: tre numeri in una sola fascia, non tre card */
.money-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.money-summary > div {
  padding: var(--s-3) var(--s-4);
}

.money-summary > div + div {
  border-left: 1px solid var(--border);
}

.money-summary dt {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.money-summary dd {
  margin: 2px 0 0;
  font-size: var(--fs-lg);
  font-weight: 700;
}

.money-summary dd.is-negative {
  color: var(--danger);
}

/* l'importo resta su una riga: sul telefono il carattere si riduce invece di andare a capo */
.money-summary dd {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .money-summary > div {
    padding: var(--s-3);
  }

  .money-summary dd {
    font-size: var(--fs-sm);
  }
}

/* Scadenze */
.due {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border);
}

.due:last-child {
  border-bottom: 0;
}

.due__title {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  text-align: left;
}

.due__when {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-3);
}

.due__when svg {
  width: 14px;
  height: 14px;
}

.due.is-late .due__when {
  color: var(--warning);
  font-weight: 600;
}

.due__amount {
  font-weight: 700;
}

/* Grafico a barre orizzontali (categorie) */
.bars {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.bars__row {
  display: grid;
  grid-template-columns: minmax(80px, 30%) 1fr auto;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}

.bars__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.bars__track {
  height: 10px;
}

.bars__fill {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--chart-out);
}

.bars__value {
  font-weight: 600;
}

/* Grafico a colonne (ultimi 6 mesi) */
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart__legend {
  display: flex;
  gap: var(--s-4);
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.chart__legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart__key {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chart__key--in,
.chart__in { background: var(--chart-in); fill: var(--chart-in); }
.chart__key--out,
.chart__out { background: var(--chart-out); fill: var(--chart-out); }

.chart__axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart__label {
  font-family: var(--font-ui);
  font-size: 11px;
  fill: var(--text-3);
}

/* area invisibile più grande delle barre: il suggerimento compare passando su tutto il mese */
.chart__hit {
  fill: transparent;
}

.chart__month:hover .chart__hit {
  fill: var(--surface-2);
}

/* Movimenti */
.day-head {
  margin: var(--s-3) 0 var(--s-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-3);
}

.tx {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--border);
}

.tx:last-child {
  border-bottom: 0;
}

.tx__dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
}

.tx__dot--in { background: var(--chart-in); }
.tx__dot--out { background: var(--chart-out); }

.tx__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: var(--s-2) 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
}

.tx__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tx__meta {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.tx__amount {
  flex: none;
  font-weight: 700;
}

.archive > .btn {
  margin-top: var(--s-3);
}

/* Importo nel pannello: grande, è il dato principale */
.amount-field {
  position: relative;
}

.field--amount {
  min-height: 56px;
  padding-right: 40px;
  font-size: var(--fs-xl);
  font-weight: 700;
}

.amount-field__unit {
  position: absolute;
  top: 50%;
  right: var(--s-4);
  transform: translateY(-50%);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-3);
}

/* ---------- Foto di Jess nella testata ---------- */
.topbar {
  justify-content: flex-start;
}

.topbar__text {
  flex: 1;
  min-width: 0;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  overflow: hidden;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  /* senza foto: icona della fotocamera su verde-turchese chiaro */
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
  box-shadow: 0 0 0 1px var(--border-strong);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--accent);
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar:focus-visible {
  outline-offset: 3px;
  border-radius: 50%;
}

/* ---------- Calendario: più spazio su schermi larghi ---------- */
@media (min-width: 1024px) {
  .main-col:has(#main[data-view="calendario"]) {
    max-width: 1280px;
  }
}

/* ---------- Settimana ---------- */
.week-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin: var(--s-3) calc(var(--s-2) * -1) var(--s-2);
}

.week-toolbar__hint {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: right;
}

.week-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
}

.week {
  --hours-w: 44px;
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  /* nessun "copia/condividi" o selezione del testo mentre si tiene premuto un impegno */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.week__head,
.week__allday,
.week__grid {
  display: grid;
  grid-template-columns: var(--hours-w) repeat(var(--days), minmax(0, 1fr));
}

.week__head {
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface);
}

.week__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s-2) 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.week__day strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: var(--fs-md);
  color: var(--text);
}

.week__day.is-today strong {
  background: var(--accent);
  color: var(--on-accent);
}

.week__allday {
  border-bottom: 1px solid var(--border);
}

.week__label {
  padding: var(--s-1);
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-3);
}

.week__allday-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 32px;
  padding: 3px 2px;
  border-left: 1px solid var(--border);
  cursor: pointer;
}

.allday-chip {
  overflow: hidden;
  padding: 2px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--area-soft);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--area-c);
}

.allday-chip.is-done {
  color: var(--text-3);
  text-decoration: line-through;
}

.week__grid {
  position: relative;
  height: var(--grid-h);
}

.week__hours {
  position: relative;
}

.week__hours span {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-3);
}

.week__hours span:first-child {
  transform: none;
}

/* Colonna di un giorno: righe orarie disegnate con uno sfondo a strisce */
.week__col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 100% var(--hour-h);
  cursor: cell;
}

.week__col.is-today {
  background-color: color-mix(in oklab, var(--accent) 4%, var(--surface));
}

/* Fascia dell'orario di lavoro */
.week__work {
  position: absolute;
  inset-inline: 0;
  background: color-mix(in oklab, var(--surface-2) 60%, transparent);
  pointer-events: none;
}

.week__now {
  position: absolute;
  inset-inline: 0;
  z-index: 2;
  height: 2px;
  background: var(--now);
  pointer-events: none;
}

.week__now::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--now);
}

/* Blocco: un impegno nella griglia */
.block {
  position: absolute;
  z-index: 1;
  padding: 1px 2px;
  touch-action: manipulation;
}

.block__open {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 3px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--area-soft);
  box-shadow: inset 3px 0 0 var(--area-c);
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: grab;
}

.block--appt .block__open {
  background: color-mix(in oklab, var(--area-c) 26%, var(--surface));
}

.block__time {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
}

.block__title {
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.25;
  /* nei blocchi stretti si va a capo tra le parole (o con il trattino), non a metà parola */
  overflow-wrap: break-word;
  hyphens: auto;
}

.block.is-done .block__title {
  color: var(--text-3);
  text-decoration: line-through;
}

/* Bordo in basso: tirandolo si cambia la durata (area di tocco più grande della linea visibile) */
.block__resize {
  position: absolute;
  inset: auto 2px 0;
  height: 12px;
  cursor: ns-resize;
  touch-action: none;
}

.block__resize::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--area-c);
  opacity: 0;
  transform: translateX(-50%);
}

.block:hover .block__resize::after,
.block.is-dragging .block__resize::after {
  opacity: 0.7;
}

.block.is-dragging {
  z-index: 5;
}

.block.is-dragging .block__open {
  box-shadow: inset 3px 0 0 var(--area-c), var(--shadow-float);
  cursor: grabbing;
}

/* Lista "Da fare" accanto al calendario */
.week-inbox {
  position: sticky;
  top: var(--s-4);
  width: 260px;
  flex: none;
}

.week-inbox__list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

.inbox-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: grab;
  user-select: none;
}

/* ---------- Mese ---------- */
.month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.month__weekday {
  padding-bottom: var(--s-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  color: var(--text-3);
}

.month__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 6px 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
}

.month__day:hover {
  background: var(--surface-2);
}

.month__num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.month__day.is-outside {
  color: var(--text-3);
  opacity: 0.6;
}

.month__day.is-today .month__num {
  color: var(--accent);
  font-weight: 800;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.month__day[aria-pressed="true"] .month__num {
  background: var(--accent);
  color: var(--on-accent);
}

.month__dots {
  display: flex;
  gap: 3px;
  min-height: 6px;
}

.month__dots .dot {
  width: 6px;
  height: 6px;
}

/* giorno con tutto fatto: pallini più tenui */
.month__day.is-clear .month__dots {
  opacity: 0.4;
}

.month__day-title {
  font-size: var(--fs-md);
  color: var(--text);
}

@media (min-width: 768px) {
  .month__day {
    min-height: 72px;
  }
}

/* ---------- Impostazioni ---------- */
.settings-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.settings-item + .settings-item {
  border-top: 1px solid var(--border);
}

.settings-item summary {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 52px;
  padding: 0 var(--s-4);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.settings-item summary::-webkit-details-marker {
  display: none;
}

.settings-item summary .dot {
  width: 12px;
  height: 12px;
}

.settings-item__name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.settings-item__meta {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-3);
}

.settings-item__body {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-4) var(--s-4);
}

/* Scelta del colore: cerchi colorati (radio button nascosti) */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.swatch-option {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  cursor: pointer;
}

.swatch-option::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--sw);
}

.swatch-option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-option:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--text);
}

.swatch-option:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.settings-danger {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}

/* Orario di lavoro, un giorno per riga */
.hours__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 56px;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border);
}

.hours__row:last-child {
  border-bottom: 0;
}

.hours__day {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--tap);
  font-weight: 600;
  cursor: pointer;
}

.hours__day input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.hours__times {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.hours__times .field {
  width: 112px;
  min-height: 40px;
  padding: 0 var(--s-2);
}

.hours__off {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* Campo di testo dentro una riga di elenco (nomi delle categorie) */
.field--inline {
  flex: 1;
  min-height: 40px;
  border-color: transparent;
  background: transparent;
}

.field--inline:hover {
  border-color: var(--border);
}

.settings-email {
  color: var(--text-2);
}

/* "Prima di eliminare, sposta i N elementi in…": la scelta prende tutta la riga, il pulsante va sotto */
.settings-danger .field-inline {
  flex-basis: 100%;
}

.avatar__placeholder svg {
  width: 22px;
  height: 22px;
}

/* ---------- Tutorial (Driver.js): fumetti con i colori e i font dell'app ---------- */
.driver-popover.tour-popover {
  max-width: min(340px, calc(100vw - 32px));
  padding: var(--s-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  box-shadow: var(--shadow-float);
}

.tour-popover .driver-popover-title {
  padding-right: 36px; /* spazio per la × di chiusura */
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
}

.tour-popover .driver-popover-description {
  margin-top: var(--s-2);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-2);
}

.tour-popover .driver-popover-footer {
  align-items: center;
  margin-top: var(--s-4);
}

.tour-popover .driver-popover-progress-text {
  font-family: var(--font-num);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.tour-popover .driver-popover-footer button {
  min-height: 40px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-shadow: none;
}

.tour-popover .driver-popover-footer .driver-popover-next-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.tour-popover .driver-popover-close-btn {
  width: var(--tap);
  height: var(--tap);
  color: var(--text-3);
}

.tour-popover .driver-popover-close-btn:hover {
  color: var(--text);
}

/* la freccetta del fumetto prende il colore del fumetto (anche in tema scuro) */
.tour-popover .driver-popover-arrow-side-top { border-top-color: var(--surface); }
.tour-popover .driver-popover-arrow-side-bottom { border-bottom-color: var(--surface); }
.tour-popover .driver-popover-arrow-side-left { border-left-color: var(--surface); }
.tour-popover .driver-popover-arrow-side-right { border-right-color: var(--surface); }
