/* ==========================================================================
   AI PHYSICS LAB - MODERN SCI-FI GLASSMORPHISM DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-main: #090c15;
  --bg-sub: #0f1422;
  --bg-card: rgba(16, 22, 36, 0.75);
  --bg-card-hover: rgba(24, 32, 52, 0.85);
  --bg-elevated: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.35);
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.4);
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-emerald-bright: #05df72;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --sidebar-width: 295px;
  --topbar-height: 64px;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.07) 0%, transparent 45%);
}

/* ==========================================================================
   1. TOP NAVIGATION BAR (1번: 학습/연구 중심 메인 메뉴 구성)
   ========================================================================== */
.top-navbar {
  height: var(--topbar-height);
  background: rgba(13, 18, 30, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* 브랜드 영역 */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.menu-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.menu-toggle-btn:hover {
  color: var(--primary);
  background: var(--bg-elevated);
}

.brand-logo-icon {
  font-size: 1.6rem;
  color: var(--primary);
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.brand-title-wrap h2 {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 중앙 스마트 검색창 */
.nav-search-bar {
  flex: 1;
  max-width: 420px;
  margin: 0 1.5rem;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition-normal);
}

.search-input-wrapper:hover {
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
  background: rgba(255, 255, 255, 0.08);
}

.search-input-wrapper i {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-input-wrapper span {
  font-size: 0.84rem;
  color: var(--text-muted);
  flex: 1;
}

.kbd-shortcut {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* 1번 메뉴 탭 링크 */
.nav-study-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-pill-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 15px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition-fast);
}

.nav-pill-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.35);
}

.nav-pill-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.nav-pill-btn.ai-special {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(56, 189, 248, 0.18));
  border-color: rgba(168, 85, 247, 0.4);
  color: #e2e8f0;
}

.nav-pill-btn.ai-special:hover {
  border-color: var(--accent-purple);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

/* 우측 유틸리티 */
.nav-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-circle-btn:hover {
  color: var(--primary);
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
}

/* ==========================================================================
   2. APP LAYOUT CONTAINER & SIDEBAR
   ========================================================================== */
.main-body-container {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

/* 좌측 사이드바 */
.left-sidebar {
  width: var(--sidebar-width);
  background: rgba(12, 17, 28, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal);
}

.left-sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-header {
  padding: 1.2rem 1.2rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title i {
  color: var(--primary);
}

.sidebar-filter-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-fast);
}

.sidebar-filter-btn:hover {
  color: var(--text-main);
}

.sidebar-search-box {
  padding: 0 1.2rem 1rem;
  position: relative;
}

.sidebar-search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 10px 7px 32px;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition-fast);
}

.sidebar-search-box input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-search-box i {
  position: absolute;
  left: 1.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* 아코디언 트리 스타일 */
.category-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.8rem 1.5rem;
}

.category-tree::-webkit-scrollbar {
  width: 5px;
}

.category-tree::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.category-group {
  margin-bottom: 6px;
}

.category-item.main-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: var(--transition-fast);
}

.category-item.main-cat:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
}

