/* Txistus Peiolín — sistema visual propio.
   Serif editorial (Fraunces) para titulares + sans del sistema para texto.
   Temas por variables CSS en :root[data-theme="…"] (cookie `theme`):
   garnata (default) · oliba · itsaso · gaua (oscuro). Sin frameworks.

   Enfoque "app": barra de pestañas inferior en móvil (.tabbar), botón
   flotante (.fab), pestañas de sección del grupo (.group-nav), listas en dos
   densidades (:root[data-density]), toasts (.messages),
   modales tipo bottom-sheet en móvil y respeto de las safe areas (PWA). */

/* =========================================================
   1. Tokens y temas
   ========================================================= */
:root {
  /* Garnata (default): neutro claro + granate + oro para los txistus. */
  --bg: #f5f5f2;
  --paper: #f5f5f2;
  --surface: #ffffff;
  --paper-2: #ebeae4;
  --ink: #22252a;
  --ink-soft: #676d76;
  --line: #e3e3dd;
  --line-strong: #c9cac3;

  --wine: #a23d4d;
  --wine-deep: #7e2e3c;
  --gold: #b3862d;
  --gold-soft: #d4ab55;
  --olive: #5b7150;
  --ok: #337a53;
  --warn: #a67714;
  --err: #b23225;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(20, 22, 26, 0.04), 0 2px 10px rgba(20, 22, 26, 0.05);
  --shadow-lift: 0 6px 16px rgba(20, 22, 26, 0.08), 0 18px 42px rgba(20, 22, 26, 0.14);
  --focus-ring: color-mix(in srgb, var(--wine) 25%, transparent);
  --header-glass: color-mix(in srgb, var(--surface) 86%, transparent);
  --maxw: 1060px;
  --tabbar-h: 58px;
}

:root[data-theme="oliba"] {
  --bg: #f4f6ef;
  --paper: #f4f6ef;
  --paper-2: #e8ecdd;
  --line: #dfe3d2;
  --line-strong: #c4ccb2;
  --wine: #57713f;
  --wine-deep: #42582e;
  --gold: #a8842e;
  --gold-soft: #c9a656;
}

:root[data-theme="itsaso"] {
  --bg: #f3f6f9;
  --paper: #f3f6f9;
  --paper-2: #e5ebf1;
  --line: #dde4ea;
  --line-strong: #c2ccd6;
  --wine: #31608c;
  --wine-deep: #25496b;
}

:root[data-theme="gaua"] {
  color-scheme: dark;
  --bg: #14161a;
  --paper: #14161a;
  --surface: #1c1f25;
  --paper-2: #262a31;
  --ink: #e8e6e1;
  --ink-soft: #a0a5ad;
  --line: #2d3138;
  --line-strong: #454a52;
  --wine: #c66576;
  --wine-deep: #ad4d5f;
  --gold: #d3a552;
  --gold-soft: #e2bf7d;
  --olive: #8ba178;
  --ok: #63b98b;
  --warn: #d3a552;
  --err: #e07a68;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 8px 20px rgba(0, 0, 0, 0.4), 0 18px 44px rgba(0, 0, 0, 0.55);
  --focus-ring: color-mix(in srgb, var(--wine) 40%, transparent);
  --header-glass: color-mix(in srgb, var(--surface) 84%, transparent);
}

/* =========================================================
   2. Base
   ========================================================= */
* {
  box-sizing: border-box;
}

/* El filtrado y la paginación marcan las tarjetas con el atributo `hidden`.
   Las reglas de `.rec-card`/`.grid-recs` fijan `display`, y cualquier regla
   de autor gana al `[hidden] { display: none }` del navegador: sin esto, las
   tarjetas filtradas se seguirían viendo. */
[hidden] {
  display: none !important;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

html[data-text="grande"] {
  font-size: 19px;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Fundido suave entre páginas (MPA view transitions, mejora progresiva). */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

::selection {
  background: color-mix(in srgb, var(--wine) 22%, transparent);
}

a,
button,
label,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--wine);
  text-decoration: none;
}

a:hover {
  color: var(--wine-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Iconos SVG de trazo (sprite en base.html). Heredan currentColor. */
.icon {
  width: 1.1em;
  height: 1.1em;
  flex: 0 0 auto;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* =========================================================
   3. Header / navegación
   ========================================================= */
.site-header {
  background: var(--header-glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  border-top: 3px solid var(--wine);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  background-color: var(--wine);
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  transform: translateY(0.1em);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.main-nav a {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.main-nav a:hover {
  color: var(--ink);
  background: var(--paper-2);
  text-decoration: none;
}

.main-nav .nav-cta {
  color: var(--wine);
  border: 1px solid var(--line-strong);
  margin-left: 0.3rem;
}

.main-nav .nav-cta:hover {
  border-color: var(--wine);
  background: var(--surface);
  color: var(--wine);
}

.main-content {
  flex: 1 0 auto;
  padding-top: 2.2rem;
  padding-bottom: 4rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding: 1.5rem 0;
  letter-spacing: 0.02em;
}

/* --- Barra de pestañas inferior (móvil, usuarios con sesión) --- */
.tabbar {
  display: none;
}

@media (max-width: 720px) {
  .header-inner {
    padding: 0.6rem 0;
  }

  .brand {
    font-size: 1.28rem;
  }

  /* Con sesión, la navegación vive en la tabbar; sin sesión caben los
     dos enlaces (Entrar / Crear cuenta) en el propio header. */
  body.has-tabbar .main-nav {
    display: none;
  }

  .main-nav a {
    font-size: 0.88rem;
    padding: 0.38rem 0.55rem;
  }

  body.has-tabbar .site-footer {
    display: none;
  }

  body.has-tabbar .main-content {
    padding-top: 1.4rem;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 2.2rem);
  }

  body.has-tabbar .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--header-glass);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    backdrop-filter: blur(16px) saturate(1.5);
    border-top: 1px solid var(--line);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
  }
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.3rem 0.2rem 0.24rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.1;
  user-select: none;
  transition: color 0.15s ease, transform 0.1s ease;
}

.tabbar-item .icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.9;
}

.tabbar-item:hover {
  color: var(--ink);
  text-decoration: none;
}

.tabbar-item:active {
  transform: scale(0.92);
}

.tabbar-item.active {
  color: var(--wine);
}

.tabbar-item.active .icon {
  stroke-width: 2.5;
}

/* --- Botón flotante (móvil) --- */
.fab {
  display: none;
}

@media (max-width: 720px) {
  .fab {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 1rem);
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wine);
    color: #fff;
    box-shadow: 0 6px 14px color-mix(in srgb, var(--wine) 35%, transparent),
    0 14px 34px color-mix(in srgb, var(--wine) 30%, transparent);
    transition: transform 0.12s ease, background 0.15s ease;
  }

  .fab .icon {
    width: 26px;
    height: 26px;
  }

  .fab:hover {
    color: #fff;
    background: var(--wine-deep);
    text-decoration: none;
  }

  .fab:active {
    transform: scale(0.92);
  }

  .hide-sm {
    display: none !important;
  }
}

