/* divídelo — componentes */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* La malla vive en una capa fija detrás de todo: es lo que el cristal
   desenfoca y refracta. Sin ella las tarjetas no tendrían nada que mostrar. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--mesh);
  background-attachment: fixed;
}

/* Monedas del tema claro, en su propia capa para poder apagarlas en oscuro.
   Van quietas a propósito: si se movieran, cada panel de cristal tendría que
   volver a desenfocar el fondo en cada fotograma, y eso se come la batería. */
.bg-coins {
  display: var(--coins-display);
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.bg-coins span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font: 800 var(--s) / 1 var(--font);
  transform: translate(-50%, -50%) rotate(var(--r));
  color: transparent;
  background: var(--coin-face);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1.5px var(--coin-edge);
  filter: var(--coin-shadow);
  opacity: var(--o, 0.8);
}

/* Repartidas por los bordes, lejos del centro donde vive el contenido. Las
   grandes quedan medio fuera de la pantalla, como las burbujas del diseño. */
.bg-coins span:nth-child(1) { --x: 88%; --y: 10%; --s: 124px; --r: 14deg; }
.bg-coins span:nth-child(2) { --x: 9%;  --y: 29%; --s: 66px;  --r: -12deg; --o: 0.7; }
.bg-coins span:nth-child(3) { --x: 93%; --y: 46%; --s: 52px;  --r: 10deg;  --o: 0.65; }
.bg-coins span:nth-child(4) { --x: 12%; --y: 64%; --s: 88px;  --r: -8deg; }
.bg-coins span:nth-child(5) { --x: 80%; --y: 86%; --s: 136px; --r: -10deg; }
.bg-coins span:nth-child(6) { --x: 30%; --y: 94%; --s: 46px;  --r: 16deg;  --o: 0.6; }
.bg-coins span:nth-child(7) { --x: 38%; --y: 5%;  --s: 40px;  --r: -18deg; --o: 0.55; }
.bg-coins span:nth-child(8) { --x: 62%; --y: 60%; --s: 34px;  --r: 8deg;   --o: 0.5; }

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

h1,
h2,
h3,
p {
  margin: 0;
}

/* ---------- Estructura ---------- */

#app {
  min-height: 100%;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 20px) var(--gap) 0;
  max-width: 560px;
  margin: 0 auto;
}

.screen--center {
  justify-content: center;
  align-items: stretch;
  text-align: center;
}

/* Deja hueco para la barra inferior flotante */
.screen--docked {
  padding-bottom: calc(var(--safe-bottom) + 116px);
}

