/* =========================================================
   3D Studio - Professional Vector UI/UX
   Zero-Distortion SVG Icon System, Fully Responsive
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --surface-0: #ffffff;
  --surface-50: #f8fafc;
  --surface-100: #f1f5f9;
  --surface-200: #e2e8f0;
  --surface-300: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --border-color: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --topbar-height: 48px;
  --bottombar-height: 30px;
  --sidebar-w: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Tajawal', 'Inter', system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--surface-100);
  color: var(--text-primary);
  direction: rtl;
}

body {
  display: flex;
  flex-direction: column;
}

/* ==================== نظام أيقونات المتجهات الدقيق (SVG Icon Engine) ==================== */
.app-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.app-icon-lg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.app-icon-sm {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}

/* ==================== 1. الشريط العلوي (Top Navbar) ==================== */

.top-navbar {
  height: var(--topbar-height);
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 1000;
  flex-shrink: 0;
  gap: 8px;
  white-space: nowrap;
  overflow: visible;
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon .app-icon {
  width: 16px;
  height: 16px;
  stroke: white;
  stroke-width: 2.2;
}

.brand-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-100);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--surface-200);
}

/* مجموعات الأدوات */
.tool-group {
  display: flex;
  align-items: center;
  background: var(--surface-100);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.tool-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  height: 30px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.tool-btn:hover {
  background: var(--surface-0);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tool-btn:active {
  transform: translateY(1px);
}

.tool-btn.active {
  background: var(--primary);
  color: white;
}

.tool-btn-icon-only {
  width: 30px;
  padding: 0;
  justify-content: center;
}

.tool-btn-danger:hover {
  background: #fee2e2;
  color: var(--accent-red);
}

/* أزرار الإجراءات */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0 12px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

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

.btn-secondary {
  background: var(--surface-0);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0 10px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--surface-50);
  border-color: var(--surface-300);
}

.btn-sidebar-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--surface-0);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-sidebar-toggle:hover {
  background: var(--surface-100);
  color: var(--text-primary);
}

.btn-sidebar-toggle.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #bfdbfe;
}

/* ==================== القوائم المنسدلة في الشريط العلوي (Dropdown Menus) ==================== */

.dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.dropdown-btn .app-icon-sm {
  margin-right: -2px;
  opacity: 0.85;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  background: var(--surface-0);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 2500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  pointer-events: none;
}

.dropdown-menu-end {
  left: 0;
  right: auto;
}

.dropdown-menu-start {
  right: 0;
  left: auto;
}

.dropdown-wrapper.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: right;
  transition: background 0.12s ease;
  color: var(--text-primary);
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--surface-100);
}

.dropdown-item:active {
  transform: scale(0.99);
}

.dropdown-item-danger:hover {
  background: #fef2f2;
}

.dropdown-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dropdown-item:hover .dropdown-item-icon {
  background: var(--surface-100);
}

.dropdown-item-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
  text-align: right;
}

.dropdown-item-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.dropdown-item-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

/* ==================== 2. مساحة العمل (App Workspace) ==================== */

.app-workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== 3. اللوحات الجانبية (Sidebars) ==================== */

.sidebar-left {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface-0);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 90;
  transition: margin-right 0.22s ease, transform 0.22s ease;
}

.sidebar-right {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface-0);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 90;
  transition: margin-left 0.22s ease, transform 0.22s ease;
}

