/* Stage 2 — Trauma + Surgery setup refinement only.
   One scrollable control column; fixed mannequin sibling. */

body[data-stage1-view="sim"] .surg2-config{
  grid-template-rows:auto minmax(0,1fr);
  overflow:hidden;
}

body[data-stage1-view="sim"] .surg2-config-lower{
  min-height:0;
  height:100%;
  overflow:hidden;
  grid-template-columns:minmax(500px,1fr) minmax(280px,330px);
  align-items:stretch;
}

body[data-stage1-view="sim"] .surg2-control-column{
  min-width:0;
  min-height:0;
  height:100%;
  max-height:100%;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  padding-right:8px;
}

body[data-stage1-view="sim"] .surg2-patient-core{
  flex:0 0 auto;
  margin:0 0 8px;
  padding:0 0 8px;
  border-bottom:1px solid #183b2c;
}

body[data-stage1-view="sim"] .surg2-section-title,
body[data-stage1-view="sim"] .surg2-injury>h2{
  margin:0 0 7px;
  font-size:1rem;
  line-height:1.2;
}

body[data-stage1-view="sim"] .surg2-patient-core>.grid2,
body[data-stage1-view="sim"] .surg2-patient-core>.grid3{
  gap:8px;
}

body[data-stage1-view="sim"] .surg2-patient-core>.compact-fields{margin-top:7px}

body[data-stage1-view="sim"] .surg2-injury{
  flex:0 0 auto;
  padding:0 0 8px;
  margin-bottom:8px;
  border-bottom:1px solid #183b2c;
}

body[data-stage1-view="sim"] .surg2-advanced{
  flex:0 0 auto;
  margin-top:0;
  gap:8px;
}

body[data-stage1-view="sim"] .surg2-surgery-options>.surgery-runtime-flags{
  display:grid;
  grid-template-columns:1fr;
  gap:7px;
  margin:0 10px 7px 28px;
  width:calc(100% - 38px);
}

body[data-stage1-view="sim"] .surg2-surgery-options>.surgery-runtime-flags + .surgery-runtime-flags{
  margin-top:0;
}

body[data-stage1-view="sim"] .surg2-surgery-options .surgery-runtime-flags>.tag{
  min-width:0;
  width:100%;
  min-height:38px;
  display:flex;
  align-items:center;
  gap:7px;
  padding:7px 9px;
  white-space:normal;
  line-height:1.2;
}

body[data-stage1-view="sim"] .surg2-surgery-options .surgery-runtime-flags>label:not(.tag){
  display:block;
  min-width:0;
  width:100%;
}

body[data-stage1-view="sim"] .surg2-surgery-options #patientStress{
  width:100%;
  min-width:0;
  max-width:none;
}

body[data-stage1-view="sim"] .surg2-surgery-selects{
  display:grid!important;
  grid-template-columns:1fr!important;
  gap:8px!important;
  margin:0 10px 10px 28px!important;
  width:calc(100% - 38px)!important;
}

body[data-stage1-view="sim"] .surg2-limb-field{
  width:min(220px,100%);
}

body[data-stage1-view="sim"] .surg2-surface-field{
  width:100%!important;
  min-width:0!important;
  max-width:none!important;
}

body[data-stage1-view="sim"] #surface{
  display:block;
  width:100%!important;
  min-width:0!important;
  max-width:none!important;
  padding-right:34px;
  text-overflow:clip;
}

body[data-stage1-view="sim"] .surg2-organ-damage>.organ-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
}

body[data-stage1-view="sim"] .surg2-final-actions{
  flex:0 0 auto;
  margin-top:10px!important;
  padding:9px 0 2px;
  background:#10281d;
}

body[data-stage1-view="sim"] .surg2-mannequin-region{
  position:sticky;
  top:0;
  align-self:stretch;
  height:100%;
  max-height:100%;
  overflow:hidden;
}

body[data-stage1-view="sim"] .surg2-body{
  height:min(434px,100%);
  max-height:100%;
}

@media(min-width:1500px){
  body.stage2-surgery-setup-active .surg2-config{
    overflow:hidden;
  }

  body.stage2-surgery-setup-active .surg2-config-lower{
    min-height:0;
    overflow:hidden;
  }

  body.stage2-surgery-setup-active .surg2-control-column{
    overflow-y:auto;
    overflow-x:hidden;
  }
}

@media(min-width:1500px) and (max-height:900px){
  body.stage2-surgery-setup-active .surg2-control-column{
    padding-right:6px;
  }

  body.stage2-surgery-setup-active .surg2-patient-core,
  body.stage2-surgery-setup-active .surg2-injury{
    padding-bottom:6px;
    margin-bottom:6px;
  }

  body.stage2-surgery-setup-active .surg2-advanced{
    gap:6px;
  }

  body.stage2-surgery-setup-active .surg2-body{
    height:min(410px,100%);
  }
}

@media(min-width:1500px) and (max-height:760px){
  body.stage2-surgery-setup-active .surg2-body{
    height:min(360px,100%);
  }
}

@media(max-width:1180px){
  body[data-stage1-view="sim"] .surg2-config-lower{
    grid-template-columns:1fr;
    height:auto;
    overflow:visible;
  }

  body[data-stage1-view="sim"] .surg2-control-column{
    height:auto;
    max-height:none;
    overflow:visible;
    padding-right:0;
  }

  body[data-stage1-view="sim"] .surg2-mannequin-region{
    position:relative;
    height:auto;
    max-height:none;
  }
}

@media(max-width:760px){
  body[data-stage1-view="sim"] .surg2-organ-damage>.organ-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}
