button, [role="button"], select, summary, input:not([type="checkbox"], [type="radio"]) { min-height: 2rem; }
* { box-sizing: border-box; }
:root {
  color-scheme: light dark;
  --bg: #ece5df;
  --panel: #fbf8f4;
  --panel-2: #f3ede7;
  --ink: #2b2521;
  --muted: #7d7268;
  --line: #ddd2c6;
  --field-bg: #ffffff;
  --chip: #efe8e0;
  --chip-ink: #57504c;
  --btn: #57504c;
  --btn-ink: #ffffff;
  --notice-bg: #f9e9e2;
  --notice-line: #d9a184;
  --notice-ink: #6e3520;
  --shadow: 0 12px 32px rgba(64, 52, 44, .12);
  /* Carnet artwork palette — fixed, from the Free Spirits cover */
  --mauve: #a08e8a;
  --taupe: #7e726c;
  --taupe-deep: #57504c;
  --card-bg: #fffdfa;
  --card-ink: #2b2724;
  --card-muted: #97867c;
  --card-line: #e7e0d8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171310;
    --panel: #221d18;
    --panel-2: #292219;
    --ink: #f3ece4;
    --muted: #b3a696;
    --line: #3b342b;
    --field-bg: #2b251f;
    --chip: #322b24;
    --chip-ink: #e8ddd2;
    --btn: #e8ddd2;
    --btn-ink: #2b2521;
    --notice-bg: #3a2721;
    --notice-line: #8a5a44;
    --notice-ink: #f3cdb8;
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  }
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  line-height: 1.45;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 56px; }

/* ---------- Hero ---------- */
.hero { max-width: 720px; margin-bottom: 26px; }
.hero-kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px; font-weight: 600;
  letter-spacing: .28em;
  color: var(--muted);
  margin: 0 0 10px;
}
.hero h1 {
  font-size: clamp(30px, 5.4vw, 46px);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.hero .lede { font-size: clamp(15px, 2.4vw, 17px); color: var(--muted); margin: 0 0 18px; max-width: 60ch; }
.hero .lede strong { color: var(--ink); font-weight: 700; }
.steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px; font-weight: 600; letter-spacing: .06em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
}

