:root {
  --bg: #0a0e14;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #3dff9a;
  --line: rgba(255, 255, 255, 0.08);
  --periodic-cell-w: 51px;
  --periodic-cell-h: 53px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

body.page-pt2 {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2744 0%, var(--bg) 55%);
  color: var(--text);
}

.hidden { display: none !important; }

.pt2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.95);
}

.pt2-brand {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.pt2-nav {
  display: flex;
  gap: 0.85rem;
  font-size: 0.88rem;
}

.pt2-nav a {
  color: var(--muted);
  text-decoration: none;
}

.pt2-nav a:hover { color: var(--text); }

.main--pt2 { max-width: none; padding: 0; }

.page-pt2 { overflow-x: auto; }

.pt2-app {
  min-height: calc(100vh - 2.8rem);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.pt2-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.pt2-toolbar__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
}

.pt2-toolbar__lead {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.pt2-toolbar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.pt2-search__input {
  width: 9rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}

.pt2-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(61, 255, 154, 0.12);
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}

.pt2-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.pt2-btn--link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.pt2-view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.pt2-view-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.38rem 0.8rem;
  cursor: pointer;
}

.pt2-view-btn.is-active {
  background: rgba(61, 255, 154, 0.18);
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.pt2-anim-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.pt2-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
}

.pt2-scene-wrap {
  position: relative;
  padding: 0.75rem;
  overflow: auto;
}

.pt2-fast-grid {
  display: grid;
  gap: 3px;
  width: max-content;
  margin: 0 auto;
}

.pt2-scene {
  display: none;
  width: 100%;
  min-height: 420px;
  cursor: grab;
}

.pt2-scene.is-active { display: block; }

.pt2-fast-grid.is-hidden { display: none; }

.pt2-scene-hint {
  margin: 0.5rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
}

.el {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--periodic-cell-w);
  height: var(--periodic-cell-h);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  font-size: 0.68rem;
  line-height: 1.15;
  color: inherit;
  text-decoration: none;
  padding: 2px;
  font-family: ui-monospace, monospace;
  cursor: pointer;
  appearance: none;
  background: #2a2a32;
}

.el:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.pt2-cell.is-selected {
  outline: 2px solid var(--accent);
  z-index: 1;
}

.pt2-cell.is-group-peer {
  box-shadow: inset 0 0 0 1px rgba(61, 255, 154, 0.45);
}

.el-z { font-size: 0.6rem; opacity: 0.75; }
.el-sym { font-weight: 700; font-size: 0.9rem; }
.el-name {
  max-width: 100%;
  font-size: 0.48rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.86;
}

.cat-diatomic { background: linear-gradient(145deg, #1e3a2f, #0f1f18); }
.cat-noble { background: linear-gradient(145deg, #2a1f4a, #151028); }
.cat-alkali { background: linear-gradient(145deg, #4a1f1f, #280f0f); }
.cat-alkaline { background: linear-gradient(145deg, #4a3a1a, #28200c); }
.cat-metalloid { background: linear-gradient(145deg, #2a3a1a, #14200c); }
.cat-polyatomic { background: linear-gradient(145deg, #1a3a3a, #0c2020); }
.cat-post-transition { background: linear-gradient(145deg, #2a3540, #151a22); }
.cat-transition { background: linear-gradient(145deg, #1a2840, #0c1428); }
.cat-lanthanide { background: linear-gradient(145deg, #352a40, #1a1422); }
.cat-actinide { background: linear-gradient(145deg, #403020, #221810); }
.el.grp-halogens { background: linear-gradient(145deg, #5e35b1, #311b92); }

.pt2-panel {
  border-left: 1px solid var(--line);
  background: rgba(18, 24, 38, 0.96);
  overflow-y: auto;
  max-height: calc(100vh - 5rem);
}

.pt2-panel__empty,
.pt2-panel__body { padding: 1rem; }

.pt2-panel__empty-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 0.4rem; }
.pt2-panel__empty-text { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }

.pt2-panel__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pt2-panel__sym {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  background: rgba(61, 255, 154, 0.12);
  border: 1px solid rgba(61, 255, 154, 0.28);
  color: var(--accent);
}

.pt2-panel__name { font-size: 1.1rem; font-weight: 800; }
.pt2-panel__meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }

.pt2-panel__atom {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 40%, rgba(80, 120, 200, 0.12), rgba(0, 0, 0, 0.35));
  margin-bottom: 0.75rem;
}

.pt2-atom {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.pt2-bohr-fallback {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 0.5rem;
}

.pt2-atom-caption {
  margin: 0;
  padding: 0.45rem 0.65rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.pt2-scene-wrap--atom-focus .pt2-panel__atom {
  min-height: 360px;
}

.pt2-scene-wrap--atom-focus .pt2-atom,
.pt2-scene-wrap--atom-focus .pt2-bohr-fallback {
  min-height: 320px;
}

.pt2-photo {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.pt2-photo-cap { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }

.pt2-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.pt2-fact__text { font-size: 0.92rem; line-height: 1.4; margin-bottom: 0.75rem; }

.pt2-props__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pt2-props__row dt { color: var(--muted); margin: 0; }
.pt2-props__row dd { margin: 0; text-align: right; font-family: ui-monospace, monospace; font-size: 0.75rem; }

.pt2-summary { color: var(--muted); font-size: 0.84rem; line-height: 1.4; margin: 0.75rem 0; }

.pt2-detail-link {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: rgba(61, 255, 154, 0.18);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.88rem;
}

.pt2-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}

.pt2-legend__swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.2rem;
}

@media (max-width: 960px) {
  .pt2-stage { grid-template-columns: 1fr; }
  .pt2-panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
}
