/**
 * Tabla Periódica Interactiva - Estilos Corporativos Prémium
 * Fijate Tools • Ciencia y Espacio
 */

:root {
  color-scheme: dark;
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta Tema Oscuro (Midnight Slate) */
  --bg-body: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-hover: #1c273c;
  --bg-input: #0f1623;
  --border-color: #1e293b;
  --border-focus: #00e5ff;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #00e5ff;
  --accent-cyan-glow: rgba(0, 229, 255, 0.25);
  --accent-amber: #ff8507;
  --accent-amber-glow: rgba(255, 133, 7, 0.25);
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;

  /* Estados térmicos */
  --color-phase-solid: #3b82f6;
  --color-phase-liquid: #10b981;
  --color-phase-gas: #f59e0b;
  --color-phase-unknown: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(0, 229, 255, 0.2);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-cyan: #0284c7;
  --accent-cyan-glow: rgba(2, 132, 199, 0.15);
  --accent-amber: #d97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.15);
  --accent-emerald: #059669;
  --accent-purple: #7c3aed;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.15);
}

/* Reset y estructura global para centrado simétrico en monitores 1080p, 2K y 4K */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: clip;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Contenedores con anchos estándar */
.main-wrapper,
.tool-layout,
.app-main {
  width: 100% !important;
  max-width: 1440px !important;
  margin: 0 auto !important;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex: 1 0 auto;
  padding: 1rem clamp(0.75rem, 2vw, 1.5rem) 3rem;
}