/* رأس اللوحات */
.panel-header-bar {
  height: 38px;
  background: var(--surface-50);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.panel-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-close-panel {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-close-panel:hover {
  background: var(--surface-200);
  color: var(--text-primary);
}

/* تبويبات اللوحة اليسرى */
.panel-tabs-header {
  display: flex;
  background: var(--surface-50);
  border-bottom: 1px solid var(--border-color);
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.panel-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 4px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.12s ease;
}

.panel-tab-btn:hover {
  color: var(--text-primary);
}

.panel-tab-btn.active {
  background: var(--surface-0);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.panel-body-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* إخفاء التبويبات غير النشطة بقوة */
.tab-pane, .left-tab-content {
  display: none !important;
}

.tab-pane.active, .left-tab-content.active {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
}

.section-caption {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* شبكة الأشكال */
.geometry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.shape-item-btn {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.12s ease;
}

.shape-item-btn:hover {
  background: var(--surface-0);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
}

.shape-item-btn:active {
  transform: translateY(1px);
}

.shape-item-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: white;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.shape-item-icon .app-icon {
  width: 15px;
  height: 15px;
}

/* إدخال النص 3D */
.input-group-row {
  display: flex;
  gap: 6px;
}

.clean-input {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--surface-0);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.clean-input:focus {
  border-color: var(--primary);
}

/* منطقة إفلات الملفات */
.dropzone-box {
  border: 2px dashed var(--border-color);
  background: var(--surface-50);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.dropzone-box:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.dropzone-icon {
  color: var(--primary);
  margin-bottom: 4px;
}

.dropzone-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.dropzone-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.models-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.model-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.model-item-row:hover {
  border-color: var(--primary);
  background: var(--surface-100);
}

.model-item-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-open-model {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-open-model:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* بطاقات المشاريع */
.project-card {
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-card-badge {
  font-size: 9px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 5px;
  border-radius: 3px;
}

.project-card-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
}

.project-card-desc {
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.project-card-steps {
  font-size: 10px;
  color: var(--text-muted);
  padding-right: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-load-project {
  width: 100%;
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.btn-load-project:hover {
  background: var(--primary);
  color: white;
}

/* ==================== 4. مساحة العرض ثلاثية الأبعاد (Viewport) ==================== */

.viewport-wrapper {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #f1f5f9;
}

#canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

.camera-controls-stack {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 35;
  pointer-events: none;
  user-select: none;
  transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.camera-controls-stack > * {
  pointer-events: auto;
}

.camera-quick-tools {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 5px;
  gap: 3px;
  user-select: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.orientation-sphere-wrapper {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  border-radius: 50%;
  overflow: hidden;
}

.orientation-sphere-wrapper:active {
  cursor: grabbing;
}

#orientation-sphere-canvas {
  width: 76px;
  height: 76px;
  display: block;
  border-radius: 50%;
  touch-action: none;
}

/* لوحة أزرار الوظائف الثلاثة العائمة أسفل كارت الكاميرا (تحريك، تحجيم، تدوير) */
.transform-modes-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 86px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05);
  padding: 6px 5px;
  gap: 4px;
  user-select: none;
  animation: fadeInDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

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

.transform-modes-header {
  width: 100%;
  text-align: center;
  padding: 2px 0 4px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 1px;
}

.transform-modes-title {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.transform-mode-btn {
  width: 100%;
  min-height: 52px;
  padding: 6px 3px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
  box-sizing: border-box;
}

.transform-mode-btn:hover {
  background: var(--surface-100);
  border-color: var(--border-color);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.transform-mode-btn:active {
  transform: scale(0.97);
}

.transform-mode-key {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 3.5px;
  border-radius: 4px;
  background: var(--surface-200);
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  transition: all 0.18s ease;
}

.transform-mode-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-200);
  color: var(--text-primary);
  transition: all 0.18s ease;
}

.transform-mode-btn:hover .transform-mode-icon-box {
  background: var(--primary-light);
  color: var(--primary);
}

.transform-mode-icon-box .app-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.transform-mode-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.1;
  color: inherit;
}

/* الحالة النشطة للزر المحدد (تحريك / تحجيم / تدوير) */
.transform-mode-btn.active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.transform-mode-btn.active .transform-mode-icon-box {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.transform-mode-btn.active .transform-mode-label {
  color: #ffffff;
  font-weight: 800;
}

.transform-mode-btn.active .transform-mode-key {
  background: rgba(255, 255, 255, 0.26);
  color: #ffffff;
}

/* لوحة المفتش - مبدل الوظائف المجزأ فائق الأناقة */
.inspector-modes-segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-100);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-top: 6px;
  box-sizing: border-box;
}

.insp-mode-tab {
  flex: 1;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.16s ease;
  color: var(--text-secondary);
  font-family: inherit;
  box-sizing: border-box;
}

.insp-mode-tab:hover {
  background: var(--surface-200);
  color: var(--text-primary);
}

.insp-mode-tab:active {
  transform: scale(0.97);
}

.insp-mode-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.insp-mode-tab-icon .app-icon {
  width: 15px;
  height: 15px;
}

.insp-mode-tab-text {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.insp-mode-tab.active {
  background: var(--surface-0);
  color: var(--primary);
  font-weight: 800;
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.insp-mode-tab.active .insp-mode-tab-icon {
  color: var(--primary);
}

/* زر طي وتمديد قائمة زوايا الرؤية أسفل الكرة */
.cam-toggle-collapse-btn {
  width: 100%;
  height: 20px;
  border: none;
  background: var(--surface-100);
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 1px;
}

.cam-toggle-collapse-btn:hover {
  background: var(--surface-200);
  color: var(--primary);
}

.cam-toggle-collapse-btn .cam-chevron-icon {
  width: 13px;
  height: 13px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.camera-quick-tools.expanded .cam-toggle-collapse-btn {
  background: var(--primary-subtle);
  color: var(--primary);
}

.camera-quick-tools.expanded .cam-chevron-icon {
  transform: rotate(180deg);
}

/* حاوية الأزرار المنكمشة افتراضياً وتتمدد بسلاسة */
.cam-views-collapsible {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 3px;
  align-items: center;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: max-height 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s ease,
              transform 0.2s ease;
}

.camera-quick-tools.expanded .cam-views-collapsible {
  max-height: 180px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.cam-tools-divider {
  width: 100%;
  height: 1px;
  background: var(--border-color);
  margin: 2px 0;
}

.cam-quick-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.cam-quick-btn:hover {
  background: var(--surface-100);
  color: var(--primary);
}

.cam-quick-btn:active {
  background: var(--surface-200);
  transform: scale(0.96);
}

/* ==================== 5. لوحة المفتش والخصائص (Inspector) ==================== */

.inspector-card {
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selected-obj-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* أبعاد X, Y, Z */
.axis-indicator-row {
  display: flex;
  gap: 4px;
}

.axis-badge-box {
  flex: 1;
  border-radius: var(--radius-sm);
  padding: 4px 5px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.axis-badge-box.flash {
  transform: scale(1.08);
  filter: brightness(1.25);
}

.axis-x { background: #ef4444; }
.axis-y { background: #10b981; }
.axis-z { background: #2563eb; }

.axis-val {
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 3px;
  border-radius: 2px;
  font-family: 'Inter', monospace;
  font-size: 10px;
}

/* صف مؤشرات زوايا الدوران بالدرجات */
.rotation-indicator-row {
  margin-top: 4px;
  transition: all 0.2s ease;
}

.rotation-indicator-row .axis-badge-box {
  background: #334155;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rotation-indicator-row .axis-x { background: #b91c1c; }
.rotation-indicator-row .axis-y { background: #047857; }
.rotation-indicator-row .axis-z { background: #1d4ed8; }

body.transform-mode-rotate .rotation-indicator-row {
  border-radius: 6px;
  box-shadow: 0 0 0 1.5px rgba(37, 99, 235, 0.45);
}

/* أزرار التحكم الدقيق بالاتجاهات */
.directional-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-0);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.control-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.btn-ctrl {
  flex: 1;
  height: 30px;
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.1s ease;
}

.btn-ctrl:hover {
  background: var(--surface-100);
  border-color: var(--surface-300);
  color: var(--text-primary);
}

.btn-ctrl:active {
  transform: translateY(1px);
}

.btn-ctrl.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ctrl-accent {
  background: var(--primary-light);
  border-color: var(--border-color);
  color: var(--primary);
}

.btn-ctrl-accent:hover {
  background: var(--surface-200);
  color: var(--primary-hover);
}

.btn-ctrl .app-icon {
  width: 14px;
  height: 14px;
}

.step-selector-row {
  display: flex;
  gap: 3px;
  margin-top: 2px;
}

.btn-step {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 0;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.12s ease;
}

.btn-step:hover {
  background: var(--surface-100);
  color: var(--text-primary);
}

.btn-step.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* الألوان */
.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.color-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.color-dot:hover {
  transform: scale(1.15);
}

.color-dot.active {
  box-shadow: 0 0 0 2px white, 0 0 0 3.5px var(--primary);
  transform: scale(1.05);
}

/* الخامات */
.finishes-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.finish-item-btn {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s ease;
}

.finish-item-btn:hover {
  background: var(--surface-100);
  border-color: var(--surface-300);
  color: var(--text-primary);
}

.finish-item-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* عناصر المشهد */
.outliner-box {
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.outliner-list {
  display: flex;
  flex-direction: column;
  max-height: 120px;
  overflow-y: auto;
}

.outliner-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.outliner-item:hover {
  background: var(--surface-100);
  color: var(--text-primary);
}

.outliner-item.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.outliner-name {
  flex: 1;
  margin: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outliner-actions {
  display: flex;
  gap: 4px;
}

.btn-outliner-action {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-outliner-action:hover {
  background: var(--surface-200);
  color: var(--text-primary);
}

/* ==================== 6. شريط الحالة السفلي ==================== */

.bottom-status-bar {
  height: var(--bottombar-height);
  background: var(--surface-0);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 60;
  white-space: nowrap;
  overflow: hidden;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-tip {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== 7. النوافذ المنبثقة والإشعارات ==================== */

.toast-box {
  position: fixed;
  top: 64px;
  bottom: auto !important;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: white;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  direction: rtl;
}

.toast-box.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--surface-0);
  border-radius: var(--radius-md);
  padding: 16px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-backdrop.show .modal-dialog {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-snapshot-container {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--surface-100);
}

.preview-snapshot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ==================== إعدادات مساحة العمل والجاذبية ==================== */
.settings-group {
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

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

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

@media (max-width: 600px) {
  #unit-presets-row {
    grid-template-columns: 1fr;
  }
}

.btn-preset {
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  transition: all 0.15s ease;
  text-align: right;
}

.btn-preset:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.btn-preset.active {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.preset-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.preset-sub {
  font-size: 9.5px;
  color: var(--text-muted);
}

.setting-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-toggle-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.setting-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* مفتاح التحويل (Toggle Switch) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface-300);
  transition: 0.2s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.loader-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3.5px solid var(--surface-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinRing 0.8s linear infinite;
}

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

.loader-text {
  color: white;
  font-size: 13px;
  font-weight: 700;
}

body.drag-active::after {
  content: 'إفلات الملف ثلاثي الأبعاد للاستيراد المباشر';
  position: fixed;
  inset: 12px;
  background: rgba(37, 99, 235, 0.9);
  backdrop-filter: blur(4px);
  border: 2px dashed white;
  border-radius: var(--radius-md);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  z-index: 10000;
  pointer-events: none;
}

/* ==================== 8. التجاوب المطلق وحماية عدم التداخل ==================== */

/* ==================== 8. التجاوب الذكي للشريط العلوي وكافة الأجهزة ==================== */

@media (max-width: 1200px) {
  .btn-text-label {
    display: none !important;
  }
  .tool-btn {
    padding: 0 6px;
  }
}

@media (max-width: 900px) {
  .nav-desktop-only {
    display: none !important;
  }
  .brand-tag {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .brand-text {
    display: none !important;
  }
  .top-navbar {
    padding: 0 8px;
    gap: 6px;
  }
  .nav-left, .nav-center, .nav-right {
    gap: 4px;
  }
}

/* تصغير عناصر الشريط العلوي عند تجاوز العرض الأدنى للشريط */
@media (max-width: 640px) {
  :root {
    --topbar-height: 40px;
  }
  .top-navbar {
    padding: 0 clamp(4px, 1.2vw, 8px);
    gap: clamp(3px, 0.8vw, 6px);
  }
  .nav-left, .nav-center, .nav-right {
    gap: clamp(2px, 0.6vw, 4px);
  }
  .brand-wrapper {
    margin-left: 0;
    gap: 0;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
  }
  .brand-icon .app-icon {
    width: 14px;
    height: 14px;
  }
  .tool-group {
    padding: 1px;
    gap: 1px;
    border-radius: 6px;
  }
  .tool-btn {
    height: 26px;
    min-width: 26px;
    padding: 0 4px;
    font-size: 11px;
    border-radius: 4px;
    gap: 3px;
  }
  .tool-btn-icon-only {
    width: 26px;
    height: 26px;
    padding: 0;
  }
  .tool-btn .app-icon,
  .btn-primary .app-icon,
  .btn-sidebar-toggle .app-icon {
    width: 14px;
    height: 14px;
  }
  .btn-primary {
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 11px;
  }
  .btn-primary .app-icon-sm {
    display: none !important;
  }
  .btn-sidebar-toggle {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }
}

/* الشاشات الضيقة جداً: تصغير متناسق لحماية الشريط من الخروج أو التداخل */
@media (max-width: 480px) {
  :root {
    --topbar-height: 36px;
  }
  .top-navbar {
    padding: 0 4px;
    gap: 3px;
  }
  .nav-left, .nav-center, .nav-right {
    gap: 2.5px;
  }
  .brand-icon {
    width: 24px;
    height: 24px;
    border-radius: 5px;
  }
  .brand-icon .app-icon {
    width: 13px;
    height: 13px;
  }
  .tool-group {
    padding: 1px;
    gap: 1px;
    border-radius: 5px;
  }
  .tool-btn {
    height: 24px;
    min-width: 24px;
    padding: 0 2px;
    border-radius: 3px;
  }
  .tool-btn-icon-only {
    width: 24px;
    height: 24px;
  }
  .tool-btn .app-icon,
  .btn-primary .app-icon,
  .btn-sidebar-toggle .app-icon {
    width: 13px;
    height: 13px;
  }
  .btn-primary {
    height: 25px;
    padding: 0 6px;
    border-radius: 5px;
  }
  .btn-sidebar-toggle {
    width: 25px;
    height: 25px;
    border-radius: 5px;
  }
  .bottom-status-bar {
    display: none;
  }
}

/* الشاشات الصغيرة جداً والموبايل الصغير */
@media (max-width: 380px) {
  :root {
    --topbar-height: 33px;
  }
  .top-navbar {
    padding: 0 2px;
    gap: 2px;
  }
  .nav-left, .nav-center, .nav-right {
    gap: 1.5px;
  }
  .brand-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
  }
  .brand-icon .app-icon {
    width: 12px;
    height: 12px;
  }
  .tool-group {
    padding: 0.5px;
    gap: 0.5px;
    border-radius: 4px;
  }
  .tool-btn {
    height: 22px;
    min-width: 22px;
    padding: 0 1px;
    border-radius: 3px;
  }
  .tool-btn-icon-only {
    width: 22px;
    height: 22px;
  }
  .tool-btn .app-icon,
  .btn-primary .app-icon,
  .btn-sidebar-toggle .app-icon {
    width: 12px;
    height: 12px;
  }
  .btn-primary {
    height: 23px;
    padding: 0 4px;
    border-radius: 4px;
  }
  .btn-sidebar-toggle {
    width: 23px;
    height: 23px;
    border-radius: 4px;
  }
}

@media (max-width: 1080px) {
  .sidebar-left {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.15);
    transform: translateX(105%);
    margin-right: 0 !important;
  }

  .sidebar-left.open {
    transform: translateX(0);
  }

  .sidebar-right {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    box-shadow: 10px 0 25px rgba(0, 0, 0, 0.15);
    transform: translateX(-105%);
    margin-left: 0 !important;
  }

  .sidebar-right.open {
    transform: translateX(0);
  }
}

@media (min-width: 1081px) {
  .sidebar-left.collapsed {
    margin-right: calc(-1 * var(--sidebar-w));
  }

  .sidebar-right.collapsed {
    margin-left: calc(-1 * var(--sidebar-w));
  }

  .drawer-backdrop {
    display: none !important;
  }
}

/* ==================== 9. شريط وأدوات النحت والصلصال الرقمي ==================== */

.sculpt-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-15px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 60;
  max-width: 95vw;
}

.sculpt-toolbar.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.sculpt-toolbar-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.sculpt-badge {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
}

.sculpt-main-controls {
  display: contents;
}

.sculpt-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sculpt-brushes-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-sculpt-brush {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-100);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sculpt-brush:hover {
  background: var(--surface-200);
  border-color: var(--primary-light);
}

.btn-sculpt-brush.active {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--primary);
}

.sculpt-sliders-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.sculpt-slider-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 75px;
}

.sculpt-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
}

.slider-badge {
  font-family: monospace;
  font-size: 10px;
  color: var(--primary);
  font-weight: 700;
}

.sculpt-range {
  width: 100%;
  accent-color: var(--primary);
  height: 4px;
  cursor: pointer;
}

.btn-exit-sculpt {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid #16a34a;
  background: #16a34a;
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-exit-sculpt:hover {
  background: #15803d;
}

.btn-sculpt-reset {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  background: var(--surface-100);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sculpt-reset:hover {
  background: #fee2e2;
  color: var(--accent-red);
  border-color: #fca5a5;
}

.btn-sculpt-trigger {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.18s ease;
  margin-top: 8px;
}

.btn-sculpt-trigger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.btn-sculpt-trigger.active {
  background: #ea580c;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
}

@media (max-width: 820px) {
  .sculpt-toolbar {
    top: 8px;
    left: 50%;
    transform: translateX(-50%) translateY(-15px);
    width: calc(100% - 16px);
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 7px 10px;
    gap: 7px;
    box-sizing: border-box;
  }

  .sculpt-toolbar.show {
    transform: translateX(-50%) translateY(0);
  }

  .sculpt-toolbar-header {
    display: none;
  }

  .sculpt-main-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 4px;
  }

  .sculpt-brushes-group {
    display: flex;
    gap: 3px;
    align-items: center;
  }

  .btn-sculpt-brush {
    width: 32px;
    height: 30px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .btn-sculpt-brush span {
    display: none;
  }

  .btn-sculpt-brush svg {
    width: 15px;
    height: 15px;
  }

  .sculpt-actions-group {
    display: flex;
    gap: 5px;
    align-items: center;
  }

  .btn-sculpt-reset {
    height: 30px;
    padding: 0 8px;
    font-size: 11px;
    gap: 3px;
  }

  .btn-exit-sculpt {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
    gap: 4px;
  }

  .sculpt-sliders-group {
    display: flex;
    width: 100%;
    gap: 12px;
    border: none;
    border-top: 1px solid var(--border-color);
    padding: 4px 2px 0 2px;
    margin: 0;
  }

  .sculpt-slider-item {
    flex: 1;
    min-width: 0;
    gap: 1px;
  }

  .sculpt-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
  }

  .slider-badge {
    font-size: 10px;
  }

  .sculpt-range {
    height: 6px;
    margin: 1px 0;
  }

  /* إزاحة كرة التوجيه والزر العائم للأسفل تلقائياً لتفادي أي تداخل أثناء النحت على الهاتف */
  body.sculpt-mode .camera-controls-stack,
  body.sculpt-mode .camera-quick-tools {
    top: 98px !important;
    transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@media (max-width: 400px) {
  .btn-sculpt-reset span {
    display: none;
  }
  .btn-sculpt-reset {
    width: 30px;
    padding: 0;
    justify-content: center;
  }
  .btn-exit-sculpt {
    padding: 0 8px;
    font-size: 10px;
  }
}

/* ==================== 10. أداة متر القياس الافتراضي (3D Tape Measure) ==================== */

.measure-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-15px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 10px;
  height: 40px;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  z-index: 60;
  max-width: 95vw;
  box-sizing: border-box;
}

.measure-toolbar.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.measure-header-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

.measure-count-badge {
  background: var(--primary);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.4;
}

.measure-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  flex-shrink: 1;
}

.measure-values {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  box-sizing: border-box;
}

.measure-total-val {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 15px;
  font-weight: 800;
  color: #1d4ed8;
  line-height: 28px;
}

.measure-unit {
  font-size: 11px;
  font-weight: 700;
  color: #3b82f6;
  line-height: 28px;
}

.measure-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
}

.btn-measure-action {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-100);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-measure-action:hover {
  background: var(--surface-200);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-measure-action.btn-measure-clear:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.btn-measure-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-100);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-measure-close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}
  color: #dc2626;
}

/* بادج مؤشر زاوية ونسبة الدوران التفاعلي العائم ثلاثي الأبعاد */
.rotation-live-badge {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -14px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 10px 30px -4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 8px 12px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 60;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  animation: popInRotBadge 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  min-width: 130px;
}

@keyframes popInRotBadge {
  from {
    opacity: 0;
    transform: translate(-50%, -85%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
}

.rot-badge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.rot-badge-axis-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 4px;
  color: #ffffff;
  background: #3b82f6;
  line-height: 1.4;
}

.rot-badge-axis-tag.axis-x { background: #ef4444; }
.rot-badge-axis-tag.axis-y { background: #10b981; }
.rot-badge-axis-tag.axis-z { background: #2563eb; }

.rot-badge-step-hint {
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: -0.2px;
}

.rot-badge-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 1px 0;
}

.rot-badge-deg {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  letter-spacing: -0.5px;
  line-height: 1;
}

.rot-badge-delta {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  font-family: monospace;
}

.rot-badge-coords {
  display: flex;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 3px;
  margin-top: 1px;
  width: 100%;
  justify-content: center;
}

.rot-coord-item {
  font-size: 9.5px;
  font-weight: 600;
  color: #94a3b8;
  font-family: monospace;
}

.rot-coord-item.active {
  color: #ffffff;
  font-weight: 800;
}

/* حاوية بادجات القياس العائمة لجميع الأجهزة والخطوط */
.measure-badges-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 55;
  overflow: hidden;
  direction: ltr !important; /* فرض الاتجاه من اليسار لليمين لضمان دقة الإحداثيات على الكانفاس */
}

/* بادج المسافة المباشر أثناء المعاينة */
.measure-live-badge {
  position: absolute;
  top: 0;
  left: 0;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.90);
  color: #38bdf8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid #38bdf8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), 0 0 10px rgba(56, 189, 248, 0.35);
  pointer-events: none;
  display: none;
  white-space: nowrap;
  user-select: none;
  z-index: 56;
}

/* بادج المسافة النهائي لكل جهاز قياس مسجل */
.measure-item-badge {
  position: absolute;
  top: 0;
  left: 0;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 8px 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(15, 23, 42, 0.08);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
  direction: rtl;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  z-index: 55;
  cursor: pointer;
}

.measure-item-badge:hover {
  border-color: #3b82f6;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.22);
  transform: translate(-50%, -50%) scale(1.06);
}

.m-badge-text {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
}

.m-badge-num {
  font-weight: 800;
  color: #1d4ed8;
}

.m-badge-unit {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
}

.m-badge-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.m-badge-del:hover {
  background: #ef4444;
  color: #ffffff;
}

#canvas-container.measuring {
  cursor: crosshair !important;
}

@media (max-width: 820px) {
  .measure-toolbar {
    top: 8px;
    width: calc(100% - 16px);
    justify-content: space-between;
    padding: 0 8px;
    gap: 6px;
    height: 38px;
  }
  .measure-status,
  .measure-deltas-divider,
  .measure-deltas-row,
  .btn-toggle-deltas {
    display: none !important;
  }
}

/* ==================== 11. بادجات الأبعاد الرقمية التفاعلية ==================== */

.handles-dim-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  padding: 2px 7px;
  cursor: pointer;
  z-index: 52;
  user-select: none;
  white-space: nowrap;
  pointer-events: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.handles-dim-badge span,
.handles-dim-badge input {
  pointer-events: auto;
}

.handles-dim-badge.is-dragging span {
  pointer-events: none;
}

.handles-dim-badge:hover {
  border-color: #2563eb;
  color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.handles-dim-badge input {
  width: 52px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  color: #2563eb;
  background: transparent;
  text-align: center;
  padding: 0;
  margin: 0;
}

/* بادج مؤشر زاوية التدوير ثلاثي الأبعاد */
.handles-rot-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.94);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 55;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.5px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ==================== 12. زر النماذج والأشكال العائم على الحافة (Edge Drawer Toggle) ==================== */

.edge-drawer-toggle {
  position: absolute;
  top: 50%;
  right: var(--sidebar-w);
  transform: translateY(-50%);
  width: 42px;
  min-height: 84px;
  padding: 8px 3px;
  background: var(--surface-0);
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  z-index: 95;
  color: var(--text-primary);
  transition: right 0.22s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  outline: none;
}

.edge-drawer-toggle:hover {
  background: var(--surface-50);
  border-color: #cbd5e1;
  box-shadow: -6px 0 22px rgba(0, 0, 0, 0.14);
}

.edge-drawer-toggle .edge-icon-expand {
  display: none;
  color: var(--primary);
}

.edge-drawer-toggle .edge-icon-collapse {
  display: block;
  color: var(--text-secondary);
}

.edge-drawer-toggle .edge-toggle-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  line-height: 1;
}

/* عندما تكون القائمة مغلقة/منطوية (Collapsed) */
.edge-drawer-toggle:not(.is-expanded) {
  right: 0 !important;
  background: var(--surface-0);
  box-shadow: -4px 0 18px rgba(37, 99, 235, 0.18);
  border-color: #bfdbfe;
}

.edge-drawer-toggle:not(.is-expanded):hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.edge-drawer-toggle:not(.is-expanded) .edge-icon-expand {
  display: block;
}

.edge-drawer-toggle:not(.is-expanded) .edge-icon-collapse {
  display: none;
}

.edge-drawer-toggle:not(.is-expanded) .edge-toggle-text {
  color: var(--primary);
}

@media (max-width: 1080px) {
  .edge-drawer-toggle {
    right: 290px;
  }
}

/* ==================== 13. شريط إضافة الأشكال السريع (Quick Shapes Dock) ==================== */

.quick-shapes-dock {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  padding: 4px 8px;
  display: none;
  align-items: center;
  gap: 4px;
  z-index: 40;
  transition: all 0.2s ease;
}

.quick-shapes-dock.show {
  display: flex;
}

.quick-shape-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.quick-shape-btn:hover {
  background: var(--surface-100);
  color: var(--primary);
  transform: translateY(-1px);
}

.quick-shape-btn.quick-shape-clay {
  color: var(--primary);
}

.quick-shape-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 2px;
}

.quick-shape-more {
  color: var(--text-secondary);
}

@media (max-width: 680px) {
  .quick-shape-btn span {
    display: none;
  }
  .quick-shape-btn {
    padding: 6px;
  }
}

/* ==================== 14. شريط التحكم السياقي بالعنصر المحدد (Contextual Selection Bar) ==================== */

.contextual-selection-bar {
  position: absolute;
  bottom: calc(var(--bottombar-height, 30px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 50;
  animation: ctxBarEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  max-width: calc(100vw - 24px);
  overflow: visible !important;
  box-sizing: border-box;
}

@keyframes ctxBarEnter {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.ctx-item {
  position: relative;
  display: flex;
  align-items: center;
}

.ctx-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.ctx-btn:hover {
  background: var(--surface-100);
  color: var(--primary);
}

.ctx-btn-danger:hover {
  background: #fee2e2;
  color: var(--accent-red);
}

.ctx-btn-ghost {
  padding: 6px;
  color: var(--text-secondary);
}

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

/* معاينة اللون ولوحة الباليتة السريعة */
.ctx-color-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  display: inline-block;
  flex-shrink: 0;
}

.ctx-color-palette {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 50%;
  transform: translateX(50%);
  background: var(--surface-0);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  padding: 10px;
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  z-index: 60;
  animation: ctxPaletteIn 0.15s ease;
}

@keyframes ctxPaletteIn {
  from {
    opacity: 0;
    transform: translateX(50%) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(50%) translateY(0);
  }
}

.ctx-color-palette.open {
  display: grid;
}

.ctx-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ctx-swatch:hover {
  transform: scale(1.22);
  box-shadow: 0 0 0 2px var(--primary);
}

/* قائمة الخامات السريعة */
.ctx-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--surface-0);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  padding: 6px;
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  min-width: 190px;
  z-index: 60;
  animation: ctxPaletteIn 0.15s ease;
}

.ctx-dropdown-menu.open {
  display: grid;
}

.ctx-menu-item {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.ctx-menu-item:hover {
  background: var(--surface-100);
  color: var(--primary);
}

/* ==================== عمليات الدمج والنحت الهندسية (Boolean Operations) ==================== */
.ctx-boolean-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ctx-dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

/* زر الدمج وزر النحت كأزرار إجراء قياسية غير مفعلة مسبقاً */
#ctx-btn-merge {
  border: 1px solid transparent;
  background: transparent !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
  font-weight: 700 !important;
}

#ctx-btn-merge:hover {
  background: var(--surface-100) !important;
  color: var(--primary) !important;
}

.ctx-btn-accent {
  background: transparent !important;
  color: var(--text-primary) !important;
  border-color: transparent !important;
  font-weight: 700 !important;
}

.ctx-btn-accent:hover {
  background: var(--surface-100) !important;
  color: var(--primary) !important;
}

.ctx-btn-highlight {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}

/* تمييز زر التحديد المتعدد في الشريط السياقي عند التفعيل */
.ctx-btn.active,
#ctx-btn-multi-toggle.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.45) !important;
  font-weight: 800 !important;
}

.ctx-btn.active svg,
#ctx-btn-multi-toggle.active svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.ctx-btn.active:hover,
#ctx-btn-multi-toggle.active:hover {
  background: #1d4ed8 !important;
  color: #ffffff !important;
}

#ctx-btn-multi-toggle.active::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #93c5fd;
  border-radius: 50%;
  box-shadow: 0 0 6px #60a5fa;
  margin-inline-start: 4px;
}

.badge-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-block;
}

.badge-pill-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-pill-muted {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.boolean-action-buttons {
  margin-top: 4px;
}

.boolean-action-buttons .btn-ctrl {
  height: 32px;
  font-size: 11px;
}

/* ==================== نمط التحديد المتعدد للهاتف واللمس (Mobile Multi-Select) ==================== */
.cam-multi-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 6px 4px;
  background: var(--surface-50);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  gap: 3px;
  transition: all 0.16s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-top: 6px;
}

.cam-multi-select-btn:hover {
  background: var(--surface-100);
  border-color: var(--border-color);
  color: var(--primary);
}

.cam-multi-select-btn.active {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35) !important;
  font-weight: 800;
}

.cam-multi-select-btn.active svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.cam-multi-select-label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

/* شريط إشعار نمط التحديد المتعدد العائم */
.multi-select-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 55;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  animation: ctxPaletteIn 0.2s ease;
  direction: rtl;
  max-width: 90vw;
}

.multi-select-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.multi-select-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.multi-select-count-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
}

.btn-done-multi {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-done-multi:hover {
  background: #1d4ed8;
}

/* ==================== بادجات ترتيب المجسمات المحددة في المشهد 3D ==================== */
.selection-order-badges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  direction: ltr !important;
  z-index: 28;
  overflow: hidden;
}

.selection-order-badge {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
}

.badge-index-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

.badge-obj-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.badge-obj-title {
  font-size: 11px;
  font-weight: 700;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-role-tag {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.2px;
}

.selection-order-badge.role-target {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.65) !important;
}

.selection-order-badge .target-tag {
  background: #06b6d4;
  color: #083344;
}

.selection-order-badge.role-tool {
  border-color: #ef4444 !important;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.65) !important;
}

.selection-order-badge .tool-tag {
  background: #ef4444;
  color: #ffffff;
}

.selection-order-badge.role-intersect {
  border-color: #8b5cf6 !important;
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.65) !important;
}

.selection-order-badge .intersect-tag {
  background: #8b5cf6;
  color: #ffffff;
}

/* ==================== قائمة خيارات النحت الهندسية المحسنة (Carve Menu UX) ==================== */
#ctx-carve-menu {
  min-width: 280px !important;
  display: none;
  flex-direction: column !important;
  gap: 6px !important;
  padding: 8px !important;
  grid-template-columns: none !important;
}

#ctx-carve-menu.open {
  display: flex !important;
}

#ctx-carve-menu .ctx-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-0);
  border-radius: var(--radius-sm);
  text-align: right;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

#ctx-carve-menu .ctx-menu-item:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.carve-menu-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

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

.carve-card-sub {
  opacity: 0.9;
}

.carve-action-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary);
}

