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

/* ─── THEME TOKENS ─── */
:root {
  --bg:            #F0EDE6;
  --bg-gradient:   radial-gradient(circle at 15% 50%, rgba(30,106,80,0.08), transparent 28%), radial-gradient(circle at 85% 30%, rgba(217,119,6,0.07), transparent 28%), #F0EDE6;
  --surface:       rgba(255, 254, 252, 0.85);
  --surface-2:     rgba(248, 245, 240, 0.75);
  --sidebar-bg:    rgba(255, 255, 255, 0.80);
  --border:        #DDD8CE;
  --border-soft:   #E8E3DB;
  --text-1:        #12100E;
  --text-2:        #5A5550;
  --text-3:        #9A948C;
  --accent:        #1E6A50;
  --accent-2:      #D97706;
  --accent-light:  #E2F0EB;
  --accent-ring:   rgba(30,106,80,.20);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 16px rgba(0,0,0,.11), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 20px 60px rgba(0,0,0,.16), 0 4px 12px rgba(0,0,0,.07);
  --radius:        10px;
  --sidebar-w:     210px;

  /* Element categories - light */
  --c-nonmetal:       #C8EBC8; --c-nonmetal-t:    #1A4E1A; --c-nonmetal-b:  #A0CCA0;
  --c-noble:          #FFF0B0; --c-noble-t:       #6A4800; --c-noble-b:     #D8C060;
  --c-alkali:         #FFCACA; --c-alkali-t:      #7A1010; --c-alkali-b:    #E89090;
  --c-alkaline:       #FFE0B0; --c-alkaline-t:    #6A3800; --c-alkaline-b:  #E8B860;
  --c-metalloid:      #DDD8FF; --c-metalloid-t:   #2E1E78; --c-metalloid-b: #B0A0F0;
  --c-polyatomic:     #C8E8F8; --c-polyatomic-t:  #0C4060; --c-polyatomic-b:#88C0E0;
  --c-posttrans:      #D8EACC; --c-posttrans-t:   #284A0A; --c-posttrans-b: #A8C888;
  --c-transition:     #E4E0D4; --c-transition-t:  #38321C; --c-transition-b:#C4C0A8;
  --c-lanthanide:     #F0D4E8; --c-lanthanide-t:  #5C004A; --c-lanthanide-b:#CC98BC;
  --c-actinide:       #ECD0DA; --c-actinide-t:    #5E1228; --c-actinide-b:  #CCA0B0;
}

[data-theme="dark"] {
  --bg:            #0E0D0C;
  --bg-gradient:   radial-gradient(circle at 15% 50%, rgba(52,168,114,0.12), transparent 32%), radial-gradient(circle at 85% 30%, rgba(245,158,11,0.10), transparent 32%), #0E0D0C;
  --surface:       rgba(22, 21, 19, 0.85);
  --surface-2:     rgba(28, 27, 25, 0.75);
  --sidebar-bg:    rgba(18, 17, 16, 0.90);
  --border:        #2A2824;
  --border-soft:   #222018;
  --text-1:        #F2EFE9;
  --text-2:        #928C84;
  --text-3:        #52504A;
  --accent:        #34A872;
  --accent-2:      #F59E0B;
  --accent-light:  rgba(52,168,114,.14);
  --accent-ring:   rgba(52,168,114,.22);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.35);
  --shadow-md:     0 4px 20px rgba(0,0,0,.45);
  --shadow-lg:     0 24px 64px rgba(0,0,0,.65);

  --c-nonmetal:       #162A16; --c-nonmetal-t:    #72C072; --c-nonmetal-b:  #244A24;
  --c-noble:          #28220A; --c-noble-t:       #C8A028; --c-noble-b:     #403800;
  --c-alkali:         #280C0C; --c-alkali-t:      #D87070; --c-alkali-b:    #421818;
  --c-alkaline:       #281800; --c-alkaline-t:    #D8A050; --c-alkaline-b:  #422800;
  --c-metalloid:      #140E28; --c-metalloid-t:   #9E90E8; --c-metalloid-b: #241848;
  --c-polyatomic:     #081A28; --c-polyatomic-t:  #60B8E0; --c-polyatomic-b:#102838;
  --c-posttrans:      #101C0A; --c-posttrans-t:   #7EC060; --c-posttrans-b: #1C2E10;
  --c-transition:     #1C1A14; --c-transition-t:  #A8A080; --c-transition-b:#2C2A1E;
  --c-lanthanide:     #22081C; --c-lanthanide-t:  #C87CB8; --c-lanthanide-b:#360E30;
  --c-actinide:       #220A10; --c-actinide-t:    #C87888; --c-actinide-b:  #360E18;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-1);
  display: flex;
  height: 100dvh;
  overflow: hidden;
  transition: background .25s, color .25s;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* prevents whole sidebar from scrolling */
  transition: background .25s, border-color .25s;
  box-shadow: 2px 0 10px rgba(0,0,0,0.02);
  z-index: 50;
}

/* Logo + footer are flex children that don't shrink and don't scroll */
.sidebar > .logo-wrap,
.sidebar > .sidebar-foot { flex-shrink: 0; }

/* Pinned config in sidebar foot */
.sidebar-foot {
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.sidebar-foot .nav-item { margin: 0; }

/* The scrollable middle region — only this part can scroll */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0; /* allow flex child to shrink and enable inner scroll */
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 15px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 30px; height: 30px;
  background: var(--text-1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .25s;
}

[data-theme="dark"] .logo-mark {
  background: var(--accent);
}

.logo-text { font-family: 'DM Serif Display', serif; font-size: 17px; color: var(--text-1); letter-spacing: -.3px; }
.logo-tag  { font-size: 8.5px; font-weight: 600; color: var(--accent); letter-spacing: .6px; text-transform: uppercase; margin-top: 1px; }

.nav-section { padding: 14px 10px 6px; }

.nav-label {
  font-size: 9px; font-weight: 600;
  letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px; margin-bottom: 3px;
}

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px; font-weight: 400;
  color: var(--text-2);
  text-decoration: none;
  transition: background .14s, color .14s;
  position: relative;
  user-select: none;
}

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

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  width: 15px; height: 15px;
  flex-shrink: 0; opacity: .65;
  transition: opacity .14s;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-badge {
  font-size: 7.5px; font-weight: 700;
  background: var(--accent-2);
  color: #fff;
  padding: 1px 5px; border-radius: 4px;
  margin-left: auto; letter-spacing: .3px;
}

.nav-lock {
  margin-left: auto;
  opacity: .4; font-size: 10px;
}

.sidebar-rule { border: none; border-top: 1px solid var(--border); margin: 6px 10px; }