/* =========================================================
   4. Tipografía y cabeceras de página
   ========================================================= */
h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.6rem);
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1rem;
}

.muted {
  color: var(--ink-soft);
}

.measure {
  max-width: 62ch;
}

.eyebrow {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--wine);
  margin: 0 0 0.4rem;
}

.section-title {
  margin-top: 2.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

.page-head h1 {
  margin: 0;
}

.head-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 1rem;
}

.section-head h2 {
  margin: 0;
}

/* Bloque de una página con su cabecera ("Fotos", "Opiniones", "Debate"…). El
   hilo de arriba marca el ritmo de la página sin necesidad de tarjetas. */
.page-section {
  margin-top: 2rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

.page-section-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.page-section-head h2 {
  font-size: 1.2rem;
  margin: 0;
}

.page-section-head .btn {
  margin-left: auto;
}

.page-section-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Migas de vuelta ("← Grupo") con aspecto de control nativo. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding: 0.32rem 0.8rem 0.32rem 0.45rem;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.86rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.back-link:hover {
  color: var(--wine);
  background: color-mix(in srgb, var(--wine) 10%, var(--paper-2));
  text-decoration: none;
}

.back-link:active {
  transform: scale(0.97);
}

/* =========================================================
   5. Botones
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--wine);
  background: var(--wine);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.93rem;
  letter-spacing: 0.01em;
  padding: 0.58rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.08s ease, box-shadow 0.15s ease;
  line-height: 1.25;
  box-shadow: var(--shadow);
}

.btn:hover {
  background: var(--wine-deep);
  border-color: var(--wine-deep);
  color: #fff;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--wine);
  color: var(--wine);
}

.btn-muted {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-muted:hover {
  background: var(--line);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-danger {
  background: transparent;
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, var(--line));
  box-shadow: none;
}

.btn-danger:hover {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}

.btn-sm {
  padding: 0.34rem 0.75rem;
  font-size: 0.82rem;
}

.btn-block {
  display: flex;
  width: 100%;
  text-align: center;
}

/* Botón de solo icono: acciones secundarias que no merecen texto (editar y
   borrar una ficha, borrar una opinión o un comentario). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease,
    transform 0.08s ease;
}

.icon-btn:hover {
  color: var(--wine);
  border-color: var(--wine);
  text-decoration: none;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn .icon {
  width: 17px;
  height: 17px;
}

.icon-btn.is-danger:hover {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 45%, var(--line));
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
  border-color: transparent;
  background: transparent;
}

.icon-btn-sm .icon {
  width: 15px;
  height: 15px;
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--wine);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  color: var(--wine-deep);
}

.link-danger {
  background: none;
  border: none;
  color: var(--err);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0;
}

.link-danger:hover {
  text-decoration: underline;
}

/* Miga de vuelta al grupo, en las páginas de sección. */
.group-crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.group-crumb .icon {
  width: 1em;
  height: 1em;
}

.group-crumb:hover {
  color: var(--wine);
  text-decoration: none;
}

.group-crumb-img {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper-2) center / cover no-repeat;
}

/* Secciones del grupo: control segmentado con TODAS las pestañas a la vista.
   En móvil es una rejilla que reparte el ancho y salta de línea sola (nada de
   scroll lateral, que escondía la mitad de las opciones); en escritorio se
   encoge y queda como una barra de pestañas junto al título. */
.group-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 3px;
  padding: 4px;
  margin: 0 0 1.5rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.group-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  min-height: 56px;
  padding: 0.45rem 0.25rem;
  border-radius: calc(var(--radius) - 5px);
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.group-nav-item .icon {
  width: 19px;
  height: 19px;
}

.group-nav-item:hover {
  color: var(--wine);
  text-decoration: none;
}

.group-nav-item.is-active {
  background: var(--surface);
  color: var(--wine);
  box-shadow: var(--shadow);
}

.group-nav-item:active {
  transform: scale(0.95);
}

@media (min-width: 721px) {
  .group-nav {
    display: inline-flex;
    gap: 2px;
  }

  .group-nav-item {
    flex-direction: row;
    gap: 0.45rem;
    min-height: 0;
    padding: 0.5rem 0.95rem;
    font-size: 0.86rem;
    font-weight: 600;
  }

  .group-nav-item .icon {
    width: 1.05em;
    height: 1.05em;
  }
}

/* =========================================================
   6. Tarjetas y rejillas
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem;
}

a.card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

@media (hover: hover) {
  a.card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lift);
    transform: translateY(-2px);
    text-decoration: none;
  }
}

a.card:active {
  transform: scale(0.985);
}

/* Tarjeta de grupo: portada arriba (o marca de agua si no hay foto). */
.card-group {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-width: 0;
}

.card-group .group-cover {
  height: 148px;
  background: var(--paper-2) center / cover no-repeat;
  border-bottom: 1px solid var(--line);
}

.group-cover.is-empty {
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--wine) 10%, var(--paper-2)),
    var(--paper-2) 70%
  );
}

.group-cover.is-empty::before {
  content: "";
  width: 52px;
  height: 52px;
  background: color-mix(in srgb, var(--wine) 38%, var(--line-strong));
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
}

.card-group-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.05rem 1.2rem 1.2rem;
  flex: 1;
}

.card-group h2 {
  color: var(--ink);
  font-size: 1.25rem;
  margin: 0;
}

a.card-group:hover h2 {
  color: var(--wine);
}

.card-group-body p {
  margin: 0;
  font-size: 0.92rem;
}

.card-group-body .rec-meta {
  margin-top: auto;
  padding-top: 0.35rem;
}

.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.grid {
  display: grid;
  gap: 1.3rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid-recs {
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

@media (max-width: 720px) {
  .grid,
  .grid-recs {
    gap: 0.85rem;
  }
}

/* En móvil, dos tarjetas por fila (más compacto y se ven más de golpe). */
@media (max-width: 560px) {
  .grid-recs {
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
  }
}

/* Tarjeta de recomendación */
.rec-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  /* Es celda de rejilla y el título va en `nowrap`: sin esto, su ancho mínimo
     sería el del nombre entero y ensancharía la columna (página con scroll
     lateral en móvil). Con 0, el nombre se recorta con puntos suspensivos. */
  min-width: 0;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

@media (hover: hover) {
  .rec-card:hover {
    box-shadow: var(--shadow-lift);
    transform: translateY(-2px);
  }
}

.rec-card:active {
  transform: scale(0.985);
}

.rec-card .rec-photo {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.rec-photo.rec-photo-empty {
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--wine) 8%, var(--paper-2)),
    var(--paper-2) 70%
  );
}

.rec-photo.rec-photo-empty::before {
  content: "";
  width: 44px;
  height: 44px;
  background: color-mix(in srgb, var(--wine) 32%, var(--line-strong));
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
}

