@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/static/fonts/public-sans-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/material-symbols-outlined-subset.woff2') format('woff2');
}

.material-symbols-outlined {
  align-items: center;
  direction: ltr;
  display: inline-flex;
  flex-shrink: 0;
  font-family: 'Material Symbols Outlined';
  font-feature-settings: 'liga';
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
  height: 1em;
  justify-content: center;
  letter-spacing: normal;
  line-height: 1;
  min-width: 1em;
  overflow: hidden;
  text-transform: none;
  user-select: none;
  vertical-align: middle;
  visibility: hidden;
  white-space: nowrap;
  width: 1em;
  word-wrap: normal;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

html.material-symbols-ready .material-symbols-outlined {
  visibility: visible;
}

/* ── Initial app shell ────────────────────────────────────────────────────── */
.app-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgb(var(--primary-rgb) / 0.08), transparent 34%),
    var(--bg);
}

.app-boot-overlay.is-exiting {
  pointer-events: none;
  animation: app-boot-overlay-exit 220ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

.app-boot-overlay[hidden] {
  display: none;
}

.app-boot-overlay__logo {
  width: min(14rem, 58vw);
  height: auto;
  transform-origin: center center;
}

.app-boot-overlay.is-exiting .app-boot-overlay__logo {
  animation: app-boot-logo-exit 220ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Keyframes ─────────────────────────────────────────────────────────────── */
@keyframes app-boot-overlay-exit {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes app-boot-logo-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-26px) scale(0.92);
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(220, 38, 38, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Pod si espande con leggero overshoot spring */
@keyframes pod-appear {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* Entrata contenuti: sale da sotto con fade */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pop scale per icone / bottoni */
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Uscita login */
@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Micro-feedback avvio registrazione */
@keyframes rec-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.88);
  }
  100% {
    transform: scale(1);
  }
}

/* Invio nota: successo bottone */
@keyframes note-btn-success {
  0% {
    transform: scale(1);
    background: var(--accent);
    opacity: 1;
  }
  35% {
    transform: scale(1.18);
    background: linear-gradient(145deg, #34c759, #30d158);
    opacity: 1;
  }
  65% {
    transform: scale(0.96);
    background: linear-gradient(145deg, #34c759, #30d158);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    background: linear-gradient(145deg, #34c759, #30d158);
    opacity: 0;
  }
}

/* Invio nota: uscita textarea */
@keyframes note-text-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-7px);
  }
}

/* Bounce successo stato done */
@keyframes done-pop {
  0% {
    transform: scale(0.82);
  }
  55% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* ── Onboarding ───────────────────────────────────────────────────────────── */
#onboardingOverlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgb(var(--primary-rgb) / 0.09), transparent 38%),
    linear-gradient(180deg, rgb(255 255 255 / 0.72), transparent 32%),
    var(--bg);
  pointer-events: auto;
  overscroll-behavior: contain;
  overflow-y: auto;
}

#onboardingOverlay[hidden] {
  display: none;
}

.dark #onboardingOverlay {
  background:
    radial-gradient(circle at top, rgb(var(--primary-rgb) / 0.16), transparent 34%),
    linear-gradient(180deg, rgb(15 23 42 / 0.52), transparent 32%),
    var(--bg);
}

.onboarding-welcome {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  color: var(--text);
}

.onboarding-welcome__content {
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 24px 28px;
}

.onboarding-welcome__title {
  max-width: 12ch;
  font-size: clamp(2.1rem, 5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
  font-weight: 700;
}

.onboarding-welcome__intro {
  margin-top: 14px;
  max-width: 34rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-2);
}

.onboarding-welcome__body {
  display: grid;
  gap: 18px;
  margin-top: 30px;
}

.onboarding-welcome__feature {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.onboarding-welcome__feature-icon-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgb(var(--primary-rgb) / 0.12), rgb(var(--primary-rgb) / 0.06));
  border: 1px solid rgb(var(--primary-rgb) / 0.12);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45);
}

.dark .onboarding-welcome__feature-icon-shell {
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12);
}

.onboarding-welcome__feature-icon {
  font-size: 1.35rem;
  color: var(--accent);
}

.onboarding-welcome__feature-copy {
  min-width: 0;
}

