/* Stencily - Light theme, modern minimalist */
:root {
  /* Light palette - claro, no dark */
  --bg-primary: #f5f3f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0eef5;
  
  --text-primary: #1a1a24;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-muted: rgba(124, 58, 237, 0.12);
  
  --border: #e4e4e7;
  --border-focus: var(--accent);
  
  --radius: 12px;
  --radius-sm: 8px;
  
  --sidebar-width: 260px;
  --header-height: 72px;
  
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

/* Layout */
body:not(.landing):not(.auth-page) {
  display: flex;
}

.main-content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem 3rem;
  overflow-x: hidden;
  position: relative;
}

body.landing .main-content,
body.auth-page .main-content {
  margin-left: 0;
  padding: 0;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.375rem;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.25rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-tier {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-tier.premium {
  color: var(--accent);
}

.user-tier.admin {
  color: #059669;
}

.nav-item.logout {
  color: var(--text-muted);
}

.nav-item.logout:hover {
  color: #ef4444;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(.disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary:hover:not(.disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-block {
  width: 100%;
}

.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}

.stat-card h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 0.25rem;
}

/* Misma altura y alineación en todas las tarjetas del dashboard */
.stat-value-fixed {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  font-size: 2rem;
}

.stat-detail {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.stat-value.tier-badge {
  font-size: 2rem;
  margin-top: 0;
  padding: 0;
}

.tier-badge.premium {
  color: var(--accent);
}

/* Dashboard grid */
/* Dashboard top: header + grid + create button; on mobile button goes below grid */
.dashboard-top {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 1.75rem 1rem;
  align-items: start;
  margin-bottom: 2rem;
}

.dashboard-header-row {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dashboard-brand {
  display: none;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.125rem;
}

.dashboard-top .page-header {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

/* Saludo con emoji que saluda y se detiene */
.wave-emoji {
  display: inline-block;
  transform-origin: 70% 70%;
  animation: wave 1.2s ease-in-out 1;
  animation-fill-mode: forwards;
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-8deg); }
  50% { transform: rotate(14deg); }
  60%, 100% { transform: rotate(0deg); }
}

.dashboard-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: stretch;
}

.dashboard-actions .dashboard-create-btn,
.dashboard-actions .btn-upgrade {
  flex: 1;
  white-space: nowrap;
}

.btn-upgrade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: filter 0.2s;
  animation: upgrade-shine 2.8s ease-in-out infinite;
}

.btn-upgrade::after {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.45) 50%, transparent 100%);
  transform: skewX(-20deg);
  animation: shine-sweep 2.8s ease-in-out infinite;
}

@keyframes shine-sweep {
  0%, 60%   { left: -75%; }
  80%        { left: 125%; }
  100%       { left: 125%; }
}

@keyframes upgrade-shine {
  0%, 55%   { filter: brightness(1); }
  70%        { filter: brightness(1.12); }
  85%        { filter: brightness(1); }
  100%       { filter: brightness(1); }
}

.btn-upgrade:hover {
  filter: brightness(1.12);
  color: white;
}

.btn-icon {
  flex-shrink: 0;
}

.dashboard-top .dashboard-grid {
  grid-column: 1 / -1;
  grid-row: 2;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

/* Admin panel */
.admin-section {
  margin-bottom: 2.5rem;
}

.admin-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.admin-section-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  max-width: 560px;
}

/* User management result card */
.user-management-result {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.user-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-start;
}

.user-info-block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 100px;
}

.user-info-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.user-info-value {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 500;
}

.tier-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tier-badge.badge-premium {
  background: rgba(var(--accent-rgb, 139, 92, 246), 0.12);
  color: var(--accent);
}

.tier-badge.badge-trial {
  background: rgba(var(--text-muted-rgb, 150, 150, 160), 0.12);
  color: var(--text-secondary);
}

.tier-badge.badge-admin {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.user-actions-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-note {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.admin-form .form-group {
  margin-bottom: 1rem;
}

.admin-form .btn {
  margin-top: 0.25rem;
}

.settings-section {
  margin-top: 1.5rem;
}
.settings-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  width: 100%;
}
.settings-box-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}
.settings-box-desc {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin: 0 0 1rem 0;
}
.settings-box-form .form-group {
  margin-bottom: 1rem;
}
.settings-box-form .btn {
  margin-top: 0.25rem;
}

.settings-box-danger {
  border-color: #fca5a5;
}

.admin-stats .stat-card {
  max-width: 280px;
}

/* Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #b91c1c;
}

.alert-info {
  background: var(--accent-muted);
  border: 1px solid rgba(124, 58, 237, 0.35);
  color: #5b21b6;
}

/* History section */
.history-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-section-head h2 {
  margin: 0;
  padding: 0;
  line-height: 1;
  font-size: 1.125rem;
  font-weight: 600;
}