.rec-slide {
  position: absolute;
  inset: 0;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.rec-slide.active {
  opacity: 1;
}

/* Guardar ("quiero ir") como marcador sobre la foto. */
.rec-save {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
}

.rec-save button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(18, 16, 14, 0.45);
  color: #fff;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, background 0.15s ease;
}

.rec-save button .icon {
  width: 19px;
  height: 19px;
}

.rec-save button:hover {
  background: rgba(18, 16, 14, 0.65);
}

.rec-save button:active {
  transform: scale(0.88);
}

.rec-save button.is-saved {
  background: var(--gold);
}

.rec-save button.is-saved .icon {
  fill: currentColor;
}

/* Editar (solo el autor) como marcador sobre la foto, arriba a la izquierda. */
.rec-edit {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(18, 16, 14, 0.45);
  color: #fff;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, background 0.15s ease;
}

.rec-edit .icon {
  width: 18px;
  height: 18px;
}

.rec-edit:hover {
  background: rgba(18, 16, 14, 0.65);
  color: #fff;
  text-decoration: none;
}

.rec-edit:active {
  transform: scale(0.88);
}

/* Precio sobre la foto. */
.photo-badge {
  position: absolute;
  left: 0.6rem;
  bottom: 0.55rem;
  z-index: 2;
  pointer-events: none;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(18, 16, 14, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Puntitos del carrusel (los pinta project.js). */
.rec-dots {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 5px;
  pointer-events: none;
}

.rec-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  transition: width 0.25s ease, background 0.25s ease;
}

.rec-dots span.active {
  width: 15px;
  background: #fff;
}

.rec-card .rec-body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.rec-card h3 {
  margin: 0;
  min-width: 0;
  font-size: 1.08rem;
}

.rec-card h3 a {
  color: var(--ink);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-card h3 a:hover {
  color: var(--wine);
  text-decoration: none;
}

.rec-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  align-items: center;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.rec-sub {
  font-size: 0.82rem;
}

/* Barra de filtros/orden sobre la lista de recomendaciones. */
.rec-controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0 0 0.9rem;
}

.rec-controls-top {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  /* Sin esto los hijos se estiran a la altura del buscador y la pastilla de
     densidad queda con los botones arriba y un hueco muerto debajo. */
  align-items: center;
}

.rec-search {
  position: relative;
  flex: 1 1 220px;
  display: flex;
  align-items: center;
}

.rec-search .icon {
  position: absolute;
  left: 0.75rem;
  color: var(--ink-soft);
  pointer-events: none;
}

/* El selector lleva el tipo a propósito: la regla general de `input[type=…]`
   está más abajo con `padding` en atajo y, a igualdad de peso, ganaría ella
   dejando el texto debajo de la lupa. */
.rec-search input[type="search"] {
  width: 100%;
  padding-left: 2.3rem;
}

.rec-chips {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.15rem;
}

.rec-chips::-webkit-scrollbar {
  display: none;
}

.rec-chip {
  flex: 0 0 auto;
  appearance: none;
  font-family: inherit;
  padding: 0.42rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.rec-chip:hover {
  border-color: var(--wine);
  color: var(--wine);
}

.rec-chip.is-active {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
}

.rec-count {
  font-size: 0.82rem;
  margin: 0;
}

/* Con pocas recomendaciones no hay buscador: el recuento ocupa su sitio y
   empuja el selector de densidad al extremo derecho. */
.rec-controls-top .rec-count {
  margin-right: auto;
  align-self: center;
}

@media (max-width: 560px) {
  .rec-search {
    flex: 1 1 100%;
  }

  /* El buscador se lleva una fila; filtros y densidad comparten la de abajo.
     Con el selector del contenedor para ganar a la regla base, que va después
     en el archivo. */
  .rec-controls-top .filter-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  /* Los chips llegan al borde de la pantalla al deslizar. */
  .rec-chips {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Cuerpo de tarjeta más compacto en móvil (rejilla de 2 columnas). */
  .rec-card .rec-body {
    padding: 0.6rem 0.7rem 0.75rem;
    gap: 0.3rem;
  }

  .rec-card h3 {
    font-size: 0.95rem;
  }

  .rec-meta {
    font-size: 0.8rem;
    gap: 0.25rem 0.5rem;
  }

  .rec-sub {
    font-size: 0.76rem;
  }

  /* Se ocultan los chips de categoría de la tarjeta para ganar altura. */
  .rec-tags {
    display: none;
  }

  .rec-save button,
  .rec-edit {
    width: 32px;
    height: 32px;
  }

  .rec-save button .icon,
  .rec-edit .icon {
    width: 16px;
    height: 16px;
  }

  .rec-save,
  .rec-edit {
    top: 0.45rem;
  }

  .rec-save {
    right: 0.45rem;
  }

  .rec-edit {
    left: 0.45rem;
  }
}

.field-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}

.detail-hero-photo {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.4rem;
  border: 1px solid var(--line);
}

.meta-sep::before {
  content: "·";
  margin: 0 0.5rem;
  color: var(--line-strong);
}

/* Filas de datos con icono (dirección, enlace…). */
.info-rows {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  min-width: 0;
}

.info-row + .info-row {
  border-top: 1px solid var(--line);
}

.info-row .icon {
  color: var(--wine);
  width: 1.15em;
  height: 1.15em;
}

.info-row > span,
.info-row > a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.info-rows + .map-picker {
  margin-top: 0.9rem;
}

/* La reseña del Peio, con aire de cita. */
.peio-quote {
  position: relative;
  margin: 0 0 1.4rem;
  padding: 1.1rem 1.2rem 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(
    100deg,
    color-mix(in srgb, var(--gold) 7%, var(--surface)),
    var(--surface) 60%
  );
  font-size: 1.02rem;
  line-height: 1.65;
}

.peio-quote .eyebrow {
  color: var(--gold);
}

.peio-quote > :last-child {
  margin-bottom: 0;
}

/* =========================================================
   7. Badges y txistus
   ========================================================= */
.badge {
  display: inline-block;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.badge-peio {
  background: var(--ink);
  color: var(--gold-soft);
  border-color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  font-weight: 700;
}

.badge-admin {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
}

.badge-price {
  color: var(--olive);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.badge-ok {
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
}

.badge-warn {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
}

.txistus {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}

.txistu {
  display: inline-block;
  width: 1.4rem;
  height: 1.4rem;
  background-color: var(--gold);
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
}

.txistu.is-empty {
  background-color: var(--line-strong);
}

/* Avatar con inicial (miembros, opiniones, comentarios). */
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--wine) 14%, var(--paper-2));
  color: var(--wine);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  user-select: none;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.88rem;
}

/* =========================================================
   8. Formularios (aspecto app)
   ========================================================= */
.form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.5rem 1.6rem;
}

.card .form,
.auth-card .form {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.form-wide {
  max-width: 760px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form label,
.form-row > label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  font: inherit;
  font-size: 0.96rem;
  color: var(--ink);
  width: 100%;
  padding: 0.68rem 0.85rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--wine) 40%, var(--line-strong));
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

