:root {
  --primary: #c62828;
  --secondary: #475569;
  --accent: #ef4444;
  --bg-light: #f4f7f6;
  --card-bg: #ffffff;
  --glass: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-main: #2c3e50;
  --text-muted: #64748b;

  /* Simulation Specific Variables */
  --lab-bg: #ffffff;
  --artery-color: #580000;
  --wall-color: #8a1515;
  --pulse-speed: 1s;
  --pulse-scale: 1.02;
  --artery-height: 220px;
  --header-height: 70px;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  font-family: 'Outfit', sans-serif;
  background: var(--bg-light);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- SIMULATION INSTRUCTION TEXT --- */
.sim-instruction-text {
  position: absolute;
  bottom: -40px;
  /* Below the hand on Desktop */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  margin: 0;
  color: var(--text-main);
  font-size: 1rem;
  opacity: 0.8;
  z-index: 5;
  white-space: nowrap;
  pointer-events: none;
}

/* --- HEADER --- */
header.app-header {
  flex-shrink: 0;
  height: 70px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid #ddd;
  z-index: 1001;
  position: relative;
}

.header-content {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
}

.logo {
  flex-shrink: 0;
  z-index: 2;
}

.amrita-logo {
  height: 35px;
  display: block;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  width: 100%;
  text-align: center;
  position: absolute;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

@media (max-width: 650px) {
  header.app-header {
    height: auto;
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    gap: 10px;
  }

  header h1 {
    position: static;
    font-size: 1.2rem;
    pointer-events: auto;
  }

  :root {
    --header-height: 120px;
    /* Revised for mobile stack */
  }
}

/* --- NAVIGATION BUTTONS (Tag Style) --- */
.main-nav {
  display: flex;
  gap: 10px;
}

/* Theory Page Nav Specifics */
.theory-nav {
  background: transparent;
  border: none;
  padding: 0 0 1rem 0;
  justify-content: flex-start;
}

/* Simulation Page Nav Specifics */
.sim-nav {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;

}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #666;
  padding: 6px 16px;
  border-radius: 4px;
  /* Tag shape */
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn.active {
  background: var(--primary);
  /* Red for Active */
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.4);
}

.nav-btn:hover {
  border-color: var(--accent);
  color: white;
}

/* --- HOME PAGE STYLES --- */
#homePage {
  display: block;
  gap: 1rem;
  padding: 1rem;
  height: 100%;
  box-sizing: border-box;
}

