/* MeMori — aspetto grafico.
 * Stile da giornale e rivista d'epoca (riferimenti: «Poetry» 1912, «Poesia» di Marinetti, pagine di
 * annunci del 1900, il «Corriere Lombardo»): carta ingiallita, inchiostro nero, giallo senape (nel
 * tema scuro viola), testata in carattere calligrafico (Fondamento), titoli in bastone stretto e
 * nerissimo, testo con le grazie, filetti semplici e doppi, riquadri come articoli. Il tema scuro è
 * la stessa pagina in negativo, su carta seppia scura.
 * Il tema segue il sistema, oppure la scelta fatta nella pagina Account (attributo data-theme su
 * <html>, vedi theme.js). Tutti i colori sono variabili qui sotto: per cambiare tinta basta
 * modificarle. */

/* --- Caratteri ---------------------------------------------------------------- */
/* Ospitati dal sito (public/fonts, licenza SIL Open Font License, testi OFL-*.txt nella stessa
   cartella): il browser non contatta Google o altri servizi. Solo alfabeto latino e latino esteso.
   Fondamento: testata, nome del sito e capilettera. Oswald: titoli, occhielli, menù. Playfair Display: titoli dei libri.
   Libre Caslon Text: testo. */
@font-face {
  font-family: "Libre Caslon Text";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/LibreCaslonText-italic-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Caslon Text";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/LibreCaslonText-italic-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/LibreCaslonText-normal-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/LibreCaslonText-normal-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/LibreCaslonText-normal-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/LibreCaslonText-normal-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Oswald-normal-400_700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Oswald-normal-400_700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/PlayfairDisplay-italic-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/PlayfairDisplay-italic-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url("fonts/PlayfairDisplay-normal-700_900-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url("fonts/PlayfairDisplay-normal-700_900-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Fondamento";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Fondamento-normal-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Fondamento";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Fondamento-normal-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Colori e misure -------------------------------------------------------- */
:root {
  /* Carta bianco avorio e inchiostro (dal 27/10/2026 su richiesta dell'utente: prima carta di
     giornale d'epoca, #efe6d1; il bianco puro era «troppo bianco»: un bianco caldo che si accosta
     alla senape). Superfici e bordi in toni caldi chiari. */
  --bg: #fcf9f2;
  --bg-glow: #fcf9f2;
  --surface: #f7f2e6;
  --surface-2: #eee7d7;
  --surface-3: #e1d7c2;
  --text: #1d1a16;
  --muted: #5d564b;
  --border: #d2c7b0;
  /* Filetto forte (testata, colonne, riquadri). */
  --rule: #1d1a16;
  /* Il colore del tema ha un nome nostro (--mm-…, MeMori): un'estensione di Avast metteva nelle
     pagine una sua --accent blu, e le scritte senape diventavano blu (27/10/2026). */
  /* Colore del tema chiaro: giallo senape. Come testo (link, occhielli, motto) un ocra scuro che
     sulla carta si legge (--mm-accent); come fondo pieno (occhielli in apertura, pulsanti) il giallo
     vivo con testo nero (--fill). */
  --mm-accent: #8a6100;
  --mm-accent-hover: #6e4d00;
  --mm-accent-text: #fff8ee;
  --mm-accent-soft: #f3e3b3;
  --fill: #d4a21a;
  --fill-hover: #e2b43a;
  --fill-text: #1d1a16;
  /* Prima era l'oro dei dettagli: ora è l'ocra. */
  --mm-gold: #8a6100;
  --danger: #a3241a;
  --danger-soft: #f1d6c8;
  --star: #1d1a16;
  --star-off: #d6ccb6;

  /* Niente ombre: solo per finestre e copertine. */
  --shadow-sm: 0 0 0 transparent;
  --shadow: 0 0 0 transparent;
  --shadow-lg: 0 18px 40px -16px rgb(40 25 10 / 0.35);
  --shadow-book: 0 1px 2px rgb(40 25 10 / 0.18), 0 6px 14px -8px rgb(40 25 10 / 0.35);

  --radius: 2px;
  --radius-sm: 2px;
  --nav-height: 64px;
  /* Altezza del menù in alto sul PC (ritagli.css). */
  --masthead-height: 76px;
  /* Caratteri (vedi «Caratteri» sopra). --serif è il testo; --display i titoli dei libri;
     --condensed titoli, occhielli e menù; --testata la testata, il nome del sito e i capilettera
     (prima in gotico Fraktur, poco leggibile: scelta dell'utente). */
  --serif: "Libre Caslon Text", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --display: "Playfair Display", "Libre Caslon Text", Georgia, serif;
  --condensed: "Oswald", "Arial Narrow", "Helvetica Neue", sans-serif;
  --testata: "Fondamento", "Palatino Linotype", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* Colori degli stati (segnalibro sulle copertine, schede, pagina del libro), inchiostri d'epoca:
     blu di Prussia da leggere, terracotta in lettura (l'ocra è il colore del tema), verde oliva
     letto, grigio abbandonato. Si cambiano qui (e sotto, per lo scuro). */
  --s-da_leggere: #2e4a6b;
  --s-in_lettura: #a5532a;
  --s-letto: #3d6b3a;
  --s-abbandonato: #7a7064;
  /* Testo sopra un colore di stato pieno. */
  --on-status: #fff8ee;
  /* Mensole degli scaffali: cartoncino, niente legno finto. */
  --wood-top: #cdbf9f;
  --wood-bottom: #a8987a;

  color-scheme: light;
}

/* Scuro: la stessa pagina in negativo, su carta seppia scurissima. Vale con il sistema in modalità
   scura (se non si è scelto "Chiaro") oppure con "Scuro" scelto nella pagina Account. I due blocchi
   qui sotto vanno cambiati insieme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --bg-glow: #17140f;
    --surface: #1f1b15;
    --surface-2: #29241c;
    --surface-3: #332d23;
    --text: #efe4cc;
    --muted: #a99c84;
    --border: #4a4133;
    --rule: #efe4cc;
    /* Colore del tema scuro: viola. Testo viola chiaro, fondi pieni viola con testo chiaro. */
    --mm-accent: #b996ec;
    --mm-accent-hover: #cbb0f2;
    --mm-accent-text: #17140f;
    --mm-accent-soft: #2e2440;
    --fill: #8e5fd0;
    --fill-hover: #a378e0;
    --fill-text: #f5eedd;
    --mm-gold: #b996ec;
    --danger: #ef6b61;
    --danger-soft: #3b2219;
    --star: #efe4cc;
    --star-off: #4a4133;
    --shadow-sm: 0 0 0 transparent;
    --shadow: 0 0 0 transparent;
    --shadow-lg: 0 18px 40px -16px rgb(0 0 0 / 0.8);
    --shadow-book: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 18px -8px rgb(0 0 0 / 0.8);
    --s-da_leggere: #8fb0d6;
    --s-in_lettura: #e08a5f;
    --s-letto: #86b97a;
    --s-abbandonato: #a39684;
    --on-status: #17140f;
    --wood-top: #3b3428;
    --wood-bottom: #2a251c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --bg-glow: #17140f;
  --surface: #1f1b15;
  --surface-2: #29241c;
  --surface-3: #332d23;
  --text: #efe4cc;
  --muted: #a99c84;
  --border: #4a4133;
  --rule: #efe4cc;
  --mm-accent: #b996ec;
  --mm-accent-hover: #cbb0f2;
  --mm-accent-text: #17140f;
  --mm-accent-soft: #2e2440;
  --fill: #8e5fd0;
  --fill-hover: #a378e0;
  --fill-text: #f5eedd;
  --mm-gold: #b996ec;
  --danger: #ef6b61;
  --danger-soft: #3b2219;
  --star: #efe4cc;
  --star-off: #4a4133;
  --shadow-sm: 0 0 0 transparent;
  --shadow: 0 0 0 transparent;
  --shadow-lg: 0 18px 40px -16px rgb(0 0 0 / 0.8);
  --shadow-book: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 18px -8px rgb(0 0 0 / 0.8);
  --s-da_leggere: #8fb0d6;
  --s-in_lettura: #e08a5f;
  --s-letto: #86b97a;
  --s-abbandonato: #a39684;
  --on-status: #17140f;
  --wood-top: #3b3428;
  --wood-bottom: #2a251c;
  color-scheme: dark;
}

/* --- Base ------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

/* Sul PC la testata in alto è fissa: quando la pagina scorre fino a un punto (es. i risultati dei
   consigli) lo lascia sotto la testata, non nascosto. */
@media (min-width: 761px) {
  html {
    scroll-padding-top: calc(var(--masthead-height) + 1rem);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.55 var(--serif);
  background: var(--bg);
}

/* Titoli da quotidiano: bastone stretto e nerissimo (Oswald), interlinea stretta. */
h1,
h2,
h3 {
  font-family: var(--condensed);
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 0.5rem;
  letter-spacing: 0;
}

/* Titolo di pagina: maiuscolo, come la testata di una sezione del giornale. */
h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  text-transform: uppercase;
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.1rem;
}

a {
  color: var(--mm-accent);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Menù: in ritagli.css (stile «Ritagli») ------------------------------------- */

/* --- Layout ----------------------------------------------------------------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 32px 4rem;
}

body.with-nav main {
  max-width: none;
  padding: calc(var(--masthead-height) + 2.5rem) clamp(24px, 4vw, 56px) 4rem;
}

body.with-nav main > section {
  max-width: 1180px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  color: var(--muted);
  margin-top: 4rem;
}

/* Riquadri come articoli di giornale: niente scatola, solo un filetto sopra (come i riquadri
   della Home); lo spazio a destra e a sinistra è quello della pagina. */
.card {
  background: none;
  border: 0;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  box-shadow: none;
}

.panel {
  padding: 1.25rem 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel h2 {
  margin: 0;
}

/* Testata di pagina: occhiello rosso, titolo grande, filetto spesso sotto. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 0.7rem;
  border-bottom: 4px double var(--rule);
}

.page-head h1 {
  margin: 0;
}

/* --- Accesso: accesso.css ------------------------------------------------------------ */

/* --- Form ------------------------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.form small {
  font-weight: 400;
}

input,
select,
textarea {
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  width: 100%;
  min-width: 0;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  cursor: pointer;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--mm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mm-accent) 22%, transparent);
}

.btn:focus-visible,
.tab:focus-visible,
.link:focus-visible,
.status-tab:focus-visible,
.status-chip:focus-visible,
.book:focus-visible,
.lookup-item:focus-visible {
  outline: 2px solid var(--mm-accent);
  outline-offset: 2px;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.form-error {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-line;
}

.form-error:empty,
.form-success:empty {
  display: none;
}

.form-success {
  color: var(--mm-accent);
  background: var(--mm-accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin: 0;
  font-size: 0.9rem;
}

.link {
  background: none;
  border: 0;
  padding: 0.2rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--mm-accent);
  cursor: pointer;
  align-self: center;
}

.link:hover {
  text-decoration: underline;
}

.rating-input {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
}

.rating-input legend {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.form .rating-input label {
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  font-weight: 400;
  color: var(--star);
}

.rating-input input {
  width: auto;
  accent-color: var(--mm-accent);
  box-shadow: none;
}

/* --- Pulsanti --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.15rem;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Pulsante principale: fondo pieno nel colore vivo del tema (giallo nel chiaro, viola nello scuro). */
.btn-primary {
  background: var(--fill);
  color: var(--fill-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--fill-hover);
}

/* Secondario: contorno in inchiostro, senza riempimento. */
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--rule);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

/* --- Home: in home.css (stile «Ritagli») ------------------------------------------ */

/* --- Libreria: in libreria.css (stile «Ritagli»). Qui restano le parti usate anche da altre pagine
   (stati, ricerca, catalogo, copertine). ------------------------------------------------- */
/* Schede per stato: filtro e conteggi insieme. */
.status-tabs {
  display: flex;
  min-width: 0;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 2px 6px;
}

.status-tabs::-webkit-scrollbar {
  display: none;
}

/* Sul PC le schede vanno a capo (accanto c'è «Aggiungi libro»); sul telefono scorrono di lato. */
@media (min-width: 761px) {
  .status-tabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

.status-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  color: var(--text);
  font-family: var(--condensed);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.status-tab:hover {
  border-color: var(--muted);
}

.status-tab .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 0;
  background: var(--status-color);
}

.status-tab .count {
  min-width: 1.6em;
  padding: 0.05rem 0.4rem;
  border-radius: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.status-tab[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.status-tab[aria-pressed="true"] .count {
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  color: inherit;
}

/* Catalogo (vista predefinita della libreria): come il catalogo di un editore o l'indice di un
   giornale, tre colonne separate da filetti, i libri raggruppati sotto capilettera nel carattere
   della testata (o sotto un titoletto: decennio, voto, mese, secondo l'ordine scelto). Ogni riga:
   titolo, autore in corsivo, puntini fino alle stelle e al quadratino del colore dello stato. */
.catalog {
  columns: 3 16rem;
  column-gap: 2.5rem;
  column-rule: 1px solid var(--rule);
}

.catalog-group {
  margin-bottom: 0.9rem;
}

.catalog-letter {
  margin: 0;
  color: var(--mm-accent);
  font-family: var(--testata);
  font-size: 2.6rem;
  font-weight: 400;
  line-height: 1.1;
  text-transform: none;
  break-after: avoid;
}

.catalog-heading {
  margin: 0.2rem 0 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  break-after: avoid;
}

.catalog-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.catalog-entry {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding: 0.2rem 0;
  break-inside: avoid;
}

.catalog-link {
  min-width: 0;
  color: inherit;
  text-decoration: none;
  line-height: 1.3;
}

.catalog-link:hover .catalog-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.catalog-title {
  font-family: var(--display);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.catalog-author {
  margin-left: 0.35rem;
  color: var(--muted);
  font-style: italic;
}

/* I puntini tra il titolo e le stelle, come in un listino. */
.catalog-lead {
  flex: 1 0 1.25rem;
  margin-bottom: 0.4em;
  border-bottom: 1px dotted var(--muted);
}

.catalog-entry .verdict-tag {
  flex: none;
  font-size: 0.75rem;
}

/* Lo stato: un quadratino del suo colore; l'area da toccare è più grande del quadratino. */
.catalog-status {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin: 0 -0.45rem -0.3rem -0.2rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.catalog-status::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  background: var(--status-color);
}

.catalog-status:hover::before,
.catalog-status[aria-expanded="true"]::before {
  outline: 2px solid var(--status-color);
  outline-offset: 2px;
}

.catalog-status:focus-visible {
  outline: 2px solid var(--mm-accent);
  outline-offset: 1px;
}

/* Scaffale: copertine grandi, titolo e autore sotto. */
.books {
  list-style: none;
  /* Spazio in alto e tra le righe (il segnalibro dello stato sporge appena sopra i libri). */
  padding: 1.25rem 0 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2.75rem 1.5rem;
}

.book {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.book .book-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 1px 3px 3px 1px;
  box-shadow: var(--shadow-book);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book:hover .book-cover,
.book:focus-visible .book-cover {
  transform: translateY(-6px) rotate(-0.6deg);
  box-shadow: var(--shadow-lg);
}

.book:focus-visible {
  outline-offset: 6px;
  border-radius: 6px;
}

.book-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

/* Titolo come i titoli dei libri della Home (Playfair), autore in corsivo come una firma. */
.book-title {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  overflow-wrap: anywhere;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--status-color, var(--mm-accent));
  background: color-mix(in srgb, var(--status-color, var(--mm-accent)) 13%, transparent);
}

.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 0;
  background: currentColor;
}

/* Riquadro del libro: lo stato è un segnalibro che spunta sopra la copertina (la copertina inizia
   in cima al riquadro), come elemento a parte: la scheda è già un pulsante. */
.book-item {
  position: relative;
}

/* Lo stato: un segnalibro del suo colore appeso al bordo superiore della copertina, a sinistra
   (sporge appena, 4 px; dal 28/10/2026, prima usciva tutto sopra il libro), con la coda di rondine
   in basso. L'area da toccare comprende anche il bordo della copertina, comoda col dito. */
.cover-status {
  position: absolute;
  top: -4px;
  left: 0.6rem;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 2.5rem;
  height: 2.9rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.cover-status::before {
  content: "";
  width: 1.05rem;
  height: 1.55rem;
  /* Più scuro in alto, dove si piega sul bordo. */
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.22), transparent 30%), var(--status-color);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.3));
  transition: transform 0.15s ease;
}

/* Toccandolo si sfila un poco. */
.cover-status:hover::before,
.cover-status[aria-expanded="true"]::before {
  transform: translateY(-0.3rem);
}

.cover-status:focus-visible {
  outline: none;
}

.cover-status:focus-visible::before {
  outline: 2px solid var(--mm-accent);
  outline-offset: 2px;
}

/* Menù degli stati, accanto al bollino toccato. */
.status-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  min-width: 11rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.status-menu[hidden] {
  display: none;
}

.status-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.6rem;
  padding: 0.4rem 0.7rem;
  border: 0;
  border-radius: calc(var(--radius-sm) - 4px);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.status-menu-item::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 0;
  background: var(--status-color);
}

.status-menu-item[aria-checked="true"] {
  background: color-mix(in srgb, var(--status-color) 14%, transparent);
}

.status-menu-item[aria-checked="true"]::after {
  content: "✓";
  margin-left: auto;
  color: var(--status-color);
}

.status-menu-item:hover,
.status-menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}

