:root {
  /* paleta (desde el archivo de Figma) */
  --px-navy: #0C0D45;
  --px-pink: #F3D2FF;
  --px-pink-light: #F7E6FE;
  --px-grey: #9498A4;
  --px-blue: #3F5BA4;
  --px-alice: #DAE8FB;
  --px-white: #FFFFFF;
  --px-disabled-bg: #E7E8F2;
  --px-header-grad: linear-gradient(265deg, #95A3C9 -0.64%, #3F5BA4 99.57%);
  --px-grad-pink: linear-gradient(255deg, #FAEBFF 0%, #F3D2FF 100%);
  --px-grad-teal: linear-gradient(255deg, #9BCED2 0%, #7ACCD2 100%);
  --px-grad-blue: linear-gradient(255deg, #ECF2FB 0%, #DBE8FB 100%);
  --px-grad-indigo: linear-gradient(255deg, #8189BE 0%, #4C58A0 100%);
  --px-grad-banner: linear-gradient(88deg, var(--px-alice) -0.41%, var(--px-pink-light) 102.88%, var(--px-pink) 142.07%);
  --px-bg-gradient: linear-gradient(259deg, var(--px-alice) -7.04%, #FAF1FE 76.36%, var(--px-pink-light) 110%);

  --bevel-sm: inset 3px 3px 0 rgba(255,255,255,0.6), inset -3px -3px 0 rgba(74,76,121,0.55);
  --bevel-sm-pressed: inset -3px -3px 0 rgba(255,255,255,0.6), inset 3px 3px 0 rgba(74,76,121,0.55);
  --bevel-lg: inset 9px 9px 0 rgba(255,255,255,0.5), inset -9px -9px 0 rgba(74,76,121,0.5);
  --bevel-lg-pressed: inset -9px -9px 0 rgba(255,255,255,0.5), inset 9px 9px 0 rgba(74,76,121,0.5);

  --bg: #FCF6FE;
  --text: var(--px-navy);
  --text-dim: #6B6790;

  --header-h: 68px;
}

* {
  box-sizing: border-box;
  /* El único feedback de toque es el bisel :active de cada componente;
     se anula el resaltado táctil nativo del navegador (gris/azul semitransparente). */
  -webkit-tap-highlight-color: transparent;
}

button, .px-pill, .px-deco-btn {
  outline: none;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-top: var(--header-h);
  font-family: 'Saira', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--px-bg-gradient);
  background-attachment: fixed;
  color: var(--text);
}

main#app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  padding: 15px 16px 36px;
}

.screen { display: none; }
.screen.active { display: block; animation: fade-in 0.15s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-hint {
  color: var(--text-dim);
  margin: 0 0 16px;
  font-size: 0.95rem;
  font-weight: 500;
}

.hidden { visibility: hidden !important; }

/* ================= Header ================= */
.px-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--px-header-grad);
  border-bottom: 3px solid var(--px-navy);
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.px-header-title {
  flex: 1;
  margin: 0;
  text-align: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
}

.px-icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 3px solid var(--px-navy);
  border-radius: 12px;
  background: var(--px-white);
  box-shadow: var(--bevel-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.px-icon-btn:active, .px-icon-btn.is-pressed { box-shadow: var(--bevel-sm-pressed); }
.px-icon-btn:disabled {
  background: var(--px-disabled-bg);
  border-color: var(--px-grey);
  cursor: not-allowed;
  box-shadow: inset 3px 3px 0 rgba(255,255,255,0.7), inset -3px -3px 0 rgba(148,152,164,0.4);
}
.px-icon-btn:disabled .px-icon-img,
.px-icon-btn:disabled .px-icon-img-lg { filter: grayscale(1) opacity(0.7); }
.px-icon-img { width: 28px; height: 28px; }

/* ================= Ventana (Categorías / Elementos / Resultado) ================= */
.px-window {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.px-titlebar {
  background: var(--px-pink);
  border: 3px solid var(--px-navy);
  border-radius: 8px 8px 0 0;
  padding: 12px 12px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.px-titlebar-label {
  flex: 1;
  min-width: 0;
  color: var(--px-navy);
  font-size: 0.98rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.px-titlebar-controls { display: flex; gap: 6px; flex-shrink: 0; }

/* Insignias decorativas: los "?"/"x" de la barra rosa y el pin del subheader.
   A propósito NO se ven presionables (sin :active, cursor default). */
.px-deco-btn {
  width: 28px;
  height: 24px;
  border: none;
  border-radius: 3px;
  background: var(--px-pink-light);
  color: var(--px-navy);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--bevel-sm);
  cursor: default;
  flex-shrink: 0;
  padding: 0;
}
.px-deco-btn img { width: 13px; height: 13px; }

.px-body {
  background: var(--px-white);
  border: 3px solid var(--px-navy);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: clamp(14px, 3vh, 25px) 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 3vh, 33px);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,0.18);
}

/* ================= Subheader: categoría activa (pantalla Elementos) ================= */
.px-category-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: stretch;
  width: 100%;
  height: 34px;
  padding: 0 5px;
  border-bottom: 3px solid var(--px-navy);
  border-right: 3px solid var(--px-navy);
  border-left: 3px solid var(--px-navy);
  background: var(--px-grad-banner);
}
.px-category-banner-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.px-category-banner-label {
  color: var(--px-navy);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}
.px-category-banner .px-deco-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
}

/* ================= Pills (categorías y elementos) ================= */
.px-pill-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.px-pill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}

.px-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border: 3px solid var(--px-navy);
  border-radius: 10px;
  background: var(--px-white);
  box-shadow: var(--bevel-sm);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
}
.px-pill:active { box-shadow: var(--bevel-sm-pressed); }
.px-pill.is-selected {
  background: var(--px-alice);
  box-shadow: var(--bevel-sm-pressed);
}
.px-pill-icon { width: 24px; height: 24px; flex-shrink: 0; }
.px-pill-label {
  color: var(--px-blue);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
}

/* ================= Botones primarios ================= */
.px-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 64px;
  flex-shrink: 0;
  border: 3px solid var(--px-navy);
  border-radius: 10px;
  color: var(--px-navy);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--bevel-lg);
  padding: 0 24px;
}
.px-primary-btn:active, .px-primary-btn.is-pressed { box-shadow: var(--bevel-lg-pressed); }
.px-primary-btn:disabled {
  background: var(--px-disabled-bg);
  border-color: var(--px-grey);
  color: var(--px-grey);
  cursor: not-allowed;
  box-shadow: inset 3px 3px 0 rgba(255,255,255,0.7), inset -3px -3px 0 rgba(148,152,164,0.4);
}
.px-primary-btn:disabled .px-btn-icon[src$="back-arrow.svg"] { content: url('assets/icons/back-arrow-grey.svg'); }
.px-primary-btn:disabled .px-btn-icon[src$="star.svg"],
.px-primary-btn:disabled .px-btn-icon[src$="star-white.svg"] { content: url('assets/icons/star-grey.svg'); }
.px-primary-btn--pink { background: var(--px-grad-pink); }
.px-primary-btn--teal { background: var(--px-grad-teal); }
.px-primary-btn--indigo { background: var(--px-grad-indigo); color: #FFFFFF; }
.px-primary-btn--blue { background: var(--px-grad-blue); }
.px-btn-icon { width: 22px; height: 22px; }
.px-btn-icon--flip { transform: scaleX(-1); }

/* ================= Resultado ================= */
.px-result-phrase {
  width: 100%;
  margin: 0;
  color: var(--px-navy);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
}

.px-result-actions {
  display: flex;
  justify-content: center;
  gap: 22px;
}

.px-icon-btn--lg {
  width: auto;
  height: 64px;
  padding: 0 25px;
  gap: 15px;
  border-radius: 10px;
}
.px-icon-btn--lg.is-active { background: var(--px-pink-light); }
.px-icon-img-lg { width: 32px; height: 32px; aspect-ratio: 1 / 1; }

/* ================= Favoritos (pendiente de rediseño) ================= */
.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.favorite-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--px-white);
  border-radius: 8px;
  border: 2.5px solid var(--px-navy);
  box-shadow: 3px 3px 0 var(--px-navy);
  padding: 16px;
}
.favorite-card .fav-content { flex: 1; min-width: 0; }
.favorite-card .fav-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--px-blue);
  margin-bottom: 6px;
}
.favorite-card .fav-phrase { margin: 0; line-height: 1.4; color: var(--px-navy); font-weight: 500; }
.favorite-card .fav-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--px-white);
  border: 2px solid var(--px-navy);
  border-radius: 8px;
  box-shadow: var(--bevel-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
}
.favorite-card .fav-delete:active, .favorite-card .fav-delete.is-pressed { box-shadow: var(--bevel-sm-pressed); }
.favorite-card .fav-delete img { width: 18px; height: 18px; }

.empty-msg {
  color: var(--text-dim);
  text-align: center;
  margin-top: 40px;
  font-weight: 500;
}

/* ================= Flourish decorativo ================= */
.px-decor {
  position: fixed;
  right: 24px;
  bottom: -10px;
  width: 220px;
  height: auto;
  mix-blend-mode: plus-lighter;
  pointer-events: none;
  z-index: 0;
}

/* La pantalla de Elementos tiene el doble de ítems que Categorías, así que
   su grilla usa espaciado más ajustado (nunca el botón principal, que
   siempre mantiene su alto fijo). Escala con la altura de pantalla en vez
   de saltar de golpe en un breakpoint. */
.px-pill-grid {
  gap: clamp(4px, 1.2vh, 10px);
}
.px-pill-grid .px-pill {
  padding: clamp(3px, 1vh, 10px) 12px;
}
.px-pill-grid .px-pill-icon {
  width: clamp(16px, 3.5vh, 24px);
  height: clamp(16px, 3.5vh, 24px);
}