.category-group.open > .category-item.main-cat {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-wrap {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.math-icon {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.physics-icon {
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
}

.applied-icon {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.eng-sub {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 400;
  margin-left: 4px;
}

.item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  color: var(--text-muted);
}

.count-badge.highlight {
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  font-weight: 700;
}

.arrow-icon {
  font-size: 0.72rem;
  color: var(--text-dim);
  transition: transform var(--transition-fast);
}

.category-group.open > .category-item .arrow-icon,
.nested-group.open > .nested-item .arrow-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

/* 2단계 서브 카테고리 */
.sub-category-list {
  display: none;
  padding: 4px 0 4px 14px;
  margin-left: 12px;
  border-left: 1px dashed rgba(255, 255, 255, 0.12);
}

.category-group.open > .sub-category-list {
  display: block;
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.83rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

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

/* 2단계 중첩 그룹 (물리 하위: 역학, 열역학, 현대물리 등) */
.nested-group {
  margin: 3px 0;
}

.nested-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #cbd5e1;
  font-size: 0.84rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nested-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.branch-icon {
  font-size: 0.78rem;
  color: var(--primary);
  width: 16px;
}

.nested-group.open > .nested-item {
  color: var(--primary);
  font-weight: 600;
}

.leaf-list {
  display: none;
  padding: 2px 0 2px 12px;
  margin-left: 10px;
  border-left: 1px solid rgba(56, 189, 248, 0.2);
}

.nested-group.open > .leaf-list {
  display: block;
}

.leaf-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.leaf-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.leaf-item.active-sim {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  font-weight: 600;
  border-left: 2px solid var(--primary);
}

.leaf-play-icon {
  font-size: 0.68rem;
  color: var(--primary);
}

/* 3단계 중첩 (현대물리 -> 특수상대성이론, 일반상대성이론) */
.deep-nested-group {
  margin: 4px 0;
}

.deep-nested-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #93c5fd;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.05);
}

.deep-nested-item:hover {
  background: rgba(56, 189, 248, 0.12);
}

.deep-arrow {
  font-size: 0.7rem;
  transition: transform var(--transition-fast);
}

.deep-nested-group.open > .deep-nested-item .deep-arrow {
  transform: rotate(90deg);
  color: var(--primary);
}

.deep-leaf-list {
  display: none;
  padding: 2px 0 2px 10px;
  margin-left: 8px;
  border-left: 1px solid rgba(168, 85, 247, 0.3);
}

.deep-nested-group.open > .deep-leaf-list {
  display: block;
}

.sidebar-footer {
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 13, 20, 0.5);
}

.engine-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.quantum-spin {
  animation: spin 12s linear infinite;
}

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

/* ==========================================================================
   ★ 3. SIMULATION CONTROL DECK BANNER (사용자가 요청한 2번 조작바 위치) ★
   ========================================================================== */
.simulation-control-deck-banner {
  background: rgba(16, 22, 38, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 7px 16px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.deck-left-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 재생 / 일시정지 버튼 (에메랄드 그린 알약형) */
.deck-play-btn {
  background: var(--accent-emerald-bright);
  color: #000000;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  border: none;
  padding: 6px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition-fast);
  box-shadow: 0 0 16px rgba(5, 223, 114, 0.4);
}

.deck-play-btn:hover {
  background: #22c55e;
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(5, 223, 114, 0.6);
}

.deck-play-btn.paused {
  background: #f59e0b;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

/* 리셋 버튼 */
.deck-reset-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.deck-reset-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* 뷰 모드 및 단위계 선택기 */
.deck-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.deck-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.deck-select-wrap select {
  background: #151c2e;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.deck-select-wrap select:hover,
.deck-select-wrap select:focus {
  border-color: var(--primary);
  background: #1b243b;
}

/* 우측 툴 (배속, GPU, 전체화면) */
.deck-right-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deck-speed-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.deck-speed-badge select {
  background: #151c2e;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 0.78rem;
  cursor: pointer;
}

.gpu-badge {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.deck-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition-fast);
}

.deck-icon-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   4. MAIN WORKSPACE CONTENT
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* 시뮬레이션 헤더 카드 */
.simulation-header-card {
  margin-bottom: 1.5rem;
}

.sim-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 10px;
}

.path-badge {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.meta-tags {
  display: flex;
  gap: 8px;
}

.tag-pill {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-weight: 600;
  border: 1px solid transparent;
}

.tag-interactive {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

.tag-gpu {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.tag-ai {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.3);
}

.sim-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.sim-description {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 900px;
}

/* 스테이지 그리드 (캔버스 + 파라미터 패널) */
.simulation-stage-grid {
  display: grid;
  grid-template-columns: 1fr 370px;
  gap: 1.5rem;
}

@media (max-width: 1200px) {
  .simulation-stage-grid {
    grid-template-columns: 1fr;
  }
}

/* 캔버스 패널 */
.canvas-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-glass);
}

.canvas-toolbar {
  padding: 10px 16px;
  background: rgba(10, 13, 22, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.canvas-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-controls {
  display: flex;
  gap: 6px;
}

.view-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.view-btn:hover, .view-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  border-color: var(--primary);
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 450px;
  background: #05070f;
}

#simCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* HUD 오버레이 */
.hud-overlay {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.hud-item {
  background: rgba(10, 15, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 210px;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hud-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.hud-val.highlight {
  color: var(--accent-amber);
}

.hud-val.cyan {
  color: var(--primary);
}

.hud-val.green {
  color: var(--accent-emerald);
}

/* 캔버스 하단 상태 바 */
.canvas-bottom-bar {
  padding: 10px 16px;
  background: rgba(10, 13, 22, 0.7);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.text-emerald {
  color: var(--accent-emerald);
}

.fps-counter {
  font-size: 0.78rem;
  color: var(--accent-emerald);
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 우측 제어 패널 */
.control-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-glass);
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 13, 22, 0.6);
}

.panel-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
}

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

.panel-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(56, 189, 248, 0.05);
}

.panel-tab-content {
  display: none;
  padding: 1.2rem;
  flex: 1;
  overflow-y: auto;
}

.panel-tab-content.active {
  display: block;
}

/* 슬라이더 그룹 */
.slider-group {
  margin-bottom: 1.2rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.slider-header label {
  color: #cbd5e1;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-val {
  font-family: 'JetBrains Mono', monospace;
  color: var(--primary);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.preset-box {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-subtle);
}

.preset-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
  color: #fff;
}

/* AI 튜터 탭 */
.ai-chat-box {
  height: 280px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 10px;
}

.ai-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.ai-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.user-msg {
  justify-content: flex-end;
}

.user-bubble {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  color: #fff;
  max-width: 80%;
}

.ai-input-wrapper {
  display: flex;
  gap: 6px;
}

.ai-input-wrapper input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: #fff;
  font-size: 0.82rem;
  outline: none;
}

.ai-input-wrapper input:focus {
  border-color: var(--accent-purple);
}

.ai-input-wrapper button {
  background: var(--accent-purple);
  color: #fff;
  border: none;
  width: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* 수식 탭 */
.formula-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.formula-card h4 {
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.latex-box {
  background: #080c16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: #38bdf8;
  margin-bottom: 6px;
}

.formula-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   5. MODAL DIALOG (AI SEARCH CTRL+K)
   ========================================================================== */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-modal-backdrop.active {
  display: flex;
}

.search-modal-box {
  width: 100%;
  max-width: 600px;
  background: #111726;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  overflow: hidden;
}

.modal-search-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-search-input i {
  color: var(--primary);
  font-size: 1.1rem;
}

.modal-search-input input {
  flex: 1;
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  outline: none;
}

.esc-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--text-dim);
}

.quick-results {
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
}

.res-category {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px;
}

.res-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.res-item:hover {
  background: rgba(56, 189, 248, 0.15);
}

.res-item i {
  font-size: 1.1rem;
}

.text-cyan { color: var(--primary); }
.text-amber { color: var(--accent-amber); }
.text-purple { color: var(--accent-purple); }

.res-item strong {
  display: block;
  font-size: 0.88rem;
  color: #fff;
}

.res-item small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* ==========================================================================
   6. SETTINGS MODAL (환경설정 창 & 반전 버튼 UI)
   ========================================================================== */
.settings-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.settings-modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.22s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.settings-modal-box {
  width: 100%;
  max-width: 520px;
  background: #111728;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 30px rgba(56, 189, 248, 0.15);
  overflow: hidden;
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.settings-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.settings-modal-title i {
  color: var(--primary);
  font-size: 1.15rem;
}

.settings-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition-fast);
}

.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.settings-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 현재 상태 멘트 카드 */
.settings-status-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

.settings-status-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.settings-status-content {
  flex: 1;
}

.settings-status-title {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 4px;
}

.settings-status-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.45;
  margin: 0;
}

/* 옵션 아이템 */
.settings-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.settings-option-info {
  flex: 1;
}

.settings-option-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.94rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.settings-option-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin: 0;
}