.grow {
  flex: 1 1 auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

/* ---------- Cristal ---------- */

.glass,
.dish,
.dock-inner,
.btn-ghost,
.bubble,
.dropzone {
  position: relative;
  isolation: isolate;
  border: 0;
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  box-shadow: var(--glass-shadow);
}

/*
 * El filo especular. Un borde de 1 px plano se lee como "rectángulo
 * semitransparente"; lo que hace que parezca cristal es que el borde brille
 * fuerte arriba y se apague en los laterales, como una pieza curva recogiendo
 * la luz. Se dibuja con un degradado recortado en forma de marco.
 */
.glass::before,
.dish::before,
.dock-inner::before,
.btn-ghost::before,
.bubble::before,
.dropzone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: var(--rim);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

.glass {
  border-radius: var(--r-lg);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass,
  .dish,
  .dock-inner,
  .btn-ghost,
  .bubble,
  .dropzone {
    background-color: var(--glass-bg-solid);
  }
}

.panel {
  padding: var(--gap-lg) var(--gap);
}

/* ---------- Tipografía ---------- */

.title {
  font-size: clamp(27px, 7.4vw, 33px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.title-lg {
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.subtitle {
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 600;
}

.hint {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.caption {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 700;
}

.label {
  display: block;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.amount-xl {
  font-size: clamp(42px, 13vw, 58px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1;
}

.accent-text {
  color: var(--accent-solid);
}

.center {
  text-align: center;
}

/* ---------- Botones ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 60px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* El único elemento luminoso de la pantalla */
.btn-primary {
  background: var(--accent-grad);
  color: var(--on-accent);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.55),
    inset 0 -8px 16px rgba(0, 0, 0, 0.08),
    0 10px 28px var(--accent-1),
    0 4px 12px rgba(0, 0, 0, 0.18);
}

.btn-ghost {
  border-radius: var(--r-pill);
  color: var(--text);
}

.btn-sm {
  min-height: 46px;
  font-size: 15px;
  width: auto;
  padding: 0 18px;
}

.btn-row {
  display: flex;
  gap: var(--gap-sm);
}

.btn-row .btn {
  width: auto;
  flex: 1 1 0;
}

.btn-text {
  background: none;
  border: 0;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: var(--glass-muted-bg);
}

/* ---------- Cabecera ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  margin: 0 -8px var(--gap-sm);
}

.topbar .title {
  font-size: clamp(24px, 6.4vw, 30px);
}

/* ---------- Campos ---------- */
/* Los <input> no admiten pseudoelementos, así que aquí el filo es un borde
   real en vez del degradado recortado. */

.field {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--glass-border);
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.5),
    var(--glass-shadow);
}

.field::placeholder {
  color: var(--text-faint);
  font-weight: 600;
}

.field:focus-visible,
.dish:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.code-box:focus-visible {
  outline: 3px solid var(--accent-solid);
  outline-offset: 2px;
}

/*
 * Al cambiar de pantalla se lleva el foco al título para que el lector de
 * pantalla anuncie dónde estás. Ese foco es programático, no lo ha pedido
 * nadie con el teclado, así que no debe pintar un recuadro alrededor.
 */
[tabindex="-1"]:focus {
  outline: none;
}

/* ---------- Código de sala ---------- */

.code-boxes {
  display: flex;
  gap: var(--gap-sm);
  justify-content: center;
}

.code-box {
  flex: 1 1 0;
  /* Un <input> en flex no encoge por debajo de su ancho mínimo: sin esto las
     cinco casillas se salían por los lados en un iPhone de 390 px. */
  min-width: 0;
  max-width: 72px;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-md);
  border: 1.5px solid var(--glass-border);
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  text-align: center;
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.5),
    var(--glass-shadow);
  padding: 0;
}

.code-display {
  font-size: clamp(46px, 15vw, 64px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: var(--accent-solid);
  line-height: 1.1;
  text-shadow: 0 2px 18px var(--glass-sel-glow);
}

.qr-card {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 16px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  width: fit-content;
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.7),
    0 18px 40px rgba(0, 0, 0, 0.3);
}

.qr-card svg,
.qr-card canvas,
.qr-card img {
  display: block;
  width: min(56vw, 220px);
  height: auto;
  image-rendering: pixelated;
}

/* ---------- Burbuja de icono ---------- */

.bubble {
  width: 112px;
  height: 112px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-solid);
}

.bubble svg {
  width: 52px;
  height: 52px;
}

/* ---------- Avatares ---------- */

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 17px;
  color: #06302a;
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    inset 0 -6px 10px rgba(0, 0, 0, 0.12),
    0 3px 10px rgba(6, 48, 42, 0.28);
}

/* El brillo que convierte el círculo plano en una burbuja con volumen */
.avatar::after {
  content: "";
  position: absolute;
  top: 8%;
  left: 14%;
  width: 72%;
  height: 46%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
  font-size: 13px;
  border-width: 2px;
}

.avatar-stack {
  display: flex;
}

.avatar-stack .avatar + .avatar {
  margin-left: -11px;
}

.avatar-stack--sm .avatar + .avatar {
  margin-left: -8px;
}

/* ---------- Lista de platos ---------- */

.dish {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  width: 100%;
  padding: 18px;
  text-align: left;
  border-radius: var(--r-lg);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background-color 0.2s ease,
    box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.dish:active {
  transform: scale(0.985);
}

.dish.is-selected {
  background-color: var(--glass-sel-bg);
  box-shadow: var(--glass-sel-glow), var(--glass-sel-shadow);
}

.dish.is-selected::before {
  background: var(--rim-sel);
}

/* El estado no reclamado se apaga: es el que hay que ver de un vistazo */
.dish.is-idle {
  background-color: var(--glass-muted-bg);
  background-image: none;
  box-shadow: none;
}

.dish.is-idle::before {
  background: var(--rim-muted);
}

.dish.is-idle .dish-name,
.dish.is-idle .amount {
  color: var(--text-muted);
}

.dish-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.dish-head {
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
}

.dish-name {
  flex: 1 1 auto;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.dish-head .amount {
  font-size: 20px;
}

.dish-meta {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  flex-wrap: wrap;
}

.check {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--text-faint);
  margin-top: 1px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.check svg {
  width: 21px;
  height: 21px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.is-selected .check {
  border-color: transparent;
  background: var(--check-bg);
  color: var(--check-fg);
  box-shadow:
    inset 0 -4px 8px rgba(0, 0, 0, 0.12),
    0 3px 10px rgba(0, 0, 0, 0.22);
}

.is-selected .check svg {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Chips y etiquetas ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: var(--r-pill);
  background: var(--glass-muted-bg);
  border: 1.5px solid var(--glass-border);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

.chip--accent {
  color: var(--accent-solid);
  border-color: var(--accent-solid);
}

/* Dentro de una columna flex, un chip se estiraría a todo el ancho y dejaría
   de parecer una etiqueta. Se queda pegado a la izquierda, a su tamaño. */
.stack > .chip,
.stack-sm > .chip {
  align-self: flex-start;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-solid);
  box-shadow: 0 0 8px var(--accent-solid);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Filas de lista ---------- */

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 15px 0;
  min-height: 62px;
}

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

.row-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* Fila editable de la revisión del ticket: nombre arriba, controles debajo */
.row--edit {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.row-edit-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-title {
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.row-sub {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  margin-top: 3px;
}

.row .amount {
  font-size: 19px;
}

.row.is-pending {
  opacity: 0.75;
  box-shadow: inset 3px 0 0 var(--warning);
  padding-left: 12px;
}

/* ---------- Stepper ---------- */

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--glass-border);
  background: var(--glass-muted-bg);
  padding: 2px;
}

.stepper button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-solid);
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.stepper button:active {
  background: var(--glass-bg);
}

.stepper output {
  min-width: 26px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- Control segmentado ---------- */

.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-pill);
  background: var(--glass-muted-bg);
  border: 1.5px solid var(--glass-border);
}

.segmented button {
  flex: 1 1 0;
  min-height: 48px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-grad);
  color: var(--on-accent);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.5),
    0 6px 18px rgba(0, 0, 0, 0.2);
}

