:root {
  color-scheme: dark;
  --bg: #14191b;
  --panel: #1b2224;
  --stage: #20282b;
  --line: #354043;
  --ink: #edf0e9;
  --muted: #aab7b5;
  --accent: #d6bc7c;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
[hidden] { display: none !important; }
body { margin: 0; }
::selection { background: var(--accent); color: var(--bg); }
button, input, select { font: inherit; }
button, input, a, select { touch-action: manipulation; }
button, input, select, .download { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 4px; }
button, .download { padding: var(--space-2) var(--space-3); cursor: pointer; text-decoration: none; }
button:hover, .download:hover { background: var(--hover); }
button[aria-pressed="true"] { color: var(--selected-ink); background: var(--selected-bg); border-color: var(--selected-border); }
button:disabled { opacity: .45; cursor: default; }
:is(button, a, input, select, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: 3px; }
input, select { width: 100%; min-width: 0; padding: 10px var(--space-3); caret-color: var(--accent); }
input::placeholder { color: var(--muted); }
p, h1, h2, h3 { margin: 0; }
h1, h2, h3 { font-weight: 600; }
h1 { font-size: clamp(24px, 2.5vw, 36px); letter-spacing: -.025em; line-height: 1.2; overflow-wrap: anywhere; }
h2 { font-size: 15px; }
h3 { font-size: 12px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; }
header { height: 68px; padding: 0 var(--space-6); display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); border-bottom: 1px solid var(--line); }
#browse-toggle { display: none; }
.workbench { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: calc(100dvh - 68px); }
aside { min-height: 0; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); }
.catalog-controls { padding: var(--space-5) var(--space-4) 0; }
.control-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: var(--space-2); }
.search-field { position: relative; }
.search-field svg { position: absolute; left: var(--space-3); top: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 38px; background: var(--bg); font-size: 13px; }
.filter-options { margin-top: var(--space-3); font-size: 12px; }
.filter-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.inventory-filters { display: flex; gap: var(--space-1); margin: var(--space-2) 0; }
.inventory-filters button { flex: 1; padding: var(--space-2) var(--space-1); font-size: 11px; white-space: nowrap; }
#include-parts { width: 100%; font-size: 12px; text-align: left; margin-bottom: var(--space-2); }
.category-heading { padding: var(--space-3) 0 var(--space-2); border-top: 1px solid var(--line); margin-top: var(--space-2); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#categories { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--space-3) var(--space-4); }
#categories button { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: var(--space-2); text-align: left; border-color: transparent; background: none; font-size: 13px; padding: 7px var(--space-2); }
#categories button:hover { background: var(--panel); }
#categories button[aria-pressed="true"] { background: var(--selected-bg); color: var(--selected-ink); box-shadow: inset 2px 0 var(--accent); }
.category-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#browse-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.text-button { background: none; color: var(--accent); border: 0; padding: var(--space-1); font-size: 12px; }
.virtual-gallery { position: relative; overflow-anchor: none; }
.virtual-gallery-row { position: absolute; top: 0; left: 0; width: 100%; padding-bottom: var(--space-5); }
.virtual-gallery-row h2 { margin: var(--space-4) 0 var(--space-3); color: var(--muted); font-size: 14px; }
.gallery-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-3); }
.gallery-intro { color: var(--muted); margin: var(--space-3) 0 var(--space-6); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: var(--space-5); }
.card { display: flex; flex-direction: column; padding: 0; min-width: 0; text-align: left; border: 1px solid var(--card-border); background: var(--panel); overflow: hidden; border-radius: 6px; transition: border-color .16s ease, background .16s ease; }
.card:hover { background: var(--card-hover); border-color: var(--selected-border); }
.card[aria-pressed="true"] { background: var(--card-selected); border-color: var(--accent); }
.card img { display: block; width: 100%; height: 230px; object-fit: contain; background: var(--stage); }
.card .placeholder { display: grid; place-items: center; width: 100%; height: 230px; padding: var(--space-3); text-align: center; color: var(--muted); background: var(--stage); font-size: 12px; }
.card .caption { display: flex; flex: 1; flex-direction: column; width: 100%; padding: var(--space-4); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; border-top: 1px solid var(--card-border); }
.card small { display: block; color: var(--muted); font-size: 11px; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.card .asset-state { color: var(--accent); }
.card .card-levels { display: flex; gap: 5px; padding-top: var(--space-3); margin-top: auto; }
.card-levels span { padding: 2px 5px; border-radius: 3px; font-size: 10px; }
.level-ready { color: var(--badge-ink); background: var(--badge-bg); }
.level-missing { color: var(--soft-ink); border: 1px dashed var(--line); }
.catalog-footer { border-top: 1px solid var(--line); padding: var(--space-3) var(--space-5); color: var(--muted); font-size: 11px; }
#no-results { padding: var(--space-6) 0; font-size: 13px; color: var(--muted); }
.main { min-width: 0; overflow: auto; padding: var(--space-6) clamp(20px, 3vw, 48px); }
.title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
.title-description { min-width: 0; display: flex; flex-direction: column-reverse; gap: var(--space-1); }
#family { color: var(--muted); font-size: 13px; }
.download { flex-shrink: 0; font-size: 12px; background: var(--download-bg); color: #20241f; border-color: var(--download-bg); font-weight: 600; padding: 11px 16px; }
.download:hover { background: var(--download-hover); }
.download svg { width: 16px; height: 16px; vertical-align: middle; margin-left: var(--space-2); }
.variant-options { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.variant-options button { padding: 5px 9px; font-size: 11px; }
.back-button { background: none; border-color: transparent; color: var(--accent); padding-left: 0; margin-bottom: var(--space-4); }
.detail-workspace { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--space-6); margin-top: var(--space-5); }
.preview-column { min-width: 0; }
.viewer-panel { display: grid; grid-template-columns: minmax(0,1fr); border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.model-viewport { min-width: 0; display: flex; flex-direction: column; background: var(--panel); position: sticky; top: -1px; z-index: 2; align-self: start; border-radius: 6px 6px 0 0; }
.quality-controls { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: 0 0 var(--space-3); }
.quality-controls h2 { font-size: 11px; color: var(--muted); font-weight: 400; }
.animation-inspection { min-width: 0; min-height: 0; height: 460px; display: flex; flex-direction: column; padding: var(--space-4); border-top: 1px solid var(--line); }
.rig-heading { margin-bottom: var(--space-3); }
.rig-heading h2 { font-size: 14px; }
#preview-motion { color: var(--accent); font-size: 12px; line-height: 1.5; margin-top: var(--space-1); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.inspection-tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); flex-shrink: 0; }
.inspection-tabs button { flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: var(--space-2) 0; font-size: 11px; line-height: 1.4; border-bottom: 2px solid transparent; }
.inspection-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.inspection-tabs button:hover { color: var(--ink); }
#pose-panel { min-height: 0; overflow: auto; padding: 2px; }
.rig-actions h3 { font-size: 11px; font-weight: 400; color: var(--muted); margin-bottom: var(--space-2); }
.rig-actions h3:not(:first-child) { margin-top: var(--space-6); }
#game-animation-controls, #pose-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.rig-actions button { padding: 8px 10px; font-size: 12px; overflow-wrap: anywhere; min-width: 0; max-width: 100%; text-align: left; }
#game-animation-status { margin-top: var(--space-3); }
.source-actions, #source-action-picker { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.source-action-filters { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }
.action-search-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); font-size: 11px; color: var(--muted); }
#source-action-count { font-variant-numeric: tabular-nums; font-size: 10px; }
#source-action-category { display: flex; flex-wrap: wrap; align-content: start; gap: 4px; max-height: 76px; overflow: auto; padding: 2px; }
#source-action-category button { padding: 5px 7px; font-size: 11px; }
#source-action { display: flex; flex-direction: column; flex: 1; min-height: 64px; overflow: auto; overscroll-behavior: contain; padding: 2px; }
#source-action button { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); text-align: left; flex-shrink: 0; min-width: 0; overflow-wrap: anywhere; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 8px; font-size: 12px; }
#source-action button:focus-visible, #source-action-category button:focus-visible { outline-offset: -2px; }
#source-action button:hover { background: var(--hover); }
#source-action button[aria-pressed="true"] { background: var(--selected-bg); color: var(--selected-ink); }
#source-action button span { flex-shrink: 0; color: var(--muted); font-size: 10px; }
#source-action-search { font-size: 12px; padding: 8px 10px; background: var(--bg); }
.action-playback { border-top: 1px solid var(--line); padding-top: var(--space-2); margin-top: var(--space-2); }
#source-action-status { font-size: 11px; max-height: 3em; overflow: auto; overflow-wrap: anywhere; }
#source-action-status:empty { display: none; }
.source-action-options { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: 11px; }
.source-action-options label { display: flex; align-items: center; gap: var(--space-1); min-height: 32px; }
.source-action-options input { width: auto; }
.source-action-options button { font-size: 11px; padding: 6px 9px; }
.source-action-options a { margin-left: auto; }
.source-animation-archive { margin: var(--space-3) 0; font-size: 12px; }
.stage { height: clamp(240px, 38dvh, 500px); position: relative; background: var(--stage); overflow: hidden; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-hint { position: absolute; bottom: var(--space-3); left: var(--space-4); color: var(--muted); font-size: 11px; pointer-events: none; z-index: 1; }
.stage-hint span { padding: 0 var(--space-1); }
.stage-message { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: var(--space-6); color: var(--muted); background: var(--stage); z-index: 2; white-space: pre-line; pointer-events: none; }
.stage[data-empty="true"] .stage-hint { display: none; }
.inspection { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2); border-bottom: 1px solid var(--line); }
.views, .overlays { display: flex; gap: var(--space-1); }
.inspection button { font-size: 12px; padding: 6px 9px; }
.views button { background: transparent; border-color: transparent; }
.views button:hover, .views button[aria-pressed="true"] { background: var(--panel); color: var(--accent); }
.model-info { min-width: 0; min-height: 0; flex: 1; overflow: auto; overscroll-behavior: contain; padding: 2px; }
.stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--space-4); padding: 0 0 var(--space-4); margin: 0 0 var(--space-4); border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: 11px; }
.stats dd { margin: var(--space-1) 0 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.help, .posture-note { color: var(--muted); font-size: 12px; max-width: 80ch; margin: var(--space-2) 0; }
.model-info .help, .model-info .posture-note { line-height: 1.7; overflow-wrap: anywhere; margin-bottom: var(--space-4); }
#detail-note { margin-top: var(--space-3); }
#error { color: var(--error); font-size: 13px; overflow-wrap: anywhere; }
#error:not(:empty) { padding: var(--space-3) 0; }
#setup { padding: var(--space-4); border: 1px solid var(--line); }
#setup code { display: block; overflow: auto; color: var(--accent); margin: var(--space-3) 0; }
@media (min-width: 1600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } .card img, .card .placeholder { height: 260px; } }
@media (min-width: 1200px) {
  .viewer-panel { grid-template-columns: minmax(0,1fr) 300px; height: clamp(520px, calc(100dvh - 245px), 860px); }
  .model-viewport { position: static; height: 100%; min-height: 0; }
  .stage { flex: 1; height: auto; min-height: 0; }
  .animation-inspection { height: auto; border-top: 0; border-left: 1px solid var(--line); }
}
@media (max-width: 1050px) { .workbench { grid-template-columns: 240px minmax(0, 1fr); } .catalog-controls { padding-inline: var(--space-4); }  }
@media (max-width: 760px) {
  header { padding: 0 var(--space-4); gap: var(--space-3); }
  #browse-toggle { display: block; font-size: 12px; }
  .workbench { display: block; height: auto; }
  aside { display: none; border-right: 0; border-bottom: 1px solid var(--line); max-height: calc(100dvh - 68px); }
  body[data-browse-open="true"] aside { display: flex; }
  #categories { max-height: 40dvh; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .card img, .card .placeholder { height: 170px; }
  .card .caption { font-size: 12px; padding: var(--space-3); }
  .card .card-levels { gap: 3px; flex-wrap: wrap; }
  .card-levels span { padding: 2px 4px; }
  .main { padding: var(--space-5) var(--space-4); overflow: visible; }
  .title { gap: var(--space-3); align-items: start; }
  .title-description { display: flex; }
  #family { margin-top: var(--space-1); }
  .download { padding: var(--space-2); font-size: 11px; }
  .download svg { display: none; }
  .stage { height: clamp(190px, 29dvh, 280px); }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .animation-inspection { height: 460px; padding: var(--space-3); }
  .inspection-tabs button { min-height: 40px; }
  .stage-hint { font-size: 10px; left: var(--space-3); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

@media(max-width:760px) { header { gap: 8px; padding-inline: 12px; }     #browse-toggle { padding: 7px 8px; font-size: 12px; } }
