:root {
  --bg: #07101a;
  --surface: #0c1622;
  --text: #dde8f4;
  --dim: rgba(221, 232, 244, 0.45);
  --border: rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 28px 24px;
}

/* ─── Header ──────────────────────────────────────── */

header {
  margin-bottom: 20px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.gh-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}

.gh-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.4px;
  background: linear-gradient(90deg, #e2eaf4 30%, #7eb8d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header input {
  display: block;
  width: 100%;
  max-width: 380px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: 14px;
}

header input::placeholder {
  color: var(--dim);
}

header input:focus {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(100, 180, 255, 0.1);
}

#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 11px;
  border-radius: 20px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.filter-btn::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat, transparent);
  flex-shrink: 0;
}

.filter-btn:not([data-cat])::before {
  display: none;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.filter-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

/* ─── Periodic Table ──────────────────────────────── */

#table-wrapper {
  overflow-x: auto;
  padding-bottom: 8px;
}

#table {
  display: grid;
  grid-template-columns: repeat(18, 52px);
  gap: 4px;
  width: max-content;
}

.blank {
  width: 52px;
  height: 60px;
}

.element {
  position: relative;
  width: 52px;
  height: 60px;
  background: color-mix(in srgb, var(--cat, #1a2535) 12%, #0c1622);
  border-radius: 6px;
  padding: 5px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 2px solid var(--cat, rgba(255, 255, 255, 0.08));
  transition: transform .12s, box-shadow .12s;
  z-index: 0;
}

.element:hover {
  transform: scale(1.22);
  z-index: 10;
  box-shadow:
    0 6px 24px color-mix(in srgb, var(--cat, #000) 55%, transparent),
    0 0 0 1px var(--cat, rgba(255, 255, 255, 0.1));
  border-color: var(--cat, rgba(255, 255, 255, 0.2));
}

.element:focus {
  outline: 2px solid var(--cat, rgba(14, 165, 164, 0.5));
  outline-offset: 2px;
}

.num {
  font-size: 9px;
  line-height: 1;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.sym {
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  align-self: center;
  color: var(--text);
  letter-spacing: -0.3px;
}

.name {
  font-size: 8.5px;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
  text-overflow: ellipsis;
  color: var(--dim);
}

/* ─── Modal ──────────────────────────────────────── */

#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  visibility: hidden;
  opacity: 0;
  transition: opacity .18s, visibility 0s .18s;
}

#modal[aria-hidden="false"] {
  visibility: visible;
  opacity: 1;
  transition: opacity .18s;
}

.modal-content {
  background: #0c1726;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 28px;
  border-radius: 16px;
  color: var(--text);
  width: min(400px, 95%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  position: relative;
}

.modal-content button#close {
  position: absolute;
  right: 16px;
  top: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  line-height: 1;
}

.modal-content button#close:hover {
  background: rgba(255, 255, 255, 0.12);
}

#details .symbol-hero {
  font-size: 80px;
  font-weight: 800;
  line-height: 1;
  margin: 0 0 4px;
  color: var(--cat, var(--text));
  letter-spacing: -2px;
}

#details h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

#details .props {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#details .prop {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 11px 13px;
}

#details .prop-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
  margin-bottom: 5px;
}

#details .prop-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