.carve-tool-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.carve-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-100);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 10.5px;
  font-weight: 700;
  max-width: 180px;
}

.carve-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.carve-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carve-chip-role {
  font-size: 9px;
  font-weight: 800;
  color: #0284c7;
}

.carve-chip-role.carve-role-cutter {
  color: #dc2626;
}

.carve-dot-inline {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 3px;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.insp-carve-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== شجرة عناصر المشهد المحسنة (Outliner UX) ==================== */
.outliner-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.outliner-header-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-outliner-pill {
  background: var(--surface-100);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
}

.btn-outliner-pill:hover {
  background: var(--surface-200);
  color: var(--text-primary);
}

.btn-outliner-pill.active {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
  font-weight: 800;
}

.outliner-item-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.outliner-checkbox {
  width: 14px;
  height: 14px;
  accent-color: #2563eb;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.outliner-color-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.outliner-order-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ==================== تجاوب الشريط السفلي وسياق التحكم على أجهزة التابلت والمحمول ==================== */

.status-tip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 1040px) {
  .contextual-selection-bar {
    bottom: calc(var(--bottombar-height, 30px) + 10px);
    padding: 4px 8px;
    gap: 3px;
    max-width: calc(100vw - 20px);
  }
  .ctx-btn {
    padding: 5px 8px;
    font-size: 10.5px;
    gap: 4px;
  }
  /* إخفاء نصوص الأزرار المفهومة من أيقوناتها لتوفير مساحة رحبة على شاشات التابلت */
  #ctx-btn-snap span.ctx-label,
  #ctx-btn-duplicate span.ctx-label,
  #ctx-btn-sculpt span.ctx-label {
    display: none;
  }
  .bottom-status-bar {
    padding: 0 10px;
    font-size: 10.5px;
  }
  .status-tip-text {
    max-width: 55vw;
  }
}