.onboarding-welcome__feature-title {
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.onboarding-welcome__feature-description {
  margin-top: 4px;
  font-size: 0.96rem;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.onboarding-welcome__actions {
  width: min(100%, 42rem);
  margin: auto auto 0;
  padding: 0 24px calc(20px + var(--safe-bottom));
}

.onboarding-overlay__button {
  min-height: 3.5rem;
  width: 100%;
  border: none;
  border-radius: 1.15rem;
  padding: 0 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease;
}

.onboarding-overlay__button:active:not(:disabled) {
  transform: scale(0.985);
}

.onboarding-overlay__button:disabled {
  opacity: 0.55;
}

.onboarding-overlay__button--primary {
  background: linear-gradient(145deg, rgb(var(--primary-rgb)), rgb(var(--primary-rgb) / 0.88));
  color: #ffffff;
  box-shadow: 0 8px 22px rgb(var(--primary-rgb) / 0.28);
}

.onboarding-welcome__cta {
  width: 100%;
}

.onboarding-overlay[data-layout='mobile'] .onboarding-welcome--panel {
  min-height: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.onboarding-overlay[data-layout='desktop'] {
  align-items: center;
  padding: 2rem;
}

.onboarding-overlay[data-layout='desktop'] .onboarding-welcome--panel {
  width: min(100%, 32rem);
  min-height: auto;
  margin: auto;
  border-radius: 2rem;
  overflow: hidden;
}

.onboarding-overlay[data-layout='desktop'] .onboarding-welcome__content {
  width: 100%;
  padding: 1.75rem 1.75rem 1.4rem;
}

.onboarding-overlay[data-layout='desktop'] .onboarding-welcome__actions {
  width: 100%;
  padding: 0 1.75rem 1.75rem;
}

@media (min-width: 768px) {
  .onboarding-welcome__body {
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .onboarding-welcome {
    animation: fade-in-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* ── Reset & tokens ────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --primary-rgb: 0 52 98;
  --primary-soft: rgba(0, 52, 98, 0.1);
  --primary-ring: rgba(0, 52, 98, 0.24);
  --primary-shadow: rgba(0, 52, 98, 0.28);
  --accent: rgb(var(--primary-rgb));
  --search-bg: rgba(116, 116, 128, 0.18);
  --search-surface: rgba(248, 250, 252, 0.8);
  --search-surface-focus: rgba(248, 250, 252, 0.88);
  --search-border: rgba(148, 163, 184, 0.18);
  --card-radius: 9px;
  --home-mobile-gutter: 16px;
  --catalog-shell-inline: 20px;
  --root-view-transition-duration: 220ms;
  --shared-detail-view-transition-duration: 380ms;
  --shared-detail-cover-transition-shadow:
    0 10px 24px rgba(0, 0, 0, 0.16),
    0 2px 6px rgba(0, 0, 0, 0.08);
  --shared-detail-button-transition-shadow:
    0 6px 18px rgba(0, 0, 0, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

:root.dark {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #ffffff;
  --text-2: #98989d;
  --primary-rgb: 75 111 147;
  --primary-soft: rgba(75, 111, 147, 0.22);
  --primary-ring: rgba(75, 111, 147, 0.36);
  --primary-shadow: rgba(75, 111, 147, 0.4);
  --accent: rgb(var(--primary-rgb));
  --search-bg: rgba(116, 116, 128, 0.24);
  --search-surface: rgba(28, 32, 38, 0.9);
  --search-surface-focus: rgba(28, 32, 38, 0.94);
  --search-border: rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  font-family:
    'Public Sans',
    -apple-system,
    'SF Pro Display',
    'Segoe UI',
    Tahoma,
    sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass {
  background: rgba(28, 28, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ios-shadow {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.04);
}

.cover-shadow {
  box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.3);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#reviewAudio {
  display: block;
  width: 100%;
  min-height: 44px;
}

@supports (-webkit-touch-callout: none) {
  #state-review {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
    min-height: 3.5rem;
  }

  #reviewAudio {
    height: 48px;
    min-height: 48px;
  }
}

#chat-input {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@keyframes sheet-slide-up {
  from {
    opacity: 0.98;
    transform: translate3d(0, 100%, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes sheet-slide-down {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }

  to {
    opacity: 0.98;
    transform: translate3d(0, 100%, 0);
  }
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes overlay-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.sheet-overlay-enter {
  animation: overlay-fade-in 0.22s ease forwards;
}

.sheet-overlay-exit {
  animation: overlay-fade-out 0.18s ease forwards;
}

.sheet-panel-enter {
  animation: sheet-slide-up 0.28s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

.sheet-panel-exit {
  animation: sheet-slide-down 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.sheet-panel-dragging {
  will-change: transform;
  transition: none !important;
}

.sheet-drag-surface {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── View shell ────────────────────────────────────────────────────────────── */
.view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition:
    transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.38s ease;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Let iOS system back/forward gestures snap the layers without fighting our own transitions. */
html.navigation-transitions-disabled .view {
  transition: none !important;
}

html.shared-navigation-transition-active .view,
html.shared-navigation-transition-active #view-home,
html.shared-navigation-transition-active #view-home.pushed,
html.shared-navigation-transition-active #view-detail,
html.shared-navigation-transition-active #detail-card,
html.shared-navigation-transition-active .back-btn {
  transition: none !important;
}

html.shared-navigation-transition-active {
  --root-view-transition-duration: 0.01ms;
}

html.shared-navigation-transition-active #view-detail.active .detail-cover,
html.shared-navigation-transition-active #view-detail.active .detail-title,
html.shared-navigation-transition-active #view-detail.active .detail-author,
html.shared-navigation-transition-active #view-detail.active .detail-category,
html.shared-navigation-transition-active #view-detail.active .bussola-section,
html.shared-navigation-transition-active #view-detail.active .note-section {
  animation: none !important;
}

html.shared-navigation-transition-active #view-detail .glass,
html.shared-navigation-transition-active #view-detail #chat-pod,
html.shared-navigation-transition-active #view-detail .bussola-item {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
}

html.shared-navigation-transition-active #view-detail .cover-shadow,
html.shared-navigation-transition-active #view-detail .detail-cover,
html.shared-navigation-transition-active #view-detail .ios-shadow,
html.shared-navigation-transition-active #view-detail .tap-feedback-btn {
  box-shadow: none !important;
  filter: none !important;
  transition: none !important;
}

html.shared-navigation-transition-active #view-detail .shared-transition-hero-shadow-button {
  box-shadow: var(--shared-detail-button-transition-shadow) !important;
}

html.shared-navigation-transition-active #view-detail .shared-transition-hero-shadow-cover-frame {
  box-shadow: var(--shared-detail-cover-transition-shadow) !important;
  filter: none !important;
  transition: none !important;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--root-view-transition-duration);
}

/* Home: keep the layer stable unless detail is actually open. */
#view-home {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.38s ease;
  will-change: auto;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}

#view-home.pushed {
  transform: translate3d(-28%, 0, 0);
  opacity: 0.65;
  pointer-events: none;
  transition:
    transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.38s ease;
  will-change: transform;
}

/* While an input in home is focused, keep the layer fully stable for iOS caret rendering. */
#view-home:focus-within {
  transform: none !important;
  transition-property: opacity;
  will-change: auto;
}

/* iOS Safari: avoid caret offset bugs in focused inputs inside transformed layers */
@supports (-webkit-touch-callout: none) {
  #view-home.pushed {
    transform: translate3d(-28%, 0, 0);
  }
}

/* Detail: starts off-screen right; slides to 0 when active */
#view-detail {
  z-index: 2;
  transform: translateX(100%);
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
}

