/* Rigging workbench: graphite stage, warm chalk ink, the two bone colours from the thumbnails.
   Orange = main-body joints, blue = extra bones (hair, skirts, accessories). */
:root {
  --bg: #121418;
  --panel: #1a1d23;
  --well: #22262e;
  --ink: #ece6dc;
  --ink-2: #9aa0aa;
  --line: #2c313a;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --extra: #40a0ff;
  --signal: #ffb27a;
  --stage: #1d2026;
  --stage-2: #0d0f12;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-text: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font-text); -webkit-font-smoothing: antialiased; }
a { color: var(--signal); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
b { font-weight: 600; }

/* ---------- masthead ---------- */
.masthead { padding: 26px 24px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); }
.mast-inner { display: flex; gap: 24px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font: 500 12px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }
.ident h1 { margin: 0; font-family: var(--font-display); font-size: clamp(2rem, 1.3rem + 2.6vw, 3.3rem); line-height: .95; font-weight: 780; font-variation-settings: "wdth" 82, "opsz" 96; letter-spacing: -0.02em; }
.ident h1 span { color: var(--accent); }
.tagline { margin: 10px 0 0; color: var(--ink-2); max-width: 70ch; }
.tagline b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.ds-links { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.searchrow { display: flex; gap: 10px; align-items: center; padding: 18px 0 16px; }
.search { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); padding: 0 12px; height: 46px; border-radius: 8px; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; outline: none; min-width: 0; }
.search input::placeholder { color: #6b717c; }
.search kbd { font: 12px var(--font-mono); color: var(--ink-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.sort select { background: var(--panel); color: var(--ink); border: 1px solid var(--line); height: 46px; padding: 0 10px; font: inherit; border-radius: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--ink-2); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13.5px; }
.only-narrow { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 28px; padding: 22px 24px 40px; }
.facets { position: sticky; top: 190px; align-self: start; max-height: calc(100vh - 210px); overflow: auto; padding-right: 6px; scrollbar-width: thin; }
.facet { margin-bottom: 22px; }
.facet h3 { margin: 0 0 8px; font: 500 12px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.facet ul { list-style: none; margin: 0; padding: 0; }
.facet li label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 14px; }
.facet li label:hover { color: var(--signal); }
.facet input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.facet .n { margin-left: auto; font: 12px var(--font-mono); color: var(--ink-2); }
.facet li.zero { opacity: .45; }
.facet .more { background: none; border: 0; padding: 4px 0; color: var(--signal); font-size: 13px; }
.facet .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.range { display: flex; gap: 8px; align-items: center; font: 13px var(--font-mono); color: var(--ink-2); }
.range input { width: 70px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); height: 32px; border-radius: 6px; padding: 0 8px; font: inherit; }

.result-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; min-height: 30px; }
#count { margin: 0; color: var(--ink-2); font-size: 14px; }
#count b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.chip::after { content: "×"; color: var(--ink-2); }
.chip:hover { border-color: var(--accent); }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.card:hover, .card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.card .th { aspect-ratio: 1; background-repeat: no-repeat; background-color: var(--well); background-image: radial-gradient(circle at 50% 40%, #2a2f38, var(--well) 70%); }
.card .th i { display: block; width: 100%; height: 100%; background-repeat: no-repeat; }
.card .cap { padding: 7px 9px 9px; }
.card .uid { font: 500 12.5px var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .stats { display: flex; gap: 8px; font: 11.5px var(--font-mono); color: var(--ink-2); margin-top: 2px; }
.card .tag { position: absolute; top: 7px; left: 7px; font: 500 10.5px/1 var(--font-mono); padding: 4px 6px; border-radius: 4px; background: rgba(13,15,18,.72); color: var(--ink-2); letter-spacing: .03em; }
.card .xb { color: var(--extra); }
#sentinel { height: 1px; }
.empty { text-align: center; padding: 60px 0; color: var(--ink-2); }

.foot { border-top: 1px solid var(--line); padding: 18px 24px 28px; color: var(--ink-2); font-size: 13px; }
.foot p { margin: 0; max-width: 110ch; }

/* ---------- detail ---------- */
.detail { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: 1fr 380px; background: var(--bg); }
.stage { position: relative; background: radial-gradient(ellipse at 50% 35%, var(--stage), var(--stage-2) 75%); overflow: hidden; min-height: 0; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.seg { display: inline-flex; background: rgba(18,20,24,.82); border: 1px solid var(--line); border-radius: 8px; padding: 3px; backdrop-filter: blur(6px); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 13.5px; color: var(--ink-2); }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { height: 34px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); background: rgba(18,20,24,.82); font-size: 13px; color: var(--ink-2); backdrop-filter: blur(6px); }
.tool[aria-pressed=true] { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.tool:hover { color: var(--ink); }

.transport { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: rgba(18,20,24,.86); border: 1px solid var(--line); border-radius: 14px; padding: 7px 10px 7px 7px; backdrop-filter: blur(8px); max-width: calc(100% - 28px); }
.play { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--accent); display: grid; place-items: center; flex: none; }
.play svg { width: 20px; height: 20px; fill: var(--accent-ink); }
.play .i-play { display: none; }
.play.paused .i-play { display: block; }
.play.paused .i-pause { display: none; }
.presets { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.presets button { border: 1px solid transparent; background: transparent; padding: 7px 11px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.presets button:hover { color: var(--ink); }
.presets button[aria-pressed=true] { color: var(--ink); border-color: var(--line); background: var(--well); }
.speed { display: flex; align-items: center; gap: 8px; font: 11px var(--font-mono); color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; padding-left: 6px; border-left: 1px solid var(--line); }
.speed input { width: 80px; accent-color: var(--accent); }
.hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; margin: 0; font-size: 12px; color: var(--ink-2); pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); font-size: 14px; background: rgba(13,15,18,.35); }
.loading p { margin: 0; text-align: center; max-width: 40ch; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hover-tip { position: absolute; pointer-events: none; font: 500 12px var(--font-mono); padding: 4px 7px; border-radius: 5px; background: rgba(13,15,18,.9); border: 1px solid var(--line); transform: translate(12px, -50%); white-space: nowrap; }

.info { overflow: auto; padding: 16px 20px 30px; border-left: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; }
.info-top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.info-top #d-pos { flex: 1; text-align: center; font: 12px var(--font-mono); color: var(--ink-2); }
.kicker { margin: 0; font: 500 12px var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
#d-title { margin: 4px 0 12px; font: 700 26px/1.1 var(--font-display); font-variation-settings: "wdth" 85; word-break: break-all; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0 0 18px; }
.meta div { background: var(--well); padding: 8px 10px; }
.meta dt { font: 11px var(--font-mono); color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.meta dd { margin: 2px 0 0; font: 500 15px var(--font-mono); }
.panel { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.panel h3 { margin: 0 0 10px; font: 600 15px var(--font-display); letter-spacing: .01em; }
.panel h3 span { font: 12px var(--font-mono); color: var(--ink-2); font-weight: 400; }
.note { margin: 6px 0 10px; color: var(--ink-2); font-size: 13px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked + span { background: var(--extra); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.sliders { display: grid; gap: 6px; }
.sliders label { display: grid; grid-template-columns: 80px 1fr; align-items: center; font-size: 13px; color: var(--ink-2); }
.sliders input { accent-color: var(--extra); width: 100%; }
.sliders.off { opacity: .4; pointer-events: none; }

.sel { background: var(--well); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.sel .nm { font: 500 14px var(--font-mono); }
.sel .nm i { font-style: normal; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.sel .sub { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 8px; }
.sel .row { margin: 6px 0 2px; }
.jfilter { width: 100%; height: 32px; background: var(--well); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); padding: 0 10px; font: 13px var(--font-text); margin-bottom: 6px; }
.jtree { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font: 12.5px/1.25 var(--font-mono); scrollbar-width: thin; border: 1px solid var(--line); border-radius: 8px; }
.jtree li { padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.jtree li:hover { background: var(--well); }
.jtree li.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.jtree li i { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--accent); }
.jtree li.x i { background: var(--extra); }
.jtree li .ix { margin-left: auto; color: var(--ink-2); font-size: 11px; }
.code-head { display: flex; justify-content: space-between; align-items: center; }
.code-head h3 { margin: 0; }
.code pre { background: var(--stage-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font: 12px/1.5 var(--font-mono); color: #d7d2c8; margin: 10px 0 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .masthead { padding: 18px 16px 0; position: static; }
  .facets { position: static; max-height: none; display: none; }
  .facets.open { display: block; }
  .only-narrow { display: inline-flex; }
  .searchrow { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .sort { flex: 1; }
  .sort select { flex: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .detail { grid-template-columns: 1fr; grid-template-rows: 58vh 1fr; }
  .info { border-left: 0; border-top: 1px solid var(--line); }
  .transport { bottom: 30px; }
  .speed { display: none; }
  .hint { display: none; }
  .stage-top .toggles .tool { height: 30px; padding: 0 8px; }
}
