/* ====== LAYOUT ====== */
#ip-sim-root .ip-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;   /* left: sim+graph, right: controls */
  gap: 12px;
  align-items: start;
  margin: 6px 10px;
}

/* Left: simulation (top) + graph (bottom) */
#ip-sim-root .ip-left {
  display: grid;
  grid-template-rows: auto auto;      /* heights are set by JS */
  gap: 8px;
}

/* ====== CANVASES ====== */
/* Strongly scoped rules to beat global canvas !important min-heights, but
   we DO NOT set a fixed height here so JS can control it. */
#ip-sim-root .ip-left canvas#ip-canvas.ip-canvas,
#ip-sim-root .ip-left canvas#ip-graph.ip-graph {
  border: 1px solid #ccc;
  width: 100% !important;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: block;

  /* Neutralize aggressive global rules */
  min-height: unset !important;
  max-height: unset !important;
}

/* Give the sim a gray background, leave graph white */
#ip-sim-root .ip-left canvas#ip-canvas.ip-canvas { background: #f0f0f0; }

/* ====== CONTROLS (sticky, compact) ====== */
#ip-sim-root .ip-controls {
  width: 100%;
  text-align: left;
  font-family: Arial, sans-serif;
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  position: sticky;
  top: 64px;                            /* adjust if your header/admin bar differs */
  max-height: calc(100vh - 80px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#ip-sim-root .ip-group { padding-bottom: 8px; border-bottom: 1px solid #eee; }
#ip-sim-root .ip-group:last-child { border-bottom: none; }

/* ====== TYPOGRAPHY / SPACING ====== */
#ip-sim-root h2 { font-size: 1.45em; margin: 6px 0 2px; color: #333; }
#ip-sim-root h3 { font-size: 1.02em; color: #333; margin: 6px 0; }

#ip-sim-root table {
  margin: 10px auto;
  border-collapse: collapse;
  font-size: 0.9em;
  width: 100%;
  max-width: 1000px;
}
#ip-sim-root td, #ip-sim-root th {
  padding: 6px; border: 1px solid #ddd; text-align: center;
}

#ip-sim-root label { display: flex; align-items: center; margin: 4px 0; font-size: 1em; color: #555; }
#ip-sim-root input[type="range"] { flex-grow: 1; margin: 0 8px; }
#ip-sim-root select { margin: 0 8px; padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; }
#ip-sim-root .ip-val { font-weight: 600; color: #007bff; min-width: 44px; text-align: right; }

#ip-sim-root .ip-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
#ip-sim-root button { background: #007bff; color: #fff; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 0.88em; }
#ip-sim-root button:hover { background: #005ec1; }

#ip-sim-root p { font-size: 0.9em; margin: 8px 0 0; color: #333; border-top: 1px solid #eee; padding-top: 8px; }
#ip-sim-root p span { color: #28a745; }

/* ====== RESPONSIVE (phones/tablets) ====== */
@media (max-width: 960px) {
  #ip-sim-root .ip-wrapper { grid-template-columns: 1fr; }
}
