/* Componentes reutilizables. Los bloques de cada pantalla se van añadiendo abajo. */

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 14px;
  font-weight: 700;
  transition: var(--accent-transition), opacity 150ms ease, transform 100ms ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-outline {
  border: 1px solid var(--outline);
  color: var(--accent);
}

.btn-text {
  color: var(--accent);
  padding: 0 12px;
  min-height: 40px;
  font-weight: 600;
}

.btn-text.muted {
  color: var(--text-secondary);
}

.btn-danger {
  color: var(--danger);
}

.btn-tall {
  min-height: 54px;
  width: 100%;
}

/* ---------- Campos ---------- */

.field {
  position: relative;
  display: block;
  width: 100%;
}

.field input,
.field textarea {
  width: 100%;
  padding: 22px 14px 8px;
  background: transparent;
  border: 1px solid var(--outline);
  border-radius: var(--radius-field);
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms ease;
}

.field textarea {
  resize: none;
  padding-top: 14px;
  padding-bottom: 14px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field.error input,
.field.error textarea {
  border-color: var(--danger);
}

/*
 * Etiqueta flotante: sube al enfocar o cuando ya hay texto. El selector :placeholder-shown
 * es lo que permite saber "esta vacio" sin JavaScript, y por eso los campos llevan un
 * placeholder de un espacio.
 */
.field-label {
  position: absolute;
  top: 16px;
  left: 15px;
  color: var(--text-secondary);
  font-size: 16px;
  pointer-events: none;
  transition: transform 140ms ease, font-size 140ms ease, color 140ms ease;
  transform-origin: left top;
}

.field input:focus + .field-label,
.field input:not(:placeholder-shown) + .field-label,
.field textarea:focus + .field-label,
.field textarea:not(:placeholder-shown) + .field-label {
  transform: translateY(-9px);
  font-size: 11px;
  letter-spacing: 0.5px;
}

.field input:focus + .field-label,
.field textarea:focus + .field-label {
  color: var(--accent);
}

.field-trailing {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

.field-trailing .icon-btn {
  color: var(--text-secondary);
}

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--danger);
}

/* ---------- Tarjetas y chips ---------- */

.card {
  background: var(--surface-1);
  border-radius: var(--radius-card);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.chip[aria-pressed='true'] {
  border-color: transparent;
}

.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- Spinner ---------- */

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgb(255 255 255 / 14%);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.spinner.small {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

.spinner.on-accent {
  border-color: rgb(0 0 0 / 20%);
  border-top-color: var(--on-accent);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Barra de progreso ---------- */

.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: progress-slide 1200ms ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* ---------- Toasts ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 13px 16px;
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 45%);
  animation: toast-in 200ms ease;
}

.toast.toast-error {
  border-color: var(--danger);
  color: var(--danger);
}

.toast.leaving {
  animation: toast-out 200ms ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------- Diálogos ---------- */

dialog.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  border: none;
  border-radius: 24px;
  background: var(--surface-1);
  color: var(--text-primary);

  /*
   * `margin: auto` NO es decorativo: es lo unico que centra un <dialog> modal.
   *
   * El navegador lo coloca con `position: fixed; inset: 0` y deja que el margen automatico
   * lo centre en los dos ejes. El reset universal de base.css (`* { margin: 0 }`) pisaba ese
   * margen y el dialogo se iba a la esquina superior izquierda.
   */
  margin: auto;
}

dialog.dialog::backdrop {
  background: rgb(0 0 0 / 62%);
}

.dialog-title {
  margin-bottom: 10px;
}

.dialog-body {
  color: var(--text-secondary);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 20px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Recortador ---------- */

.cropper {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.cropper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 4px;
}

.cropper-title {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cropper-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  /* touch-action none: sin esto el navegador se queda el gesto para desplazar la pagina y
     el arrastre del marco no llega nunca. */
  touch-action: none;
  overflow: hidden;
}

.cropper-stage canvas {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.cropper-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px;
}

.cropper-hint {
  padding: 0 24px 16px;
}

/* ---------- Login ---------- */

.login {
  flex: 1;
  /* La pantalla ya no crece con el contenido, asi que el login se desplaza por dentro
     cuando el teclado del movil se come media pantalla. */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 40px 32px calc(40px + env(safe-area-inset-bottom));
  /* Degradado vertical con un velo del verde Monster en medio, como en el Android. */
  background:
    linear-gradient(180deg, var(--ink) 0%, rgb(140 255 0 / 6%) 50%, var(--ink) 100%);
}

.login-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 162px;
  height: 162px;
}

/* El halo late despacio: da sensacion de app viva sin robar atencion al formulario. */
.login-halo {
  position: absolute;
  width: 162px;
  height: 162px;
  border-radius: 50%;
  background: rgb(140 255 0 / 12%);
  animation: halo 2800ms ease-in-out infinite;
}

@keyframes halo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Recortada en circulo: el icono es un cuadrado de cantos redondeados y sin esto se veria
   un cuadrado flotando dentro del halo redondo. */
.login-mark {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
}

.login h1 {
  margin-top: 24px;
}

.login-sub {
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  margin-top: 40px;
}

.login-form .btn-tall {
  margin-top: 8px;
}

.login-note {
  margin-top: 16px;
}

/* ---------- Imágenes en Base64 ---------- */

.b64 {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.b64-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Hueco cuando el producto no tiene foto. Con foto NO hay fondo: la imagen ya viene
   recortada y un fondo propio solo devolvería el parche que se acaba de quitar. */
.b64-empty {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-secondary);
}

/* ---------- Avatar ---------- */

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
  line-height: 1;
}

