/* Clinical workspace v3.1 polish: dense professional workbench, no floating overlap. */
body.uxv3{
  --v31-control-h:38px;
  --v31-radius:14px;
  --v31-pad:14px;
}

/* Keep the main workspace visually calm and information-dense. */
body.uxv3 .bp-shell{width:min(1540px,calc(100% - 28px))}
body.uxv3 .ux-context-bar{padding:12px 14px;border-radius:16px;gap:10px}
body.uxv3 .ux-context-line strong{font-size:1rem}
body.uxv3 .ux-context-meta{font-size:.76rem}
body.uxv3 .ux-context-metric{min-width:78px;padding:7px 9px;border-radius:10px}
body.uxv3 .ux-context-metric span{font-size:.59rem}
body.uxv3 .ux-context-metric b{font-size:.84rem}
body.uxv3 .ux-context-actions{gap:6px}
body.uxv3 .ux-context-actions .ux-btn{min-height:36px;padding:7px 10px;font-size:.73rem;border-radius:9px}

body.uxv3 .ux-workspace-shell{
  grid-template-columns:196px minmax(0,1fr) 286px;
  gap:14px;
  margin-top:12px;
}
body.uxv3 .ux-step-rail,body.uxv3 .ux-inspector{top:78px}
body.uxv3 .ux-step-rail{padding:11px;border-radius:15px}
body.uxv3 .ux-step-list{gap:4px;margin-top:7px}
body.uxv3 .ux-step-button{grid-template-columns:30px 1fr;gap:8px;padding:7px;border-radius:10px;min-height:48px}
body.uxv3 .ux-step-button>span{width:28px;height:28px;border-radius:8px;font-size:.68rem}
body.uxv3 .ux-step-button b{font-size:.76rem}
body.uxv3 .ux-step-button small{font-size:.61rem}

body.uxv3 .ux-stage{
  border-radius:17px!important;
  padding:18px!important;
  box-shadow:0 10px 28px rgba(15,23,42,.06)!important;
}
body.uxv3 .ux-stage>h3,body.uxv3 .ux-stage .bp-card-head h2{font-size:1.18rem!important;line-height:1.25}
body.uxv3 .ux-stage>p,body.uxv3 .ux-stage .bp-sub{max-width:78ch;font-size:.79rem!important;line-height:1.55;color:var(--bp-muted)}
body.uxv3 .ux-stage .badge-row{margin-bottom:8px}
body.uxv3 .ux-stage .chip,body.uxv3 .ux-stage .bp-status{font-size:.63rem!important}

/* The screenshots showed primary controls overpowering the scientific content. */
body.uxv3 .ux-stage .bp-btn,
body.uxv3 .ux-stage>.bp-btn,
body.uxv3 .ux-stage .toolbar>.bp-btn{
  min-height:var(--v31-control-h)!important;
  width:auto!important;
  max-width:100%;
  padding:7px 11px!important;
  border-radius:9px!important;
  font-size:.76rem!important;
  line-height:1.1!important;
  font-weight:820!important;
  box-shadow:none!important;
}
body.uxv3 .ux-stage>.bp-btn{display:inline-flex;margin:4px 6px 8px 0}
body.uxv3 .ux-stage .bp-btn-primary{box-shadow:0 5px 14px rgba(8,103,232,.14)!important}
body.uxv3 .ux-stage .toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-start;
  gap:7px;
  width:100%;
  padding:8px;
  margin:8px 0 10px;
  border:1px solid var(--v3-line);
  border-radius:11px;
  background:color-mix(in srgb,var(--bp-surface-soft) 58%,var(--bp-surface));
}
body.uxv3 .ux-stage .toolbar input,
body.uxv3 .ux-stage .toolbar select{
  flex:0 1 250px;
  width:min(250px,100%)!important;
  min-width:150px!important;
  min-height:var(--v31-control-h)!important;
  padding:7px 9px!important;
  border-radius:9px!important;
  font-size:.76rem!important;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  color:var(--bp-muted);
}
body.uxv3 .ux-stage .toolbar .mini{flex:1 1 260px;font-size:.68rem}
body.uxv3 .ux-stage input[placeholder*="_id" i]{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem}
body.uxv3 .ux-stage>.bp-notice.output,
body.uxv3 .ux-stage pre.output{
  margin:8px 0 12px;
  padding:8px 10px;
  min-height:0;
  max-height:150px;
  border-radius:10px;
  font-size:.65rem;
  background:color-mix(in srgb,var(--bp-surface-tint) 45%,var(--bp-surface));
}

