:root {
  --bg-obsidian: #090b10;
  --glass-bg: rgba(13, 16, 24, 0.84);
  --glass-heavy: rgba(12, 15, 22, 0.94);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-gold: rgba(229, 192, 123, 0.38);
  --gold: #e5c07b;
  --gold-bright: #f6d89e;
  --gold-dim: rgba(229, 192, 123, 0.16);
  --cyan: #56c8f5;
  --rose: #f43f5e;
  --text-main: #eef2f7;
  --text-dim: #94a3b8;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-obsidian);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  user-select: none;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

#app-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* ==================== Sleek Top Header ==================== */
#top-bar {
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l));
  background: var(--glass-heavy);
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
  z-index: 40;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.8px;
  color: var(--gold-bright);
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-tabs {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.mode-tab.active {
  background: var(--gold-dim);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px var(--border-gold);
}

#top-bar select {
  max-width: 195px;
  height: 28px;
  padding: 0 8px;
  font-size: 11.5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-spine-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.nav-arrow-btn {
  padding: 0 7px !important;
  font-size: 10px !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10.5px;
  white-space: nowrap;
}

.telemetry-pill strong {
  color: var(--text-main);
  font-weight: 600;
}

.icon-btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.icon-btn.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

/* ==================== Full-Bleed Viewport ==================== */
#viewport-shell {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #131722 0%, #07090d 100%);
  overflow: hidden;
  overflow: clip;
}

#canvas-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#canvas-frame.portrait-aspect {
  width: auto;
  height: 95%;
  aspect-ratio: 9 / 16;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.8);
}

#canvas-frame.ref-aspect {
  width: auto;
  height: 95%;
  aspect-ratio: 1 / 2;
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.8);
}

#gl-canvas, #spine-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#spine-debug-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 13;
  pointer-events: none;
}

#spine-canvas.cutin-overlay {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--rose);
}

.cutin-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(12, 15, 22, 0.88);
  border: 1px solid var(--border-gold);
  color: var(--gold-bright);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 1px;
  padding: 4px 14px;
  border-radius: 999px;
  pointer-events: none;
}

/* ==================== Unified Compact HUD Cards ==================== */
#hud-overlay, .spine-hud-top {
  position: absolute;
  top: 10px;
  left: calc(10px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(360px, 62vw);
  pointer-events: none;
  z-index: 15;
}

.hud-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1.38;
}

.hud-stage-title {
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-sub {
  color: var(--text-dim);
  font-size: 10.5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-accent-tip {
  color: #cbd5e1;
  font-family: inherit;
}

/* ==================== Mobile Landscape Touch Joystick & Quick Battle Dock ==================== */
#touch-controls-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 16;
}

.touch-joystick {
  position: absolute;
  left: calc(18px + var(--safe-l));
  bottom: calc(56px + var(--safe-b));
  width: 104px;
  height: 104px;
  pointer-events: auto;
  touch-action: none;
}

.joy-ring {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(12, 15, 22, 0.52);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(229, 192, 123, 0.34);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.joy-ring::after {
  content: "";
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.joy-knob {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6d89e, #c79a4b);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transform: translate(0px, 0px);
  pointer-events: none;
}

.hud-battle-dock {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(54px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  transition: right 0.22s ease;
}

/* Shift dock left when drawer is open on desktop so they never overlap */
#app-layout:not(.drawer-collapsed) .hud-battle-dock {
  right: 334px;
}

.dock-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 1px;
}

.dock-toggle, .dock-skill-btn {
  height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.dock-toggle.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.dock-skill-btn span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.24);
  color: #fda4af;
  font-size: 10px;
  font-weight: 700;
}

.dock-skill-btn:hover, .dock-skill-btn:active {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.55);
}

/* ==================== Spine Interactive Gameplay Layer ==================== */
#spine-ui-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

#spine-ui-layer:active {
  cursor: grabbing;
}

#spine-hotspots-layer, #spine-feedback-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.spine-hotspot {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  pointer-events: none;
}

.spine-hotspot .hs-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.8px solid rgba(86, 200, 245, 0.85);
  background: rgba(86, 200, 245, 0.14);
  animation: hsPulse 1.8s ease-in-out infinite;
}

.spine-hotspot-drag .hs-ring,
.spine-hotspot-hold_drag .hs-ring {
  border-color: rgba(229, 192, 123, 0.95);
  background: rgba(229, 192, 123, 0.2);
}

.spine-hotspot-hold .hs-ring {
  border-color: rgba(244, 63, 94, 0.9);
  background: rgba(244, 63, 94, 0.18);
}

