/* ==========================================================================
   CustomAnimals 3D Studio - Dark Theme & Modern Glassmorphism Styling
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-surface: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.85);
  --bg-panel-header: rgba(30, 41, 59, 0.7);
  --bg-input: #1e293b;
  --bg-hover: #334155;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #8b5cf6;
  --accent-action: #10b981;
  --accent-action-hover: #059669;
  --accent-danger: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --glass-backdrop: blur(12px);
  --font-family: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body.dark-theme {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   Top Application Header
   -------------------------------------------------------------------------- */
.app-header {
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 16.5px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  border: 1.5px solid rgba(56, 189, 248, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-logo-img:hover {
  transform: scale(1.08);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.8);
}

.brand-icon {
  color: var(--accent-primary);
  font-size: 20px;
}

.brand .badge {
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   Buttons & Controls
   -------------------------------------------------------------------------- */
.btn {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-action {
  background: linear-gradient(135deg, var(--accent-action), var(--accent-action-hover));
  color: #fff;
  border: none;
}

.btn-action:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 9px;
  font-size: 13px;
}

.btn-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
}

.btn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-toggle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   Workspace Layout
   -------------------------------------------------------------------------- */
.app-workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Viewport 3D Canvas Container */
#viewport-container {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
}

#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewport-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 15;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.v-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

.toolbar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.switch-sm {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
}
.switch-sm input { opacity: 0; width: 0; height: 0; }
.switch-sm .slider:before {
  height: 10px;
  width: 10px;
  left: 3px;
  bottom: 3px;
}
.switch-sm input:checked + .slider:before { transform: translateX(12px); }

.viewport-badge {
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-muted);
}

/* Sidebars */
.sidebar {
  width: 350px;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-backdrop);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.right-sidebar {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}

.tab-panel.active {
  display: flex;
}

#panel-ai.ai-workspace {
  flex-direction: column !important;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Tool Groups & Inputs */
.tool-group {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-sub);
  letter-spacing: 0.5px;
}

.sub-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  min-width: 0;
}

.input-group span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  margin-right: 4px;
}

.input-group input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 12px;
  text-align: left;
  padding: 4px 0;
  outline: none;
}

/* Hide number spin arrows that squish text */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

select, input[type="text"], input[type="number"] {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-family);
  font-size: 12px;
  outline: none;
}

select:focus, input:focus {
  border-color: var(--border-focus);
}

.input-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Toggle Switch */
.toggle-switch-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-hover);
  transition: .2s;
  border-radius: 20px;
}
.slider:before {
  position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-primary); }
input:checked + .slider:before { transform: translateX(16px); }

/* Palette Grid */
.mc-block-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.mc-block-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mc-block-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  background: rgba(99, 102, 241, 0.1);
}

.mc-block-card.active {
  border-color: var(--accent-action);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.15);
}

.mc-block-img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.mc-block-name {
  font-size: 10px;
  font-weight: 500;
  text-align: center;
  color: var(--text-muted);
  word-break: break-word;
  line-height: 1.1;
}

.btn-category {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-full);
}

/* Sliders */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-container span {
  font-size: 11px;
  color: var(--text-muted);
}

input[type="range"] {
  accent-color: var(--accent-primary);
}

/* Outliner Tree */
.outliner-body {
  padding: 8px;
}

.tree-root {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-item {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  transition: background 0.15s ease;
}

.tree-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.tree-item.active {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
  font-weight: 500;
}

.btn-rename-part:hover {
  opacity: 1 !important;
  color: var(--accent-action) !important;
}

.btn-delete-part:hover {
  opacity: 1 !important;
  color: var(--accent-danger) !important;
}

/* --------------------------------------------------------------------------
   Animation Timeline Drawer
   -------------------------------------------------------------------------- */
.timeline-drawer {
  height: 220px;
  min-height: 120px;
  max-height: 70vh;
  background: var(--bg-surface);
  border-top: 2px solid var(--border-color);
  display: none;
  flex-direction: column;
  z-index: 20;
  position: relative;
  flex-shrink: 0;
}

.timeline-drawer.active {
  display: flex;
}

#timeline-resize-handle:hover,
#timeline-resize-handle:active {
  background: linear-gradient(to right, transparent 0%, var(--accent-primary) 50%, transparent 100%) !important;
  opacity: 0.5;
}

.timeline-toolbar {
  height: 38px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
}

.time-display {
  font-family: monospace;
  font-size: 12px;
  color: var(--accent-primary);
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.timeline-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.timeline-tracks-header {
  height: 24px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-sub);
}

.track-title-column {
  width: 180px;
  padding: 4px 12px;
  border-right: 1px solid var(--border-color);
}

.track-ruler-column {
  flex: 1;
  position: relative;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 19px,
    var(--border-color) 20px
  );
}

.timeline-tracks-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.timeline-track-row {
  height: 28px;
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.timeline-track-row .track-title-column {
  font-size: 12px;
  color: var(--text-main);
  display: flex;
  align-items: center;
}

.timeline-track-row .track-ruler-column {
  position: relative;
}

/* Outliner Inline Rename Input */
.outliner-inline-input {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-family: var(--font-family);
  font-size: 12px;
  outline: none;
}

/* Custom Toast Notification Container */
#toast-container {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-message {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--accent-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease forwards;
}