#view-detail.active {
  transform: translateX(0);
  pointer-events: auto;
}

/*
  Avoid fixed descendants inside a transformed full-screen layer.
  WebKit is notably fragile when a translated view contains fixed overlays.
*/
#detail-card {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 100%;
}

#view-detail.detail-pull-dragging #detail-card,
#detail-card.detail-pull-rebounding {
  transform: translate3d(0, var(--detail-pull-y, 0px), 0) scale(var(--detail-pull-scale, 1));
  transform-origin: top center;
}

#view-detail.detail-pull-dragging #detail-card {
  transition: none !important;
  border-radius: calc(18px * var(--detail-pull-progress, 0));
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.22);
}

#detail-card.detail-pull-rebounding {
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

#view-detail .detail-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

#view-detail #chat-pod-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .view,
  #view-detail.active .detail-cover,
  #view-detail.active .detail-title,
  #view-detail.active .detail-author,
  #view-detail.active .detail-category,
  #view-detail.active .bussola-section,
  #view-detail.active .note-section,
  .search-clear-btn:not([hidden]),
  .note-textarea:not(:placeholder-shown) ~ .note-send-btn,
  .record-dock.pod-active #review-panel,
  #view-login.dismissing,
  .sheet-overlay-enter,
  .sheet-overlay-exit,
  .sheet-panel-enter,
  .sheet-panel-exit {
    transition: none;
    animation: none;
  }
  #recordBtn {
    animation: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* HOME VIEW                                                                   */
/* ═══════════════════════════════════════════════════════════════════════════ */

.home-header {
  flex-shrink: 0;
  padding: calc(16px + var(--safe-top)) var(--home-mobile-gutter) 0;
  background: var(--bg);
}

.home-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.1;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-header .subtitle {
  margin-top: 3px;
  font-size: 1rem;
  color: var(--text-2);
}

.search-wrapper {
  margin-top: 12px;
  padding-bottom: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--search-surface);
  border: 1px solid var(--search-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 9px 12px;
  transition:
    background 0.16s ease,
    border-color 0.16s ease;
}

.search-bar:focus-within {
  background: var(--search-surface-focus);
  border-color: var(--primary-ring);
}

/*
  iOS Safari still misplaces the caret in empty inputs inside composited layers.
  Home search sits in a fixed view shell plus a glass surface, so simplify that
  surface while the field is focused.
*/
@supports (-webkit-touch-callout: none) {
  /*
    WebKit is less glitchy if the focused single-line input is not fully
    transparent inside a composited surface.
  */
  #view-home #searchInput {
    background-color: rgba(255, 255, 255, 0.01);
  }

  .dark #view-home #searchInput {
    background-color: rgba(0, 0, 0, 0.01);
  }

  #view-home .search-bar:focus-within {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.search-bar svg {
  flex-shrink: 0;
  color: var(--text-2);
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  line-height: 1.5rem;
  min-height: 1.5rem;
  padding-top: 0;
  padding-bottom: 0;
  color: var(--text);
  outline: none;
  min-width: 0;
  appearance: textfield;
  -webkit-appearance: textfield;
}

/* Keep the search field on plain textfield metrics to avoid WebKit caret drift. */
#searchInput {
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
  caret-color: currentColor;
  font-size: 16px;
  line-height: 1.25rem;
  padding: 2px 0;
  margin: 0;
  min-height: unset;
  vertical-align: middle;
  -webkit-text-size-adjust: 100%;
}

#searchInput::-webkit-search-decoration,
#searchInput::-webkit-search-results-button,
#searchInput::-webkit-search-results-decoration,
#searchInput::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-bar input::placeholder {
  color: var(--text-2);
}
.search-bar input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-clear-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--text-2);
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.15s;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

/* forza il colore stroke senza dipendere da currentColor (iOS Safari) */
.search-clear-btn svg {
  display: block;
  stroke: var(--bg);
}

