/* MeMori — le finestre del libro nello stile «Ritagli» (28/10/2026, prova in tools/prova-finestre):
 * «Inseriscilo a mano» e «Modifica il libro» (#book-dialog), «Cambia la copertina» (#cover-dialog),
 * il ritaglio della copertina (#crop-dialog), la citazione (#quote-dialog) e «Sistema il ritratto»
 * (#frame-dialog, prova in tools/prova-ritratto). Come la finestra Aggiungi
 * (aggiungi.css): un foglio di carta col bordo e l'ombra d'inchiostro, intestazione e fondo fissi e il
 * corpo che scorre; sul telefono un foglio che sale dal basso con la linguetta. Campi arrotondati col
 * bordo d'inchiostro, pulsanti a pillola, il principale in un ritaglio senape. Vale solo per i dialog
 * con la classe .fw. Caratteri e colori: ritagli.css. Animazioni: motion.css (D8). */

dialog.fw {
  width: min(640px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--rt-ink);
  border-radius: 30px 24px 34px 26px;
  background: var(--rt-paper);
  color: var(--rt-ink);
  font-family: var(--rt-body);
  box-shadow: 8px 8px 0 var(--rt-ink);
}

dialog.fw::backdrop {
  background: color-mix(in srgb, var(--rt-ink) 38%, transparent);
  backdrop-filter: blur(2px);
}

dialog.fw > form {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100vh - 68px);
}

.fw-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 22px 24px 12px;
}

dialog.fw h2 {
  margin: 0;
  font: 800 1.8rem/1 var(--rt-display);
  letter-spacing: -0.03em;
  text-transform: none;
}

.fw-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  border: 2px solid var(--rt-ink);
  border-radius: 50%;
  background: none;
  color: var(--rt-ink);
  cursor: pointer;
}

.fw-x .icon {
  width: 18px;
  height: 18px;
}

.fw-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 4px 24px 20px;
}

.fw-body > [hidden] {
  display: none;
}

.fw-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 14px 24px 18px;
  border-top: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}

.fw-foot .spacer {
  flex: 1;
}

.fw-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* --- Pulsanti --------------------------------------------------------------------- */
.fw-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: var(--rt-ink);
  color: var(--rt-paper);
  font: 700 0.92rem var(--rt-body);
  cursor: pointer;
}

.fw-btn.fw-ghost {
  background: none;
  color: var(--rt-ink);
}

.fw-btn.fw-danger {
  border-color: var(--rt-coral);
  background: none;
  color: var(--rt-coral);
}

/* Il pulsante principale: un ritaglio senape con l'ombra d'inchiostro. */
.fw-btn.fw-main {
  padding: 0.8rem 1.5rem;
  border: 0;
  border-radius: 22px 28px 24px 26px;
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  font: 800 1.05rem var(--rt-display);
  box-shadow: 4px 4px 0 var(--rt-ink);
}

.fw-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.fw-btn:focus-visible,
.fw-x:focus-visible,
.fw-pill:focus-visible,
.fw-tile:focus-visible,
.fw-tabs button:focus-visible,
.fw-link:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

.fw-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--rt-ink);
  font: 600 0.92rem var(--rt-body);
  text-decoration: underline;
  cursor: pointer;
}

.fw-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.fw-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 600 0.85rem var(--rt-body);
  cursor: pointer;
}

.fw-pill .icon {
  width: 16px;
  height: 16px;
}

/* --- Campi: riquadri arrotondati col bordo d'inchiostro ------------------------------ */
dialog.fw .fw-field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

dialog.fw .fw-field small {
  color: var(--muted);
  font-weight: 400;
}

dialog.fw .fw-field input,
dialog.fw .fw-field textarea,
dialog.fw .lookup-bar input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 1rem;
  border: 2px solid var(--rt-ink);
  border-radius: 16px;
  background: var(--rt-bg);
  color: var(--rt-ink);
  font: 500 1rem var(--rt-body);
  box-shadow: none;
}

dialog.fw .fw-field input:focus-visible,
dialog.fw .fw-field textarea:focus-visible,
dialog.fw .lookup-bar input:focus-visible {
  outline: none;
  border-color: var(--rt-ink);
  box-shadow: 3px 3px 0 var(--rt-accent);
}

dialog.fw [aria-invalid="true"] {
  border-color: var(--rt-coral);
}