textarea {
  resize: vertical;
  min-height: 5.2rem;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

.form .helptext {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0;
}

.form .errorlist,
.errorlist {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  color: var(--err);
  font-size: 0.84rem;
}

.form-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 0.3rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check input {
  width: auto;
}

.form-check label {
  font-weight: 500;
  margin: 0;
}

/* Controles segmentados (txistus 1–5 y rango de precio) */
input.seg-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.form-row div:has(> div > label > input.seg-input) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

label:has(> input.seg-input) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  padding: 0.5rem 0.95rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease,
    transform 0.1s ease;
  user-select: none;
  touch-action: manipulation;
}

label:has(> input.seg-input):hover {
  border-color: var(--wine);
  color: var(--wine);
}

label:has(> input.seg-input):active {
  transform: scale(0.95);
}

label:has(> input.seg-input:checked) {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
}

label:has(> input.seg-input:focus-visible) {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* =========================================================
   9. Mensajes flash (toasts)
   ========================================================= */
.messages {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  width: min(94vw, 460px);
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.message {
  pointer-events: auto;
  cursor: pointer;
  padding: 0.75rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-soft);
  background: var(--surface);
  font-size: 0.93rem;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.message.closing {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.message-success {
  border-left-color: var(--ok);
}

.message-error,
.message-danger {
  border-left-color: var(--err);
}

.message-warning {
  border-left-color: var(--warn);
}

.message-info {
  border-left-color: var(--wine);
}

/* =========================================================
   10. Tablas y lista de miembros
   ========================================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th,
.table td {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
  vertical-align: middle;
}

.table th {
  background: var(--paper-2);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 700;
}

.table tr:last-child td {
  border-bottom: none;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
}

.inline-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.inline-actions form {
  display: inline;
}

/* Lista de miembros como filas de app (avatar + nombre + acciones). */
.member-list {
  padding: 0;
  overflow: hidden;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.15rem;
}

.member-row + .member-row {
  border-top: 1px solid var(--line);
}

.member-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  margin-right: auto;
}

.member-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-badges {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.member-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.member-actions form {
  display: inline;
}

@media (max-width: 600px) {
  .member-actions {
    width: 100%;
    padding-left: calc(40px + 0.9rem);
  }
}

/* =========================================================
   11. Invitaciones
   ========================================================= */
.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.invite-card {
  max-width: 480px;
  margin: 2.5rem auto;
  text-align: center;
}

.invite-card h1 {
  margin-top: 0.2rem;
}

.copy-field {
  display: flex;
  gap: 0.5rem;
  min-width: min(420px, 100%);
}

.copy-field input,
.copy-field input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  background: var(--paper);
  color: var(--ink-soft);
}

/* =========================================================
   12. Mapas y detector de sitios
   ========================================================= */
/* Leaflet pinta sus paneles y controles en z-index 400–800. Sin un contexto de
   apilamiento propio esos números compiten con los del resto de la app y el
   mapa se dibuja por encima de la barra de pestañas, del header y de los
   modales. Con `z-index: 0` + `isolation` todo lo de Leaflet se queda dentro
   de su caja y respeta el orden de la app. */
.map,
.map-picker,
.place-map {
  position: relative;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--paper-2);
}

.map {
  height: 70vh;
  min-height: 380px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  /* En móvil el mapa va a sangre, como una pantalla propia, pero termina por
     encima de la barra de pestañas (de ahí el descuento del alto). */
  .map {
    margin-left: -1rem;
    margin-right: -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom, 0px) - 230px);
    min-height: 320px;
  }
}

.map-picker {
  height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
}

/* Leaflet carga su CSS *después* del nuestro (va en el bloque `extra_css` de
   cada página), así que para vestir el mapa con los colores del tema hay que
   ganarle en especificidad. Sin esto, los globos y los botones se quedan
   blancos también en el tema oscuro. */
.leaflet-container.map,
.leaflet-container.map-picker,
.leaflet-container.place-map {
  font-family: var(--sans);
  font-size: 0.82rem;
  background: var(--paper-2);
}

.leaflet-container .leaflet-popup-content-wrapper,
.leaflet-container .leaflet-popup-tip {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
}

.leaflet-container .leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm);
}

.leaflet-container .leaflet-bar a,
.leaflet-container .leaflet-bar a:hover {
  background: var(--surface);
  color: var(--ink);
  border-bottom-color: var(--line);
}

.leaflet-container .leaflet-bar a:hover {
  background: var(--paper-2);
}

body .leaflet-container .leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--ink-soft);
}

body .leaflet-container .leaflet-control-attribution a {
  color: var(--ink-soft);
}

.map-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

/* Pin propio: un cuadrado con una esquina en pico, girado 45°, para no
   depender de las imágenes que Leaflet carga por su cuenta y para que siga
   los colores del tema. */
.map-pin-shape {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  background: var(--wine);
  border: 2px solid var(--surface);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 9px rgba(20, 22, 26, 0.35);
}

.map-pin-shape::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--surface);
  opacity: 0.92;
}

.leaflet-marker-draggable .map-pin-shape {
  cursor: grab;
}

/* Capa que "desbloquea" el mapa al primer toque: sin ella, arrastrar con el
   dedo dentro de un mapa metido en una página larga movería el mapa en vez de
   bajar por la página. */
.map-lock {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.9rem;
  background: transparent;
  pointer-events: none;
}

.map-lock-chip {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.32rem 0.8rem;
  font-size: 0.76rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* Botón redondo flotando sobre un mapa (mi ubicación). */
.map-fab {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  cursor: pointer;
}

.map-fab:active {
  transform: scale(0.94);
}

.map-fab .icon {
  width: 20px;
  height: 20px;
}

.map-empty {
  position: absolute;
  inset: auto 0 0;
  z-index: 500;
  padding: 0.8rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--line);
}

/* Globo de una recomendación en el mapa del grupo. */
.map-popup {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 150px;
}

.map-popup strong {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.2;
}

.map-popup-detail {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.map-popup a,
.map-popup .map-popup-link {
  color: var(--wine);
  font-weight: 600;
  font-size: 0.82rem;
}

/* --- Detector de sitios del formulario --- */
.place-picker {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  /* Igual que los mapas: que las capas de dentro (sugerencias, botón de mi
     ubicación) no compitan con la barra de pestañas ni con el header. */
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 1rem;
  margin: 0;
}

.place-picker > legend {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0 0.4rem;
  margin-left: -0.4rem;
}

@media (max-width: 720px) {
  /* En el móvil el mapa se lleva casi todo el ancho de la tarjeta. */
  .place-picker {
    padding: 0.9rem 0.7rem 1rem;
  }
}

.place-picker .helptext {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0;
}

.place-search {
  position: relative;
  display: flex;
  align-items: center;
}

.place-search-icon {
  position: absolute;
  left: 0.75rem;
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
  pointer-events: none;
}

.place-input,
input.place-input {
  width: 100%;
  padding-left: 2.5rem;
  padding-right: 2.6rem;
  background: var(--surface);
}

.place-mini {
  position: absolute;
  right: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-soft);
  cursor: pointer;
}

