:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
  background: #171d21;
  color: #dce3e6;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background: #171d21;
  overflow: hidden;
}

button,
input,
select {
  font-family: inherit;
}

.app-header {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid #3b454b;
  background: #20272b;
}

.app-header h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #eef3f4;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-mark {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #57a4ad;
  border-radius: 4px;
  background: #177f91;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

#pose-editor-root {
  width: 100%;
  height: calc(100vh - 48px);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: #252b2f;
}

.loading-state {
  height: 100%;
  display: grid;
  place-items: center;
  color: #aeb9bd;
  font-size: 12px;
}

.loading-error {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-direction: column;
  color: var(--studio-text, #e7eff0);
  text-align: center;
}

.loading-error span {
  color: var(--studio-muted, #aebcc0);
  font-size: 12px;
}

.loading-error button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid #54d0ca;
  border-radius: 6px;
  background: #177f91;
  color: #fff;
  cursor: pointer;
}

#pose-editor-root > .standalone-editor-container {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  display: block !important;
  position: relative !important;
  gap: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  scrollbar-color: #56636a #252b2f;
}

#pose-editor-root .standalone-stage {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.pose-editor-sidebar {
  position: absolute;
  z-index: 20;
  top: 48px;
  bottom: auto;
  left: 58px;
  width: min(286px, calc(100% - 72px));
  height: fit-content;
  max-height: min(620px, calc(100% - 146px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(95, 112, 120, 0.9);
  border-radius: 6px;
  background: rgba(29, 36, 40, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 12px));
  transition: opacity 150ms ease, transform 150ms ease;
}