.history-section-head .btn-text {
  margin: 0;
  padding: 0;
  line-height: 1;
  font-size: 0.8125rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.history-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9375rem;
  padding: 0.25rem 0;
}

.btn-text:hover {
  text-decoration: underline;
}

.history-placeholder {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.history-placeholder p {
  margin-bottom: 0.5rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.history-placeholder .btn {
  margin-top: 1rem;
}

/* Ordenador y tablet: 5 cuadrados en una fila */
.history-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

/* En desktop/tablet ocultar el 6.º (solo mostramos 5) */
.history-grid > .history-item-link:nth-child(6) {
  display: none;
}

/* Teléfono: 6 cuadrados, de 2 en 2 (3 filas) */
@media (max-width: 640px) {
  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .history-grid > .history-item-link:nth-child(6) {
    display: block;
  }
}

/* Página historial: mostrar todos los items (no ocultar el 6.º) */
.history-grid--all > .history-item-link:nth-child(n) {
  display: block;
}

/* Historial por mes */
.history-month-section {
  margin-bottom: 2.5rem;
}

.history-month-section:last-child {
  margin-bottom: 0;
}

.history-month-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

.history-item-link {
  text-decoration: none;
  color: inherit;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  border-color: var(--accent-muted);
}

.history-card-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #000;
}

.history-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-card-meta {
  padding: 0.5rem 0.75rem 0.6rem;
}

.history-card-meta time {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Upload */
.upload-card {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.upload-zone {
  padding: 3rem 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  margin: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

.upload-zone:hover .upload-icon {
  color: var(--accent);
}

.upload-text {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.upload-browse {
  color: var(--accent);
  text-decoration: underline;
}

.upload-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.upload-preview {
  padding: 1.5rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.upload-preview.hidden {
  display: none;
}

/* Wrapper: full width, responsive, no overflow - no arrastrar ni mostrar fondo */
.stencil-preview-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 0 1rem;
  overflow-x: hidden;
  overflow-y: visible;
}

.preview-image-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-hover);
  touch-action: pan-y;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

/* Contenedor del stencil: ocupa el ancho del wrapper para que en móvil no haga zoom ni se recorte */
.preview-image-wrapper .stencil-zoom-container {
  width: 100%;
  max-width: 100%;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.stencil-zoom-pan {
  max-width: 100%;
  width: fit-content;
}

.stencil-preview-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  background: var(--bg-hover);
}

.stencil-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stencil-controls-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stencil-controls-row-single .control-group {
  flex: 1;
  min-width: 0;
}

.stencil-controls-row-half .control-group {
  flex: 1;
  min-width: 0;
}

.stencil-controls .control-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.stencil-controls .control-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stencil-controls .stencil-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.stencil-controls .stencil-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.stencil-controls .stencil-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.stencil-controls .stencil-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.stencil-tip {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 1rem;
}

/* Big stencil display area: height = content (stencil/original), no extra space */
.stencil-display-area {
  position: relative;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
}

.stencil-eraser-toolbar-float {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  pointer-events: auto;
}

.stencil-eraser-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stencil-eraser-toolbar-float .btn.hidden,
.stencil-eraser-toolbar-float .eraser-size-control.hidden {
  display: none;
}

.stencil-eraser-toolbar-float .eraser-size-value {
  color: var(--text-secondary);
}

.stencil-display-area.eraser-cursor {
  cursor: crosshair;
}

/* Contenedor de zoom en modo goma: recorta y no deja salir la imagen */
.stencil-zoom-container {
  position: relative;
  z-index: 0;
  line-height: 0;
}

.stencil-zoom-container.stencil-zoom-container--active {
  overflow: hidden;
  touch-action: none;
}

.stencil-zoom-pan {
  display: inline-block;
  transform-origin: 0 0;
  will-change: transform;
}

.btn-eraser .btn-icon {
  width: 1.125rem;
  height: 1.125rem;
}

.stencil-eraser-toolbar-float .btn-eraser.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.btn-icon-only {
  padding: 0.5rem;
  min-width: 2.25rem;
}

.btn-icon-only .btn-icon {
  width: 1.125rem;
  height: 1.125rem;
}

.btn-undo .btn-icon {
  width: 1.125rem;
  height: 1.125rem;
}

.eraser-size-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.eraser-size-control .btn-size-btn {
  width: 2rem;
  min-width: 2rem;
  padding: 0.35rem 0;
  font-size: 1.125rem;
  line-height: 1;
  font-weight: 600;
}

.eraser-size-value {
  min-width: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Footer bar: label left, actions right (like ref) */
.stencil-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.stencil-footer-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stencil-footer-label strong {
  color: var(--text-primary);
}

.stencil-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}

.stencil-footer-actions > .btn,
.stencil-footer-actions > .stencil-form-inline {
  min-width: 0;
}

.stencil-footer-actions > .btn {
  width: 100%;
  box-sizing: border-box;
}

.stencil-footer-actions > .stencil-form-inline {
  display: flex;
  min-width: 0;
  width: 100%;
}

.stencil-footer-actions .stencil-form-inline .btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
  box-sizing: border-box;
}

.stencil-form-inline {
  display: inline-block;
}

/* Botón Download flotante abajo a la derecha (solo en upload con preview) */
.stencil-download-float {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  margin: 0;
  /* Evitar que el scroll del main lo recorte en móvil */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.stencil-download-float.hidden {
  display: none !important;
}

.stencil-download-float .btn {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-with-icon .btn-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.preview-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Stencil result page – full width, same order as ref */
.stencil-result-page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
}

.stencil-result-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stencil-result-wrap .stencil-tip-result {
  margin-bottom: 1rem;
}

.stencil-result-wrap .stencil-view {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stencil-result-wrap .stencil-view img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

.stencil-result-wrap .stencil-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.stencil-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stencil-view {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0;
}

.stencil-view img {
  max-width: 100%;
  height: auto;
  display: block;
}

.stencil-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Landing page */
.landing {
  min-height: 100vh;
  background: var(--bg-primary);
}

.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.landing-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.landing-nav {
  display: flex;
  gap: 0.75rem;
}

.landing-hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.hero-title .underline {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 420px;
}

.hero-cta-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hero-social-proof {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.hero-cta-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.btn-emoji {
  margin-right: 0.25rem;
}

.hero-visual {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Before/After image slider */
.before-after-slider {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 5 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.before-after-slider .slider-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.before-after-slider .slider-before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.slider-after-wrap {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  clip-path: inset(0 var(--clip-right, 50%) 0 0);
}

.before-after-slider.animating .slider-after-wrap {
  transition: clip-path 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.before-after-slider.animating .slider-divider {
  transition: left 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-after-wrap .slider-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slider-divider {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: var(--accent);
  cursor: col-resize;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.slider-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

/* Testimonials */
.testimonials-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

.testimonial-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.testimonial-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.testimonial-quote {
  font-size: 0.9375rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.testimonial-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
}

.testimonial-author span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Pricing - 2 steps (7 days free → $19.99/year) */
.pricing-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
  text-align: center;
}

.pricing-question {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.pricing-title {
  font-size: 2.25rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2.5rem;
  color: var(--text-primary);
}

.pricing-steps {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.pricing-step-card {
  flex: 1;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  text-align: left;
}

.pricing-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
}

.pricing-step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pricing-step-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
}

.pricing-step-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.pricing-step-arrow {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.btn-pricing-cta {
  display: inline-block;
  padding: 0.875rem 2rem;
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius);
}

/* Footer */
.landing-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  border-top: 1px solid var(--border);
}

.footer-creator {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.creator-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-hover);
  flex-shrink: 0;
  object-fit: cover;
}

.footer-creator p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.footer-creator a {
  color: var(--accent);
  text-decoration: underline;
}

.footer-creator a:hover {
  color: var(--accent-hover);
}

/* Auth pages */
.auth-page .main-content {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form .btn {
  margin-top: 0.5rem;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
  .sidebar {
    width: 72px;
    padding: 0;
  }

  .sidebar-logo span:not(.logo-icon),
  .nav-item span,
  .user-info,
  .nav-item.logout span {
    display: none;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 1rem;
  }

  .nav-item {
    justify-content: center;
    padding: 1rem;
  }

  .nav-item.logout {
    justify-content: center;
  }

  .user-profile {
    justify-content: center;
    padding: 0.75rem;
  }

  .main-content {
    margin-left: 72px;
    padding: 1.25rem;
    overflow-x: hidden;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 3rem 1.5rem 1.5rem;
  }

  .hero-subtitle {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-cta-row {
    justify-content: center;
  }

  .testimonial-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Responsive - Tablet Portrait (mismo look que móvil) */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.5rem;
    gap: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .sidebar-logo span:not(.logo-icon),
  .nav-item span,
  .user-info,
  .nav-item.logout span {
    display: none;
  }

  .nav-item {
    flex: 1;
    justify-content: center;
    padding: 0.75rem 1rem;
  }

  body:not(.landing):not(.auth-page) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .main-content {
    margin-left: 0;
    margin-bottom: 0;
    padding: 1rem 1.25rem 5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 72px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    height: 100%;
    min-height: 0;
    flex: 1 1 0;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header .btn {
    width: 100%;
  }

  .dashboard-top {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .dashboard-header-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    grid-row: 1;
  }

  .dashboard-brand {
    display: inline-block;
    font-weight: 700;
    font-size: 1.35rem;
    flex-shrink: 0;
  }

  .dashboard-top .page-header {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    grid-row: auto;
  }

  .dashboard-top .page-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
  }

  .dashboard-top .dashboard-grid {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .dashboard-actions {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    gap: 0.75rem;
  }

  .dashboard-top .dashboard-create-btn,
  .btn-upgrade {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .header-actions {
    flex-direction: column;
  }

  .header-actions .btn {
    width: 100%;
  }
}

/* Auth forms en móvil */
@media (max-width: 480px) {
  .auth-container {
    width: 90%;
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.5rem;
    gap: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .nav-item span {
    display: none;
  }

  .nav-item {
    flex: 1;
    justify-content: center;
  }

  /* Contenedor principal: scroll solo vertical y nunca debajo del sidebar inferior */
  body:not(.landing):not(.auth-page) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .main-content {
    margin-left: 0;
    margin-bottom: 0;
    padding: 1rem 1.25rem 5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 72px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    height: 100%;
    min-height: 0;
    flex: 1 1 0;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header .btn {
    width: 100%;
  }

  /* Dashboard: on mobile put Create button below the two stat boxes */
  .dashboard-top {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .dashboard-header-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    grid-row: 1;
  }

  .dashboard-brand {
    display: inline-block;
    font-weight: 700;
    font-size: 1.35rem;
    flex-shrink: 0;
  }

  .dashboard-top .page-header {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    grid-row: auto;
  }

  .dashboard-top .page-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
  }

  .dashboard-top .dashboard-grid {
    grid-row: 2;
  }

  .dashboard-actions {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    gap: 0.75rem;
  }

  .dashboard-top .dashboard-create-btn,
  .btn-upgrade {
    width: 100%;
  }

  .header-actions {
    flex-direction: column;
  }

  .header-actions .btn {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .upload-zone {
    padding: 2rem 1rem;
  }

  .upload-preview {
    padding: 1rem;
  }

  .stencil-preview-wrap {
    margin-bottom: 0.75rem;
  }

  .stencil-controls {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    /* Mismo orden que tablet/desktop: arriba Detail y Smooth, abajo Threshold, Line thin, Original */
    flex-direction: column;
  }

  /* Primera fila: Detail y Smooth en fila (igual que escritorio) */
  .stencil-controls-row.stencil-controls-row-half {
    flex-direction: row;
  }

  .stencil-controls-row.stencil-controls-row-half .control-group {
    flex: 1;
    min-width: 0;
  }

  /* Segunda fila: Threshold, Line thin, Original en la misma fila (igual que escritorio) */
  .stencil-controls-row:not(.stencil-controls-row-half) {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .stencil-controls-row:not(.stencil-controls-row-half) .control-group {
    flex: 1;
    min-width: 0;
  }

  .stencil-footer {
    flex-direction: column;
    align-items: stretch;
    margin-top: 1rem;
    padding-top: 1rem;
    gap: 0.75rem;
  }

  .stencil-footer-actions {
    width: 100%;
  }

  .stencil-footer-actions > .btn,
  .stencil-footer-actions > .stencil-form-inline {
    flex: 1 1 0%;
    min-width: 0;
  }

  .stencil-result-wrap {
    padding: 1rem;
  }

  .stencil-download-float {
    bottom: calc(1rem + 72px + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    left: auto;
    /* Forzar capa propia para que no lo recorte el scroll en iOS */
    isolation: isolate;
  }


  .landing-hero {
    padding: 2rem 1rem 1.5rem;
    gap: 2rem;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .landing-header {
    padding: 1rem;
    flex-wrap: wrap;
  }

  .hero-cta-row {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-cta-row .btn {
    width: 100%;
  }

  .before-after-slider {
    max-width: 100%;
    cursor: col-resize;
  }

  .testimonials-section,
  .pricing-section {
    padding: 2rem 1rem;
  }

  .testimonial-cards {
    grid-template-columns: 1fr;
  }

  .pricing-steps {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .pricing-step-arrow {
    transform: rotate(90deg);
  }

  .pricing-step-card {
    max-width: 100%;
  }
}

/* ─── Stencil Reveal Popup ──────────────────────────────────────────────── */
.stencil-reveal-popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.stencil-reveal-popup.active {
  opacity: 1;
  pointer-events: auto;
}

.stencil-reveal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 20, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.stencil-reveal-modal {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 58, 237, 0.2);
  max-width: min(92vw, 720px);
  width: fit-content;
}

.stencil-reveal-label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.stencil-reveal-canvas {
  display: block;
  border-radius: calc(var(--radius) - 4px);
  max-width: min(88vw, 680px);
  max-height: min(72vh, 560px);
  width: auto;
  height: auto;
  object-fit: contain;
}
