:root {
  --acento: #e8590c;
  --fondo: #f7f5f2;
  --superficie: #ffffff;
  --texto: #1f1d1a;
  --tenue: #6f6a63;
  --borde: #e6e1da;
  --si: #2f9e44;
  --quiza: #e67700;
  --no: #c92a2a;
  --radio: 14px;
  --sombra: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .04);
  --nav-alto: 64px;
  color-scheme: light;
}
/* Tema oscuro: si el usuario lo elige, o en "automático" si el móvil está en modo oscuro. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    --fondo: #151412;
    --superficie: #201e1b;
    --texto: #f1ede7;
    --tenue: #a39d94;
    --borde: #34312c;
    --si: #51cf66;
    --quiza: #fcc419;
    --no: #ff6b6b;
    --sombra: none;
    color-scheme: dark;
  }
}
:root[data-theme="oscuro"] {
  --fondo: #151412;
  --superficie: #201e1b;
  --texto: #f1ede7;
  --tenue: #a39d94;
  --borde: #34312c;
  --si: #51cf66;
  --quiza: #fcc419;
  --no: #ff6b6b;
  --sombra: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  padding-bottom: calc(var(--nav-alto) + env(safe-area-inset-bottom));
}
a { color: var(--acento); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--tenue); }
pre { background: var(--fondo); padding: .6rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }

/* Estructura */
.barra {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 16px .6rem;
  background: color-mix(in srgb, var(--fondo) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}
.marca { font-weight: 800; font-size: 1.1rem; color: var(--texto); text-decoration: none; }
.contenido { max-width: 680px; margin: 0 auto; padding: 12px 16px 24px; }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-alto) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--superficie); border-top: 1px solid var(--borde);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .68rem; color: var(--tenue); text-decoration: none; min-width: 0;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.activa { color: var(--acento); font-weight: 600; }

body.centrado { padding-bottom: 0; }
body.centrado .contenido { min-height: 100dvh; display: grid; place-items: center; }
.caja {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--superficie); padding: 28px 20px; border-radius: var(--radio); box-shadow: var(--sombra);
}
.caja .formulario { text-align: left; }
.logo { display: block; margin: 0 auto 8px; border-radius: 18px; }

/* Mensajes */
.mensajes { display: grid; gap: 8px; margin-bottom: 12px; }
.mensaje { padding: .7rem .9rem; border-radius: 10px; background: var(--superficie); border-left: 4px solid var(--acento); box-shadow: var(--sombra); }
.mensaje-success { border-color: var(--si); }
.mensaje-error { border-color: var(--no); }
.mensaje-warning { border-color: var(--quiza); }
.aviso {
  background: color-mix(in srgb, var(--quiza) 12%, var(--superficie));
  border: 1px solid color-mix(in srgb, var(--quiza) 40%, transparent);
  padding: 12px 14px; border-radius: var(--radio); margin: 16px 0; text-align: left;
}
.aviso p { margin-top: 0; }

/* Botones */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--acento); color: #fff; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.boton:active { transform: scale(.98); }
.boton-sm { min-height: 36px; padding: 0 14px; font-size: .9rem; }
.boton-secundario { background: var(--superficie); color: var(--texto); border: 1px solid var(--borde); }
.boton-peligro { background: transparent; color: var(--no); border: 1px solid currentColor; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; align-items: center; }
.acciones form { margin: 0; }

/* Formularios */
.formulario { display: grid; gap: 14px; }
.formulario .boton { width: 100%; }
.campo { display: grid; gap: 4px; }
.campo label { font-weight: 600; font-size: .9rem; }
.campo input:not([type=checkbox]):not([type=color]), .campo textarea, .campo select, input.enlace {
  width: 100%; padding: .7rem .8rem; font: inherit; color: inherit;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px;
}
.campo input[type=color] { width: 64px; height: 40px; border: 0; padding: 0; background: none; }
.campo input:focus, .campo textarea:focus { outline: 2px solid var(--acento); outline-offset: 1px; }
.ayuda { color: var(--tenue); font-size: .8rem; }
.ayuda ul { margin: .2rem 0; padding-left: 1.1rem; }
.error { color: var(--no); font-size: .85rem; }
.con-error input { border-color: var(--no) !important; }