.theory-scroll-container {
  overflow-y: auto;
  padding: 2rem 1rem;
  height: 100%;
  width: 98%;
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

@media (max-width: 768px) {
  .theory-scroll-container {
    padding: 1rem 0.5rem;
  }
}


.theory-nav-container {
  width: 100%;
  max-width: 1350px;
  margin: 0 auto 1.5rem auto;
  display: flex;
  justify-content: flex-start;
  transform: translateX(-40px);
  /* Nudge slightly back to the right */
}

.main-nav.theory-nav {
  background: var(--card-bg);
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 10px;
}

.theory-card {
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  width: 95%;
  max-width: 1350px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

@media (max-width: 768px) {
  .theory-card {
    padding: 1.5rem 1rem;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-right: none;
    box-sizing: border-box;
  }
}

.theory-card.image-card {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  margin-bottom: 2rem;
  max-width: 100%;
  box-sizing: border-box;
}

.theory-card.image-card .human-body {
  margin-top: 0;
}

.experiment-header {
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.experiment-header h2 {
  font-size: 2rem;
  margin: 0.5rem 0;
  color: #1a202c;
}

.tag {
  background: var(--primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.doc-section {
  margin-bottom: 2rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  color: #333;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.doc-section h3 {
  background: #3a86ff;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-section p,
.doc-section ol,
.doc-section ul {
  padding: 15px 20px;
  margin: 0;
  line-height: 1.6;
  color: #444;
  font-size: 0.95rem;
}

.doc-section ol,
.doc-section ul {
  list-style-position: inside;
}

.step-list li {
  padding: 8px 10px;
  margin-bottom: 5px;
  background: #f0f4f8;
  border-left: 4px solid #3a86ff;
  border-radius: 4px;
}

.physics-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.formula {
  font-size: 1.4rem;
  color: #c62828;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .params-grid {
    grid-template-columns: 1fr;
  }
}

/* Text Size Reductions for "Fit to Screen" */
.doc-section {
  margin-bottom: 1.5rem;
}

.doc-section h3 {
  font-size: 1rem;
}

.doc-section p {
  line-height: 1.5;
  font-size: 0.9rem;
}

.experiment-header h2 {
  font-size: 1.6rem;
  margin: 0.5rem 0;
}

.physics-box .formula-container {
  background: #f8fafc;
  padding: 15px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin: 10px 0;
}

.params-grid {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  color: #333;
}

.params-grid li strong {
  color: #c62828;
}


.human-body {
  position: relative;
  width: 450px;
  /* Increased from 300px */
  opacity: 0.8;
  transition: opacity 0.3s;
}

.human-body:hover {
  opacity: 1;
}

.anatomy-wrapper {
  position: relative;
  width: 100%;
  display: inline-block;
  /* Wraps image tightly */
}

.human-body img {
  width: 100%;
  border-radius: 20px;
}

.pulse-point {
  position: absolute;
  width: 40px;
  height: 40px;
  background: radial-gradient(circle, var(--accent), transparent);
  border-radius: 50%;
  animation: heartPulse 1.2s infinite;
  /* Optimized Position */
  top: 64%;
  left: 23%;
}

@keyframes heartPulse {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}


/* --- SIM INTRO STYLES (Refactored) --- */
.sim-intro {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  justify-content: center;
  /* Centering fix */
  padding: 1rem;
}

.human-body {
  cursor: pointer;
  margin-top: 2rem;
  /* Adjusted spacing */
}

.click-instruction {
  text-align: center;
  color: #ef4444;
  margin-top: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- SIMULATION PAGE STYLES (Clean White) --- */
#simPage {
  height: 100vh;
  width: 100vw;
  background: #ffffff;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 999;
}

.lab-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
}



/* Sidebar */
.sidebar,
.controls-panel.sidebar-full {
  width: 320px;
  background: var(--card-bg);
  border-right: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 20000;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  padding-bottom: 60px;
}


.btn-back {
  background: #f8f9fa;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.btn-back:hover {
  background: #eee;
  color: var(--text-main);
}

/* Green Start Stimulation Button Overrides */
.start-action-btn:hover {
  background: #15803d !important; /* Slightly darker green */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.sidebar h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--text-main);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 10px;
}

.sidebar h3 {
  font-size: 0.8rem;
  margin: 10px 0 5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Stage Buttons */
.stage-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-btn {
  padding: 12px 15px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.stage-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(3px);
}

.stage-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(198, 40, 40, 0.3);
}

.stage-btn.active::after {
  content: '●';
  font-size: 0.8rem;
}

/* --- Disabled States --- */
.stage-btn:disabled,
.action-btn:disabled,
input[type=range]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(100%);
}

/* Sliders */
.slider-group {
  background: rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
}

.slider-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}

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

.value-display {
  font-weight: bold;
  color: var(--accent);
  float: right;
  font-size: 0.9rem;
}

/* Simulation Area */
/* Simulation Area - Fix Overflow for Labels */
.simulation-area {
  flex: 1;
  position: relative;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: visible;
  /* Changed from hidden to allow labels to show */
}

/* Artery Wrapper */
.artery-wrapper {
  position: relative;
  width: 85%;
  height: var(--artery-height);
  transition: all 0.5s ease;
  z-index: 10;
}

/* Artery Labels - Clean Positioning */
.artery-labels {
  position: absolute;
  top: 100%;
  /* Push completely below the artery */
  margin-top: 50px;
  /* Restore initial gap */
  left: 0;
  width: 100%;
  padding-top: 15px;
  /* constant gap */
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
  z-index: 5;
  pointer-events: none;
}

.label-text:last-child {
  text-align: right;
}

/* Graph Container */
#graph-container {
  transition: all 0.3s ease;
}

/* Graph Controls Default */
.graph-controls {
  position: absolute;
  top: -10px;
  right: -10px;
  display: flex;
  gap: 5px;
  z-index: 10001;
}

/* Maximized State */
#graph-container.maximized {
  display: block !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  inset: 0 !important;
  z-index: 10000 !important;
  background: rgba(15, 15, 27, 1) !important;
  padding: 40px !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
}

/* Move controls inside when maximized */
#graph-container.maximized .graph-controls {
  top: 15px;
  right: 15px;
}

/* Responsiveness */
@media (max-width: 600px) {

  /* Artery Logic */
  .artery-wrapper {
    width: 95%;
  }

  .artery-labels {
    width: 100%;
    font-size: 0.8rem;
  }

  /* Graph Logic */
  #graph-container {
    width: 90% !important;
    height: 200px !important;
    bottom: 15px !important;
    right: 5% !important;
    left: 5% !important;
  }

  #graph-container.maximized {
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }
}


