:root {
  color-scheme: dark;
  --bg-main: #1a1d22;
  --bg-panel: rgba(23, 27, 35, 0.86);
  --bg-panel-strong: rgba(18, 22, 28, 0.96);
  --text-main: #eef3ff;
  --text-soft: #b8c4dc;
  --muted: #8791a8;
  --line: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 89, 89, 0.18), transparent 30%),
    radial-gradient(circle at 86% 20%, rgba(50, 214, 255, 0.16), transparent 32%),
    radial-gradient(circle at 50% 92%, rgba(90, 255, 179, 0.14), transparent 35%),
    linear-gradient(180deg, #252a31 0%, #181c22 60%, #15181d 100%);
  color: var(--text-main);
  overflow-x: hidden;
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.03) 0,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 28px
  );
  opacity: 0.25;
  z-index: -1;
}

.app-shell {
  width: min(100%, 1880px);
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 2.2vw, 2rem) 3rem;
}

.site-menu-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.95rem;
}

.site-menu {
  position: relative;
}

.site-menu > summary {
  list-style: none;
}

.site-menu > summary::-webkit-details-marker {
  display: none;
}

.menu-button {
  border: 1px solid rgba(126, 219, 255, 0.45);
  border-radius: 999px;
  padding: 0.52rem 1rem;
  min-width: 110px;
  text-align: center;
  background: linear-gradient(
    145deg,
    rgba(28, 35, 44, 0.96),
    rgba(17, 22, 29, 0.98)
  );
  color: #f0f7ff;
  font-family: "Orbitron", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 18px rgba(73, 209, 255, 0.24);
}

.menu-button:hover,
.menu-button:focus-visible {
  border-color: rgba(126, 219, 255, 0.8);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 0 22px rgba(126, 219, 255, 0.36);
}

.menu-panel {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  min-width: 220px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 0.5rem;
  background: rgba(12, 16, 23, 0.97);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.38);
  display: grid;
  gap: 0.4rem;
  z-index: 30;
}

.menu-link {
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.56rem 0.72rem;
  color: #dce9ff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.menu-link:hover,
.menu-link:focus-visible {
  border-color: rgba(118, 228, 255, 0.64);
  box-shadow: 0 0 14px rgba(118, 228, 255, 0.22);
  transform: translateY(-1px);
}

.menu-link.active {
  border-color: rgba(255, 153, 88, 0.68);
  box-shadow: 0 0 14px rgba(255, 153, 88, 0.24);
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr minmax(250px, 430px);
  gap: 1.25rem;
  align-items: end;
  margin-bottom: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.19em;
  color: #87d2ff;
  font-size: 0.75rem;
  margin: 0;
}

h1 {
  margin: 0.35rem 0 0.65rem;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
  font-size: clamp(1.9rem, 3.8vw, 3.15rem);
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
  max-width: 62ch;
  line-height: 1.45;
}

.hero-controls {
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-panel);
  backdrop-filter: blur(6px);
}

.hero-controls label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-soft);
}

#search-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #0f1318;
  color: var(--text-main);
  border-radius: 10px;
  padding: 0.72rem 0.88rem;
  font-size: 0.98rem;
  outline: none;
  font-family: inherit;
}

#search-input:focus {
  border-color: #5ed0ff;
  box-shadow: 0 0 0 2px rgba(94, 208, 255, 0.25);
}

.scroll-note {
  margin: 0.55rem 0 0;
  color: #ffdca0;
  font-size: 0.82rem;
}

.legend-wrap {
  margin: 1rem 0 1.2rem;
}

.legend-wrap h2 {
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  margin: 0 0 0.62rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
}

.legend button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: #0f1318;
  color: var(--text-main);
  font-size: 0.82rem;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, filter 180ms ease;
}