/* Friendly forms are the primary interaction; advanced payload is clearly secondary. */
body.uxv3 .ux-form-group,body.uxv3 .ux-array-editor,body.uxv3 .ux-mapping-editor{
  padding:12px;
  margin:10px 0;
  border-radius:13px;
  background:color-mix(in srgb,var(--bp-surface-soft) 35%,var(--bp-surface));
}
body.uxv3 .ux-form-group-head,body.uxv3 .ux-array-head{margin-bottom:8px}
body.uxv3 .ux-form-group-head strong,body.uxv3 .ux-array-head strong{font-size:.84rem}
body.uxv3 .ux-form-grid{gap:8px}
body.uxv3 .ux-field{font-size:.7rem;gap:4px}
body.uxv3 .ux-field input,body.uxv3 .ux-field select,body.uxv3 .ux-field textarea,
body.uxv3 .ux-mini-field input,body.uxv3 .ux-mini-field textarea,body.uxv3 .ux-map-row input{
  min-height:40px;
  padding:8px 9px;
  border-radius:9px;
}
body.uxv3 .ux-field textarea,body.uxv3 .ux-mini-field textarea{min-height:68px}
body.uxv3 .ux-array-card{padding:8px;border-radius:10px;gap:7px}
body.uxv3 .ux-icon-action{min-height:34px;padding:6px 8px}
body.uxv3 .ux-advanced-json{margin-top:12px;padding-top:10px}
body.uxv3 .ux-advanced-json summary{font-size:.68rem}

/* v3 studios read as one scientific workbench, not cards inside cards. */
body.uxv3 .v3-studio{padding:13px;margin:11px 0;border-radius:14px;box-shadow:none}
body.uxv3 .v3-studio-head,body.uxv3 .v3-section-head{margin-bottom:9px;gap:9px}
body.uxv3 .v3-studio-head h3,body.uxv3 .v3-section-head h3{font-size:.92rem}
body.uxv3 .v3-studio-head p{font-size:.68rem;line-height:1.45}
body.uxv3 .v3-coverage b{font-size:1.05rem}
body.uxv3 .v3-protocol-nav{gap:4px;padding-bottom:8px}
body.uxv3 .v3-protocol-nav span{padding:5px 7px;font-size:.59rem}
body.uxv3 .v3-form-grid{gap:7px}
body.uxv3 .v3-field{font-size:.67rem}
body.uxv3 .v3-field input,body.uxv3 .v3-field select,body.uxv3 .v3-field textarea,
body.uxv3 .v3-inline-add input,body.uxv3 .v3-ice-list input,body.uxv3 .v3-ice-list select,
body.uxv3 .v3-ice-list textarea,body.uxv3 .v3-registry input,body.uxv3 .v3-registry select,
body.uxv3 .v3-qwen-embedded textarea,body.uxv3 .v3-search-box input,body.uxv3 .v3-qc-list select{
  min-height:40px;
  padding:7px 9px;
  border-radius:9px;
}
body.uxv3 .v3-studio button,body.uxv3 .v3-decision-cockpit button,body.uxv3 .v3-dialog button{
  min-height:36px;
  padding:7px 10px;
  border-radius:9px;
  font-size:.71rem;
}

/* Right inspector: compact, readable, and never hidden under the global copilot. */
body.uxv3 .ux-inspector{gap:9px;min-width:0}
body.uxv3 .ux-inspector-card{min-width:0;padding:12px;border-radius:14px;box-shadow:0 8px 22px rgba(15,23,42,.05)}
body.uxv3 .ux-inspector-card h3{font-size:.86rem;margin:2px 0 8px;line-height:1.3}
body.uxv3 .ux-inspector-card p,body.uxv3 .ux-inspector-card div{font-size:.7rem}
body.uxv3 .ux-evidence-chip{padding:7px 8px;border-radius:9px}
body.uxv3 .ux-evidence-chip b{font-size:.64rem}
body.uxv3 .ux-evidence-chip small{font-size:.6rem}
body.uxv3 .v3-qwen-embedded textarea{min-height:64px;max-height:96px;margin:6px 0}
body.uxv3 .v3-qwen-embedded>button{
  width:100%!important;
  min-width:0!important;
  min-height:38px!important;
  padding:7px 10px!important;
  border-radius:9px!important;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#fff!important;
}
body.uxv3 .v3-qwen-shortcuts button{width:100%;min-width:0;min-height:30px;padding:6px 0;font-size:.66rem;white-space:normal}
body.uxv3 .ux-qwen-card a{font-size:.69rem;padding:7px 0;overflow-wrap:anywhere}

/* Dense clinical pages already have embedded Qwen; keep the global launcher available but unobtrusive. */
body.uxv3 .bp-copilot-launcher{
  right:max(.8rem,env(safe-area-inset-right));
  bottom:max(.8rem,env(safe-area-inset-bottom));
  width:48px;
  height:48px;
  min-width:48px;
  min-height:48px;
  padding:0;
  gap:0;
  justify-content:center;
  border-radius:14px;
  box-shadow:0 10px 30px rgba(11,65,46,.22);
}
body.uxv3 .bp-copilot-launcher-label{display:none!important}
body.uxv3 .bp-copilot-launcher-icon{width:38px;height:38px;background:transparent;font-size:.9rem}
body.uxv3 .bp-copilot-panel{right:max(.8rem,env(safe-area-inset-right));bottom:max(.8rem,env(safe-area-inset-bottom))}