.spine-hotspot .hs-icon {
  position: relative;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

@keyframes hsPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.76; }
  50% { transform: scale(1.16); opacity: 1.0; }
}

.spine-float-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 11.5px;
  background: var(--glass-heavy);
  border: 1px solid var(--border-gold);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  animation: floatUpFade 1.05s ease-out forwards;
}

@keyframes floatUpFade {
  0% { opacity: 1; margin-top: 0px; }
  100% { opacity: 0; margin-top: -34px; }
}

.spine-gauge-box {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 8px;
  padding: 5px 10px;
  pointer-events: auto;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #fda4af;
  margin-bottom: 4px;
}

.gauge-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #fb7185, #f43f5e, #e5c07b);
  transition: width 0.2s ease-out;
}

.spine-bottom-dock {
  position: absolute;
  bottom: calc(12px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 24px);
  z-index: 16;
}

.spine-ui-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 4px 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

.spine-ui-bar::-webkit-scrollbar {
  display: none;
}

.stage-chip, .tool-chip {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  cursor: pointer;
}

.stage-chip.active, .tool-chip.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 6px;
}

.tool-chip img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* ==================== Floating Bottom Pipeline Bar ==================== */
#pipeline-bar {
  position: absolute;
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  bottom: calc(8px + var(--safe-b));
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  transition: right 0.22s ease;
}

#app-layout:not(.drawer-collapsed) #pipeline-bar {
  right: 332px;
}

.pipeline-dock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.stage-pills::-webkit-scrollbar {
  display: none;
}

.stage-pill {
  flex: 1 0 auto;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.stage-pill.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
  font-weight: 700;
}

.pipeline-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pill-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.wipe-slider {
  width: 74px !important;
}

#stage-detail-strip {
  display: grid;
  grid-template-columns: 1.3fr 1.2fr 1.1fr 1.2fr;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 5px;
  font-size: 10.5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.detail-cell span {
  color: var(--text-dim);
  display: block;
  font-size: 9.5px;
}

/* ==================== Floating Consolidated Slide-Over Drawer ==================== */
.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 28;
}

#side-drawer {
  position: absolute;
  top: 8px;
  right: calc(8px + var(--safe-r));
  bottom: calc(8px + var(--safe-b));
  width: 316px;
  max-width: calc(100vw - 16px);
  background: var(--glass-heavy);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.65);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}

#app-layout.drawer-collapsed #side-drawer {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.drawer-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 9px 7px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
  flex-shrink: 0;
}

.sub-tabs {
  display: flex;
  flex: 1 1 auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}

.sub-tab {
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 4px 4px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.sub-tab.active {
  background: var(--gold-dim);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px var(--border-gold);
}

.drawer-close-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 9px 10px 16px;
  scrollbar-width: thin;
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.panel-group {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--text-main);
}

.summary-toggle {
  cursor: pointer;
  list-style: none;
}

.summary-toggle::-webkit-details-marker {
  display: none;
}

.summary-toggle::after {
  content: "▾";
  color: var(--text-dim);
  font-size: 11px;
}

details[open] .summary-toggle::after {
  content: "▴";
}

.details-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.tag-gold, .tag-rose {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.tag-gold {
  background: var(--gold-dim);
  color: var(--gold-bright);
  border: 1px solid var(--border-gold);
}

.tag-rose {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.mini-btn {
  padding: 2px 7px;
  font-size: 10.5px;
  height: 22px;
}

/* ==================== Form Controls ==================== */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-dim);
  font-size: 11px;
}

.control-val {
  color: var(--gold-bright);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10.5px;
}

select, button, input[type="text"] {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
}

select option {
  background: #141924;
  color: var(--text-main);
}

select, button {
  cursor: pointer;
}

select:hover, button:hover, input[type="text"]:focus {
  border-color: var(--border-gold);
  outline: none;
}

button.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.btn-row {
  display: flex;
  gap: 6px;
}

.btn-row > button {
  flex: 1 1 0;
  padding: 5px 6px;
  font-size: 11px;
}

.skill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.skill-grid .skill-btn {
  font-weight: 600;
  font-size: 11px;
  padding: 5px 6px;
}

.skill-btn-wide {
  grid-column: 1 / -1;
}

.status-note {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.35;
}

.spine-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  padding: 5px;
  border-radius: 6px;
  text-align: center;
}

.spine-stat-grid span {
  display: block;
  font-size: 9.5px;
  color: var(--text-dim);
}

.spine-stat-grid strong {
  font-size: 11.5px;
  color: var(--gold-bright);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.cat-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
}

