/*
 * Workbench control sizing baseline.
 *
 * Short, single-line business fields follow their current value or placeholder.
 * Long text fields follow their longest line and grow vertically with content.
 * Search/file surfaces keep the available row width because they are working
 * areas rather than compact business values. Every control is clamped to its
 * container so the same rule remains safe on desktop and mobile.
 */
:root{
  --workbench-control-min-inline:min(10ch,100%);
  --workbench-control-max-block:16rem;
}

body :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]):not([type="hidden"]):not([type="image"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="search"]),
  select
){
  box-sizing:border-box;
  inline-size:fit-content!important;
  width:fit-content!important;
  min-inline-size:var(--workbench-control-min-inline)!important;
  max-inline-size:100%!important;
  block-size:auto!important;
  height:auto!important;
  min-block-size:0!important;
  min-height:0!important;
  field-sizing:content;
}

body input:is([type="number"],[type="time"]){
  --workbench-control-min-inline:min(7ch,100%);
}

body input:is([type="date"],[type="month"],[type="week"],[type="datetime-local"]){
  --workbench-control-min-inline:min(11ch,100%);
}

body textarea{
  box-sizing:border-box;
  inline-size:fit-content!important;
  width:fit-content!important;
  min-inline-size:min(18ch,100%)!important;
  max-inline-size:100%!important;
  block-size:auto!important;
  height:auto!important;
  min-block-size:calc(1lh + 20px)!important;
  min-height:calc(1lh + 20px)!important;
  max-block-size:var(--workbench-control-max-block)!important;
  max-height:var(--workbench-control-max-block)!important;
  overflow:auto;
  field-sizing:content;
}

/* Explicit, documented opt-outs for true work surfaces. */
body :is(input[type="search"],input[type="file"],[data-field-size="fill"],.adaptive-field-fill){
  inline-size:100%!important;
  width:100%!important;
  max-inline-size:100%!important;
}

/* Explicit compact marker for generated controls whose module CSS is stronger. */
body :is([data-field-size="content"],.adaptive-field-content){
  inline-size:fit-content!important;
  width:fit-content!important;
  min-inline-size:0!important;
  max-inline-size:100%!important;
  block-size:auto!important;
  height:auto!important;
  min-block-size:0!important;
  min-height:0!important;
  field-sizing:content;
}

body :is(label,.form-grid>*),
body :is(td,th){
  min-inline-size:0;
}

@media(max-width:700px){
  body :is(input,select,textarea){max-inline-size:100%!important}
}
