.periodic-page {
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 40px);
}

.periodic-page-header {
  display: grid;
  max-width: 920px;
  gap: 8px;
  padding: 18px 8px 0 76px;
}

.periodic-page-header h1 {
  color: #101827;
}

.periodic-page-header p {
  max-width: 740px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.58;
}

.periodic-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 18px;
  min-height: 0;
}

.periodic-table-panel,
.periodic-detail-card,
.periodic-legend-card {
  border: 1px solid rgba(217, 224, 232, 0.95);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.periodic-table-panel {
  min-width: 0;
  overflow: hidden;
}

.periodic-table-scroll {
  overflow: auto;
  padding: 16px;
}

.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(58px, 1fr));
  grid-auto-rows: 72px;
  gap: 6px;
  min-width: 1160px;
}

.periodic-element,
.periodic-series-label {
  min-width: 0;
  border-radius: 7px;
}

.periodic-element {
  position: relative;
  overflow: hidden;
  padding: 7px;
  border: 1px solid rgba(16, 24, 39, 0.16);
  color: #0f172a;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    filter 150ms ease;
}

.periodic-element:hover,
.periodic-element:focus-visible {
  z-index: 4;
  transform: translateY(-3px) scale(1.04);
  filter: brightness(1.04);
  box-shadow:
    0 14px 28px rgba(30, 41, 59, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.periodic-element.is-selected {
  z-index: 3;
  border-color: rgba(15, 107, 255, 0.58);
  box-shadow:
    0 0 0 3px rgba(15, 107, 255, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

.periodic-number {
  position: absolute;
  top: 6px;
  left: 7px;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.72;
}

.periodic-symbol {
  position: absolute;
  top: 18px;
  right: 5px;
  left: 5px;
  display: block;
  margin: 0;
  font-size: 1.36rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.periodic-name {
  position: absolute;
  top: 44px;
  right: 5px;
  left: 5px;
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.periodic-mass {
  position: absolute;
  right: 7px;
  bottom: 5px;
  font-size: 0.5rem;
  font-weight: 800;
  opacity: 0.72;
}

.periodic-series-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px dashed rgba(91, 105, 125, 0.36);
  background: rgba(255, 255, 255, 0.5);
  color: #526075;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.periodic-sidebar {
  display: grid;
  gap: 18px;
}

.periodic-detail-card {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
  padding: 20px;
}

.periodic-detail-heading {
  display: grid;
  gap: 4px;
}

.periodic-detail-heading h2 {
  color: #111827;
  font-size: 1.6rem;
  line-height: 1;
}

.periodic-detail-heading p {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.periodic-detail-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 86px;
  height: 86px;
  border: 1px solid rgba(16, 24, 39, 0.14);
  border-radius: var(--radius);
  color: #0f172a;
  font-size: 2.7rem;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.periodic-facts {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
  font-size: 0.88rem;
}

.periodic-facts dt {
  color: var(--muted);
}

.periodic-facts dd {
  min-width: 0;
  margin: 0;
  color: #202838;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.periodic-legend-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.periodic-legend-card h2 {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.periodic-legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.periodic-legend-item {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: #30394a;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.periodic-swatch {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 1px solid rgba(16, 24, 39, 0.12);
  border-radius: 5px;
}

.periodic-page .category-alkali-metal {
  background: #ff8a80;
}

.periodic-page .category-alkaline-earth-metal {
  background: #ffb15f;
}

.periodic-page .category-transition-metal {
  background: #ffd65a;
}

.periodic-page .category-post-transition-metal {
  background: #b8e66d;
}

.periodic-page .category-metalloid {
  background: #58d6a2;
}

.periodic-page .category-nonmetal {
  background: #5dd4e8;
}

.periodic-page .category-halogen {
  background: #73a8ff;
}

.periodic-page .category-noble-gas {
  background: #b79cff;
}

.periodic-page .category-lanthanide {
  background: #f58ac4;
}

.periodic-page .category-actinide {
  background: #d29af2;
}

.periodic-page .category-unknown {
  background: #b8c1cc;
}

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

  .periodic-detail-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .periodic-page {
    gap: 12px;
    min-height: calc(100vh - 24px);
  }

  .periodic-page-header {
    padding: 14px 4px 2px 68px;
  }

  .periodic-page-header p {
    font-size: 0.92rem;
  }

  .periodic-workspace,
  .periodic-sidebar {
    gap: 12px;
  }

  .periodic-table-scroll {
    padding: 10px;
  }

  .periodic-table {
    min-width: 1080px;
  }

  .periodic-detail-card,
  .periodic-legend-card {
    padding: 16px;
  }

  .periodic-legend-grid {
    grid-template-columns: 1fr;
  }
}