.empty-icon {
  width: 3rem;
  height: 3rem;
  stroke-width: 1.3;
  color: var(--border);
}

.empty-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.5rem 0 0.25rem;
}

/* --- Copertine -------------------------------------------------------------- */
.book-cover,
.lookup-thumb,
.cover {
  position: relative;
  flex: none;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-cover img,
.lookup-thumb img,
.cover img,
.book-page-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Dorso: una leggera ombra a sinistra, come un libro vero. */
.book-cover::after,
.book-page-cover::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7%;
  background: linear-gradient(90deg, rgb(0 0 0 / 0.18), rgb(255 255 255 / 0.08) 60%, transparent);
  pointer-events: none;
}

.book-cover {
  width: 56px;
  height: 84px;
  box-shadow: var(--shadow-book);
}

/* Senza copertina: titolo e autore su un fondo colorato (tinta dal titolo, vedi hueOf).
   Misure in cqi (percentuali della larghezza della copertina): il testo si adatta a ogni
   dimensione, dalla scheda dei consigli alla pagina del libro. */
.cover-placeholder {
  container-type: inline-size;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: 0;
  /* Come la tela di una vecchia rilegatura: tinta smorzata e una cornice sottile all'interno. */
  background: hsl(var(--hue, 30) 24% 30%);
  color: hsl(40 45% 88%);
  box-shadow:
    inset 0 0 0 5cqi hsl(var(--hue, 30) 24% 30%),
    inset 0 0 0 calc(5cqi + 1px) hsl(40 45% 88% / 0.7);
  text-align: center;
  border: 0;
}