@media (max-width: 850px) {
  .contextual-selection-bar {
    bottom: calc(var(--bottombar-height, 30px) + 8px);
    padding: 3px 6px;
    gap: 2px;
    max-width: calc(100vw - 16px);
  }
  .ctx-btn {
    padding: 5px 6px;
    font-size: 10px;
  }
  /* إخفاء نصوص الأزرار الثانوية على التابلت الرأسي */
  .ctx-btn span.ctx-label {
    display: none;
  }
  /* إبقاء نص الأزرار الأساسية فقط */
  #ctx-btn-merge span.ctx-label,
  #ctx-btn-carve-toggle span.ctx-label,
  #ctx-finish-label {
    display: inline-block;
    font-size: 10px;
  }
  .ctx-divider {
    height: 14px;
    margin: 0 1px;
  }
  .status-left {
    gap: 8px;
    font-size: 9.5px;
  }
  .status-tip-text {
    max-width: 45vw;
  }
}

@media (max-width: 600px) {
  .contextual-selection-bar {
    bottom: 12px;
    padding: 3px 6px;
    gap: 2px;
    max-width: calc(100vw - 12px);
  }
  .ctx-btn span.ctx-label {
    display: none !important;
  }
  .ctx-btn {
    padding: 6px;
  }
}


/* ==================== 15. استوديو المحاكاة الفيزيائية والعرض التفاعلي (Simulator Studio) ==================== */

