/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e17;
  --bg-card: #141b2d;
  --bg-panel: #1a2236;
  --text: #e8eaf0;
  --text-dim: #8892a4;
  --border: #2a3450;
  --accent: #64b5f6;
  --radius: 8px;

  /* Category colors */
  --alkali-metal: #ff6b6b;
  --alkaline-earth: #ffa94d;
  --transition-metal: #ffd43b;
  --post-transition: #69db7c;
  --metalloid: #38d9a9;
  --nonmetal: #4dabf7;
  --noble-gas: #da77f2;
  --lanthanide: #f783ac;
  --actinide: #e599f7;
  --unknown: #adb5bd;
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Header === */
.site-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}
.site-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #64b5f6, #da77f2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-header p { color: var(--text-dim); margin-top: 0.25rem; }
.site-header nav { margin-top: 0.75rem; display: flex; gap: 1.5rem; justify-content: center; }
.site-header nav a {
  color: var(--text-dim);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.site-header nav a:hover, .site-header nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* === Legend === */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  padding: 0 1rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* === Periodic Table Grid === */
.table-wrapper {
  overflow: visible;
  padding: 1.5rem 1rem 1rem;
}
.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(56px, 1fr));
  gap: 3px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 0.5rem;
  overflow: visible;
}

/* Lanthanide/Actinide spacer rows */
.table-spacer {
  grid-column: 1 / -1;
  height: 12px;
}

/* === Element Cell === */
.element-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, z-index 0s;
  border: 1px solid transparent;
  background: var(--bg-card);
  min-width: 56px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.element-cell:hover,
.element-cell:focus-visible {
  transform: scale(1.25);
  z-index: 10;
  box-shadow: 0 0 20px rgba(100, 181, 246, 0.3);
  outline: none;
}
.element-cell .z { font-size: 0.6rem; color: var(--text-dim); line-height: 1; }
.element-cell .symbol { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.element-cell .name { font-size: 0.5rem; color: var(--text-dim); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.element-cell .mass { font-size: 0.45rem; color: var(--text-dim); line-height: 1; margin-top: 1px; }

/* Category colors as left border accent */
.element-cell[data-cat="alkali-metal"]     { border-left: 3px solid var(--alkali-metal); }
.element-cell[data-cat="alkaline-earth"]   { border-left: 3px solid var(--alkaline-earth); }
.element-cell[data-cat="transition-metal"] { border-left: 3px solid var(--transition-metal); }
.element-cell[data-cat="post-transition"]  { border-left: 3px solid var(--post-transition); }
.element-cell[data-cat="metalloid"]        { border-left: 3px solid var(--metalloid); }
.element-cell[data-cat="nonmetal"]         { border-left: 3px solid var(--nonmetal); }
.element-cell[data-cat="noble-gas"]        { border-left: 3px solid var(--noble-gas); }
.element-cell[data-cat="lanthanide"]       { border-left: 3px solid var(--lanthanide); }
.element-cell[data-cat="actinide"]         { border-left: 3px solid var(--actinide); }
.element-cell[data-cat="unknown"]          { border-left: 3px solid var(--unknown); }

/* Highlighted state when hovering */
.element-cell[data-cat="alkali-metal"]:hover,
.element-cell[data-cat="alkali-metal"]:focus-visible     { background: color-mix(in srgb, var(--alkali-metal) 20%, var(--bg-card)); }
.element-cell[data-cat="alkaline-earth"]:hover,
.element-cell[data-cat="alkaline-earth"]:focus-visible   { background: color-mix(in srgb, var(--alkaline-earth) 20%, var(--bg-card)); }
.element-cell[data-cat="transition-metal"]:hover,
.element-cell[data-cat="transition-metal"]:focus-visible { background: color-mix(in srgb, var(--transition-metal) 20%, var(--bg-card)); }
.element-cell[data-cat="post-transition"]:hover,
.element-cell[data-cat="post-transition"]:focus-visible  { background: color-mix(in srgb, var(--post-transition) 20%, var(--bg-card)); }
.element-cell[data-cat="metalloid"]:hover,
.element-cell[data-cat="metalloid"]:focus-visible        { background: color-mix(in srgb, var(--metalloid) 20%, var(--bg-card)); }
.element-cell[data-cat="nonmetal"]:hover,
.element-cell[data-cat="nonmetal"]:focus-visible         { background: color-mix(in srgb, var(--nonmetal) 20%, var(--bg-card)); }
.element-cell[data-cat="noble-gas"]:hover,
.element-cell[data-cat="noble-gas"]:focus-visible        { background: color-mix(in srgb, var(--noble-gas) 20%, var(--bg-card)); }
.element-cell[data-cat="lanthanide"]:hover,
.element-cell[data-cat="lanthanide"]:focus-visible       { background: color-mix(in srgb, var(--lanthanide) 20%, var(--bg-card)); }
.element-cell[data-cat="actinide"]:hover,
.element-cell[data-cat="actinide"]:focus-visible         { background: color-mix(in srgb, var(--actinide) 20%, var(--bg-card)); }
.element-cell[data-cat="unknown"]:hover,
.element-cell[data-cat="unknown"]:focus-visible          { background: color-mix(in srgb, var(--unknown) 20%, var(--bg-card)); }

/* Placeholder cells for La/Ac markers */
.element-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-dim);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  min-width: 56px;
  aspect-ratio: 1;
}