/* ---------- Layout ---------- */
.layout { display: flex; flex-direction: column; gap: 26px; max-width: 880px; margin: 0 auto; }
.form-panel { min-width: 0; width: 100%; }
.preview-col { min-width: 0; width: 100%; }
.result-head { max-width: 720px; margin-bottom: 16px; }
.result-head h2 { font-size: clamp(22px, 3.6vw, 28px); font-weight: 800; margin: 0 0 8px; }
.result-head p { color: var(--muted); margin: 0; font-size: 15px; }
.carnet { margin-left: auto; margin-right: auto; }
.carnet { max-width: 780px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.block + .block { margin-top: 28px; padding-top: 24px; border-top: 1px dashed var(--line); }
.block h2 { font-size: 17px; font-weight: 800; margin: 0 0 14px; letter-spacing: .01em; }
.block h2 em { font-style: normal; font-weight: 600; color: var(--muted); font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.hint.top { margin: 0 0 14px; }

/* ---------- Aviso en línea (errores de la foto) ----------
   Vive dentro del bloque de la foto, en el flujo normal de la
   página: empuja el contenido en vez de flotar sobre los campos,
   y se cierra con su botón. */
.notice {
  display: none;
  align-items: flex-start; gap: 10px;
  margin-top: 12px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  color: var(--notice-ink);
  border-radius: 12px;
  padding: 11px 8px 11px 14px;
  font-size: 14px; font-weight: 600; line-height: 1.4;
}
.notice.show { display: flex; }
.notice-msg { flex: 1; padding-top: 5px; }
.notice-close {
  flex: none;
  background: transparent; border: 0; color: inherit;
  font-size: 20px; line-height: 1; font-weight: 700;
  width: 34px; min-height: 34px; height: 34px;
  border-radius: 999px; padding: 0;
  display: grid; place-items: center;
}
.notice-close:hover { background: rgba(0, 0, 0, .08); }

/* ---------- Form controls ---------- */
.dz {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 20px 16px;
  cursor: pointer;
  min-height: 104px;
  transition: border-color .15s, background .15s;
}
.dz:hover, .dz:focus-within { border-color: var(--taupe); }
.dz.dragging { border-color: var(--taupe-deep); background: var(--chip); }
/* El input va reducido a un punto de 2px en la esquina de la zona
   (técnica de «visualmente oculto» sin clip ni opacidad 0): su
   texto nativo «Seleccionar archivo · ningún archivo seleccionado»
   no cabe ni se ve, pero el control sigue en el DOM, enfocable
   con teclado y operable. La zona reenvía el toque con
   input.click() desde su propio manejador de clic — lo que
   fallaba en navegadores dentro de apps era el reenvío automático
   de un <label> a su control, no el clic por JS dentro del gesto
   del usuario. */
.dz input {
  position: absolute; top: 8px; left: 8px;
  width: 2px; height: 2px; min-height: 0;
  margin: 0; padding: 0; border: 0;
  overflow: hidden;
}
.dz.has-photo svg { display: none; }
.dz-thumb {
  width: 68px; height: 68px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line);
  margin-bottom: 2px;
}
.dz svg { width: 26px; height: 26px; color: var(--taupe); margin-bottom: 2px; }
.dz-title { font-weight: 700; font-size: 14.5px; }
.dz-sub { font-size: 12.5px; color: var(--muted); font-family: "IBM Plex Mono", monospace; letter-spacing: .04em; }

.ctl-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.zoom { display: flex; align-items: center; gap: 10px; flex: 1; font-size: 13px; font-weight: 600; color: var(--muted); }
.zoom input[type="range"] { flex: 1; accent-color: var(--taupe); min-height: 36px; }
.zoom input[type="range"]:disabled { opacity: .35; }

button { font-family: inherit; cursor: pointer; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  min-height: 38px; white-space: nowrap;
}
.ghost:hover { color: var(--ink); border-color: var(--taupe); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; font-weight: 600; letter-spacing: .22em;
  color: var(--muted); margin-bottom: 6px; text-transform: uppercase;
}
.field input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; font-weight: 600;
  color: var(--ink); background: var(--field-bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; min-height: 46px;
}
.field input[type="text"]:focus { outline: 2px solid var(--taupe); outline-offset: 1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: -4px 0 16px; }
.chips button {
  background: var(--chip); color: var(--chip-ink);
  border: 1px solid transparent; border-radius: 999px;
  font-size: 13px; font-weight: 600; padding: 8px 13px; min-height: 38px;
}
.chips button:hover { border-color: var(--taupe); }
.chips button.active { background: var(--taupe-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .chips button.active { background: #e8ddd2; color: #2b2521; } }

/* ---------- Tour dates picker ---------- */
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .date-grid { grid-template-columns: 1fr; } }
.date-btn {
  text-align: left;
  background: var(--field-bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; min-height: 56px;
}
.date-btn b { display: block; font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.date-btn span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.date-btn:hover { border-color: var(--taupe); }
.date-btn.active { background: var(--taupe-deep); color: #fff; border-color: var(--taupe-deep); }
.date-btn.active span { color: rgba(255, 255, 255, .78); }
@media (prefers-color-scheme: dark) {
  .date-btn.active { background: #e8ddd2; color: #2b2521; border-color: #e8ddd2; }
  .date-btn.active span { color: rgba(43, 37, 33, .72); }
}
/* Tour desplegable por países */
.tour-main { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); padding: 2px 12px 12px; }
.tour-main > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 800; font-size: 15px; padding: 12px 2px 10px; min-height: 2rem;
}
.tour-main > summary::-webkit-details-marker { display: none; }
.tour-main-hint { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
.tour-main-chev, .tour-country-chev { flex: none; font-size: 13px; color: var(--muted); transition: transform .18s ease; line-height: 1; }
.tour-main[open] > summary .tour-main-chev, .tour-country[open] .tour-country-chev { transform: rotate(180deg); }
.tour-country { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin-top: 10px; overflow: hidden; }
.tour-country.has-selected { border-color: var(--taupe); }
.tour-country-summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; min-height: 48px;
}
.tour-country-summary::-webkit-details-marker { display: none; }
.tour-country-name { flex: 1; min-width: 0; font-weight: 800; font-size: 15px; letter-spacing: .01em; }
.tour-country-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.tour-country-count { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.tour-country-badge { background: var(--taupe-deep); color: #fff; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .tour-country-badge { background: #e8ddd2; color: #2b2521; } }
.tour-country .date-grid { padding: 0 12px 12px; }
.tour-country:not([open]) .date-grid { display: none; }
.tour-main:not([open]) #tourAll { display: none; }
@media (prefers-reduced-motion: reduce) { .tour-main-chev, .tour-country-chev { transition: none; } }
.tour-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.tour-summary p { flex: 1; min-width: 200px; font-size: 13.5px; color: var(--muted); margin: 0; }
.tour-summary p strong { color: var(--ink); }
.f .v.ingreso { white-space: normal; line-height: 1.3; }
.f .v.ingreso span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.folio-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px;
}
.folio-row .flabel { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-weight: 600; letter-spacing: .22em; color: var(--muted); }
.folio-row code { font-family: "IBM Plex Mono", monospace; font-size: 16px; font-weight: 600; flex: 1; }

/* ---------- Preview stage ---------- */
.stage {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(14px, 2.6vw, 22px);
}
.stage-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px; font-weight: 600; letter-spacing: .26em;
  color: var(--muted); margin: 0 0 12px;
}

/* ---------- Carnet artwork ---------- */
.carnet {
  container-type: inline-size;
  width: 100%; min-width: 0;
  background: var(--card-bg); color: var(--card-ink);
  border: 1px solid #e2dbd4; border-radius: 3.4cqw;
  aspect-ratio: 8 / 5;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 42px rgba(50, 40, 34, .20);
  font-size: 16px;
}
.cc-top { display: flex; justify-content: space-between; align-items: center; padding: 3.4cqw 4.5cqw 2.4cqw; }
.cc-brand { display: flex; align-items: center; gap: 1.9cqw; min-width: 0; }
.cc-logo { flex: none; width: 6.75cqw; height: 6.75cqw; background: var(--taupe-deep); border-radius: 1.5cqw; display: grid; place-items: center; }
.cc-logo svg { width: 4.9cqw; height: 5.24cqw; display: block; }
.cc-brand strong { display: block; font-size: 3.6cqw; font-weight: 800; letter-spacing: .03em; line-height: 1; white-space: nowrap; }
.cc-brand span { display: block; font-family: "IBM Plex Mono", monospace; font-size: 1.55cqw; font-weight: 500; letter-spacing: .44em; color: var(--card-muted); margin-top: .9cqw; white-space: nowrap; }
.cc-doc { text-align: right; flex: none; }
.cc-doc b { display: block; font-family: "IBM Plex Mono", monospace; font-size: 1.8cqw; font-weight: 600; letter-spacing: .16em; }
.cc-doc span { display: block; font-family: "IBM Plex Mono", monospace; font-size: 1.8cqw; font-weight: 500; color: var(--card-muted); margin-top: .9cqw; }
.cc-rule { height: 1px; background: var(--card-line); margin: 0 4.5cqw; }
.cc-body { flex: 1; display: flex; gap: 3.4cqw; padding: 2.6cqw 4.5cqw 3cqw; min-height: 0; }
.cc-photo {
  position: relative; flex: 0 0 29.5%;
  background: var(--mauve); border-radius: 1.6cqw; overflow: hidden;
  touch-action: none; cursor: grab;
}
.cc-photo:active { cursor: grabbing; }
.photo-slot img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; }
.photo-ph {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1cqw;
  color: #fff; text-align: center; padding: 2cqw; pointer-events: none;
}
.photo-ph b { font-size: 2.6cqw; font-weight: 800; letter-spacing: .05em; }
.photo-ph span { font-family: "IBM Plex Mono", monospace; font-size: 1.45cqw; letter-spacing: .14em; opacity: .88; }
.cc-fields { flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: .4cqw 0; }
.f label {
  display: block; font-family: "IBM Plex Mono", monospace;
  font-size: 1.35cqw; font-weight: 500; letter-spacing: .3em;
  color: var(--card-muted); margin-bottom: .75cqw;
}
.f .v { font-weight: 600; font-size: 2.45cqw; line-height: 1.12; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f .v.name { font-weight: 800; font-size: 4.1cqw; text-transform: uppercase; letter-spacing: .01em; }
.f .v.mono { font-family: "IBM Plex Mono", monospace; font-weight: 500; font-size: 2cqw; }
.f-row { display: flex; gap: 3cqw; }
.f-row .f { flex: 1; min-width: 0; }
.f-row.bottom { align-items: end; }
.cc-barcode { position: relative; width: 28.5cqw; height: 6cqw; flex: none; overflow: hidden; }
.cc-barcode i { position: absolute; top: 0; bottom: 0; background: var(--card-ink); display: block; }
.cc-strip {
  background: var(--taupe); color: #fff;
  display: flex; justify-content: space-between; align-items: center; gap: 2cqw;
  padding: 2.1cqw 4.5cqw;
}
.cc-strip b { font-size: 2.05cqw; font-weight: 700; letter-spacing: .13em; white-space: nowrap; }
.cc-strip span { font-family: "IBM Plex Mono", monospace; font-size: 1.55cqw; font-weight: 500; letter-spacing: .3em; white-space: nowrap; }

/* ---------- Guardar ---------- */
.downloads { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.btn-primary {
  width: 100%; border-radius: 14px; font-size: 16px; font-weight: 700;
  padding: 14px 18px; min-height: 52px;
}
.btn-primary { background: var(--btn); color: var(--btn-ink); border: 1px solid var(--btn); }
.downloads .hint { text-align: center; margin: 0; }

footer {
  margin-top: 40px; text-align: center;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .24em;
  color: var(--muted);
}
.credit {
  margin-top: 14px; text-align: center;
  font-size: 13.5px; color: var(--muted); line-height: 1.5;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.credit strong { color: var(--ink); font-weight: 700; }
.credit-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.credit a {
  color: var(--taupe-deep); font-weight: 700; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; line-height: 1.2; white-space: nowrap;
}
.credit a:hover { color: var(--ink); border-color: var(--taupe); }
@media (prefers-color-scheme: dark) { .credit a { color: #e8ddd2; } }
.toast {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translate(-50%, 0);
  background: var(--taupe-deep); color: #fff;
  font-size: 13.5px; font-weight: 600; line-height: 1.35;
  padding: 8px 8px 8px 16px; border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
  z-index: 50;
  width: max-content; max-width: calc(100vw - 24px);
  display: none; align-items: center; gap: 8px; text-align: left;
}
.toast.show { display: flex; animation: toast-in .28s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) { .toast.show { animation: none; } }
.toast-close {
  flex: none;
  background: transparent; border: 0; color: inherit;
  font-size: 18px; line-height: 1; font-weight: 700;
  width: 32px; min-height: 32px; height: 32px;
  border-radius: 999px; padding: 0;
  display: grid; place-items: center;
}
.toast-close:hover { background: rgba(0, 0, 0, .12); }
@media (prefers-color-scheme: dark) { .toast { background: #e8ddd2; color: #2b2521; } }

/* ---------- Hoja para guardar (fallback universal) ---------- */
.save-modal {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  padding: 18px; background: rgba(20, 16, 13, .62);
}
.save-modal.open { display: flex; }
.save-card {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px; width: 100%; max-width: 460px;
  max-height: calc(100dvh - 36px); overflow: auto;
  text-align: center;
}
.save-card h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.save-card p { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.save-card p strong { color: var(--ink); }
.save-card img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 14px;
}
.save-actions { display: flex; flex-direction: column; gap: 9px; }
.save-actions .btn-primary { margin: 0; }
.save-actions .ghost { min-height: 46px; font-size: 14.5px; }

/* ---------- Utilidades (antes eran estilos en línea) ---------- */
.is-hidden { display: none !important; }
.hint-tight { margin: -4px 0 14px; }
.tour-main-right { display: flex; align-items: center; gap: 10px; }
.dz.busy { pointer-events: none; opacity: .7; }
.dz.busy .dz-title::after { content: ""; display: inline-block; width: .9em; height: .9em; margin-left: .5em; vertical-align: -.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: dz-spin .8s linear infinite; }
@keyframes dz-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dz.busy .dz-title::after { animation: none; } }
/* La foto del carnet no se muestra hasta que hay una (evita el ícono de imagen rota). */
.photo-slot img:not([src]) { display: none; }