.search-clear-btn:active {
  opacity: 1;
}
.search-clear-btn[hidden] {
  display: none;
}
/* Scala in quando il pulsante diventa visibile */
.search-clear-btn:not([hidden]) {
  animation: scale-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.home-utilities {
  margin-top: 10px;
  display: none;
}

.home-utilities:has(#installBtn:not([hidden])),
.home-utilities:has(#pendingBadge:not([hidden])),
.home-utilities:has(#installHint:not([hidden])) {
  display: block;
}

.home-utility-row {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.home-utility-row:has(#installBtn:not([hidden])),
.home-utility-row:has(#pendingBadge:not([hidden])) {
  display: flex;
}

/* ── Catalog body (scrollable) ─────────────────────────────────────────────  */
#catalog-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* Primaria: 2-column grid */
.grid-catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 18px;
  padding: 14px var(--home-mobile-gutter);
}

/* SS1/SS2: category sections */
.category-section {
  margin-top: 26px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  padding-top: 14px;
}
.category-section:first-child {
  margin-top: 14px;
  border-top: none;
  padding-top: 0;
}

.category-title {
  font-size: 1.18rem;
  font-weight: 700;
  padding: 0 var(--home-mobile-gutter);
  margin-bottom: 12px;
  color: var(--text);
}

.scroll-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 14px var(--home-mobile-gutter) 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.scroll-row--full-bleed {
  margin-left: calc(-1 * var(--catalog-shell-inline));
  margin-right: calc(-1 * var(--catalog-shell-inline));
  padding-left: var(--catalog-shell-inline);
  padding-right: var(--catalog-shell-inline);
}

.themes-row {
  gap: 14px;
  padding: 14px var(--home-mobile-gutter) 8px;
}

.themes-row--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  overflow: visible;
}

.themes-row--carousel {
  display: flex;
  align-items: stretch;
  margin-left: calc(-1 * var(--catalog-shell-inline));
  margin-right: calc(-1 * var(--catalog-shell-inline));
  padding-left: var(--catalog-shell-inline);
  padding-right: var(--catalog-shell-inline);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.themes-row--carousel::-webkit-scrollbar {
  display: none;
}

/* ── Themes strip (top of home) ─────────────────────────── */
.themes-strip {
  gap: 12px;
  padding: 10px var(--home-mobile-gutter) 4px;
}

.themes-strip--carousel {
  display: flex;
  align-items: stretch;
  margin-left: calc(-1 * var(--catalog-shell-inline));
  margin-right: calc(-1 * var(--catalog-shell-inline));
  padding-left: var(--catalog-shell-inline);
  padding-right: var(--catalog-shell-inline);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.themes-strip--carousel::-webkit-scrollbar {
  display: none;
}

.themes-strip--carousel .theme-card {
  width: calc((100vw - 54px) / 2.3);
  min-width: calc((100vw - 54px) / 2.3);
  flex-shrink: 0;
}

/* SS1: per-category fixed 3-column grid */
.category-grid-ss1 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  padding: 14px var(--home-mobile-gutter) 8px;
}

/* SS2 Umanistica: 2-row horizontal grid (scrolls together) */
.scroll-grid-2rows {
  display: grid;
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  grid-auto-columns: calc((100vw - 82px) / 2.6);
  align-items: end;
  gap: 14px;
  padding: 14px var(--home-mobile-gutter) 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-grid-2rows::-webkit-scrollbar {
  display: none;
}

.scroll-grid-2rows--full-bleed {
  margin-left: calc(-1 * var(--catalog-shell-inline));
  margin-right: calc(-1 * var(--catalog-shell-inline));
  padding-left: var(--catalog-shell-inline);
  padding-right: var(--catalog-shell-inline);
}

/* ── Book card ─────────────────────────────────────────────────────────────  */
.book-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex-shrink: 0;
  width: calc((100vw - 82px) / 2.6);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease;
}

.shared-transition-card {
  view-transition-name: shared-detail-card;
  contain: paint;
}

/* In Primaria grid, cards fill track and keep cover proportions */
.grid-catalog .book-card {
  width: 100%;
  min-width: 0;
}

.category-grid-ss1 .book-card {
  width: 100%;
  min-width: 0;
}

.grid-catalog .book-cover-wrap {
  height: auto;
  aspect-ratio: auto;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.grid-catalog .book-cover {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: bottom center;
}

.book-cover-wrap {
  height: auto; /* auto-fits image so shadow on img matches exactly */
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.book-cover {
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: var(--card-radius);
  display: block;
  transition:
    box-shadow 0.16s ease,
    filter 0.16s ease;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.2),
    0 1px 3px rgba(0, 0, 0, 0.1),
    inset -2px 0 5px rgba(0, 0, 0, 0.07);
}

.shared-transition-cover {
  view-transition-name: shared-detail-cover;
}

::view-transition-group(shared-detail-card),
::view-transition-group(shared-detail-cover) {
  animation-duration: var(--shared-detail-view-transition-duration);
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

::view-transition-old(shared-detail-card),
::view-transition-new(shared-detail-card),
::view-transition-old(shared-detail-cover),
::view-transition-new(shared-detail-cover) {
  animation-duration: var(--shared-detail-view-transition-duration);
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.book-title {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 17px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-2);
  text-align: center;
  line-height: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Filter states */
.book-card.hidden {
  display: none;
}

.catalog-card.hidden {
  display: none;
}

.theme-card {
  width: 100%;
  min-width: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease;
}

.themes-row--carousel .theme-card {
  width: calc((100vw - 54px) / 1.5);
  min-width: calc((100vw - 54px) / 1.5);
}

.theme-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(135deg, #ee7d29 0%, #f6b144 52%, #f4ede3 100%);
}

.theme-banner__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.theme-banner__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.28), transparent 34%),
    linear-gradient(140deg, #cf5a0d 0%, #eb8b21 58%, #f3cb7f 100%);
}

.theme-banner__fallback-icon {
  font-size: 58px;
  color: rgba(255, 255, 255, 0.88);
}

.theme-banner__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.06), rgba(15, 23, 42, 0.62));
}

.theme-banner__content {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  color: #fff;
}

.theme-banner__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.category-section.hidden {
  display: none;
}

.no-results {
  padding: 40px 20px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-2);
}

.no-results[data-state='loading']::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto 12px;
  border: 2px solid rgba(100, 116, 139, 0.18);
  border-top-color: rgba(100, 116, 139, 0.72);
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* DETAIL VIEW                                                                 */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ── Detail content: entrata a strati sincronizzata con lo slide della view ── */
/* I delay sono calibrati sulla transizione da 0.38s:
   il contenuto inizia ad apparire mentre la view sta ancora scivolando,
   creando un effetto layered in stile iOS. */
#view-detail.active .detail-cover {
  animation: fade-in-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}
#view-detail.active .detail-title {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}
#view-detail.active .detail-author {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both;
}
#view-detail.active .detail-category {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.25s both;
}
#view-detail.active .bussola-section {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}
#view-detail.active .note-section {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.36s both;
}

/* #view-detail overflow handled by detail-body child scroll */

.back-btn {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.18),
    0 1px 4px rgba(0, 0, 0, 0.1);
  color: #1c1c1e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.back-btn:active,
.back-btn.tapped {
  transform: scale(0.88);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
  background: #e5e5ea;
}

.back-btn svg {
  width: 17px;
  height: 17px;
  transform: translateX(-1px);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-y;
  padding: calc(62px + var(--safe-top)) 20px 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.detail-cover {
  width: 40vw;
  max-width: 200px;
  min-width: 120px;
  border-radius: 11px;
  display: block;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.24),
    0 2px 6px rgba(0, 0, 0, 0.14),
    inset -3px 0 7px rgba(0, 0, 0, 0.08);
}

.detail-title {
  margin-top: 18px;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
}

