/* Late cross-panel overrides. These rules must load after the panel files to keep the cascade unchanged.
   Load order is significant: styles/*.css are linked in numeric order from index.html. */

.s2-conversion-info.warning{color:#a25a00;background:#fff8e6;border:calc(1px * var(--tas-density)) solid #e5c982;border-radius:calc(5px * var(--tas-density));padding:calc(6px * var(--tas-density)) calc(8px * var(--tas-density))}
.time-info-panel .time-range-help,
.time-info-panel .time-mcu-help{
  margin:0;
  color:#555;
}
.time-info-panel .time-mcu-help{margin-top:calc(7px * var(--tas-density));padding-top:calc(7px * var(--tas-density));border-top:calc(1px * var(--tas-density)) solid #e2e5e9}
.time-info-row-inline{
  display:inline-flex!important;
  justify-content:flex-start!important;
  margin:0!important;
}
.geometry-scan-table th,.geometry-scan-table td{border:calc(1px * var(--tas-density)) solid #ddd;padding:calc(6px * var(--tas-density)) calc(7px * var(--tas-density));text-align:right;font-variant-numeric:tabular-nums;background:#fff}
.geometry-scan-table th{background:#f2f2f2;font-weight:650;position:sticky;top:0;z-index:1}
.geometry-scan-table th:first-child,.geometry-scan-table td:first-child{text-align:center;width:calc(52px * var(--tas-density));min-width:calc(52px * var(--tas-density))}
.geometry-scan-table th:last-child,.geometry-scan-table td:last-child{text-align:left;white-space:normal;min-width:calc(150px * var(--tas-density))}
.geometry-scan-table tbody tr{cursor:pointer}
.geometry-scan-table tbody tr:hover td{background:#fff9e8}
.structure-color-chip.selected{
  border-color:#111;
  box-shadow:0 0 0 calc(1px * var(--tas-density)) #fff inset;
}
@media (max-width:1450px){
  
  .structure-moment-row{
    grid-template-columns:calc(44px * var(--tas-density)) minmax(calc(58px * var(--tas-density)),calc(72px * var(--tas-density))) minmax(calc(150px * var(--tas-density)),1fr) calc(90px * var(--tas-density)) calc(42px * var(--tas-density))!important;
  }
  .structure-bond-row{
    grid-template-columns:minmax(calc(58px * var(--tas-density)),1fr) minmax(calc(58px * var(--tas-density)),1fr) calc(88px * var(--tas-density)) calc(54px * var(--tas-density)) calc(40px * var(--tas-density)) auto!important;
  }
}
.cif-generator-message.error-text{color:#a22}
.absorption-table th,.absorption-table td{padding:calc(7px * var(--tas-density)) calc(9px * var(--tas-density));border-bottom:calc(1px * var(--tas-density)) solid #e1e1e1;text-align:right;white-space:nowrap}
.absorption-table th:first-child,.absorption-table td:first-child{text-align:left}
.absorption-table:not(.absorption-summary-table) th,.absorption-table:not(.absorption-summary-table) td{width:20%}
.cif-generator-section + .cif-generator-section{margin-top:calc(14px * var(--tas-density));padding-top:calc(12px * var(--tas-density));border-top:calc(1px * var(--tas-density)) solid #ddd}
.cif-reflection-parameters-section .cif-generator-beam-grid{margin:calc(8px * var(--tas-density)) 0 0}
.absorption-cif-row>label,.absorption-cif-row input,.absorption-input-mode-row label,.absorption-input-mode-row select{min-width:0;max-width:100%;box-sizing:border-box}
.toolbox-subtab.active{background:white;border-color:#c5cad2;box-shadow:0 calc(1px * var(--tas-density)) calc(3px * var(--tas-density)) #00000014;}
.magff-info.error{color:#9c441d;border:0;padding:0;background:transparent;}
.magff-extra-row>label{
  min-width:0;display:grid;gap:calc(5px * var(--tas-density));align-content:end;
}
.magff-extra-row :is(input,select){
  box-sizing:border-box;width:100%;max-width:100%;min-width:0;
}

/* v44: Clear visual hierarchy between workspace tabs and nested tabs.
   Main navigation stays lighter and carries the stronger outer border.
   All nested tab bars share the main tab palette, with thinner borders and a single row.
   The selected tab is white at every navigation level (v45).
   On narrow screens swipe horizontally instead of wrapping or clipping labels. */
.main-tabs{
  display:flex;
  flex-wrap:nowrap;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  gap:calc(5px * var(--tas-density));
  border:calc(2px * var(--tas-density)) solid #b9c4d0;
  background:#f3f5f7;
  scrollbar-width:thin;
}
.main-tabs .tab-button{
  flex:1 0 auto;
  white-space:nowrap;
  padding:calc(9px * var(--tas-density)) calc(11px * var(--tas-density));
  font-size:calc(16px * var(--tas-density));
  line-height:1.25;
  border:calc(1px * var(--tas-density)) solid transparent;
  background:#f3f5f7;
}
.main-tabs .tab-button:hover{background:#eaf0f6;}
.main-tabs .tab-button.active{
  background:#fff;
  border-color:#aab7c5;
  box-shadow:none;
}
@media(max-width:760px){
  .main-tabs{background:#f3f5f7;}
  .main-tabs .tab-button{flex:1 0 auto;padding:calc(8px * var(--tas-density)) calc(10px * var(--tas-density));}
}
.toolbox-subtab:hover{background:#eaf0f6;}
.toolbox-subtab.active{
  background:#fff;
  border:0;
  box-shadow:none;
  color:#222;
}
.geometry-card-tabs .geometry-card-tab,
.cif-output-tabs .cif-output-tab{
  flex:1 0 auto;
  min-width:max-content;
  white-space:nowrap;
  border:0;
  border-right:calc(1px * var(--tas-density)) solid #b9c4d0;
  border-radius:0;
  background:#f3f5f7;
  color:#222;
  font-size:calc(14px * var(--tas-density));
  line-height:1.25;
  padding:calc(8px * var(--tas-density)) calc(10px * var(--tas-density));
  box-shadow:none;
  position:static;
  bottom:auto;
}
.geometry-card-tabs .geometry-card-tab:hover,
.cif-output-tabs .cif-output-tab:hover{background:#eaf0f6;}
.geometry-card-tabs .geometry-card-tab.active,
.cif-output-tabs .cif-output-tab.active{
  background:#fff;
  border-color:#aab7c5;
  box-shadow:inset 0 calc(-1px * var(--tas-density)) 0 #66798b;
  color:#222;
  position:static;
  bottom:auto;
}
.toolbox-subtab.active,
#structurePanel .structure-config-tabs button.active{
  border:calc(1px * var(--tas-density)) solid #98a7b6;
  border-radius:calc(5px * var(--tas-density));
  background:#fff;
  box-shadow:none;
}
.geometry-card-tabs .geometry-card-tab,
.cif-output-tabs .cif-output-tab{
  box-sizing:border-box;
  border:calc(1px * var(--tas-density)) solid transparent;
  border-radius:0;
}
.geometry-card-tabs .geometry-card-tab.active,
.cif-output-tabs .cif-output-tab.active{
  box-sizing:border-box;
  border:calc(1px * var(--tas-density)) solid #98a7b6;
  border-radius:calc(4px * var(--tas-density));
  background:#fff;
  box-shadow:none;
}

/* On a narrow MAIN WORKSPACE (not just a narrow window), show the six
   primary tabs in two rows of three instead of a horizontal scroller. */
@container (max-width:850px){
  main > .main-tabs{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    grid-template-rows:repeat(2,auto);
    gap:calc(5px * var(--tas-density));
    overflow:visible;
  }
  main > .main-tabs > .tab-button{
    flex:none;
    width:100%;
    min-width:0;
    display:flex;
    align-items:center;
    justify-content:center;
    white-space:normal;
    overflow-wrap:anywhere;
    text-align:center;
    padding:calc(8px * var(--tas-density)) calc(5px * var(--tas-density));
  }
}
/* Viewport fallback for browsers without the main-column container query. */
@media (max-width:760px){
  main > .main-tabs{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    grid-template-rows:repeat(2,auto);
    gap:calc(5px * var(--tas-density));
    overflow:visible;
  }
  main > .main-tabs > .tab-button{
    flex:none;
    width:100%;
    min-width:0;
    display:flex;
    align-items:center;
    justify-content:center;
    white-space:normal;
    overflow-wrap:anywhere;
    text-align:center;
    padding:calc(8px * var(--tas-density)) calc(5px * var(--tas-density));
  }
}

/* v49: equal-width items throughout every navigation tab group. */
main > .main-tabs{
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  gap:calc(5px * var(--tas-density));
  overflow:visible;
}
main > .main-tabs > .tab-button{
  width:100%;min-width:0;flex:none;
  display:flex;align-items:center;justify-content:center;
  text-align:center;white-space:normal;overflow-wrap:anywhere;
}
/* Each two-item Q-E/geometry/scan/preview pair receives exactly half the row. */
.geometry-card-tabs,
.cif-output-tabs{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:0;
  overflow-x:hidden;
}
.geometry-card-tabs > .geometry-card-tab,
.cif-output-tabs > .cif-output-tab{
  width:100%;min-width:0;max-width:100%;flex:none;
  white-space:normal;overflow-wrap:anywhere;
  text-align:center;
}
/* Four calculators share equal widths; small viewports scroll the entire even grid. */
.toolbox-subtabs{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:calc(4px * var(--tas-density));
  overflow-x:auto;
}
@container (max-width:850px){
  main > .main-tabs{grid-template-columns:repeat(3,minmax(0,1fr));}
}
@media (max-width:760px){
  main > .main-tabs{grid-template-columns:repeat(3,minmax(0,1fr));}
}
@media (max-width:600px){
  .toolbox-subtabs{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}
/* Five equal main tabs instead of the previous six. */
main > .main-tabs{grid-template-columns:repeat(5,minmax(0,1fr));}
@container (max-width:850px){
  main > .main-tabs{grid-template-columns:repeat(3,minmax(0,1fr));}
}
@media(max-width:760px){
  main > .main-tabs{grid-template-columns:repeat(3,minmax(0,1fr));}
}
.qe-external-legend .qe-legend-item{
  display:inline-flex;gap:calc(6px * var(--tas-density));align-items:center;
  border:calc(1px * var(--tas-density)) solid transparent;border-radius:calc(4px * var(--tas-density));
  padding:calc(4px * var(--tas-density)) calc(5px * var(--tas-density));background:transparent;color:#202a37;
  cursor:pointer;font-size:calc(13px * var(--tas-density));line-height:1.25;text-align:left;
}
.qe-external-legend .qe-legend-item:hover,
.qe-external-legend .qe-legend-item:focus-visible{background:#f2f5f9;border-color:#b7c2d0}
.qe-external-legend .qe-legend-swatch{
  display:inline-block;flex:0 0 calc(16px * var(--tas-density));height:calc(10px * var(--tas-density));border-radius:calc(2px * var(--tas-density));
  background:var(--legend-color);border:calc(1px * var(--tas-density)) solid rgba(0,0,0,.15);
}
.qe-external-legend .qe-legend-line{
  height:0;border:0;border-top:calc(3px * var(--tas-density)) solid var(--legend-color);
  border-radius:0;background:transparent;
}
/* Sidebars are bounded by the real viewport, not an enlarged stage. */
.shell { min-height: calc(100vh - var(--tas-header-height)); }

/* Read each Time estimate Command diagnostic on its own line. */
.time-estimate-message{white-space:pre-line}
.sidebar label,
.sidebar .checkbox-label {
  font-size: calc(16px * var(--tas-density));
  line-height: 1.3;
}

/* Readability refinements – targeted typography without changing UI density,
   Plotly hit-testing geometry, or the existing responsive grid layout. */
/* Automatic W vector beside the scattering plane input. */
.sidebar .auto-row .auto-vector{
  font-size:calc(17px * var(--tas-density));
  line-height:1.4;
  font-weight:500;
  overflow-wrap:anywhere;
}

/* Time estimate scan cells previously had a fixed 38*density pixel height and
   overflow:hidden.  Those values clipped larger selects/input text.  Let grid
   tracks grow to fit whichever control is tallest, preserving horizontal
   scrolling and the index/command columns. */
.time-scan-table .time-scan-cell{
  box-sizing:border-box;
  height:auto!important;
  min-height:max(36px,calc(48px * var(--tas-density)));
  overflow:visible;
  padding:max(4px,calc(5px * var(--tas-density)));
  align-content:center;
}
.time-scan-table-wrap.time-scan-scroll{
  max-height:max(410px,calc(600px * var(--tas-density)));
  overflow-y:auto;
}

/* Warning lines and Script editor are readable at both density breakpoints.
   Overlay text and line-number gutter MUST share the same font metrics or
   highlighted SPICE lines will drift away from the actual command lines. */
.time-estimate-message.warning-text,
.script-message.warning-text,
.script-message.error-text{
  font-size:max(13px,calc(18px * var(--tas-density)));
  line-height:1.5;
  overflow-wrap:anywhere;
}

/* Shared mono/analyzer crystal selectors immediately below fixed energy. */
.instrument-crystal-row{
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr));
  gap:calc(5px * var(--tas-density)); align-items:end;
  margin-top:calc(7px * var(--tas-density));
  margin-bottom:calc(7px * var(--tas-density));
}

/* Six fixed-beam unit choices share one existing Fixed and one value slot.
   The hidden legacy fields retain the canonical meV interface used by TAS calculations. */
.instrument-primary-row > .fixed-beam-internal{display:none!important;}

/* Sidebar: make No. compact and give the space-group selector more room.
   Override the legacy equal-width columns without changing sidebar width. */
.sample-spacegroup-row{
  grid-template-columns:minmax(0,1fr) minmax(0,.825fr) minmax(0,1.375fr)!important;
}
@media(max-width:760px){
  .sample-spacegroup-row{
    grid-template-columns:minmax(0,1fr) minmax(0,.825fr) minmax(0,1.375fr)!important;
  }
}

/* Independent sidebar / workspace scrolling for two-column layouts.
   Size the shell from the space remaining beneath the actual header rather
   than assuming a fixed header height (which can vary with wrapping/zoom). */
@media (min-width: 761px) {
  html { height: 100%; }
  body {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
  }
  #tasTopBar { flex: 0 0 auto; }
  .shell {
    flex: 1 1 auto;
    height: 0;
    min-height: 0;
  }
  .shell > .sidebar {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  .shell > main {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }
}

/* Viewport resizing: prevent the document from retaining an oversized scroll
   area when the layout crosses the 760px breakpoint.  The shell should be
   sized by the flex viewport on desktop, not by older vh-based minimums. */
@media (min-width: 761px) {
  html { height: 100%; overflow-y: hidden; }
  body { min-height: 0; max-height: 100dvh; overflow-y: hidden; }
  body > .shell { min-height: 0; max-height: 100%; }
  body > .shell > main,
  body > .shell > .sidebar { min-height: 0; max-height: 100%; }
}
@media (max-width: 760px) {
  html { height: auto; overflow-y: auto; }
  body { display: block; height: auto; min-height: 0; max-height: none; overflow-y: auto; }
  body > .shell { display: block; height: auto; min-height: 0; max-height: none; }
  body > .shell > main,
  body > .shell > .sidebar { height: auto; max-height: none; overflow-y: visible; }
}

/* Touch tablets: allow native pull-to-refresh to reach the viewport when the
   independent sidebar / workspace scroller has reached its top.  The desktop
   viewport lock and the <=760px single-page mobile layout are unchanged. */
@media (min-width:761px) and (pointer:coarse){
  html, body{
    overflow-y:auto;
    overscroll-behavior-y:auto;
  }
  body > .shell > .sidebar,
  body > .shell > main{
    overscroll-behavior-y:auto;
  }
}

/* Text next to entries, selects, checkboxes and sliders in all main tabs.
   Also cover the value/output text beside Q–E and TAS Geometry sliders. */
.tab-panel label,
.tab-panel .checkbox-label,
.tab-panel .qe-control-entry,
.tab-panel .qe-s2-control-entry > span,
.tab-panel .qe-path-snap-label,
.tab-panel .energy-slider-row output,
.tab-panel .geometry-scan-point-row > output,
.tab-panel .cif-reflection-plane-toggle,
.tab-panel .structure-entry-label,
.tab-panel .cif-unified-preview-label {
  font-size: var(--plane-tab-label-font) !important;
  line-height: 1.35;
}

/* Section headings, including Input/Output file and Structure editor. */
.tab-panel h2,
.tab-panel h3,
.tab-panel .cif-section-title,
.tab-panel .script-pane-heading,
.tab-panel .structure-section-title {
  font-size: var(--plane-tab-heading-font) !important;
  font-weight: 700;
  line-height: 1.3;
}

/* Warnings/status notices have the exact text size of the diffractometer
   Resolution unavailable message. Keep their original colors and borders. */
.diffractometer-resolution-note,
.tab-panel .orientation-plane-warning,
.tab-panel .cif-generator-message,
.tab-panel .generator-reflections-notice,
.tab-panel .cif-release-note,
.tab-panel .s2-conversion-info.warning,
.tab-panel .qe-spurion-warning,
.tab-panel .time-estimate-message {
  font-size: var(--plane-tab-warning-font) !important;
  line-height: 1.45;
}

/* Propagation vector toggles should be the same native size as the parent
   'show' checkbox. The slightly wider first column keeps the k_i legend
   legible; the three HKL fields continue to flex and can display four digits. */
.sidebar .propagation-row {
  grid-template-columns: calc(88px * var(--tas-density)) repeat(3, minmax(0,1fr)) calc(70px * var(--tas-density));
}
.sidebar .propagation-enable {
  gap: calc(6px * var(--tas-density));
  align-items: center;
  padding-top: calc(15px * var(--tas-density));
}

/* Slider/checkbox/combobox captions match Angle calculation > Scan slider. */
.tab-panel label:has(> input[type="range"]),
.tab-panel label:has(> input[type="checkbox"]),
.tab-panel label:has(> select),
.tab-panel .geometry-scan-point-row > :is(label,output),
.tab-panel .energy-slider-row > :is(label,output),
#qeConstantMapPane .qe-control-entry,
#qeConstantMapPane .qe-control-entry > :is(span,label),
#qeDisplayControls .qe-map-toolbar label,
#qeDisplayControls .qe-path-snap-label,
#qeDisplayControls .checkbox-label {
  font-size: max(14px, calc(16px * var(--tas-density))) !important;
  line-height: 1.35;
}

/* Labels that belong to a control should never become headings in bold.
   Keep entry labels legible, and match select captions to the sidebar's
   Instrument caption (16px * density) instead of enlarging to >=14px. */
.tab-panel :is(label, .checkbox-label, .structure-entry-label, .qe-control-entry,
               .qe-s2-control-entry > span, .qe-path-snap-label,
               .cif-reflection-plane-toggle, .cif-unified-preview-label),
.tab-panel .energy-slider-row output,
.tab-panel .geometry-scan-point-row output,
#qeDisplayControls :is(.qe-map-toolbar label, .checkbox-label, .qe-path-snap-label),
#qeConstantMapPane .qe-control-entry > :is(span,label) {
  font-size: var(--plane-tab-label-font) !important;
  font-weight: 400 !important;
  line-height: 1.35;
}
/* Selects get the same caption size as the Instrument select in the sidebar;
   their option/selected-value type is left unchanged. */
.tab-panel label:has(> select),
#qeDisplayControls .qe-map-toolbar label:has(> select),
#qeDisplayControls .qe-path-snap-label:has(> select) {
  font-size: var(--plane-tab-select-caption-font) !important;
  font-weight: 400 !important;
}
/* A few compound controls carry the bold weight on their inner caption. */
.tab-panel label :is(span, b, strong),
.tab-panel .checkbox-label :is(span, b, strong),
#qeDisplayControls .qe-control-entry :is(span, b, strong),
#qeDisplayControls .qe-map-toolbar label :is(span, b, strong) {
  font-weight: 400 !important;
}
.tab-panel button:not([role="tab"]) :is(b,strong),
.sidebar button :is(b,strong) {
  font-weight: 400 !important;
}

/* Toolbox / Neutron attenuation's summary captions (Cell volume, scattering
   cross section, abs/coh/incoh, penetration depth, transmission) were not
   covered by the shared label selectors: they are DIV/SPAN elements. */
#toolboxAttenuationPane :is(.absorption-summary-label, .absorption-summary-subgrid span),
#toolboxAttenuationPane :is(.absorption-beam-controls, .absorption-thickness-control,
                            .absorption-input-mode-row, .absorption-manual-row,
                            .absorption-cif-row) label {
  font-size: var(--plane-tab-label-font) !important;
  font-weight: 400 !important;
  line-height: 1.35;
}

/* Field/select captions are uniformly sidebar-sized in every tab even when an
   older, ID-qualified Toolbox or Resolution layout rule specified larger text. */
.tab-panel[id] label:has(> select) {
  font-size: var(--plane-tab-select-caption-font) !important;
  font-weight: 400 !important;
}

/* 2026-10-13 — Typography parity with Atomic positions. All four editor
   tables inherit the same table/header font token, with native form controls
   matching the actual Atomic positions inputs. Preserve row paddings/colors. */
#structurePanel :is(.cif-atom-header,.cif-thermal-header,
  #cifSpinTable .structure-spin-table-header,
  .structure-style-table .structure-style-header){
  font-size:var(--tas-table-text-size)!important;
  line-height:1.35;
  font-weight:650;
}
#structurePanel :is(.cif-atom-cell,.cif-thermal-cell,
  #cifSpinTable .structure-spin-cell,
  .structure-style-table .structure-style-cell,
  #cifSpinTable .structure-spin-index,
  #cifSpinTable .structure-moment-site,
  .structure-style-table .structure-style-index,
  .cif-thermal-atom-name){
  font-size:var(--tas-table-text-size)!important;
  line-height:1.35;
}
#structurePanel :is(.cif-atom-cell input,.cif-thermal-cell input[type=number],
  #cifSpinTable .structure-spin-value input[type=number],
  .structure-style-table .structure-style-cell select,
  .structure-style-table .structure-style-cell input[type=number]){
  font-size:var(--tas-control-text-size)!important;
}

/* Sidebar: Lattice parameters and Scattering plane use the same heading size. */
.sidebar h3.lattice-parameters-heading{
  font-size:calc(16px * var(--tas-density))!important;
  line-height:1.3;
}

/* hbar-omega / U / V / linear-combination sliders: 4 aligned columns. */
.geometry-sliders{grid-template-columns:max-content minmax(0,1fr) calc(52px * var(--tas-density)) max-content!important;}
.geometry-sliders .geometry-slider-combo{display:contents;}
.geometry-combo-label{display:inline-flex;align-items:center;gap:calc(3px * var(--tas-density));white-space:nowrap;}
.geometry-combo-label input{width:calc(42px * var(--tas-density))!important;min-width:0!important;padding:calc(2px * var(--tas-density)) calc(4px * var(--tas-density));text-align:right;}
#geomComboSetOrigin{padding:calc(2px * var(--tas-density)) calc(8px * var(--tas-density));white-space:nowrap;}
.geometry-sliders .geometry-slider-row > *,
.geometry-sliders .geometry-combo-label input{font-size:max(13px,calc(16px * var(--tas-density)));}
/* Snap 1/n entry and the Constant E map HKL path box (same path as Q vector–E). */
#qePathSnap{width:calc(64px * var(--tas-density))!important;min-width:0!important;text-align:center;}
.qe-path-snap-label{display:inline-flex!important;flex-direction:row!important;align-items:center;gap:calc(3px * var(--tas-density));}
.qe-constant-path-input{margin-top:calc(6px * var(--tas-density));}
.qe-constant-path-input{display:flex!important;align-items:center;gap:calc(6px * var(--tas-density));}
.qe-constant-path-input label{flex:none;}
.qe-constant-path-input input{flex:1 1 auto;width:auto!important;min-width:0!important;}
/* Powder: no map tabs and no HKL path box (beats the display rules above). */
#qePanel .qe-map-tabs.hidden,
#qePanel .qe-constant-path-input.hidden{display:none!important;}

/* Q-E Range fitted to the visible workspace height (see ui-shell.js). */
#qePanel.qe-fit-left #singlePlot,
#qePanel.qe-fit-left #powderPlot,
#qePanel.qe-fit-left #qeVectorPlot{
  height:var(--qe-fit-left)!important;
  min-height:0!important;
}
#qePanel.qe-fit-right #geometryPlot{
  height:var(--qe-fit-right)!important;
  min-height:0!important;
}

/* One accent colour (dark blue) for every slider, checkbox and radio button,
   independent of the browser / OS default accent. */
:root{--tas-accent:#466d98}
input[type=range],input[type=checkbox],input[type=radio]{accent-color:var(--tas-accent)}

/* Script fitted to the visible workspace height (see ui-shell.js): the three
   panes keep their headings/buttons and scroll their lists inside. */
#scriptPanel.script-height-limited .script-workspace{height:var(--script-fit-height);align-items:stretch}
#scriptPanel.script-height-limited :is(.script-aset-pane,.script-command-pane,.script-spice-pane){
  display:flex;flex-direction:column;min-height:0;overflow:hidden;
}
/* The ASET pane carries the sticky-note tab outside its right edge. */
#scriptPanel.script-height-limited .script-aset-pane{overflow:visible}
#scriptPanel.script-height-limited .script-aset-list{flex:1 1 0;min-height:0;max-height:none;overflow-y:auto}
#scriptPanel.script-height-limited #scriptTimeMount{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column}
/* Command list: takes the remaining height and scrolls; the buttons, scan
   times and messages below it stay visible. */
#scriptPanel.script-height-limited #scriptTimeMount>.time-estimate-pane{display:flex!important;flex-direction:column;flex:1 1 0;min-height:0}
#scriptPanel.script-height-limited #scriptTimeMount>.time-estimate-pane>*{flex:0 0 auto}
#scriptPanel.script-height-limited #scriptTimeMount .time-scan-table-wrap{
  flex:0 1 auto;min-height:calc(130px * var(--tas-density));max-height:none;overflow-y:auto;scrollbar-gutter:stable;
}
#scriptPanel.script-height-limited #scriptTimeMount .time-scan-table-wrap .time-scan-header{position:sticky;top:0;z-index:3;background:#f7f7f7}
#scriptPanel.script-height-limited .script-spice-editor{flex:1 1 0;height:auto;min-height:0;max-height:none}
#scriptPanel.script-height-limited :is(.script-pane-heading,.script-message){flex:0 0 auto}

/* Script ASET drawer: a sticky-note tab on the right edge of the open ASET
   pane; when collapsed, a narrow rail ("ASET" + count) takes its place. */
#scriptPanel{--aset-tab-w:max(20px,calc(26px * var(--tas-density)))}
#scriptPanel .script-aset-pane{position:relative}
#scriptPanel .script-workspace:not(.aset-collapsed) .script-command-pane{margin-left:var(--aset-tab-w)}
#scriptPanel .script-aset-tab,
#scriptPanel .script-aset-rail{
  writing-mode:vertical-rl;
  display:flex;align-items:center;justify-content:center;gap:calc(6px * var(--tas-density));
  padding:calc(10px * var(--tas-density)) 0!important;
  border:1px solid var(--tas-accent)!important;
  background:#e8eef5!important;color:#2f4d6e!important;
  font-weight:650;font-size:max(12px,calc(14px * var(--tas-density)))!important;
  line-height:1;cursor:pointer;white-space:nowrap;
}
#scriptPanel .script-aset-tab{
  position:absolute;z-index:4;
  top:calc(44px * var(--tas-density));
  right:calc(-1 * var(--aset-tab-w) - 1px);
  width:var(--aset-tab-w)!important;min-width:0!important;
  border-left:0!important;border-radius:0 calc(8px * var(--tas-density)) calc(8px * var(--tas-density)) 0!important;
}
#scriptPanel .script-aset-rail{display:none!important;min-width:0!important;width:auto!important;
  border-radius:calc(8px * var(--tas-density))!important;justify-content:flex-start;
  padding-top:calc(14px * var(--tas-density))!important}