.fw-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.9rem;
}

dialog.fw .form-error:empty {
  display: none;
}

/* Stato: pillole col pallino (le radio nascoste restano per la tastiera). */
dialog.fw .fw-states {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.fw-states legend {
  margin-bottom: 0.3rem;
  padding: 0;
}

/* Le etichette in fila (la regola dei moduli le metterebbe in colonna, larghe quanto la riga). Il
   colore di ogni stato con una classe: la CSP non permette gli attributi style nell'HTML. */
dialog.fw .fw-states label {
  position: relative;
  display: block;
  flex: none;
  width: auto;
  cursor: pointer;
}

.fw-st-da_leggere {
  --status-color: var(--s-da_leggere);
}

.fw-st-in_lettura {
  --status-color: var(--s-in_lettura);
}

.fw-st-letto {
  --status-color: var(--s-letto);
}

.fw-st-abbandonato {
  --status-color: var(--s-abbandonato);
}

.fw-states input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fw-states span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--rt-ink);
  border-radius: 999px;
  font-size: 0.85rem;
}

.fw-states span::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-color);
}

.fw-states input:checked + span {
  border-color: var(--status-color);
  background: var(--status-color);
  color: #161616;
  box-shadow: 3px 3px 0 var(--rt-ink);
}

.fw-states input:checked + span::before {
  background: #161616;
}

.fw-states input:focus-visible + span {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

/* Etichette (generi, argomenti): pillole rosa con la ✕, e il campo per aggiungerne. */
.fw-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem;
  border: 2px solid var(--rt-ink);
  border-radius: 16px;
  background: var(--rt-bg);
}

.fw-chips:focus-within {
  box-shadow: 3px 3px 0 var(--rt-accent);
}

.fw-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.3rem 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--rt-blush);
  font-size: 0.82rem;
  font-weight: 600;
}

.fw-chip button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.1);
  color: inherit;
  font-size: 0.65rem;
  cursor: pointer;
}

dialog.fw .fw-chips input {
  flex: 1;
  width: auto;
  min-width: 90px;
  padding: 0.25rem;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

/* Sezioni della modifica: pillole in una pillola. */
.fw-tabs {
  display: flex;
  gap: 0.3rem;
  padding: 4px;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}

.fw-tabs button {
  flex: 1 0 auto;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 600 0.88rem var(--rt-body);
  white-space: nowrap;
  cursor: pointer;
}

.fw-tabs button[aria-selected="true"] {
  background: var(--rt-ink);
  color: var(--rt-paper);
}

/* Grandi ritagli da toccare (copertina, foto della citazione). */
.fw-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.9rem;
}

.fw-tile {
  display: grid;
  justify-items: start;
  gap: 0.3rem;
  padding: 1.1rem;
  border: 0;
  border-radius: 26px 20px 28px 22px;
  background: var(--rt-accent);
  color: #161616;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--rt-ink);
  transition:
    translate 0.15s,
    box-shadow 0.15s;
}

.fw-tile[hidden] {
  display: none;
}

.fw-tile-sage {
  background: var(--rt-sage);
}

@media (hover: hover) {
  .fw-tile:hover {
    translate: -2px -2px;
    box-shadow: 6px 6px 0 var(--rt-ink);
  }
}

.fw-tile .icon {
  width: 32px;
  height: 32px;
}

.fw-tile b {
  font: 800 1.12rem var(--rt-display);
}

.fw-tile span {
  font-size: 0.8rem;
}

.fw-tiles-small .fw-tile {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.7rem;
  padding: 0.8rem;
}

.fw-tiles-small .fw-tile .icon {
  grid-row: span 2;
  width: 26px;
  height: 26px;
}

.fw-tiles-small .fw-tile b {
  font-size: 0.98rem;
}

.fw-or {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.2rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.fw-or::before,
.fw-or::after {
  content: "";
  flex: 1;
  border-top: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}

/* --- Libro: aggiunta a mano o modifica ----------------------------------------------- */
.book-dialog.is-add .bd-edit,
.book-dialog.is-edit .bd-add {
  display: none;
}

.bd-pane {
  display: grid;
  gap: 0.9rem;
}

.bd-pane[hidden] {
  display: none;
}

/* La copertina col modo di averla. */
.bd-cover {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 1.1rem;
}

.bd-cover b {
  font-family: var(--rt-display);
}

.bd-cover .fw-hint {
  margin: 0.2rem 0 0.6rem;
}

dialog.fw #cover-preview {
  width: 96px;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
}

