/* ==========================================================================
   LUMENLINE WEB - iOS LIQUID MONOCHROME DESIGN SYSTEM
   Inspirado en Apple Human Interface Guidelines (HIG), VisionOS y Minimalismo Monocromático
   ========================================================================== */

:root, html[data-theme="dark"] {
  color-scheme: dark;

  /* Superficies Modo Oscuro (OLED Cupertino) */
  --bg: #000000;
  --card-bg: #1C1C1E;
  --card-sub: #2C2C2E;
  --card-sub-active: #3A3A3C;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --surface-3: #3A3A3C;
  --raised: #1C1C1E;
  
  /* Tipografía y Contrastes */
  --paper: #FFFFFF;
  --text-primary: #FFFFFF;
  --text-secondary: #8E8E93;
  --muted: #8E8E93;
  --faint: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.08);
  --line-bright: rgba(255, 255, 255, 0.16);
  --divider: rgba(255, 255, 255, 0.08);
  
  /* Acentos Monocromáticos */
  --accent: #FFFFFF;
  --accent-soft: rgba(255, 255, 255, 0.12);
  --accent-glow: rgba(255, 255, 255, 0.25);
  --accent-ink: #000000;

  /* Semántica Funcional (iOS System Colors) */
  --ios-blue: #007AFF;
  --ios-blue-soft: rgba(0, 122, 255, 0.16);
  --ios-blue-glow: rgba(0, 122, 255, 0.35);
  --green: #34C759;
  --green-bg: rgba(52, 199, 89, 0.14);
  --red: #FF453A;
  --red-bg: rgba(255, 69, 58, 0.14);
  --amber: #FF9F0A;
  --amber-bg: rgba(255, 159, 10, 0.14);

  /* Efectos de Superficie y Destellos */
  --grabber: rgba(255, 255, 255, 0.28);
  --flare-start: rgba(255, 255, 255, 0.95);
  --flare-mid: rgba(255, 255, 255, 0.35);

  /* Tipografía Apple */
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Space Grotesk", "Inter", sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Inter", -system-ui, sans-serif;
  --mono: "SF Mono", "SFMono-Regular", "IBM Plex Mono", Menlo, Consolas, monospace;

  /* Escala de Espaciado */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 48px;

  /* Escala Tipográfica */
  --fs-xs: 11px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 22px; --fs-xl: 34px;

  /* Radios de Curvatura (Squircles iOS) */
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 20px; --r-xl: 24px; --r-pill: 999px;
  
  /* Sombras y Físicas */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[data-theme="light"] {
  color-scheme: light;

  /* Superficies Modo Claro (iOS System Gray) */
  --bg: #F2F2F7;
  --card-bg: #FFFFFF;
  --card-sub: #F0F0F4;
  --card-sub-active: #E5E5EA;
  --surface: #FFFFFF;
  --surface-2: #F2F2F7;
  --surface-3: #E5E5EA;
  --raised: #FFFFFF;

  --paper: #000000;
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --muted: #8E8E93;
  --faint: rgba(0, 0, 0, 0.04);
  --line: rgba(0, 0, 0, 0.06);
  --line-bright: rgba(0, 0, 0, 0.12);
  --divider: rgba(0, 0, 0, 0.07);

  --accent: #000000;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --accent-glow: rgba(0, 0, 0, 0.12);
  --accent-ink: #FFFFFF;

  --ios-blue: #007AFF;
  --ios-blue-soft: rgba(0, 122, 255, 0.12);
  --ios-blue-glow: rgba(0, 122, 255, 0.25);
  --grabber: rgba(0, 0, 0, 0.22);
  --flare-start: rgba(0, 122, 255, 0.65);
  --flare-mid: rgba(0, 122, 255, 0.22);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   RESET NATIVO APP Y MICRO-SENSACIÓN TÁCTIL
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.45;
  background-color: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* ==========================================================================
   ANIMACIONES Y KEYFRAMES ESENCIALES
   ========================================================================== */

@keyframes cardStepJelly {
  0%   { transform: scale(1); }
  32%  { transform: scale(1.02); }
  65%  { transform: scale(0.99); }
  84%  { transform: scale(1.004); }
  100% { transform: scale(1); }
}

@keyframes tabJellyPop {
  0%   { transform: scale(0.94); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */

.layout-wrapper {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: max(calc(var(--sp-4) + env(safe-area-inset-top, 0px)), 20px)
           calc(var(--sp-5) + env(safe-area-inset-right, 0px))
           max(calc(var(--sp-8) + env(safe-area-inset-bottom, 0px)), 36px)
           calc(var(--sp-5) + env(safe-area-inset-left, 0px));
  animation: viewIn 0.3s var(--ease-ios);
}

/* ==========================================================================
   CABECERA PRINCIPAL (NAVBAR LIQUID)
   ========================================================================== */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.brand-badge {
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;
}

.brand-info h1 {
  margin: 0;
  font-family: var(--display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-info p {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ==========================================================================
   SISTEMA DE BOTONES (TÁCTIL NATIVO iOS)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background-color: var(--card-sub);
  color: var(--text-primary);
  transition: transform 0.22s var(--ease-ios), background-color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.95);
  background-color: var(--card-sub-active);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.94;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.95);
  background-color: var(--accent);
}

.btn-secondary {
  background-color: var(--surface-2);
  border-color: var(--line);
  color: var(--text-primary);
}

.btn-icon-only {
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ==========================================================================
   BANNER DE DIAGNÓSTICO
   ========================================================================== */

.diagnostic-banner {
  background-color: var(--amber-bg);
  border: 1px solid var(--amber);
  color: var(--text-primary);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  animation: viewIn 0.25s var(--ease-ios);
}

.diagnostic-banner.hidden {
  display: none;
}

.diagnostic-banner .banner-icon {
  font-size: 20px;
  line-height: 1;
}

.diagnostic-banner .banner-body {
  flex: 1;
}

.diagnostic-banner strong {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.diagnostic-banner code {
  background: var(--line-bright);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-family: var(--mono);
  font-size: var(--fs-xs);
}

/* ==========================================================================
   PANEL DE ESTADO DEL SISTEMA (iOS FLUID)
   ========================================================================== */

.system-status-panel {
  background-color: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-5);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

.system-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.status-indicator-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--r-pill);
  background-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
  transition: all 0.3s var(--ease-ios);
}

.status-dot.connected {
  background-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
}

.status-dot.error {
  background-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-bg);
}

.status-text-wrapper strong {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.status-text-wrapper span {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* ==========================================================================
   BARRA DE HERRAMIENTAS: BÚSQUEDA Y FILTROS TIPO CAPSULE iOS
   ========================================================================== */

.toolbar-section {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: var(--sp-4);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* Input Cápsula Flotante */
.search-box-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
  background: var(--card-bg);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-pill);
  height: 46px;
  padding: 0 16px 0 42px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.search-box-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box-wrapper svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-primary);
  user-select: text;
  -webkit-user-select: text;
}

.search-input::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* Desplegables Tipo Píldora iOS */
.filter-select {
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-bright);
  background-color: var(--card-bg);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: all 0.2s var(--ease-ios);
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.count-pill {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background-color: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   REJILLA Y TARJETAS EDITORIALES DE ARTÍCULO (HIGH-END LIQUID DESIGN)
   ========================================================================== */

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-4);
}

/* Tarjeta Integral Cupertino */
.news-card {
  background-color: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s var(--ease-ios), border-color 0.2s ease;
}

.news-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-bright);
  box-shadow: var(--shadow-md);
}