.artery {
  width: 100%;
  height: 100%;
  background-color: var(--artery-color);
  border-top: 22px solid var(--wall-color);
  border-bottom: 22px solid var(--wall-color);
  position: relative;
  overflow: hidden;
  border-radius: 120px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6), 0 20px 50px rgba(0, 0, 0, 0.3);
  /* Pulse animation applied here */
  animation: pulse var(--pulse-speed) ease-in-out infinite;
}

/* --- GRAPH CONTAINER --- */
#graph-container {
  display: none;
  /* Hidden by default */
  position: absolute !important;
  bottom: 70px !important;
  /* Moved Up */
  right: 20px !important;
  width: 360px;
  /* Increased Width */
  height: 300px;
  /* Increased Height for Labels */
  background: rgba(15, 15, 27, 0.95);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  z-index: 9999 !important;
  flex-direction: column;
}

#graph-container.maximized {
  bottom: auto !important;
  right: auto !important;
}

@keyframes pulse {

  0%,
  100% {
    transform: scaleY(1);
  }

  50% {
    transform: scaleY(var(--pulse-scale));
  }
}

/* Plaque */
.plaque-top,
.plaque-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background-color: #fdd835;
  background-image: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.5), transparent 40%), repeating-radial-gradient(circle, #fbc02d 0, #fbc02d 4px, #fdd835 8px, #fff176 10px);
  border: none;
  transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  box-shadow: inset 0 0 15px rgba(100, 50, 0, 0.4);
}

.plaque-top {
  top: 0;
  border-radius: 0 0 40% 70% / 0 0 60% 40%;
  height: 0;
}

.plaque-bottom {
  bottom: 0;
  border-radius: 60% 40% 0 0 / 70% 50% 0 0;
  height: 0;
}

/* Cells */
.cell {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}

.rbc {
  width: 42px;
  height: 42px;
  background: radial-gradient(circle at 30% 30%, #ff5252, #b71c1c);
  border-radius: 50%;
  box-shadow: inset -2px -2px 5px rgba(0, 0, 0, 0.4);
}

.rbc::after {
  content: '';
  width: 65%;
  height: 65%;
  background: radial-gradient(#ff8a80, #c62828);
  border-radius: 50%;
  opacity: 0.9;
}

.wbc {
  width: 48px;
  height: 48px;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e0e0e0);
  border-radius: 50%;
  opacity: 0.95;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.wbc::after {
  content: '';
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, #bbb 1px, transparent 1px);
  background-size: 6px 6px;
  border-radius: 50%;
  opacity: 0.5;
}

/* Animations */
.flowing {
  animation: flow linear forwards;
}

@keyframes flow {
  from {
    left: -60px;
    transform: rotate(0deg);
  }

  to {
    left: 100%;
    transform: rotate(360deg);
  }
}

.stuck {
  animation: travel-to-block linear forwards;
}

@keyframes travel-to-block {
  from {
    left: -60px;
    transform: rotate(0deg);
  }

  to {
    left: calc(50% - 170px + var(--stack-offset));
    transform: rotate(180deg);
  }
}

.stuck::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  animation: bob 3s infinite ease-in-out alternate;
}

@keyframes bob {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(3px);
  }
}

/* Labels - Removed duplicate block relative to previous line numbers 741-758 */

.label-text::before {
  content: '▲';
  display: block;
  text-align: center;
  color: #ccc;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

/* =========================================
   RESPONSIVE DESIGN (Tablets & Mobile)
   ========================================= */

@media (max-width: 900px) {

  /* Header adjustments */
  header.app-header {
    height: auto;
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    gap: 10px;
  }

  header h1 {
    position: static;
    font-size: 1.1rem;
    margin-top: 5px;
    width: 100%;
    text-align: center;
  }

  .logo {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .amrita-logo {
    height: 30px;
  }

  /* Home Page */
  #homePage {
    /* height: auto; Removed to allow internal scrolling */
    padding: 1rem 0.5rem;
  }

  .theory-card {
    padding: 1.5rem 1rem;
    border-radius: 12px;
  }

  .theory-nav-container {
    transform: none;
    margin: 0 auto 1.5rem auto;
    justify-content: center;
  }

  .main-nav.theory-nav {
    flex-wrap: wrap;
    padding: 0.8rem 1rem;
    justify-content: center;
  }

  .sidebar {
    width: 100%;
    /* Full width */
    height: auto;
    /* Auto height */
    max-height: 40vh;
    /* Limit height */
    order: 2;
    /* Move to bottom */
    border-right: none;
    border-top: 1px solid var(--glass-border);
    flex-direction: row;
    /* Horizontal controls if possible */
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 15px;
    gap: 10px;
  }

  .simulation-area {
    order: 1;
    /* Visual on top */
    height: 60vh;
    /* Remaining space */
  }

  /* Adjust sidebar contents for horizontal layout */
  .sidebar h2,
  .sidebar .btn-back,
  .sidebar h3 {
    flex-basis: 100%;
    /* Keep headings full width */
    margin-bottom: 5px;
  }

  .sidebar h3 {
    margin-top: 5px;
  }

  .stage-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
  }

  .stage-btn {
    flex: 1;
    padding: 8px;
    font-size: 0.8rem;
    justify-content: center;
  }

  .stage-btn::after {
    display: none;
    /* Hide dot to save space */
  }

  .slider-group {
    flex: 1 1 45%;
    /* 2 columns for sliders */
    min-width: 140px;
    padding: 8px;
  }

  .artery-wrapper {
    width: 95%;
  }

  .artery-labels {
    font-size: 0.7rem;
    bottom: 20px;
  }
}