/* Expandable nav group (Visualizador) */
.nav-expandable .nav-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px; font-weight: 400;
  color: var(--text-2);
  transition: background .14s, color .14s;
  user-select: none;
}
.nav-expandable .nav-row:hover { background: var(--bg); color: var(--text-1); }
.nav-expandable.has-active .nav-row { color: var(--text-1); font-weight: 500; }
.nav-chevron {
  margin-left: auto; width: 11px; height: 11px;
  opacity: .45; transition: transform .2s; flex-shrink: 0;
}
.nav-expandable.open .nav-chevron { transform: rotate(90deg); opacity: .75; }
.nav-children {
  display: none;
  margin: 2px 0 4px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-soft);
}
.nav-expandable.open .nav-children { display: block; }
.nav-children .nav-item { padding: 6px 8px; font-size: 12px; border-radius: 6px; }
.nav-children .nav-icon { width: 13px; height: 13px; }

.theme-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
  color: var(--text-2);
}

.theme-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.user-av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--text-1);
  color: var(--bg);
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .25s;
}

.user-name { font-size: 11.5px; font-weight: 500; color: var(--text-1); }
.user-role { font-size: 10px; color: var(--text-3); }

/* ─── MAIN ─── */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── TOPBAR ─── */
.topbar {
  height: 50px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
  transition: background .25s, border-color .25s;
  position: relative;
  z-index: 40;
}

.breadcrumb {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-3);
}

.breadcrumb span { color: var(--text-1); font-weight: 500; }

.search-box {
  margin-left: auto;
  display: flex; align-items: center; gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 11px;
  width: 230px;
  transition: border-color .15s, box-shadow .15s, background .25s;
}

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

.search-box input {
  border: none; background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; color: var(--text-1);
  outline: none; width: 100%;
}

.search-box input::placeholder { color: var(--text-3); }

/* ─── CONTENT AREA ─── */
.content {
  flex: 1; overflow-y: auto; overflow-x: auto;
  padding: 24px 28px 40px;
  animation: pageIn .28s ease;
}

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

.content::-webkit-scrollbar { width: 5px; height: 5px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── PAGE HEADER ─── */
.ph-kicker {
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 5px;
}

.ph-title {
  font-family: 'DM Serif Display', serif;
  font-size: 26px; color: var(--text-1);
  letter-spacing: -.4px; line-height: 1.15;
  margin-bottom: 5px;
}

.ph-desc {
  font-size: 12.5px; color: var(--text-2);
  line-height: 1.55; max-width: 520px;
  margin-bottom: 18px;
}

/* ─── LEGEND ─── */
.legend {
  display: flex; flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background .25s, border-color .25s;
  box-shadow: var(--shadow-sm);
}

.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-2);
  cursor: pointer; padding: 2px 4px; border-radius: 5px;
  transition: background .1s, opacity .15s;
}

.legend-item:hover { background: var(--border-soft); color: var(--text-1); }
.legend-item.active-filter { color: var(--text-1); font-weight: 500; }
.legend-item.dimmed { opacity: .4; }