/* ---------- Banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 15px 17px;
  border-radius: var(--r-md);
  background: var(--warning-bg);
  border: 1.5px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 15px;
  font-weight: 800;
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
}

.banner svg {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.banner--danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Zona de subida ---------- */

.dropzone {
  border-radius: var(--r-lg);
  padding: var(--gap-lg) var(--gap);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
}

.dropzone::before {
  /* Trazo discontinuo: aquí falta algo por hacer */
  background: none;
  border: 2px dashed var(--accent-solid);
  opacity: 0.55;
  padding: 0;
  -webkit-mask: none;
  mask: none;
}

.dropzone .preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--r-md);
}

/* ---------- Barra inferior flotante ---------- */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 20;
  padding: 0 var(--gap);
  pointer-events: none;
}

.dock-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 12px 12px 12px 22px;
  border-radius: var(--r-xl);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(var(--blur-strong)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur-strong)) saturate(var(--saturate));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.dock-info {
  flex: 1 1 auto;
  min-width: 0;
}

.dock-info .caption {
  display: block;
}

.dock-info .amount {
  font-size: 30px;
  display: block;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.dock .btn {
  width: auto;
  flex: 0 0 auto;
  min-width: 124px;
}

/* ---------- Logo ---------- */

.wordmark {
  font-size: clamp(46px, 14.5vw, 64px);
  font-weight: 800;
  letter-spacing: -0.04em;
  /* Con line-height 1 la tilde de la í se sale de la caja y se come la línea
     de abajo. 1.12 le deja sitio sin abrir un hueco. */
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 4px;
}

/* Icono 3D de cristal de la marca, en la portada. */
.brand-mark {
  width: 136px;
  height: 136px;
  margin: 0 auto;
  display: block;
  border-radius: 34px;
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.35),
    0 18px 44px rgba(6, 48, 42, 0.32);
}

/* ---------- Carga ---------- */

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.loading-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  padding: var(--gap-xl) var(--gap);
  text-align: center;
}

.loading-block .spinner {
  width: 36px;
  height: 36px;
  color: var(--accent-solid);
  border-color: var(--glass-muted-bg);
  border-top-color: var(--accent-solid);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 118px);
  transform: translate(-50%, 10px);
  z-index: 60;
  padding: 13px 22px;
  border-radius: var(--r-pill);
  background: var(--glass-bg-solid);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-weight: 800;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Utilidades ---------- */

.hidden {
  display: none !important;
}

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

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

/* ---------- Recorte del ticket ---------- */

.cropper {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

/*
 * Hueco alrededor de la imagen para que los tiradores de las esquinas se
 * puedan agarrar aunque el recuadro esté pegado al borde — que es justo el
 * caso por defecto, con el recorte cubriendo la foto entera.
 */
.cropper-stage {
  position: relative;
  /* Los tiradores sobresalen 17 px por fuera del recuadro, y por defecto el
     recuadro cubre la imagen entera. Sin este margen se montarían encima del
     texto de arriba y de los botones de abajo. */
  margin: 22px 6px;
  width: calc(100% - 12px);
  line-height: 0;
  touch-action: none;
}

/* Ancho y alto automáticos con los dos topes: la caja de la imagen mide lo
   mismo que la foto pintada, sin franjas vacías a los lados, y el redondeo
   cae en las esquinas de la foto. crop.js calcula el recuadro sobre esto. */
.cropper-img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 46vh;
  margin-inline: auto;
  border-radius: var(--r-md);
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.cropper-box {
  position: absolute;
  border: 2px solid #fff;
  border-radius: 4px;
  cursor: move;
  /* Oscurece todo lo que queda fuera del recuadro de un solo trazo */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  touch-action: none;
}

/* Guías tenues: ayudan a encuadrar sin tapar el ticket */
.cropper-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
  background-position: 33.33% 33.33%;
  background-repeat: repeat;
  pointer-events: none;
}