/* === Detail Panel (slide-up on mobile, sidebar on desktop) === */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.detail-overlay.active { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 1.5rem;
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 70vh;
  overflow-y: auto;
}
.detail-panel.active { transform: translateY(0); }

@media (min-width: 900px) {
  .detail-panel {
    top: 0; bottom: 0; left: auto;
    right: 0;
    width: 380px;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    max-height: 100vh;
  }
  .detail-panel.active { transform: translateX(0); }
}

.detail-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.detail-close:hover { color: var(--text); }

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.detail-header .big-symbol {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}
.detail-header .name-block h2 { font-size: 1.25rem; font-weight: 600; }
.detail-header .name-block .z-line { font-size: 0.85rem; color: var(--text-dim); }

.detail-summary {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.detail-props {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.detail-prop {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}
.detail-prop .label { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-prop .value { font-size: 0.95rem; font-weight: 600; margin-top: 2px; }

.detail-category-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.detail-buy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #64b5f6, #42a5f5);
  color: #fff;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
}
.detail-buy-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(100, 181, 246, 0.4);
  text-decoration: none;
  color: #fff;
}
.detail-buy-btn.disabled {
  background: var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}
.detail-buy-btn.disabled:hover {
  transform: none;
  box-shadow: none;
}

/* === Shop Page === */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}
.shop-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.shop-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(100,181,246,0.15);
}
.shop-card .symbol { font-size: 2rem; font-weight: 800; }
.shop-card .name { font-size: 1rem; font-weight: 600; margin: 0.25rem 0; }
.shop-card .form { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.shop-card .price { font-size: 1.1rem; font-weight: 700; color: var(--accent); margin-bottom: 0.75rem; }

/* Shop element detail page */
.shop-detail {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.shop-detail .hero {
  text-align: center;
  margin-bottom: 2rem;
}
.shop-detail .hero .symbol { font-size: 5rem; font-weight: 800; }
.shop-detail .hero h1 { font-size: 2rem; }
.shop-detail .hero .tagline { color: var(--text-dim); margin-top: 0.5rem; }
.shop-detail .info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.shop-detail .info-item {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 0.75rem;
}
.shop-detail .info-item .label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; }
.shop-detail .info-item .val { font-size: 1rem; font-weight: 600; margin-top: 4px; }
.shop-detail .buy-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
}
.shop-detail .buy-section .price { font-size: 2rem; font-weight: 800; color: var(--accent); }
.shop-detail .buy-section .note { font-size: 0.8rem; color: var(--text-dim); margin: 0.5rem 0 1rem; }

/* Search/filter bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 1rem 1rem;
  max-width: 600px;
  margin: 0 auto;
}
.filter-bar input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.filter-bar input:focus { border-color: var(--accent); }
.filter-bar input::placeholder { color: var(--text-dim); }

/* === Mobile View: Mini-map + Card List === */
.mobile-view { display: none; }