.legend-dot {
  width: 10px; height: 10px; border-radius: 3px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.legend-clear {
  margin-left: auto; font-size: 10.5px;
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 5px;
  transition: color .15s, background .1s;
}

.legend-clear:hover { color: var(--text-1); background: var(--border-soft); }

/* table-wrap replaced below with centered version */

/* ─── FULLSCREEN TABLE MODE ─── */
/* Activated by toggleFullTable() — hides every chrome element so only the
   periodic table is visible. Modal overlay still works (it's a sibling).
   Also bumps --el-cell so the table fills the viewport more generously. */
body.fs-table {
  background: var(--bg);
  --el-cell: 82px;
  --el-sym-size: 30px;
}
body.fs-table .sidebar,
body.fs-table .mobile-overlay,
body.fs-table .topbar,
body.fs-table .data-strip,
body.fs-table .mobile-scroll-hint,
body.fs-table .mobile-cat-bar,
body.fs-table .mobile-zoom-controls,
body.fs-table .pt-tabs,
body.fs-table .legend,
body.fs-table .dl-bar,
body.fs-table #pg-periodic > .content > div:first-child,  /* page header */
body.fs-table #pg-other { display: none !important; }
body.fs-table .main { padding: 0 !important; width: 100%; height: 100vh; overflow: auto; }
body.fs-table #pg-periodic,
body.fs-table .content,
body.fs-table #ct-periodic { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
body.fs-table .table-wrap-outer { width: auto; max-width: none; }
body.fs-table .table-wrap { overflow: visible; }
body.fs-table .tab-content { width: auto; }
/* Floating "exit fullscreen" hint */
body.fs-table::after {
  content: 'ESC para sair';
  position: fixed;
  top: 14px; right: 16px;
  font-family: 'DM Mono', monospace;
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 6px;
  letter-spacing: .5px;
  opacity: .85;
  pointer-events: none;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.ptable {
  display: grid;
  grid-template-columns: repeat(18, var(--el-cell, 62px));
  grid-template-rows: repeat(10, calc(var(--el-cell, 62px) + 6px));
  gap: 3px;
  min-width: calc(var(--el-cell, 62px) * 18 + 3px * 17);
}

/* ─── ELEMENT CARD ─── */
.el {
  border-radius: 8px;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 2px 4px;
  position: relative;
  border: 1.5px solid transparent;
  user-select: none;
  transition: transform .12s cubic-bezier(.2,.8,.3,1),
              box-shadow .12s ease,
              opacity .2s ease,
              filter .2s ease;
  will-change: transform;
}

.el:hover {
  transform: scale(1.16) translateY(-2px);
  z-index: 20;
  box-shadow: 0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.05), 0 0 15px var(--accent-ring);
}
body.no-anim .el { transition: none !important; }
body.no-anim .el:hover { transform: none !important; box-shadow: none !important; z-index: 1; }

.el.dim    { opacity: .15; filter: grayscale(.4); }
.el.shine  { outline: 2.5px solid var(--accent); outline-offset: 1px; transform: scale(1.1); z-index: 15; }

/* Card layout — corners are absolute, center is flow */
.el-z {
  position: absolute;
  top: 2px; left: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 7.5px; font-weight: 500;
  opacity: .7; line-height: 1;
}
.el-shells {
  position: absolute;
  top: 2px; right: 3px;
  font-family: 'DM Mono', monospace;
  font-size: 5.5px;
  letter-spacing: -.05em;
  opacity: .58; line-height: 1;
  max-width: 70%;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  font-variant-numeric: tabular-nums;
}
.el-sym { font-family: 'DM Serif Display', serif; font-size: var(--el-sym-size, 18px); line-height: 1; }
.el-mass {
  font-family: 'DM Mono', monospace;
  font-size: 6.5px;
  opacity: .75;
  line-height: 1;
  margin-top: 2px;
}
.el-name {
  font-size: 6.5px; opacity: .7;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 92%; text-align: center;
  line-height: 1;
}

/* Category bg/text pairs */
.c-nonmetal    { background: var(--c-nonmetal);    color: var(--c-nonmetal-t);    border-color: var(--c-nonmetal-b); }
.c-noble       { background: var(--c-noble);       color: var(--c-noble-t);       border-color: var(--c-noble-b); }
.c-alkali      { background: var(--c-alkali);      color: var(--c-alkali-t);      border-color: var(--c-alkali-b); }
.c-alkaline    { background: var(--c-alkaline);    color: var(--c-alkaline-t);    border-color: var(--c-alkaline-b); }
.c-metalloid   { background: var(--c-metalloid);   color: var(--c-metalloid-t);   border-color: var(--c-metalloid-b); }
.c-polyatomic  { background: var(--c-polyatomic);  color: var(--c-polyatomic-t);  border-color: var(--c-polyatomic-b); }
.c-posttrans   { background: var(--c-posttrans);   color: var(--c-posttrans-t);   border-color: var(--c-posttrans-b); }
.c-transition  { background: var(--c-transition);  color: var(--c-transition-t);  border-color: var(--c-transition-b); }
.c-lanthanide  { background: var(--c-lanthanide);  color: var(--c-lanthanide-t);  border-color: var(--c-lanthanide-b); }
.c-actinide    { background: var(--c-actinide);    color: var(--c-actinide-t);    border-color: var(--c-actinide-b); }

/* Placeholder cell */
.el-ph {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 9px; color: var(--text-3);
  cursor: default;
}

/* Spacer row */
/* Spacer row — gives room for the f-block connector SVG (arrows + labels) */
.row-spacer { grid-column: 1 / span 18; height: 44px; }

/* f-block row label */
.f-label {
  grid-column: 1 / span 2;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 8.5px; color: var(--text-3);
  font-style: italic;
}

/* f-block connector: wrapper around table + connector SVG */
.table-with-connector {
  position: relative;
  display: inline-block;
}

.fblock-connector-svg {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  left: 0; top: 0;
  width: 100%; height: 100%;
}

/* ─── ELEMENT MODAL ─── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(6px) saturate(.85);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}

.overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-radius: 20px;
  width: 640px; max-width: 95vw;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1) inset;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  transform: scale(.94) translateY(10px);
  transition: transform .25s cubic-bezier(.175,.885,.32,1.275);
}

.overlay.open .modal { transform: scale(1) translateY(0); }

/* Modal left panel */
.modal-l {
  width: 200px; flex-shrink: 0;
  padding: 26px 18px;
  display: flex; flex-direction: column; gap: 8px;
}

.modal-z    { font-family: 'DM Mono', monospace; font-size: 10.5px; opacity: .55; }
.modal-sym  { font-family: 'DM Serif Display', serif; font-size: 58px; line-height: 1; }
.modal-nm   { font-family: 'DM Serif Display', serif; font-size: 19px; line-height: 1.1; }
.modal-mass-wrap { margin-top: 2px; }
.modal-mass-lbl  { font-size: 8.5px; opacity: .45; text-transform: uppercase; letter-spacing: .5px; }
.modal-mass-val  { font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500; margin-top: 1px; }

.modal-cat {
  display: inline-flex; align-items: center;
  font-size: 8.5px; font-weight: 600;
  letter-spacing: .7px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px;
  border: 1.5px solid currentColor;
  margin-top: auto; align-self: flex-start;
  opacity: .85;
}

/* Modal right panel */
.modal-r {
  flex: 1; min-width: 0;
  padding: 20px 22px 28px;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 26px;
  position: relative;
  overflow-y: auto; max-height: 80vh;
}

.modal-r::-webkit-scrollbar { width: 4px; }
.modal-r::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-close-wrap {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;   /* Pull EXPLORAR + X together on the right —
                                  no empty horizontal gap between them. */
  align-items: center;
  gap: 8px;
  margin: -20px -22px 4px;
  padding: 10px 14px 0;
  z-index: 10;
  pointer-events: none;          /* the buttons themselves keep pointer-events:all */
  flex-shrink: 0;
  /* Transparent — the buttons float over the modal content. No background fill,
     no border, no shadow. Content scrolls cleanly behind. */
  background: transparent;
}

/* When the explore button lives inside the sticky close-wrap (top-right area)
   it overrides the footer-positioning rules of .modal-cta. */
.modal-cta-sticky {
  pointer-events: all;
  margin-left: 0 !important;
}

.modal-close {
  pointer-events: all;
  width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 15px; line-height: 1;
  transition: background .12s;
  box-shadow: 0 1px 6px rgba(0,0,0,.10);
}

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

.m-section-lbl {
  font-size: 8.5px; font-weight: 600;
  letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 9px;
}

.m-desc {
  font-size: 12.5px; font-style: italic;
  color: var(--text-2); line-height: 1.6;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.m-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
}

.m-meta-item { display: flex; flex-direction: column; gap: 2px; }
.m-meta-lbl  { font-size: 9.5px; color: var(--text-3); }
.m-meta-val  { font-size: 13px; font-weight: 500; color: var(--text-1); }

.m-props-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.m-prop {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}

.m-prop:last-child { border-bottom: none; }
.m-prop-lbl  { font-size: 10.5px; color: var(--text-3); flex-shrink: 0; }
.m-prop-val  { font-family: 'DM Mono', monospace; font-size: 11.5px; font-weight: 500; color: var(--text-1); text-align: right; }

.modal-foot {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}

.modal-soon { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.modal-cta  {
  margin-left: auto;
  font-size: 10.5px; font-weight: 600;
  color: var(--accent); letter-spacing: .5px; text-transform: uppercase;
  display: flex; align-items: center; gap: 4px;
  text-decoration: none;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  transition: all .15s;
}
.modal-cta:hover { background: var(--accent-light); border-color: var(--accent); }

.modal-dl-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  background: var(--accent); color: #fff;
  border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  font-family: inherit;
  transition: opacity .15s;
}
.modal-dl-btn:hover { opacity: .88; }

.m-econfig {
  font-family: 'DM Mono', monospace;
  font-size: 12px; color: var(--text-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  letter-spacing: .3px;
}

/* Oxidation states */
.m-oxidation-row {
  display: flex; gap: 5px; flex-wrap: wrap;
}
.m-ox-badge {
  font-family: 'DM Mono', monospace;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 5px;
  border: 1.5px solid var(--border);
  color: var(--text-2);
  background: var(--surface-2);
}
.m-ox-badge.common {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* Valence bar */
.m-valence-row {
  display: flex; align-items: center; gap: 8px;
}
.m-valence-track {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.m-valence-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
  transition: width .4s ease;
}
.m-valence-num {
  font-family: 'DM Mono', monospace;
  font-size: 12px; font-weight: 600; color: var(--accent);
  min-width: 18px; text-align: right;
}

/* Occurrence badge */
.m-occur-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--text-2);
}

/* Fun fact */
.m-funfact {
  font-size: 12px; color: var(--text-2);
  background: var(--accent-light);
  border-left: 2.5px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  line-height: 1.55;
  font-style: italic;
}

.m-shells {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.m-shell-badge {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; min-width: 36px;
}

.m-shell-lbl { font-size: 8px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); }
.m-shell-val { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 600; color: var(--text-1); }

.m-apps {
  display: flex; gap: 6px; flex-wrap: wrap;
}

.m-app-tag {
  font-size: 10.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px;
}

/* ─── DEV PANEL ─── */
.dev-wrap {
  flex: 1; display: none;
  align-items: center; justify-content: center;
}
.dev-wrap.show { display: flex; }

.dev-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 56px 80px;
  text-align: center;
  max-width: 420px;
  transition: background .25s, border-color .25s;
}