#scriptPanel .script-aset-tab:hover,#scriptPanel .script-aset-rail:hover{background:#d9e3ee!important}
#scriptPanel .script-aset-rail-count{
  writing-mode:horizontal-tb;min-width:1.6em;text-align:center;
  padding:calc(1px * var(--tas-density)) calc(5px * var(--tas-density));
  border-radius:calc(8px * var(--tas-density));background:#fff;font-size:max(11px,calc(12px * var(--tas-density)));
}
#scriptPanel .script-workspace.aset-collapsed .script-aset-rail{display:flex!important}
@media(min-width:1181px){
  #scriptPanel .script-workspace.aset-collapsed{
    grid-template-columns:var(--aset-rail-w,max(30px,calc(38px * var(--tas-density)))) repeat(2,minmax(0,1fr))!important;
  }
}
/* One-column layout: horizontal bars instead of the vertical tab / rail. */
@media(max-width:1180px){
  #scriptPanel .script-workspace:not(.aset-collapsed) .script-command-pane{margin-left:0}
  #scriptPanel .script-aset-tab{
    position:static;writing-mode:horizontal-tb;width:100%!important;margin-top:calc(8px * var(--tas-density));
    border:1px solid var(--tas-accent)!important;border-radius:calc(6px * var(--tas-density))!important;
    padding:calc(5px * var(--tas-density)) 0!important;
  }
  #scriptPanel .script-aset-rail{writing-mode:horizontal-tb;justify-content:center;padding:calc(6px * var(--tas-density)) 0!important}
}