/* إخفاء كافة عناصر وأدوات التحرير أثناء وضع المحاكاة */
body.simulator-studio-mode .top-navbar,
body.simulator-studio-mode .sidebar-left,
body.simulator-studio-mode .sidebar-right,
body.simulator-studio-mode .bottom-status-bar,
body.simulator-studio-mode .bottom-bar,
body.simulator-studio-mode .edge-drawer-toggle,
body.simulator-studio-mode #btn-edge-shapes-toggle,
body.simulator-studio-mode .drawer-backdrop,
body.simulator-studio-mode .transform-modes-panel,
body.simulator-studio-mode .contextual-selection-bar,
body.simulator-studio-mode .quick-shapes-dock,
body.simulator-studio-mode .measure-badges-container,
body.simulator-studio-mode .floating-measure-card,
body.simulator-studio-mode .rotation-live-badge,
body.simulator-studio-mode .selection-order-badges,
body.simulator-studio-mode .cam-multi-select-btn,
body.simulator-studio-mode #btn-floating-multi-select,
body.simulator-studio-mode #multi-select-banner {
  display: none !important;
}

/* إزاحة عمود كرة الكاميرا لأسفل الشريط العلوي للمحاكي لمنع أي تداخل بصري */
body.simulator-studio-mode .camera-controls-stack {
  top: 80px !important;
  left: 14px !important;
  transition: top 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* موضع رسائل الإشعار في وضع المحاكي: تظهر في الأعلى أسفل الترويسة لمنع حجب أزرار الشريط السفلي */
body.simulator-studio-mode .toast-box {
  top: 68px !important;
  bottom: auto !important;
  z-index: 9999 !important;
  pointer-events: none !important;
}

@media (max-width: 760px) {
  body.simulator-studio-mode .toast-box {
    top: 108px !important;
  }
}

body.simulator-studio-mode #canvas-container {
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 10;
}