/* Portada Integrada: Portada protagonista, sin achatarse (16:10 / 16:9 cinematográfica) */
.card-header-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 200px;
  background-color: var(--surface-2);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: block;
}

/* Efecto Shimmer de carga progresiva estilo Telegram */
.card-header-thumb.is-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.07) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: tgShimmer 1.5s infinite ease-in-out;
  z-index: 1;
  pointer-events: none;
}

@keyframes tgShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.card-header-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.35s ease, transform 0.4s var(--ease-ios), filter 0.3s ease;
  display: block;
  opacity: 0;
}

.card-header-thumb img.loaded,
.card-header-thumb img:not([data-dynamic]) {
  opacity: 1;
}

.news-card:hover .card-header-thumb img {
  transform: scale(1.04);
}

/* Overlay degradado sutil en la imagen para fundirse con la tarjeta */
.card-header-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.news-card:hover .card-header-thumb::after {
  opacity: 0.6;
}

/* Indicador flotante en la imagen para abrir enlace */
.thumb-open-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  z-index: 2;
  transition: transform 0.2s var(--ease-spring), background 0.2s ease;
}

.news-card:hover .thumb-open-indicator {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.8);
}

/* Fallback cuando no hay foto */
.thumb-fallback,
.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: radial-gradient(circle at 50% 40%, var(--surface-3), var(--surface-2));
  color: var(--text-secondary);
  font-family: var(--display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.thumb-fallback .thumb-favicon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-bright);
  padding: 8px;
  box-shadow: var(--shadow-sm);
  object-fit: contain;
}

/* Cuerpo de la tarjeta integrado */
.card-body {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--sp-3);
  position: relative;
}

