/* 同一组骨段按钮在宽屏显示层级，窄屏紧凑平铺；画布随面板高度缩放。 */
#rig-editor[open] {
  display: grid; grid-template-rows: auto minmax(0,1fr) auto auto auto;
  width: min(940px,calc(100vw - 24px)); height: min(680px,calc(100dvh - 24px));
  min-width: min(510px,calc(100vw - 24px)); min-height: min(405px,calc(100dvh - 24px));
  max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px);
  container: rig-window / size; inset: 0; margin: auto; padding: 0;
  overflow: hidden; border: 1px solid #58646b; border-radius: 7px;
  background: var(--surface,#1c2025); color: var(--text,#e4eae6); box-shadow: 0 15px 64px #000a;
}
#rig-editor::backdrop { background: #070c10ac; }
#rig-grip { position:absolute; right:0; bottom:0; z-index:1; width:22px; height:22px; cursor:nwse-resize; touch-action:none; }
#rig-grip::after { content:""; position:absolute; inset:4px; background:repeating-linear-gradient(135deg,transparent 0 3px,#9aa9af 3px 4px); clip-path:polygon(100% 0,100% 100%,0 100%); }
#rig-editor button, #rig-editor input[type=number] {
  min-height: 30px; color: #deebe4; padding: 3px 8px; border: 1px solid #45525a;
  border-radius: 4px; background: #252d32; font-family: inherit; font-size: 12px; line-height: 1.3;
}
#rig-editor button:hover { border-color: #78978c; }
#rig-editor :focus-visible { outline: 2px solid #edc98b; outline-offset: 1px; }
#rig-editor button:disabled, #rig-editor input:disabled { opacity: .46; }
#rig-editor label { color: #bdc9cb; font-size: 12px; }
#rig-editor input[type=number] { min-width: 0; width: 51px; text-align: center; font-family: var(--mono,monospace); padding-inline: 3px; appearance: textfield; }
#rig-editor input[type=number]::-webkit-inner-spin-button { appearance: none; }
#rig-editor input[type=range] { min-width: 0; margin: 0; accent-color: #a8dfbf; cursor: pointer; touch-action: none; }
.rig-header, .rig-header > div, .rig-view-options, .rig-properties, .rig-key-heading, .rig-transport, .rig-key-actions, .rig-properties label, .rig-transport label { display: flex; align-items: center; }
.rig-header { min-height: 47px; justify-content: space-between; padding: 6px 14px; border-bottom: 1px solid #3d474e; background: #242b30; }
.rig-header div { gap: 12px; }
.rig-header span, #rig-mode, #rig-hint { font-size: 12px; color: #afbdc3; }
.rig-header h2 { margin: 0; font-size: 17px; letter-spacing:.04em; }
.rig-header span { border-right: 1px solid #53616a; padding-right: 12px; }
.rig-main { display: grid; grid-template-columns: minmax(135px,21%) minmax(0,1fr); min-height: 0; overflow: hidden; }
.rig-tree-panel { padding: 12px 8px; border-right: 1px solid #384249; min-height: 0; }
.rig-tree-panel h3 { margin: 0 4px 7px; color: #acb9be; font-size: 12px; font-weight: 550; }
#rig-tree { display: grid; gap: 1px; }
#rig-editor #rig-tree button {
  width: 100%; min-height: 25px; margin: 0; padding: 3px 4px 3px calc(6px + var(--depth)*11px); border-color: transparent;
  text-align: left; white-space: nowrap; background: transparent; color: #c0c9ce;
}
#rig-tree button::before { content: "◇"; color: #82929c; padding-right: 5px; font-size: 9px; }
#rig-editor #rig-tree button[aria-pressed=true] { background: #314332; color: #daebd7; border-color: #657761; }
#rig-tree button[aria-pressed=true]::before { color: #e8c485; }
.rig-workarea { display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; min-width: 0; background: #182128; }
.rig-view-options { gap: 12px; padding: 4px 10px; min-height: 29px; border-bottom: 1px solid #34414a; }
.rig-view-options label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.rig-view-options input { accent-color: #a8dfbf; margin: 0; }
#rig-mode { margin-left: auto; color: #adcdb6; font-size: 11px; white-space: nowrap; }
#rig-canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; touch-action: none; cursor: crosshair; }
#rig-editor[data-original=true] #rig-canvas { cursor: default; }
.rig-properties { min-width: 0; flex-wrap: wrap; gap: 5px 12px; padding: 6px 14px; border-top: 1px solid #374149; background: #22292e; }
.rig-properties label, .rig-transport label { gap: 5px; }
#rig-selected-name { font-size: 13px; color: #e6c48c; min-width: 6em; }
#rig-angle-range { max-width: 290px; flex: 1 1 60px; }
.rig-length-controls { display: inline-flex; align-items: center; gap: 5px; padding-left: 9px; border-left: 1px solid #49565b; }
.rig-key-panel { padding: 7px 14px; border-top: 1px solid #39434c; }
.rig-key-heading { justify-content: space-between; gap: 5px; }
.rig-transport, .rig-key-actions { gap: 5px; }
.rig-transport output { color: #bfcbcc; font: 12px var(--mono,monospace); white-space: nowrap; }
#rig-editor #rig-play, #rig-editor #rig-add-key { color: #c1e8ce; border-color: #567962; }
.rig-key-jump { display:flex; gap:3px; }
.rig-timeline { position: relative; margin: 5px 0; padding-top: 16px; }
#rig-key-marks { position: absolute; top: 0; left: 8px; right: 8px; height: 16px; }
#rig-editor #rig-key-marks button { position:absolute; width:16px; min-height:16px; height:16px; padding:0; border:0; transform:translateX(-50%); background:transparent; }
#rig-key-marks button::before { content:""; display:block; width:7px; height:7px; margin:auto; background:#e7c18c; transform:rotate(45deg); }
#rig-scrub { display: block; width: 100%; height: 22px; }
#rig-reset { margin-left: auto; }
#rig-hint { margin: 0; padding: 4px 14px 7px; color: #b5bec1; font-size: 11px; line-height: 1.4; min-height: 20px; }
@media (max-width:820px), (max-height:620px) {
  /* 缩放后的宽高保存在当前面板；切到小屏时由相同的最小、最大尺寸重新贴合视口。 */
  #rig-editor[open] { min-width:calc(100vw - 8px); max-width:calc(100vw - 8px); min-height:calc(100dvh - 8px); max-height:calc(100dvh - 8px); resize:none; }
  #rig-grip { display:none; }
}
@container rig-window (max-width: 700px) or (max-height: 610px) {
  .rig-main { grid-template-columns: minmax(132px,22%) minmax(0,1fr); }
  .rig-tree-panel { padding:5px; }
  .rig-tree-panel h3 { margin-bottom:3px; }
  #rig-tree { grid-template-columns: repeat(2,minmax(0,1fr)); gap:2px; }
  #rig-editor #rig-tree button { padding:2px; text-align:center; background:#232c32; border-color:#3c4850; }
  #rig-tree button::before { content:none; }
  #rig-editor #rig-tree button[aria-pressed=true] { background:#314332; border-color:#657761; }
  .rig-properties { padding:5px 8px; }
  .rig-key-panel { padding:6px 8px; }
  .rig-header { min-height:39px; padding:4px 8px; }
  #rig-hint { padding-inline:8px; }
}
@container rig-window (max-width: 500px) {
  .rig-main { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); }
  .rig-tree-panel { border:0; border-bottom:1px solid #384249; }
  .rig-tree-panel h3 { display:none; }
  #rig-tree { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
@media (max-width:430px) {
  .rig-properties { display:grid; grid-template-columns:auto minmax(0,1fr); gap:3px 7px; }
  #rig-selected-name { grid-column:1; grid-row:1; min-width:0; }
  .rig-length-controls { grid-column:2; grid-row:1; justify-self:end; padding:0; border:0; }
  .rig-angle-label { grid-column:1; grid-row:2; }
  #rig-angle-range { grid-column:2; grid-row:2; width:100%; }
  .rig-key-heading { flex-wrap: wrap; gap: 3px 5px; }
  #rig-editor #rig-frame { width:34px; }
  #rig-editor button { padding-inline:6px; }
  .rig-transport { gap:3px; }
  .rig-transport label { gap:3px; }
  #rig-editor input[type=number] { width:42px; }
  .rig-header span { padding-right:8px; }
}
@media (max-height:450px) {
  .rig-header { min-height:33px; }
  #rig-editor button, #rig-editor input[type=number] { min-height:25px; }
  .rig-properties { padding-block:3px; }
  .rig-key-panel { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:3px 14px; }
  .rig-key-heading { grid-column:1/-1; }
  .rig-timeline { margin:0; }
  #rig-hint { padding-block:1px; min-height:16px; }
}
@media (max-width:375px) {
  .rig-length-controls label { gap:3px; white-space:nowrap; }
  #rig-editor #rig-reset-length { font-size:0; width:28px; padding:0; }
  #rig-reset-length::after { content:"↺"; font-size:16px; }
}