.simulator-studio-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 20px;
  box-sizing: border-box;
  animation: simFadeIn 0.25s ease;
}

@keyframes simFadeIn {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

/* الشريط العلوي للاستوديو */
.sim-header {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  user-select: none;
  align-self: center;
  width: auto;
  max-width: calc(100vw - 32px);
}

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

.sim-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sim-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.sim-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

/* تبويبات الأنماط */
.sim-mode-tabs {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 999px;
  gap: 4px;
}

.sim-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.sim-tab-btn:hover {
  color: var(--primary);
}

.sim-tab-btn.active {
  background: #2563eb;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.sim-tab-btn.active svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

/* أزرار الرأس الإضافية */
.sim-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-header-tool-btn {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.sim-header-tool-btn:hover {
  background: var(--surface-100);
  border-color: var(--border-color);
  color: var(--primary);
}

.sim-header-tool-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* زر العودة للتصميم */
.sim-btn-exit {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.sim-btn-exit:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* نافذة تخصيص بيئة ومظهر المحاكي المنبثقة */
.sim-env-popover {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: 330px;
  max-width: calc(100vw - 32px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 16px 45px -8px rgba(0, 0, 0, 0.22);
  padding: 16px;
  box-sizing: border-box;
  pointer-events: auto;
  z-index: 150;
  animation: simEnvFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes simEnvFadeIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.sim-env-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.sim-env-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
}

.sim-env-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sim-env-close:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

.sim-env-section {
  margin-bottom: 12px;
}

.sim-env-section:last-child {
  margin-bottom: 0;
}

.sim-env-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

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

.sim-env-card {
  border: 1.5px solid var(--border-color);
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.sim-env-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.sim-env-card.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.sim-env-swatch {
  width: 26px;
  height: 16px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.sim-env-name {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.sim-env-colors-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sim-color-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.sim-color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 6px;
}

.sim-color-input-wrapper input[type="color"] {
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.sim-color-input-wrapper span {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
}

.sim-env-toggles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

.sim-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.sim-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* شريط التحكم السفلي العائم */
.sim-control-dock {
  pointer-events: auto;
  align-self: center;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  user-select: none;
  animation: simDockIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes simDockIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sim-controls-pane {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sim-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sim-divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 2px;
}

.sim-action-btn {
  border: 1px solid var(--border-color);
  background: var(--surface-50);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.14s ease;
}

.sim-action-btn:hover {
  background: var(--surface-100);
  border-color: var(--primary);
  color: var(--primary);
}

.sim-action-btn.sim-btn-play {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.sim-action-btn.sim-btn-play:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.sim-action-btn.sim-btn-active {
  background: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.sim-action-btn.sim-btn-active svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.sim-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sim-slider-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-preset-chips {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-chip {
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.sim-chip:hover {
  background: #eff6ff;
  color: var(--primary);
}

.sim-chip.active {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.sim-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.sim-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 4px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
}

.sim-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.sim-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.sim-step-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.sim-step-count {
  font-size: 10.5px;
  font-weight: 800;
  color: #1d4ed8;
}

.sim-step-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sim-label-sub {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* تنسيقات ارتفاع السقوط الحر */
.sim-drop-height-group {
  min-width: 175px;
}

.sim-chips-mini {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.sim-chips-mini .sim-chip {
  padding: 2px 7px;
  font-size: 9.5px;
}

/* زر قوالب ومؤثرات العرض */
.sim-btn-templates {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-color: #c4b5fd;
  color: #5b21b6;
  font-weight: 800;
}

.sim-btn-templates:hover {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-color: #a78bfa;
  color: #4c1d95;
}

/* نافذة قوالب ومؤثرات التفكيك والتركيب الكبرى */
.sim-templates-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  pointer-events: auto;
  animation: simModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes simModalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.sim-templates-dialog {
  background: #ffffff;
  border-radius: 20px;
  width: 820px;
  max-width: 95vw;
  max-height: 88vh;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(226, 232, 240, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.sim-dialog-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.sim-dialog-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sim-dialog-title svg {
  width: 26px;
  height: 26px;
  color: #6366f1;
}

.sim-dialog-title h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-primary);
}

.sim-dialog-title p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.sim-dialog-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sim-dialog-close:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.sim-dialog-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sim-section-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  color: #4338ca;
  background: #e0e7ff;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.sim-templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sim-template-card {
  position: relative;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sim-template-card:hover {
  border-color: #818cf8;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.12);
}

.sim-template-card.active {
  border-color: #6366f1;
  background: #f5f3ff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.sim-card-badge {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9px;
  font-weight: 800;
  background: #6366f1;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 999px;
}

.sim-template-card.active .sim-card-badge {
  display: block;
}

.sim-template-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #ede9fe;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.sim-template-icon svg {
  width: 22px;
  height: 22px;
}

.sim-template-card.active .sim-template-icon {
  background: #6366f1;
  color: #ffffff;
}

.sim-template-card h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
}

.sim-template-card p {
  margin: 0;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  font-weight: 600;
}

/* خيارات التعديل والضبط الدقيق للمؤثرات */
.sim-fine-tuning-section {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.sim-tuning-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.sim-tuning-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sim-tuning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.sim-tuning-header b {
  color: #2563eb;
  font-weight: 800;
}

.sim-tuning-hint {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.sim-switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.sim-switch-label input[type="checkbox"] {
  display: none;
}

.sim-switch-slider {
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sim-switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sim-switch-label input[type="checkbox"]:checked + .sim-switch-slider {
  background: #2563eb;
}

.sim-switch-label input[type="checkbox"]:checked + .sim-switch-slider::after {
  transform: translateX(-16px);
}

.sim-switch-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.sim-dialog-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
}

.sim-dialog-btn-apply {
  background: #2563eb;
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.15s ease;
}

.sim-dialog-btn-apply:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* ==========================================================================
   تجاوب ذكي شامل لاستوديو المحاكاة (يعمل بمرونة وانسيابية على كافة مقاسات الشاشات)
   ========================================================================== */

/* الشريط السفلي العائم (يتكيف بمرونة مع أي عرض شاشة) */
.sim-control-dock {
  width: fit-content;
  max-width: calc(100vw - 16px);
  max-height: 48vh;
  overflow-x: hidden !important;
  overflow-y: auto;
  border-radius: clamp(16px, 3vw, 28px);
  padding: clamp(6px, 1.2vw, 10px) clamp(8px, 2vw, 18px);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.sim-control-dock::-webkit-scrollbar {
  width: 4px;
}

.sim-control-dock::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.sim-control-dock::-webkit-scrollbar-track {
  background: transparent;
}

/* حاوية عناصر التحكم تلتف بانسيابية وذكاء */
.sim-controls-pane {
  display: flex;
  flex-wrap: wrap;
  white-space: normal;
  justify-content: center;
  align-items: center;
  row-gap: 8px;
  column-gap: clamp(6px, 1vw, 10px);
  max-width: 100%;
}

.sim-controls-pane[style*="display: none"] {
  display: none !important;
}

.sim-group,
.sim-preset-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* مجموعات المنزلقات تُعرض كبطاقات مدمجة متجاورة تتوزع تلقائياً حسب العرض */
.sim-controls-pane .sim-slider-group {
  display: flex;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  flex: 1 1 170px;
  width: auto !important;
  min-width: min(100%, 150px) !important;
  max-width: 260px;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(241, 245, 249, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-sizing: border-box;
}

.sim-controls-pane .sim-slider-group .sim-range {
  width: 100%;
}

.sim-controls-pane .sim-slider-group .sim-preset-chips,
.sim-controls-pane .sim-slider-group .sim-chips-mini {
  justify-content: flex-start;
  margin-top: 0;
}

.sim-controls-pane .sim-slider-label {
  flex-wrap: wrap;
}

.sim-controls-pane .sim-drop-height-group {
  min-width: min(100%, 170px) !important;
}

@media (min-width: 1101px) {
  .sim-controls-pane .sim-slider-group {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    padding: 0;
  }
}

/* أزرار الإجراءات في المحاكي */
.sim-action-btn {
  font-size: clamp(10px, 1.1vw + 6px, 12px);
  padding: clamp(5px, 0.8vw, 7px) clamp(8px, 1.2vw, 12px);
  white-space: nowrap;
}

/* الشريط العلوي يتجاوب دون تداخل */
.sim-header {
  display: flex;
  flex-wrap: wrap;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  row-gap: 6px;
}

.sim-mode-tabs {
  flex-wrap: nowrap;
}

.sim-tab-btn,
.sim-tab-btn span {
  white-space: nowrap;
}

/* الشاشات المتوسطة واللوحية */
@media (max-width: 1100px) {
  .sim-controls-pane .sim-divider {
    display: none;
  }
  .sim-sub {
    display: none;
  }
  .sim-templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* شاشات الهاتف والأجهزة الضيقة */
@media (max-width: 760px) {
  .simulator-studio-overlay {
    padding: 8px 6px;
  }
  .sim-header {
    flex-wrap: wrap;
    border-radius: 20px;
    padding: 6px 8px;
    gap: 6px;
    justify-content: space-between;
  }
  .sim-header-brand .sim-title,
  .sim-header-brand .sim-sub {
    display: none;
  }
  .sim-mode-tabs {
    order: 3;
    flex: 1 1 100%;
    display: flex;
    gap: 4px;
  }
  .sim-tab-btn {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
    padding: 6px 8px;
  }
  .sim-tab-btn span {
    white-space: nowrap;
    font-size: 11px;
  }
  .sim-header-actions {
    margin-inline-start: auto;
  }
  .sim-header-tool-btn span,
  .sim-btn-exit span {
    display: none;
  }
  body.simulator-studio-mode .camera-controls-stack {
    top: 112px !important;
  }
  .sim-control-dock {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
    padding: 8px 10px;
  }
  .sim-templates-grid {
    grid-template-columns: 1fr;
  }
}

/* الشاشات الصغيرة جداً */
@media (max-width: 420px) {
  .sim-chip {
    padding: 3px 7px;
    font-size: 10px;
  }
  .sim-control-dock {
    max-height: 44vh;
  }
}

/* الشاشات الأفقية القصيرة (الهاتف بالعرض) */
@media (max-height: 500px) {
  .sim-control-dock {
    max-height: 40vh;
  }
  .sim-header {
    padding-block: 4px;
  }
}

/* ===== قائمة خطوات التركيب التعليمي ===== */
.sim-steps-list {
  flex: 1 1 100%;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 2px;
  scrollbar-width: thin;
}
.sim-step-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.sim-step-item:hover { border-color: var(--primary); color: var(--primary); }
.sim-step-item.done { background: #dcfce7; border-color: #86efac; color: #166534; }
.sim-step-item.current { background: #2563eb; border-color: #2563eb; color: #fff; box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.sim-step-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(15,23,42,.1);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.sim-step-item.current .sim-step-num { background: rgba(255,255,255,.25); }
.sim-step-nm { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-step-move {
  border: 0; background: transparent; color: inherit; opacity: .55;
  font-size: 9px; padding: 2px 3px; cursor: pointer; line-height: 1;
}
.sim-step-move:hover { opacity: 1; }

/* ===== وضع شاشة العرض الكاملة / تسجيل الشاشة (إخفاء كافة عناصر التحكم تماماً) ===== */
body.sim-clean-view-mode .sim-header,
body.sim-clean-view-mode .sim-control-dock,
body.sim-clean-view-mode .camera-controls-stack,
body.sim-clean-view-mode .sim-env-popover,
body.sim-clean-view-mode .sim-templates-modal-backdrop {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transition: opacity 0.28s ease, visibility 0.28s ease !important;
}

/* زر عائم لطيف يظهر عند الرغبة بالخروج من وضع الشاشة الكاملة */
.sim-clean-exit-floating {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.18;
  transition: opacity 0.24s ease, transform 0.18s ease, background 0.18s ease;
}

.sim-clean-exit-floating:hover {
  opacity: 1 !important;
  background: #0f172a !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

body.sim-clean-view-mode .sim-clean-exit-floating {
  display: inline-flex !important;
}

/* تنسيق زر شاشة العرض الكاملة في الشريط السفلي */
.sim-action-btn.sim-btn-fullscreen-view {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
  font-weight: 700;
}

.sim-action-btn.sim-btn-fullscreen-view svg {
  color: #2563eb;
}

.sim-action-btn.sim-btn-fullscreen-view:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.sim-action-btn.sim-btn-fullscreen-view:hover svg {
  color: #ffffff !important;
}

.sim-action-btn.sim-btn-fullscreen-view.active {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
}

.sim-action-btn.sim-btn-fullscreen-view.active svg {
  color: #ffffff !important;
}

/* ==================== القائمة الجانبية لقوالب ومؤثرات العرض ==================== */

/* زر الحافة اليمنى لفتح/إغلاق قوالب ومؤثرات العرض */
.sim-edge-templates-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 42px;
  min-height: 100px;
  padding: 10px 3px;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border: 1px solid #c4b5fd;
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: -4px 0 16px rgba(99, 102, 241, 0.18);
  display: none; /* shown via JS when in assembly mode */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  z-index: 150;
  color: #5b21b6;
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s ease;
  user-select: none;
  outline: none;
  pointer-events: auto;
}

.sim-edge-templates-toggle:hover {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-color: #a78bfa;
  box-shadow: -6px 0 22px rgba(99, 102, 241, 0.28);
}

.sim-edge-templates-toggle .edge-icon-expand {
  display: block;
  color: #6366f1;
}

.sim-edge-templates-toggle .edge-icon-collapse {
  display: none;
  color: #5b21b6;
}

.sim-edge-templates-toggle.is-expanded .edge-icon-expand {
  display: none;
}

.sim-edge-templates-toggle.is-expanded .edge-icon-collapse {
  display: block;
}

.sim-edge-templates-toggle .sim-edge-toggle-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #5b21b6;
  line-height: 1;
}

/* القائمة الجانبية لقوالب ومؤثرات العرض */
.sim-templates-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 92vw;
  background: #ffffff;
  border-left: 1px solid rgba(196, 181, 253, 0.5);
  box-shadow: -8px 0 32px rgba(99, 102, 241, 0.15);
  z-index: 140;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  overflow: hidden;
}

.sim-templates-sidebar.is-open {
  transform: translateX(0);
}

/* عند فتح القائمة الجانبية، ازح زر الحافة يساراً */
.sim-edge-templates-toggle.is-expanded {
  right: 340px;
}

@media (max-width: 400px) {
  .sim-edge-templates-toggle.is-expanded {
    right: 92vw;
  }
}

/* رأس القائمة الجانبية */
.sim-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e9d5ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  flex-shrink: 0;
}

.sim-sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sim-sidebar-title svg {
  width: 22px;
  height: 22px;
  color: #6366f1;
}

.sim-sidebar-title h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: #3730a3;
}

.sim-sidebar-title p {
  margin: 2px 0 0;
  font-size: 10px;
  color: #6d28d9;
  font-weight: 600;
}

/* جسم القائمة الجانبية */
.sim-sidebar-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* تذييل القائمة الجانبية */
.sim-sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #e9d5ff;
  background: #f5f3ff;
  flex-shrink: 0;
}

/* إغلاق زر القائمة */
.sim-sidebar-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(196, 181, 253, 0.3);
  color: #5b21b6;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sim-sidebar-close:hover {
  background: rgba(196, 181, 253, 0.6);
}

/* إخفاء في وضع العرض النقي */
body.sim-clean-view-mode .sim-templates-sidebar,
body.sim-clean-view-mode .sim-edge-templates-toggle {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* شبكة القوالب في الشاشات الصغيرة */
@media (max-width: 500px) {
  .sim-templates-sidebar .sim-templates-grid {
    grid-template-columns: 1fr 1fr;
  }
}