.place-mini:hover {
  color: var(--ink);
}

.place-mini .icon {
  width: 15px;
  height: 15px;
}

.place-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.place-help {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.place-help > summary {
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.place-help > summary::-webkit-details-marker {
  display: none;
}

/* Abierto, los pasos ocupan la fila entera en vez de un trozo del flex. */
.place-help[open] {
  flex-basis: 100%;
}

.place-help ol {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  line-height: 1.6;
}

.place-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.place-status.is-error {
  color: var(--err);
}

.place-status.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid color-mix(in srgb, var(--wine) 30%, transparent);
  border-top-color: var(--wine);
  border-radius: 50%;
  animation: place-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .place-status.is-loading::before {
    animation-duration: 2.4s;
  }
}

/* Tarjeta de "esto es lo que hemos detectado". */
.place-found {
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.8rem 0.9rem;
}

.place-found-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ok);
}

.place-found-head .icon {
  width: 15px;
  height: 15px;
}

.place-found-head .place-mini {
  position: static;
  margin-left: auto;
}

.place-found-name {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0.35rem 0 0.1rem;
}

.place-found .info-row {
  font-size: 0.87rem;
  padding: 0.4rem 0;
}

.place-found .btn {
  margin-top: 0.6rem;
}

.place-map-wrap {
  position: relative;
  isolation: isolate;
}

.place-map {
  height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
}

@media (max-width: 720px) {
  .place-map {
    height: 46vh;
    min-height: 260px;
  }
}

.place-picker .disclosure {
  background: var(--surface);
}

/* Sugerencias del buscador de sitios y del de categorías. */
.place-suggestions,
.tag-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  max-height: 260px;
  overflow: auto;
}

.place-suggestions[hidden],
.tag-suggestions[hidden] {
  display: none;
}

.place-suggestions li,
.tag-suggestions li {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink);
}

.place-suggestions li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.place-suggestions li strong {
  font-weight: 600;
}