.detail-author {
  margin-top: 5px;
  font-size: 0.9rem;
  color: var(--text-2);
  text-align: center;
}

.detail-category {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--text-2);
  text-align: center;
  font-style: italic;
}

/* Domande della redazione */
.bussola-section {
  width: 100%;
  margin-top: 30px;
}

.bussola-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: 10px;
}

.bussola-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bussola-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem; /* ≥ 16 px body text for readability */
  line-height: 1.45;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  user-select: text;
  -webkit-user-select: text;
}

.detail-media-frame {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(135deg, #f5ede6, #fff7ee);
}

.detail-media-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.22), transparent 30%),
    linear-gradient(145deg, #cf5a0d 0%, #eb8b21 56%, #f2d19a 100%);
  color: #fff;
}

.detail-media-fallback__icon {
  font-size: 64px;
  opacity: 0.92;
}

.detail-media-fallback__title {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.14;
  text-align: left;
}

#view-detail[data-target-kind='tema'] .detail-media-frame {
  width: clamp(16rem, 78vw, 22rem);
  max-width: 100%;
  margin-bottom: 1.75rem;
  border-radius: 20px;
  aspect-ratio: 16 / 9;
}

#view-detail[data-target-kind='tema'] #detailMediaFallback {
  border-radius: inherit;
}

#view-detail[data-target-kind='tema'] #detail-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

#view-detail[data-target-kind='tema'] #detail-category {
  margin-top: 0.3rem;
}

.bussola-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

/* ── Record dock ────────────────────────────────────────────────────────────  */
/* Base: solo posizionamento — il bottone fluttua nudo */
.record-dock {
  position: absolute;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.record-dock.dock-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
}

/* Pod card — appare solo in stato review */
.record-dock.pod-active {
  width: min(calc(100% - 48px), 340px);
  padding: 22px 28px 22px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 28px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.07),
    0 16px 48px rgba(0, 0, 0, 0.15);
  animation: pod-appear 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Contenuto del pod entra sfumato con lieve ritardo rispetto al contenitore */
.record-dock.pod-active #review-panel {
  animation: fade-in-up 0.3s ease-out 0.12s both;
}

.tap-feedback-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    filter 0.16s ease,
    box-shadow 0.16s ease;
}

.tap-feedback-btn.tap-feedback--pressed {
  opacity: 0.96;
  transform: scale(0.94);
  filter: brightness(0.97) saturate(0.98);
}

#recordBtn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #ffffff;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    opacity 0.2s,
    transform 0.1s;
}

#recordBtn:active:not(:disabled) {
  transform: scale(0.91);
}

#recordBtn[data-state='idle'] {
  background: #dc2626;
}
/* rec-pop: micro-burst al tocco, poi il ring pulsa in loop */
#recordBtn[data-state='recording'] {
  background: #dc2626;
  animation:
    rec-pop 0.22s ease,
    pulse-ring 1.4s 0.22s ease-out infinite;
}
#recordBtn[data-state='sending'] {
  background: #8e8e93;
  animation: none;
}
/* done-pop: bounce di successo */
#recordBtn[data-state='done'] {
  background: #22c55e;
  animation: done-pop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 1.9rem;
}

.note-action-btn--success {
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.28);
}

@media (prefers-reduced-motion: no-preference) {
  .note-action-btn--success {
    animation: done-pop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

#recordBtn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Timer inside button during recording */
.rec-timer {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  pointer-events: none;
}

/* Spinner inside button during upload */
.rec-spinner {
  display: block;
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  pointer-events: none;
}

#statusText {
  display: none; /* visibile solo per errori via JS */
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-2);
  text-align: center;
  line-height: 1.5;
}

/* ── Note section ───────────────────────────────────────────────────────────  */
.note-section {
  width: 100%;
  margin-top: 32px;
}

.note-input-wrap {
  position: relative;
}

.note-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: 10px;
}

.note-textarea {
  width: 100%;
  min-height: 88px;
  max-height: 220px;
  overflow-y: hidden;
  resize: none;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
  line-height: 1.45;
  font-size: 1rem; /* ≥ 16 px prevents iOS auto-zoom on focus */
  font-family: inherit;
  color: var(--text);
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  -webkit-appearance: none;
  user-select: text;
  -webkit-user-select: text;
  padding-right: 62px;
}

.note-textarea::placeholder {
  color: var(--text-2);
}

.note-send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  box-shadow:
    0 5px 14px var(--primary-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    box-shadow 0.15s ease;
}

.note-send-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.note-send-btn:active {
  opacity: 0.92;
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 2px 8px rgb(var(--primary-rgb) / 0.22);
}
.note-send-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.note-send-btn--sent {
  display: flex !important;
  pointer-events: none;
  animation: note-btn-success 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.note-textarea--clearing {
  animation: note-text-out 0.26s ease forwards;
  pointer-events: none;
}

.chat-pod-feedback {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 4px 8px;
}

.chat-pod-feedback[hidden] {
  display: none;
}

.pod-status-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.88);
  color: #334155;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.pod-status-chip[hidden] {
  display: none;
}

.pod-status-chip__icon,
.pod-status-chip__chevron {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
}

.pod-status-chip__text {
  flex: 1;
  min-width: 0;
  font-size: 0.79rem;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

#noteStatus {
  margin: 0;
}

#noteStatusShell[data-tone='info'],
#noteStatusShell[data-tone='neutral'] {
  border-color: var(--primary-ring);
  background: var(--primary-soft);
  color: var(--accent);
}

#noteStatusShell[data-tone='loading'] {
  border-color: var(--primary-ring);
  background: rgb(var(--primary-rgb) / 0.16);
  color: var(--accent);
}

#noteStatusShell[data-tone='success'] {
  border-color: rgba(34, 197, 94, 0.22);
  background: rgba(240, 253, 244, 0.92);
  color: #15803d;
}

#noteStatusShell[data-tone='offline'] {
  border-color: rgba(249, 115, 22, 0.22);
  background: rgba(255, 247, 237, 0.94);
  color: #c2410c;
}