/* 핵심: 반전 버튼 (토글 버튼) */
.theme-invert-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #04101e;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35);
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.theme-invert-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.55);
  filter: brightness(1.08);
}

.theme-invert-btn:active {
  transform: translateY(0);
}

.theme-invert-btn i {
  font-size: 1rem;
}

/* 뱃지 */
.settings-badge-high {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-bright);
  border: 1px solid rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

/* 모달 푸터 (확인 버튼) */
.settings-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  justify-content: flex-end;
}

.settings-confirm-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.settings-confirm-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

/* ==========================================================================
   7. LIGHT THEME STYLES (반전 시 밝은 배경 전환 스타일)
   ========================================================================== */
body.theme-light {
  --bg-main: #f1f5f9;
  --bg-sub: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-elevated: rgba(0, 0, 0, 0.05);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(2, 132, 199, 0.35);

  --primary: #0284c7;
  --primary-glow: rgba(2, 132, 199, 0.3);
  --accent-cyan: #0891b2;
  --accent-purple: #7c3aed;
  --accent-emerald: #059669;
  --accent-emerald-bright: #10b981;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --shadow-glass: 0 8px 30px 0 rgba(15, 23, 42, 0.07);

  background-color: var(--bg-main);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at 12% 15%, rgba(2, 132, 199, 0.08) 0%, transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(124, 58, 237, 0.06) 0%, transparent 45%);
}

