/* ==============================================================================
   BIBLIONOTES - COMPONENTI UI (iOS PWA) v2.1
   Copertine ad alto impatto, form ottimizzati per tastiera iPhone, accessibilità
   ============================================================================== */

/* --- PULSANTI (Touch Target Apple >= 44px) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  min-height: 44px;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold), #CB8535);
  color: #0A0C10;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(229, 164, 84, 0.35);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 12.5px;
  min-height: 36px;
  border-radius: var(--radius-sm);
}

/* --- BARRA DI RICERCA GLOBALE --- */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  gap: 10px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.search-bar:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold-soft);
}

.search-bar svg {
  width: 19px;
  height: 19px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px; /* Font size >= 16px evita lo zoom automatico di Safari iOS */
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-size: 14.5px;
}

/* --- SEGMENTED PILLS --- */
.segmented-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.segmented-scroll::-webkit-scrollbar {
  display: none;
}

.segment-pill {
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.segment-pill.active {
  background: var(--accent-gold-soft);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 700;
}

/* --- CAROSELLO IN LETTURA --- */
.reading-carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
  margin-bottom: 18px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.reading-carousel::-webkit-scrollbar {
  display: none;
}

.reading-card {
  flex: 0 0 290px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  position: relative;
}

.reading-card:active {
  transform: scale(0.98);
}

.book-cover {
  width: 76px;
  height: 112px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--bg-tertiary);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}

.book-cover-placeholder {
  width: 76px;
  height: 112px;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #1A1F2C, #283145);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.reading-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.book-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.book-author {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

/* --- GRIGLIA LIBRERIA CON COPERTINE IN EVIDENZA --- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 480px) {
  .books-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 720px) {
  .books-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }
}

.grid-book-card {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.grid-book-card:active {
  transform: scale(0.97);
}

.grid-book-cover-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-tertiary);
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.grid-book-cover-wrap .grid-book-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.grid-book-cover-wrap .grid-book-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #181D2A, #242D3F);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
}

.grid-book-placeholder-icon {
  font-size: 26px;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.grid-book-placeholder-title {
  font-weight: 700;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.grid-book-card .book-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 35px;
  margin-bottom: 3px;
  word-break: break-word;
}

.grid-book-card .book-author {
  font-size: 12px;
  line-height: 1.25;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 16px;
  margin-bottom: 8px;
}

.grid-book-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
  min-height: 24px;
}

.grid-book-rating {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
}

.grid-book-progress-slot {
  height: 8px;
  margin-top: 6px;
  display: flex;
  align-items: center;
}

.grid-book-progress-slot .progress-bar-bg {
  width: 100%;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  width: fit-content;
}

/* Progresso */
.progress-container {
  width: 100%;
  margin-top: 6px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), #F3BA72);
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* --- NOTE STRUTTURATE --- */
.notes-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-note-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge-note-type.idea { color: var(--note-idea); background: rgba(245, 158, 11, 0.15); }
.badge-note-type.summary { color: var(--note-summary); background: rgba(59, 130, 246, 0.15); }
.badge-note-type.quote { color: var(--note-quote); background: rgba(16, 185, 129, 0.15); }
.badge-note-type.reflection { color: var(--note-reflection); background: rgba(168, 85, 247, 0.15); }

.badge-page {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 6px;
}

.note-date {
  font-size: 11.5px;
  color: var(--text-muted);
}

.note-book-ref {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.note-title-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.35;
}

.note-citation-box {
  background: rgba(229, 164, 84, 0.08);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-style: italic;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.note-content {
  font-size: 14.5px;
  color: var(--text-primary);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* --- DETTAGLIO LIBRO HERO --- */
.book-detail-hero {
  display: flex;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.detail-cover {
  width: 105px;
  height: 155px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
}

.detail-author {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.star-rating {
  display: inline-flex;
  gap: 4px;
  cursor: pointer;
  padding: 4px 0;
}

.star-rating svg {
  width: 22px;
  height: 22px;
  fill: transparent;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  transition: all 0.15s ease;
}

.star-rating svg.filled {
  fill: var(--accent-gold);
  stroke: var(--accent-gold);
}

/* --- ATTIVITÀ DI LETTURA REALI --- */
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
}

.activity-badge-pages {
  font-weight: 700;
  color: var(--status-completed);
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}

/* --- STATISTICHE WIDGETS --- */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.metric-value span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-left: 2px;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 140px;
  padding-top: 10px;
  gap: 6px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 20px;
  background: linear-gradient(180deg, var(--accent-gold), #A96E2E);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  min-height: 4px;
}

.chart-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 6px;
}

.chart-val-hint {
  font-size: 9.5px;
  color: var(--accent-gold);
  font-weight: 700;
  margin-bottom: 3px;
}

/* --- MODALI & BOTTOM SHEETS (iOS) --- */
.sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.active {
  display: flex;
  opacity: 1;
}

.bottom-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 92dvh;
  background: var(--bg-sheet);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border-top: 1px solid var(--border-strong);
  padding: 12px 20px calc(var(--safe-bottom) + 20px) 20px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.sheet-backdrop.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  background: var(--text-muted);
  opacity: 0.4;
  border-radius: 3px;
  margin: 0 auto 12px auto;
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding-right: 2px;
}

/* Modale di Conferma */
.confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.confirm-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.confirm-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form Styles & iOS Safari Fix (font-size >= 16px) */
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 16px; /* Evita lo zoom non richiesto in iOS Safari */
  font-family: inherit;
  outline: none;
  min-height: 46px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold-soft);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Toasts */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 60px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--status-completed); }