/* Cleaner next-action and decision surfaces. */
body.uxv3 .ux-next-action{padding:11px 13px;border-radius:14px;margin:9px 0;gap:10px}
body.uxv3 .ux-next-action strong{font-size:.88rem}
body.uxv3 .ux-next-action p{font-size:.69rem}
body.uxv3 .ux-decision-board{gap:9px;margin:9px 0}
body.uxv3 .ux-decision-copy,body.uxv3 .ux-decision-board .ux-next-action{padding:13px;border-radius:14px}
body.uxv3 .v3-truth-banner{padding:10px 12px;border-radius:14px;margin:8px 0 11px}
body.uxv3 .v3-truth-banner strong{font-size:.86rem}
body.uxv3 .v3-truth-banner p{font-size:.68rem}
body.uxv3 .v3-truth-actions button{min-height:34px;padding:6px 9px;font-size:.67rem}

/* Responsive behavior: never squeeze the inspector into a narrow, overlapping third column. */
@media(max-width:1180px){
  body.uxv3 .ux-workspace-shell{grid-template-columns:184px minmax(0,1fr)}
  body.uxv3 .ux-inspector{
    grid-column:1/-1;
    position:static;
    grid-template-columns:repeat(2,minmax(0,1fr));
    align-items:start;
  }
  body.uxv3 .v3-qwen-embedded{grid-column:1/-1;display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.55fr);column-gap:12px;align-items:start}
  body.uxv3 .v3-qwen-embedded>.ux-eyebrow,body.uxv3 .v3-qwen-embedded>h3{grid-column:1/-1}
  body.uxv3 .v3-qwen-embedded textarea{grid-column:1/2;grid-row:3/5;min-height:86px}
  body.uxv3 .v3-qwen-embedded>button{grid-column:2/3;grid-row:3/4}
  body.uxv3 .v3-qwen-shortcuts{grid-column:2/3;grid-row:4/5;margin-top:0}
}

@media(max-width:900px){
  body.uxv3 .bp-shell{width:min(100% - 20px,1540px)}
  body.uxv3 .ux-context-bar{grid-template-columns:1fr;align-items:start}
  body.uxv3 .ux-context-metrics,body.uxv3 .ux-context-actions{justify-content:flex-start}
  body.uxv3 .ux-context-metric{min-width:72px}
  body.uxv3 .ux-inspector{grid-template-columns:1fr}
  body.uxv3 .v3-qwen-embedded{display:block}
  body.uxv3 .v3-qwen-embedded textarea{min-height:68px}
  body.uxv3 .ux-stage .toolbar{align-items:stretch}
  body.uxv3 .ux-stage .toolbar input,body.uxv3 .ux-stage .toolbar select{flex:1 1 190px;width:auto!important}
}

@media(max-width:820px){
  body.uxv3 .ux-workspace-shell{grid-template-columns:1fr;gap:10px}
  body.uxv3 .ux-step-rail{position:static;padding:9px}
  body.uxv3 .ux-step-list{display:flex;overflow-x:auto;gap:5px;padding-bottom:2px}
  body.uxv3 .ux-step-button{flex:0 0 170px;min-height:46px}
  body.uxv3 .ux-stage{padding:14px!important;border-radius:14px!important}
  body.uxv3 .ux-form-grid,body.uxv3 .v3-form-grid{grid-template-columns:1fr}
  body.uxv3 .ux-field-wide,body.uxv3 .v3-field.wide{grid-column:auto}
  body.uxv3 .ux-array-card{grid-template-columns:1fr 1fr}
  body.uxv3 .ux-array-card .ux-icon-action{grid-column:1/-1;justify-self:start}
  body.uxv3 .v3-ice-list article{grid-template-columns:1fr}
  body.uxv3 .v3-data-metrics,body.uxv3 .v3-work-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  body.uxv3 .v3-profile-grid,body.uxv3 .v3-validation-grid,body.uxv3 .v3-diagnostic-grid{grid-template-columns:1fr}
  body.uxv3 .bp-copilot-launcher{width:44px;height:44px;min-width:44px;min-height:44px;border-radius:13px}
}

@media(max-width:520px){
  body.uxv3 .bp-shell{width:min(100% - 14px,1540px)}
  body.uxv3 .ux-stage{padding:12px!important}
  body.uxv3 .ux-stage .toolbar{display:grid;grid-template-columns:1fr;padding:7px}
  body.uxv3 .ux-stage .toolbar>.bp-btn,body.uxv3 .ux-stage .toolbar>input,body.uxv3 .ux-stage .toolbar>select{width:100%!important;max-width:none}
  body.uxv3 .ux-stage>.bp-btn{width:100%!important;margin-right:0}
  body.uxv3 .v3-data-metrics,body.uxv3 .v3-work-metrics{grid-template-columns:1fr}
  body.uxv3 .v3-truth-banner{display:grid}
  body.uxv3 .v3-truth-actions{justify-content:flex-start}
}