.mini-map {
  display: grid;
  grid-template-columns: repeat(18, 16px);
  grid-template-rows: repeat(10, 16px);
  gap: 1px;
  width: fit-content;
  margin: 0 auto;
  padding: 0 0.5rem;
  position: relative;
}
.mini-dot {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.6);
  line-height: 1;
  overflow: hidden;
  user-select: none;
}
.mini-dot.active {
  outline: 2px solid #fff;
  outline-offset: 1px;
  z-index: 2;
  position: relative;
}
.mini-dot.search-dim { opacity: 0.15; }

/* === Magnifier Loupe === */
.magnifier {
  position: fixed;
  z-index: 90;
  background: var(--bg-panel);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(100,181,246,0.2);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  animation: loupe-in 0.15s ease;
}
.magnifier.active { display: flex; }
@keyframes loupe-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.magnifier-grid {
  display: grid;
  gap: 3px;
}
.magnifier-cell {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.magnifier-cell:active { transform: scale(1.1); }
.magnifier-cell.mag-target {
  outline: 2px solid #fff;
  outline-offset: -1px;
}
.magnifier-cell .mag-z {
  font-size: 7px;
  color: rgba(0,0,0,0.5);
  line-height: 1;
}
.magnifier-cell .mag-symbol {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  color: rgba(0,0,0,0.75);
}
.magnifier-cell .mag-name {
  font-size: 6px;
  color: rgba(0,0,0,0.5);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46px;
  text-align: center;
}
/* Magnifier cell category colors */
.magnifier-cell[data-cat="alkali-metal"]     { background: var(--alkali-metal); }
.magnifier-cell[data-cat="alkaline-earth"]   { background: var(--alkaline-earth); }
.magnifier-cell[data-cat="transition-metal"] { background: var(--transition-metal); }
.magnifier-cell[data-cat="post-transition"]  { background: var(--post-transition); }
.magnifier-cell[data-cat="metalloid"]        { background: var(--metalloid); }
.magnifier-cell[data-cat="nonmetal"]         { background: var(--nonmetal); }
.magnifier-cell[data-cat="noble-gas"]        { background: var(--noble-gas); }
.magnifier-cell[data-cat="lanthanide"]       { background: var(--lanthanide); }
.magnifier-cell[data-cat="actinide"]         { background: var(--actinide); }
.magnifier-cell[data-cat="unknown"]          { background: var(--unknown); }
.magnifier-cell.empty { background: transparent; cursor: default; }

.magnifier-hint {
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 2px;
}
.magnifier-backdrop {
  position: fixed;
  inset: 0;
  z-index: 89;
  display: none;
}
.magnifier-backdrop.active { display: block; }

/* Mini-dot category colors */
.mini-dot[data-cat="alkali-metal"]     { background: var(--alkali-metal); }
.mini-dot[data-cat="alkaline-earth"]   { background: var(--alkaline-earth); }
.mini-dot[data-cat="transition-metal"] { background: var(--transition-metal); }
.mini-dot[data-cat="post-transition"]  { background: var(--post-transition); }
.mini-dot[data-cat="metalloid"]        { background: var(--metalloid); }
.mini-dot[data-cat="nonmetal"]         { background: var(--nonmetal); }
.mini-dot[data-cat="noble-gas"]        { background: var(--noble-gas); }
.mini-dot[data-cat="lanthanide"]       { background: var(--lanthanide); }
.mini-dot[data-cat="actinide"]         { background: var(--actinide); }
.mini-dot[data-cat="unknown"]          { background: var(--unknown); }

/* Mobile card list */
.mobile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 1rem;
  max-width: 500px;
  margin: 0 auto;
}
.mobile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  border-left: 4px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.mobile-card:active { background: var(--bg-panel); }
.mobile-card.highlight {
  animation: card-flash 0.6s ease;
}
@keyframes card-flash {
  0%, 100% { background: var(--bg-card); }
  30% { background: var(--bg-panel); border-color: var(--accent); }
}
.mobile-card.search-hidden { display: none; }

/* Mobile card category borders */
.mobile-card[data-cat="alkali-metal"]     { border-left-color: var(--alkali-metal); }
.mobile-card[data-cat="alkaline-earth"]   { border-left-color: var(--alkaline-earth); }
.mobile-card[data-cat="transition-metal"] { border-left-color: var(--transition-metal); }
.mobile-card[data-cat="post-transition"]  { border-left-color: var(--post-transition); }
.mobile-card[data-cat="metalloid"]        { border-left-color: var(--metalloid); }
.mobile-card[data-cat="nonmetal"]         { border-left-color: var(--nonmetal); }
.mobile-card[data-cat="noble-gas"]        { border-left-color: var(--noble-gas); }
.mobile-card[data-cat="lanthanide"]       { border-left-color: var(--lanthanide); }
.mobile-card[data-cat="actinide"]         { border-left-color: var(--actinide); }
.mobile-card[data-cat="unknown"]          { border-left-color: var(--unknown); }