.app-container {
  width: 100% !important;
  max-width: 1440px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.header-container {
  max-width: 1440px !important;
  margin: 0 auto !important;
}

/* Desplegables nativos con protección estricta contra desbordamiento */
select, .form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 2.2rem 0.6rem 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select option, .form-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

select:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

/* ========================================================================= */
/* BARRA DE ACCIONES RÁPIDAS (HERO) */
/* ========================================================================= */

.chem-quick-actions-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.btn-action-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.925rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-action-hero:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-action-hero svg {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.badge-pill {
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
}

/* ========================================================================= */
/* PANEL DE CONTROL INTERACTIVO */
/* ========================================================================= */

.chem-control-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-row-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.search-input-wrapper {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

.chem-search-input {
  width: 100%;
  font-family: var(--font-main);
  font-size: 0.9rem;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 2.4rem 0.65rem 2.6rem;
  min-height: 42px;
  transition: all 0.2s;
}

.chem-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.btn-clear-search {
  position: absolute;
  right: 0.65rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-clear-search:hover {
  color: var(--text-main);
  background: var(--border-color);
}

.view-toggles-wrapper {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.btn-view-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
}

.btn-view-toggle:hover {
  color: var(--text-main);
}

.btn-view-toggle.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

/* Slider térmico */
.thermal-slider-section {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.thermal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.thermal-title-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
}

.thermal-display {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.thermal-value-celsius {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-amber);
}

.thermal-value-kelvin {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.thermal-range-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #3b82f6 0%, #10b981 10%, #f59e0b 25%, #ef4444 80%);
  outline: none;
  appearance: none;
  cursor: pointer;
}

.thermal-range-slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent-amber);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s;
}

.thermal-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.thermal-presets-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-thermal-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-thermal-preset span {
  color: var(--text-dim);
  font-size: 0.725rem;
}

.btn-thermal-preset:hover,
.btn-thermal-preset.active {
  background: var(--border-color);
  color: var(--text-main);
  border-color: var(--accent-amber);
}

.phase-legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.phase-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.phase-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.phase-solido { background: var(--color-phase-solid); box-shadow: 0 0 6px rgba(59, 130, 246, 0.6); }
.phase-liquido { background: var(--color-phase-liquid); box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
.phase-gas { background: var(--color-phase-gas); box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.phase-desconocido { background: var(--color-phase-unknown); }

/* Filtros por bloques y familias */
.filters-chips-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.filter-group-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.heatmap-select {
  flex: 1 1 240px;
}

.blocks-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.825rem;
}

.filter-label {
  color: var(--text-dim);
  font-weight: 600;
  margin-right: 0.2rem;
}

.btn-chip-block {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-chip-block:hover,
.btn-chip-block.active {
  background: var(--accent-cyan-glow);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.categories-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn-chip-category {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-chip-category:hover,
.btn-chip-category.active {
  border-color: currentColor;
  color: var(--text-main);
  background: var(--bg-card-hover);
}

/* ========================================================================= */
/* MATRIZ DE LA TABLA PERIÓDICA */
/* ========================================================================= */

.periodic-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: clamp(0.5rem, 1.2vw, 1.25rem);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.periodic-table-header-scroll-notice {
  display: none;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.775rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.periodic-table-scroll-container {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch;
}

.periodic-table-scroll-container::-webkit-scrollbar {
  height: 8px;
}

.periodic-table-scroll-container::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}

.periodic-table-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.periodic-table-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.periodic-table-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, auto));
  gap: clamp(2px, 0.35vw, 4px);
  width: 100%;
  min-width: 0;
}

@media (max-width: 960px) {
  .periodic-table-grid {
    grid-template-columns: repeat(18, minmax(54px, 1fr));
    min-width: 980px;
  }
  .periodic-table-header-scroll-notice {
    display: flex;
  }
}

/* Casilla del elemento */
.element-cell {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: clamp(2px, 0.3vw, 4px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
  min-height: clamp(48px, 5.2vw, 68px);
  min-width: 0;
  overflow: hidden;
}

.element-cell:hover {
  transform: translateY(-2px) scale(1.04);
  z-index: 10;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  border-color: var(--border-focus);
}

.element-cell.dimmed {
  opacity: 0.15;
  filter: grayscale(80%);
  pointer-events: none;
}

.element-cell.highlighted {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  transform: scale(1.05);
  z-index: 5;
}

.cell-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  line-height: 1;
}

.cell-atomic-num {
  font-family: var(--font-mono);
  font-size: clamp(0.55rem, 0.75vw, 0.68rem);
  color: #cbd5e1;
  font-weight: 700;
}

.cell-phase-dot {
  width: clamp(4px, 0.5vw, 6px);
  height: clamp(4px, 0.5vw, 6px);
  border-radius: 50%;
  flex-shrink: 0;
}

.cell-symbol {
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 1.35vw, 1.25rem);
  font-weight: 800;
  text-align: center;
  line-height: 1;
  color: #ffffff;
  margin: 1px 0;
}

.cell-bottom-row {
  text-align: center;
  line-height: 1.1;
  overflow: hidden;
}

.cell-name {
  font-size: clamp(0.48rem, 0.65vw, 0.62rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f1f5f9;
  font-weight: 600;
}

.cell-mass-or-val {
  font-family: var(--font-mono);
  font-size: clamp(0.44rem, 0.55vw, 0.58rem);
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

/* Modo Mapa de Calor: Letras en negro de alto contraste sobre fondos de color */
.element-cell.is-heatmap {
  color: #000000 !important;
}

.element-cell.is-heatmap .cell-symbol {
  color: #000000 !important;
  font-weight: 900 !important;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}

.element-cell.is-heatmap .cell-atomic-num {
  color: #000000 !important;
  font-weight: 800 !important;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}

.element-cell.is-heatmap .cell-name {
  color: #000000 !important;
  font-weight: 800 !important;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}

.element-cell.is-heatmap .cell-mass-or-val {
  color: #000000 !important;
  font-weight: 800 !important;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}

.element-cell.is-heatmap .cell-phase-dot {
  border: 1.5px solid rgba(0, 0, 0, 0.5);
}

/* Tema Claro */
[data-theme="light"] .element-cell:not(.is-heatmap) .cell-symbol {
  color: #0f172a;
}
[data-theme="light"] .element-cell:not(.is-heatmap) .cell-atomic-num {
  color: #0f172a;
  font-weight: 700;
}
[data-theme="light"] .element-cell:not(.is-heatmap) .cell-name {
  color: #0f172a;
  font-weight: 700;
}
[data-theme="light"] .element-cell:not(.is-heatmap) .cell-mass-or-val {
  color: #334155;
  font-weight: 700;
}

/* Celdas especiales de enlace a lantánidos y actínidos */
.series-marker-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.series-marker-cell strong {
  font-size: 0.75rem;
  color: var(--text-main);
}

/* Espaciador entre tabla y f-block */
.grid-row-gap {
  grid-column: 1 / span 18;
  height: 14px;
}

/* ========================================================================= */
/* VISTA EN CUADRÍCULA DE TARJETAS */
/* ========================================================================= */

.cards-view-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.element-card-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.element-card-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-md);
}

.card-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-item-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.card-item-symbol {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.card-item-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-item-cat {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  width: fit-content;
  font-weight: 600;
}

.card-item-props {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.725rem;
  color: var(--text-dim);
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-color);
}

/* Estado vacío */
.chem-empty-state {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.chem-empty-state h3 {
  font-size: 1.15rem;
}

.chem-empty-state p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ========================================================================= */
/* MODALES */
/* ========================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.btn-modal-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-modal-nav:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--accent-cyan);
}

.modal-element-title-wrap {
  text-align: center;
}

.modal-element-heading {
  font-size: 1.35rem;
  line-height: 1.2;
}

.modal-element-category-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  display: inline-block;
  margin-top: 2px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-close-modal:hover {
  color: var(--text-main);
  background: var(--border-color);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Ficha del Elemento (Hero & Bohr Model) */
.element-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: center;
}

@media (max-width: 580px) {
  .element-hero-grid {
    grid-template-columns: 1fr;
  }
}

.element-big-tile {
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
}

.big-tile-number {
  position: absolute;
  top: 0.75rem;
  left: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.big-tile-symbol {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  margin: 0.5rem 0;
  color: var(--text-main);
}

.big-tile-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.big-tile-mass {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.bohr-model-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.bohr-canvas-wrap {
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bohr-electrons-info {
  text-align: center;
  margin-top: 0.4rem;
}

.bohr-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.bohr-shells {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Matriz de propiedades */
.section-subtitle {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.properties-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
}

.prop-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prop-full {
  grid-column: 1 / -1;
}

.prop-label {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.prop-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Tarjeta divulgativa */
.fact-card-box {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.fact-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
}

.fact-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.fact-content {
  flex: 1 1 0%;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.fact-content strong {
  display: block;
  font-size: 0.825rem;
  color: var(--text-main);
  margin-bottom: 2px;
}

.fact-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ========================================================================= */
/* SUITE DE TEST Y RETOS */
/* ========================================================================= */

.modal-quiz-card {
  max-width: 640px;
}

.quiz-lead-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quiz-options-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quiz-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.quiz-mode-selector,
.quiz-difficulty-selector {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.btn-mode-select,
.btn-diff-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-mode-select strong,
.btn-diff-select strong {
  font-size: 0.9rem;
  color: var(--text-main);
}

.btn-mode-select span,
.btn-diff-select span {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.btn-mode-select:hover,
.btn-diff-select:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-mode-select.active,
.btn-diff-select.active {
  background: var(--accent-cyan-glow);
  border-color: var(--accent-cyan);
}

.btn-mode-select.active strong,
.btn-diff-select.active strong {
  color: var(--accent-cyan);
}

.quiz-action-start {
  margin-top: 0.5rem;
}

.btn-start-game {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

/* Arena de juego */
.quiz-hud {
  display: flex;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.675rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}

.hud-accent {
  color: var(--accent-cyan);
}

.quiz-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--accent-cyan), var(--accent-emerald));
  transition: width 0.3s ease;
}

.quiz-question-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.quiz-question-badge {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: var(--accent-cyan-glow);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
}

.quiz-question-text {
  font-size: 1.2rem;
  line-height: 1.35;
}

.quiz-answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 500px) {
  .quiz-answers-grid {
    grid-template-columns: 1fr;
  }
}

.btn-quiz-answer {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.925rem;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-quiz-answer:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.btn-quiz-answer.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: var(--accent-emerald) !important;
  color: var(--accent-emerald) !important;
}

.btn-quiz-answer.incorrect {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}

.quiz-feedback-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  text-align: center;
}

.feedback-icon {
  font-size: 1.5rem;
}

.feedback-text-wrap h4 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.feedback-text-wrap p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Pantalla de resultados */
.result-celebration {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.result-trophy {
  font-size: 3rem;
  line-height: 1;
}

.result-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.result-metric-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-num {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.result-actions button {
  flex: 1 1 0%;
}

/* ========================================================================= */
/* CALCULADORA DE MASA MOLAR */
/* ========================================================================= */

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

.molar-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.molar-input-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.molar-input-row {
  display: flex;
  gap: 0.5rem;
}

.molar-formula-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
}

.molar-formula-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.molar-sample-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--text-dim);
}

.btn-sample-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sample-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--accent-emerald);
}

.molar-results-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.molar-total-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
}

.molar-total-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-emerald);
}