/* Categoría y Estado en pastillas liquid */
.card-tags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.category-tag {
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background-color: var(--surface-2);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
}

.fuente-tag {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background-color: var(--surface-2);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-bright);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta .meta-fuente {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.state-badge {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  letter-spacing: -0.01em;
}

.state-badge.state-pendiente {
  background-color: var(--amber-bg);
  color: var(--amber);
}

.state-badge.state-seleccionado {
  background-color: var(--green-bg);
  color: var(--green);
}

/* Tipografía de Título: Editorial de alto impacto */
.card-title {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.48;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  font-weight: 400;
}

/* Pie de metadatos */
.card-meta {
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Acciones de la tarjeta: Preparar + Eliminar */
.card-actions {
  margin-top: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.card-actions .btn-select {
  flex: 1;
  padding: 11px var(--sp-4);
  font-size: 14px;
  border-radius: var(--r-pill);
}

.card-actions .btn-delete {
  padding: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--r-pill);
  background-color: var(--card-sub);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.22s var(--ease-ios);
}

.card-actions .btn-delete:hover {
  background-color: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

.card-actions .btn-delete:active {
  transform: scale(0.92);
}

.card-actions .btn-comment {
  padding: 0 10px;
  height: 40px;
  border-radius: var(--r-pill);
  background-color: var(--card-sub);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.22s var(--ease-ios);
  white-space: nowrap;
}

.card-actions .btn-comment:hover {
  background-color: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--line-bright);
}

.card-actions .btn-comment:active {
  transform: scale(0.94);
}

.card-actions .btn-comment svg {
  opacity: 0.75;
}

/* Botón Deshacer en cabecera */
.btn-undo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface-2);
  border-color: var(--line-bright);
  color: var(--text-primary);
  transition: all 0.22s var(--ease-ios);
}

.btn-undo:hover {
  background-color: var(--card-sub);
  border-color: var(--accent);
}

.btn-undo:active {
  transform: scale(0.94);
}

/* Botón permanente de rehacer en la esquina inferior izquierda */
.floating-undo-btn {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  z-index: 9995;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  min-height: 38px;
  border-radius: var(--r-pill);
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line-bright);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  transition: all 0.22s var(--ease-ios);
  user-select: none;
  -webkit-user-select: none;
}

.floating-undo-btn.is-disabled {
  opacity: 0.38;
  cursor: default;
  filter: grayscale(0.6);
  border-color: var(--line);
  color: var(--text-muted);
  box-shadow: none;
}

.floating-undo-btn.is-active {
  opacity: 1;
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-soft);
  animation: tabJellyPop 0.3s var(--ease-spring);
}

