/* ==========================================================================
   NeuroVis 3D - Scientific Ivory & Parchment Medical Drafting System
   ========================================================================== */

:root {
  /* Warm Parchment / Drafting Paper Aesthetic */
  --bg-canvas: #f4efe6;
  --bg-primary: #f4efe6;
  --bg-secondary: #ece5d8;
  --bg-surface: rgba(250, 247, 240, 0.92);
  --bg-surface-hover: rgba(242, 237, 227, 0.98);
  --bg-card: rgba(253, 251, 247, 0.95);
  
  --border-glass: rgba(185, 172, 148, 0.4);
  --border-glass-light: rgba(185, 172, 148, 0.65);
  --border-accent: rgba(37, 99, 235, 0.45);

  --accent-blue: #1d4ed8;
  --accent-blue-hover: #1e40af;
  --accent-amber: #b45309;
  --accent-red: #dc2626;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --badge-vessel: #dc2626;
  --badge-tract: #0284c7;
  --badge-subcortical: #7e22ce;
  --badge-cortex: #0d9488;
  --badge-head: #b45309;

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: 'Consolas', 'Menlo', 'Monaco', 'Courier New', monospace;
  --shadow-card: 0 4px 18px -2px rgba(90, 80, 60, 0.08), 0 2px 6px -1px rgba(90, 80, 60, 0.04);
  --shadow-drawer: 0 10px 30px -4px rgba(80, 70, 50, 0.15);

  /* High-Contrast Clinical Custom Cursors - Slate Navy Fill with Crisp White Border */
  --cursor-default: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M3 2 L3 19.5 L7.8 15.2 L11.8 22.5 L14.5 21 L10.5 13.8 L17 13.8 Z' fill='%230f172a' stroke='%23ffffff' stroke-width='1.8' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, auto;
  --cursor-pointer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M8 2 L8 12 L6.2 12 C4.8 12 4.2 13.5 5.3 14.6 L10.5 20.5 C11.5 21.6 13 22 15 22 L16.5 22 C18.5 22 19.5 20.5 19.5 18.5 L19.5 11.5 C19.5 10.2 18 10.2 18 10.2 C18 9 16.5 9 16.5 9 C16.5 7.8 15 7.8 15 7.8 L15 2 C15 0.8 13.5 0.8 13.5 2 L13.5 8 L12 8 L12 2 C12 0.8 10.5 0.8 10.5 2 L10.5 8 L9.5 8 L9.5 2 C9.5 0.8 8 0.8 8 2 Z' fill='%230f172a' stroke='%23ffffff' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") 8 2, pointer;
  --cursor-grab: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.5' fill='%230f172a' stroke='%23ffffff' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='2.5' fill='%23ffffff'/%3E%3Cpath d='M12 1v5M12 18v5M1 12h5M18 12h5' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, crosshair;
  --cursor-grabbing: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.5' fill='%231d4ed8' stroke='%23ffffff' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='3.5' fill='%23ffffff'/%3E%3Cpath d='M12 1v5M12 18v5M1 12h5M18 12h5' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, crosshair;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  cursor: var(--cursor-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: var(--cursor-grab);
}
#three-canvas:active {
  cursor: var(--cursor-grabbing);
}

button, a, select, input[type="range"], input[type="checkbox"], .tree-item, .sys-tab, .btn-toggle, .btn-mode-switch, .btn-preset, .tree-group-header, .brand, .btn-matrix-jump {
  cursor: var(--cursor-pointer);
}
input[type="text"] {
  cursor: text;
}

/* Custom Scrollbar - Warm Muted Paper */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(180, 168, 145, 0.4);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(180, 168, 145, 0.7);
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: var(--bg-canvas);
}

/* ==========================================================================
   Top Header Navigation
   ========================================================================== */