.molar-total-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.molar-breakdown-title {
  font-size: 0.95rem;
}

.molar-bar-chart {
  display: flex;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.molar-bar-segment {
  height: 100%;
  transition: width 0.3s ease;
  position: relative;
}

.molar-table-wrap {
  overflow-x: auto;
}

.molar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.molar-table th,
.molar-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.molar-table th {
  color: var(--text-dim);
  font-size: 0.725rem;
  text-transform: uppercase;
}

.molar-table td {
  font-family: var(--font-mono);
}

/* ========================================================================= */
/* COMPARADOR 1 VS 1 */
/* ========================================================================= */

.compare-selectors-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-end;
  gap: 0.75rem;
}

.compare-select-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.compare-select-box label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.compare-vs-pill {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.85rem;
  background: var(--accent-amber);
  color: #000;
  padding: 0.4rem 0.65rem;
  border-radius: 20px;
  margin-bottom: 4px;
}

.compare-results-matrix {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.825rem;
}

.compare-val-a {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
}

.compare-metric-name {
  text-align: center;
  font-size: 0.725rem;
  color: var(--text-dim);
  font-weight: 600;
}

.compare-val-b {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-amber);
}

/* ========================================================================= */
/* COMPARTIR SOCIAL */
/* ========================================================================= */