/* Listas y tarjetas */
.lista { display: grid; gap: 10px; }
.tarjeta {
  display: flex; gap: 12px; align-items: center;
  background: var(--superficie); border-radius: var(--radio); padding: 12px; box-shadow: var(--sombra);
  color: inherit; text-decoration: none; border: 1px solid var(--borde);
}
.quedada .fecha {
  flex: none; width: 52px; height: 56px; border-radius: 12px; display: grid; place-content: center; text-align: center;
  background: color-mix(in srgb, var(--acento) 14%, var(--superficie)); color: var(--acento);
}
.quedada .dia { font-size: 1.35rem; font-weight: 800; line-height: 1; }
.quedada .mes { font-size: .72rem; text-transform: uppercase; font-weight: 700; }
.quedada .info { display: grid; gap: 2px; min-width: 0; }
.quedada .info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado-cancelada { opacity: .6; }
.estado-cancelada strong { text-decoration: line-through; }
.estado-pendiente .fecha { background: color-mix(in srgb, var(--quiza) 18%, var(--superficie)); color: var(--quiza); }
.estado-celebrada .fecha { background: color-mix(in srgb, var(--si) 14%, var(--superficie)); color: var(--si); }

.meta { color: var(--tenue); font-size: .85rem; }
.vacio { color: var(--tenue); text-align: center; padding: 24px 0; }
.migas { margin: 0 0 4px; font-size: .9rem; }
.migas a { text-decoration: none; }
.cabecera-seccion { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 1.6rem 0 .6rem; }
.cabecera-seccion:first-child { margin-top: .4rem; }
.cabecera-seccion h1, .cabecera-seccion h2 { margin: 0; }
.enlace-lateral { text-align: right; font-size: .9rem; margin: 0 0 10px; }

.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--borde); color: var(--texto); width: fit-content;
}
.chip-si { background: color-mix(in srgb, var(--si) 18%, transparent); color: var(--si); }
.chip-quiza { background: color-mix(in srgb, var(--quiza) 20%, transparent); color: var(--quiza); }
.chip-no { background: color-mix(in srgb, var(--no) 16%, transparent); color: var(--no); }
.chip-aviso { background: color-mix(in srgb, var(--quiza) 20%, transparent); color: var(--quiza); }
.chip-pendiente { background: color-mix(in srgb, var(--acento) 16%, transparent); color: var(--acento); }