.cat-pill {
  flex: 1 1 0;
  padding: 4px 3px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
}

.cat-pill.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.spine-rig-gallery {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 184px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.rig-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}

.rig-card:hover {
  border-color: var(--border-gold);
  background: rgba(255, 255, 255, 0.06);
}

.rig-card.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
}

.rig-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.rig-card-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 11px;
  color: var(--text-main);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rig-card.active .rig-card-title {
  color: var(--gold-bright);
}

.rig-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

.rig-badge-dating {
  background: rgba(229, 192, 123, 0.22);
  color: var(--gold-bright);
}

.rig-badge-prestige {
  background: rgba(244, 63, 94, 0.22);
  color: #fda4af;
}

.rig-badge-cutscene {
  background: rgba(86, 200, 245, 0.2);
  color: #7dd3fc;
}

.rig-badge-special {
  background: rgba(192, 132, 252, 0.2);
  color: #d8b4fe;
}

.rig-card-meta {
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.rig-card-sub {
  font-size: 10px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== Live2D Rigging & Binding Debug Styles ==================== */
.spine-debug-hud {
  border-color: rgba(244, 63, 94, 0.42);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dbg-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 10px;
  color: var(--text-main);
}

.dbg-legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.dbg-legend-row i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.dbg-pick-line {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dbg-checks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.dbg-checks-grid .pill-check {
  justify-content: flex-start;
  height: 25px;
  font-size: 10.5px;
}

.dbg-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.28);
  padding: 6px;
  border-radius: 6px;
  text-align: center;
}

.dbg-telemetry-grid span {
  display: block;
  font-size: 9.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.dbg-telemetry-grid strong {
  font-size: 11px;
  color: var(--gold-bright);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.dbg-selected-card {
  background: rgba(229, 192, 123, 0.08);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dbg-sel-name {
  font-weight: 700;
  font-size: 11px;
  color: var(--gold-bright);
  word-break: break-all;
}

.dbg-sel-meta {
  font-size: 10px;
  color: #cbd5e1;
  line-height: 1.38;
  word-break: break-word;
}

.dbg-bone-list {
  max-height: 165px;
}

.anim-listbox {
  height: 165px;
  padding: 4px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--gold);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--text-main);
}

/* Loading Mask */
#loading-mask {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 15, 0.86);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 50;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(229, 192, 123, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#app-layout.pipeline-collapsed .touch-joystick {
  bottom: calc(14px + var(--safe-b));
}

#app-layout.pipeline-collapsed .hud-battle-dock {
  bottom: calc(12px + var(--safe-b));
}

/* ==================== Mobile Landscape & Compact Screen Optimization ==================== */
@media (max-width: 1120px) {
  .tel-hide-md {
    display: none;
  }
  #app-layout:not(.drawer-collapsed) #pipeline-bar,
  #app-layout:not(.drawer-collapsed) .hud-battle-dock {
    right: calc(10px + var(--safe-r));
  }
}

@media (max-width: 960px), (max-height: 540px) {
  #top-bar {
    height: 38px;
  }
  .tel-hide-sm {
    display: none;
  }
  #top-bar select {
    max-width: 135px;
    height: 26px;
    font-size: 11px;
  }
  .mode-tab, .icon-btn {
    padding: 3px 8px;
    height: 26px;
    font-size: 11px;
  }
  #side-drawer {
    top: 4px;
    bottom: calc(4px + var(--safe-b));
    width: min(300px, 78vw);
  }
  .touch-joystick {
    width: 92px;
    height: 92px;
    bottom: calc(46px + var(--safe-b));
  }
  .joy-knob {
    width: 34px;
    height: 34px;
  }
  .hud-battle-dock {
    bottom: calc(46px + var(--safe-b));
    padding: 4px 6px;
    gap: 4px;
    max-width: calc(100vw - 135px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hud-battle-dock::-webkit-scrollbar {
    display: none;
  }
  .dock-toggle, .dock-skill-btn {
    height: 28px;
    padding: 0 7px;
    font-size: 10.5px;
  }
  #pipeline-bar {
    padding: 4px 6px;
    bottom: calc(4px + var(--safe-b));
  }
  .stage-pill {
    height: 24px;
    padding: 0 6px;
    font-size: 10px;
  }
  #stage-detail-strip {
    grid-template-columns: 1fr 1fr;
  }
  .spine-bottom-dock {
    bottom: calc(6px + var(--safe-b));
    gap: 4px;
  }
  .hud-card {
    padding: 4px 8px;
  }
  .spine-rig-gallery {
    max-height: 126px;
  }
}