.floating-undo-btn.is-active:hover {
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.floating-undo-btn.is-active:active {
  transform: scale(0.94);
}

@media (max-width: 600px) {
  .floating-undo-btn {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: calc(14px + env(safe-area-inset-left, 0px));
    padding: 7px 12px;
    font-size: 12px;
    min-height: 34px;
  }
}

/* Modal de Comentarios para Fuentes_RSS */
.comment-modal .modal-dialog-content {
  max-width: 440px;
}

.comment-field-wrapper {
  margin-bottom: var(--sp-4);
  text-align: left;
}

.comment-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.comment-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background-color: var(--surface-2);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.toast-undo-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 8px;
  border-radius: var(--r-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.2s ease;
}

.toast-undo-btn:hover {
  opacity: 0.8;
}

.toast-undo-btn:active {
  transform: scale(0.95);
}

/* ==========================================================================
   SKELETON LOADING (OLED SHIMMER)
   ========================================================================== */

.skeleton-card {
  height: 420px;
  border-radius: var(--r-xl);
  background: linear-gradient(
    90deg,
    var(--card-bg) 25%,
    var(--card-sub) 37%,
    var(--card-bg) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border: 1px solid var(--line);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ==========================================================================
   ESTADO VACÍO
   ========================================================================== */

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 24px;
  background-color: var(--card-bg);
  border: 1px dashed var(--line-bright);
  border-radius: var(--r-xl);
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-secondary);
  margin-bottom: var(--sp-3);
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   BOTTOM SHEET MODAL (<dialog>) CON GRABBER HANDLE ADAPTATIVO
   ========================================================================== */

dialog.custom-modal {
  padding: 0;
  border: 1px solid var(--line-bright);
  border-radius: var(--r-xl);
  background-color: var(--raised);
  color: var(--text-primary);
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: viewIn 0.26s var(--ease-ios);
}

dialog.custom-modal:not([open]) {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

dialog.custom-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.modal-dialog-content {
  padding: var(--sp-5) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
}

/* Grabber handle característico de iOS */
.modal-dialog-content::before {
  content: '';
  display: block;
  width: 38px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--grabber);
  margin: 0 auto var(--sp-4);
}

.modal-header {
  margin-bottom: var(--sp-4);
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-preview {
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-5);
}

.modal-preview-flex {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.modal-thumb-box {
  width: 58px;
  height: 58px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background-color: var(--surface-3);
  flex-shrink: 0;
  display: none;
}

.modal-thumb-box.has-thumb {
  display: block;
}

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

.modal-preview-info {
  flex: 1;
  min-width: 0;
}

.modal-preview .preview-row {
  font-family: var(--display);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.modal-preview .preview-title {
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  color: var(--text-primary);
}

/* ==========================================================================
   MENÚS DEL MODAL: PASO A PASO (WIZARD iOS LIQUID)
   ========================================================================== */

.modal-step {
  animation: viewIn 0.26s var(--ease-ios);
}

.modal-step.hidden {
  display: none;
}

.step-indicator {
  display: inline-block;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.step-description {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin: 0 0 var(--sp-3);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.menu-title {
  font-family: var(--display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.menu-selected-badge {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background-color: var(--accent);
  color: var(--accent-ink);
  letter-spacing: -0.02em;
}

/* 1. Selector de números en COLUMNA VERTICAL SCROLLABLE */
.slots-vertical-container {
  max-height: 230px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  margin-bottom: var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.slots-vertical-container::-webkit-scrollbar {
  width: 5px;
}

.slots-vertical-container::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: var(--r-pill);
}

.slots-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-item-btn {
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s var(--ease-ios);
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.slot-item-btn:hover {
  background-color: var(--surface-3);
  border-color: var(--line-bright);
}

.slot-item-btn:active {
  transform: scale(0.97);
}

.slot-item-btn.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 12px var(--accent-glow);
  animation: tabJellyPop 0.28s var(--ease-spring);
}

.slot-item-btn .slot-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slot-item-btn .slot-item-badge {
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.6;
}

.slot-item-btn.active .slot-item-badge {
  opacity: 0.9;
}

.slot-item-btn .slot-item-check {
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.slot-item-btn.active .slot-item-check {
  opacity: 1;
}

.slot-item-btn.slot-other {
  border-style: dashed;
  background-color: var(--surface-3);
  margin-top: 4px;
}

.custom-slot-wrapper {
  margin-bottom: var(--sp-4);
  animation: viewIn 0.25s var(--ease-ios);
}

.custom-slot-wrapper.hidden {
  display: none;
}

.custom-slot-input {
  width: 100%;
  height: 46px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-bright);
  background-color: var(--surface-2);
  color: var(--text-primary);
  padding: 0 18px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-slot-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 2. Selector de recorte con Auto por encima de los otros */
.crop-selection-layout {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

/* Tarjeta HERO superior para 'Auto' */
.crop-card-hero {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 18px !important;
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all 0.22s var(--ease-ios);
  gap: 14px !important;
}

.crop-card-hero:active {
  transform: scale(0.97);
}

.crop-card-hero.active {
  background-color: var(--card-sub);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.crop-card-hero .crop-schematic {
  width: 58px !important;
  height: 40px !important;
}

.crop-card-hero .crop-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  flex: 1;
}

.crop-card-hero .crop-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.crop-card-hero .crop-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.crop-card-hero .crop-check-icon {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.crop-card-hero.active .crop-check-icon {
  opacity: 1;
}

.crop-divider-label {
  font-family: var(--display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

/* Fila inferior para izquierda, centro y derecha */
.crop-subgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.crop-card {
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.22s var(--ease-ios);
  user-select: none;
}

.crop-card:active {
  transform: scale(0.94);
}

.crop-card.active {
  background-color: var(--card-sub);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  animation: tabJellyPop 0.28s var(--ease-spring);
}

.crop-card.active .crop-label {
  color: var(--text-primary);
  font-weight: 700;
}

/* Esquemas visuales */
.crop-schematic {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.schematic-screen {
  width: 52px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid var(--line-bright);
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.crop-card.active .schematic-screen {
  border-color: var(--accent);
}

.schematic-zone {
  height: 100%;
  background: var(--accent);
  opacity: 0.85;
  transition: all 0.2s ease;
}

.schematic-left .zone-left {
  width: 45%;
  margin-right: auto;
  border-right: 1px solid var(--bg);
}

.schematic-center .zone-center {
  width: 50%;
  margin: 0 auto;
}

.schematic-right .zone-right {
  width: 45%;
  margin-left: auto;
  border-left: 1px solid var(--bg);
}

.schematic-auto .schematic-lens {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  margin: auto;
  opacity: 0.9;
}

.crop-card.active .schematic-lens {
  border-style: solid;
  background: var(--accent-glow);
}

.crop-label {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: -0.01em;
}

.crop-label strong {
  text-transform: uppercase;
  margin-right: 2px;
  font-family: var(--mono);
}

/* ==========================================================================
   PASO 3: SELECTOR DE DESTINO DE REDES SOCIALES (INSTAGRAM, TIKTOK, AMBAS)
   ========================================================================== */

.platform-selection-layout {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.platform-card-hero {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 18px !important;
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all 0.22s var(--ease-ios);
  gap: 14px !important;
  width: 100%;
}

.platform-card-hero:active {
  transform: scale(0.97);
}

.platform-card-hero.active {
  background-color: var(--card-sub);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.platform-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
}

.platform-plus {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.platform-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

.platform-icon svg {
  width: 100%;
  height: 100%;
}

.platform-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  flex: 1;
}

.platform-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.platform-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.platform-check-icon {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.platform-card.active .platform-check-icon {
  opacity: 1;
}

.platform-subgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.platform-card:not(.platform-card-hero) {
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: all 0.22s var(--ease-ios);
  user-select: none;
  position: relative;
  width: 100%;
}

.platform-card:not(.platform-card-hero):active {
  transform: scale(0.96);
}

.platform-card:not(.platform-card-hero).active {
  background-color: var(--card-sub);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  animation: tabJellyPop 0.28s var(--ease-spring);
}

.platform-card:not(.platform-card-hero) .platform-icon {
  background: var(--surface);
  width: 32px;
  height: 32px;
  padding: 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-soft);
}

.platform-card:not(.platform-card-hero) .platform-check-icon {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

.modal-actions .btn {
  flex: 1;
}

/* ==========================================================================
   TOAST NOTIFICATIONS (LIQUID PILL)
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 400px;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
  border: 1px solid var(--line-bright);
  box-shadow: var(--shadow-lg);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  animation: tabJellyPop 0.3s var(--ease-spring);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-success {
  border-color: var(--green);
}

.toast.toast-error {
  border-color: var(--red);
}

.toast.toast-info {
  border-color: var(--accent);
}

/* ==========================================================================
   RESPONSIVIDAD Y OPTIMIZACIÓN MÓVIL (PWA & SMARTPHONE)
   ========================================================================== */

@keyframes slideUpSheet {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .layout-wrapper {
    padding: max(calc(var(--sp-3) + env(safe-area-inset-top, 0px)), 12px)
             max(12px, env(safe-area-inset-right, 0px))
             max(calc(var(--sp-7) + env(safe-area-inset-bottom, 0px)), 28px)
             max(12px, env(safe-area-inset-left, 0px));
  }

  .site-header {
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-4);
    gap: var(--sp-3);
  }

  .brand-info h1 {
    font-size: 17px;
  }

  .brand-info p {
    font-size: 11px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    width: 100%;
  }

  .header-actions .btn {
    min-height: 40px;
    padding: 0 10px;
    font-size: 12px;
  }

  .header-actions .btn-icon-only {
    grid-column: span 1;
    width: 40px;
    height: 40px;
    margin: 0 auto;
  }

  .toolbar-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
  }

  .search-box-wrapper {
    max-width: 100%;
  }

  .filter-group {
    width: 100%;
    display: flex;
    gap: var(--sp-2);
  }

  .filter-select {
    flex: 1;
    min-height: 42px;
    font-size: 13px;
  }

  .grid-container {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }

  .card-header-thumb {
    aspect-ratio: 16 / 9;
    min-height: 180px;
  }

  .news-card-actions .btn {
    min-height: 44px;
    font-size: 14px;
  }

  /* Bottom-Sheet Nativo iOS para Smartphone */
  dialog.custom-modal[open] {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-top: auto !important;
    margin-bottom: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    max-height: 88vh;
    max-height: 88dvh;
    animation: slideUpSheet 0.32s var(--ease-ios);
  }

  .modal-dialog-content {
    padding: var(--sp-4) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom, 16px));
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .slots-vertical-container {
    max-height: 220px;
  }

  .slot-item-btn {
    height: 46px;
    font-size: 15px;
  }
}

/* ==========================================================================
   OPTIMIZACIONES MODO STANDALONE (APP INSTALADA PWA)
   ========================================================================== */

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .site-header {
    margin-top: env(safe-area-inset-top, 0px);
  }

  .toast-container {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