#noteStatusShell[data-tone='error'] {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(254, 242, 242, 0.94);
  color: #b91c1c;
}

.pod-status-chip--action {
  border-color: rgba(249, 115, 22, 0.18);
  background: rgba(255, 247, 237, 0.92);
  color: #c2410c;
  cursor: pointer;
  -webkit-appearance: none;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease;
}

.pod-status-chip--action .pod-status-chip__chevron {
  opacity: 0.55;
}

.pod-status-chip--action:active:not(:disabled) {
  transform: scale(0.985);
  opacity: 0.9;
}

.pod-status-chip--action:disabled {
  cursor: default;
}

.pod-status-chip--action[data-online='false'] .pod-status-chip__chevron {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .chat-pod-feedback > :not([hidden]) {
    animation: fade-in-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* compare quando la textarea ha contenuto */
.note-textarea:not(:placeholder-shown) ~ .note-send-btn {
  display: flex;
  animation: scale-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* LOGIN VIEW                                                                   */
/* ═══════════════════════════════════════════════════════════════════════════ */

#view-login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}

#view-login[hidden] {
  display: none;
}

/* Fade-out animato prima di hide (classe aggiunta da JS) */
#view-login.dismissing {
  animation: fade-out 0.28s ease forwards;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.login-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.4;
}

.login-error {
  width: 100%;
  font-size: 0.88rem;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.5;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding: 13px 22px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  min-height: 44px;
  box-shadow:
    0 1px 6px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.login-btn:active {
  opacity: 0.75;
}

.login-google-btn {
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.login-google-btn__icon,
.login-google-btn__spinner {
  flex: 0 0 auto;
}

.login-google-btn__label {
  transition: opacity 0.18s ease;
}

.login-google-btn__spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(15, 23, 42, 0.16);
  border-top-color: rgba(15, 23, 42, 0.72);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.dark .login-google-btn__spinner {
  border-color: rgba(226, 232, 240, 0.26);
  border-top-color: rgba(248, 250, 252, 0.9);
}

.login-google-btn[data-state='pending'] {
  pointer-events: none;
}

.login-google-btn[data-state='pending'] .login-google-btn__label {
  opacity: 0.9;
}

/* ── Home header top row ─────────────────────────────────────────────────── */
.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.install-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--primary-soft);
  border: 1px solid var(--primary-ring);
  border-radius: 20px;
  padding: 4px 10px;
  min-height: 28px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.install-btn:active {
  opacity: 0.75;
}

.install-btn[disabled] {
  opacity: 0.58;
  cursor: default;
}

.install-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-2);
  text-align: left;
}

.install-hint[data-tone='success'] {
  color: #157347;
}

.install-hint[hidden] {
  display: none;
}

.pending-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: #f97316;
  border: none;
  border-radius: 20px;
  padding: 4px 10px;
  min-height: 28px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.pending-badge:active {
  opacity: 0.75;
}

.logout-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0 4px 12px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.logout-btn:active {
  opacity: 0.45;
}

/* ── Review panel (shown after recording, before sending) ───────────────────  */
#review-panel {
  display: none; /* JS sets display:flex when entering review state */
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
}

.review-audio {
  width: 100%;
  border-radius: 10px;
  /* Native controls height varies by browser; ensure it's tappable */
  min-height: 44px;
}