dialog.fw #cover-preview.cover-empty {
  border: 2px dashed var(--muted);
  background: none;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

dialog.fw #cover-preview:not(.cover-empty) {
  box-shadow: 5px 5px 0 var(--rt-ink);
  rotate: -2deg;
}

/* «Altri dettagli»: chiusi finché servono; in modifica è la sezione «L'edizione». */
.book-dialog.is-add .bd-more {
  border-radius: 20px;
  background: var(--rt-bg);
}

.book-dialog.is-add .bd-more[open] {
  padding: 0 1rem 1rem;
}

.bd-more summary {
  display: flex;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.bd-more[open] summary {
  margin: 0 -1rem;
}

.bd-more summary::-webkit-details-marker {
  display: none;
}

.bd-more summary::after {
  content: "＋";
}

.bd-more[open] summary::after {
  content: "−";
}

/* La ricerca online in «L'edizione». */
dialog.fw .lookup {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0 0 0.4rem;
  border: 0;
  border-bottom: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}

dialog.fw .lookup-bar {
  display: flex;
  gap: 0.5rem;
}

/* --- Copertina ------------------------------------------------------------------- */
.fw-compare {
  display: grid;
  grid-template-columns: 110px auto 110px;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0.2rem 0 0.4rem;
}

.fw-cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: hsl(var(--hue, 30) 24% 30%);
  color: #fffaf1;
  box-shadow: 5px 5px 0 var(--rt-ink);
}

.fw-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fw-cover .ph-title {
  padding: 0.5rem;
  font: 700 0.8rem/1.15 var(--rt-display);
  text-align: center;
}

.fw-cover-new {
  border: 2px dashed var(--muted);
  background: repeating-linear-gradient(45deg, var(--rt-blush) 0 8px, var(--rt-paper) 8px 16px);
  color: var(--muted);
  font-size: 0.78rem;
  box-shadow: none;
  rotate: -3deg;
}

.fw-arrow {
  color: var(--muted);
  font: 800 1.8rem var(--rt-display);
}

.fw-private {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Ritaglio della copertina -------------------------------------------------------- */
dialog.fw .crop-stage {
  border-radius: 18px;
  overflow: hidden;
}

dialog.fw .crop-handle {
  border: 3px solid var(--rt-ink);
  background: var(--rt-accent);
}

/* --- Citazione ------------------------------------------------------------------- */
.qd-book {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: 0.9rem;
}

.qd-book i {
  flex: none;
  width: 12px;
  height: 34px;
  border-radius: 2px;
  background: var(--qd-spine, #2f5d62);
}

.qd-book b {
  font-family: var(--rt-display);
}

/* La frase su un ritaglio col dorso del libro; la pagina in un bollino senape nell'angolo. */
.qd-card {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  margin-top: 0.6rem;
  filter: drop-shadow(4px 4px 0 var(--rt-ink));
}

.qd-spine {
  border-radius: 8px 2px 2px 8px;
  background: var(--qd-spine, #2f5d62);
}

dialog.fw .qd-card textarea {
  min-height: 150px;
  padding: 1rem 4.6rem 1rem 1rem;
  border: 0;
  border-radius: 2px 20px 22px 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rt-ink) 10%, transparent), transparent 14px), var(--rt-bg);
  color: var(--rt-ink);
  font: 600 1.15rem/1.45 var(--rt-display);
  resize: vertical;
  box-shadow: none;
}

dialog.fw .qd-card textarea:focus-visible {
  outline: none;
}

.qd-page {
  position: absolute;
  top: -14px;
  right: -10px;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  box-shadow: 3px 3px 0 var(--rt-ink);
  rotate: 6deg;
  text-align: center;
}

.qd-page small {
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
}