.app-header {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(246, 241, 232, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
  box-shadow: 0 1px 8px rgba(90, 80, 60, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.brand-icon svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.2px;
}

.brand-text .sub-title {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.system-badges {
  display: flex;
  align-items: center;
  gap: 5px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(235, 228, 215, 0.85);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}
.badge:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--border-accent);
  color: var(--accent-blue);
}

/* Dual-Coordinate Live Telemetry Pill (Bottom-Right Floating, Non-Wrapping) */
.coord-display-floating {
  position: absolute;
  bottom: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  box-shadow: var(--shadow-card);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  z-index: 28;
  user-select: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.coord-display-floating .coord-label {
  font-size: 10px;
  font-weight: 700;
  color: #8c8273;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.coord-display-floating .coord-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
}

.coord-display-floating .coord-divider {
  color: #cbd5e1;
  margin: 0 4px;
}

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

/* Mode Switch Button (Assembly vs Matrix) */
.zh-sub {
  font-size: 0.84em;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

.btn-mode-switch {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.35);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
}
.btn-mode-switch:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: var(--accent-blue);
}
.btn-mode-switch.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}
.btn-mode-switch .btn-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}
.btn-mode-switch .btn-text-en {
  font-size: 11px;
  font-weight: 700;
}
.btn-mode-switch .btn-text-zh {
  font-size: 9px;
  color: inherit;
  opacity: 0.8;
}

.view-preset-group {
  display: flex;
  align-items: center;
  background: rgba(235, 228, 215, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.btn-preset {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  transition: var(--transition-fast);
}
.btn-preset .preset-en {
  font-size: 10px;
  font-weight: 700;
}
.btn-preset .preset-zh {
  font-size: 8.5px;
  color: var(--text-muted);
}
.btn-preset:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-primary);
}
.btn-preset.active {
  background: #ffffff;
  color: var(--accent-blue);
  box-shadow: 0 1px 3px rgba(90, 80, 60, 0.12);
}
.btn-preset.active .preset-zh {
  color: rgba(29, 78, 216, 0.75);
}

/* ==========================================================================
   Main Container & 3D Viewport
   ========================================================================== */
.main-container {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100vh - 52px);
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
}

#viewport-container {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
}

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

/* Loading Overlay */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(244, 239, 230, 0.94);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 340px;
  text-align: center;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(37, 99, 235, 0.15);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.85s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
  margin-bottom: 16px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.loading-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.progress-bar-bg {
  width: 260px;
  height: 6px;
  background: rgba(185, 172, 148, 0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
  transition: width 0.2s ease;
}

.loading-count {
  font-size: 11px;
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Hide Hover Tooltip per User Request */
#mesh-tooltip, .mesh-tooltip {
  display: none !important;
}

/* Matrix Controls Hint Badge (Visible in Matrix Mode) */
.matrix-controls-hint {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(250, 247, 240, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 4px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(90, 80, 60, 0.1);
  z-index: 24;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}
.matrix-controls-hint.hidden {
  opacity: 0;
  pointer-events: none;
}
.matrix-controls-hint .hint-en {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}
.matrix-controls-hint .hint-zh {
  font-size: 10px;
  color: var(--text-muted);
}

/* ==========================================================================
   Bottom Floating Control Bar
   ========================================================================== */
.bottom-control-bar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
  max-width: 95vw;
}

.control-card {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
}

.explosion-control {
  flex-direction: column;
  gap: 6px;
  width: 440px;
  min-width: 440px;
  max-width: 440px;
  flex: 0 0 440px;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  gap: 12px;
}
.control-label .label-left {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.control-label .lbl-en {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.control-label .lbl-zh {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.control-label .val-mono {
  font-family: var(--font-sans);
  color: var(--accent-blue);
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
  letter-spacing: -0.1px;
}

.slider-wrapper {
  width: 100%;
}
.slider-wrapper input[type="range"] {
  width: 100%;
  height: 5px;
  accent-color: var(--accent-blue);
  background: rgba(185, 172, 148, 0.4);
  border-radius: 3px;
  cursor: pointer;
}

.mode-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-toggle {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 0 13px;
  height: 38px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: var(--cursor-pointer);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.btn-toggle .icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.btn-toggle .btn-lbl {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-toggle .zh-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.btn-toggle:hover {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-glass-light);
  box-shadow: 0 2px 8px rgba(90, 80, 60, 0.08);
}
.btn-toggle.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.18);
}

/* ==========================================================================
   Left Hierarchy Sidebar (Compact & Collapsible)
   ========================================================================== */
.left-sidebar {
  position: absolute;
  top: 14px;
  left: 14px;
  bottom: 14px;
  width: 260px;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: transform var(--transition-smooth);
}

.left-sidebar.collapsed {
  transform: translateX(-276px);
}

/* Modern Floating Circular Pill Drawer Toggle */
.btn-sidebar-toggle {
  position: absolute;
  right: -15px;
  top: 15px;
  width: 30px;
  height: 30px;
  background: rgba(254, 252, 248, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(185, 172, 148, 0.7);
  border-radius: 50%;
  cursor: var(--cursor-pointer);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  box-shadow: 0 3px 10px rgba(90, 80, 60, 0.16);
  z-index: 30;
  transition: all var(--transition-fast);
}
.btn-sidebar-toggle:hover {
  background: #ffffff;
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}
.btn-sidebar-toggle .toggle-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  transition: transform var(--transition-normal);
}
.left-sidebar.collapsed .btn-sidebar-toggle .toggle-icon {
  transform: rotate(180deg);
}

.sidebar-header {
  padding: 10px 10px 8px 10px;
  border-bottom: 1px solid var(--border-glass);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
}
.search-icon {
  stroke: var(--text-muted);
}
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-sans);
}
.search-box input::placeholder {
  color: var(--text-muted);
}

.system-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(235, 228, 215, 0.4);
}