.dev-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 20px;
}

.dev-title { font-size: 15px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.dev-sub   { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }

/* ─── PAGES ─── */
#pg-periodic { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#pg-other    { display: none; flex: 1; align-items: center; justify-content: center; }

/* tooltip on hover (element name full) */
.topbar-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-size: 11px; font-weight: 600;
  color: var(--text-2); letter-spacing: .3px;
  font-family: inherit;
  transition: background .14s, color .14s, border-color .14s;
}
.topbar-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.el[title] { cursor: pointer; }

/* ─── HEATMAP MODE ─── */
body.heatmap-mode .el { filter: none !important; }
body.heatmap-mode .el.dim { opacity: .15; }

/* ─── SETTINGS PAGE ─── */
.settings-grid {
  display: flex; flex-direction: column; gap: 20px;
  max-width: 680px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: background .25s, border-color .25s;
}

.settings-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.settings-row:last-child { border-bottom: none; }

.settings-row-info { flex: 1; min-width: 0; }
.settings-row-label { font-size: 13px; font-weight: 500; color: var(--text-1); margin-bottom: 2px; }
.settings-row-desc  { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* Segmented control */
.settings-segmented {
  display: flex; gap: 2px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 3px;
  flex-shrink: 0;
}
.seg-btn {
  padding: 5px 12px; border-radius: 7px; border: none;
  background: transparent; cursor: pointer;
  font-size: 11px; font-weight: 500; color: var(--text-2);
  font-family: inherit; transition: all .15s;
}
.seg-btn.active, .seg-btn:focus {
  background: var(--surface); color: var(--text-1);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* Toggle */
.settings-toggle {
  width: 40px; height: 22px; border-radius: 11px;
  border: none; cursor: pointer; flex-shrink: 0;
  background: var(--border); position: relative;
  transition: background .2s;
}
.settings-toggle.active { background: var(--accent); }
.toggle-knob {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; position: absolute; top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.settings-toggle.active .toggle-knob { transform: translateX(18px); }

/* Select */
.settings-select {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text-1);
  font-family: 'DM Sans', sans-serif; font-size: 12px;
  padding: 6px 10px; cursor: pointer; outline: none;
  transition: border-color .15s;
}
.settings-select:focus { border-color: var(--accent); }

/* Input */
.settings-input {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text-1);
  font-family: 'DM Sans', sans-serif; font-size: 12px;
  padding: 6px 10px; outline: none; width: 160px;
  transition: border-color .15s;
}
.settings-input:focus { border-color: var(--accent); }

/* PDF buttons grid */
.settings-pdf-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 14px 18px;
}
.settings-pdf-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.settings-pdf-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.pdf-icon { font-size: 18px; margin-bottom: 2px; }
.pdf-label { font-size: 12px; font-weight: 600; color: var(--text-1); }
.pdf-desc  { font-size: 10.5px; color: var(--text-3); line-height: 1.3; }

/* About section */
.settings-about { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.about-logo { display: flex; align-items: center; gap: 12px; }
.about-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.about-stats { display: flex; gap: 20px; }
.about-stat { display: flex; flex-direction: column; gap: 2px; }
.about-stat-val { font-family: 'DM Mono', monospace; font-size: 18px; font-weight: 600; color: var(--accent); }
.about-stat-lbl { font-size: 10px; color: var(--text-3); letter-spacing: .4px; }

/* ─── TABS ENHANCEMENTS ─── */
/* Heatmap legend — em v9.1 movida pra cima da tabela. Layout em duas colunas
   (gradiente à esquerda, select à direita), espaçados pra ocupar a largura
   visualmente como uma "barra de comando" do heatmap. Quando a tabela
   recarrega ao trocar o select, o controle continua visível sem scroll. */
.heatmap-legend {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px;
}
/* .heatmap-legend-top é a classe específica do novo posicionamento — mantemos
   .heatmap-legend genérica caso outro lugar reutilize. */
.heatmap-legend-top {
  /* Pequeno destaque pra sinalizar que é um controle ativo, não só legenda */
  border-color: rgba(52,168,114,0.25);
  box-shadow: 0 1px 0 rgba(52,168,114,0.06) inset;
}
.heatmap-scale {
  display: flex; align-items: center; gap: 10px;
}
.heatmap-gradient {
  width: 180px; height: 10px; border-radius: 5px;
  background: linear-gradient(to right, hsl(240, 80%, 55%), hsl(180, 80%, 50%), hsl(60, 90%, 50%), hsl(0, 80%, 55%));
  border: 1px solid var(--border);
}
.hm-low, .hm-high {
  font-size: 10px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
}
.hm-select {
  background: var(--bg); color: var(--text-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-family: 'DM Sans', sans-serif;
  font-size: 12px; font-weight: 500;
  cursor: pointer; outline: none; transition: border-color .15s;
  min-width: 220px;
}
.hm-select:hover { border-color: rgba(52,168,114,0.4); }
.hm-select:focus { border-color: var(--accent); }

.compare-wrap { display: flex; flex-direction: column; gap: 24px; width: 100%; max-width: 900px; margin: 0 auto; }
.compare-selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ─── Slot (one per element) ─── */
.cmp-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  min-height: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.03), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
[data-theme="dark"] .cmp-slot {
  box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.02);
}
.cmp-slot:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 48px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.5), 0 0 0 2px var(--accent-ring);
  transform: translateY(-2px);
}

.cmp-slot-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* "Empty" picker button — visible when nothing selected */
.cmp-slot-pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  background: rgba(0,0,0,0.01);
  border: 2px dashed var(--border);
  border-radius: 16px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] .cmp-slot-pick { background: rgba(255,255,255,0.01); }
.cmp-slot-pick:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.02);
}
.cmp-slot-pick:active { transform: scale(0.98); }

.cmp-slot-empty-icon {
  font-size: 32px;
  line-height: 1;
  font-weight: 300;
  background: var(--surface);
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all .3s ease;
}
.cmp-slot-pick:hover .cmp-slot-empty-icon {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: rotate(90deg);
}

.cmp-slot-empty-txt { font-size: 13px; }