dialog.fw .qd-page input {
  width: 52px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 800 1.2rem var(--rt-display);
  text-align: center;
  box-shadow: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.qd-page input::-webkit-inner-spin-button,
.qd-page input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qd-page input:focus-visible {
  outline: 2px solid var(--rt-ink);
  border-radius: 6px;
}

.qd-count {
  margin: -0.4rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.qd-count:empty {
  display: none;
}

/* Con una foto già scelta (o salvata) non serve proporne un'altra. */
.quote-dialog:has(#quote-crop:not([hidden]), #quote-current:not([hidden])) :is(.fw-or, .fw-tiles) {
  display: none;
}

dialog.fw .quote-current img,
dialog.fw .quote-crop canvas {
  border-radius: 14px;
}

/* --- Telefono: un foglio che sale dal basso ---------------------------------------- */
/* --- Le ultime finestre (28/10/2026, prova in tools/prova-ultime) ----------------------- */
/* Edizioni, Importa, Esporta, Cambia password, Elimina account: il bollino con l'icona nella testa. */
.fw-bubble {
  display: grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  font-size: 1.3rem;
  box-shadow: 3px 3px 0 var(--rt-ink);
  rotate: -6deg;
}

.fw-b-accent { background: #e0a518; }
.fw-b-sage { background: #c3cbb0; }
.fw-b-blush { background: #f3cfc3; }
.fw-b-coral { background: #e9785a; }

.fw-label {
  margin: 0;
  font: 800 0.92rem var(--rt-display);
}

/* La ricerca a pillola (Edizioni). */
.fw-search {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: var(--rt-bg);
  color: var(--muted);
}

.fw-search:focus-within {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

.fw-search .icon {
  flex: none;
  width: 18px;
  height: 18px;
}

dialog.fw .fw-search input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rt-ink);
  font: 500 0.95rem var(--rt-body);
  box-shadow: none;
  outline: none;
}

/* Le edizioni: righe con la copertina, il testo e il pulsante. */
#editions-dialog .lookup-results {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#editions-dialog .lookup-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: 18px;
  background: var(--rt-bg);
  color: var(--rt-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#editions-dialog .lookup-item:hover {
  box-shadow: inset 0 0 0 2px var(--rt-ink);
}

#editions-dialog .lookup-item:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

#editions-dialog .lookup-thumb {
  display: block;
  width: 52px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 5px;
  background: color-mix(in srgb, var(--muted) 25%, var(--rt-bg));
  box-shadow: 3px 3px 0 var(--rt-ink);
}

#editions-dialog .lookup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#editions-dialog .lookup-text {
  display: grid;
  min-width: 0;
  font-size: 0.8rem;
}

#editions-dialog .lookup-text strong {
  font: 800 0.95rem/1.15 var(--rt-display);
  overflow-wrap: anywhere;
}

#editions-dialog .lookup-text .muted {
  color: var(--muted);
}

#editions-dialog .lookup-add {
  padding: 0.35rem 0.85rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: var(--rt-paper);
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Importa: il file in un grande riquadro tratteggiato (verde quando c'è). */
.fw-drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 1.4rem 1rem;
  border: 2px dashed var(--rt-ink);
  border-radius: 22px;
  background: var(--rt-bg);
  text-align: center;
  cursor: pointer;
}

.fw-drop input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.fw-drop:focus-within {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

.fw-drop i {
  font-style: normal;
  font-size: 2rem;
}

.fw-drop b {
  font: 800 1.05rem var(--rt-display);
  overflow-wrap: anywhere;
}

.fw-drop small {
  color: var(--muted);
  font-size: 0.8rem;
}

.fw-drop.is-chosen {
  border-style: solid;
  background: color-mix(in srgb, #c3cbb0 55%, var(--rt-bg));
}

.fw-help summary {
  font: 800 0.92rem var(--rt-display);
  cursor: pointer;
}

.fw-sources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
}

.fw-sources li {
  padding: 0.7rem 0.8rem;
  border-radius: 18px;
  background: var(--rt-bg);
  font-size: 0.8rem;
}

.fw-sources b {
  display: block;
  font: 800 0.92rem var(--rt-display);
}

/* L'anteprima dell'importazione in bollini colorati. */
.fw-sum {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}

.fw-sum div {
  padding: 0.7rem 0.8rem;
  border-radius: 18px;
  background: #f3cfc3;
  color: #161616;
}

.fw-sum .is-new { background: #c3cbb0; }
.fw-sum .is-skip { background: #e0a518; }

.fw-sum b {
  display: block;
  font: 800 1.5rem/1 var(--rt-display);
}

.fw-sum span {
  font-size: 0.75rem;
}

/* Interruttore a pillola (una radio per voce) e scelte a ritagli (Esporta). */
.fw-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  justify-self: start;
  align-self: flex-start;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
}

.fw-toggle label,
.fw-choices label {
  position: relative;
  cursor: pointer;
}

.fw-toggle input,
.fw-choices input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.fw-toggle span {
  display: block;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
}

.fw-toggle input:checked + span {
  background: var(--rt-ink);
  color: var(--rt-paper);
}

.fw-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fw-choices span {
  display: grid;
  gap: 0.2rem;
  height: 100%;
  padding: 0.9rem 1rem;
  border: 2px solid var(--rt-ink);
  border-radius: 22px 18px 24px 20px;
  background: var(--rt-bg);
  transition: translate 0.15s ease, box-shadow 0.15s ease;
}

.fw-choices b {
  font: 800 1rem var(--rt-display);
}

.fw-choices small {
  color: var(--muted);
  font-size: 0.78rem;
}

.fw-choices input:checked + span {
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  box-shadow: 4px 4px 0 var(--rt-ink);
  translate: -2px -2px;
}

.fw-choices input:checked + span small {
  color: inherit;
  opacity: 0.8;
}

:is(.fw-toggle, .fw-choices) input:focus-visible + span {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

/* La password con l'occhio (Cambia password, Elimina account): come nell'accesso. */
dialog.fw .ax-pass input {
  padding-right: 3rem;
}

dialog.fw .ax-pass input::-ms-reveal,
dialog.fw .ax-pass input::-ms-clear {
  display: none;
}

/* Elimina account: bordo corallo, cosa si cancella, «Prima di andare». */
dialog.fw.fw-red {
  border-color: var(--rt-coral);
}

.fw-gone {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fw-gone li {
  padding: 0.45rem 0.8rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--rt-coral) 16%, var(--rt-bg));
  font-size: 0.88rem;
}

.fw-save {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.8rem 1rem;
  border: 2px dashed var(--rt-ink);
  border-radius: 18px;
  font-size: 0.88rem;
}

.fw-save p {
  flex: 1 1 220px;
  margin: 0;
}

.fw-btn.fw-main.fw-red-btn {
  background: var(--rt-coral);
  color: #161616;
}

@media (max-width: 760px) {
  .fw-sources,
  .fw-choices {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Accesso in due passaggi (#twofa-dialog, 28/10/2026) ------------------------------- */
/* Il QR su un foglio bianco anche col tema scuro (le app leggono meglio scuro su chiaro), accanto
   la chiave da scrivere; i codici di riserva su due colonne in carattere a larghezza fissa. */
.tf-steps {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
  font-size: 0.92rem;
}

.tf-scan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.2rem;
  margin-bottom: 0.9rem;
}

.tf-qr {
  flex: none;
  width: 184px;
  height: 184px;
  padding: 8px;
  border: 2px solid var(--rt-ink);
  border-radius: 16px;
  background: #fff;
  box-shadow: 4px 4px 0 var(--rt-ink);
  image-rendering: pixelated;
}

.tf-key {
  display: grid;
  flex: 1 1 200px;
  justify-items: start;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.85rem;
}

.tf-key p {
  margin: 0;
  color: var(--muted);
}

.tf-key code,
.tf-codes {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.tf-key code {
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--rt-ink) 8%, transparent);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

/* «Apri nell'app» (otpauth://) solo dove c'è il dito: sul PC l'app di solito non c'è. */
.tf-open {
  text-decoration: none;
}

@media (pointer: fine) {
  .tf-open {
    display: none;
  }
}

.twofa-dialog .tf-code {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-align: center;
}

.tf-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1rem;
  margin: 0 0 0.9rem;
  padding: 0.9rem 1rem 0.9rem 2.8rem;
  border: 2px dashed var(--rt-ink);
  border-radius: 16px;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.tf-code-actions,
.tf-on-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

#twofa-dialog .tf-saved {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: 0;
  font-weight: 700;
  text-align: left;
}

#twofa-dialog .tf-saved input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--rt-accent);
}

.tf-on {
  margin: 0 0 0.9rem;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  background: var(--rt-sage);
  color: #161616;
}

.fw-pill.tf-off {
  border-color: var(--rt-coral);
}

@media (max-width: 760px) {
  .tf-scan {
    justify-content: center;
  }
}

/* Sul telefono i codici di riserva in una colonna sola: in due non ci stanno. */
@media (max-width: 520px) {
  .tf-codes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- «Sistema il ritratto» (#frame-dialog) --------------------------------------------- */
/* Foto intera a sinistra col cerchio tratteggiato senape di ciò che entra nel ritratto (fuori
   scurito); a destra l'anteprima nella forma della scheda dell'autore, le due misure degli elenchi
   e lo zoom. Sul telefono la foto sopra, il resto sotto. */
dialog.frame-dialog {
  width: min(780px, calc(100vw - 64px));
}

.frame-who {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font: 600 0.8rem var(--rt-body);
  letter-spacing: 0;
}

.fw-hint b {
  color: var(--rt-ink);
}

.frame-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 1.6rem;
  align-items: center;
}

.frame-photo {
  position: relative;
  justify-self: center;
  max-width: 100%;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 0 0 2px var(--rt-ink);
  line-height: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.frame-photo:active {
  cursor: grabbing;
}

.frame-photo img {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  pointer-events: none;
}

.frame-marker {
  position: absolute;
  border-radius: 50%;
  translate: -50% -50%;
  outline: 3px dashed var(--rt-accent);
  outline-offset: -3px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.5);
  pointer-events: none;
}

.frame-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px;
  border-radius: 50%;
  background: var(--rt-accent);
  box-shadow: 0 0 0 2px var(--rt-ink);
}

.frame-side {
  display: grid;
  justify-items: center;
  gap: 1rem;
}

/* L'anteprima come nella scheda dell'autore: forma di carta, ombra d'inchiostro, appena girata. */
#frame-dialog .frame-preview {
  width: 170px;
  height: 170px;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  box-shadow: 7px 7px 0 var(--rt-ink);
  rotate: -3deg;
}

.frame-info {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
}

.frame-caption {
  margin: 0;
  color: var(--muted);
  font: 700 0.8rem var(--rt-body);
}

.frame-where {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

#frame-dialog .frame-mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: 2px 2px 0 var(--rt-ink);
}

#frame-dialog .frame-mini-2 {
  width: 48px;
  height: 48px;
}

.frame-zoom {
  display: grid;
  gap: 0.3rem;
  width: 100%;
}

.frame-zoom-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  font-size: 0.85rem;
}