.ph-title {
  margin: 14cqi 11cqi 0;
  padding-bottom: 5cqi;
  border-bottom: 1px solid currentColor;
  font-family: var(--display);
  font-weight: 700;
  font-size: max(0.55rem, 11cqi);
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ph-author {
  margin: 0 9cqi 12cqi;
  font-family: var(--condensed);
  font-size: max(0.45rem, 7cqi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
  overflow-wrap: anywhere;
}

/* Copertine piccole (miniature): solo il colore, il testo non ci sta. */
.lookup-thumb .ph-title,
.lookup-thumb .ph-author {
  display: none;
}

.cover-empty:not(.cover-placeholder) {
  border: 1px dashed var(--border);
  box-shadow: none;
}

.lookup-thumb {
  width: 40px;
  height: 60px;
  box-shadow: var(--shadow-sm);
}

.cover {
  width: 96px;
  height: 144px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 0.4rem;
}

.cover:not(.cover-empty) {
  padding: 0;
  box-shadow: var(--shadow-book);
}

/* --- Ricerca online --------------------------------------------------------- */
.lookup {
  background: var(--mm-accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lookup-bar {
  display: flex;
  gap: 0.5rem;
}

/* Scansione del codice a barre: anteprima della fotocamera. */
.scanner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.scanner[hidden] {
  display: none;
}

.scanner-view {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.scanner video {
  display: block;
  width: 100%;
  max-height: 45vh;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #000;
}

/* Riquadro guida: la fascia centrale che il nostro lettore guarda (vedi grayImage in app.js). */
.scanner-guide {
  position: absolute;
  inset: 30% 8%;
  border: 2px solid var(--fill);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.25);
  pointer-events: none;
}

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.scanner p {
  margin: 0;
  font-size: 0.85rem;
}

.lookup-status {
  margin: 0;
  font-size: 0.88rem;
}

.lookup-status:empty {
  display: none;
}

.lookup-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 300px;
  overflow-y: auto;
}

.lookup-results:empty {
  display: none;
}

.lookup-results > li {
  display: flex;
  flex-direction: column;
}

/* "43 edizioni Mondadori →" sotto un risultato: apre solo quelle. */
.lookup-editions {
  align-self: flex-end;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--mm-accent);
  background: none;
  border: 0;
  padding: 0.15rem 0.3rem;
  cursor: pointer;
}

.lookup-editions:hover,
.lookup-editions:focus-visible {
  text-decoration: underline;
}

/* "Altri editori": tutti, in una finestra grande. */
.editions-open {
  align-self: center;
}

dialog.editions-dialog {
  width: min(960px, calc(100vw - 32px));
}

.editions-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  max-height: min(65vh, 640px);
}

.editions-results .lookup-thumb {
  width: 48px;
  height: 72px;
}

/* Un risultato che si sta aggiungendo (finestra Aggiungi, in aggiungi.css). */
.lookup-item[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

.lookup-add {
  margin-left: auto;
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mm-accent);
}

.lookup-item {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.lookup-item:hover {
  border-color: var(--mm-accent);
  box-shadow: var(--shadow);
}

.lookup-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

/* Titolo e autore insieme, in evidenza; editore, anno e ISBN sotto, più piccoli. */
.lookup-text strong {
  font-family: var(--serif);
  font-size: 1rem;
}

.lookup-author {
  font-weight: 600;
}

/* --- Pagina del libro ------------------------------------------------------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.back-link:hover {
  color: var(--text);
}

.book-page-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 1px 3px 3px 1px;
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  align-self: start;
}

/* Dati del libro come la scheda tecnica di una recensione: tra due filetti, senza riquadro. */
.bp-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0.5rem 0 0;
  padding: 0.8rem 0;
  font-size: 0.93rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--border);
}