@media (max-width: 600px) {

  /* Sim Intro */
  .human-body {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }

  .main-nav.theory-nav {
    flex-direction: column;
    padding: 1rem;
  }

  .main-nav.theory-nav .nav-btn {
    width: 100%;
    text-align: center;
  }

  .params-grid {
    grid-template-columns: 1fr;
  }

  .pulse-point {
    width: 25px;
    height: 25px;
  }

  .site-footer-theory {
    padding: 15px 0;
    margin-top: 20px;
  }
}

.sim-nav {
  top: 1rem;
}

/* Stacking sliders on very small screens */
.slider-group {
  flex: 1 1 100%;
}

.stage-btn {
  font-size: 0.75rem;
  padding: 6px;
}


/* =========================================
   HAND VIEW & MAGNIFIER IMPLEMENTATION
   ========================================= */

.hand-view-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #ffffff !important;
  overflow: hidden;
}

#sim-entry-stage {
  padding-top: 80px;
  /* Push image card down only on Entry Stage */
}

/* --- MAIN LAYOUT CONTAINER --- */
.lab-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* --- LEFT SIDEBAR (Controls) --- */
.controls-panel.sidebar-full {
  position: fixed;
  left: 0;
  top: var(--header-height);
  width: 300px;
  /* Fixed Width */
  height: calc(100vh - var(--header-height));
  background: #ffffff;
  /* Darker, less transparent */
  border-right: 1px solid var(--glass-border);
  border-radius: 0;
  padding: 0;
  /* Internal padding handled by children */
  display: flex;
  flex-direction: column;
  z-index: 100;
  backdrop-filter: blur(20px);
  box-shadow: 5px 0 20px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
  padding: 15px 20px 5px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--glass-border);
}

.nav-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 5px;
  width: 100%;
}

.nav-toggle .nav-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
}

.controls-panel h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scroll-content {
  padding: 10px 20px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.action-btn {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--glass-border);
  color: #333;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  margin-top: 5px;
}

.sidebar-footer-label {
  background: rgba(0, 0, 0, 0.05);
  /* Similar to action-btn */
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  /* Slightly muted text */
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 15px;
  /* Spacing from button above */
  cursor: default;
  pointer-events: none;
  /* Not clickable */
  user-select: none;
}


/* --- SIMULATION CARD CONTAINER --- */
.simulation-card {
  background: #ffffff;
  padding: 3rem;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: calc(100% - 320px);
  max-width: 1350px;
  margin: 0 auto 0 320px;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

@media (max-width: 1024px) {
  .simulation-card {
    padding: 2.5rem;
    width: calc(100% - 320px);
    margin-left: 320px;
  }
}

@media (max-width: 768px) {
  .simulation-card {
    flex-direction: column;
    padding: 1.5rem;
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 40px;
    margin-left: 0;
    max-width: 100%;
  }
}

/* --- HAND WRAPPER (Center) --- */
.hand-wrapper {
  position: relative;
  width: 45%;
  max-width: 600px;
  aspect-ratio: 4/3;
  z-index: 2;
  margin-left: -40px;
  /* Move hand a little to the left */
  margin-right: 40px;
  /* Add space between hand and magnifier */
  flex-shrink: 0;
}

/* Remove raster image styles if conflict, but keeping entry class separate */
.hand-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
}

@keyframes handFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.flow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* --- CONNECTORS --- */
/* DESKTOP CONNECTORS (Artery -> Magnifier) */
.connector-desktop {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, #222, #444, transparent);
  z-index: 100;
  pointer-events: none;
  opacity: 0.8;
  transform-origin: 0 0;
}

/* Static positions removed - JS handles positioning dynamically */


/* Add a dot at the start to blend */
/* White dot removed per user request */