.legend button:hover,
.legend button:focus-visible {
  border-color: var(--swatch, rgba(255, 255, 255, 0.7));
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.legend button.active {
  box-shadow: 0 0 18px color-mix(in srgb, var(--swatch), transparent 45%);
}

.legend .swatch {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.36rem;
  vertical-align: middle;
  box-shadow: 0 0 10px currentColor;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-panel);
  padding: 0.95rem;
  margin-bottom: 1.15rem;
}

.table-scroll {
  overflow: hidden;
  padding-bottom: 0.55rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.table-scroll::-webkit-scrollbar {
  height: 11px;
}

.table-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 999px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(255, 89, 89, 0.7), rgba(74, 208, 255, 0.78));
  border-radius: 999px;
}

.periodic-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  display: grid;
  grid-template-columns: repeat(18, 92px);
  grid-template-rows: repeat(10, 108px);
  gap: 0.58rem;
  align-items: stretch;
  animation: fade-grid 600ms ease;
  transform-origin: top left;
}

.table-fit-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

@keyframes fade-grid {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tile-placeholder {
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  color: #ced9f4;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.03);
}

.element-tile {
  border: 1px solid color-mix(in srgb, var(--family-color), transparent 57%);
  border-radius: 12px;
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--family-color), #0d1116 76%) 0%,
    #0f1319 86%
  );
  color: var(--text-main);
  padding: 0.38rem 0.4rem 0.45rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 14px color-mix(in srgb, var(--family-color), transparent 62%);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    filter 180ms ease;
  opacity: 0;
  transform: translateY(10px);
  animation: tile-in 460ms ease forwards;
  animation-delay: calc(var(--index, 0) * 8ms);
}

@keyframes tile-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.element-tile:hover,
.element-tile:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--family-color), white 24%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07) inset,
    0 0 21px color-mix(in srgb, var(--family-color), transparent 48%);
  filter: saturate(1.1);
  z-index: 2;
}

.element-tile.active {
  border-color: color-mix(in srgb, var(--family-color), white 18%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 0 24px color-mix(in srgb, var(--family-color), transparent 42%);
}

.element-tile .num {
  font-size: 0.71rem;
  color: #d8e4ff;
  opacity: 0.9;
}

.element-tile .symbol {
  font-family: "Orbitron", sans-serif;
  font-size: 1.18rem;
  letter-spacing: 0.03em;
  line-height: 1;
  text-shadow: 0 0 11px color-mix(in srgb, var(--family-color), transparent 30%);
}

.element-tile .name {
  font-size: 0.71rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c6d4f2;
}

.element-tile .mass {
  font-size: 0.67rem;
  color: #b5c1d8;
}

.element-tile.hidden {
  opacity: 0.14;
  filter: grayscale(0.85);
  pointer-events: none;
}

.element-tile.dimmed {
  opacity: 0.28;
}

.details {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-panel-strong);
  padding: 1rem;
}

.details-empty {
  min-height: 220px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--text-soft);
}

.details-empty h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
}

.detail-card {
  display: grid;
  gap: 1rem;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}

.atomic-number {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: #a7b7d5;
}

.detail-head h2 {
  margin: 0.24rem 0 0.22rem;
  font-size: clamp(1.32rem, 2.4vw, 1.85rem);
  font-family: "Orbitron", sans-serif;
}

.meta-line {
  margin: 0;
  color: #c2d1ee;
}