button.avatar {
  cursor: pointer;
  padding: 0;
}

.avatar-hi {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.avatar-img {
  position: absolute;
  inset: 0;
}

/* ---------- Nota ---------- */

.score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Pestañas ---------- */

.tabs {
  position: relative;
  display: flex;
  flex: none;
  border-bottom: 1px solid var(--outline);
}

.tab {
  flex: 1;
  padding: 12px 4px 14px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  transition: color 250ms ease;
}

.tab-active {
  font-weight: 900;
}

.tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: calc(100% / 3);
  height: 2px;
  background: var(--accent);
  transition: transform 260ms cubic-bezier(0.2, 0, 0, 1), background-color 400ms ease;
}

/* ---------- Carrusel de categorías ---------- */

.pager {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  /* Sin esto Chrome enseña la barra horizontal sobre el contenido en escritorio. */
  scrollbar-width: none;
}

.pager::-webkit-scrollbar {
  display: none;
}

.pager-panel {
  flex: 0 0 100%;
  scroll-snap-align: start;
  overflow-y: auto;
  /* El hueco de abajo lo escribe el ranking segun cuantos botones flotantes haya. */
  padding: 4px 16px var(--fab-room, 28px);
  display: flex;
  flex-direction: column;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 32px;
}

.add-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

/* ---------- Podio ---------- */

.podium {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px 12px;
}

.podium-slot {
  position: relative;
  flex-basis: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  /* Hueco para el pedestal mas alto, que va posicionado abajo del todo. */
  padding-bottom: calc(68px * var(--podium-scale, 1));
}

/*
 * Percha: todas las latas apoyadas en la misma linea, sea cual sea su tamaño.
 *
 * La altura la fija la mayor (la del primer puesto). Sin esto cada columna medía lo que su
 * propia lata y los nombres quedaban a tres alturas distintas.
 */
.podium-perch {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: calc(104px * var(--podium-scale, 1));
}

.podium-image {
  padding: 0;
  border-radius: 50%;
  border: 3px solid;
  overflow: hidden;
  flex: none;
}

.podium-name {
  margin-top: 8px;
  text-align: center;
  /* Dos líneas como máximo: un nombre largo no puede empujar el pedestal fuera de sitio. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0 2px;
}

.podium-pedestal {
  position: absolute;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 100%;
  border-radius: 10px 10px 0 0;
  font-weight: 900;
}

/* ---------- Tarjeta de producto ---------- */

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  padding: 12px;
  text-align: left;
  transition: background-color 150ms ease;
}

.product-card:hover {
  background: var(--surface-2);
}

