/* ============================================================
   ChemSciHub · 元素周期表样式（ptable.css）
   布局参考 ptable.com：18 列主网格 + 镧系/锕系两行；
   元素配色采用 CPK / Jmol 扩展（每元素独立色，非分类色）。
   深色主题适配：格子底色 = CPK 色，文字色由 JS 按亮度自适应。
   ============================================================ */

/* ---------- 控制栏 ---------- */
.pt-controls {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  margin: 0 0 14px;
}
.pt-search {
  position: relative; flex: 1 1 220px; max-width: 320px;
  display: flex; align-items: center;
}
.pt-search svg { position: absolute; left: 10px; color: var(--accent); pointer-events: none; }
.pt-search input {
  width: 100%; padding: 8px 10px 8px 32px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13.5px; outline: none;
}
.pt-search input:focus { border-color: var(--accent); }
.pt-search input::placeholder { color: var(--muted); }
.pt-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pt-count b { color: var(--accent); }

/* ---------- 筛选 chips ---------- */
.pt-filters { margin: 0 0 16px; }
.pt-frow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.pt-frow:last-child { margin-bottom: 0; }
.pt-flabel {
  font-size: 11.5px; color: var(--muted); min-width: 58px; letter-spacing: .04em;
}
.pt-chip {
  padding: 3px 10px; font-size: 12px; line-height: 1.5;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); cursor: pointer; user-select: none;
  transition: color .12s, border-color .12s, background .12s;
}
.pt-chip:hover { color: var(--text); border-color: var(--accent-2); }
.pt-chip.on {
  color: var(--bg); background: var(--accent); border-color: var(--accent);
  font-weight: 600;
}
.pt-reset {
  margin-left: auto; font-size: 12px; color: var(--accent-2);
  background: none; border: none; cursor: pointer; padding: 3px 4px;
}
.pt-reset:hover { text-decoration: underline; }

/* ---------- 周期表网格 ---------- */
.pt-wrap { overflow-x: auto; padding-bottom: 4px; }
.pt-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(34px, 1fr));
  gap: 4px;
  min-width: 640px;
}
.pt-cell {
  position: relative;
  align-self: start;
  aspect-ratio: 1 / 1.06;
  border: 1px solid rgba(128,140,160,.22);
  border-radius: 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  cursor: pointer; overflow: hidden;
  transition: transform .1s, box-shadow .1s, opacity .15s;
  padding: 4px 3px 3px;
  container-type: inline-size; /* 供子元素按格子宽度自适应字号 */
}
.pt-cell:hover {
  transform: scale(1.12); z-index: 5;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  border-color: rgba(255,255,255,.55);
}
.pt-cell .z { align-self: flex-start; font-size: 9px; font-size: clamp(6.5px, 22cqw, 9.5px); opacity: .8; line-height: 1; white-space: nowrap; }
.pt-cell .sym { font-size: clamp(13px, 1.35vw, 17px); font-size: clamp(10px, 40cqw, 17px); font-weight: 700; line-height: 1; margin: auto 0; }
.pt-cell .ms { align-self: flex-end; font-size: 8px; font-size: clamp(5.5px, 17cqw, 8px); opacity: .75; line-height: 1; white-space: nowrap; letter-spacing: -.02em; }
.pt-cell.dim { opacity: .14; pointer-events: none; }
.pt-cell.hit { box-shadow: 0 0 0 2px var(--accent); }
.pt-cell.sel { box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(79,209,197,.45); }

/* f 区块占位（57-71 / 89-103） */
.pt-fnote {
  aspect-ratio: 1 / 1.06;
  border: 1px dashed var(--border); border-radius: 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9.5px; color: var(--muted); cursor: pointer; gap: 1px;
  background: rgba(42,53,72,.25);
}
.pt-fnote:hover { color: var(--accent); border-color: var(--accent); }
.pt-fnote b { font-size: 11px; font-weight: 600; }

/* 镧系/锕系行标签 */
.pt-series-tag {
  grid-column: 1 / 3;
  display: flex; align-items: center; justify-content: flex-end;
  font-size: 11px; color: var(--muted); padding-right: 8px; text-align: right; line-height: 1.3;
}
.pt-series-tag b { color: var(--text); font-weight: 600; }

/* ---------- 图例 ---------- */
.pt-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  margin: 16px 0 0; padding: 10px 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  font-size: 11.5px; color: var(--muted);
}
.pt-legend .lg-item { display: inline-flex; align-items: center; gap: 5px; }
.pt-legend .sw { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(255,255,255,.18); }
.pt-legend .lg-note { margin-left: auto; opacity: .8; }

/* ---------- 详情面板（嵌入周期表左上空白区：H–He 之间） ---------- */
.pt-detail {
  align-self: stretch;
  background: var(--bg-soft); border: none; border-radius: 0;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
  overflow: hidden;
}
.pt-detail-empty { color: var(--muted); font-size: 11.5px; text-align: center; margin: auto; padding: 6px 0; line-height: 1.6; }
.pt-detail-empty kbd {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 4px; font-size: 10px; font-family: inherit;
}
.pt-d-head { display: flex; gap: 10px; align-items: stretch; flex: 1 1 auto; min-height: 0; }
.pt-d-tile {
  align-self: stretch;
  aspect-ratio: 1 / 1;
  width: auto; height: auto;
  border: 1px solid rgba(128,140,160,.3); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.pt-d-tile .z { position: absolute; top: 4px; left: 6px; font-size: 10px; opacity: .75; }
.pt-d-tile .sym { font-size: 30px; font-weight: 700; line-height: 1; }
.pt-d-tile .ms { position: absolute; bottom: 4px; right: 6px; font-size: 9px; opacity: .7; }
.pt-d-title {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between;
}
.pt-d-name { display: flex; flex-direction: column; gap: 2px; }
.pt-d-title h4 { margin: 0; font-size: 14px; line-height: 1.25; }
.pt-d-title h4 small { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 5px; }
.pt-d-title .d-sub { color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.pt-d-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.pt-d-tag {
  font-size: 9.5px; padding: 0 6px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted);
}
.pt-d-tag.cat { color: var(--text); }
.pt-d-shell { align-self: center; flex: none; }
.pt-d-nav { display: flex; flex-direction: column; gap: 0; margin-left: auto; flex: none; align-self: stretch; justify-content: space-between; }
.pt-d-nav button {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted); font-size: 10px; padding: 2px 10px; cursor: pointer; line-height: 1.5;
  white-space: nowrap;
}
.pt-d-nav button:hover { color: var(--text); border-color: var(--accent-2); }
.pt-d-shell { flex: none; line-height: 0; }
.pt-d-shell svg { display: block; }

.pt-d-row { display: flex; gap: 4px 12px; }
.pt-d-item { font-size: 11.5px; min-width: 0; flex: 1; }
.pt-d-item.cfg { flex: 1.7; }
.pt-d-item .k { font-size: 9px; color: var(--muted); display: block; line-height: 1.3; white-space: nowrap; }
.pt-d-item .v { font-variant-numeric: tabular-nums; }
.pt-d-item .v small { color: var(--muted); font-weight: 400; }

/* ---------- 数据说明 ---------- */
.pt-src { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.pt-src b { color: var(--text); font-weight: 600; }

@media (max-width: 720px) {
  .pt-grid { min-width: 600px; }
  .pt-search { max-width: none; }
}