/* Filled state — horizontal layout: card left, bohr right */
.cmp-slot-filled {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  flex: 1;
  justify-content: center;
  padding: 8px 0;
}

.cmp-slot-clear {
  position: absolute;
  top: -8px; right: -8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
  z-index: 10;
}
.cmp-slot-clear:hover {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  transform: scale(1.15);
}

/* The compare card — tall vertical card */
.cmp-slot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 130px; height: 160px;
  padding: 14px 12px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-1);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.cmp-slot-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.cmp-slot-card .cmp-z {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  opacity: .7;
  margin-bottom: 4px;
}
.cmp-slot-card .cmp-sym {
  font-family: 'DM Serif Display', serif;
  font-size: 48px;
  line-height: 1;
}
.cmp-slot-card .cmp-nm {
  font-size: 13px;
  font-weight: 600;
  opacity: .85;
  margin-top: auto;
  line-height: 1.2;
}

/* Category colorization */
.cmp-slot-card.c-nonmetal    { background: var(--c-nonmetal);    color: var(--c-nonmetal-t);    border-color: var(--c-nonmetal-b); }
.cmp-slot-card.c-noble       { background: var(--c-noble);       color: var(--c-noble-t);       border-color: var(--c-noble-b); }
.cmp-slot-card.c-alkali      { background: var(--c-alkali);      color: var(--c-alkali-t);      border-color: var(--c-alkali-b); }
.cmp-slot-card.c-alkaline    { background: var(--c-alkaline);    color: var(--c-alkaline-t);    border-color: var(--c-alkaline-b); }
.cmp-slot-card.c-metalloid   { background: var(--c-metalloid);   color: var(--c-metalloid-t);   border-color: var(--c-metalloid-b); }
.cmp-slot-card.c-polyatomic  { background: var(--c-polyatomic);  color: var(--c-polyatomic-t);  border-color: var(--c-polyatomic-b); }
.cmp-slot-card.c-posttrans   { background: var(--c-posttrans);   color: var(--c-posttrans-t);   border-color: var(--c-posttrans-b); }
.cmp-slot-card.c-transition  { background: var(--c-transition);  color: var(--c-transition-t);  border-color: var(--c-transition-b); }
.cmp-slot-card.c-lanthanide  { background: var(--c-lanthanide);  color: var(--c-lanthanide-t);  border-color: var(--c-lanthanide-b); }
.cmp-slot-card.c-actinide    { background: var(--c-actinide);    color: var(--c-actinide-t);    border-color: var(--c-actinide-b); }

/* Bohr model in comparator — clean, no glow */
.cmp-bohr-wrap {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

/* Empty state under the slots */
.cmp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 20px;
  color: var(--text-3);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}
.cmp-empty-state-icon {
  font-size: 42px;
  opacity: .5;
  background: var(--bg);
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.cmp-empty-state p {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  text-align: center;
}

/* ─── Element picker overlay ─── */
.cmp-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity .2s ease;
}
[data-theme="dark"] .cmp-picker-overlay { background: rgba(0, 0, 0, 0.55); }
.cmp-picker-overlay.open {
  display: flex;
  opacity: 1;
}

.cmp-picker {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(900px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.cmp-picker-overlay.open .cmp-picker {
  transform: translateY(0);
  opacity: 1;
}

.cmp-picker-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cmp-picker-title {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text-1);
}
.cmp-picker-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  letter-spacing: .2px;
}
.cmp-picker-search {
  flex: 1;
  max-width: 320px;
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.cmp-picker-search:focus { border-color: var(--accent); }
.cmp-picker-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.cmp-picker-close:hover { background: var(--surface-2); color: var(--text-1); }

.cmp-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  align-content: start;
}
.cmp-picker-grid::-webkit-scrollbar { width: 6px; }
.cmp-picker-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.cmp-picker-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 8px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .15s;
  font-family: inherit;
  text-align: left;
  color: var(--text-1);
}
.cmp-picker-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.cmp-picker-cell.hidden { display: none; }
.cmp-picker-cell.selected { outline: 2px solid var(--accent); outline-offset: -1px; }

.cmp-picker-cell .pc-z {
  font-family: 'DM Mono', monospace;
  font-size: 8.5px;
  opacity: .65;
}
.cmp-picker-cell .pc-sym {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  line-height: 1;
  margin-top: 1px;
}
.cmp-picker-cell .pc-nm {
  font-size: 9px;
  opacity: .8;
  margin-top: auto;
  line-height: 1.1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: stretch;
}

/* Apply category colors to picker cells too */
.cmp-picker-cell.c-nonmetal    { background: var(--c-nonmetal);    color: var(--c-nonmetal-t);    border-color: var(--c-nonmetal-b); }
.cmp-picker-cell.c-noble       { background: var(--c-noble);       color: var(--c-noble-t);       border-color: var(--c-noble-b); }
.cmp-picker-cell.c-alkali      { background: var(--c-alkali);      color: var(--c-alkali-t);      border-color: var(--c-alkali-b); }
.cmp-picker-cell.c-alkaline    { background: var(--c-alkaline);    color: var(--c-alkaline-t);    border-color: var(--c-alkaline-b); }
.cmp-picker-cell.c-metalloid   { background: var(--c-metalloid);   color: var(--c-metalloid-t);   border-color: var(--c-metalloid-b); }
.cmp-picker-cell.c-polyatomic  { background: var(--c-polyatomic);  color: var(--c-polyatomic-t);  border-color: var(--c-polyatomic-b); }
.cmp-picker-cell.c-posttrans   { background: var(--c-posttrans);   color: var(--c-posttrans-t);   border-color: var(--c-posttrans-b); }
.cmp-picker-cell.c-transition  { background: var(--c-transition);  color: var(--c-transition-t);  border-color: var(--c-transition-b); }
.cmp-picker-cell.c-lanthanide  { background: var(--c-lanthanide);  color: var(--c-lanthanide-t);  border-color: var(--c-lanthanide-b); }
.cmp-picker-cell.c-actinide    { background: var(--c-actinide);    color: var(--c-actinide-t);    border-color: var(--c-actinide-b); }