.bp-facts:empty {
  display: none;
}

.bp-facts dt {
  color: var(--muted);
}

.bp-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* --- Letture e pagina del libro: barra, diario, citazioni (Letture: letture.css) ------- */
/* La barra dell'avanzamento senza numero di pagine (solo la cornice). */
.progress {
  height: 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
}

/* La barra dell'avanzamento è il cursore del browser (input range) ridisegnato: cornice, parte
   letta gialla fino a --share, cursore d'inchiostro. Si tocca o si trascina. */
.page-slider {
  --share: 0%;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: linear-gradient(to right, var(--fill) var(--share), var(--surface) var(--share));
  box-shadow: none;
  appearance: none;
  cursor: pointer;
}

.page-slider:focus-visible {
  outline: 2px solid var(--mm-accent);
  outline-offset: 3px;
  box-shadow: none;
}

.page-slider::-webkit-slider-runnable-track {
  height: 100%;
  background: none;
}

.page-slider::-moz-range-track {
  height: 100%;
  background: none;
}

.page-slider::-webkit-slider-thumb {
  width: 8px;
  height: 40px;
  margin-top: -7px;
  border: 0;
  border-radius: 0;
  background: var(--text);
  appearance: none;
}

.page-slider::-moz-range-thumb {
  width: 8px;
  height: 40px;
  border: 0;
  border-radius: 0;
  background: var(--text);
}

