:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel2: #1d2430;
  --line: #2a3342;
  --ink: #eef1f6;
  --dim: #9aa5b5;
  --accent: #ffcf5a;
  --c-alkali: #ef6f6c;
  --c-alkaline: #f4a259;
  --c-transition: #f2cf63;
  --c-post: #9fb3c8;
  --c-metalloid: #5cc28c;
  --c-nonmetal: #6aa9ff;
  --c-halogen: #3fd0de;
  --c-noble: #b39ddb;
  --c-lanthanide: #f48fb1;
  --c-actinide: #d17be0;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Sora, system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; padding: 20px 24px 10px; max-width: 1500px; margin: 0 auto; }
.title h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.title p { margin: 4px 0 0; color: var(--dim); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ctl { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
select, input[type=search] { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input[type=search] { width: 170px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel2); border: 0; padding: 7px 12px; cursor: pointer; color: var(--dim); }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 600; }

main { max-width: 1500px; margin: 0 auto; padding: 0 24px 24px; }
.tablewrap { overflow-x: auto; padding: 8px 0 4px; }
.ptable { display: grid; grid-template-columns: repeat(18, minmax(46px, 1fr)); grid-template-rows: repeat(7, auto) 14px repeat(2, auto); gap: 4px; min-width: 900px; max-width: max(900px, calc((100dvh - 120px) * 1.8)); margin: 0 auto; position: relative; }
.tile { position: relative; aspect-ratio: 1 / 1.08; border-radius: 6px; border: 0; padding: 4px 5px; text-align: left; cursor: pointer; overflow: hidden;
  background: color-mix(in srgb, var(--tc) 22%, var(--panel)); color: var(--ink); transition: transform .12s, filter .12s, opacity .2s; }
.tile:hover, .tile:focus-visible { transform: scale(1.12); z-index: 3; outline: 2px solid var(--ink); outline-offset: 1px; }
.tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--tc); z-index: 2; }
.photos .tile::before { height: 4px; }
.tile .z { font-size: 10px; color: var(--dim); position: absolute; top: 5px; left: 6px; }
.tile .s { position: absolute; left: 6px; right: 4px; top: 30%; font-size: clamp(14px, 1.7vw, 24px); font-weight: 600; line-height: 1; }
.tile .n { position: absolute; left: 6px; right: 3px; bottom: 5px; font-size: clamp(7px, 0.62vw, 10px); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.guess { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255,255,255,.05) 5px 7px); }
.tile.dim { opacity: .18; }
.heat .tile { background: color-mix(in srgb, var(--tc) 72%, var(--panel)); text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.heat .tile .n, .heat .tile .z { color: rgba(255,255,255,.85); }
.tile .ph { position: absolute; inset: 0; background-size: cover; background-position: center; display: none; }
.photos .tile .ph { display: block; }
.photos .tile .ph::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,0) 60%); }
.photos .tile .s { top: auto; bottom: 16px; z-index: 1; text-shadow: 0 1px 3px #000; }
.photos .tile .n { z-index: 1; color: #d9dee6; }
.photos .tile .z { z-index: 1; color: #fff; text-shadow: 0 1px 2px #000; }
.ptable .fmark { display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--dim); border: 1px dashed var(--line); border-radius: 6px; }

.inset { grid-column: 3 / 13; grid-row: 1 / 4; display: flex; gap: 18px; align-items: stretch; padding: 4px 10px 10px; pointer-events: none; }
.inset .big { flex: 0 0 auto; width: 128px; border-radius: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--tc, #555) 24%, var(--panel)); box-shadow: inset 0 4px 0 var(--tc, #555); position: relative; }
.inset .big .z { font-size: 13px; color: var(--dim); }
.inset .big .s { font-size: 46px; font-weight: 700; line-height: 1.05; }
.inset .big .n { font-size: 13px; }
.inset .big .m { font-size: 12px; color: var(--dim); }
.inset .info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.inset .info .lead { font-size: 13px; color: var(--dim); }
.inset .info .lead b { color: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dim); pointer-events: auto; }
.legend .k { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 0; }
.legend .k i { width: 12px; height: 12px; border-radius: 3px; background: var(--kc); }
.legend .k.off { opacity: .35; }
.legend .ramp { display: flex; align-items: center; gap: 8px; width: 100%; }
.legend .ramp .bar { flex: 1; height: 10px; border-radius: 5px; max-width: 320px; }
.foot { color: var(--dim); font-size: 12px; margin-top: 16px; }

/* detail dialog */
dialog { width: min(1280px, 96vw); height: min(860px, 94vh); max-width: none; max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(5,7,10,.72); backdrop-filter: blur(3px); }
.dhead { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dhead .nav, .dhead .close { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; display: grid; place-items: center; }
.dhead svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dhead .close { margin-left: auto; }
.dtile { width: 62px; height: 66px; border-radius: 8px; padding: 4px 6px; position: relative; flex: 0 0 auto; background: color-mix(in srgb, var(--tc) 24%, var(--panel)); box-shadow: inset 0 3px 0 var(--tc); }
.dtile .z { font-size: 11px; color: var(--dim); }
.dtile .s { font-size: 28px; font-weight: 700; line-height: 1; margin-top: 2px; }
.dtitle h2 { margin: 0; font-size: 24px; font-weight: 700; }
.dsub { color: var(--dim); font-size: 13px; }
.dsub .chip { display: inline-block; padding: 1px 8px; border-radius: 99px; color: #111; background: var(--tc); font-weight: 600; font-size: 12px; margin-right: 6px; }
.dbody { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.viewer { min-width: 0; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.mtabs { display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; flex: 0 0 auto; }
.mtabs button { flex: 0 0 auto; border: 1px solid var(--line); border-bottom: 0; background: transparent; color: var(--dim); padding: 7px 12px; border-radius: 9px 9px 0 0; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.mtabs button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.mtabs button.on { background: #0a0d12; color: var(--ink); border-color: var(--line); }
.mtabs button:disabled { opacity: .35; cursor: default; }
.stage { position: relative; flex: 1; min-height: 260px; background: #0a0d12; border-top: 1px solid var(--line); overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.flat { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.flat:empty { display: none; }
.stagebar { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.stagebar > * { pointer-events: auto; }
.pill { border: 1px solid var(--line); background: rgba(22,27,36,.86); color: var(--ink); border-radius: 99px; padding: 5px 11px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pill.off { opacity: .45; }
a.pill { text-decoration: none; }
.pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--kc); }
.pill.note { cursor: default; color: var(--dim); }
.about { flex: 0 0 auto; padding: 12px 16px 14px; font-size: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.about p { margin: 0; }
.about b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.about .warn b { color: #ff9d8a; }
.facts { overflow-y: auto; padding: 14px 16px; }
.facts dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; font-weight: 600; }
.facts dd small { font-weight: 400; color: var(--dim); }
.facts h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 18px 0 8px; font-weight: 600; }
.facts h3:first-child { margin-top: 0; }
.pnc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.pnc div { background: var(--panel2); border-radius: 8px; padding: 8px 4px; }
.pnc .v { font-size: 22px; font-weight: 700; }
.pnc .l { font-size: 11px; color: var(--dim); }
.pnc .p .v { color: #ff7a6b; } .pnc .nn .v { color: #b8c2d0; } .pnc .e .v { color: #6ec3ff; }
.facts .iso { font-size: 12px; color: var(--dim); margin-top: 6px; }
.cfg { font-size: 15px; font-weight: 600; word-break: break-word; }
.cfg sup { font-size: 10px; }

/* photo */
.photo { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px 14px 56px; gap: 10px; }
.photo img { max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.photo .cap { font-size: 13px; color: var(--dim); text-align: center; max-width: 640px; }
.photo .tag { display: inline-block; background: #ff9d8a; color: #111; font-weight: 700; border-radius: 4px; padding: 0 6px; margin-right: 6px; font-size: 11px; }
.scan { position: absolute; inset: 0; }
.scan iframe { width: 100%; height: 100%; border: 0; }
.none { text-align: center; color: var(--dim); max-width: 440px; padding: 20px; }
.none .big { font-size: 64px; font-weight: 700; color: var(--ink); opacity: .25; }

/* 2D models */
.svgwrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 10px 10px 50px; }
.svgwrap svg { max-width: 100%; max-height: 100%; }
.spin { transform-origin: 0 0; animation: spin linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.paused .spin { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.orbs { padding: 18px 20px 60px; display: flex; gap: 14px; align-items: stretch; width: 100%; height: 100%; }
.orbs .axis { width: 22px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; color: var(--dim); font-size: 11px; }
.orbs .axis .ar { flex: 1; width: 2px; background: linear-gradient(to top, var(--line), var(--dim)); position: relative; margin: 4px 0; }
.orbs .axis .ar::before { content: ""; position: absolute; top: -6px; left: -5px; border: 6px solid transparent; border-bottom-color: var(--dim); border-top: 0; }
.orbs .axis span { writing-mode: vertical-rl; transform: rotate(180deg); }
.orbs .rows { flex: 1; display: flex; flex-direction: column-reverse; justify-content: center; gap: 6px; overflow-y: auto; }
.orow { display: flex; align-items: center; gap: 10px; }
.orow .lab { width: 34px; text-align: right; font-weight: 600; font-size: 14px; }
.orow .boxes { display: flex; gap: 0; }
.orow .box { width: 34px; height: 34px; border: 1.5px solid #5d6a7d; margin-right: -1.5px; display: flex; align-items: center; justify-content: center; gap: 1px; }
.orow .box svg { width: 10px; height: 24px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.orow .box .up { color: #6ec3ff; } .orow .box .dn { color: #ffb36b; }
.orow .cnt { color: var(--dim); font-size: 12px; margin-left: 6px; }
.orow.val .lab { color: var(--accent); }
.orow.core { color: var(--dim); font-size: 13px; }
.orow.core .chip { border: 1px dashed #5d6a7d; border-radius: 6px; padding: 6px 10px; }

.spec { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 20px 24px 60px; gap: 8px; }
.spec canvas { width: 100%; height: 150px; border-radius: 6px; display: block; }
.spec .ax { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; }
.spec .cap { color: var(--dim); font-size: 13px; }

@media (max-width: 900px) {
  .top { padding: 14px 16px 8px; }
  main { padding: 0 16px 16px; }
  dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .dbody { display: block; overflow-y: auto; }
  .stage { flex: 0 0 auto; height: 62dvh; min-height: 340px; }
  .viewer { border-right: 0; }
  .about { grid-template-columns: 1fr; }
  .dhead { gap: 8px; padding: 10px; }
  .dtile { display: none; }
  .dtitle h2 { font-size: 20px; }
  .facts { overflow: visible; border-top: 1px solid var(--line); }
}