.toast-message.success { border-color: var(--accent-action); }
.toast-message.error { border-color: var(--accent-danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.tree-item.drag-target {
  outline: 2px dashed var(--accent-action) !important;
  background: rgba(59, 130, 246, 0.2) !important;
}

#root-drop-zone.drag-target {
  border-color: var(--accent-action) !important;
  background: rgba(59, 130, 246, 0.15) !important;
  color: #fff !important;
}

/* Has unsaved live-edit pose - pulse the Add Keyframe button */
#btn-add-keyframe.has-live-edit {
  animation: pulseKf 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

@keyframes pulseKf {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  50%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Auto-keyframe toggle active state */
#btn-auto-keyframe-toggle.active {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: var(--accent-danger) !important;
  color: var(--accent-danger) !important;
}

/* ==========================================================================
   AI Node Graph & Behavior Builder Styling
   ========================================================================== */
.ai-node-card {
  position: absolute;
  min-width: 190px;
  max-width: 270px;
  background: rgba(13, 19, 33, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.5);
  user-select: none;
  font-family: var(--font-family);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: visible;
}

.ai-node-card:hover {
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85);
}

.ai-node-card.event {
  border-color: rgba(245, 158, 11, 0.5);
}
.ai-node-card.event:hover {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.2), 0 14px 40px rgba(0, 0, 0, 0.85);
}

.ai-node-card.logic {
  border-color: rgba(168, 85, 247, 0.5);
}
.ai-node-card.logic:hover {
  border-color: #a855f7;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.2), 0 14px 40px rgba(0, 0, 0, 0.85);
}

.ai-node-card.action {
  border-color: rgba(34, 197, 94, 0.5);
}
.ai-node-card.action:hover {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.2), 0 14px 40px rgba(0, 0, 0, 0.85);
}

.ai-node-card.data {
  border-color: rgba(56, 189, 248, 0.5);
}
.ai-node-card.data:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2), 0 14px 40px rgba(0, 0, 0, 0.85);
}

.ai-node-card.selected {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.5), 0 14px 40px rgba(0, 0, 0, 0.9) !important;
}

.ai-node-header {
  padding: 7px 10px;
  border-top-left-radius: 7px;
  border-top-right-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  color: #ffffff;
  font-weight: 700;
  font-size: 11.5px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 8px;
}

.ai-node-header:active {
  cursor: grabbing;
}

.ai-node-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-del-node {
  all: unset;
  width: 17px;
  height: 17px;
  min-width: 17px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-del-node:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
  transform: scale(1.1);
}

.ai-node-params {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-sizing: border-box;
}

.ai-node-params:empty {
  display: none;
}

.ai-node-params input, .ai-node-params select {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 7px;
  font-size: 11px;
  background: #090e1a;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #f1f5f9;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-node-params input:focus, .ai-node-params select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.node-sockets {
  padding: 4px 10px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-sizing: border-box;
}

.node-socket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  color: #cbd5e1;
  min-height: 18px;
  position: relative;
}

.socket-pin {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #090e1a;
  background: #94a3b8;
  cursor: crosshair;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: absolute;
  z-index: 10;
}

.socket-pin:hover {
  transform: scale(1.45);
  box-shadow: 0 0 10px currentColor;
}

.socket-pin.input {
  left: -15px;
}

.socket-pin.output {
  right: -15px;
}

.socket-pin.socket-exec {
  background: #ffffff !important;
  color: #ffffff;
  border-radius: 2px !important;
  width: 9px;
  height: 9px;
}