.symbol-pill {
  width: 78px;
  height: 78px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 22px color-mix(in srgb, var(--family-color), transparent 45%);
  background: color-mix(in srgb, var(--family-color), #0e141b 75%);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1rem;
}

.element-photo-panel,
.summary-panel,
.structure-panel,
.lewis-panel,
.full-data-panel,
.links-panel,
.facts-grid {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.85rem;
}

.element-photo-panel {
  margin: 0;
  grid-column: 1;
}

.element-photo {
  width: 100%;
  height: 265px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.photo-caption {
  margin-top: 0.6rem;
  font-size: 0.76rem;
  color: #b1bfd8;
  line-height: 1.35;
}

.facts-grid {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  align-content: start;
}

.fact {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0.54rem;
  background: color-mix(in srgb, var(--family-color), #10151b 90%);
}

.fact .label {
  margin: 0;
  font-size: 0.7rem;
  color: #c2d0ea;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fact .value {
  margin: 0.34rem 0 0;
  font-size: 0.91rem;
  color: #f2f7ff;
}

.summary-panel {
  grid-column: 1 / span 2;
}

.summary-panel h3,
.structure-panel h3,
.lewis-panel h3,
.full-data-panel h3,
.links-panel h3 {
  margin: 0 0 0.55rem;
  font-size: 0.94rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c4d4ef;
}

.summary {
  margin: 0;
  line-height: 1.5;
  color: #dde7fb;
}

.structure-panel {
  grid-column: 1;
}

.structure-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  align-items: start;
}

.bohr-svg-wrap {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0d1116;
  min-height: 190px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.bohr-image {
  width: 100%;
  min-height: 190px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  object-fit: contain;
  background: #0f1319;
}

.lewis-panel {
  grid-column: 2;
}

.lewis-wrap {
  min-height: 190px;
  display: grid;
  place-items: center;
}

.lewis-structure {
  position: relative;
  width: 170px;
  height: 170px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(
    155deg,
    color-mix(in srgb, var(--family-color), #11161d 78%),
    #0e1319
  );
}

.lewis-symbol {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: 2.25rem;
  color: #f7fbff;
  text-shadow: 0 0 12px color-mix(in srgb, var(--family-color), transparent 25%);
}

.lewis-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--family-color), #ffffff 30%);
  box-shadow: 0 0 9px color-mix(in srgb, var(--family-color), transparent 15%);
}

.lewis-note {
  margin: 0.42rem 0 0;
  color: #cfdbf4;
  font-size: 0.82rem;
  line-height: 1.42;
}

.full-data-panel {
  grid-column: 1 / span 2;
}

.all-info-grid {
  max-height: 340px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.58rem;
  padding-right: 0.25rem;
}

.all-info-grid::-webkit-scrollbar {
  width: 10px;
}

.all-info-grid::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--family-color), #ffffff 65%);
  border-radius: 999px;
}

.all-info-item {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0.52rem;
  background: color-mix(in srgb, var(--family-color), #10151b 90%);
}

.all-info-label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #baccf1;
}

.all-info-value {
  margin: 0.32rem 0 0;
  color: #eef5ff;
  font-size: 0.86rem;
  line-height: 1.35;
  word-break: break-word;
}

.all-info-value a {
  color: #83ddff;
}

.links-panel {
  grid-column: 1 / span 2;
}

.links-panel a {
  color: #7fd7ff;
}

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

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .element-photo-panel,
  .facts-grid,
  .summary-panel,
  .structure-panel,
  .lewis-panel,
  .full-data-panel,
  .links-panel {
    grid-column: 1;
  }

  .structure-content {
    grid-template-columns: 1fr;
  }

  .periodic-grid {
    grid-template-columns: repeat(18, 84px);
    grid-template-rows: repeat(10, 100px);
    gap: 0.5rem;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 1.2rem 0.65rem 2rem;
  }

  .table-wrap,
  .details,
  .hero-controls {
    border-radius: 14px;
  }

  .periodic-grid {
    grid-template-columns: repeat(18, 77px);
    grid-template-rows: repeat(10, 95px);
    gap: 0.43rem;
  }

  .element-tile .symbol {
    font-size: 1.05rem;
  }

  .element-tile .name,
  .element-tile .mass {
    font-size: 0.64rem;
  }

  .symbol-pill {
    width: 68px;
    height: 68px;
    font-size: 1.65rem;
  }

  .all-info-grid {
    grid-template-columns: 1fr;
    max-height: 300px;
  }
}
