:root{font-family:system-ui,-apple-system,Segoe UI,sans-serif;color:#222;background:#fff}*{box-sizing:border-box}body{margin:0}header{position:sticky;top:0;z-index:20;padding:10px 16px;border-bottom:1px solid #ddd;background:#fff;display:flex;align-items:baseline;gap:20px}h1{font-size:22px;margin:0}.status{font-size:12px;color:#666}.shell{display:grid;grid-template-columns:390px minmax(0,1fr);min-height:calc(100vh - 50px)}.sidebar{padding:10px;border-right:1px solid #ddd;overflow:auto;max-height:calc(100vh - 50px)}.sidebar section,.sidebar details,.calc-card,#result{border:1px solid #ddd;border-radius:8px;padding:9px;margin-bottom:9px}.sidebar h2,.calc-card h2,#result h2{font-size:16px;margin:0 0 8px}.sidebar h3{font-size:13px;margin:8px 0 4px}details summary{font-weight:650;cursor:pointer}main{padding:12px;min-width:0}.grid2,.grid3,.grid4,.grid5,.vector,.toolbar{display:grid;gap:4px}.grid2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid5{grid-template-columns:repeat(5,minmax(0,1fr));align-items:end}.vector{grid-template-columns:28px repeat(3,minmax(0,1fr));align-items:center;margin:3px 0}.auto-row{grid-template-columns:28px 1fr}.auto-vector{font-size:12px;padding:4px 0}.toolbar{grid-template-columns:repeat(3,minmax(0,1fr));margin-bottom:8px}label{font-size:12px;display:flex;flex-direction:column;gap:2px;min-width:0}input,select,button{font:inherit;min-width:0;padding:4px 5px;border:1px solid #bbb;border-radius:4px;background:white}input[type=number]{width:10ch;min-width:8ch;max-width:100%}select{width:100%}input[type=checkbox]{width:auto}.checkbox-label{flex-direction:row;align-items:center;gap:6px;align-self:end;min-height:28px}.compact-checks>div{border:1px solid #eee;padding:5px;border-radius:5px}.compact-checks label:has(input[type=checkbox]){flex-direction:row;align-items:center}.dark-table{display:grid;grid-template-columns:26px repeat(3,minmax(0,1fr));gap:3px;align-items:center;font-size:11px}.chart-grid{display:grid;grid-template-columns:minmax(520px,1.35fr) minmax(430px,1fr);gap:12px}#singleMain .chart-grid>div:first-child,#singleMain .chart-grid>.geometry-card,#powderMain>#powderPlot{border:1px solid #ddd;border-radius:8px;padding:9px;margin-bottom:9px}.qe-plot{width:100%;min-height:620px}.geometry{min-height:620px}.powder{min-height:650px}.energy-slider-row{display:flex;gap:12px;align-items:center;padding:0 20px 12px}.energy-slider-row label{flex:1}.energy-slider-row input{width:100%}.calc-card{margin-top:8px}.plots{display:grid;grid-template-columns:1fr 1fr;gap:8px}.plots>div{height:390px;border:1px solid #eee}.summary{font-size:13px;margin-bottom:8px}.error{border:1px solid #c33;background:#fff4f4;padding:10px;margin-bottom:10px;white-space:pre-wrap}.hidden{display:none!important}.scan-nav{display:grid;grid-template-columns:auto 1fr auto auto;gap:8px;align-items:center;margin-bottom:8px}pre{overflow:auto;font-size:12px}.scan .grid5{margin-top:5px}button{cursor:pointer}
@media(max-width:1050px){.shell{grid-template-columns:320px minmax(0,1fr)}.chart-grid{grid-template-columns:1fr}.geometry{min-height:420px}.plots{grid-template-columns:1fr}.grid5{grid-template-columns:repeat(2,minmax(0,1fr))}#singleInputs.grid5{grid-template-columns:repeat(5,minmax(0,1fr))}#scanInputs .grid5{grid-template-columns:repeat(5,minmax(0,1fr))}}
@media(max-width:760px){.shell{display:block}.sidebar{max-height:none;border-right:0;border-bottom:1px solid #ddd}.chart-grid{grid-template-columns:1fr}.qe-plot{min-height:520px}.grid4{grid-template-columns:repeat(4,minmax(0,1fr))}}

/* Keep the dark-angle / geometry card border continuous around Plotly content */
#singleMain .chart-grid>.geometry-card{overflow:hidden}
.geometry-target{padding:10px 8px 4px}
.geometry-target-title{font-size:13px;font-weight:650;margin-bottom:7px}
.geometry-angles{font-size:12px;line-height:1.45;margin-top:8px;padding:7px 8px;background:#f7f7f7;border-radius:5px;min-height:34px}
.geometry-angles.error-text{color:#a22;background:#fff4f4}

/* Main workspace tabs: Sample / Instrument setup remain shared in the sidebar. */
.main-tabs{
  display:flex;
  gap:6px;
  margin:0 0 12px;
  padding:4px;
  border:1px solid #ddd;
  border-radius:9px;
  background:#f7f7f7;
}
.tab-button{
  flex:0 1 220px;
  padding:8px 14px;
  border:1px solid transparent;
  border-radius:6px;
  background:transparent;
  font-weight:650;
}
.tab-button:hover{background:#fff}
.tab-button.active{
  background:#fff;
  border-color:#ccc;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
}
.tab-button:focus-visible{outline:2px solid currentColor;outline-offset:2px}
.tab-panel{min-width:0}
.panel-heading{margin:0 0 10px}
.panel-heading h2{font-size:18px;margin:0 0 3px}
.panel-heading p{font-size:12px;color:#666;margin:0}
#resolutionPanel .calc-card{margin-top:0}

@media(max-width:760px){
  .main-tabs{position:sticky;top:49px;z-index:15;background:#f7f7f7}
  .tab-button{flex:1;padding:8px 6px}
}

/* Q-E workspace: compact square reciprocal-space map + larger TAS schematic. */
#singleMain .chart-grid{grid-template-columns:minmax(500px,1.08fr) minmax(500px,1fr);align-items:stretch}
#singlePlot{height:680px;min-height:680px}
#geometryPlot.geometry{min-height:580px}
@media(max-width:1250px){#singleMain .chart-grid{grid-template-columns:minmax(440px,1.05fr) minmax(440px,1fr)}#geometryPlot.geometry{min-height:580px}}
@media(max-width:1050px){#singleMain .chart-grid{grid-template-columns:1fr}#singlePlot{min-height:560px}#geometryPlot.geometry{min-height:620px}}

/* TAS Geometry target energy slider */
.geometry-hw-slider-row{display:flex;gap:12px;align-items:center;padding:8px 4px 2px}.geometry-hw-slider-row label{flex:1}.geometry-hw-slider-row input{width:100%}.geometry-hw-slider-row output{min-width:76px;text-align:right;font-size:12px}


/* v51: Q-E Range vertical spacing polish.
   Keep the chosen 580 px plot height, but give the x-axis/legend and slider more breathing room. */
#singleMain .chart-grid>div:first-child .energy-slider-row{
  padding:12px 20px 8px;
}


/* v53: enlarge the square Q-E map to approximately the former full x-axis width.
   The data aspect remains 1:1 in Plotly; the extra vertical room prevents
   `constrain:domain` from shrinking the x domain to fit the 580 px box. */
@media(min-width:1051px){
  #singlePlot{height:680px;min-height:680px}
}

/* v54: right-card heading above the angle controls; Plotly title removed. */
.geometry-card-title{font-size:16px;font-weight:650;padding:9px 8px 2px}