/* Segmentos (pestañas internas) */
.segmentos { display: flex; gap: 4px; padding: 4px; background: var(--borde); border-radius: 999px; margin-bottom: 12px; }
.segmentos a { flex: 1; text-align: center; padding: 6px 10px; border-radius: 999px; color: var(--texto); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.segmentos a.activo { background: var(--superficie); font-weight: 600; box-shadow: var(--sombra); }
.segmentos.desplazable { overflow-x: auto; }
.segmentos.desplazable a { flex: 0 0 auto; }
.punto { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--quiza); color: #fff; font-size: .7rem; font-weight: 700; }

/* Contadores */
.contadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.contador {
  display: grid; padding: 14px; border-radius: var(--radio); text-decoration: none; color: inherit;
  background: var(--superficie); border: 1px solid var(--borde); box-shadow: var(--sombra);
}
.contador .numero { font-size: 2.2rem; font-weight: 800; line-height: 1.1; color: var(--acento); }
.contador .etiqueta { color: var(--tenue); font-size: .85rem; }

/* Avatares y personas */
.avatar {
  --c: var(--acento);
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; font-size: .9rem; text-decoration: none;
}
img.avatar { object-fit: cover; background: var(--borde); padding: 0; }
.avatar-sm { width: 26px; height: 26px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }
.personas { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.personas li { display: flex; align-items: center; gap: 6px; background: var(--superficie); border: 1px solid var(--borde); border-radius: 999px; padding: 3px 12px 3px 3px; font-size: .9rem; }
.personas.tenue li { opacity: .65; }
.personas.grande { display: grid; gap: 8px; }
.personas.grande li { border-radius: var(--radio); padding: 8px 12px; }
.perfil-cabecera { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.perfil-cabecera h1 { margin: 0; }

/* Ficha de quedada */
.ficha { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); }
.ficha h1 { margin-top: 0; }
.ficha .dato { margin: .2rem 0; }
.ficha .descripcion { white-space: normal; margin: .8rem 0; }

/* RSVP */
.opciones-rsvp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opcion {
  min-height: 48px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--superficie); color: var(--texto); border: 2px solid var(--borde);
}
.opcion-si.elegida { background: var(--si); border-color: var(--si); color: #fff; }
.opcion-quiza.elegida { background: var(--quiza); border-color: var(--quiza); color: #fff; }
.opcion-no.elegida { background: var(--no); border-color: var(--no); color: #fff; }
.htmx-request .opcion { opacity: .6; }

/* Checklist de asistencia */
.checklist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.checklist label {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: 12px;
}
.checklist input { width: 22px; height: 22px; accent-color: var(--si); }
.checklist label:has(input:checked) { border-color: var(--si); background: color-mix(in srgb, var(--si) 8%, var(--superficie)); }
.checklist .nombre { flex: 1; }

/* Tabla de estadísticas */
.tabla { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: .9rem; }
.tabla th { text-align: left; color: var(--tenue); font-weight: 600; font-size: .75rem; text-transform: uppercase; padding: 6px 4px; }
.tabla td { padding: 8px 4px; border-top: 1px solid var(--borde); }
.tabla td.nombre { display: flex; align-items: center; gap: 6px; }
.barrita { position: relative; width: 52px; height: 18px; border-radius: 9px; background: var(--borde); overflow: hidden; }
.barrita::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: color-mix(in srgb, var(--acento) 60%, transparent); }
.barrita span { position: relative; display: block; text-align: center; font-size: .72rem; font-weight: 700; line-height: 18px; }

/* Invitaciones */
.invitaciones { list-style: none; padding: 0; display: grid; gap: 10px; }
.invitaciones .tarjeta { display: grid; gap: 8px; }
.invitaciones .acciones { margin: 0; }
input.enlace { font-size: .8rem; color: var(--tenue); }
.formulario.en-linea { grid-template-columns: 1fr; }

@media (min-width: 720px) {
  .tabs { inset: 0 auto 0 0; width: 88px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--borde); }
  body { padding-bottom: 0; padding-left: 88px; }
  body.centrado { padding-left: 0; }
}

/* Selector de foto (perfil / registro) */
.selector-foto {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 12px; border: 2px dashed var(--borde); border-radius: var(--radio); background: var(--superficie);
}
.selector-foto input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.selector-foto:focus-within { border-color: var(--acento); }
.previa-foto {
  flex: none; width: 72px; height: 72px; border-radius: 50%;
  background: var(--borde) center / cover no-repeat;
  display: grid; place-items: center; font-size: 1.6rem;
}
.previa-foto:empty::before { content: "📷"; }
.previa-foto.con-imagen::before { content: ""; }
.boton-enlace { background: none; border: 0; color: var(--tenue); font: inherit; text-decoration: underline; cursor: pointer; margin-top: 12px; }
.enlace-tarjeta { justify-content: space-between; font-weight: 600; }
.selector-tema { margin: 0; }
.selector-tema button { flex: 1; border: 0; background: none; color: var(--texto); font: inherit; font-size: .9rem; padding: 8px 6px; border-radius: 999px; cursor: pointer; }
.selector-tema button.activo { background: var(--superficie); font-weight: 600; box-shadow: var(--sombra); }

/* Carrete */
.albumes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .albumes { grid-template-columns: repeat(3, 1fr); } }
.album-tarjeta { display: grid; gap: 2px; color: inherit; text-decoration: none; min-width: 0; }
.album-tarjeta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cubierta {
  position: relative; aspect-ratio: 1; border-radius: var(--radio); overflow: hidden;
  background: var(--borde); display: grid; place-items: center; margin-bottom: 4px;
}
.cubierta img { width: 100%; height: 100%; object-fit: cover; }
.sin-fotos, .mas { font-size: 2rem; color: var(--tenue); }
.album-tarjeta.nuevo .cubierta { background: transparent; border: 2px dashed var(--borde); }
.etiqueta-album {
  position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--acento); color: #fff; font-size: .7rem; font-weight: 700;
}
.rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: 10px; overflow: hidden; }
@media (min-width: 560px) { .rejilla { grid-template-columns: repeat(4, 1fr); } }
.miniatura { display: block; aspect-ratio: 1; background: var(--borde); }
.miniatura img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cargar-mas { grid-column: 1 / -1; text-align: center; padding: 16px; color: var(--tenue); }
.grupo-fotos h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.grupo-fotos h2 a { color: inherit; text-decoration: none; }
.filtro { background: var(--superficie); border: 1px solid var(--borde); padding: 8px 12px; border-radius: 10px; }