@media (max-width: 700px) {
  .compare-selectors { grid-template-columns: 1fr; }
  .cmp-picker-head { flex-wrap: wrap; }
  .cmp-picker-search { max-width: 100%; margin-left: 0; width: 100%; }
}
.compare-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 16px; background: var(--surface); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.compare-table th, .compare-table td { padding: 16px 20px; text-align: left; border-bottom: 1px solid var(--border-soft); transition: background .2s; }
.compare-table th { font-weight: 600; color: var(--text-1); background: rgba(0,0,0,0.02); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.compare-table tbody tr:hover td { background: var(--bg); }
.compare-table tr:last-child td { border-bottom: none; }
.c-val-better { color: var(--accent); font-weight: 700; background: var(--accent-light); padding: 2px 8px; border-radius: 6px; }

.trend-controls { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.trend-chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; height: 400px; }

.iso-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 24px; }
.iso-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.iso-item { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background .15s; }
.iso-item:hover { background: rgba(0,0,0,0.02); }
.iso-item.active { border-left: 3px solid var(--accent); background: var(--accent-light); }
.iso-item-name { font-weight: 600; color: var(--text-1); font-size: 14px; }
.iso-item-mass { font-size: 11px; color: var(--text-3); }
.iso-details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.iso-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.iso-card { background: var(--bg); border: 1px solid var(--border); padding: 12px; border-radius: 8px; }
.iso-card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 4px; }
.iso-card-val { font-size: 18px; font-weight: 600; color: var(--text-1); font-family: 'DM Mono', monospace; }

/* ─── BOHR VIEWER ─── */
.bohr-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  /* No outer ring by default — minimalism preserved */
}
.bohr-wrap canvas {
  display: block;
  cursor: grab;
  transition: filter .25s ease;
  transform-origin: center center;
  /* Transform is applied dynamically via JS for zoom+pan; no CSS transition on transform to keep dragging crisp */
  will-change: transform;
}
.bohr-wrap canvas:active { cursor: grabbing; }

/* Subtle ring on paused (original state) — refined, no glow */
.bohr-wrap.paused canvas { filter: saturate(.95); }

/* Static thin ring to indicate "original state" — barely visible */
.bohr-wrap.paused::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px dashed var(--border);
  opacity: .5;
  pointer-events: none;
  transition: opacity .25s;
}

