:root {
  --phet-blue: #e0f6f5;
  --panel-bg: white;
  --border-color: #cbd5e1;
  --text-main: #333;

  /* Colors */
  --color-o2: #ef4444;
  --color-co2: #64748b;
  --color-na: #f97316;
  --color-glucose: #10b981;
  --color-water: #3b82f6;

  --btn-primary: #8bc34a;
  /* PhET Greenish */
  --btn-primary-hover: #7cb342;
  --btn-reset: #ff9800;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
  margin: 0;
  height: 100vh;
  font-family: "Roboto", sans-serif;
  background: var(--phet-blue);
  color: var(--text-main);
  overflow-x: hidden;
}

.sim-header {
  height: 80px;
  background: #ffffff;
  border-bottom: 4px solid #8bc34a;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 100;
  position: relative;
  justify-content: space-between;
}

.institution-logo {
  max-height: 60px;
  width: auto;
  display: block;
}

.title-container {
  flex: 1;
  display: flex;
  justify-content: center;
}

.sim-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2c3e50;
  margin: 0;
  font-family: "Roboto", sans-serif;
  letter-spacing: 0.5px;
}

.phet-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr 220px;
  grid-template-areas:
    "left center"
    "left bottom";
  height: calc(100vh - 84px);
  padding: 1rem;
  gap: 1rem;
}

/* Panels */
.left-panel,
.center-panel,
.bottom-panel {
  background: var(--panel-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid #ccc;
  overflow: hidden;
  position: relative;
}

.left-panel {
  grid-area: left;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.center-panel {
  grid-area: center;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.bottom-panel {
  grid-area: bottom;
  padding: 1rem;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
}

.panel-header {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 500;
  border-bottom: 2px solid #eee;
  padding-bottom: 0.5rem;
}

.panel-header-sm {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
}

/* LEFT: Controls */
.solute-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.solute-row {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
}

.solute-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.solute-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.control-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

.control-label {
  font-size: 0.85rem;
  color: #666;
  width: 60px;
}

/* Stepper Buttons (PhET Style) */
.stepper {
  display: flex;
  background: #eee;
  border-radius: 20px;
  padding: 2px;
}

.step-btn {
  border: none;
  background: #ddd;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  margin: 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.step-btn:hover {
  background: #ccc;
}

.step-btn:active {
  background: #bbb;
}

/* CENTER: Simulation */
.simulation-wrapper {
  flex: 1;
  position: relative;
  background: #f0fbff;
  border-bottom: 1px solid #eee;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sim-label {
  position: absolute;
  font-weight: 700;
  font-size: 1.5rem;
  color: rgba(0, 0, 0, 0.2);
  pointer-events: none;
  text-transform: uppercase;
}

.label-outside {
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
}

.label-inside {
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
}

.channel-toggles {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.channel-toggle {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.channel-toggle label {
  cursor: pointer;
}

/* Playback Bar */
.playback-bar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  background: #fafafa;
}

.phet-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}

.phet-button.primary {
  background: var(--btn-primary);
  color: white;
  border-color: #7cb342;
}

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

.phet-button.warning {
  background: var(--btn-reset);
  color: white;
  border-color: #f57c00;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

.phet-panel-inset {
  background: #e0e0e0;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

/* BOTTOM: Graphs */
.concentration-cards {
  display: flex;
  gap: 1rem;
  height: 100%;
  align-items: stretch;
  flex-wrap: wrap;
}

.conc-card {
  flex: 1;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}

.conc-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.conc-bars {
  flex: 1;
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.5rem;
}

.bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 20px;
  transition: height 0.3s;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
}

.bar-label {
  font-size: 0.7rem;
  color: #666;
}

/* Shapes */
.shape-o2 {
  background: var(--color-o2);
  border-radius: 50%;
}

.shape-co2 {
  background: var(--color-co2);
  border-radius: 50%;
  border: 2px solid #555;
}

.shape-na {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 16px solid var(--color-na);
}

.shape-glu {
  background: var(--color-glucose);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.shape-water {
  background: var(--color-water);
  border-radius: 50%;
  transform: scale(0.8);
}

/* Responsive Breakpoints */

/* Tablet Layout */
@media (max-width: 1199px) {
  .phet-grid {
    grid-template-columns: 260px 1fr;
    grid-template-areas:
      "left center"
      "bottom bottom";
  }
}

@media (max-width: 1024px) {
  .phet-grid {
    grid-template-columns: 240px 1fr;
  }
}

/* Mobile Layout */
@media (max-width: 768px) {
  body {
    height: auto;
    overflow-y: auto;
  }

  .sim-header {
    flex-direction: column;
    height: auto;
    padding: 1rem;
    gap: 0.5rem;
  }

  .institution-logo {
    max-height: 40px;
  }

  .sim-title {
    font-size: 1.25rem;
    text-align: center;
  }

  .phet-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 0.5rem;
    gap: 1rem;
  }

  .center-panel {
    order: 1;
    min-height: 450px;
  }

  .left-panel {
    order: 2;
    overflow-y: visible;
    padding: 0.5rem;
  }

  .bottom-panel {
    order: 3;
  }

  .playback-bar {
    height: auto;
    padding: 0.5rem;
    flex-wrap: wrap;
    gap: 1rem;
  }

  /* Touch Targets */
  .step-btn {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .phet-button {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .channel-toggles {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.95);
  }

  .channel-toggle {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .solute-row {
    padding: 0.5rem;
  }
}