.share-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.btn-share-social {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  color: #ffffff;
  transition: opacity 0.2s;
  min-height: 40px;
}

.btn-share-social:hover {
  opacity: 0.9;
}

.btn-whatsapp { background: #25d366; }
.btn-telegram { background: #0088cc; }
.btn-twitter { background: #000000; border: 1px solid var(--border-color); }

.share-copy-link-wrap {
  display: flex;
  gap: 0.5rem;
}

.share-url-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

/* ========================================================================= */
/* BOTONES GENERALES */
/* ========================================================================= */

.btn-primary {
  background: var(--accent-cyan);
  color: #000000;
  border: none;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

/* ========================================================================= */
/* ADAPTACIÓN MÓVIL Y RESPONSIVE */
/* ========================================================================= */

@media (max-width: 768px) {
  .app-main {
    padding: 0.75rem 0.5rem 2rem 0.5rem;
  }

  .chem-quick-actions-bar {
    grid-template-columns: 1fr;
  }

  .btn-action-hero {
    width: 100%;
  }

  .chem-control-panel {
    padding: 0.85rem;
    gap: 1rem;
  }

  .control-row-main {
    flex-direction: column;
    align-items: stretch;
  }

  .view-toggles-wrapper {
    width: 100%;
  }

  .btn-view-toggle {
    flex: 1 1 0%;
    justify-content: center;
  }

  .thermal-presets-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .periodic-table-wrapper {
    padding: 0.75rem 0.5rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }

  .nav-elem-text {
    display: none;
  }

  .molar-input-row {
    flex-direction: column;
  }

  .molar-input-row button {
    width: 100%;
  }

  .share-buttons-grid {
    grid-template-columns: 1fr;
  }

  .share-copy-link-wrap {
    flex-direction: column;
  }

  .share-copy-link-wrap button {
    width: 100%;
  }
}