.place-suggestions li span {
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-suggestions li:hover,
.tag-suggestions li:hover {
  background: var(--paper-2);
}

/* =========================================================
   13. Tags (chips + autocompletado)
   ========================================================= */
.tag-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-chips:empty {
  display: none;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.3rem 0.25rem 0.65rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.tag-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  color: var(--bg);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.tag-chip-x:hover {
  background: var(--wine);
  color: #fff;
}

.tag-field {
  position: relative;
}

.tag-field input {
  width: 100%;
}

/* =========================================================
   14. Subida de fotos (formsets)
   ========================================================= */
.photos-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
  margin: 0;
  background: var(--paper);
}

.photos-fieldset legend {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0 0.4rem;
  margin-left: -0.4rem;
}

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

/* Zona para subir fotos: un solo campo con `multiple` (abre la galería y deja
   elegir varias a la vez); las tarjetas se crean debajo. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
  padding: 1.5rem 1rem;
  margin: 0.6rem 0 0;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-within,
.dropzone.is-drag {
  border-color: var(--wine);
  color: var(--wine);
  background: var(--paper-2);
}

.dropzone-icon .icon {
  width: 1.9rem;
  height: 1.9rem;
  stroke-width: 1.6;
}

.dropzone-title {
  font-weight: 600;
  color: var(--ink);
}

.dropzone-hint {
  font-size: 0.8rem;
}

.photo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.photo-cards:empty {
  margin-top: 0;
}

.photo-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.photo-card.is-removed {
  display: none;
}

.photo-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--paper-2);
}

.photo-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card-remove {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
  box-shadow: none;
}

.photo-card-remove:hover {
  background: var(--wine);
}

.photo-card-remove .icon {
  width: 1rem;
  height: 1rem;
}

.photo-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem;
}

.photo-card-body select,
.photo-card-body input {
  padding: 0.42rem 0.55rem;
  font-size: 0.82rem;
}

.photo-card-body select {
  padding-right: 1.9rem;
}

.file-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  width: fit-content;
}

.file-field input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: 0;
}

.file-btn {
  display: inline-block;
  background: var(--paper-2);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.file-field:hover .file-btn {
  border-color: var(--wine);
  color: var(--wine);
}

.file-name {
  font-size: 0.82rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* =========================================================
   15. Ficha de una recomendación: galería y visor de fotos
   ========================================================= */
/* La ficha se lee mejor estrecha que a todo lo ancho de la pantalla, y
   centrada para que el hueco quede repartido y no todo a la derecha. */
.rec-detail {
  max-width: 800px;
  margin: 0 auto;
}

/* Portada. Es un botón: abre el visor en la primera foto, y así las
   miniaturas de abajo pueden ir pequeñas sin perder nada. */
.rec-hero {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 400px;
  margin: 0 0 1.3rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.rec-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

@media (hover: hover) {
  .rec-hero:hover img {
    transform: scale(1.03);
  }
}

.rec-hero-scrim {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(12, 10, 9, 0.5));
  pointer-events: none;
}

.rec-hero-pill {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(12, 10, 9, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.rec-hero-pill .icon {
  width: 15px;
  height: 15px;
}

@media (max-width: 720px) {
  /* A sangre, como la foto de cabecera de una app. */
  .rec-hero {
    width: auto;
    margin-left: -1rem;
    margin-right: -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    aspect-ratio: 4 / 3;
    max-height: 44vh;
  }
}

/* Cabecera: nombre, nota, precio y quién lo recomienda. */
.rec-head {
  margin-bottom: 1.1rem;
}

.rec-head h1 {
  margin: 0 0 0.55rem;
}

.rec-facts {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.rec-facts-score {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  margin-left: -0.45rem;
}

.rec-fact {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

.rec-fact .icon {
  width: 15px;
  height: 15px;
  color: var(--wine);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.rec-byline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.rec-byline strong {
  color: var(--ink);
}

/* Fila de acciones: guardar, cómo llegar, opinar y (si puedes) editar. */
.rec-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.rec-actions > form {
  display: flex;
}

.rec-actions-end {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: auto;
}

@media (max-width: 520px) {
  /* Los botones con texto llenan la fila; los de icono se quedan pequeños. */
  .rec-actions > form,
  .rec-actions > .btn {
    flex: 1 1 8rem;
  }

  .rec-actions > form .btn {
    width: 100%;
  }
}

.rec-where {
  padding: 0.4rem 1.1rem 1.1rem;
}

.rec-where .map-picker {
  height: 220px;
}

.rec-empty {
  margin: 0;
  padding: 1.1rem 1.2rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* --- Rejilla de fotos --- */
/* Cuadradas y pequeñas: la foto grande ya está arriba y el visor es quien
   enseña de verdad, así que aquí lo que importa es que quepan muchas. */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.5rem;
}

.gallery-sm {
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.35rem;
}

@media (max-width: 720px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }

  .gallery-sm {
    grid-template-columns: repeat(4, 1fr);
  }
}

.gallery-item {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-2);
  cursor: zoom-in;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

@media (hover: hover) {
  .gallery-item:hover img {
    transform: scale(1.06);
  }
}

.gallery-more {
  width: 100%;
  margin-top: 0.6rem;
}

.chip-n {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-size: 0.74rem;
  font-weight: 700;
}

.rec-chip.is-active .chip-n {
  background: rgba(255, 255, 255, 0.22);
}

/* --- Visor de fotos a pantalla completa --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  background: rgba(10, 9, 8, 0.93);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.lightbox.open {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: nav-fade 0.18s ease;
}

@keyframes nav-fade {
  from {
    opacity: 0;
  }
}

.lightbox-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) 1rem 0.7rem;
  color: #f2efe9;
}

.lightbox-count {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.lightbox-top .lightbox-btn {
  margin-left: auto;
}

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0 0.6rem;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-btn:active {
  transform: scale(0.93);
}

.lightbox-btn .icon {
  width: 20px;
  height: 20px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 0.5rem;
}

.lightbox-next {
  right: 0.5rem;
}

.lightbox-nav[hidden] {
  display: none !important;
}

.lightbox-foot {
  padding: 0.85rem 1rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: #f2efe9;
  min-height: 2.6rem;
}

.lightbox-kind {
  display: inline-block;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.lightbox-cap {
  margin: 0.5rem auto 0;
  max-width: 60ch;
  font-size: 0.92rem;
  opacity: 0.9;
}

/* =========================================================
   16. Estados vacíos y hero
   ========================================================= */
.empty-state {
  text-align: center;
  padding: 3.2rem 1rem;
  color: var(--ink-soft);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state::before {
  content: "";
  display: block;
  width: 46px;
  height: 46px;
  margin: 0 auto 0.9rem;
  background: var(--line-strong);
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
}

.empty-state p {
  margin-bottom: 1.2rem;
}

.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2.4rem, 1.6rem + 3vw, 3.6rem);
  line-height: 1.05;
}

.hero p {
  max-width: 560px;
  margin: 1rem auto 1.8rem;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

.hero-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* =========================================================
   17. Debate / comentarios
   ========================================================= */
/* Mismo lenguaje para comentarios y opiniones: avatar a la izquierda y el
   contenido en una columna, para que los dos hilos de una ficha se lean como
   una sola conversación. */
.comments {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.3rem;
}

.comment,
.review {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

.comment-body,
.review-body {
  min-width: 0;
}

.comment-top,
.review-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 30px;
}

.comment-author {
  font-weight: 700;
  font-size: 0.93rem;
}

.comment-date,
.review-date {
  font-size: 0.78rem;
}

.comment-del {
  margin-left: auto;
  display: flex;
}

.comment-text {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Caja de escribir: el avatar de quien comenta y el botón bajo el texto. */
.comment-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.comment-form-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.comment-form textarea {
  min-height: 4.4rem;
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
}

/* =========================================================
   18. Opiniones (reviews)
   ========================================================= */
.rating-summary {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rating-avg {
  font-family: var(--serif);
  font-size: 2.3rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}

.rating-summary-detail {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.84rem;
}

.rating-summary-detail .txistu {
  width: 1.15rem;
  height: 1.15rem;
}

.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.review-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.review .txistu {
  width: 1.1rem;
  height: 1.1rem;
}

.review-comment {
  margin: 0;
  overflow-wrap: anywhere;
}

.review .gallery-sm {
  align-self: stretch;
  margin-top: 0.15rem;
}

/* =========================================================
   19. Estadísticas
   ========================================================= */

/* Pestañas de apartado dentro de una página (control segmentado). */
.subnav {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  padding: 4px;
  margin: 0 0 1.6rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.subnav-item {
  flex: 0 0 auto;
  padding: 0.5rem 1.15rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.subnav-item:hover {
  color: var(--wine);
}

.subnav-item.is-active {
  background: var(--surface);
  color: var(--wine);
  box-shadow: var(--shadow);
}

@media (max-width: 560px) {
  /* A ancho completo reparten el sitio y se leen mejor de un vistazo. */
  .subnav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    overflow: visible;
  }

  .subnav-item {
    padding: 0.55rem 0.5rem;
    text-align: center;
    font-size: 0.84rem;
  }
}

/* La primera sección de una pestaña no necesita la línea de separación. */
.section-title.is-first {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Las dos medias, con la nota en txistus además de en número. */
.score-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.score-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1.3rem 1.4rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.score-tag {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-soft);
}

.score-card .txistus {
  gap: 4px;
}

.score-card .txistu {
  width: 1.25rem;
  height: 1.25rem;
  background-color: var(--gold-soft);
}

.score-card .txistu.is-empty {
  background-color: color-mix(in srgb, var(--bg) 28%, transparent);
}

.score-num {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--bg);
}

.score-num small {
  font-size: 1rem;
  opacity: 0.6;
}

.score-foot {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.72;
}

.score-card.is-empty {
  background: var(--surface);
  color: var(--ink);
  border: 1px dashed var(--line-strong);
}

.score-card.is-empty .score-tag {
  color: var(--ink-soft);
}

.score-card.is-empty .score-num {
  color: var(--line-strong);
}

/* Los totales, en una sola tarjeta con celdas separadas por hilo: el mismo
   lenguaje de "tabla" que las listas, en vez de seis cajas sueltas. */
.stat-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
}

.stat-cell .icon {
  width: 17px;
  height: 17px;
  color: var(--wine);
  margin-bottom: 0.35rem;
}

.stat-num {
  display: block;
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  .stat-board {
    grid-template-columns: 1fr 1fr;
  }

  .stat-cell {
    padding: 0.9rem 0.95rem;
  }

  .stat-num {
    font-size: 1.6rem;
  }
}

/* Cuadro de honor. */
.awards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.8rem;
}

.award {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.award-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--gold) 16%, var(--surface));
  color: var(--gold);
}

.award-icon .icon {
  width: 19px;
  height: 19px;
}

.award .avatar {
  flex: 0 0 auto;
}

.award-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.award-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--wine);
}

.award-value {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.award-value:hover {
  color: var(--wine);
}

.award-detail {
  font-size: 0.82rem;
}

/* Barras de distribución. */
.bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.bar {
  display: grid;
  grid-template-columns: minmax(84px, 26%) 1fr auto;
  align-items: center;
  gap: 0.8rem;
}

.bar-label {
  display: flex;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* En el reparto de notas la etiqueta son txistus: más pequeños, que la
   columna es estrecha. */
.bar-label .txistu {
  width: 0.95rem;
  height: 0.95rem;
}

.bar-label .txistus {
  gap: 2px;
}

.bar-track {
  height: 10px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.bar-count {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.6rem;
  text-align: right;
}

/* =========================================================
   20. Perfil
   ========================================================= */
.profile-card {
  max-width: 460px;
}

.profile-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
}

.profile-row + .profile-row {
  border-top: 1px solid var(--line);
}

.profile-row .field-label {
  width: 5rem;
  flex: 0 0 auto;
  margin: 0;
}

/* =========================================================
   21. Modales (bottom-sheet en móvil)
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 9, 0.55);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 1.7rem 1.7rem 1.8rem;
  animation: modal-in 0.18s ease;
  overscroll-behavior: contain;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 720px) {
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: none;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: 1rem 1.25rem calc(1.6rem + env(safe-area-inset-bottom, 0px));
    animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  }

  /* Asa del bottom-sheet. */
  .modal-card::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--line-strong);
    margin: 0 auto 1rem;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0.5;
    transform: translateY(40px);
  }
}