.page-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-top: 0.6rem;
}

.progress-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--condensed);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Il numero della pagina si scrive qui: grande, sottolineato, come un campo di un modulo. */
.page-number {
  width: 5.5rem;
  padding: 0.15rem 0.2rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
  appearance: textfield;
}

.page-number::-webkit-inner-spin-button,
.page-number::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.page-number:focus-visible {
  border-bottom-color: var(--mm-accent);
  box-shadow: 0 1px 0 var(--mm-accent);
}

.page-form .btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.reading-stats {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-family: var(--condensed);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reading-diary {
  margin-top: 0.9rem;
}

.reading-diary summary {
  cursor: pointer;
  font-family: var(--condensed);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reading-diary ol {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
}

.reading-diary li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px dotted var(--muted);
  font-size: 0.92rem;
}

.diary-remove {
  padding: 0 0.4rem;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.diary-remove:hover {
  color: var(--danger);
}

/* Una citazione: il testo in corsivo con le virgolette grandi nel colore del tema. */
.quote {
  position: relative;
  margin: 0.9rem 0 0;
  padding-left: 2.2rem;
}

.quote blockquote::before {
  content: "«";
  position: absolute;
  left: -2.2rem;
  top: -0.35rem;
  color: var(--mm-accent);
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
}

.quote blockquote {
  position: relative;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.6;
  white-space: pre-line;
}

.quote figcaption {
  margin-top: 0.2rem;
  color: var(--muted);
  font-family: var(--condensed);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quote-edit {
  padding: 0;
  border: 0;
  background: none;
  color: var(--mm-accent);
  font: inherit;
  cursor: pointer;
}

.quote-edit:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Finestra della citazione: la foto con il riquadro da trascinare. */
.quote-crop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quote-crop canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 55vh;
  object-fit: contain;
  border: 1px solid var(--rule);
  touch-action: none;
  cursor: crosshair;
}

.quote-crop p {
  margin: 0.4rem 0;
}

/* Anteprima del ritaglio e foto attuale della citazione. */
.quote-preview-label {
  margin: 0.6rem 0 0.3rem;
  font-family: var(--condensed);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#quote-preview,
.quote-current img {
  display: block;
  max-width: 100%;
  max-height: 30vh;
  border: 1px solid var(--rule);
}

.quote-current {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

/* La foto di una citazione, sopra il testo (o da sola). */
.quote-image {
  display: block;
  max-width: 100%;
  max-height: 340px;
  margin-bottom: 0.4rem;
  border: 1px solid var(--rule);
  box-shadow: 0 6px 14px -10px rgb(0 0 0 / 0.5);
}

.catalog-wish {
  position: absolute;
  top: -1.25rem;
  right: 0;
  z-index: 1;
  min-height: 1.9rem;
  padding: 0.25rem 0.65rem;
  border: 0;
  border-radius: 0;
  background: var(--fill);
  color: var(--fill-text);
  font-family: var(--condensed);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.catalog-wish:hover {
  background: var(--fill-hover);
}

.catalog-wish:focus-visible {
  outline: 2px solid var(--mm-gold);
  outline-offset: 2px;
}

.catalog-wish:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Nel catalogo la copertina è il segnaposto con titolo in alto e autore in basso: «+ Desideri»
   va al centro, nello spazio vuoto (75cqw = metà dell'altezza di una copertina 2:3). */
.catalog-item {
  container-type: inline-size;
}

.catalog-item .catalog-wish {
  top: calc(75cqw - 1rem);
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Catalogo delle opere (scheda dell'autore): le opere che non hai si aggiungono ai desideri con
   «+ Desideri» (come «Comprato» nei Desideri); quelle già in lista hanno un'etichetta. */
.author-catalog {
  margin-top: 2.5rem;
}

/* Un'opera senza edizione è un link alla sua scheda. */
a.book {
  text-decoration: none;
}

/* Scheda dell'opera: la copertina (del tuo libro o segnaposto) riempie il riquadro grande. */
#wp-cover .book-cover {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

#wp-actions .muted {
  align-self: center;
}

/* Nella scheda dell'opera le edizioni stanno tutte nella pagina, senza riquadro che scorre. */
#wp-editions {
  max-height: none;
  overflow: visible;
}

/* Edizioni solo da vedere (l'opera è già in libreria): niente effetto al passaggio. */
.lookup-item.lookup-static {
  cursor: default;
  color: inherit;
  opacity: 1;
}

.lookup-item.lookup-static:hover {
  border-color: var(--border);
  box-shadow: none;
}

.wp-old {
  margin-top: 1rem;
}

.wp-old summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.wp-old-list {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.catalog-tag {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  padding: 0.25rem 0.65rem;
  border-radius: 0;
  background: var(--text);
  color: var(--bg);
  font-family: var(--condensed);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* --- Scaffali --------------------------------------------------------------- */

/* La mensola di uno scaffale nell'elenco: i libri in piedi, di dorso (vedi .book-spine). Ci sono
   tutti e la mensola si scorre col dito in orizzontale; toccandola si apre lo scaffale. L'aspetto
   «Ritagli» (riquadri, mensola colorata, dorsi F1) è in scaffali.css. */
.shelf-row {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 158px;
  padding: 20px 1.2rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 55%, rgb(0 0 0 / 0.06)),
    var(--surface-2);
}

/* Spazio in fondo alla fila, così l'ultimo libro non resta attaccato al bordo scorrendo. */
.shelf-row::after {
  content: "";
  flex: none;
  width: 1rem;
}

/* Un libro in piedi visto di dorso: colore della copertina (o dal titolo), ombre ai bordi per
   dare volume, titolo e autore in verticale (si leggono dal basso, come sui libri veri). */
.book-spine {
  position: relative;
  flex: none;
  display: flex;
  justify-content: center;
  width: var(--thick, 24px);
  height: var(--tall, 92%);
  border-radius: 2px 2px 1px 1px;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 0.28), rgb(255 255 255 / 0.14) 28%, transparent 55%, rgb(0 0 0 / 0.22)),
    var(--spine, hsl(var(--hue, 30) var(--sat, 40%) var(--light, 32%)));
  color: var(--spine-ink, hsl(var(--hue, 30) 45% 93%));
  text-decoration: none;
  box-shadow: 1px 0 0 rgb(0 0 0 / 0.22), 0 4px 8px -4px rgb(0 0 0 / 0.5);
  transition: transform 0.15s ease;
}

/* Il segnalibro dello stato che spunta dall'alto del libro. */
.book-spine::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: clamp(5px, 45%, 10px);
  height: 11px;
  transform: translateX(-50%);
  background: var(--status-color);
  clip-path: polygon(0 0, 50% 30%, 100% 0, 100% 100%, 0 100%);
}

.book-spine-text {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  max-height: 100%;
  padding: 0.7rem 0;
  overflow: hidden;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: clamp(0.55rem, calc(var(--thick, 24px) * 0.42), 0.8rem);
  line-height: 1;
}

.book-spine-title {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--serif);
  font-weight: 700;
}

.book-spine-author {
  flex: none;
  max-height: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.shelf-plank {
  height: 14px;
  background: linear-gradient(180deg, var(--wood-top), var(--wood-bottom));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 6px 10px -6px rgb(0 0 0 / 0.5);
}

/* --- Autori ----------------------------------------------------------------- */
/* Ritratto rotondo, oppure le iniziali su un colore che dipende dal nome. */
.author-avatar,
.author-portrait-image {
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.author-avatar {
  width: 64px;
  height: 64px;
  font-size: 1.3rem;
}

.author-avatar img,
.author-portrait-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

/* Ritratto incorniciato dall'utente («Sistema il ritratto»): misure e posizione in linea,
   calcolate da framedStyle in app.js perché il volto stia al centro del cerchio. */
.author-avatar,
.author-portrait-image {
  position: relative;
}

.author-avatar img.framed,
.author-portrait-image img.framed {
  position: absolute;
  max-width: none;
  object-fit: fill;
}

/* «Ritaglia la copertina»: la foto, fuori dal ritaglio scurita, e quattro angoli da trascinare.
   La larghezza della foto la decide cropCoverPhoto (alta al massimo il 60% della finestra). */
dialog.crop-dialog {
  width: min(720px, calc(100vw - 32px));
}

.crop-stage {
  position: relative;
  margin: 0.5rem auto 0;
  line-height: 0;
  touch-action: none;
  user-select: none;
}

.crop-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.crop-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#crop-outside {
  fill: rgb(0 0 0 / 0.55);
}

#crop-quad {
  fill: none;
  stroke: #fff;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.crop-handle {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.25);
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.55);
  cursor: grab;
  touch-action: none;
}

.crop-handle:active {
  cursor: grabbing;
}

.crop-handle:focus-visible {
  outline: 3px solid var(--mm-accent);
  outline-offset: 2px;
}

/* Sul telefono angoli più grandi, facili da prendere col dito. */
@media (pointer: coarse) {
  .crop-handle {
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
  }
}

.avatar-initials {
  background: linear-gradient(140deg, hsl(var(--hue, 30) 35% 42%), hsl(var(--hue, 30) 40% 28%));
  color: hsl(var(--hue, 30) 45% 94%);
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.04em;
}

#author-credit:empty {
  display: none;
}

/* --- Pillole dei consigli (anche nella finestra di benvenuto); le pagine: scopri.css ------- */
.rec-features {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rec-group h3 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.rec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.rec-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: line-through;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rec-chip[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--mm-accent);
  background: var(--mm-accent-soft);
  color: var(--mm-accent);
  text-decoration: none;
}

.rec-chip .count {
  font-size: 0.75rem;
  opacity: 0.8;
}

.rec-chip:focus-visible {
  outline: 2px solid var(--mm-accent);
  outline-offset: 2px;
}

/* Schede dei consigli: copertina in alto, testo sotto, «Desideri» in fondo. */
.rec-custom-chosen:empty {
  display: none;
}

.rec-custom-list {
  max-height: 168px;
  overflow-y: auto;
  padding: 0.15rem;
}

/* Qui una voce non scelta è solo da scegliere (non «spenta» come in «Affina»). */
.rec-custom-list .rec-chip:not([aria-pressed="true"]) {
  border-style: solid;
  color: var(--text);
  text-decoration: none;
}

.rec-custom-chosen .rec-chip::after {
  content: "×";
  margin-left: 0.15rem;
  font-weight: 700;
}

.bp-editions {
  max-height: 420px;
}

/* --- Account: account.css ------------------------------------------------------------- */
.form label.check,
.form .language-picker label {
  flex-direction: row;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}

/* Caselle e pallini: della loro misura, non larghi quanto la riga come gli altri campi. */
.form input[type="checkbox"],
.form input[type="radio"] {
  width: auto;
  flex: none;
}

/* Comunità: recensioni dei lettori (pagina del libro, profilo pubblico, moderazione). Come gli
   articoli del giornale: filetti, niente scatole. */
.community-summary {
  margin: 0 0 0.5rem;
}

.community-average {
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--mm-accent);
}