.sys-tab {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  transition: var(--transition-fast);
}
.sys-tab .tab-en {
  font-size: 10px;
  font-weight: 700;
}
.sys-tab .tab-zh {
  font-size: 8.5px;
  color: var(--text-muted);
}
.sys-tab:hover {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-glass-light);
}
.sys-tab.active {
  background: #ffffff;
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.15);
}
.sys-tab.active .tab-zh {
  color: rgba(29, 78, 216, 0.75);
}
.tab-count {
  font-size: 9px;
  opacity: 0.8;
  font-family: var(--font-mono);
}

.tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.tree-group {
  margin-bottom: 8px;
}

.tree-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: rgba(235, 228, 215, 0.45);
  margin-bottom: 2px;
  transition: var(--transition-fast);
}
.tree-group-header:hover {
  background: rgba(235, 228, 215, 0.8);
}
.group-title-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.group-master-cb {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent-blue);
  margin: 0 2px 0 0;
  flex-shrink: 0;
}
.group-title-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.group-title-text .title-en {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-title-text .title-zh-sub {
  font-size: 8.5px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-arrow {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.tree-group.collapsed .group-arrow {
  transform: rotate(-90deg);
}
.tree-group.collapsed .tree-items {
  display: none;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.tree-item:hover {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-primary);
}
.tree-item.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-blue);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.color-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.item-title-box {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  flex: 1;
}
.name-en-primary {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-sans);
  letter-spacing: -0.15px;
}
.name-zh-sub {
  font-size: 8.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-item.active .name-en-primary {
  color: var(--accent-blue);
  font-weight: 700;
}

.item-visibility {
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: var(--accent-blue);
  flex-shrink: 0;
}

/* ==========================================================================
   Right Clinical Knowledge Inspector (Compact & Floating)
   ========================================================================== */
.right-inspector {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 275px;
  max-height: calc(100vh - 130px);
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  z-index: 35;
  transform: translateX(310px);
  transition: transform var(--transition-smooth);
  overflow: hidden;
}
.right-inspector.visible {
  transform: translateX(0);
}

.inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-glass);
}

