:root {
  --bg: #07090e;
  --bg-panel: rgba(14, 19, 32, 0.85);
  --bg-panel-2: rgba(22, 30, 50, 0.7);
  --bg-panel-solid: #0e1320;
  --text: #f0f4fc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: #00f0ff;
  --accent: #00f0ff;
  --accent-glow: rgba(0, 240, 255, 0.35);

  /* Categorías químicas */
  --c-alcalino: #ff5376;
  --c-alcalinoterreo: #ff9e44;
  --c-transicion: #ffd166;
  --c-post-transicion: #a6e22e;
  --c-metaloide: #06d6a0;
  --c-no-metal: #38bdf8;
  --c-halogeno: #818cf8;
  --c-noble: #d946ef;
  --c-lantanido: #f472b6;
  --c-actinido: #c084fc;
  --c-desconocido: #94a3b8;

  /* Bloques */
  --c-block-s: #ff5376;
  --c-block-p: #38bdf8;
  --c-block-d: #ffd166;
  --c-block-f: #c084fc;

  /* Fases */
  --c-phase-solido: #38bdf8;
  --c-phase-liquido: #fbbf24;
  --c-phase-gas: #d946ef;
  --c-phase-sintetico: #94a3b8;

  /* Superficies y estados (tema oscuro por defecto) */
  --surface-header: rgba(10, 14, 25, 0.85);
  --surface-toolbar: rgba(14, 19, 32, 0.6);
  --surface-legend: rgba(10, 14, 25, 0.4);
  --surface-footer: rgba(10, 14, 25, 0.7);
  --surface-float: rgba(10, 14, 25, 0.95);
  --surface-info: rgba(12, 17, 30, 0.5);
  --btn-float: rgba(14, 20, 35, 0.7);
  --overlay: rgba(4, 6, 12, 0.88);
  --well: rgba(0, 0, 0, 0.25);
  --hover-bg: rgba(255, 255, 255, 0.08);
  --cell-border: rgba(255, 255, 255, 0.15);
  --text-body: #d1d5db;
  --text-neutron: #cbd5e1;
  --proton: #ff5376;
  --danger-text: #ff859d;
  --accent-contrast: #07090e;
  --shadow-strong: rgba(0, 0, 0, 0.7);
  --shadow-soft: rgba(0, 0, 0, 0.45);
  --orb-opacity: 0.22;
  color-scheme: dark;
}