.reviews {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.review {
  padding: 0.8rem 0;
  border-top: 1px solid var(--border);
}

.review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.7rem;
  margin: 0 0 0.35rem;
}

.review-author {
  font-family: var(--condensed);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.review-body {
  margin: 0;
  white-space: pre-line;
}

.review-spoiler summary {
  cursor: pointer;
  color: var(--mm-accent);
  font-family: var(--condensed);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.review-report {
  margin-top: 0.3rem;
  font-size: 0.85rem;
}

.review-form {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 4px double var(--rule);
}

.review-form h3 {
  margin: 0;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 0.2rem 1.5rem;
  justify-content: start;
  margin: 0 0 1.5rem;
}

.profile-stats dt {
  grid-row: 2;
  font-family: var(--condensed);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-stats dd {
  grid-row: 1;
  margin: 0;
  font-family: var(--display);
  font-size: 1.6rem;
}

.profile-books {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  columns: 2 280px;
}

.profile-books li {
  padding: 0.25rem 0;
  break-inside: avoid;
}

.profile-preview {
  padding: 0.5rem 0.8rem;
  border: 1px dashed var(--rule);
}

/* Libreria di un altro lettore: come la propria, ma i libri non si aprono (niente segnalibro). */
.profile-library {
  margin-bottom: 1.5rem;
}

.profile-library .book {
  cursor: default;
}

.community-stats {
  margin: -0.25rem 0 0.75rem;
}

/* Lingue in cui si legge: caselle in fila, che vanno a capo sul telefono. */
.language-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.language-picker label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

/* Benvenuto: accesso.css. */
/* Inviti (solo amministratore): sotto le due colonne, aperti da un filetto doppio come le
   altre rubriche. Il modulo su una riga sul PC; il link appena creato in un riquadro. */
.invites-panel {
  margin-top: 1.5rem;
  border-top: 4px double var(--rule);
}

.invite-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.invite-form label:first-of-type {
  flex: 1 1 260px;
}

.invite-form .form-error {
  flex-basis: 100%;
  order: 3;
}

.invite-new {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--rule);
}

.invite-new p {
  margin: 0;
}

.invite-new code {
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.invite-new .btn {
  align-self: flex-start;
}

.invite-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.invite {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.invite-note {
  font-weight: 600;
}

.invite-when {
  flex: 1 1 auto;
}

.invite [data-revoke] {
  margin-left: auto;
}

/* Inviti chiusi (usati, scaduti, revocati) in secondo piano. */
.invite:not(.invite-attivo) .invite-note {
  color: var(--muted);
}

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

/* Importazione da Goodreads: istruzioni, scelta dei «Want to Read» e anteprima. */
.import-steps {
  margin: 0;
  padding-left: 1.3rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.import-steps strong {
  color: var(--text);
}

/* «Come esportare da Goodreads e da Anobii»: chiuso di base, per non allungare la finestra. */
.import-help summary {
  cursor: pointer;
  color: var(--mm-accent);
  font-weight: 600;
  font-size: 0.92rem;
}

.import-help .import-steps {
  margin-top: 0.5rem;
}

.import-label {
  margin: 0 0 -0.5rem;
  font-weight: 600;
}

.import-summary {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.import-summary p {
  margin: 0.2rem 0;
}

.import-total {
  font-weight: 700;
}

/* --- Finestre --------------------------------------------------------------- */
/* Come un riquadro di giornale: carta, filetto d'inchiostro, angoli dritti. */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 3px double var(--rule);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgb(15 10 5 / 0.5);
  backdrop-filter: blur(3px);
}

dialog h2 {
  font-size: 1.5rem;
}

.spacer {
  flex: 1;
}

/* --- Notifiche -------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.2rem;
  border-radius: 0;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
  font-weight: 600;
  z-index: 50;
}

/* --- Schermi medi ----------------------------------------------------------- */
@media (max-width: 1000px) {

}

@media (max-width: 760px) {


}

/* --- Schermi piccoli (telefono) -------------------------------------------- */
@media (max-width: 760px) {
  main,
  body.with-nav main {
    margin-left: 0;
    padding: 1.5rem 16px 2rem;
  }

  body.with-nav main {
    padding-top: 1.5rem;
    padding-bottom: calc(var(--nav-height) + 2rem + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-bottom: 1.1rem;
  }

  .catalog-letter {
    font-size: 2rem;
  }

  .books {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 1rem;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .cover {
    width: 72px;
    height: 108px;
  }

  .bp-facts {
    width: 100%;
    text-align: left;
  }

  /* Finestre come fogli che salgono dal basso. */
  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 0;
    border-width: 3px 0 0;
    padding: 1.4rem 1.1rem calc(1.25rem + env(safe-area-inset-bottom));
  }

  dialog.editions-dialog {
    width: 100vw;
  }

  body.with-nav .toast {
    left: 50%;
    bottom: calc(var(--nav-height) + 1rem + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* La copertina segnaposto della pagina del libro: colorata come le altre (la regola
   .book-page-cover, più avanti nel file, ne metterebbe lo sfondo neutro). */
.book-page-cover.cover-placeholder {
  background: hsl(var(--hue, 30) 24% 30%);
  color: hsl(40 45% 88%);
}

/* Miniature dei libri da scegliere per i consigli: solo il titolo, l'autore non ci sta. */
.rec-book .ph-author {
  display: none;
}