.product-position {
  width: 28px;
  flex: none;
}

.product-thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 14px;
  overflow: hidden;
}

.product-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 14px;
}

.product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-mine {
  font-weight: 600;
}

/* ---------- Botones flotantes ---------- */

.fabs {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 18px;
  background: var(--surface-1);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 6px 22px rgb(0 0 0 / 45%);
  transition: var(--accent-transition), transform 100ms ease;
}

.fab:active {
  transform: scale(0.97);
}

.fab-icon {
  display: grid;
  place-items: center;
}

/* ---------- Hojas inferiores ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 0%);
  transition: background-color 260ms ease;
}

.sheet-backdrop.sheet-open {
  background: rgb(0 0 0 / 62%);
}

.sheet-panel {
  width: min(560px, 100%);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--ink);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.2, 0, 0, 1);
  touch-action: none;
}

.sheet-open .sheet-panel {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 4px auto 12px;
  border-radius: 2px;
  background: var(--outline);
  flex: none;
}

.sheet-title {
  flex: none;
}

.sheet-subtitle {
  margin: 2px 0 12px;
  flex: none;
}

.sheet-content {
  overflow-y: auto;
  /* El contenido sí puede desplazarse aunque el panel intercepte el gesto de arrastre. */
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  text-align: left;
  border-radius: 16px;
}

.sheet-row-thumb {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
}

.sheet-row-name {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sheet-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px;
}

.sheet-empty-icon {
  color: var(--accent);
}

/* ---------- Perfil ---------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}

.profile-action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  text-align: left;
  border-radius: 18px;
}

.profile-action-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
}

/* ---------- Diálogos: extras ---------- */

.dialog-input {
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--outline);
  border-radius: var(--radius-field);
  outline: none;
}

.dialog-input:focus {
  border-color: var(--accent);
}

.dialog-expected {
  margin: 8px 0 12px;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Ficha del producto ---------- */

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px;
}

.detail-header {
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

.detail-hero {
  position: relative;
  flex: none;
  width: calc(100% + 40px);
  margin: 0 -20px;
  aspect-ratio: 1;
}

/*
 * La imagen va posicionada en absoluto y NO en el flujo.
 *
 * Si contara para la altura, el canvas aportaria su tamaño natural —hasta 1024 px— y el
 * aspect-ratio del padre se quedaria sin efecto, porque solo manda cuando la altura es
 * automatica y el contenido no la impone. La foto se comia la pantalla entera.
 */
.detail-hero > .b64 {
  position: absolute;
  inset: 0;
}

/* Degradado inferior: el texto de debajo no compite con la foto. */
.detail-fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 60%, var(--ink) 100%);
}

.detail-avg {
  display: flex;
  justify-content: center;
}

.detail-card {
  margin-top: 12px;
  padding: 16px;
}

.detail-card:first-of-type {
  margin-top: 20px;
}

.detail-cannot-rate {
  padding: 4px;
}

.detail-rating-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-my-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.detail-slider-ends {
  display: flex;
  justify-content: space-between;
}

.detail-remove-hint {
  margin-top: 6px;
}

.detail-empty-line {
  margin-top: 10px;
}

/* ---------- Slider ---------- */