/* Mobile card inner elements */
.mc-z {
  font-size: 0.65rem;
  color: var(--text-dim);
  min-width: 1.5rem;
  text-align: right;
}
.mc-symbol {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 2.5rem;
  text-align: center;
}
.mc-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.mc-name {
  font-size: 0.85rem;
  font-weight: 600;
}
.mc-mass {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.mc-phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.mobile-card[data-phase-at="Liquid"] .mc-phase-dot {
  background: rgba(255, 107, 107, 0.4);
  border-color: #ff6b6b;
}
.mobile-card[data-phase-at="Gas"] .mc-phase-dot {
  background: rgba(77, 171, 247, 0.3);
  border-color: #4dabf7;
}
.mobile-card[data-phase-at="Unknown"] { opacity: 0.5; }

/* === Responsive === */
@media (max-width: 768px) {
  .table-wrapper { display: none; }
  .mobile-view { display: block; }
  .legend { display: none; }
  .site-header h1 { font-size: 1.5rem; }

  .temp-control { flex-wrap: wrap; gap: 0.5rem; }
  .temp-control label { width: 100%; text-align: center; font-size: 0.75rem; }
  .temp-control .temp-presets { margin: 0 auto; }
}

@media (min-width: 769px) {
  .mobile-view { display: none !important; }
}

/* === Temperature Slider === */
.temp-control {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.temp-control label {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.temp-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #4dabf7 0%, #ffd43b 40%, #ff6b6b 100%);
  outline: none;
}
.temp-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(100,181,246,0.4);
}
.temp-control .temp-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 70px;
  text-align: right;
}
.temp-control .temp-presets {
  display: flex;
  gap: 0.25rem;
}
.temp-control .temp-presets button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.65rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.temp-control .temp-presets button:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Phase state indicators on cells */
.element-cell[data-phase-at="Gas"] { box-shadow: inset 0 0 0 1px rgba(77, 171, 247, 0.5); }
.element-cell[data-phase-at="Liquid"] { box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.5); }
.element-cell[data-phase-at="Unknown"] { opacity: 0.4; }