.pose-editor-sidebar.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.pose-editor-tool-rail {
  position: absolute;
  z-index: 22;
  top: 48px;
  left: 8px;
  width: 42px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px 4px;
  border: 1px solid rgba(95, 112, 120, 0.9);
  border-radius: 6px;
  background: rgba(29, 36, 40, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(10px);
}

.pose-editor-tool-button {
  width: 32px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #aebbc0;
  cursor: pointer;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.pose-editor-tool-button:hover,
.pose-editor-tool-button.is-active {
  border-color: #4a9eaa;
  background: #177f91;
  color: #fff;
}

.pose-editor-tool-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pose-editor-sidebar-header {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid #465158;
  color: #eef4f5;
  font-size: 11px;
}

.pose-editor-sidebar-close {
  width: 26px !important;
  height: 26px !important;
  padding: 0 !important;
}

.pose-editor-sidebar-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.pose-editor-tool-pane {
  display: none;
  min-height: 0;
}

.pose-editor-tool-pane.is-active {
  display: block;
}

.pose-editor-tool-pane-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.pose-library-sidebar {
  position: absolute;
  z-index: 18;
  top: 48px;
  bottom: 8px;
  right: 8px;
  width: min(346px, calc(100% - 72px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(95, 112, 120, 0.9);
  border-radius: 6px;
  background: rgba(29, 36, 40, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.pose-hand-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  border-bottom: 1px solid #465158;
  background: rgba(36, 44, 48, 0.72);
}

.pose-joint-rotation-panel {
  position: absolute;
  z-index: 19;
  top: 96px;
  right: 362px;
  width: 250px;
  min-width: 240px;
  min-height: 210px;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 7px;
  box-sizing: border-box;
  border: 1px solid rgba(49, 214, 160, 0.55);
  border-radius: 6px;
  background: rgba(20, 27, 31, 0.9);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.pose-joint-rotation-header {
  min-height: 34px;
  flex-wrap: nowrap !important;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.pose-joint-rotation-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 4px;
}

.pose-library-section {
  flex: 1 1 300px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
}

.pose-library-header {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: #eef4f5;
  font-size: 12px;
}

.pose-library-count {
  color: #91a2a8;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.pose-library-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 1px 2px 4px 1px;
  scrollbar-color: #718087 #20272b;
  scrollbar-width: thin;
}

.pose-library-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #46545b;
  border-radius: 4px;
  background: #30393e;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.18);
}

.pose-library-card:hover,
.pose-library-card:focus-within {
  border-color: #55b9c7;
}

.pose-library-card-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e8eff1;
  cursor: pointer;
  text-align: left;
}

.pose-library-thumb {
  width: 100%;
  height: 94px;
  display: block;
  object-fit: cover;
  object-position: center;
  background: #a2a4a5;
}

.pose-library-thumb-fallback {
  display: grid;
  place-items: center;
  color: #dfe6e7;
  background: linear-gradient(180deg, #8f9698 0%, #b7bbbc 66%, #d6d8d7 66%, #c5c8c8 100%);
  font-size: 28px;
  font-weight: 300;
}

.pose-library-card-name {
  min-height: 26px;
  display: flex;
  align-items: center;
  padding: 4px 6px;
  color: #e7eef0;
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pose-transform-panel {
  gap: 8px !important;
  padding: 4px !important;
}

.pose-transform-panel [role='slider'][aria-label$='joystick'] {
  width: 62px !important;
  height: 62px !important;
}

.pose-library-card-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.pose-library-card:hover .pose-library-card-actions,
.pose-library-card:focus-within .pose-library-card-actions {
  opacity: 1;
}

.pose-library-card-action {
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
  border-color: rgba(255,255,255,.4) !important;
  background: rgba(20, 27, 31, .86) !important;
  font-size: 10px !important;
}

.pose-library-card-action.danger {
  background: rgba(112, 61, 67, .92) !important;
}

.pose-library-sidebar .pose-editor-tool-section {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.pose-editor-sidebar-toggle {
  position: absolute !important;
  z-index: 22 !important;
  top: 48px;
  left: 8px;
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  border-color: rgba(93, 113, 121, 0.95) !important;
  background: rgba(29, 36, 40, 0.92) !important;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.26);
  transition: left 150ms ease, background 150ms ease !important;
}

.pose-editor-sidebar-toggle.is-open {
  left: min(306px, calc(100% - 44px));
  background: #177f91 !important;
}

.pose-editor-sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.pose-editor-sidebar-body {
  min-height: 0;
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: min(560px, calc(100% - 54px));
  scrollbar-gutter: stable;
  scrollbar-color: #718087 #20272b;
  scrollbar-width: thin;
}

.pose-editor-sidebar-body::-webkit-scrollbar {
  width: 9px;
}

.pose-editor-sidebar-body::-webkit-scrollbar-track {
  background: #20272b;
}

.pose-editor-sidebar-body::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 2px solid #20272b;
  border-radius: 6px;
  background: #718087;
}

.pose-editor-tool-section {
  border: 1px solid #465158;
  border-radius: 5px;
  background: rgba(36, 44, 48, 0.92);
  overflow: hidden;
}

.pose-editor-tool-section > summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #dce5e8;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  list-style: none;
}

.pose-editor-tool-section > summary::-webkit-details-marker {
  display: none;
}

.pose-editor-tool-section > summary::after {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid #9fadb2;
  border-bottom: 1.5px solid #9fadb2;
  content: '';
  transform: rotate(45deg);
  transition: transform 120ms ease;
}

.pose-editor-tool-section[open] > summary::after {
  transform: rotate(225deg);
}

.pose-editor-tool-section-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px 6px;
}

.pose-editor-mode-dock {
  position: absolute !important;
  z-index: 12;
  top: 8px;
  left: 50%;
  width: min(392px, calc(100% - 420px));
  min-width: 292px !important;
  transform: translateX(-50%);
  background: rgba(29, 35, 39, 0.92) !important;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

#pose-editor-root .standalone-download-button {
  min-width: 64px;
}

@media (min-width: 641px) and (max-width: 900px) {
  .pose-joint-rotation-panel {
    right: auto;
    left: 58px;
    width: 210px;
  }
}

@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  .app-header {
    height: 44px;
    padding: 0 8px;
  }

  .app-header h1 {
    font-size: 12px;
  }

  #pose-editor-root {
    height: calc(100vh - 44px);
  }

  .pose-editor-sidebar {
    top: 46px;
    left: 52px;
    width: calc(100% - 60px);
    height: fit-content;
    bottom: auto;
    max-height: calc(100% - 128px);
  }

  .pose-editor-tool-rail {
    top: 46px;
    left: 6px;
  }

  .pose-library-sidebar {
    top: 56px;
    bottom: 8px;
    right: 8px;
    width: min(346px, calc(100% - 16px));
  }

  .pose-editor-mode-dock {
    top: 8px;
    right: 8px;
    left: 50px;
    width: auto;
    min-width: 0 !important;
    transform: none;
  }
}

/* 2026 UI refresh: denser workflows, clearer hierarchy, less canvas overlap. */
:root {
  --studio-bg: #11191d;
  --studio-stage: #20292e;
  --studio-panel: #172126;
  --studio-panel-raised: #202c31;
  --studio-line: #3b4c53;
  --studio-line-strong: #50656d;
  --studio-text: #f0f5f4;
  --studio-muted: #9babb0;
  --studio-accent: #25b7b0;
  --studio-accent-strong: #168c88;
  --studio-warm: #e4a34f;
  --studio-danger: #c85f69;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--studio-bg);
}

body {
  background: var(--studio-bg);
}

.app-header {
  height: 54px;
  gap: 11px;
  padding: 0 16px;
  border-bottom-color: #314148;
  background: #141e23;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.24);
}

.app-header h1 {
  color: var(--studio-text);
  font-size: 15px;
  font-weight: 650;
}

.app-mark {
  width: 32px;
  height: 32px;
  border-color: #49cbc5;
  border-radius: 7px;
  background: var(--studio-accent-strong);
  font-size: 11px;
  box-shadow: 0 0 0 3px rgba(37, 183, 176, 0.1);
}

#pose-editor-root {
  height: calc(100vh - 54px);
  background: var(--studio-stage);
}