/* 탑바 라이트 모드 */
body.theme-light .top-navbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

body.theme-light .brand-title-wrap h2 {
  background: linear-gradient(135deg, #0f172a 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.theme-light .search-input-wrapper {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .search-input-wrapper:hover {
  background: rgba(0, 0, 0, 0.06);
}

body.theme-light .kbd-shortcut {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
  color: #64748b;
}

body.theme-light .nav-pill-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .nav-pill-btn:hover {
  background: rgba(2, 132, 199, 0.1);
  color: var(--primary);
  border-color: rgba(2, 132, 199, 0.3);
}

body.theme-light .nav-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

body.theme-light .nav-pill-btn.ai-special {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(2, 132, 199, 0.1));
  border-color: rgba(124, 58, 237, 0.25);
  color: #6d28d9;
}

body.theme-light .icon-circle-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .icon-circle-btn:hover {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
  border-color: var(--primary);
}

/* 좌측 사이드바 라이트 모드 */
body.theme-light .left-sidebar {
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .sidebar-search-box input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

body.theme-light .category-item.main-cat {
  background: rgba(0, 0, 0, 0.02);
}

body.theme-light .category-item.main-cat:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-light .category-group.open > .category-item.main-cat {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.2);
}

body.theme-light .count-badge {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-dim);
}

body.theme-light .sub-category-list {
  border-left: 1px dashed rgba(0, 0, 0, 0.12);
}

body.theme-light .sub-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

body.theme-light .nested-item {
  color: #475569;
}

body.theme-light .nested-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #0f172a;
}

body.theme-light .leaf-list {
  border-left: 1px solid rgba(2, 132, 199, 0.25);
}

body.theme-light .leaf-item:hover {
  color: var(--primary);
  background: rgba(2, 132, 199, 0.07);
}

body.theme-light .leaf-item.active-sim {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
}

body.theme-light .deep-nested-item {
  color: #0369a1;
  background: rgba(2, 132, 199, 0.06);
}

body.theme-light .deep-nested-item:hover {
  background: rgba(2, 132, 199, 0.12);
}

body.theme-light .sidebar-footer {
  background: rgba(248, 250, 252, 0.9);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* 시뮬레이션 컨트롤 데크 라이트 모드 */
body.theme-light .simulation-control-deck-banner {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

body.theme-light .deck-reset-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #334155;
}

body.theme-light .deck-reset-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

body.theme-light .deck-select-wrap select,
body.theme-light .deck-speed-badge select {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.12);
}

body.theme-light .deck-select-wrap select:hover,
body.theme-light .deck-select-wrap select:focus {
  border-color: var(--primary);
  background: #ffffff;
}

body.theme-light .deck-icon-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .deck-icon-btn:hover {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
  border-color: var(--primary);
}

/* 캔버스 패널 라이트 모드 */
body.theme-light .canvas-panel {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

body.theme-light .canvas-toolbar,
body.theme-light .canvas-bottom-bar {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.07);
}

body.theme-light .canvas-container {
  background: #f8fafc;
}

body.theme-light .view-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .hud-item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

body.theme-light .hud-val {
  color: #0f172a;
}

