:root {
  --bg: #f3f4f6;
  --card: #fff;
  --ink: #1c1e21;
  --muted: #5c6370;
  --line: #e4e6eb;
  --accent: #0c6b4d;
  --gold: #8a5a00;
  --gold-bg: #fff4d4;
  --miss: #9a3412;
  --miss-bg: #fff1ee;
  --fb: #1877f2;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

body.panel-open { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  z-index: 90;
  border-radius: 8px;
}

.skip:focus { top: 8px; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 10px 48px;
}

h1 {
  margin: 0 0 2px;
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.3;
}

#q { margin-top: 8px; min-height: 44px; }

.sintesi {
  margin: 8px 0 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sintesi summary {
  min-height: 40px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.25;
}

.sintesi ul {
  margin: 0;
  padding: 0 16px 14px 32px;
}

.sintesi li { margin: 6px 0; }

.lbl {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  overflow: visible;
  padding-bottom: 2px;
}

.chips button {
  flex: none;
}

.chips button,
#filtri-btn,
#azzera,
#azzera-panel,
#panel-close,
#dclose,
#vclose,
.open,
.zoom-link {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.chips button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tools {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 244, 246, 0.97);
  padding: 6px 0 4px;
  margin-top: 4px;
}

.tools-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

#filtri-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 12px;
}

.sort { min-width: 0; }

#ordine {
  min-width: 0;
  min-height: 40px;
  padding: 0 6px;
}

.count {
  margin: 0;
  font-weight: 700;
  min-height: 40px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: 0.92rem;
}

#filtri-btn,
#azzera {
  min-height: 40px;
  padding: 6px 10px;
  white-space: nowrap;
}

#azzera { border-radius: 12px; }

.panel-count { margin: 0 0 8px; font-weight: 700; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.45);
  z-index: 30;
}

.panel {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(86vh, 720px);
  overflow: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.16);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  padding: 6px 0;
  z-index: 1;
}

.panel-head h2 { margin: 0; font-size: 1.15rem; }

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-weight: 700;
}

.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

fieldset {
  border: 0;
  margin: 6px 0 8px;
  padding: 0;
}

legend {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.panel .chips { flex-wrap: wrap; overflow: visible; }

.panel .lbl { margin: 6px 0 0; }

.panel .lbl select {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink);
  margin-top: 4px;
  min-height: 40px;
}

.azzera-block {
  width: 100%;
  border-radius: 12px;
  margin: 4px 0 8px;
}

.active {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}

.card-meta { padding: 10px 12px 12px; }

.name {
  flex: 1;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef0f3;
}

.badge.long { background: var(--gold-bg); color: var(--gold); }