.modal-card h2 {
  margin-top: 0.2rem;
}

.modal-card h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

.modal-x {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}

.modal-x:hover {
  color: var(--ink);
}

.modal-foot {
  margin-top: 1.2rem;
}

.how-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.how-list li {
  padding-left: 1rem;
  position: relative;
  color: var(--ink-soft);
}

.how-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--wine);
}

.how-list strong {
  color: var(--ink);
}

.install-hint {
  text-align: center;
  margin: 2.5rem 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

body.modal-open {
  overflow: hidden;
}

/* =========================================================
   22. Página de Ajustes
   ========================================================= */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.8rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  background: var(--bg);
}

.theme-option:hover {
  border-color: var(--wine);
}

.theme-option:has(input:checked) {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.theme-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.swatches {
  display: inline-flex;
  gap: 3px;
  flex: 0 0 auto;
}

.swatches i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.theme-name {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  line-height: 1.25;
}

.theme-name small {
  font-weight: 500;
  font-size: 0.78rem;
}

.opt-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pill-option {
  position: relative;
  cursor: pointer;
}

.pill-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.pill-option span {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.pill-option:hover span {
  border-color: var(--wine);
  color: var(--wine);
}

.pill-option:has(input:checked) span {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.switch-row > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-weight: 600;
}

.switch-row small {
  font-weight: 500;
  font-size: 0.8rem;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s ease;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked + i {
  background: var(--ok);
}

.switch input:checked + i::after {
  transform: translateX(20px);
}

/* =========================================================
   23. Autenticación (allauth)
   ========================================================= */
.auth-wrap {
  max-width: 430px;
  margin: 2.5rem auto;
}

.auth-card {
  padding: 1.8rem 1.8rem 2rem;
}

.auth-card h1 {
  font-size: 1.7rem;
  margin-bottom: 1.2rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.auth-card p {
  margin-bottom: 0.8rem;
}

.auth-panel {
  margin-bottom: 1.4rem;
}

@media (max-width: 520px) {
  .auth-wrap {
    margin: 1rem auto;
  }

  .auth-card {
    padding: 1.4rem 1.2rem 1.6rem;
  }
}

/* =========================================================
   23b. Densidad de las listas (tarjetas / lista compacta)
   =========================================================
   La preferencia es la cookie `density`, que base.html vuelca en
   <html data-density="…">. El marcado de las tarjetas es EL MISMO en las dos
   vistas: aquí solo se reordena. Así el cambio es instantáneo (initDensity
   reescribe el atributo) y no hay dos plantillas que mantener.

   En compacto la rejilla pasa a ser una sola caja con filas dentro, para que
   se lea como una tabla: muchas recomendaciones de un vistazo y la foto
   reducida a miniatura. */

/* Selector de densidad (dos botones segmentados). */
.density-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.density-toggle button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.density-toggle button .icon {
  width: 17px;
  height: 17px;
}

.density-toggle button:hover {
  color: var(--wine);
}

.density-toggle button.is-active {
  background: var(--surface);
  color: var(--wine);
  box-shadow: var(--shadow);
}

.density-toggle button:active {
  transform: scale(0.92);
}

/* Precio dentro del cuerpo: solo hace falta cuando no hay foto grande. */
.rec-price {
  display: none;
  font-weight: 700;
  color: var(--ink-soft);
}

/* Chevron de "entrar al grupo": solo en la vista de lista. */
.card-group-go {
  display: none;
  color: var(--ink-soft);
  width: 18px;
  height: 18px;
}

/* --- Recomendaciones en lista ------------------------------------------ */
:root[data-density="compact"] .grid-recs {
  display: block;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

:root[data-density="compact"] .grid-recs .rec-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.7rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

/* Separador entre filas visibles. El `:not([hidden])` evita que, al filtrar,
   la primera fila que queda a la vista arrastre una línea suelta arriba. */
:root[data-density="compact"] .grid-recs .rec-card:not([hidden]) ~ .rec-card:not([hidden]) {
  border-top: 1px solid var(--line);
}

:root[data-density="compact"] .grid-recs .rec-card:active {
  transform: none;
}

@media (hover: hover) {
  :root[data-density="compact"] .grid-recs .rec-card:hover {
    background: var(--paper-2);
    box-shadow: none;
    transform: none;
  }
}

:root[data-density="compact"] .rec-card .rec-photo {
  grid-column: 1;
  grid-row: 1;
  width: 48px;
  height: 48px;
  aspect-ratio: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

:root[data-density="compact"] .rec-photo.rec-photo-empty::before {
  width: 24px;
  height: 24px;
}

:root[data-density="compact"] .rec-card .rec-body {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-flow: row wrap;
  align-items: baseline;
  gap: 0.1rem 0.6rem;
  padding: 0;
  min-width: 0;
}

:root[data-density="compact"] .rec-card .rec-body h3 {
  flex: 1 0 100%;
  min-width: 0;
  font-size: 0.97rem;
  line-height: 1.3;
}

:root[data-density="compact"] .rec-card .rec-meta {
  font-size: 0.79rem;
  gap: 0.2rem 0.5rem;
}

/* Los txistus a 1.4rem ocupan ~130px: en una fila se comen el ancho y tiran
   la ciudad y el autor a una tercera línea. A 1rem la fila entra en dos. */
:root[data-density="compact"] .rec-card .txistu {
  width: 0.92rem;
  height: 0.92rem;
}

:root[data-density="compact"] .rec-card .txistus {
  gap: 2px;
}

/* En una fila sobran: el precio ya sale en texto y las categorías alargarían
   la línea sin aportar (siguen en el detalle y en los filtros de arriba). */
:root[data-density="compact"] .photo-badge,
:root[data-density="compact"] .rec-tags,
:root[data-density="compact"] .rec-edit {
  display: none;
}

:root[data-density="compact"] .rec-price {
  display: inline;
}

:root[data-density="compact"] .rec-save {
  position: static;
  grid-column: 3;
  grid-row: 1;
}

:root[data-density="compact"] .rec-save button {
  width: 34px;
  height: 34px;
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

:root[data-density="compact"] .rec-save button:hover {
  background: var(--paper-2);
  color: var(--wine);
}

:root[data-density="compact"] .rec-save button.is-saved {
  background: transparent;
  color: var(--gold);
}

/* --- Grupos en lista ---------------------------------------------------- */
:root[data-density="compact"] .grid-groups {
  display: block;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

:root[data-density="compact"] .grid-groups .card-group {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

:root[data-density="compact"] .grid-groups .card-group + .card-group {
  border-top: 1px solid var(--line);
}

:root[data-density="compact"] .grid-groups .card-group:active {
  transform: none;
}

@media (hover: hover) {
  :root[data-density="compact"] .grid-groups .card-group:hover {
    background: var(--paper-2);
    box-shadow: none;
    transform: none;
  }
}

:root[data-density="compact"] .card-group .group-cover {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

:root[data-density="compact"] .group-cover.is-empty::before {
  width: 26px;
  height: 26px;
}

:root[data-density="compact"] .card-group-body {
  padding: 0;
  gap: 0.1rem;
  min-width: 0;
}

:root[data-density="compact"] .card-group-body p {
  display: none;
}

:root[data-density="compact"] .card-group h2 {
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-density="compact"] .card-group-body .rec-meta {
  margin-top: 0;
  padding-top: 0;
  font-size: 0.76rem;
  gap: 0.15rem 0.55rem;
}

:root[data-density="compact"] .card-group-go {
  display: block;
}

/* =========================================================
   23c. Piezas sueltas de interfaz
   ========================================================= */

/* Icono al tamaño del texto, dentro de un párrafo. */
.inline-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
}

/* Bloque plegable ("Crear enlace de invitación"). */
.disclosure {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary:hover {
  color: var(--wine);
}

.disclosure > summary .icon {
  color: var(--wine);
  flex: 0 0 auto;
}

.disclosure-caret {
  margin-left: auto;
  color: var(--ink-soft);
  transition: transform 0.18s ease;
}

.disclosure[open] .disclosure-caret {
  transform: rotate(90deg);
}

.disclosure-body {
  padding: 1rem 1.1rem 1.1rem;
  border-top: 1px solid var(--line);
}

.disclosure-body .form {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

/* Ajustes del grupo: una tarjeta por cada cosa que se puede tocar. */
.setting-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

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

.setting-head p {
  margin: 0;
  font-size: 0.9rem;
  max-width: 54ch;
}

.setting-card form {
  width: 100%;
}

.setting-card .form-actions {
  margin-top: 0.9rem;
}

.setting-card.is-danger {
  border-color: color-mix(in srgb, var(--err) 35%, var(--line));
}

.setting-card.is-danger .setting-head h2 {
  color: var(--err);
}

.image-setting {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.image-setting-preview {
  flex: 0 0 auto;
  width: 108px;
  height: 108px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper-2) center / cover no-repeat;
}

.image-setting-preview.is-empty {
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--wine) 10%, var(--paper-2)),
    var(--paper-2) 70%
  );
}

.image-setting-preview.is-empty::before {
  content: "";
  width: 44px;
  height: 44px;
  background: color-mix(in srgb, var(--wine) 38%, var(--line-strong));
  -webkit-mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
  mask: url("../images/txistu.ebfbafa8cf56.png") center / contain no-repeat;
}

.image-setting-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  flex: 1 1 220px;
}

/* Opción de densidad en Ajustes, con una miniatura de cómo queda. */
.density-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.density-option {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.density-option:hover {
  border-color: var(--wine);
}

.density-option:has(input:checked) {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.density-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.density-preview {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 34px;
}

.density-preview i {
  height: 14px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--wine) 45%, var(--line-strong));
}

.density-preview.is-rows {
  grid-template-columns: 1fr;
}

.density-preview.is-rows i {
  height: 5px;
}

/* Botón que abre el modal de filtros, con el contador de los que hay puestos. */
.filter-btn {
  flex: 0 0 auto;
  gap: 0.45rem;
}

.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.32rem;
  border-radius: 999px;
  background: var(--wine);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.filter-count[hidden] {
  display: none;
}

/* Modal de filtros: cada bloque separado por una línea, para leerlo de un
   vistazo aunque haya varios grupos de chips. */
.filter-modal .modal-card {
  padding-bottom: 0;
}

.filter-group + .filter-group {
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}

.filter-group:first-of-type {
  margin-top: 1.1rem;
}

.filter-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
}

/* Dentro del modal los chips se ven todos: envuelven en vez de deslizarse. */
.filter-group .rec-chips {
  flex-wrap: wrap;
  overflow: visible;
  padding-bottom: 0;
}

.filter-group .switch-row {
  gap: 1rem;
}

/* Pie pegado al fondo: en el bottom-sheet del móvil, "Ver N sitios" siempre
   queda a mano aunque la lista de categorías sea larga. */
.filter-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.3rem;
  padding: 0.85rem 0 1rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.filter-foot .js-filter-apply {
  margin-left: auto;
}

@media (max-width: 720px) {
  .filter-foot {
    padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
  }

  /* A ancho completo se pulsan mejor con el pulgar. */
  .filter-foot .btn {
    flex: 1;
    justify-content: center;
  }
}

/* Salida de una tarjeta al quitarle el marcador en "Mis guardados". */
.rec-card.is-leaving {
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

/* El icono del marcador se rellena cuando está activo, sea el botón grande del
   detalle o el marcador de la tarjeta. */
.btn[aria-pressed="true"] .icon {
  fill: currentColor;
}

/* =========================================================
   23d. Paginación de las listas
   ========================================================= */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
  margin: 1.2rem 0 0.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pager-range {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  order: 1;
}

.pager-nav {
  order: 2;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pager-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pager-btn,
.pager-num {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.pager-btn .icon {
  width: 16px;
  height: 16px;
}

.pager-btn:hover:not(:disabled),
.pager-num:hover:not(.is-active) {
  border-color: var(--wine);
  color: var(--wine);
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pager-num.is-active {
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
  cursor: default;
}

.pager-gap {
  padding: 0 0.15rem;
  color: var(--ink-soft);
  user-select: none;
}

.pager-size {
  order: 3;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.pager-size select {
  width: auto;
  min-width: 0;
  padding: 0.35rem 2rem 0.35rem 0.7rem;
  font-size: 0.86rem;
}

@media (max-width: 640px) {
  /* En móvil los botones mandan: van arriba y a lo ancho, y debajo quedan el
     recuento y el tamaño de página, que son de consulta. */
  .pager {
    justify-content: space-between;
  }

  .pager-nav {
    order: 1;
    width: 100%;
    justify-content: center;
  }

  .pager-range {
    order: 2;
  }

  .pager-size {
    order: 3;
  }

  .pager-btn,
  .pager-num {
    min-width: 40px;
    height: 40px;
  }
}

/* =========================================================
   24. Ajustes móviles finales
   ========================================================= */
@media (max-width: 720px) {
  .container {
    padding: 0 1rem;
  }

  .main-content {
    padding-top: 1.6rem;
  }
}

@media (max-width: 520px) {
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
    text-align: center;
  }

  .page-head {
    align-items: flex-start;
  }

  .head-actions {
    width: 100%;
  }

  .head-actions .btn {
    flex: 1;
    text-align: center;
  }

  /* El selector de densidad no se estira con los botones. */
  .head-actions .density-toggle {
    order: -1;
  }

  .page-section-head {
    flex-wrap: wrap;
  }

  .form {
    padding: 1.15rem 1.1rem 1.3rem;
  }
}
