:root {
  --bg: #04050c;
  --panel: rgba(12, 14, 28, 0.78);
  --line: rgba(160, 175, 230, 0.16);
  --text: #e6e8f2;
  --muted: #8d93ad;
  --accent: #9fb4ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; overflow: hidden; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
button, input { font: inherit; color: inherit; }
button, .chip, .lbl .x, input[type=range] { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* panel */
#panel {
  position: fixed; top: 16px; left: 16px; width: 280px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
#panel header h1 { font: 700 22px/1.15 Tinos, Georgia, serif; margin: 0; letter-spacing: .2px; }
#panel header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
#panel section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.seg { display: flex; background: rgba(255,255,255,.05); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 0; border-radius: 7px; color: var(--muted); }
.seg button.on { background: rgba(159,180,255,.18); color: var(--text); }
.seg button:hover:not(.on) { color: var(--text); }
#pcaInfo { margin-top: 10px; display: grid; gap: 4px; }
.row { display: flex; justify-content: space-between; align-items: center; }
.row.gap { gap: 8px; justify-content: flex-start; margin-top: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 8px 0 2px; }
#run, #reset { border: 1px solid var(--line); background: rgba(255,255,255,.04); padding: 6px 12px; border-radius: 8px; }
#run.primary { background: rgba(159,180,255,.2); border-color: rgba(159,180,255,.35); }
#run:hover, #reset:hover { background: rgba(159,180,255,.28); }
#clusters { margin-top: 10px; }
.stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.clist { display: grid; gap: 3px; font-size: 12.5px; margin-bottom: 8px; max-height: 220px; overflow: auto; }
.clist div { display: flex; align-items: center; gap: 7px; }
.clist div span { margin-left: auto; }
.clist i, .lbl i, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
#search { width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; }
#search:focus { border-color: rgba(159,180,255,.5); }
#panelToggle { display: none; }

/* labels */
#labels { position: fixed; inset: 0; pointer-events: none; }
.lbl {
  position: absolute; left: 0; top: 0; pointer-events: auto; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; letter-spacing: .3px;
  padding: 3px 8px; border-radius: 20px; border: 1px solid transparent; background: rgba(4,5,12,.45); color: #cfd4ea;
  transition: border-color .2s, background .2s;
}
.lbl:hover { border-color: var(--line); background: rgba(20,24,46,.8); }

/* tooltip */
#tip {
  position: fixed; left: 0; top: 0; pointer-events: none; z-index: 5;
  background: rgba(12,14,28,.92); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px;
}
#tip span { display: block; color: var(--muted); font-size: 11.5px; }

/* card */
#card {
  position: fixed; top: 16px; right: 16px; width: 330px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px;
}
#card[hidden] { display: none; }
#card .x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 22px; color: var(--muted); line-height: 1; padding: 4px 6px; }
#card .x:hover { color: var(--text); }
.crumbs { font-size: 11.5px; color: var(--muted); padding-right: 20px; }
#card h2 { font: 700 24px/1.15 Tinos, Georgia, serif; margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.pill { font-size: 11.5px; padding: 2px 9px; border-radius: 20px; border: 1px solid; }
.v-sport { color: #7ee2a8; border-color: rgba(126,226,168,.4); }
.v-lean { color: #a8e07e; border-color: rgba(168,224,126,.4); }
.tag { font-size: 11px; color: #d9c58f; }
.v-no { color: #f28b8b; border-color: rgba(242,139,139,.4); }
.v-deb { color: #f2c76b; border-color: rgba(242,199,107,.4); }
.v-exc { color: #b49cff; border-color: rgba(180,156,255,.45); }
.v-und { color: #a9b0c8; border-color: rgba(169,176,200,.35); }
.v-excl { color: #8a8fa3; border-color: rgba(138,143,163,.3); text-decoration: line-through; }
.note { font: italic 15px/1.45 Tinos, Georgia, serif; margin: 12px 0 6px; color: #f0f1f7; }
.why { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }
.bars { display: grid; gap: 5px; margin-bottom: 14px; }
.bar { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.bar div { height: 5px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 20px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.chip:hover { background: rgba(159,180,255,.2); }

/* mobile */
@media (max-width: 720px) {
  #panelToggle {
    display: grid; place-items: center; position: fixed; top: 16px; left: 16px; z-index: 3;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  }
  #panel { top: 64px; left: 16px; right: 16px; width: auto; max-height: 60vh; display: none; }
  body.panel-open #panel { display: block; }
  #card { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; max-height: 55vh; }
  .lbl { font-size: 10.5px; }
}