.socket-pin.socket-entity { background: #38bdf8 !important; color: #38bdf8; }
.socket-pin.socket-number { background: #f59e0b !important; color: #f59e0b; }
.socket-pin.socket-boolean { background: #a855f7 !important; color: #a855f7; }
.socket-pin.socket-string { background: #4ade80 !important; color: #4ade80; }
.socket-pin.socket-any { background: #94a3b8 !important; color: #94a3b8; }

/* Autonomous Goal Priority Item */
.ai-goal-priority-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.ai-goal-priority-item:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.ai-goal-priority-rank {
  font-weight: 700;
  font-size: 10px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-radius: 4px;
  padding: 1px 5px;
  min-width: 22px;
  text-align: center;
}

/* Popover & Context Menu Item */
.node-popover-item, .node-context-item {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s ease;
}

.node-popover-item:hover, .node-context-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* AI Studio Sub-Navigation Tabs */
/* AI Studio Sub-Navigation Tabs */
.btn-sub-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sub-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-sub-tab.active {
  background: var(--accent-action) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* AI Split Layout & Collapsible Left Panel */
#ai-left-panel.collapsed {
  width: 0px !important;
  min-width: 0px !important;
  max-width: 0px !important;
  border-right: none !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.ai-left-view {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.ai-right-view {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

/* Inspector Property Table */
.ai-inspector-table {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.ai-inspector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid #1e293b;
  gap: 16px;
  transition: background 0.12s ease;
  min-width: 0;
  box-sizing: border-box;
}

.ai-inspector-row:last-child {
  border-bottom: none;
}

.ai-inspector-row:nth-child(even) {
  background: rgba(15, 23, 42, 0.4);
}

.ai-inspector-row:hover {
  background: rgba(30, 41, 59, 0.5);
}

.ai-inspector-label-col {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  flex: 0 0 280px;
}

.ai-inspector-controls-col {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.ai-inspector-slider {
  flex: 1;
  min-width: 120px;
  max-width: 280px;
  accent-color: var(--accent-action);
  height: 4px;
}

.ai-inspector-num {
  width: 70px;
  padding: 4px 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
  background: #0b1120;
  border: 1px solid #334155;
  color: #fff;
  border-radius: 4px;
  outline: none;
  font-family: monospace;
}

.ai-inspector-num:focus {
  border-color: var(--accent-action);
}

.ai-inspector-unit {
  font-size: 10.5px;
  color: var(--text-muted);
  width: 38px;
  text-align: left;
  flex-shrink: 0;
}

.ai-attr-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Goal & Target Priority Stack Cards */
.ai-goal-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  min-width: 0;
  transition: all 0.15s ease;
}

.ai-goal-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.ai-goal-card.disabled {
  opacity: 0.45;
  background: #090e1a;
  border-style: dashed;
}

.ai-goal-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-priority-badge {
  font-size: 10px;
  font-weight: 800;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-action);
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 1px 6px;
  border-radius: 5px;
  min-width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.ai-goal-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Custom Creature Variable Cards */
.cv-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0f172a;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.cv-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.cv-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cv-card-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Left panel smooth custom scrollbar */
.ai-left-view::-webkit-scrollbar {
  width: 6px;
}
.ai-left-view::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
.ai-left-view::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
.ai-left-view::-webkit-scrollbar-thumb:hover {
  background: var(--accent-action);
}

/* Goal Selection Modal Cards */
.ai-modal-goal-item {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}

.ai-modal-goal-item:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  transform: translateX(2px);
}

.custom-goal-card-item {
  padding: 8px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s ease;
}

.custom-goal-card-item:hover, .custom-goal-card-item.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
}

/* Node Context & Popover Menu Items with Category Matching Colors */
.node-context-item, .node-popover-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 5px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-left-width: 3.5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.node-context-item.event, .node-popover-item.event {
  border-left-color: #f59e0b;
}
.node-context-item.event:hover, .node-popover-item.event:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.5);
  border-left-color: #f59e0b;
  transform: translateX(2px);
}

.node-context-item.logic, .node-popover-item.logic {
  border-left-color: #a855f7;
}
.node-context-item.logic:hover, .node-popover-item.logic:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.5);
  border-left-color: #a855f7;
  transform: translateX(2px);
}

.node-context-item.action, .node-popover-item.action {
  border-left-color: #22c55e;
}
.node-context-item.action:hover, .node-popover-item.action:hover {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.5);
  border-left-color: #22c55e;
  transform: translateX(2px);
}

.node-context-item.data, .node-popover-item.data {
  border-left-color: #38bdf8;
}
.node-context-item.data:hover, .node-popover-item.data:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.5);
  border-left-color: #38bdf8;
  transform: translateX(2px);
}

.node-type-badge {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: auto;
}

.node-type-badge.event {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.node-type-badge.logic {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.node-type-badge.action {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.node-type-badge.data {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* ==========================================================================
   Rigging Front Direction & Forward Vector Styling
   ========================================================================== */
.front-direction-group {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  position: relative;
  overflow: hidden;
}

.front-direction-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-action), #38bdf8, transparent);
}

.vector-badge {
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.2px;
}

.direction-presets-grid .btn-forward-preset {
  padding: 4px 2px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.direction-presets-grid .btn-forward-preset:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: #fff;
}

.direction-presets-grid .btn-forward-preset.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent-action);
  color: #fff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.direction-presets-grid .btn-forward-preset i {
  font-size: 11px;
  color: var(--accent-action);
}

#rigging-hierarchy-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ==========================================================================
   Minecraft AI Studio Styling (Attributes, Goals, Targets)
   ========================================================================== */
.ai-workspace {
  background: radial-gradient(circle at 50% 0%, #0d1527 0%, #070b14 100%) !important;
}

.ai-view-panel {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 20px 60px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.15s ease-out;
}

.ai-category-block {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.ai-category-header {
  padding: 10px 16px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-attributes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
  padding: 12px;
}

.ai-attr-card {
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
}

.ai-attr-card:hover {
  background: #0f172a;
  border-color: #334155;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ai-goal-card, .ai-target-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-goal-card:hover, .ai-target-card:hover {
  border-color: #334155;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.ai-goal-card.disabled, .ai-target-card.disabled {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.goal-priority-badge {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.target-priority-badge {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.goal-cat-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.modal-item-row {
  padding: 10px 14px;
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-item-row:hover {
  background: #1e293b;
  border-color: var(--accent-action);
  transform: translateX(2px);
}