.slider {
  width: 100%;
  margin: 10px 0 2px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ---------- Desglose de puntuaciones ---------- */

.rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.rating-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating-value {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ---------- Chat ---------- */

.detail-comments {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
}

.detail-comments-title {
  padding: 28px 8px 8px;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 3px 0;
}

.bubble-mine {
  justify-content: flex-end;
}

.bubble {
  display: flex;
  flex-direction: column;
  max-width: min(300px, 78%);
}

.bubble-mine .bubble {
  align-items: flex-end;
}

.bubble-author {
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 12px 2px;
}

.bubble-mine .bubble-author {
  color: var(--accent);
}

.bubble-text {
  padding: 9px 14px;
  border-radius: 16px 16px 16px 4px;
  background: var(--surface-2);
  /* Un comentario largo sin espacios no puede ensanchar la burbuja fuera de la pantalla. */
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bubble-mine .bubble-text {
  border-radius: 16px 16px 4px 16px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.bubble-actionable {
  cursor: pointer;
  /* Sin esto, la pulsacion larga en movil selecciona el texto en vez de abrir el menu. */
  user-select: none;
  -webkit-user-select: none;
}

.bubble-time {
  padding: 2px 6px 0;
}

/* ---------- Caja de escribir ---------- */

.composer {
  flex: none;
  background: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
}

.composer-input {
  flex: 1;
  min-height: 48px;
  max-height: 96px;
  padding: 13px 16px;
  background: transparent;
  border: 1px solid var(--outline);
  border-radius: 24px;
  color: var(--text-primary);
  resize: none;
  outline: none;
}

.composer-input:focus {
  border-color: var(--accent);
}

.composer-send {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  transition: var(--accent-transition);
}

.composer-send:disabled {
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: default;
}

.composer-limit {
  padding: 16px;
}

/* ---------- Editor de producto ---------- */

.editor-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 20px calc(28px + env(safe-area-inset-bottom));
}

.editor-image-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: 24px;
  overflow: hidden;
  display: grid;
  place-items: center;
  /* Relleno gris SOLO mientras no hay foto: con la lata dentro, el gris sería el mismo
     recuadro de fondo que el recorte acaba de quitar. */
  background: var(--surface-2);
}

.editor-image.has-image {
  background: transparent;
  border-style: solid;
}

/* Igual que en la ficha: la imagen no puede aportar su altura natural o revienta el cuadrado. */
.editor-image > .b64 {
  position: absolute;
  inset: 0;
}

.editor-image-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.editor-image-buttons {
  display: flex;
  gap: 10px;
}

.editor-image-buttons .btn {
  flex: 1;
}

.editor-section {
  margin-bottom: -12px;
}

.editor-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-processing {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -12px;
}

.editor-cancel {
  margin-top: -12px;
}

/* ---------- Panel de administración ---------- */

.admin-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
}

.admin-initial {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
}

.admin-names {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 56px;
  min-height: 56px;
  padding: 0;
  background: var(--accent);
  color: var(--on-accent);
}

.admin-note {
  margin-top: 16px;
}

/* ---------- Ruleta ---------- */

.roulette {
  align-items: stretch;
}

.roulette-untried {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.roulette-untried input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: none;
}

.roulette-untried-text {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.roulette-section {
  margin-top: 10px;
}

.roulette-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.roulette-chips::-webkit-scrollbar {
  display: none;
}

.roulette-count {
  margin-top: 6px;
}

.roulette-none {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.roulette-spin {
  margin-top: 8px;
}

/* ---------- Carrete ---------- */

.reel-frame {
  position: relative;
  border: 2px solid var(--accent);
  border-radius: 28px;
  background: var(--reel-black);
  padding: 14px 22px;
  overflow: hidden;
}

.reel-window {
  position: relative;
  height: 132px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface-1);
}

.reel-track {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.reel-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 132px;
  flex: none;
  padding: 0 16px;
}

.reel-thumb {
  width: 96px;
  height: 96px;
  flex: none;
  display: grid;
  place-items: center;
}

.reel-thumb canvas {
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
}

.reel-name {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Degradados arriba y abajo: recortan el carrete sin una línea dura y refuerzan la ilusión
   de que sigue girando más allá de la ventana. */
.reel-fade {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 14px;
  height: 132px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    var(--reel-black) 0%,
    transparent 28%,
    transparent 72%,
    var(--reel-black) 100%
  );
}

.reel-line {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 50%;
  height: 2px;
  pointer-events: none;
}

.reel-lights {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.roulette-status {
  margin-top: 16px;
  text-align: center;
  font-weight: 900;
}

/* ---------- Ganador ---------- */

.winner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.winner-jackpot {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--neon-gold);
  /* Resplandor propio detrás del texto, como en el Android. */
  text-shadow: 0 0 24px rgb(255 210 74 / 55%), 0 0 48px rgb(255 210 74 / 30%);
  animation: jackpot 1040ms ease-in-out infinite alternate;
}

@keyframes jackpot {
  from { transform: scale(0.94); }
  to { transform: scale(1.08); }
}

.winner-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 230px;
  height: 230px;
  margin: 8px 0 4px;
}

/*
 * Los canvas de efectos llevan SIEMPRE su tamaño en CSS, no solo `inset: 0`.
 *
 * Sin `width`/`height` explicitos, el tamaño en pantalla lo decide el tamaño intrinseco del
 * canvas, y fitCanvas escribe ese tamaño a partir del de pantalla: cada fotograma se
 * multiplicaba por la densidad de pixeles y el canvas se duplicaba hasta los 33 millones de
 * pixeles, momento en el que el navegador se rinde y pinta un recuadro blanco.
 *
 * Aqui se nota porque `.winner-stage` es una rejilla con `place-items: center`, y eso hace
 * que un absoluto con `inset: 0` se ajuste al contenido en vez de estirarse.
 */
.winner-lights {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.winner-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 60px;
  animation: glow 2400ms ease-in-out infinite alternate;
}

@keyframes glow {
  from { transform: scale(1); }
  to { transform: scale(1.16); }
}

.winner-can {
  position: relative;
  width: 160px;
  height: 160px;
  display: grid;
  place-items: center;
}

.winner-can canvas {
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
}

.winner-name {
  font-weight: 900;
  margin-top: 4px;
}

.winner-mine {
  font-weight: 700;
  margin-top: 2px;
}

.winner-open {
  margin-top: 16px;
}

.winner-again {
  margin-top: 8px;
}

/* El confeti va encima de todo y no intercepta toques. */
.winner-confetti {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 560px;
  pointer-events: none;
}

/* ---------- Piezas comunes de la barra superior ---------- */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* El logo solo se ve en escritorio: en móvil la barra ya va justa de sitio. */
.topbar-logo {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  flex: none;
}

.topbar-brand > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   ESCRITORIO
   ==========================================================================

   Un único punto de corte. Por debajo de 900 px no se aplica NADA de esto y el
   diseño de móvil se queda tal cual estaba.

   El truco que se repite es `padding-inline: max(--shell-pad, (100% - --shell-max)/2)`:
   deja la barra o el fondo ocupando todo el ancho, pero centra su contenido en
   1200 px, sin necesidad de meter un div contenedor en cada pantalla.
   ========================================================================== */

@media (min-width: 900px) {
  :root {
    --shell-max: 1200px;
    --shell-pad: 24px;
    --shell-inline: max(var(--shell-pad), calc((100% - var(--shell-max)) / 2));
  }

  .topbar {
    padding: 14px var(--shell-inline);
  }

  .topbar-logo {
    display: block;
  }

  /* ---------- Ranking: barra de tres columnas ---------- */

  /*
   * `display: contents` hace que el título y las acciones dejen de estar envueltos por la
   * cabecera y pasen a ser elementos de esta misma rejilla, para poder colocar las pestañas
   * justo entre ellos. `order` los recoloca, porque en el DOM las pestañas van las últimas.
   */
  .app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 12px var(--shell-inline);
    background: var(--ink);
    border-bottom: 1px solid var(--outline);
  }

  .app-bar > .topbar {
    display: contents;
  }

  .app-bar .topbar-title { order: 1; justify-self: start; }
  .app-bar .tabs { order: 2; justify-self: center; }
  .app-bar .topbar-actions { order: 3; justify-self: end; }

  /* Las pestañas dejan de ocupar el ancho y pasan a ser un control segmentado. */
  .app-bar .tabs {
    border-bottom: none;
    background: var(--surface-1);
    border-radius: 14px;
    padding: 4px;
    gap: 4px;
  }

  .app-bar .tab {
    flex: none;
    padding: 8px 22px;
    border-radius: 10px;
    transition: background-color 200ms ease, color 250ms ease;
  }

  .app-bar .tab:hover {
    background: var(--surface-2);
  }

  .app-bar .tab-active {
    background: var(--surface-2);
  }

  /* La barrita deslizante era para las pestañas a lo ancho; aquí sobra. */
  .app-bar .tab-indicator {
    display: none;
  }

  /* ---------- Ranking: contenido ---------- */

  .pager-panel {
    padding: 24px var(--shell-inline) 48px;
  }

  .podium {
    --podium-scale: 1.35;
    max-width: 760px;
    margin: 0 auto;
    padding-bottom: 20px;
  }

  .podium-name {
    font-size: 14px;
  }

  /* Dos columnas en un portátil y tres a partir de ~1400 px, sin más puntos de corte. */
  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 12px;
    align-content: start;
  }

  /* A la izquierda, para que no parezca un tercer boton de la barra de herramientas. */
  .add-row {
    justify-content: flex-start;
    padding-bottom: 4px;
  }

  /*
   * Los botones dejan de flotar. Un botón flotante en escritorio es justo lo que delata que
   * el diseño viene de móvil, y además aquí hay sitio de sobra para ponerlos en su fila.
   */
  .fabs {
    position: static;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
    padding: 16px var(--shell-inline) 0;
  }

  .fab {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    box-shadow: none;
    border: 1px solid var(--outline);
  }

  .fab:hover {
    background: var(--surface-2);
  }

  /* Ya no hay nada flotando que esquivar. */
  .pager-panel {
    padding-bottom: 48px;
  }

  /* ---------- Ficha: dos columnas ---------- */

  .detail-body {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 32px;
    /* El contenedor no se desplaza: lo hace cada columna por su cuenta, para que un chat
       largo no arrastre consigo la foto y el slider. */
    overflow: hidden;
    padding: 24px var(--shell-inline) 0;
  }

  .detail-left,
  .detail-right {
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 24px;
  }

  .detail-header {
    padding: 0;
  }

  /* En móvil la foto se salía a sangre por los lados; aquí vive dentro de su columna. */
  .detail-hero {
    width: 100%;
    margin: 0;
    border-radius: 20px;
    overflow: hidden;
  }

  .detail-fade {
    display: none;
  }

  .detail-card:first-of-type {
    margin-top: 16px;
  }

  .detail-comments {
    padding: 0;
  }

  .detail-comments-title {
    padding: 0 0 12px;
  }

  .bubble {
    max-width: min(420px, 82%);
  }

  /* La caja de escribir se alinea con la columna del chat, no con toda la pantalla. */
  .composer {
    padding-inline: var(--shell-inline);
  }

  .composer-row {
    padding: 12px 0 16px calc(420px + 32px);
  }

  /* ---------- Editor: imagen y formulario, uno al lado del otro ---------- */

  .editor-body {
    display: grid;
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    align-items: start;
    gap: 36px;
    max-width: 900px;
    padding: 28px var(--shell-pad) 48px;
  }

  .editor-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
  }

  /* ---------- Administración ---------- */

  .admin-body {
    max-width: 720px;
    padding: 24px var(--shell-pad) 48px;
  }

  .admin-row {
    padding: 16px 18px;
  }

  .admin-fab {
    right: max(24px, calc((100% - 720px) / 2));
  }

  /* ---------- Login ---------- */

  /* En una pantalla ancha, un formulario suelto en medio de la nada se ve desamparado. */
  .login-form {
    max-width: 420px;
    padding: 28px;
    background: var(--surface-1);
    border-radius: 24px;
  }

  /* ---------- Hojas inferiores -> diálogos centrados ---------- */

  /*
   * Una hoja que sube desde abajo es un gesto de móvil. En escritorio se convierte en un
   * diálogo centrado que entra con un fundido: es lo que más quita la sensación de "menú de
   * móvil ensanchado".
   */
  .sheet-backdrop {
    align-items: center;
    justify-content: center;
  }

  .sheet-panel {
    width: min(560px, calc(100vw - 64px));
    max-height: 84dvh;
    border-radius: 24px;
    padding: 22px 26px 26px;
    transform: translateY(14px) scale(0.98);
    opacity: 0;
    transition: transform 200ms ease, opacity 200ms ease;
    box-shadow: 0 24px 70px rgb(0 0 0 / 55%);
  }

  .sheet-open .sheet-panel {
    transform: none;
    opacity: 1;
  }

  /* El tirador solo tiene sentido si la hoja se puede arrastrar hacia abajo. */
  .sheet-handle {
    display: none;
  }
}