.connector-mobile {
  display: none;
}

/* --- MAGNIFIER --- */
.magnifier-container {
  width: 420px;
  /* Decreased from 520px */
  height: 420px;
  border-radius: 50%;
  border: 12px solid #e0e0e0;
  background: #ffffff !important;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s;
  z-index: 10;
  flex-shrink: 0;
}

.magnifier-container:hover {
  transform: scale(1.02);
  border-color: #fff;
}

.magnifier-content {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.glass-glare {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 40%;
  height: 20%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
}

/* --- ADAPTATION FOR INNER SIM --- */
.magnified-artery .artery-labels {
  display: none;
}

.magnified-artery {
  width: 1000px !important;
  /* Show more part of artery */
  max-width: none !important;
  margin: 0 !important;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  /* Adjusted for smaller glass */
  transform-origin: center center;
}

@media (min-width: 769px) {
  body {
    overflow-x: hidden;
    overflow-y: hidden;
  }

  .lab-wrapper {
    width: 100%;
    overflow: visible;
  }
}

/* MOBILE (max-width: 768px) */
@media (max-width: 768px) {

  /* 1. LAYOUT STACKING */
  .lab-wrapper {
    flex-direction: column;
    padding-left: 0;
    /* Remove sidebar space */
    padding-top: 20px;
    padding-bottom: 320px;
    /* Space for bottom controls */
    justify-content: flex-start;
    gap: 20px;
    height: auto;
    overflow-y: auto;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: 100%;
  }

  /* Reset Simulation Card for Mobile */
  .simulation-card {
    padding: 1.5rem 1rem !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    max-width: 100% !important;
    flex-direction: column;
    gap: 20px;
  }

  .stage-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* 2. SIDEBAR -> BOTTOM PANEL */
  .controls-panel.sidebar-full {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    width: 100%;
    height: 320px;
    /* Slight increase for larger fonts */
    border-right: none;
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    z-index: 1000;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
  }

  /* Sidebar Internal Layout optimization for landscape/row? 
     Keeping vertical for now but enabling scroll if needed */

  /* 3. ELEMENTS */
  .hand-wrapper {
    width: 100%;
    max-width: 450px;
    margin: 20px auto;
    /* Reset desktop shift */
    position: relative;
    display: flex;
    justify-content: center;
  }

  .hand-img {
    width: 100% !important;
    height: auto !important;
  }

  .magnifier-container {
    width: 250px;
    height: 250px;
    margin-top: -40px;
    margin-left: -50px;
    /* Shifted more to left */
    border-width: 8px;
  }

  .magnified-artery {
    transform: translate(-50%, -50%) scale(0.38);
  }

  /* 4. CONNECTORS */
  .connector-desktop {
    display: none;
  }

  /* Mobile connectors: JS handles positioning */
  .connector-mobile {
    display: block;
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, #222, #444, transparent);
    z-index: 20;
    pointer-events: none;
    opacity: 0.8;
    transform-origin: 0 0;
  }

  /* Hide Magnifier Instructions or move them */
  /* Show Magnifier Instructions and position higher */
  /* Hide Magnifier Instructions or move them */
  /* Show Magnifier Instructions and position higher */

  .desktop-hint {
    display: none !important;
    /* Hide "just below hand" text on mobile */
  }

  .mobile-only-hint {
    display: block !important;
    position: static;
    transform: none;
    margin-top: 5px;
    margin-bottom: 25px;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    order: -1;
    /* Move to TOP on mobile */
  }

  /* Move Instruction Text to TOP on Mobile */
  .sim-instruction-text {
    bottom: auto;
    /* Unset bottom */
    top: -40px;
    /* Move to Top */
    font-size: 0.9rem;
    /* Keep smaller on mobile */
  }

  /* GLOBAL SCROLL RESTORATION FOR MOBILE */
  body {
    overflow-y: auto !important;
  }
}




/* GLOBAL: Hide Sim Background Elements when Graph Maximized (Desktop & Mobile) */
body.graph-maximized .magnifier-container,
body.graph-maximized .connector-desktop,
body.graph-maximized .hand-wrapper,
body.graph-maximized .sim-instruction-text {
  opacity: 0;
  /* Use opacity to prevent layout shifts if flexible, or visibility: hidden */
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Mobile specific: Hide wrapper completely as done before */
@media (max-width: 768px) {
  body.graph-maximized .lab-wrapper {
    display: none !important;
  }

  body.graph-maximized .site-header {
    display: none !important;
  }
}

@media (min-width: 1001px) {
  .magnified-artery {
    transform: translate(-50%, -50%) scale(0.7);
    /* Adjusted for smaller glass */
  }
}