.frame-zoom-label b {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  font: 800 0.8rem var(--rt-display);
}

.frame-zoom-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 0.5rem;
  align-items: center;
}

.frame-zoom-row input {
  width: 100%;
  accent-color: var(--rt-accent);
}

.frame-step {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--rt-ink);
  border-radius: 50%;
  background: var(--rt-paper);
  color: var(--rt-ink);
  font: 800 1.2rem var(--rt-display);
  cursor: pointer;
}

/* «Inquadratura automatica» sotto lo zoom: è un modo di inquadrare, non di chiudere. */
.frame-auto {
  justify-content: center;
  width: 100%;
  font-size: 0.85rem;
}

.frame-step:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .frame-editor {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .frame-photo img {
    max-height: 36vh;
  }

  .frame-side {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    align-items: center;
  }

  #frame-dialog .frame-preview {
    width: 110px;
    height: 110px;
    box-shadow: 5px 5px 0 var(--rt-ink);
  }

  .frame-info {
    justify-items: start;
  }

  .frame-zoom,
  .frame-auto {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  dialog.fw {
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - 38px);
    margin: auto 0 0;
    padding: 0;
    border-width: 2px 0 0;
    border-radius: 28px 28px 0 0;
    box-shadow: none;
  }

  dialog.fw::backdrop {
    backdrop-filter: none;
  }

  dialog.fw > form {
    max-height: calc(100dvh - 40px);
  }

  /* La linguetta in alto, come i fogli che si trascinano. */
  .fw-head {
    position: relative;
    padding: 24px 16px 10px;
  }

  .fw-head::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 46px;
    height: 6px;
    translate: -50% 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 55%, transparent);
  }

  dialog.fw h2 {
    font-size: 1.45rem;
  }

  .fw-body {
    padding: 4px 16px 16px;
  }

  .fw-foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }

  /* Sul telefono i pulsanti del piede si allargano: se vanno a capo, ciascuno occupa la riga. */
  .fw-foot > button {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .fw-foot .spacer {
    display: none;
  }

  .fw-compare {
    grid-template-columns: 96px auto 96px;
  }
}