/* 제어 패널 및 탭 라이트 모드 */
body.theme-light .control-panel {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

body.theme-light .panel-tabs {
  background: #f8fafc;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

body.theme-light .panel-tab {
  color: #64748b;
}

body.theme-light .panel-tab:hover {
  color: var(--primary);
}

body.theme-light .panel-tab.active {
  color: var(--primary);
}

body.theme-light .panel-tab.active::after {
  background: var(--primary);
}

body.theme-light .preset-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #334155;
}

body.theme-light .preset-btn:hover {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
}

body.theme-light .formula-card {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .latex-box {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #0284c7;
}

body.theme-light .ai-bubble {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.06);
  color: #1e293b;
}

body.theme-light .ai-input-wrapper input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

/* 모달들 라이트 모드 */
body.theme-light .search-modal-box,
body.theme-light .settings-modal-box {
  background: #ffffff;
  border-color: rgba(2, 132, 199, 0.3);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.15), 0 0 30px rgba(2, 132, 199, 0.1);
}

body.theme-light .modal-search-input input {
  color: #0f172a;
}

body.theme-light .res-item strong {
  color: #0f172a;
}

body.theme-light .res-item:hover {
  background: rgba(2, 132, 199, 0.1);
}

body.theme-light .settings-modal-header,
body.theme-light .settings-modal-footer {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .settings-option-item {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .settings-status-card {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.25);
}

body.theme-light .theme-invert-btn {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f8fafc;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
}

body.theme-light .theme-invert-btn:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.4);
}

/* ==========================================================================
   8. UNIFIED SIMULATION FRAME & DYNAMIC VIEWPORT
   ========================================================================== */
.simulation-unified-panel {
  min-height: 580px;
}

.simulation-iframe-container {
  position: relative;
  width: 100%;
  height: 520px;
  background: #060913;
  overflow: hidden;
}

#simFrame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: transparent;
}

/* 시뮬레이션 뱃지 */
.sim-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-left: 6px;
}

/* 시뮬레이션 로딩 오버레이 */
.sim-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 21, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
}

.sim-loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 하단 툴 액션 버튼 */
.sim-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-tool-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
}

.mini-tool-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border-color: var(--primary);
}

/* 가이드 배너 & 메타 카드 */
.guide-banner {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.guide-banner i {
  font-size: 1.1rem;
  margin-top: 2px;
}

.guide-banner strong {
  display: block;
  font-size: 0.86rem;
  color: var(--text-main);
  margin-bottom: 3px;
}

.guide-banner p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.sim-info-meta-card {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.meta-k {
  color: var(--text-dim);
}

.meta-v {
  color: var(--text-main);
  font-weight: 600;
}

/* ==========================================================================
   9. GRAPH ANALYZER MODAL
   ========================================================================== */
.graph-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  z-index: 2200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.graph-modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.22s ease-out;
}

.graph-modal-box {
  width: 100%;
  max-width: 660px;
  background: #101627;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(56, 189, 248, 0.2);
  overflow: hidden;
}

.graph-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.graph-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.graph-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.graph-meta-info {
  display: flex;
  gap: 8px;
}

.graph-target-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.graph-type-badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.graph-canvas-container {
  width: 100%;
  background: #090e1c;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#graphCanvas {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
}

.graph-explanation {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.graph-explanation p {
  margin: 0;
  line-height: 1.4;
}

.graph-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   10. LIGHT THEME COMPATIBILITY FOR UNIFIED COMPONENTS
   ========================================================================== */
body.theme-light .simulation-iframe-container {
  background: #f1f5f9;
}

body.theme-light .sim-loading-overlay {
  background: rgba(241, 245, 249, 0.9);
}

body.theme-light .mini-tool-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .mini-tool-btn:hover {
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary);
}

body.theme-light .guide-banner {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

body.theme-light .sim-info-meta-card {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .graph-modal-box {
  background: #ffffff;
  border-color: rgba(2, 132, 199, 0.3);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.15), 0 0 35px rgba(2, 132, 199, 0.1);
}

body.theme-light .graph-modal-header,
body.theme-light .graph-modal-footer {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .graph-canvas-container {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .graph-explanation {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.2);
}