.review-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-scarta,
.btn-invia {
  flex: 1;
  padding: 13px 12px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.15s;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-scarta {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.btn-scarta:active {
  opacity: 0.65;
}

.btn-invia {
  background: var(--accent);
  color: #ffffff;
}

.btn-invia:active {
  opacity: 0.8;
}

/* ── Dark mode (segue le impostazioni del sistema operativo) ────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #ffffff;
    --text-2: #98989d;
    --primary-rgb: 75 111 147;
    --primary-soft: rgba(75, 111, 147, 0.22);
    --primary-ring: rgba(75, 111, 147, 0.36);
    --primary-shadow: rgba(75, 111, 147, 0.4);
    --accent: rgb(var(--primary-rgb));
    --search-bg: rgba(116, 116, 128, 0.24);
    --search-surface: rgba(28, 32, 38, 0.9);
    --search-surface-focus: rgba(28, 32, 38, 0.94);
    --search-border: rgba(255, 255, 255, 0.1);
  }

  /* Back button (colori hardcoded) */
  .back-btn {
    background: #1c1c1e;
    color: #ffffff;
    box-shadow:
      0 2px 12px rgba(0, 0, 0, 0.45),
      0 1px 4px rgba(0, 0, 0, 0.3);
  }
  .back-btn:active,
  .back-btn.tapped {
    background: #3a3a3c;
  }

  /* Separatori categorie */
  .category-section {
    border-top-color: rgba(255, 255, 255, 0.08);
  }

  /* Pod registrazione */
  .record-dock.pod-active {
    background: rgba(28, 28, 30, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 16px 48px rgba(0, 0, 0, 0.5);
  }

  .pod-status-chip {
    background: rgba(15, 23, 42, 0.84);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  #noteStatusShell[data-tone='info'],
  #noteStatusShell[data-tone='neutral'],
  #noteStatusShell[data-tone='loading'] {
    background: rgba(30, 64, 175, 0.22);
    color: #bfdbfe;
    border-color: rgba(96, 165, 250, 0.24);
  }

  #noteStatusShell[data-tone='success'] {
    background: rgba(21, 128, 61, 0.22);
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.24);
  }

  #noteStatusShell[data-tone='offline'] {
    background: rgba(194, 65, 12, 0.22);
    color: #fdba74;
    border-color: rgba(251, 146, 60, 0.24);
  }

  #noteStatusShell[data-tone='error'] {
    background: rgba(185, 28, 28, 0.22);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.24);
  }

  .pod-status-chip--action {
    background: rgba(194, 65, 12, 0.2);
    color: #fdba74;
    border-color: rgba(251, 146, 60, 0.22);
  }

  /* Bottone Scarta nel review panel */
  .btn-scarta {
    background: rgba(255, 69, 58, 0.15);
    color: #ff453a;
  }

  /* Bussola items: override ios-shadow in dark (light shadow looks wrong) */
  .bussola-item {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }

  /* Note textarea e book title in dark */
  .note-textarea {
    background: #1c1c1e;
    color: #ffffff;
  }

  /* Hint installazione — successo */
  .install-hint[data-tone='success'] {
    color: #34c759;
  }

  /* Login card — bordo leggermente visibile su sfondo scuro */
  .login-btn {
    box-shadow:
      0 1px 6px rgba(0, 0, 0, 0.4),
      0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

/* ── Desktop: structured layout ──────────────────────────────────────────── */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  /* Home: no push-left animation, stays in place behind the modal */
  #view-home.pushed {
    transform: translateX(0);
    opacity: 1;
  }

  /* Center home content */
  .home-header {
    width: 100%;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 36px;
    padding-left: 40px;
    padding-right: 40px;
    box-sizing: border-box;
  }

  .category-title {
    max-width: 860px;
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
  }

  /* Beat Tailwind spacing utilities attached at render time. */
  .category-section > .category-title {
    margin: 0 auto 12px;
    padding-left: 40px;
    padding-right: 40px;
  }

  .grid-catalog {
    max-width: 860px;
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  /* Convert scroll rows to wrapping grids */
  .scroll-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, 130px);
    overflow-x: visible;
    max-width: 860px;
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
    scrollbar-width: none;
  }

  /*
    Standard SS2 rows are rendered with Tailwind utility classes like `flex px-5`.
    Use a more specific selector so desktop layout keeps fixed-width columns.
  */
  .category-section > .scroll-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, 130px);
    align-items: flex-end;
    justify-content: flex-start;
    overflow-x: visible;
    margin-left: auto;
    margin-right: auto;
    padding-top: 14px;
    padding-right: 40px;
    padding-bottom: 8px;
    padding-left: 40px;
  }

  .category-section > .scroll-row .book-card {
    width: 130px;
    min-width: 130px;
  }

  .category-section > .themes-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 14px;
    padding-right: 40px;
    padding-bottom: 8px;
    padding-left: 40px;
    overflow: visible;
  }

  .category-section > .themes-row .theme-card {
    width: auto;
    min-width: 0;
  }

  .category-section > .themes-strip--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    align-items: stretch;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 14px;
    padding-right: 40px;
    padding-bottom: 8px;
    padding-left: 40px;
    overflow: visible;
  }

  .category-section > .themes-strip--grid .theme-card {
    width: auto;
    min-width: 0;
  }

  .category-grid-ss1 {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    max-width: 860px;
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
    overflow-x: visible;
  }

  .category-grid-ss1 .book-card {
    width: 130px;
    min-width: 130px;
  }

  .scroll-grid-2rows {
    display: grid;
    grid-template-columns: repeat(auto-fill, 130px);
    grid-template-rows: auto;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow-x: visible;
    max-width: 860px;
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
    scrollbar-width: none;
  }

  .category-section > .scroll-grid-2rows {
    margin-left: auto;
    margin-right: auto;
    padding-top: 14px;
    padding-right: 40px;
    padding-bottom: 8px;
    padding-left: 40px;
  }

  .book-card {
    width: auto;
    flex-shrink: unset;
  }

  /* Thin vertical scrollbar for catalog */
  #catalog-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
  }
  #catalog-body::-webkit-scrollbar {
    width: 4px;
  }
  #catalog-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 2px;
  }

  /* Detail view becomes a transparent backdrop */
  #view-detail {
    transform: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.32s ease;
  }

  #view-detail.active {
    transform: none;
    background: rgba(0, 0, 0, 0.45);
  }

  /* Detail card: centered modal */
  #detail-card {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 560px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    border-radius: 20px;
    background: var(--bg);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.92);
    transition:
      opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow:
      0 24px 64px rgba(0, 0, 0, 0.28),
      0 4px 16px rgba(0, 0, 0, 0.14);
  }

  #view-detail.active #detail-card {
    opacity: 1;
    transform: scale(1);
  }

  /* Detail header: inside the modal card, not fixed to viewport */
  #detail-card .detail-header {
    position: sticky;
    top: 0;
    left: unset;
    right: unset;
    width: 100%;
    z-index: 10;
    background: var(--bg);
    padding-top: 1rem;
    padding-bottom: 0.5rem;
  }

  /* detail-body: remove padding-top reserved for the fixed header */
  #detail-card .detail-body {
    padding-top: 1rem;
  }

  /* Chat pod: part of the card flow, not fixed to viewport */
  #detail-card #chat-pod-wrap {
    position: relative;
    bottom: unset;
    left: unset;
    right: unset;
    padding: 0.5rem 1rem 1rem;
    pointer-events: auto;
  }

  #detail-card #chat-pod-wrap > div {
    max-width: 100%;
  }

  /* Thin scrollbar for detail body */
  .detail-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
  }
  .detail-body::-webkit-scrollbar {
    width: 4px;
  }
  .detail-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 2px;
  }

  /* Hover states */
  .book-card {
    transition:
      transform 0.14s ease,
      opacity 0.14s ease;
  }
  .book-card:hover {
    transform: scale(0.97);
  }
  .book-cover {
    transition:
      transform 0.28s cubic-bezier(0.33, 1, 0.68, 1),
      box-shadow 0.16s ease,
      filter 0.16s ease;
  }
  .book-card:hover .book-cover {
    transform: scale(1.05);
  }
  .theme-card:hover {
    transform: translateY(-2px);
  }
  .back-btn:hover {
    transform: scale(0.94);
  }
  .login-btn:hover {
    opacity: 0.8;
  }
  .logout-btn:hover {
    opacity: 0.6;
  }
  .btn-scarta:hover {
    opacity: 0.75;
  }
  .btn-invia:hover {
    opacity: 0.85;
  }
  .note-send-btn:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-card,
  .book-cover,
  .tap-feedback-btn {
    transition-duration: 0.01ms;
  }
}