/* Reflections: Table / Graph view tabs, wrapping option row, plot controls. */
#cifReflectionsPanel > .reflection-view-tabs{margin:0 0 calc(8px * var(--tas-density))}

#structurePanel .magnetic-options.reflection-options{
  grid-auto-flow:row;
  grid-template-columns:repeat(auto-fill,minmax(calc(170px * var(--tas-density)),1fr));
}
#structurePanel .magnetic-options .hidden{display:none!important}
/* Graph controls: a normal row above the plot (never over the axes). */
#structurePanel .reflection-powder-plot-wrap > .reflection-plot-controls{
  position:static;display:flex;flex-wrap:wrap;align-items:center;
  gap:calc(6px * var(--tas-density)) calc(18px * var(--tas-density));
  padding:calc(4px * var(--tas-density)) calc(8px * var(--tas-density)) 0;
  font-size:max(12px,calc(15px * var(--tas-density)));
}
#structurePanel .reflection-plot-xaxis-label{display:inline-flex;flex-direction:row;align-items:center;gap:calc(6px * var(--tas-density));white-space:nowrap;font-size:inherit}
#structurePanel .reflection-plot-controls .reflection-plot-xaxis{position:static;transform:none;width:auto;min-width:0;font-size:inherit}
#structurePanel .reflection-plot-controls .reflection-plot-fwhm{position:static;font-size:inherit}
#structurePanel .reflection-plot-log{display:inline-flex;flex-direction:row;align-items:center;gap:calc(4px * var(--tas-density));white-space:nowrap;font-size:inherit}
#structurePanel .reflection-powder-plot-wrap > .reflection-plot-controls{justify-content:flex-start;align-self:stretch}
#structurePanel .reflection-plot-controls :is(.reflection-plot-log,.reflection-plot-fwhm,.reflection-plot-xaxis-label){
  font-size:max(12px,calc(15px * var(--tas-density)))!important;font-weight:400;margin:0;
}
#structurePanel .reflection-plot-controls :is(input[type=number],select){font-size:max(12px,calc(15px * var(--tas-density)))!important}
/* Keep a usable plot height on narrow windows (margins hold the axis titles and legend). */
#structurePanel .reflection-powder-section .reflection-powder-plot{min-height:calc(440px * var(--tas-density))}