/* Outer frame: contains the clipped circular viewer plus floating controls/hints */
.bohr-frame {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.m-bohr-section {
  margin-top: 4px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.m-bohr-section .bohr-frame {
  align-self: center;
  margin: 4px auto;
}
.m-bohr-section .bohr-wrap canvas { width: 200px; height: 200px; }
.m-bohr-section .bohr-hint,
.m-bohr-section .bohr-status,
.m-bohr-section .bohr-zoom-tag { display: none !important; }
@media (max-width: 900px) {
  .m-bohr-section .bohr-wrap canvas { width: 170px; height: 170px; }
  .m-bohr-section { margin-top: 0; padding-top: 0; }
  .m-bohr-section .bohr-frame { margin: 0 auto; }
}

/* Controls anchor to the top-right area of the frame — outside the clipping circle. */
.bohr-controls {
  position: absolute;
  top: -2px;
  right: -2px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateX(2px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  z-index: 4;
}
.bohr-frame:hover .bohr-controls,
.bohr-frame.interacted .bohr-controls,
.bohr-frame.paused .bohr-controls {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.bohr-ctrl-btn {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s, transform .15s;
  padding: 0;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.bohr-ctrl-btn:hover {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--accent-ring);
  transform: scale(1.06);
}
.bohr-ctrl-btn svg {
  width: 12px; height: 12px;
  display: block;
}

/* Zoom level pill — top-left, outside the circle */
.bohr-zoom-tag {
  position: absolute;
  top: 4px; left: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 9.5px;
  letter-spacing: .4px;
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 3;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}
.bohr-frame.zooming .bohr-zoom-tag { opacity: 1; }

/* Hint pill — clearly visible below the circle. Fully readable, no clipping. */
.bohr-frame .bohr-hint {
  font-family: 'DM Mono', monospace;
  font-size: 9.5px;
  letter-spacing: .3px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 3px 10px;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.bohr-frame:hover .bohr-hint { opacity: 1; }
.bohr-frame.interacted .bohr-hint { opacity: 0; }

/* Status pill below — shown when paused */
.bohr-frame .bohr-status {
  font-family: 'DM Mono', monospace;
  font-size: 8.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  white-space: nowrap;
  user-select: none;
  height: 11px;
  line-height: 11px;
}
.bohr-frame.paused .bohr-status,
.bohr-frame:has(.bohr-wrap.paused) .bohr-status { opacity: 1; }

/* When paused, hide the "arraste" hint so it doesn't compete with the status line */
.bohr-frame.paused .bohr-hint,
.bohr-frame:has(.bohr-wrap.paused) .bohr-hint { opacity: 0; }

/* ─── IMPROVED MODAL AESTHETICS ─── */
.modal-z {
  font-family: 'DM Mono', monospace; font-size: 10px;
  color: currentColor; opacity: .45; letter-spacing: .5px;
}

/* ─── TABS ─── */
.pt-tabs {
  display: flex; align-items: center; gap: 2px;
  margin-bottom: 16px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
  transition: background .25s, border-color .25s;
  box-shadow: var(--shadow-sm);
}

.pt-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 7px;
  border: none; cursor: pointer;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-2);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  transition: background .14s, color .14s;
  white-space: nowrap;
  text-decoration: none;
}
.pt-tab:visited { color: var(--text-2); }
.pt-tab.active:visited { color: var(--accent); }

.pt-tab:hover { background: var(--bg); color: var(--text-1); }

.pt-tab.active {
  background: var(--sidebar-bg);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.pt-tab svg { flex-shrink: 0; opacity: .7; }
.pt-tab.active svg { opacity: 1; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Subpage FOUC prevention ─────────────────────────────────────────
   The 4 subpages (heatmap, trends, compare, isotopes) inherit the same
   HTML where #tab-tabela starts with .active. Without these rules, the
   user would see the Tabela view flash for ~50ms before JS swaps tabs.
   data-pt-tab on <body> lets us pick the right visible tab via CSS only. */
body[data-pt-tab="grupos"]   #tab-tabela.active,
body[data-pt-tab="comparar"] #tab-tabela.active,
body[data-pt-tab="isotopos"] #tab-tabela.active { display: none !important; }

body[data-pt-tab="grupos"]   #tab-grupos,
body[data-pt-tab="comparar"] #tab-comparar,
body[data-pt-tab="isotopos"] #tab-isotopos { display: block !important; }

/* Heatmap subpage: keep tab-tabela visible (heatmap reuses the table)
   but swap legend ↔ heatmap-legend immediately. */
body[data-pt-tab="heatmap"] #legend { display: none !important; }
body[data-pt-tab="heatmap"] #heatmap-legend { display: flex !important; }

/* Tab nav active state — match by data-tab attribute so the right tab
   is highlighted even before JS runs. */
body[data-pt-tab="heatmap"]  .pt-tab.active:not([data-tab="heatmap"]),
body[data-pt-tab="grupos"]   .pt-tab.active:not([data-tab="grupos"]),
body[data-pt-tab="comparar"] .pt-tab.active:not([data-tab="comparar"]),
body[data-pt-tab="isotopos"] .pt-tab.active:not([data-tab="isotopos"]) {
  background: transparent;
  color: var(--text-2);
  box-shadow: none;
}
body[data-pt-tab="heatmap"]  .pt-tab.active:not([data-tab="heatmap"])  svg,
body[data-pt-tab="grupos"]   .pt-tab.active:not([data-tab="grupos"])   svg,
body[data-pt-tab="comparar"] .pt-tab.active:not([data-tab="comparar"]) svg,
body[data-pt-tab="isotopos"] .pt-tab.active:not([data-tab="isotopos"]) svg { opacity: .7; }

/* Tab placeholder */
.tab-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 64px 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 480px; margin: 0 auto;
  transition: background .25s, border-color .25s;
}

.tab-ph-icon { font-size: 32px; margin-bottom: 16px; }
.tab-ph-title { font-family: 'DM Serif Display', serif; font-size: 18px; color: var(--text-1); margin-bottom: 8px; }
.tab-ph-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.tab-ph-soon {
  display: inline-block;
  font-size: 9px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  background: var(--accent-light); color: var(--accent);
  padding: 2px 7px; border-radius: 10px; margin-left: 4px;
}

/* ─── CENTERED TABLE ─── */
.table-wrap {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 8px;
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.modal-sym {
  font-family: 'DM Serif Display', serif;
  font-size: 64px; line-height: 1; font-weight: 400;
  letter-spacing: -2px;
}
.modal-nm {
  font-family: 'DM Serif Display', serif;
  font-size: 20px; line-height: 1.1; margin-top: -4px;
}
.modal-mass-wrap { margin-top: 4px; }
.modal-mass-lbl {
  font-size: 7.5px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase; opacity: .4;
}
.modal-mass-val {
  font-family: 'DM Mono', monospace; font-size: 13px;
  font-weight: 600; margin-top: 2px;
}
.m-section-lbl {
  font-size: 8px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.m-section-lbl::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.m-desc {
  font-size: 12.5px; font-style: italic; color: var(--text-2);
  line-height: 1.65; border-left: 2px solid currentColor;
  padding-left: 10px; opacity: .9;
}

/* ─── DOWNLOAD BAR ─── */
.dl-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  justify-content: flex-end;
  padding-right: 2px;
}
.dl-btn {
  display: flex; align-items: center; gap: 5px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all .15s;
}
.dl-btn:hover { color: var(--text-1); border-color: var(--text-3); }
.dl-btn.active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent);
  font-weight: 600;
}
.dl-divider {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 2px;
}
.dl-action {
  display: flex; align-items: center; gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px; font-weight: 600;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.dl-action:hover { opacity: .88; }
.dl-action:active { transform: scale(.97); }
.dl-action.loading { opacity: .6; cursor: wait; pointer-events: none; }

/* ─── MOBILE OVERLAY SIDEBAR ─── */
@media (max-width: 900px) {

  /* Sidebar becomes overlay drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 500;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Dim overlay when sidebar is open */
  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 400;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .mobile-overlay.show { display: block; }

  /* Main takes full width */
  .main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

  /* Topbar */
  .topbar { height: 52px; padding: 0 14px; gap: 8px; }
  .mobile-menu-btn {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    color: var(--text-2);
    flex-shrink: 0;
  }
  .breadcrumb { font-size: 12px; }
  .search-box { width: 150px; }
}

@media (max-width: 768px) {
  body { flex-direction: column; height: 100dvh; overflow: hidden; }

  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .search-box { width: 130px; font-size: 11px; }

  /* Content area */
  .content { padding: 12px 12px 40px; }

  /* Page header */
  .ph-kicker { display: none; }
  .ph-title { font-size: 18px; margin-bottom: 3px; }
  .ph-desc { font-size: 11.5px; margin-bottom: 10px; line-height: 1.5; }

  /* ─── PERIODIC TABLE: mobile improvements ─── */

  /* Wrap: horizontal scroll with momentum + pinch-zoom container */
  .table-wrap {
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-bottom: 12px;
    padding-top: 4px;
    /* Fade edges to hint scroll */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10px, black calc(100% - 10px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 10px, black calc(100% - 10px), transparent 100%);
    touch-action: pan-x pan-y pinch-zoom;
    cursor: grab;
  }
  .table-wrap:active { cursor: grabbing; }

  /* Scale the entire table + wrapper down — slightly bigger than before for readability */
  .table-with-connector {
    transform: scale(0.68);
    transform-origin: top left;
    margin-bottom: calc((58px * 10 + 3px * 9 + 44px) * -0.32);
    /* Smooth touch feedback */
    transition: transform 0.08s ease;
  }

  /* Mobile zoom controls */
  .mobile-zoom-controls {
    display: flex !important;
    align-items: center; gap: 4px;
    position: absolute;
    bottom: 8px; right: 8px;
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px 4px;
    box-shadow: var(--shadow-sm);
  }
  .mzc-btn {
    width: 26px; height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 16px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
    line-height: 1;
    font-family: 'DM Mono', monospace;
  }
  .mzc-btn:hover { background: var(--accent-light); color: var(--accent); }
  .mzc-scale-label {
    font-family: 'DM Mono', monospace;
    font-size: 9px; color: var(--text-3);
    padding: 0 2px; min-width: 28px; text-align: center;
  }

  /* table-wrap parent must be relative for zoom controls positioning */
  .table-wrap-outer {
    position: relative;
  }

  /* Mobile scroll hint — redesigned */
  .mobile-scroll-hint {
    display: flex !important;
    align-items: center; gap: 8px;
    background: var(--accent-light);
    border: 1px solid rgba(30,106,80,.18);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 11.5px; color: var(--accent);
    margin-bottom: 8px;
    font-weight: 500;
    flex-shrink: 0;
    animation: hintPulse 2.5s ease-in-out 1s forwards;
  }
  .mobile-scroll-hint svg { flex-shrink: 0; }
  .mobile-scroll-hint-close {
    margin-left: auto;
    cursor: pointer;
    opacity: .6;
    padding: 2px;
    line-height: 1;
    font-size: 14px;
    color: var(--accent);
  }
  @keyframes hintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .75; }
  }

  /* Mobile category quick-filter bar — horizontal scroll */
  .mobile-cat-bar {
    display: flex !important;
    gap: 5px;
    overflow-x: auto;
    padding: 0 0 6px;
    margin-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .mobile-cat-bar::-webkit-scrollbar { display: none; }
  .mobile-cat-chip {
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; flex-shrink: 0;
    padding: 4px 9px;
    border-radius: 20px;
    border: 1.5px solid transparent;
    font-size: 10.5px; font-weight: 500;
    cursor: pointer;
    transition: opacity .15s, transform .12s;
    font-family: 'DM Sans', sans-serif;
  }
  .mobile-cat-chip:active { transform: scale(.95); }
  .mobile-cat-chip.dimmed { opacity: .3; }
  .mobile-cat-chip-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  }

  /* Tabs */
  .pt-tabs { gap: 2px; flex-wrap: nowrap; padding: 3px; overflow-x: auto; }
  .pt-tabs::-webkit-scrollbar { display: none; }
  .pt-tab { font-size: 10px; padding: 5px 9px; gap: 3px; white-space: nowrap; flex-shrink: 0; }
  .pt-tab svg { width: 11px; height: 11px; }

  /* Legend */
  .legend { gap: 4px 8px; padding: 8px 10px; }
  .legend-item { font-size: 9.5px; padding: 1px 3px; }
  .legend-dot { width: 8px; height: 8px; }

  /* Download bar */
  .dl-bar { flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }

  /* Modal: bottom sheet on mobile */
  .overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    height: 90dvh;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-l {
    min-width: unset;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-r { padding: 14px 16px; overflow-y: auto; flex: 1; }
  .modal-sym { font-size: 40px; letter-spacing: -1px; }
  .modal-nm { font-size: 13px; }
  .modal-mass-lbl { font-size: 7px; }
  .modal-mass-val { font-size: 12px; }
  .m-meta-grid { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .m-props-grid .m-prop { padding: 5px 0; }
  .m-prop-lbl { font-size: 10px; }
  .m-prop-val { font-size: 11px; }

  /* Settings */
  .settings-grid { gap: 12px; }
  .settings-row { flex-wrap: wrap; gap: 10px; }
  .settings-row-label { font-size: 12px; }
  .settings-row-desc { font-size: 10.5px; }
  .settings-pdf-grid { grid-template-columns: 1fr 1fr; }
  .settings-segmented { flex-wrap: wrap; }

  /* Compare */
  .compare-selectors { grid-template-columns: 1fr; }
  .cmp-slot { min-height: 200px; }

  /* Isotopes */
  .iso-wrap { grid-template-columns: 1fr; }
  .iso-list { max-height: 200px; overflow-y: auto; }

  /* Trend chart */
  .trend-chart-wrap { height: 260px; }

  /* Heatmap — em telas pequenas, empilha verticalmente (gradiente em cima,
     select em baixo) para manter touch targets confortáveis. */
  .heatmap-legend {
    flex-direction: column; align-items: stretch; gap: 8px;
    padding: 8px 10px;
  }
  .heatmap-scale { justify-content: center; }
  .heatmap-gradient { width: 100%; flex: 1; min-width: 0; }
  .hm-select { width: 100%; min-width: 0; font-size: 13px; padding: 8px 10px; }
}

/* Very small phones */
@media (max-width: 420px) {
  .search-box { width: 100px; }
  .breadcrumb { display: none; }
  .table-with-connector {
    transform: scale(0.54);
    margin-bottom: calc((58px * 10 + 3px * 9 + 44px) * -0.46);
  }
  .settings-pdf-grid { grid-template-columns: 1fr; }
  .modal { height: 94dvh; max-height: 94dvh; }
}

/* Desktop — hide mobile-only elements */
@media (min-width: 901px) {
  .mobile-menu-btn { display: none; }
  .mobile-scroll-hint { display: none; }
  .mobile-overlay { display: none; }
  .sidebar { display: flex; }

  /* Transform overlay/modal into a side inspector */
  .overlay {
    position: static;
    display: none;
    width: 340px;
    height: 100dvh;
    padding: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    flex-shrink: 0;
    z-index: 100;
  }
  .overlay.open {
    display: flex;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .modal {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent;
    flex-direction: column;
  }
  .modal-l {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-r { padding: 20px; overflow-y: auto; flex: 1; }
  .modal-sym { font-size: 48px; letter-spacing: -1px; }
  .modal-nm { font-size: 15px; }
  
  .m-meta-grid { grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .m-props-grid .m-prop { padding: 6px 0; }
  
  .modal-close { top: 16px; right: 16px; }
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.mobile-menu-btn { display: none; }
.mobile-scroll-hint { display: none; }
.mobile-overlay { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE TABLE SCROLL FIX (audit 2026-05-21)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Kill the linear-gradient mask: it was visually covering the first/last
     columns of the table (H, Li, Na, K, ... and rightmost column) by ~10px. */
  .table-wrap {
    -webkit-mask-image: none !important;
    mask-image: none !important;
    /* Prevent rubber-band scroll past the table edges */
    overscroll-behavior-x: contain;
    /* Pad the inline edges so the first/last columns aren't flush against
       the viewport, and provide a comfortable scrollable area. */
    padding-left: 12px;
    padding-right: 12px;
    /* Use scroll snapping to make swipes feel anchored */
    scroll-snap-type: x proximity;
  }
  .table-wrap > * { scroll-snap-align: start; }

  /* Make sure the legend (normal filter) is visible on mobile too — the old
     mobile-cat-bar was hiding it via display:none in some layouts. */
  .legend { display: flex !important; flex-wrap: wrap; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE FIXES — round 2 (heatmap legend + zoom controls)
   ═══════════════════════════════════════════════════════════════════ */

/* Bug 1: heatmap was hiding the category legend (#legend) entirely.
   User wants both — show the category filter AND the gradient heatmap legend. */
body[data-pt-tab="heatmap"] #legend { display: flex !important; }

/* Bug 2: zoom controls were absolute-positioned over the table corner,
   covering elements (Na, Cl, etc visible in user screenshot). Move them
   out of the overlay layer and into the normal flow below the table. */
@media (max-width: 768px) {
  .mobile-zoom-controls {
    position: static !important;
    margin: 8px auto 4px;
    justify-content: center;
    /* Make it a horizontal pill centered under the table, doesn't cover anything */
    width: fit-content;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL — restructured close + explore (no more sticky bar / empty gap)
   ═══════════════════════════════════════════════════════════════════ */

/* Sticky corner actions wrapper: Explore on the LEFT, X on the RIGHT,
   transparent background — content scrolls visibly through the gap.
   Stays in place during scroll via position:sticky. Negative margin-bottom
   so the buttons overlay the first section instead of pushing it down. */
.modal-r { position: relative; }
.modal-corner-actions {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;   /* EXPLORAR left, X right — separated */
  width: 100%;
  margin-bottom: -34px;
  background: transparent;
  pointer-events: none;              /* gap area lets clicks pass through */
}
.modal-corner-actions > * { pointer-events: auto; }

/* Explore CTA — primary green pill */
.modal-cta-corner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  transition: background .14s, transform .12s;
}
.modal-cta-corner:hover { background: #15543f; transform: translateY(-1px); }
[data-theme="dark"] .modal-cta-corner { background: var(--accent); }
[data-theme="dark"] .modal-cta-corner:hover { background: #2a8c6b; }

/* X close — small square icon button matching the CTA height */
.modal-close-corner {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1;
  transition: background .14s, color .14s;
  box-shadow: 0 2px 8px rgba(0,0,0,.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-close-corner:hover { background: var(--border); color: var(--text-1); }