/* Tema claro: por preferencia del sistema o elegido con el botón */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f8;
    --bg-panel: rgba(255, 255, 255, 0.92);
    --bg-panel-2: rgba(255, 255, 255, 0.8);
    --bg-panel-solid: #ffffff;
    --text: #0f172a;
    --text-dim: #475569;
    --text-muted: #5b6b82;
    --border: rgba(15, 23, 42, 0.12);
    --border-focus: #0e7490;
    --accent: #0e7490;
    --accent-glow: rgba(14, 116, 144, 0.25);
    --surface-header: rgba(255, 255, 255, 0.85);
    --surface-toolbar: rgba(255, 255, 255, 0.6);
    --surface-legend: rgba(255, 255, 255, 0.45);
    --surface-footer: rgba(255, 255, 255, 0.75);
    --surface-float: rgba(255, 255, 255, 0.97);
    --surface-info: rgba(248, 250, 252, 0.85);
    --btn-float: rgba(255, 255, 255, 0.85);
    --overlay: rgba(15, 23, 42, 0.55);
    --well: rgba(15, 23, 42, 0.05);
    --hover-bg: rgba(15, 23, 42, 0.06);
    --cell-border: rgba(15, 23, 42, 0.14);
    --text-body: #334155;
    --text-neutron: #64748b;
    --proton: #e11d48;
    --danger-text: #be123c;
    --accent-contrast: #ffffff;
    --shadow-strong: rgba(15, 23, 42, 0.18);
    --shadow-soft: rgba(15, 23, 42, 0.12);
    --orb-opacity: 0.1;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef2f8;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-panel-2: rgba(255, 255, 255, 0.8);
  --bg-panel-solid: #ffffff;
  --text: #0f172a;
  --text-dim: #475569;
  --text-muted: #5b6b82;
  --border: rgba(15, 23, 42, 0.12);
  --border-focus: #0e7490;
  --accent: #0e7490;
  --accent-glow: rgba(14, 116, 144, 0.25);
  --surface-header: rgba(255, 255, 255, 0.85);
  --surface-toolbar: rgba(255, 255, 255, 0.6);
  --surface-legend: rgba(255, 255, 255, 0.45);
  --surface-footer: rgba(255, 255, 255, 0.75);
  --surface-float: rgba(255, 255, 255, 0.97);
  --surface-info: rgba(248, 250, 252, 0.85);
  --btn-float: rgba(255, 255, 255, 0.85);
  --overlay: rgba(15, 23, 42, 0.55);
  --well: rgba(15, 23, 42, 0.05);
  --hover-bg: rgba(15, 23, 42, 0.06);
  --cell-border: rgba(15, 23, 42, 0.14);
  --text-body: #334155;
  --text-neutron: #64748b;
  --proton: #e11d48;
  --danger-text: #be123c;
  --accent-contrast: #ffffff;
  --shadow-strong: rgba(15, 23, 42, 0.18);
  --shadow-soft: rgba(15, 23, 42, 0.12);
  --orb-opacity: 0.1;
  color-scheme: light;
}

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

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ================= AMBIENT BACKGROUND GLOW ================= */
.ambient-glow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: var(--orb-opacity);
}
.orb-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #00f0ff, transparent 70%);
  top: -120px;
  left: 10%;
  animation: floatOrb 22s ease-in-out infinite alternate;
}
.orb-2 {
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, #ff007a, transparent 70%);
  top: 40%;
  right: -100px;
  animation: floatOrb 28s ease-in-out infinite alternate-reverse;
}
.orb-3 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #7000ff, transparent 70%);
  bottom: -150px;
  left: 20%;
  animation: floatOrb 25s ease-in-out infinite alternate;
}
@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.12); }
}

/* ================= HEADER ================= */
.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 28px;
  background: var(--surface-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}