/* Phase legend inline */
.phase-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 0 1rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.phase-legend span { display: flex; align-items: center; gap: 0.3rem; }
.phase-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.phase-dot.solid { background: var(--bg-card); border: 1px solid var(--border); }
.phase-dot.liquid { background: rgba(255, 107, 107, 0.4); border: 1px solid #ff6b6b; }
.phase-dot.gas { background: rgba(77, 171, 247, 0.3); border: 1px solid #4dabf7; }

/* === Detail panel extra rows === */
.detail-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.detail-links a {
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* === Vendor cards in detail panel === */
.vendor-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.vendor-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.vendor-card:hover { border-color: var(--accent); }
.vendor-card .vendor-name { font-weight: 600; font-size: 0.85rem; }
.vendor-card .vendor-desc { font-size: 0.7rem; color: var(--text-dim); }
.vendor-card a {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* === Orbital Showcase (always visible, auto-cycling) === */
.orbital-showcase {
  margin-top: 0.75rem;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
}

.orbital-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.orbital-tab {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.45rem;
  cursor: pointer;
  transition: all 0.15s;
}
.orbital-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.orbital-tab:not(.active):hover { border-color: var(--accent); color: var(--text); }

.orbital-panel {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 200px;
}

.showcase-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 0.5rem;
}
.showcase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.showcase-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* Key stats grid */
.detail-key-stats {
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 0.4rem !important;
  margin-bottom: 0.5rem !important;
}
.detail-key-stats .detail-prop {
  padding: 0.4rem 0.5rem;
}
.detail-key-stats .detail-prop .label { font-size: 0.6rem; }
.detail-key-stats .detail-prop .value { font-size: 0.85rem; }

/* More details collapsible */
.more-details {
  margin-top: 0.75rem;
}
.more-details summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.5rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.more-details summary::before {
  content: '\25B8';
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.more-details[open] summary::before { transform: rotate(90deg); }
.more-details summary::-webkit-details-marker { display: none; }
.more-details .detail-props { margin-top: 0.5rem; }

/* Bohr model SVG */
#bohr-svg { max-width: 240px; margin: 0 auto; display: block; }
.bohr-shell { fill: none; stroke: var(--border); stroke-width: 0.8; }
.bohr-electron { stroke: none; }
.bohr-electron-s { fill: #4dabf7; }
.bohr-electron-p { fill: #69db7c; }
.bohr-electron-d { fill: #ffd43b; }
.bohr-electron-f { fill: #f783ac; }
.bohr-nucleus-circle { fill: var(--bg-panel); stroke: var(--accent); stroke-width: 1.5; }
.bohr-nucleus-symbol { fill: var(--text); font-size: 14px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.bohr-nucleus-z { fill: var(--text-dim); font-size: 8px; text-anchor: middle; }
.bohr-shell-label { fill: var(--text-dim); font-size: 7px; text-anchor: middle; }

/* SPDF orbital box diagram */
.spdf-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.spdf-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
}
.spdf-boxes {
  display: flex;
  gap: 2px;
}
.spdf-box {
  width: 22px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  position: relative;
  background: var(--bg);
}
.spdf-box.filled { border-color: var(--text-dim); }
.spdf-box .arrow-up,
.spdf-box .arrow-down {
  position: absolute;
  font-size: 13px;
  line-height: 1;
}
.spdf-box .arrow-up { top: 1px; color: #4dabf7; }
.spdf-box .arrow-down { bottom: 0px; color: #ff6b6b; transform: rotate(180deg); }
.spdf-electrons-count {
  font-size: 0.6rem;
  color: var(--text-dim);
  min-width: 16px;
}

/* 3D Orbital Viewer */
.orbital-3d-wrap {
  width: 100%;
  height: 280px;
  border-radius: 6px;
  overflow: hidden;
  background: radial-gradient(circle, #0d1117 0%, #060810 100%);
  position: relative;
}
.orbital-3d-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}
.orbital-3d-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 0.5rem;
}
.orbital-3d-toggle {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.orbital-3d-toggle.active {
  color: var(--text);
  background: var(--bg-panel);
}
.orbital-3d-toggle:not(.active) {
  opacity: 0.4;
}
.orbital-3d-hint {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.35rem;
  opacity: 0.6;
}

/* Orbital shape diagrams (2D fallback) */
.shapes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}
.shape-cell {
  text-align: center;
  background: var(--bg);
  border-radius: 6px;
  padding: 4px;
  border: 1px solid var(--border);
}
.shape-cell.occupied { border-color: var(--accent); }
.shape-cell.empty { opacity: 0.3; }
.shape-cell svg { width: 100%; height: auto; display: block; margin: 0 auto; }
.shape-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
  font-weight: 600;
}
.shape-cell.occupied .shape-label { color: var(--text); }
.shape-electrons {
  font-size: 0.55rem;
  color: var(--text-dim);
}
.shape-subshell-header {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  padding: 0.25rem 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
/* Orbital shape SVG fills */
.orbital-shape-s { fill: rgba(77, 171, 247, 0.3); stroke: #4dabf7; stroke-width: 1; }
.orbital-shape-p { fill: rgba(105, 219, 124, 0.3); stroke: #69db7c; stroke-width: 1; }
.orbital-shape-d { fill: rgba(255, 212, 59, 0.25); stroke: #ffd43b; stroke-width: 1; }
.orbital-shape-f { fill: rgba(247, 131, 172, 0.25); stroke: #f783ac; stroke-width: 1; }
.orbital-shape-empty { fill: rgba(173, 181, 189, 0.1); stroke: #495057; stroke-width: 0.5; }

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}
.site-footer .footer-links { margin-top: 0.5rem; }
.site-footer .footer-links a { color: var(--text-dim); margin: 0 0.25rem; }
.site-footer .footer-links a:hover { color: var(--accent); }
.affiliate-disclosure {
  max-width: 600px;
  margin: 0.75rem auto 0;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.7;
}

/* Scroll styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