.toast.error { border-left: 4px solid var(--sync-error); }
.toast.info { border-left: 4px solid var(--accent-gold); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  stroke: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 14px;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13.5px;
  max-width: 290px;
  margin-bottom: 16px;
  line-height: 1.45;
}

/* Edizioni alternative (Editions Explorer) */
.editions-box {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.edition-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border-subtle);
}

.edition-item:last-child {
  margin-bottom: 0;
}

.edition-cover-thumb {
  width: 32px;
  height: 48px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.edition-info {
  flex: 1;
  min-width: 0;
}

.edition-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edition-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}


/* ---- v3: aggiornamento, dimensione testo, obiettivo, scanner ---- */
:root { --ui-scale: 1; }
.view-section, .sheet-content { zoom: var(--ui-scale); }

.update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  background: var(--accent-gold); color: #111; font-size: 13px; font-weight: 600;
}

.size-picker { display: flex; gap: 8px; }
.size-picker .btn { flex: 1; }
.size-picker .btn.active { border-color: var(--accent-gold); color: var(--accent-gold); }

.goal-card { margin-bottom: 16px; }
.goal-bar { height: 8px; border-radius: 4px; background: var(--bg-secondary); overflow: hidden; margin: 8px 0 4px; }
.goal-bar > div { height: 100%; background: var(--accent-gold); border-radius: 4px; transition: width .4s ease; }