.brand-icon {
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.4));
  transition: transform 0.3s ease;
}
.brand-link:hover .brand-icon {
  transform: rotate(20deg) scale(1.05);
}
.brand-title-group h1 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.accent-gradient {
  background: linear-gradient(135deg, #00f0ff 0%, #d946ef 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
#searchInput {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 36px 8px 36px;
  border-radius: 24px;
  font-size: 0.88rem;
  font-family: inherit;
  width: 280px;
  outline: none;
  transition: all 0.2s ease;
}
#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  width: 320px;
  background: var(--bg-panel-solid);
}
#searchInput::placeholder {
  color: var(--text-muted);
}
.clear-search-btn {
  position: absolute;
  right: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  line-height: 1;
  padding: 2px 6px;
}
.clear-search-btn:hover {
  color: var(--text);
}
.search-shortcut {
  position: absolute;
  right: 12px;
  background: var(--hover-bg);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

/* Color Mode Selector */
.color-mode-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.control-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.custom-select {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.custom-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.custom-select option {
  background: var(--bg-panel-solid);
  color: var(--text);
}

/* ================= FILTER TOOLBAR ================= */
.filter-toolbar {
  position: relative;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 28px;
  background: var(--surface-toolbar);
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-buttons {
  display: flex;
  gap: 4px;
  background: var(--well);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.filter-chip {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.filter-chip:hover {
  color: var(--text);
  background: var(--hover-bg);
}
.filter-chip.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  box-shadow: 0 0 10px var(--accent-glow);
}
.chip-block-s.active { background: var(--c-block-s); color: #07090e; box-shadow: 0 0 10px rgba(255, 83, 118, 0.4); }
.chip-block-p.active { background: var(--c-block-p); color: #07090e; box-shadow: 0 0 10px rgba(56, 189, 248, 0.4); }
.chip-block-d.active { background: var(--c-block-d); color: #07090e; box-shadow: 0 0 10px rgba(255, 209, 102, 0.4); }
.chip-block-f.active { background: var(--c-block-f); color: #07090e; box-shadow: 0 0 10px rgba(192, 132, 252, 0.4); }

.filter-status {
  display: flex;
  align-items: center;
  gap: 12px;
}
.elements-counter {
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  background: var(--bg-panel-2);
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.reset-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 83, 118, 0.15);
  color: var(--danger-text);
  border: 1px solid rgba(255, 83, 118, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.reset-btn:hover {
  background: rgba(255, 83, 118, 0.3);
  color: var(--text);
}

/* ================= LEGEND ================= */
.legend {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 28px;
  font-size: 0.74rem;
  color: var(--text-dim);
  background: var(--surface-legend);
}
.legend-item {
  background: transparent;
  color: inherit;
  font-size: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}
.legend-item:hover {
  background: var(--bg-panel-2);
  border-color: var(--border);
  color: var(--text);
}
.legend-item.active-filter {
  background: var(--bg-panel-2);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 8px var(--accent-glow);
}
.legend-item.disabled {
  opacity: 0.3;
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Heatmap Scale Bar */
.heatmap-scale-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 28px;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface-legend);
}
.scale-gradient-track {
  flex: 1;
  max-width: 320px;
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ================= TABLE WRAPPER & PERIODIC GRID ================= */
.table-wrapper {
  position: relative;
  z-index: 5;
  width: 100%;
  overflow-x: auto;
  padding: 16px 20px 36px;
  -webkit-overflow-scrolling: touch;
}
.table-container {
  display: grid;
  grid-template-columns: 24px auto;
  grid-template-rows: 24px auto;
  gap: 6px 8px;
  min-width: 980px;
  max-width: 1460px;
  margin: 0 auto;
}

/* Column (Group) Headers 1-18 */
.group-numbers-header {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(18, minmax(46px, 1fr));
  gap: 4px;
}
.group-num-label {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  user-select: none;
}

/* Row (Period) Labels 1-7 */
.period-numbers-sidebar {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(10, minmax(48px, 1fr));
  gap: 4px;
}
.period-num-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  user-select: none;
}

/* Main 18x10 Grid */
.periodic-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(18, minmax(46px, 1fr));
  grid-template-rows: repeat(10, minmax(48px, 1fr));
  gap: 4px;
}

/* Element Cell */
.element-cell,
.placeholder-cell,
.legend-item {
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  text-align: inherit;
}
.element-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px 5px;
  color: #07090e;
  font-weight: 600;
  border: 1px solid var(--cell-border);
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.18s ease, filter 0.18s ease, opacity 0.2s;
  user-select: none;
  overflow: hidden;
  box-shadow: 0 2px 6px var(--shadow-soft);
}
.element-cell:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--bg), 0 0 18px var(--accent-glow);
  z-index: 21;
}
.element-cell:hover {
  transform: translateY(-4px) scale(1.14);
  box-shadow: 0 10px 24px var(--shadow-strong), 0 0 16px var(--accent-glow);
  z-index: 20;
  filter: brightness(1.18);
  border-color: #fff;
}
.element-cell.dimmed {
  opacity: 0.2;
  filter: grayscale(0.85);
  box-shadow: none;
}
.element-cell.dimmed:hover {
  transform: none;
  opacity: 0.45;
}
.element-cell.highlighted {
  border-color: #fff;
  box-shadow: 0 0 16px #fff;
  z-index: 10;
}

/* Cell Top Row: Number & Weight */
.cell-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}
.element-cell .num {
  font-size: 0.64rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  opacity: 0.85;
  line-height: 1;
}
.element-cell .mass-sub {
  font-size: 0.52rem;
  font-weight: 500;
  opacity: 0.7;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

/* Cell Center Symbol */
.element-cell .sym {
  font-size: 1.12rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  line-height: 1;
  letter-spacing: -0.5px;
  margin: 1px 0;
}

/* Cell Bottom Name */
.element-cell .nm {
  font-size: 0.56rem;
  font-weight: 600;
  opacity: 0.9;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

/* Placeholder for Lanthanides & Actinides */
.placeholder-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.62rem;
  color: var(--text-dim);
  font-weight: 700;
  background: var(--well);
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.placeholder-cell:hover {
  background: var(--bg-panel-2);
  border-color: var(--accent);
  color: var(--accent);
}
.placeholder-cell .ph-range {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  color: var(--text-muted);
}

/* Categorías Colores de Fondo */
.cat-alcalino { background: var(--c-alcalino); }
.cat-alcalinoterreo { background: var(--c-alcalinoterreo); }
.cat-transicion { background: var(--c-transicion); }
.cat-post-transicion { background: var(--c-post-transicion); }
.cat-metaloide { background: var(--c-metaloide); }
.cat-no-metal { background: var(--c-no-metal); }
.cat-halogeno { background: var(--c-halogeno); }
.cat-noble { background: var(--c-noble); }
.cat-lantanido { background: var(--c-lantanido); }
.cat-actinido { background: var(--c-actinido); }
.cat-desconocido { background: var(--c-desconocido); }

/* Bloques Colores */
.block-s { background: var(--c-block-s); color: #07090e; }
.block-p { background: var(--c-block-p); color: #07090e; }
.block-d { background: var(--c-block-d); color: #07090e; }
.block-f { background: var(--c-block-f); color: #07090e; }

/* Fases Colores */
.phase-solido { background: var(--c-phase-solido); color: #07090e; }
.phase-liquido { background: var(--c-phase-liquido); color: #07090e; }
.phase-gas { background: var(--c-phase-gas); color: #07090e; }
.phase-sintetico { background: var(--c-phase-sintetico); color: #07090e; }

/* ================= HOVER MICRO-TOOLTIP ================= */
.element-quick-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text);
  box-shadow: 0 10px 25px var(--shadow-strong), 0 0 12px var(--accent-glow);
  transform: translate(-50%, -125%);
  transition: opacity 0.15s ease;
  white-space: nowrap;
}
.tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}
.tooltip-meta {
  color: var(--text-dim);
  font-size: 0.7rem;
  margin-top: 2px;
}

/* ================= FOOTER ================= */
.app-footer {
  position: relative;
  z-index: 5;
  border-top: 1px solid var(--border);
  background: var(--surface-footer);
  padding: 16px 28px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1460px;
  margin: 0 auto;
}
.footer-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tip-badge {
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.footer-tip kbd {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text);
}
.footer-links {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ================= MODAL DIALOG ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}

.modal {
  position: relative;
  width: min(1140px, 100%);
  max-height: 92vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--shadow-strong), 0 0 30px rgba(0, 240, 255, 0.15);
  animation: modalScaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content {
  display: flex;
  flex-direction: row;
  height: 100%;
  max-height: 92vh;
}

/* Modal Left: 3D Viewer Pane */
.viewer-pane {
  /* El visor 3D es siempre oscuro, también con el tema claro */
  --text: #f0f4fc;
  --text-dim: #94a3b8;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #00f0ff;
  --accent-glow: rgba(0, 240, 255, 0.35);
  --accent-contrast: #07090e;
  color: var(--text);
  position: relative;
  flex: 1 1 50%;
  min-width: 0;
  background: radial-gradient(circle at 50% 45%, #141b2e 0%, #080b14 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}
.atom-canvas-container {
  width: 100%;
  height: 100%;
  min-height: 420px;
  cursor: grab;
}
.atom-canvas-container:active {
  cursor: grabbing;
}
.atom-canvas-container canvas {
  display: block;
}

/* 3D Viewer Controls Overlay */
.viewer-controls-overlay {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}
.viewer-btn {
  background: rgba(14, 20, 35, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.15s ease;
}
.viewer-btn:hover {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.viewer-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(7, 10, 18, 0.7);
  backdrop-filter: blur(6px);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  pointer-events: none;
  white-space: nowrap;
}

.shell-info {
  position: absolute;
  top: 14px;
  left: 14px;
  max-width: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text);
  background: rgba(7, 10, 18, 0.7);
  backdrop-filter: blur(6px);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  line-height: 1.5;
  font-family: 'JetBrains Mono', monospace;
}

/* Modal Right: Information Pane */
.info-pane {
  flex: 1 1 50%;
  min-width: 0;
  padding: 28px 32px;
  overflow-y: auto;
  background: var(--surface-info);
}

/* Custom Scrollbar for Modal Info */
.info-pane::-webkit-scrollbar {
  width: 6px;
}
.info-pane::-webkit-scrollbar-track {
  background: transparent;
}
.info-pane::-webkit-scrollbar-thumb {
  background: var(--cell-border);
  border-radius: 3px;
}

/* Heading */
.element-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}
.big-symbol {
  font-size: 2.8rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  width: 82px;
  height: 82px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #07090e;
  flex-shrink: 0;
  box-shadow: 0 8px 24px var(--shadow-soft);
}
.heading-text {
  flex: 1;
  min-width: 0;
}
.heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.heading-text h2 {
  margin: 0 0 4px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.atomic-number-badge {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  background: rgba(0, 240, 255, 0.1);
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  flex-shrink: 0;
}
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.category-tag, .block-tag, .phase-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.share-btn {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Particle Counts */
.particle-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.particle-count {
  text-align: center;
  padding: 12px 6px;
  border-radius: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.particle-count:hover {
  transform: translateY(-2px);
}
.particle-count .count-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.2;
}
.particle-count.protons .count-value { color: var(--proton); text-shadow: 0 0 10px rgba(255, 83, 118, 0.4); }
.particle-count.neutrons .count-value { color: var(--text-neutron); }
.particle-count.electrons .count-value { color: var(--accent); text-shadow: 0 0 10px var(--accent-glow); }
.particle-count .count-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Data Grid */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin-bottom: 20px;
}
.data-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.data-item.wide {
  grid-column: 1 / -1;
}
.data-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.data-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.config-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  color: var(--accent);
  word-break: break-word;
}
.label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.data-value-inline {
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}

/* Electronegativity Gauge */
.gauge-track {
  width: 100%;
  height: 6px;
  background: var(--hover-bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #00f0ff, #ff007a);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Summary Section */
.summary-section {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.summary-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.element-summary {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-body);
  margin: 0;
}

/* Modal Close & Navigation Buttons */
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 100;
  background: var(--btn-float);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s ease;
}
.modal-close:hover {
  background: rgba(255, 83, 118, 0.3);
  color: var(--text);
  border-color: #ff5376;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  background: rgba(14, 20, 35, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.nav-btn:hover {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}
.nav-prev { left: 14px; }
.nav-next { right: 62px; }
.nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* ================= TOAST NOTIFICATION ================= */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  background: var(--surface-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px var(--shadow-strong), 0 0 16px var(--accent-glow);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* ================= UTILITY & ACCESSIBILITY ================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Las celdas estrechas no tienen espacio para la masa atómica */
@media (max-width: 1200px) {
  .element-cell .mass-sub { display: none; }
}

/* ================= MOVIMIENTO REDUCIDO ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .glow-orb { animation: none; }
  .element-cell:hover { transform: none; }
}

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 1024px) {
  .app-header { padding: 14px 20px; }
  .filter-toolbar { padding: 10px 20px; }
  .legend { padding: 8px 20px; }
}

@media (max-width: 900px) {
  .modal-content {
    flex-direction: column;
    overflow-y: auto;
  }
  .viewer-pane {
    min-height: 320px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .info-pane {
    padding: 20px 22px 36px;
  }
  .viewer-controls-overlay {
    top: 62px;
  }
  .modal {
    max-height: 94vh;
  }
}

@media (max-width: 680px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }
  .header-brand {
    justify-content: center;
  }
  .header-controls {
    width: 100%;
  }
  .search-box,
  .color-mode-select-wrap {
    flex-basis: 100%;
  }
  .quiz-btn {
    flex: 1;
    justify-content: center;
  }
  #searchInput {
    width: 100% !important;
  }
  .color-mode-select-wrap {
    width: 100%;
    justify-content: space-between;
  }
  .custom-select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .filter-buttons {
    min-width: 0;
    max-width: 100%;
  }

  .filter-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px;
  }
  .filter-group {
    justify-content: space-between;
    min-width: 0;
    max-width: 100%;
  }
  .filter-buttons {
    overflow-x: auto;
  }

  .periodic-grid {
    grid-template-columns: repeat(18, minmax(36px, 1fr));
    grid-template-rows: repeat(10, minmax(38px, 1fr));
    gap: 3px;
  }
  .table-container {
    min-width: 740px;
  }
  .element-cell .sym { font-size: 0.92rem; }
  .element-cell .nm { display: none; }
  .element-cell .num { font-size: 0.5rem; }
  .element-cell .mass-sub { display: none; }

  .modal-overlay { padding: 0; }
  .modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .modal-content { max-height: 100vh; }
  .big-symbol { width: 62px; height: 62px; font-size: 2.1rem; }
  .heading-text h2 { font-size: 1.3rem; }
  .atomic-number-badge { font-size: 0.95rem; }
  .particle-count .count-value { font-size: 1.2rem; }
  .data-grid { grid-template-columns: 1fr; }
}

.bohr-2d {
  width: 100%;
  height: 100%;
  max-height: 520px;
  color: var(--text-dim);
}

/* ================= POSICIÓN EN LA REJILLA Y ENTRADA ================= */
.element-cell,
.placeholder-cell {
  grid-row: var(--row);
  grid-column: var(--col);
}
.element-cell {
  animation: cellIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  animation-delay: var(--delay, 0ms);
}
@keyframes cellIn {
  from { opacity: 0; transform: translateY(10px) scale(0.85); }
  to { opacity: 1; transform: none; }
}

/* ================= PANEL DE VISTA PREVIA ================= */
.preview-panel {
  grid-row: 1 / 4;
  grid-column: 3 / 13;
  align-self: stretch;
  margin: 2px 10px 10px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px var(--shadow-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 0;
  overflow: hidden;
}
.pv-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.pv-empty-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}
.pv-tile {
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: 0 8px 24px var(--shadow-soft);
  animation: pvIn 0.2s ease;
}
.pv-num {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 0.85rem;
  font-weight: 700;
}
.pv-sym {
  font-size: 2.9rem;
  font-weight: 800;
  line-height: 1;
}
.pv-mass {
  position: absolute;
  bottom: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.8;
}
.pv-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pv-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.pv-tags {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}
.pv-config {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
}
.pv-metric {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.pv-metric strong {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
@keyframes pvIn {
  from { opacity: 0.4; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 1100px) {
  .pv-tile { width: 88px; height: 88px; }
  .pv-sym { font-size: 2.2rem; }
  .pv-name { font-size: 1.2rem; }
  .pv-empty { font-size: 0.74rem; }
}
@media (max-width: 680px) {
  .preview-panel { display: none; }
}

sup {
  font-size: 0.7em;
  line-height: 0;
}

/* ================= LEYENDA ================= */
.legend-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* ================= BOTÓN DE TEMA ================= */
.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.theme-toggle .icon-moon,
.theme-toggle[data-current="dark"] .icon-sun { display: block; }
.theme-toggle .icon-sun,
.theme-toggle[data-current="dark"] .icon-moon { display: none; }
.theme-toggle[data-current="light"] .icon-moon { display: block; }

.tooltip-symbol {
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

/* ================= CAPAS DE BOHR EN EL VISOR ================= */
.shell-info-title {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 700;
}
.shell-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.shell-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--shell) 45%, transparent);
  background: color-mix(in srgb, var(--shell) 12%, transparent);
}
.shell-chip strong {
  color: var(--shell);
}
.shell-chip.valence {
  border-color: var(--shell);
  box-shadow: 0 0 8px color-mix(in srgb, var(--shell) 50%, transparent);
}

/* ================= BOTONES PEQUEÑOS ================= */
.mini-btn {
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.mini-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.mini-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.mini-btn.primary:hover:not(:disabled) {
  color: var(--accent-contrast);
  box-shadow: 0 0 10px var(--accent-glow);
}
.mini-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ================= TEMPERATURA ================= */
.temperature-group input[type="range"] {
  width: 180px;
  accent-color: var(--accent);
  cursor: pointer;
}
.temperature-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: var(--text);
  min-width: 128px;
}

/* ================= VISTA DE LISTA ================= */
.table-container.list-mode {
  min-width: 0;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
}
.table-container.list-mode .group-numbers-header,
.table-container.list-mode .period-numbers-sidebar {
  display: none;
}
.table-container.list-mode .periodic-grid {
  grid-column: 1;
  grid-row: 1;
}
.periodic-grid.list-view {
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  grid-template-rows: none;
  grid-auto-rows: 78px;
  gap: 6px;
}
.periodic-grid.list-view .element-cell {
  grid-row: auto;
  grid-column: auto;
  animation-delay: 0ms;
}
.periodic-grid.list-view .preview-panel,
.periodic-grid.list-view .placeholder-cell {
  display: none;
}
.periodic-grid.list-view .element-cell .sym { font-size: 1.35rem; }
.periodic-grid.list-view .element-cell .nm { display: block; font-size: 0.62rem; }
.periodic-grid.list-view .element-cell .mass-sub { display: inline; }

/* ================= QUIZ ================= */
.quiz-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.quiz-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.quiz-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.quiz-bar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 12px 28px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--surface-toolbar);
  border-bottom: 1px solid var(--border);
}
.quiz-bar[hidden] { display: none; }
.quiz-question {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.25rem;
}
.quiz-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.quiz-question strong {
  font-weight: 800;
  color: var(--accent);
}
.quiz-score {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.quiz-score strong {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.quiz-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.quiz-hint {
  flex-basis: 100%;
  font-size: 0.72rem;
  color: var(--text-muted);
}
body.quiz-mode .element-cell .nm,
body.quiz-mode .element-cell .mass-sub,
body.quiz-mode .element-cell .num,
body.quiz-mode .preview-panel {
  visibility: hidden;
}
.element-cell.quiz-correct { animation: quizGood 0.7s ease; }
.element-cell.quiz-wrong { animation: quizBad 0.5s ease; }
.element-cell.quiz-reveal {
  outline: 3px solid #22c55e;
  outline-offset: 2px;
  animation: quizPulse 1s ease-in-out infinite;
  z-index: 15;
}
@keyframes quizGood {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.9); transform: scale(1.15); }
  100% { box-shadow: 0 0 0 14px rgba(34, 197, 94, 0); transform: none; }
}
@keyframes quizBad {
  0%, 100% { transform: none; }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
  50% { box-shadow: 0 0 0 3px #ef4444; }
}
@keyframes quizPulse {
  50% { transform: scale(1.08); }
}

/* ================= FICHA: EXTRAS ================= */
.mono-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
}
.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.wiki-link:hover { text-decoration: underline; }
.compare-btn.active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}
.share-btn + .share-btn { margin-left: -10px; }

/* ================= COMPARADOR ================= */
.compare-tray {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--surface-float);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px var(--shadow-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: modalScaleIn 0.25s ease;
}
.compare-tray[hidden] { display: none; }
.compare-tray-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.compare-chips {
  display: flex;
  gap: 6px;
}
.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px 3px 9px;
  border-radius: 9px;
  color: #07090e;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}
.compare-chip button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  opacity: 0.7;
}
.compare-chip button:hover { opacity: 1; }

.compare-dialog {
  margin: auto;
  width: min(820px, calc(100% - 32px));
  max-height: 90vh;
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-panel-solid);
  color: var(--text);
  box-shadow: 0 20px 60px var(--shadow-strong);
}
.compare-dialog[open] { animation: modalScaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
.compare-dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(8px);
}
.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.compare-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}
.compare-header .modal-close { position: static; }
.compare-table-wrap { overflow-x: auto; }
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.compare-table th,
.compare-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.compare-table thead th {
  font-size: 0.95rem;
  font-weight: 800;
  border-bottom-width: 2px;
}
.compare-table tbody th {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.compare-table td.num { font-family: 'JetBrains Mono', monospace; }
.compare-table td.muted { color: var(--text-muted); }
.compare-tile {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-right: 10px;
  vertical-align: middle;
  border-radius: 10px;
  color: #07090e;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.1;
}
.compare-tile span { font-size: 0.62rem; }
.compare-tile strong { font-size: 1.1rem; }
.cmp-max { color: #22c55e; font-size: 0.75rem; }
.cmp-min { color: #f97316; font-size: 0.75rem; }
.compare-note {
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

@media (max-width: 680px) {
  .temperature-group { flex-wrap: nowrap; }
  .temperature-group input[type="range"] { flex: 1 1 80px; width: auto; min-width: 0; }
  .temperature-value { min-width: 0; white-space: nowrap; font-size: 0.7rem; }
  .quiz-bar { padding: 10px 16px; }
  .quiz-actions { margin-left: 0; }
  .compare-tray { left: 12px; right: 12px; bottom: 12px; flex-wrap: wrap; }
  .toast-notification { left: 12px; right: 12px; bottom: 12px; }
}

.viewer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 320px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