.inspector-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
}

.inspector-title h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.btn-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  transition: var(--transition-fast);
}
.btn-icon:hover {
  background: #ffffff;
  color: var(--text-primary);
}

.inspector-content {
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-en-box {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.3;
}

.inspector-actions {
  display: flex;
  gap: 6px;
}

.btn-action {
  flex: 1;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  transition: var(--transition-fast);
}
.btn-action .act-en {
  font-size: 11px;
  font-weight: 700;
}
.btn-action .act-zh {
  font-size: 8.5px;
  opacity: 0.85;
}
.btn-action.primary {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.btn-action.primary:hover {
  background: var(--accent-blue-hover);
}
.btn-action.secondary {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}
.btn-action.secondary:hover {
  background: var(--bg-surface-hover);
}

.info-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 5px;
}
.section-title .sec-en {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}
.section-title .sec-zh {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 400;
}

.coord-matrix-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coord-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.coord-lbl {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
}
.coord-val {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.coord-val.mono {
  color: var(--accent-blue);
  font-size: 9px;
}

.clinical-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.6);
  padding: 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-blue);
}

.mesh-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}
.stat-lbl {
  font-size: 9px;
  color: var(--text-muted);
}
.stat-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1px;
}
.stat-val.mono {
  font-family: var(--font-mono);
  font-size: 9px;
}

/* ==========================================================================
   Matrix Mode Section Navigator (Horizontal Floating Pill Dock at Top Center)
   ========================================================================== */
.matrix-section-nav {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(250, 247, 240, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 4px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  z-index: 25;
  box-shadow: 0 4px 16px rgba(90, 80, 60, 0.1);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.matrix-section-nav.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -15px);
}
.matrix-nav-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 8px 0 4px;
  border-right: 1px solid var(--border-glass);
  border-bottom: none;
  margin-bottom: 0;
  white-space: nowrap;
}
.btn-matrix-jump {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.btn-matrix-jump:hover {
  background: #ffffff;
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.15);
  transform: translateY(-1px);
}

/* ==========================================================================
   Mobile Responsive Layout Adaptation (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Header */
  .app-header {
    height: auto;
    min-height: 48px;
    padding: 6px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand-text .sub-title {
    display: none;
  }
  .system-badges {
    display: none;
  }
  .header-left {
    gap: 8px;
  }
  .header-right {
    gap: 6px;
    flex-wrap: wrap;
  }
  .btn-mode-switch {
    padding: 3px 8px;
  }
  .btn-mode-switch .btn-text-en {
    font-size: 10px;
  }
  .btn-mode-switch .btn-text-zh {
    display: none;
  }
  .btn-preset {
    padding: 3px 6px;
  }

  /* Left Sidebar Drawer on Mobile */
  .left-sidebar {
    top: 56px;
    left: 8px;
    bottom: 8px;
    width: calc(100vw - 32px);
    max-width: 310px;
    z-index: 80;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  }
  .left-sidebar.collapsed {
    transform: translateX(calc(-100% - 20px));
  }

  /* Bottom Controls Bar on Mobile */
  .bottom-control-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    transform: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    max-width: calc(100vw - 16px);
    width: calc(100vw - 16px);
  }
  .explosion-control {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    padding: 8px 12px;
  }
  .mode-buttons {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px 2px;
    justify-content: flex-start;
  }
  .coord-display-floating {
    display: none; /* Hide coordinate readout on mobile screens to save space */
  }

  /* Right Clinical Inspector on Mobile */
  .right-inspector {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
    top: 56px;
    max-height: calc(100vh - 120px);
  }

  /* Matrix Controls Hint */
  .matrix-controls-hint {
    top: 60px;
    font-size: 10px;
    padding: 3px 10px;
    max-width: 90vw;
    text-align: center;
  }
  .matrix-section-nav {
    max-width: 95vw;
    overflow-x: auto;
    justify-content: flex-start;
  }
}
