:root {
  --color-text: #4a3f4f;
  --color-bg-start: #fdf6f9;
  --color-bg-end: #f3effa;
  --color-accent: #e8a6d0;
  --color-accent-dark: #c97fb0;
  --color-card: #ffffff;
  --color-border: #e9dfee;
  --radius-lg: 28px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text);
  background: linear-gradient(160deg, var(--color-bg-start), var(--color-bg-end));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
}

.view {
  min-height: 100vh;
  padding: 1.75rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.view.hidden {
  display: none;
}

/* Vista 1: selección de modelo */

#viewSelect {
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  text-align: center;
  padding-bottom: 4rem;
}

.app__header h1 {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  margin: 0;
}

.selector-card {
  width: 100%;
  max-width: 320px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 12px 30px rgba(74, 63, 79, 0.12);
}

.selector-card__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
  text-align: left;
}

.model-select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fbf8fd;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text);
  min-height: 48px;
}

.variant-buttons {
  display: flex;
  gap: 0.6rem;
}

.variant-btn {
  flex: 1;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text);
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.variant-btn.is-active {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.variant-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

/* Vista 2: wallpaper */

#viewWallpaper {
  align-items: center;
}

.automation-help {
  width: 100%;
  max-width: 320px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
}

.automation-help summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--color-accent-dark);
  list-style: none;
}

.automation-help summary::-webkit-details-marker {
  display: none;
}

.automation-help summary::after {
  content: ' +';
}

.automation-help[open] summary::after {
  content: ' -';
}

.automation-help__steps {
  margin: 0.85rem 0 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  line-height: 1.4;
}

.automation-help__warning {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.85rem;
  background: #fff8e1;
  border: 1px solid #f0dca0;
  border-radius: 14px;
  color: #7a5d00;
  font-size: 0.85rem;
  line-height: 1.4;
}


.back-link {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.7;
  cursor: pointer;
  padding: 0.5rem 0;
}

/* Preview con mockup de iPhone */

.preview-section {
  display: flex;
  justify-content: center;
}

.phone-mockup {
  position: relative;
  width: min(78vw, 280px);
  background: #1d1a20;
  border-radius: 44px;
  padding: 10px;
  box-shadow: 0 18px 40px rgba(74, 63, 79, 0.25);
}

.phone-mockup__canvas {
  display: block;
  width: 100%;
  border-radius: 34px;
  background: #f3effa;
}

.phone-mockup__notch {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d1a20;
  z-index: 2;
}

.phone-mockup[data-notch='island'] .phone-mockup__notch {
  width: 28%;
  height: 8%;
  max-height: 26px;
  border-radius: var(--radius-pill);
}

.phone-mockup[data-notch='classic'] .phone-mockup__notch {
  width: 48%;
  height: 7%;
  max-height: 24px;
  border-radius: 0 0 18px 18px;
  top: 10px;
}

/* Acciones */

.actions {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.actions .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 0 0 auto;
  min-height: 3.4rem;
  line-height: 1.3;
  text-align: center;
}

.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  min-height: 44px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, background-color 0.2s, border-color 0.2s, color 0.2s;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: #ffffff;
}

.btn--secondary {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--copied {
  background: #5fbf6b;
  border-color: #5fbf6b;
  color: #ffffff;
}

.status {
  min-height: 1.2em;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.75;
  margin: 0;
}

/* Pantalla de carga */

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(253, 246, 249, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.loading-overlay.hidden {
  display: none;
}

.loading-overlay__spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 5px solid var(--color-border);
  border-top-color: var(--color-accent);
  animation: loading-spin 0.8s linear infinite;
}

.loading-overlay__text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-accent-dark);
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .variant-btn {
    transition: none;
  }

  .loading-overlay__spinner {
    animation-duration: 2.5s;
  }
}

/* QR de esquina: abrir la página desde el celular */

.qr-corner.hidden {
  display: none;
}

.qr-corner {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(74, 63, 79, 0.18);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.qr-corner__canvas {
  display: block;
  width: 84px;
  height: 84px;
  border-radius: 6px;
}

.qr-corner__label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text);
  opacity: 0.65;
}

@media (max-width: 380px) {
  .qr-corner {
    left: 0.6rem;
    bottom: 0.6rem;
    padding: 0.35rem;
  }

  .qr-corner__canvas {
    width: 66px;
    height: 66px;
  }

  .qr-corner__label {
    display: none;
  }
}

@media (min-width: 760px) {
  .app {
    max-width: 560px;
  }

  .selector-card {
    max-width: 360px;
  }

  .phone-mockup {
    width: 280px;
  }
}