/* ── Update banner ──────────────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  display: grid;
  gap: 14px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 249, 253, 0.98)),
    var(--surface);
  border-radius: 18px;
  box-shadow:
    0 12px 40px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(15, 23, 42, 0.06);
  z-index: 180;
  animation: fade-in-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.install-banner[hidden] {
  display: none;
}

.install-banner__dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-2);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.install-banner__dismiss:active {
  opacity: 0.72;
}

.install-banner__content {
  display: grid;
  gap: 6px;
  padding-right: 28px;
}

.install-banner__eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.install-banner__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.install-banner__body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-2);
}

.install-banner__actions {
  display: flex;
  justify-content: flex-start;
}

.install-banner__action {
  min-height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.install-banner__action:active {
  opacity: 0.78;
}

.install-banner[data-variant='ios-safari-manual'] .install-banner__eyebrow {
  color: #0f766e;
}

.install-banner[data-variant='android-manual'] .install-banner__eyebrow {
  color: #b45309;
}

.install-banner[data-variant='android-manual'],
.install-banner[data-variant='ios-safari-manual'] {
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.98), rgba(255, 255, 255, 0.98)),
    var(--surface);
}

.update-banner {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.14),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 200;
  animation: fade-in-up 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.update-banner[hidden] {
  display: none;
}

.update-banner__text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.update-banner__btn {
  flex-shrink: 0;
  padding: 7px 16px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.update-banner__btn:active {
  opacity: 0.75;
}

@media (prefers-color-scheme: dark) {
  .install-banner {
    background:
      linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.92)),
      var(--surface);
    box-shadow:
      0 16px 40px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  .install-banner__dismiss {
    background: rgba(148, 163, 184, 0.16);
  }

  .update-banner {
    box-shadow:
      0 4px 24px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) and (prefers-color-scheme: dark) {
  #view-detail.active {
    background: rgba(0, 0, 0, 0.62);
  }

  #detail-card {
    box-shadow:
      0 24px 64px rgba(0, 0, 0, 0.7),
      0 4px 16px rgba(0, 0, 0, 0.5);
  }

  #catalog-body {
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  }
  #catalog-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
  }

  .detail-body {
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  }
  .detail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
  }
}

/* ============================================================
   SEZIONE FEEDBACK RICEVUTI
   ============================================================ */

.feedback-section {
  margin-top: 28px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#view-detail.active .feedback-section {
  animation: fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.42s both;
}

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

.feedback-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.feedback-badge {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sintesi breve */
.sintesi-preview {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 14px;
}

.sintesi-breve-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sintesi-expand-btn {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Chip segnalazioni — scroll orizzontale */
.segnalazioni-scroll {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  padding-bottom: 4px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.segnalazioni-scroll::-webkit-scrollbar {
  display: none;
}

.seg-chip {
  flex-shrink: 0;
  width: 160px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  scroll-snap-align: start;
  cursor: default;
}

.feedback-chip--new {
  border-color: var(--primary-ring) !important;
  box-shadow:
    0 0 0 2px rgb(var(--primary-rgb) / 0.16),
    0 10px 24px rgb(var(--primary-rgb) / 0.12);
}

.seg-chip-meta {
  font-size: 0.72rem;
  color: var(--text-2);
  margin-bottom: 3px;
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}

.seg-chip-tipo {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--search-bg);
  color: var(--text-2);
}

.seg-chip-meta > span:first-child {
  max-width: calc(100% - 64px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-chip-text {
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-top: 4px;
}

.seg-chip-more {
  margin-top: 6px;
  margin-left: auto;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0;
  cursor: pointer;
}

.seg-chip-more[hidden] {
  display: none;
}

.vedi-tutte-btn {
  width: 100%;
  padding: 10px 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  text-align: right;
  cursor: pointer;
}

/* ============================================================
   BOTTOM SHEET
   ============================================================ */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
}

.bottom-sheet-overlay[hidden] {
  display: none;
}

.bottom-sheet {
  width: 100%;
  max-height: 85vh;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  animation: sheet-appear 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sheet-appear {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  margin: 10px auto 0;
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .sheet-handle {
    background: rgba(235, 235, 245, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

.sheet-header {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--search-bg);
  flex-shrink: 0;
}

.sheet-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: block;
}

.sheet-date {
  font-size: 0.78rem;
  color: var(--text-2);
  display: block;
  margin-top: 2px;
}

.sheet-body {
  overflow-y: auto;
  padding: 16px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  flex: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Markdown nella sintesi */
.sheet-body h1,
.sheet-body h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 22px 0 8px;
}
.sheet-body h1:first-child,
.sheet-body h2:first-child {
  margin-top: 0;
}
.sheet-body h3,
.sheet-body h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin: 18px 0 8px;
}
.sheet-body p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 10px;
}
.sheet-body ul,
.sheet-body ol {
  margin: 0 0 10px;
  padding-left: 18px;
}
.sheet-body ul {
  list-style: disc;
}
.sheet-body ul ul {
  list-style: circle;
}
.sheet-body ol {
  list-style: decimal;
}
.sheet-body li {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 4px;
}
.sheet-body li > ul,
.sheet-body li > ol {
  margin-top: 6px;
  margin-bottom: 6px;
}
.sheet-body strong {
  font-weight: 700;
  color: var(--text);
}
.sheet-body em {
  font-style: italic;
}

/* Lista segnalazioni nello sheet B */
.sheet-seg-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--search-bg);
}
.sheet-seg-item:last-child {
  border-bottom: none;
}
.sheet-seg-meta {
  font-size: 0.76rem;
  color: var(--text-2);
  margin-bottom: 5px;
}
.sheet-seg-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}