#pose-editor-root .standalone-stage,
#pose-editor-root .standalone-stage > canvas {
  background: var(--studio-stage) !important;
}

.pose-editor-tool-rail {
  left: 12px;
  width: 50px;
  max-height: calc(100% - 64px);
  gap: 6px;
  padding: 6px 5px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  border-color: rgba(80, 101, 109, 0.95);
  border-radius: 8px;
  background: rgba(19, 29, 34, 0.96);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
}

.pose-editor-tool-button {
  width: 38px;
  min-height: 48px;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 6px;
  color: #adbbc0;
  font-size: 9px;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.pose-editor-tool-button:hover {
  border-color: #567079;
  background: #26363c;
  color: #fff;
}

.pose-editor-tool-button.is-active {
  border-color: #54d0ca;
  background: var(--studio-accent-strong);
  color: #fff;
  box-shadow: inset 3px 0 0 #7ee1dc;
}

.pose-editor-tool-button svg {
  width: 19px;
  height: 19px;
}

.pose-editor-sidebar {
  left: 74px;
  width: min(340px, calc(100% - 90px));
  max-height: calc(100% - 64px);
  border-color: rgba(80, 101, 109, 0.98);
  border-radius: 8px;
  background: rgba(20, 30, 35, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
}

.pose-editor-sidebar-header {
  min-height: 44px;
  padding: 0 9px 0 13px;
  border-bottom-color: var(--studio-line);
  font-size: 12px;
}

.pose-editor-sidebar-close {
  width: 30px !important;
  height: 30px !important;
  border-radius: 6px !important;
}

.pose-editor-sidebar-body {
  gap: 9px;
  padding: 10px;
  max-height: calc(100% - 44px);
  scrollbar-color: #62767e #172126;
}

.pose-editor-tool-pane-body {
  gap: 9px;
  padding: 0;
}

.pose-editor-sidebar button,
.pose-library-sidebar button,
.pose-joint-rotation-panel button {
  min-height: 34px !important;
  border-color: var(--studio-line-strong) !important;
  border-radius: 6px !important;
  font-size: 11px !important;
}

.pose-editor-sidebar input:not([type='range']):not([type='checkbox']):not([type='color']),
.pose-editor-sidebar select,
.pose-editor-sidebar textarea,
.pose-library-sidebar input:not([type='range']):not([type='checkbox']),
.pose-library-sidebar select {
  min-height: 34px !important;
  border-color: var(--studio-line-strong) !important;
  border-radius: 6px !important;
  background: #121b20 !important;
  color: var(--studio-text) !important;
  font-size: 11px !important;
}

.pose-editor-sidebar textarea {
  min-height: 76px !important;
  padding: 8px !important;
  line-height: 1.45 !important;
}

.pose-editor-tool-section,
.pose-editor-sidebar details {
  border-color: var(--studio-line) !important;
  border-radius: 7px !important;
  background: var(--studio-panel-raised) !important;
}

.pose-editor-tool-section > summary,
.pose-editor-sidebar details > summary {
  min-height: 40px !important;
  padding: 0 11px !important;
  color: var(--studio-text) !important;
  font-size: 11px !important;
}

.pose-editor-mode-dock {
  top: 9px;
  width: min(460px, calc(100% - 430px));
  min-width: 300px !important;
  padding: 4px !important;
  border-color: rgba(80, 101, 109, 0.95) !important;
  border-radius: 8px !important;
  background: rgba(19, 29, 34, 0.97) !important;
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.3);
  scrollbar-width: none;
}

.pose-editor-mode-dock::-webkit-scrollbar {
  display: none;
}

.pose-editor-mode-dock button {
  height: 34px !important;
  border-radius: 6px !important;
  font-size: 10px !important;
  font-weight: 650 !important;
}

.pose-editor-mode-help {
  position: absolute;
  z-index: 5;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(360px, calc(100% - 32px));
  padding: 5px 9px;
  border: 1px solid rgba(80, 101, 109, 0.85);
  border-radius: 6px;
  background: rgba(19, 29, 34, 0.92);
  color: #c9d7da;
  font-size: 10px;
  text-align: center;
  pointer-events: none;
}

.pose-editor-welcome {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: flex;
  width: min(520px, calc(100% - 40px));
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border: 1px solid rgba(80, 101, 109, 0.98);
  border-radius: 10px;
  background: rgba(20, 30, 35, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.pose-editor-welcome h2 {
  margin: 0;
  color: #f0f7f4;
  font-size: 20px;
}

.pose-editor-welcome p,
.pose-editor-welcome small {
  margin: 0;
  color: #aebcc0;
  font-size: 11px;
}

.pose-editor-welcome button {
  min-height: 36px !important;
  padding: 0 12px !important;
}

.pose-editor-interaction-hint {
  position: absolute;
  z-index: 7;
  bottom: 14px;
  left: 50%;
  display: none;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 6px 10px;
  border: 1px solid rgba(80, 101, 109, 0.9);
  border-radius: 6px;
  background: rgba(19, 29, 34, 0.88);
  color: #cfdddf;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
}

.pose-editor-selection-badge {
  top: 58px !important;
  left: 70px !important;
  max-width: 220px !important;
  padding: 6px 9px !important;
  border-color: rgba(80, 101, 109, 0.95) !important;
  border-radius: 6px !important;
  background: rgba(19, 29, 34, 0.94) !important;
  color: var(--studio-text) !important;
  font-size: 11px !important;
}

.pose-editor-scale-dock,
.pose-editor-layer-dock,
.pose-editor-camera-dock,
.pose-editor-lens-dock,
.pose-editor-handle-dock {
  border-color: rgba(80, 101, 109, 0.95) !important;
  border-radius: 7px !important;
  background: rgba(19, 29, 34, 0.96) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28) !important;
  backdrop-filter: blur(10px);
}

.pose-editor-scale-dock {
  top: 9px !important;
  right: 12px !important;
  height: 38px !important;
  padding: 4px 6px !important;
}

.pose-editor-layer-dock {
  top: 56px !important;
  right: 12px !important;
  padding: 4px !important;
}

.pose-editor-camera-dock {
  left: 12px !important;
  bottom: 12px !important;
  gap: 4px !important;
  padding: 5px !important;
}

.pose-editor-camera-dock button {
  width: 34px !important;
  height: 32px !important;
  border-radius: 6px !important;
}

.pose-editor-lens-dock {
  left: 57px !important;
  bottom: 12px !important;
  width: 238px !important;
  gap: 6px !important;
  padding: 8px 10px !important;
}

.pose-editor-handle-dock {
  left: 57px !important;
  bottom: 96px !important;
  padding: 7px 10px !important;
}

.pose-library-sidebar {
  top: 56px;
  bottom: 12px;
  right: 12px;
  width: min(366px, calc(100% - 88px));
  border-color: rgba(80, 101, 109, 0.98);
  border-radius: 8px;
  background: rgba(20, 30, 35, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
}

.pose-library-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pose-library-header strong {
  flex: 1;
}

.pose-library-close,
.pose-library-restore {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
}

.pose-library-restore {
  position: absolute;
  z-index: 12;
  top: 58px;
  right: 12px;
  display: none;
  background: #177f91 !important;
}

.pose-hand-controls {
  gap: 8px;
  padding: 10px 11px;
  border-bottom-color: var(--studio-line);
  background: #1b282e;
}

.pose-library-section {
  gap: 10px;
  padding: 11px;
}

.pose-library-header {
  min-height: 32px;
  font-size: 13px;
}

.pose-library-count {
  color: var(--studio-muted);
  font-size: 10px;
}

.pose-library-grid {
  gap: 10px;
  scrollbar-color: #62767e #172126;
}

.pose-library-card {
  border-color: var(--studio-line);
  border-radius: 7px;
  background: #263238;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pose-library-card:hover,
.pose-library-card:focus-within {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 1px rgba(37, 183, 176, 0.22);
}

.pose-library-thumb {
  height: 108px;
  object-fit: contain;
  object-position: center;
  background: #20292e;
}

.pose-library-thumb-fallback {
  background: #c3c9c9;
  color: #f7f9f8;
}

.pose-library-card-name {
  min-height: 32px;
  padding: 6px 8px;
  color: var(--studio-text);
  font-size: 11px;
}

.pose-library-card-action {
  width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  background: rgba(19, 29, 34, 0.92) !important;
}

.pose-library-card-action.danger {
  background: rgba(167, 65, 77, 0.94) !important;
}

.pose-library-tabs button {
  min-width: 0;
  min-height: 30px !important;
}

.pose-pair-row select {
  min-width: 0;
}

.pose-library-card-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 3px 5px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 4px;
  background: rgba(22, 140, 136, 0.92);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.pose-joint-rotation-panel {
  width: 250px;
  gap: 4px;
  padding: 6px;
  border-color: rgba(37, 183, 176, 0.72);
  border-radius: 8px;
  background: rgba(18, 27, 31, 0.97);
}

.pose-joint-rotation-header > div,
.pose-joint-axis-row,
.pose-joint-limit-row {
  flex-wrap: nowrap !important;
}

.pose-joint-panel-collapse,
.pose-joint-panel-hide {
  flex: 0 0 auto !important;
}

.pose-editor-tool-rail::-webkit-scrollbar {
  display: none;
}

.pose-joint-panel-collapse {
  width: auto !important;
  min-width: 58px !important;
  min-height: 30px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px !important;
  border: 1px solid #9af1e7 !important;
  border-radius: 6px !important;
  background: #116f73 !important;
  color: #ffffff !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.pose-joint-panel-collapse:hover {
  border-color: #d1fff9 !important;
  background: #168f90 !important;
  color: #ffffff !important;
}

.pose-joint-panel-collapse:focus-visible {
  outline: 3px solid #ffffff !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(71, 226, 211, 0.6);
}

.pose-joint-panel-collapse-icon {
  min-width: 14px;
  font-size: 19px;
  font-weight: 900;
  line-height: 0.8;
}

.pose-joint-panel-collapse-label {
  line-height: 1;
}

.pose-joint-rotation-resize-handle {
  min-width: 30px !important;
  min-height: 30px !important;
  border: 1px solid rgba(154, 241, 231, 0.78) !important;
  border-radius: 5px !important;
  background: rgba(17, 111, 115, 0.9) !important;
  color: #e8fffc !important;
}

.pose-joint-rotation-resize-handle:hover {
  background: #168f90 !important;
  color: #ffffff !important;
}

.pose-joint-rotation-resize-handle:focus-visible {
  outline: 3px solid #ffffff !important;
  outline-offset: 2px;
}

.pose-joint-rotation-restore {
  min-width: 34px !important;
  min-height: 34px !important;
  border: 1px solid #9af1e7 !important;
  background: #116f73 !important;
  color: #ffffff !important;
}

.pose-joint-rotation-restore:hover {
  background: #168f90 !important;
}

.pose-joint-rotation-restore:focus-visible {
  outline: 3px solid #ffffff !important;
  outline-offset: 2px;
}

input[type='range'] {
  accent-color: var(--studio-accent) !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #5dd6d0;
  outline-offset: 2px;
}

@media (max-width: 1099px) {
  .pose-editor-mode-dock {
    left: 150px;
    right: 214px;
    width: auto;
    min-width: 0 !important;
    transform: none;
    overflow-x: auto;
  }

  .standalone-stage:has(.pose-editor-sidebar.is-open) .pose-library-sidebar {
    display: none !important;
  }

  .pose-editor-interaction-hint {
    bottom: 10px;
  }
}

@media (max-width: 760px) {
  .app-header {
    height: 50px;
    padding: 0 10px;
  }

  .app-header h1 {
    font-size: 13px;
  }

  .app-mark {
    width: 30px;
    height: 30px;
  }

  #pose-editor-root {
    height: calc(100vh - 50px);
  }

  .pose-editor-tool-rail {
    top: 54px;
    left: 8px;
    width: 46px;
  }

  .pose-editor-tool-button {
    width: 34px;
    min-height: 46px;
  }

  .pose-editor-sidebar {
    top: 54px;
    left: 62px;
    width: calc(100% - 70px);
    max-height: calc(100% - 66px);
  }

  .pose-editor-mode-dock {
    top: 8px;
    right: 210px;
    left: 80px;
  }

  .pose-editor-mode-dock button {
    min-width: 56px;
  }

  .pose-library-sidebar {
    top: 54px;
    right: 8px;
    bottom: 8px;
    width: min(360px, calc(100% - 70px));
  }

  .pose-editor-scale-dock {
    right: 8px !important;
  }

  .pose-editor-layer-dock {
    right: 8px !important;
  }

  .pose-editor-lens-dock {
    width: min(238px, calc(100% - 72px)) !important;
  }
}

@media (max-width: 520px) {
  .app-header h1 {
    max-width: calc(100vw - 62px);
  }

  .pose-editor-selection-badge,
  .pose-editor-scale-dock {
    display: none !important;
  }

  .pose-editor-mode-dock {
    right: 8px;
    left: 62px;
  }

  .pose-editor-mode-help {
    top: 104px;
    font-size: 9px;
  }

  .pose-editor-welcome {
    top: 48%;
    width: calc(100% - 86px);
    padding: 18px 12px;
  }

  .pose-editor-welcome h2 {
    font-size: 17px;
  }

  .pose-editor-welcome button {
    flex: 1 1 130px;
  }

  .pose-editor-interaction-hint {
    max-width: calc(100% - 86px);
    white-space: normal;
    text-align: center;
  }

  .pose-editor-layer-dock {
    top: 54px !important;
  }

  .pose-editor-tool-rail,
  .pose-editor-sidebar {
    top: 100px;
  }

  .pose-library-sidebar {
    top: 100px;
    width: calc(100% - 70px);
  }

  .pose-editor-camera-dock button:nth-child(3),
  .pose-editor-camera-dock button:nth-child(6),
  .pose-editor-camera-dock button:nth-child(7) {
    display: none !important;
  }

  .pose-editor-lens-dock {
    display: none !important;
  }
}

/* Persistent history and character switching controls. */
.pose-editor-history-dock {
  position: absolute;
  z-index: 18;
  top: 9px;
  left: 12px;
  height: 38px;
  gap: 4px !important;
  padding: 4px 5px;
  border: 1px solid rgba(80, 101, 109, 0.95);
  border-radius: 7px;
  background: rgba(19, 29, 34, 0.97);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.pose-editor-history-dock > span {
  padding: 0 3px;
  color: #9fb0b6;
  font-size: 9px;
  font-weight: 700;
}

.pose-editor-history-dock button {
  width: 30px !important;
  height: 28px !important;
  border-color: #52656d !important;
  border-radius: 5px !important;
  background: #2a373d !important;
  color: #eef4f5 !important;
  font-size: 17px !important;
}

.pose-editor-history-dock button:hover:not(:disabled) {
  border-color: #54d0ca !important;
  background: #168c88 !important;
}

.pose-editor-history-dock button:disabled {
  opacity: 0.35;
  cursor: default !important;
}

.pose-editor-person-switcher {
  position: absolute;
  z-index: 13;
  top: 96px;
  left: 74px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(470px, calc(100% - 470px));
  min-width: 0;
  gap: 5px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid rgba(80, 101, 109, 0.9);
  border-radius: 7px;
  background: rgba(19, 29, 34, 0.92);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(9px);
  scrollbar-width: thin;
}

/* Keep the scene entity switcher clear of the open import/library drawer. */
.standalone-stage.tool-drawer-open .pose-editor-person-switcher {
  left: 356px;
  max-width: min(470px, calc(100% - 752px));
}

@media (max-width: 920px) {
  .standalone-stage.tool-drawer-open .pose-editor-person-switcher {
    left: 356px;
    max-width: calc(100% - 390px);
  }
}

.pose-editor-entity-switcher-section {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pose-editor-entity-switcher-section + .pose-editor-entity-switcher-section {
  margin-top: 1px;
  padding-top: 5px;
  border-top: 1px solid rgba(96, 112, 120, 0.55);
}

.pose-editor-person-switcher-title {
  flex: none;
  padding: 0 4px;
  color: #8fa1a7;
  font-size: 9px;
  font-weight: 700;
}

.pose-editor-person-chip {
  height: 34px;
  min-width: 0;
  max-width: 138px;
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  border: 1px solid #45565e;
  border-radius: 5px;
  background: #26343a;
  color: #d9e2e5;
  cursor: pointer;
}

.pose-editor-person-chip-wrap {
  min-width: 0;
  max-width: 170px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: stretch;
  gap: 2px;
}

.pose-editor-person-chip-wrap .pose-editor-person-chip {
  flex: 1 1 auto;
}

.pose-editor-person-chip-remove {
  width: 24px !important;
  min-width: 24px !important;
  height: 34px !important;
  padding: 0 !important;
  border-color: #6d4a4f !important;
  border-radius: 4px !important;
  background: #703d43 !important;
  color: #ffd9dd !important;
  font-size: 15px !important;
}

.pose-editor-person-chip-remove:hover {
  background: #9b4d58 !important;
  border-color: #e58a95 !important;
}

.pose-editor-person-chip:hover,
.pose-editor-person-chip.is-active {
  border-color: #54d0ca;
  background: #168c88;
  color: #fff;
}

.pose-editor-entity-chip-subject:hover,
.pose-editor-entity-chip-subject.is-active {
  border-color: #e5a15a;
  background: #8b6844;
}

.pose-editor-entity-chip-subject .pose-editor-person-chip-avatar {
  color: #ffe0b5;
}

.pose-editor-person-chip-avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(9, 17, 20, 0.48);
  color: #bde9e6;
  font-size: 10px;
  font-weight: 800;
}

.pose-editor-person-chip-name {
  min-width: 0;
  overflow: hidden;
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pose-editor-person-chip-add {
  width: 34px;
  flex: 0 0 34px;
  justify-content: center;
  padding: 0;
  color: #83d9d4;
  font-size: 18px;
}

.pose-editor-person-switcher.is-empty .pose-editor-person-switcher-title {
  display: none;
}

.pose-editor-person-switcher.is-empty {
  right: auto;
  width: 44px;
  max-width: 44px;
}

.pose-joint-rotation-panel.is-collapsed {
  min-height: 0;
}

.character-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: min(480px, calc(100vh - 196px));
  padding-right: 2px;
  overflow: auto;
}

.character-library-card {
  position: relative;
  min-width: 0;
  min-height: 150px;
  overflow: hidden;
  border: 1px solid #405159;
  border-radius: 7px;
  background: #1d292f;
}

.character-library-card:hover {
  border-color: #54bdb8;
  background: #283941;
}

.character-library-card-main {
  width: 100% !important;
  height: 150px !important;
  display: flex !important;
  flex-direction: column;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  text-align: left;
}

.character-library-card-main.is-loading {
  opacity: 0.62;
}

.character-library-avatar {
  width: 100%;
  height: 108px;
  flex: 0 0 108px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid #405159;
  border-radius: 0;
  background: #29363c;
  color: #f7f9f8;
}

.character-library-preview {
  width: 100%;
  height: 108px;
  flex: 0 0 108px;
  display: block;
  border-bottom: 1px solid #405159;
  background: #303a40;
  object-fit: contain;
  object-position: center;
}

.character-library-avatar-uploaded {
  background: #519e98;
}

.character-library-avatar-captured-frame {
  background: #4d78a7;
}

.character-library-avatar svg {
  width: 40px;
  height: 58px;
  fill: currentColor;
}

.character-library-card-copy {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 34px 7px 8px;
  box-sizing: border-box;
}

.character-library-card-copy strong {
  width: 100%;
  overflow: hidden;
  color: #eef4f5;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-library-card-copy > span {
  color: #91a4aa;
  font-size: 9px;
  font-weight: 500;
}

.subject-library-card .character-library-preview {
  object-fit: contain;
}

.character-library-card-remove {
  position: absolute !important;
  top: 4px;
  right: 4px;
  width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  border: 0 !important;
  background: rgba(151, 57, 68, 0.92) !important;
}

.character-library-card-replace {
  position: absolute !important;
  right: 4px;
  bottom: 4px;
  width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  border: 0 !important;
  background: rgba(24, 126, 139, 0.94) !important;
  font-size: 15px !important;
}

@media (max-width: 1099px) {
  .pose-editor-person-switcher {
    right: 214px;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .pose-joint-rotation-panel {
    top: 96px;
    left: 58px !important;
    right: auto !important;
    width: min(250px, calc(100% - 66px)) !important;
    min-width: min(240px, calc(100% - 66px)) !important;
  }

  .pose-editor-history-dock {
    top: 8px;
    left: 8px;
  }

  .pose-editor-history-dock > span {
    display: none;
  }

  .pose-editor-mode-dock {
    left: 86px;
  }

  .pose-editor-person-switcher {
    top: 102px;
    left: 62px;
    right: 8px;
    max-width: none;
  }

  .standalone-stage.tool-drawer-open .pose-editor-person-switcher {
    left: 62px;
    right: 8px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .pose-editor-mode-dock {
    left: 86px;
  }

  .pose-editor-person-switcher {
    top: 148px;
  }

  .character-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