.cat-osteopatia { color: #0c6b4d; background: #e5f5ef; }
.cat-fisioterapia { color: #1d4e89; background: #e7f0fa; }
.cat-chiropratica { color: #5b3a8c; background: #f1eafa; }
.cat-dentista { color: #9d174d; background: #fde8ef; }
.cat-shiatsu { color: #8a5a00; background: #fff4d4; }
.cat-ottico { color: #276749; background: #e6f4ec; }

.angle { margin: 0 0 2px; }

.date { margin: 0 0 8px; color: var(--muted); font-size: 0.92rem; }

.why {
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.why span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.open {
  display: flex;
  flex: none;
  width: auto;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.shot {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #e8eaee;
  line-height: 0;
  cursor: zoom-in;
}

.shot img,
.vidbox .poster {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(62vh, 520px);
  display: block;
  object-fit: contain;
  background: #e8eaee;
}

.vidbox {
  position: relative;
  background: #e8eaee;
  line-height: 0;
}

.vidbox .poster { margin: 0 auto; }

.vidbox video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
  opacity: 0;
  pointer-events: none;
}

.vidbox.is-playing video {
  opacity: 1;
  pointer-events: auto;
}

.vidbox.is-playing .poster { visibility: hidden; }
.vidbox.is-playing .play-btn { display: none; }

.vidbox-detail video,
.vidbox-story video {
  opacity: 1;
  pointer-events: auto;
}

.vidbox-detail video {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
}

.play-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  padding: 0 0 0 4px;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}

.vbadge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
  line-height: 1.2;
}

.unavail {
  margin: 0;
  padding: 6px 12px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.carousel {
  position: relative;
  background: #0e0f12;
}

.car-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.car-track::-webkit-scrollbar { display: none; }

.car-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.car-slide img {
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.car-nav {
  position: absolute;
  top: 42%;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.car-prev { left: 8px; }
.car-next { right: 8px; }

.car-count {
  margin: 0;
  padding: 6px 10px;
  text-align: center;
  color: #fff;
  background: #0e0f12;
  font-size: 0.82rem;
  font-weight: 700;
}

.zoom-label {
  position: absolute;
  top: 8px;
  right: 8px;
  line-height: 1.2;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.empty {
  margin: 0;
  padding: 16px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

dialog {
  padding: 0;
  border: none;
  color: var(--ink);
}

dialog::backdrop { background: rgba(12, 14, 18, 0.62); }

.detail {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  background: #eef0f3;
  overflow: auto;
}

.detail-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.detail-bar h2 {
  flex: 1;
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.3;
}

#dclose { border-radius: 12px; flex: none; }

.detail-body { padding: 12px 12px 28px; }

.caption {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.fb {
  max-width: 480px;
  margin: 0 auto 12px;
  background: #fff;
  border: 1px solid #dddfe2;
  border-radius: 12px;
  overflow: hidden;
  color: #050505;
}

.fb-top, .story-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.fb-top { padding: 12px 12px 8px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0c6b4d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}

.fb-name { display: block; font-size: 0.95rem; }

.fb-spon { color: #65676b; font-size: 0.82rem; font-weight: 400; }

.fb-text { padding: 0 12px 10px; margin: 0; white-space: pre-wrap; word-break: break-word; }

.altro {
  border: 0;
  background: none;
  color: var(--fb);
  font-weight: 700;
  padding: 0;
  min-height: 44px;
  cursor: pointer;
}

.mock-shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #000;
  cursor: zoom-in;
  line-height: 0;
  position: relative;
}

.mock-shot img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  background: #0e0f12;
}

.fb-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f0f2f5;
  padding: 10px 12px;
}

.fb-links { flex: 1; min-width: 0; }

.fb-links strong, .fb-links span { display: block; }

.fb-links strong { font-size: 0.95rem; }

.fb-links span { color: #65676b; font-size: 0.82rem; }

.fb-cta {
  flex: none;
  background: #e4e6eb;
  color: #050505;
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 6px;
  padding: 8px 12px;
  max-width: 46%;
  text-align: center;
}

.story {
  position: relative;
  width: min(100%, 420px, calc((100vh - 150px) * 9 / 16));
  aspect-ratio: 9 / 16;
  margin: 0 auto 12px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  color: #fff;
}

.story .mock-shot {
  position: absolute;
  inset: 0;
  height: 100%;
}
.story .mock-shot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story .vidbox {
  position: absolute;
  inset: 0;
}

.story .vidbox-story video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.story-bottom { pointer-events: none; }
.story-bottom .altro,
.story-bottom button { pointer-events: auto; }

.story-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}

.story .avatar { width: 32px; height: 32px; font-size: 0.9rem; }

.story-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 12px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
}

.story-bottom p { margin: 0 0 6px; white-space: pre-wrap; }

.story-hl { display: block; margin-bottom: 8px; }

.story-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  color: #050505;
  font-weight: 700;
}

.story .altro { color: #fff; text-decoration: underline; }

.zoom-link {
  display: flex;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 16px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.info-title {
  margin: 8px 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field { margin: 0 0 12px; }

.field h3 {
  margin: 0 0 2px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field p { margin: 0; white-space: pre-wrap; word-break: break-word; }

.note { color: var(--muted); font-size: 0.92rem; margin-top: 4px !important; }

.missing {
  display: inline-block;
  color: var(--miss);
  background: var(--miss-bg);
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 6px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pills li {
  background: #e8eaee;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.88rem;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  text-align: center;
}

.btn-ghost {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.viewer {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  background: #0c0d10;
  color: #fff;
}
.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer::backdrop { background: #0c0d10; }

.viewer-bar, .viewer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  flex: none;
}

.viewer-bar { justify-content: space-between; }

#vcount { margin: 0; font-weight: 700; }

#vclose, #vzin, #vzout, .varrow {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 0;
  border-radius: 12px;
  min-width: 44px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
}

#vclose { font-size: 1rem; padding: 0 14px; }

.vstage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.vstage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.varrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
}

.varrow-prev { left: 8px; }
.varrow-next { right: 8px; }

.varrow:disabled { opacity: 0.35; }

.viewer-tools { justify-content: center; }

.vhint { margin: 0; color: #c5c8ce; font-size: 0.82rem; font-weight: 400; }

.desk { display: none; }

@media (min-width: 800px) {
  .wrap { padding: 16px 20px 64px; }
  h1 { font-size: 1.7rem; }
  .lead { font-size: 1rem; }
  .shot img, .vidbox .poster { max-height: min(52vh, 460px); }
  .grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .chips { flex-wrap: wrap; overflow: visible; }
  .mob { display: none; }
  .desk { display: inline; }
  .panel {
    position: absolute;
    left: 0;
    right: auto;
    bottom: auto;
    top: calc(100% + 8px);
    width: min(380px, 92vw);
    max-height: calc(100dvh - 300px);
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  }
  .tools { position: sticky; }
  .detail {
    width: min(980px, calc(100% - 40px));
    height: min(860px, calc(100% - 40px));
    margin: auto;
    border-radius: 16px;
  }
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(280px, 460px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }
  .actions { flex-direction: row; }
  .actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
