/* แล็บตารางธาตุ 3 มิติ — เวทีซ้าย / แผงข้อมูลขวา */
:root{
  --sans:'IBM Plex Sans Thai','Noto Sans Thai',system-ui,-apple-system,'Segoe UI',sans-serif;
  --ink:#191a24; --muted:#6b6c7e; --line:#e6e3dc; --surface:#fff; --bg:#f5f4ef;
  --brand:#2e7d88; --brand-ink:#1f5f68; --brand-soft:#dcecee;
  --ok:#129a72; --warn:#d68a17; --danger:#e2564a;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden}
body{font-family:var(--sans);color:var(--ink);background:var(--bg);display:flex;flex-direction:column;
  -webkit-font-smoothing:antialiased;user-select:none;-webkit-user-select:none}

#stage{position:relative;flex:1;min-height:0;background:#0e1020}
#webgl-canvas{width:100%;height:100%;display:block;touch-action:none}

.status{
  position:absolute;left:12px;top:12px;right:96px;
  background:rgba(255,255,255,.95);border:1px solid var(--line);border-radius:12px;
  padding:8px 13px;font-size:.82rem;box-shadow:0 4px 14px rgba(0,0,0,.3);
  pointer-events:none;max-width:min(560px,calc(100% - 120px));line-height:1.5;
}
.status.ok{border-color:#bfe9da;color:#0a6b50;background:#f0fbf7}
.status.bad{border-color:#f6cdc9;color:#8f2018;background:#fdf3f2}
.status.warn{border-color:#f7e2bd;color:#7d5209;background:#fffaf0}

#panel{
  flex:none;background:var(--surface);border-top:1px solid var(--line);
  padding:12px 14px 14px;display:flex;flex-direction:column;gap:9px;max-height:54vh;overflow-y:auto;
}
.panel-head{display:flex;align-items:baseline;gap:10px}
.panel-title{font-weight:700;font-size:.92rem}
.goal{font-size:.78rem;color:var(--muted);margin-left:auto;text-align:right}
.hint{margin:0;font-size:.72rem;color:var(--muted);line-height:1.5}

/* การ์ดธาตุ */
.el-card{border:1px solid var(--line);border-left:6px solid var(--brand);border-radius:12px;padding:10px 12px;background:var(--bg)}
.el-card[hidden]{display:none}
.el-top{display:flex;justify-content:space-between;align-items:center;font-size:.72rem}
.el-num{font-weight:700;color:var(--muted)}
.el-cat{padding:1px 8px;border-radius:999px;color:#fff;font-weight:600;font-size:.68rem}
.el-sym{font-size:2rem;font-weight:800;line-height:1.1;margin:2px 0}
.el-name{font-size:.9rem;font-weight:600}
.el-sample-wrap{position:relative;margin:8px 0 2px;border-radius:10px;overflow:hidden;border:1px solid var(--line)}
.el-sample{display:block;width:100%;height:auto;background:#eef1f6}
.el-phase{position:absolute;right:8px;bottom:6px;font-size:.66rem;font-weight:600;color:#fff;background:rgba(20,22,30,.55);padding:1px 8px;border-radius:999px;backdrop-filter:blur(2px)}
.el-rows{margin-top:6px;display:grid;grid-template-columns:1fr 1fr;gap:3px 10px;font-size:.76rem}
.el-rows .k{color:var(--muted)}

/* ตัวกรองหมวด */
.legend{display:flex;flex-wrap:wrap;gap:5px}
.lg-chip{display:flex;align-items:center;gap:5px;border:1px solid var(--line);background:#fff;border-radius:999px;
  padding:3px 9px;font-size:.72rem;font-family:inherit;cursor:pointer;color:var(--ink)}
.lg-chip .dot{width:11px;height:11px;border-radius:50%;flex:none}
.lg-chip.on{border-color:var(--brand);background:var(--brand-soft);color:var(--brand-ink);font-weight:600}

.quiz{display:flex;flex-direction:column;gap:6px;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:9px 11px}
.qz-q{font-size:.78rem;font-weight:600;line-height:1.5}
.btn-sm{align-self:flex-start;padding:5px 12px;font-size:.74rem;box-shadow:none}

.tasks{display:flex;flex-direction:column;gap:5px}
.tk-head{font-size:.78rem;font-weight:600;color:var(--muted)}
.tk-head span:last-child{background:var(--brand-soft);color:var(--brand-ink);padding:1px 8px;border-radius:999px;font-size:.72rem}
.task-list{display:flex;flex-direction:column;gap:4px}
.task-item{display:flex;align-items:center;gap:7px;font-size:.78rem;padding:6px 9px;border-radius:8px;background:var(--bg)}
.task-item.is-done{background:#e9f8f2;color:#0a6b50}
.task-check{width:16px;height:16px;border-radius:50%;border:2px solid var(--line);flex:none}
.task-item.is-done .task-check{background:var(--ok);border-color:var(--ok)}

.actions{display:flex;gap:8px}
.btn{padding:10px 14px;border-radius:999px;border:1px solid transparent;font-family:inherit;
  font-size:.84rem;font-weight:600;cursor:pointer;box-shadow:0 2px 6px rgba(25,26,36,.12)}
.btn:active{transform:translateY(1px)}
.btn[disabled]{opacity:.45;pointer-events:none}
.btn-ghost{background:var(--surface);border-color:var(--line);color:var(--ink)}
.btn-submit{background:var(--ok);color:#fff;flex:1}

@media (min-width:900px){
  body{flex-direction:row}
  #panel{width:352px;max-height:none;height:100%;border-top:none;border-left:1px solid var(--line);padding:16px}
}
@media (max-width:560px){
  .status{position:static;margin:8px 12px;max-width:none;right:auto}
  #stage{display:flex;flex-direction:column;min-height:46vh}
  #webgl-canvas{flex:1;min-height:200px}
}

/* ---------- แผนที่ความร้อน · กราฟแนวโน้ม · เทียบธาตุ ---------- */
.box-head{display:flex;align-items:center;gap:8px;font-size:.78rem;font-weight:600;color:var(--muted)}
.prop-box,.trend-box,.cmp-box{display:flex;flex-direction:column;gap:6px;
  border:1px solid var(--line);border-radius:12px;padding:9px 11px;background:var(--bg)}

.prop-chips{display:flex;flex-wrap:wrap;gap:5px}
.pp-chip{border:1px solid var(--line);background:#fff;border-radius:999px;padding:3px 10px;
  font-size:.72rem;font-family:inherit;cursor:pointer;color:var(--ink)}
.pp-chip:hover{border-color:var(--brand)}
.pp-chip.on{border-color:var(--brand);background:var(--brand);color:#fff;font-weight:600}
.prop-scale{display:flex;align-items:center;gap:7px}
.prop-scale[hidden]{display:none}
.ps-end{font-size:.68rem;color:var(--muted);font-variant-numeric:tabular-nums;white-space:nowrap}
.ps-bar{flex:1;height:10px;border-radius:999px;border:1px solid var(--line)}

.trend-sel{display:flex;gap:5px;align-items:center}
.tg-btn{border:1px solid var(--line);background:#fff;border-radius:999px;padding:3px 11px;
  font-size:.72rem;font-family:inherit;cursor:pointer;color:var(--ink)}
.tg-btn.on{border-color:var(--brand);background:var(--brand-soft);color:var(--brand-ink);font-weight:600}
.tg-pick{margin-left:auto;font-family:inherit;font-size:.74rem;padding:3px 8px;border-radius:8px;
  border:1px solid var(--line);background:#fff;color:var(--ink)}
.trend-cv{display:block;width:100%;height:auto;border-radius:10px;background:#fff;border:1px solid var(--line)}

.cmp-clear{margin-left:auto;border:1px solid var(--line);background:#fff;border-radius:999px;
  padding:2px 10px;font-size:.7rem;font-family:inherit;cursor:pointer;color:var(--muted)}
.cmp-slots{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.cmp-slot{display:flex;align-items:center;gap:7px;border:1px solid var(--line);border-radius:10px;
  padding:6px 8px;background:#fff;min-width:0}
.cmp-slot.empty{color:var(--muted);font-size:.72rem;justify-content:center}
.cs-sym{font-size:1.05rem;font-weight:800;line-height:1}
.cs-name{font-size:.7rem;color:var(--muted);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cs-pin{border:0;background:none;font-size:.85rem;cursor:pointer;padding:0 2px;opacity:.35;line-height:1}
.cs-pin.on{opacity:1}
.cmp-rows{display:grid;grid-template-columns:1fr auto auto auto;gap:2px 8px;font-size:.74rem;align-items:baseline}
.cr-k{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cr-v{font-variant-numeric:tabular-nums;text-align:right;min-width:52px}
.cr-v.win{font-weight:800;color:var(--brand-ink)}
.cr-arrow{color:var(--muted);font-size:.7rem;text-align:center;width:16px}