/* Resolution ellipse plots fitted to the visible workspace height (ui-shell.js). */
#resolutionPanel.res-fit #result .plots>div{
  height:var(--res-fit-plot)!important;
}
/* "labels" checkbox right after the Nuclear Bragg peaks legend entry. */
.qe-external-legend .qe-legend-labels,#qePlotLegend .qe-legend-labels{
  display:inline-flex;flex-direction:row;align-items:center;gap:calc(4px * var(--tas-density));
  margin-left:calc(-8px * var(--tas-density));font-size:calc(13px * var(--tas-density));color:#202a37;
  white-space:nowrap;cursor:pointer;
}
.qe-external-legend .qe-legend-labels input,#qePlotLegend .qe-legend-labels input{margin:0;cursor:pointer}

/* Instrument | Type (equal widths) on the first row; Fixed | value | Monochromator | Analyzer on the second. */
.instrument-select-row{
  display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:calc(4px * var(--tas-density)); align-items:end; min-width:0;
}
.instrument-select-row>label,.instrument-select-row select{min-width:0;width:100%;max-width:100%}
.sidebar .instrument-primary-row{
  /* Narrower Fixed/value, wider crystal selectors so "PG(002)" fits. */
  grid-template-columns:minmax(0,.78fr) minmax(0,.92fr) minmax(0,1.15fr) minmax(0,1.15fr);
  margin-top:calc(7px * var(--tas-density));
  margin-bottom:calc(7px * var(--tas-density));
}
.sidebar .instrument-primary-row>label:first-child{grid-column:auto}
@media(max-width:760px){
  .sidebar .instrument-primary-row{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* 4-circle: Dark angle is not available yet; shown greyed out, not editable. */
#darkSection.dark-unavailable .dark-section-content{opacity:.45;filter:grayscale(1);pointer-events:none;user-select:none}
#darkSection.dark-unavailable > h2{color:#9aa0a6}
.dark-unavailable-note{margin:0 0 calc(6px * var(--tas-density));font-size:calc(13px * var(--tas-density));color:#6b7280;font-style:italic}
/* Long type names ("Larmor diffractometer") fit the half-width Type selector. */
.sidebar select#instrumentType{padding-left:3px!important;padding-right:1px!important;letter-spacing:-0.45px}

/* Motor table: one row per motor (name | sign | min | max). */
.motor-limit-table{
  display:grid; grid-template-columns:max-content repeat(3,minmax(0,1fr));
  gap:calc(4px * var(--tas-density)) calc(5px * var(--tas-density)); align-items:center;
  margin-top:calc(6px * var(--tas-density)); min-width:0;
}
.motor-limit-table .hidden{display:none!important}
.motor-limit-table>select,.motor-limit-table>input,.motor-limit-table>output{min-width:0;width:100%;max-width:100%;box-sizing:border-box}
.motor-limit-head{padding-left:2px}   /* same size and colour as the other labels (Fixed, ...) */
.motor-limit-name{font-weight:600;padding-right:calc(4px * var(--tas-density));min-width:calc(22px * var(--tas-density))}
.motor-sign-display{display:block;padding-left:calc(6px * var(--tas-density));color:#555}
.motor-limit-table input[readonly]{background:#f1f3f5;color:#555}