/* Subida */
.zona-subida {
  display: grid; place-items: center; text-align: center; min-height: 140px; cursor: pointer;
  border: 2px dashed var(--borde); border-radius: var(--radio); background: var(--superficie); padding: 16px;
}
.zona-subida input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.zona-subida:focus-within { border-color: var(--acento); }
.previas { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.previas img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.progreso { position: relative; height: 28px; border-radius: 14px; background: var(--borde); overflow: hidden; }
.progreso-barra { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--acento); transition: width .2s; }
.progreso-texto { position: relative; display: block; text-align: center; line-height: 28px; font-size: .85rem; font-weight: 600; }
.campo select { width: 100%; padding: .7rem .8rem; font: inherit; color: inherit; background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; }

/* Visor de fotos */
.visor-pagina .barra { display: none; }
.visor { margin: -12px -16px 0; background: #000; color: #fff; }
.visor-barra { display: flex; justify-content: space-between; padding: 10px 16px; }
.visor-barra a { color: #fff; text-decoration: none; }
.visor-barra .meta { color: #bbb; }
.visor-imagen { position: relative; display: grid; place-items: center; min-height: 50vh; touch-action: pan-y; }
.visor-imagen img { max-width: 100%; max-height: calc(100dvh - 260px); object-fit: contain; display: block; }
.flecha {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px;
  display: grid; place-items: center; font-size: 2.4rem; color: #fff; text-decoration: none;
  background: rgb(0 0 0 / .25);
}
.flecha.izq { left: 0; border-radius: 0 12px 12px 0; }
.flecha.der { right: 0; border-radius: 12px 0 0 12px; }
.visor-info { padding-top: 12px; }
.visor-info p { display: block; line-height: 1.9; }
.visor-info .avatar { vertical-align: middle; }

/* Editor circular de la foto de perfil */
body.sin-scroll { overflow: hidden; }
.recortador {
  position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(0, 1fr);
  place-items: center; background: rgb(0 0 0 / .94); padding: 16px;
}
.recortador-panel { width: 100%; max-width: 380px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; color: #fff; }
.recortador-zoom input { min-width: 0; }
.recortador-titulo { margin: 0; text-align: center; font-weight: 600; }
.recortador-area {
  position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 12px;
  background: #000; touch-action: none; cursor: grab; user-select: none;
}
.recortador-area:active { cursor: grabbing; }
.recortador-area img {
  position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0;
  pointer-events: none; -webkit-user-drag: none;
}
.recortador-mascara {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / .55); outline: 2px solid rgb(255 255 255 / .9); outline-offset: -2px;
}
.recortador-zoom { display: flex; align-items: center; gap: 12px; font-size: 1.3rem; }
.recortador-zoom input { flex: 1; accent-color: var(--acento); }
.recortador-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recortador .boton-secundario { background: transparent; color: #fff; border-color: rgb(255 255 255 / .4); }

/* Los <input type=file> visualmente ocultos no deben ensanchar la página. */
.selector-foto, .zona-subida { position: relative; }
.campo .selector-foto input[type="file"], .zona-subida input[type="file"] {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0;
  opacity: 0; overflow: hidden; clip-path: inset(50%);
}