.cropper-handle {
  position: absolute;
  width: 34px;
  height: 34px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.cropper-handle[data-handle="nw"] {
  top: -17px;
  left: -17px;
  cursor: nwse-resize;
}
.cropper-handle[data-handle="ne"] {
  top: -17px;
  right: -17px;
  cursor: nesw-resize;
}
.cropper-handle[data-handle="sw"] {
  bottom: -17px;
  left: -17px;
  cursor: nesw-resize;
}
.cropper-handle[data-handle="se"] {
  bottom: -17px;
  right: -17px;
  cursor: nwse-resize;
}

.cropper .btn-row {
  width: 100%;
}

/* ---------- Barra de progreso ---------- */

.progress {
  width: 100%;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--glass-muted-bg);
  overflow: hidden;
  margin-top: -6px;
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-grad);
  /* La transición suaviza los saltos del temporizador: sin ella la barra
     avanza a tirones cada 120 ms en vez de deslizarse. */
  transition: width 0.25s linear;
}

/* ---------- Cómo se usa ---------- */

/* Capturas e iconos van por tema. Solo se ve la del tema activo y, como
   llevan carga diferida, solo se descarga esa. */
:root[data-theme="dark"] .only-light,
:root:not([data-theme="dark"]) .only-dark {
  display: none;
}

/* Enlace discreto de la portada, debajo de los dos botones grandes */
.howto-link {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.howto-link svg {
  color: var(--accent-solid);
}

.howto-link:active {
  background: var(--glass-muted-bg);
}

.howto-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--gap-sm);
}

.howto-lead {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.howto-index {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.howto-index-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--r-md);
  background: var(--glass-muted-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.howto-index-num,
.howto-num {
  display: grid;
  place-items: center;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.45),
    0 5px 12px rgba(6, 48, 42, 0.16);
}

.howto-index-num {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 14px;
}

/* Cada parte arranca con su icono de cristal, como una portadilla */
.howto-act {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: var(--gap-lg);
  scroll-margin-top: 16px;
}

.howto-act-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 4px;
}

.howto-kicker {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.howto-act-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.howto-tile {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1.5px var(--glass-border),
    var(--glass-shadow);
}

.howto-tile img {
  display: block;
  width: 100%;
  height: 100%;
}

.howto-tile--sm {
  flex-basis: 48px;
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

/* El paso: texto arriba y el móvil asomando por el borde de abajo */
.howto-step {
  border-radius: var(--r-xl);
  padding: 20px 20px 0;
  overflow: hidden;
}

.howto-step-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.howto-num {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  font-size: 22px;
}

.howto-who {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.howto-step-title {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.howto-step-text {
  margin-top: 10px;
}

.howto-phone {
  position: relative;
  width: min(80%, 280px);
  /* La captura entera: cada una ya va recortada a lo que importa */
  aspect-ratio: 600 / 862;
  margin: 18px auto 0;
  border: 7px solid var(--bezel);
  border-bottom: 0;
  border-radius: 36px 36px 0 0;
  background: var(--bezel);
  overflow: hidden;
  box-shadow:
    0 0 0 1.5px var(--bezel-rim),
    0 -6px 26px rgba(6, 48, 42, 0.16);
}

.howto-phone img {
  display: block;
  width: 100%;
  height: auto;
}

/* La isla del móvil hace de pie de foto: "Lo que ve Javi" */
.howto-phone-pie {
  position: absolute;
  top: 7px;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--bezel);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

/* Último paso: lo que ve quien pagó y lo que ve una invitada, a la vez */
.howto-duo {
  position: relative;
  height: clamp(230px, 64vw, 310px);
  margin-top: 18px;
}

.howto-duo .howto-phone {
  position: absolute;
  bottom: -14px;
  width: 58%;
  margin: 0;
}

.howto-duo .is-back {
  left: 1%;
  transform: rotate(-4deg);
  transform-origin: bottom left;
}

.howto-duo .is-front {
  right: 1%;
  z-index: 1;
  transform: rotate(4deg);
  transform-origin: bottom right;
}

.howto-tip {
  align-items: flex-start;
}

.howto-tip .row-title {
  font-size: 17px;
}

.howto-tip .hint {
  margin-top: 3px;
}

.howto-cta {
  margin-top: var(--gap-lg);
}