.scanner-wrap { position: relative; border-radius: var(--radius-md); overflow: hidden; background: #000; margin-bottom: 12px; }
.scanner-wrap video { width: 100%; max-height: 260px; object-fit: cover; display: block; }
.scanner-wrap::after { content: ''; position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: rgba(239,68,68,.8); }

/* ---- Profilo social: scelta visibilità libreria ---- */
.vis-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-secondary); cursor: pointer; }
.vis-option.selected { border-color: var(--accent-gold); }
.vis-option input { margin-top: 3px; accent-color: var(--accent-gold); }
.vis-option-title { display: block; font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.vis-option-desc { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Community: avatar, schede lettore, feed ---- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-gold-soft); color: var(--accent-gold); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.readers-list, .feed-list, .reader-books { display: flex; flex-direction: column; gap: 10px; }
.reader-card, .feed-item { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); cursor: pointer; }
.feed-item { align-items: flex-start; }
.reader-info, .feed-body { flex: 1; min-width: 0; }
.reader-name { font-weight: 700; font-size: 14.5px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-handle { font-size: 12px; color: var(--text-muted); }
.reader-bio { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reader-bio-full { font-size: 13.5px; color: var(--text-secondary); margin: 10px 0; white-space: pre-wrap; }
.reader-head { display: flex; gap: 14px; align-items: center; }
.reader-counts { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); margin: 10px 0 12px; }
.reader-counts strong { color: var(--text-primary); }
.follow-btn { flex-shrink: 0; }
.feed-line { font-size: 13.5px; color: var(--text-primary); line-height: 1.4; }
.feed-meta { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 4px; }
.feed-cover { width: 44px; height: 66px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.stars-inline { color: var(--accent-gold); font-size: 13px; letter-spacing: 1px; }
.review-text { font-size: 13px; color: var(--text-secondary); margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.spoiler-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.spoiler-hidden { filter: blur(6px); cursor: pointer; user-select: none; }
.reader-book-row { display: flex; gap: 12px; padding: 10px; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.reader-book-cover { width: 44px; height: 66px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.reader-book-cover-ph { display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); }
.reader-book-info { flex: 1; min-width: 0; }
.reader-book-title { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.reader-book-author { font-size: 12px; color: var(--text-secondary); }
.reader-book-status { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ---- Consigli "Per te" ---- */
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-card { display: flex; gap: 12px; padding: 12px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.rec-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rec-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-gold-soft); color: var(--accent-gold); }
.rec-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }

/* ==============================================================================
   PRIMA CONFIGURAZIONE (onboarding) E SFIDA DI LETTURA - stile "carta e inchiostro"
   ============================================================================== */
.onb-root { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--bg-primary); color: var(--text-primary); padding-top: env(safe-area-inset-top); }
.onb-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.onb-step { font-size: 11.5px; font-weight: 700; color: var(--accent-gold); background: var(--accent-gold-soft); border-radius: 999px; padding: 5px 11px; white-space: nowrap; }
.onb-title { flex: 1; font-family: Georgia, 'Times New Roman', serif; font-size: 1.05rem; font-weight: 700; }
.onb-skip { background: none; border: 0; color: var(--text-secondary); font-size: 13.5px; font-weight: 600; padding: 8px 4px; cursor: pointer; }
.onb-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 16px 8px; }
.onb-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.onb-lead { font-family: Georgia, 'Times New Roman', serif; font-size: 1.02rem; line-height: 1.45; margin: 0 0 16px; color: var(--text-primary); }
.onb-hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; }
.onb-badge { width: 132px; height: 132px; border-radius: 14px; margin: 8px 0 18px; background: var(--accent-gold); color: var(--text-inverse); display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: Georgia, 'Times New Roman', serif; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); border: 3px double rgba(0, 0, 0, .35); }
.onb-badge span { font-size: 2.1rem; font-weight: 700; line-height: 1; }
.onb-badge small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 6px; font-weight: 700; }
.onb-chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; justify-content: center; }
.onb-chip { min-width: 54px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary); font-weight: 700; font-size: 15px; cursor: pointer; }
.onb-chip.on { border-color: var(--accent-gold); background: var(--accent-gold-soft); color: var(--accent-gold); }
.onb-goal-input { max-width: 140px; text-align: center; font-size: 1.3rem; font-weight: 700; }
.onb-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-subtle); flex-shrink: 0; background: var(--bg-primary); }
.onb-next { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }
.onb-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.onb-card-title { font-weight: 700; }
.onb-card-desc { font-size: 12.5px; color: var(--text-secondary); }
.onb-loading { text-align: center; padding: 24px; color: var(--text-muted); }
.onb-genres { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 12px; }
.onb-genre { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary); font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer; }
.onb-genre span { font-size: 20px; }
.onb-genre.on { border-color: var(--accent-gold); background: var(--accent-gold-soft); }
.onb-books { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.onb-book { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card); }
.onb-cover, .challenge-cover-ph { width: 56px; height: 82px; flex-shrink: 0; border-radius: 4px 8px 8px 4px; background: hsl(var(--h, 30) 38% 34%); color: #fff; display: flex; align-items: center; justify-content: center; font-family: Georgia, 'Times New Roman', serif; font-size: 1.5rem; font-weight: 700; box-shadow: inset 4px 0 0 rgba(0, 0, 0, .25); }
.onb-book-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.onb-book-title { font-weight: 700; font-size: 14px; line-height: 1.25; }
.onb-book-author { font-size: 12px; color: var(--text-secondary); }
.onb-stars { display: flex; gap: 2px; margin: 2px 0; }
.onb-star { background: none; border: 0; padding: 2px 3px; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.onb-star.on { color: var(--accent-gold); }

.challenge-hero { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px; text-align: center; }
.challenge-count b { font-family: Georgia, 'Times New Roman', serif; font-size: 2.6rem; color: var(--accent-gold); }
.challenge-count span { font-size: 1.1rem; color: var(--text-secondary); margin-left: 6px; }
.challenge-label { font-size: 12.5px; color: var(--text-secondary); }
.challenge-pace { font-weight: 700; font-size: 13.5px; margin-top: 8px; }
.challenge-pace.good { color: var(--accent-gold); }
.challenge-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.challenge-edit { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.challenge-edit .form-input { max-width: 110px; }
.challenge-shelf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.challenge-book { cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.challenge-book img, .challenge-book .challenge-cover-ph { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px 8px 8px 4px; }
.challenge-book-title { font-size: 11.5px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Scaffali e Scopri */
.shelf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.shelf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-secondary); color: var(--text-primary); font-size: 12.5px; font-weight: 600; }
.shelf-chip.on { border-color: var(--accent-gold); background: var(--accent-gold-soft); }
.shelf-chip.suggest { cursor: pointer; color: var(--text-secondary); }
.shelf-x { background: none; border: 0; padding: 0 0 0 4px; color: var(--text-muted); font-size: 11px; cursor: pointer; }
.shelf-empty { font-size: 12.5px; color: var(--text-muted); }
.shelf-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.shelf-add .form-input { flex: 1; min-width: 0; }
.shelf-pill { font-style: italic; }
