@include _number.regexp
@word /[A-Za-z_-][A-Za-z0-9_-]*/

$(UNICODE)=\\[0-9a-fA-F]{1,6}(\r\n|[ \n\r\t\f])?
$(ESCAPE)=$(UNICODE)|\\[^\n\r\f0-9a-f]
$(NONASCII)=[^\0-\177]
$(NMSTART)=([_a-zA-Z]|$(NONASCII)|$(ESCAPE))
$(NMCHAR)=([_a-zA-Z0-9-]|$(NONASCII)|$(ESCAPE))
$(NAME)=$(NMCHAR)+
$(IDENT)=[-]*$(NMSTART)$(NMCHAR)*
$(INTEGER)=([0-9]+)
$(SYMBOL)=([A-Za-z][A-Za-z0-9]*)

@include webpage.include

documentation:
  from /** to */

comment:
  from /* to */

atrule{AtRule=Preprocessor}:
  match /@$(IDENT)/
  atrule2{AtRule}:
    between here and {

class{Class=Datatype}:
  match /\.$(IDENT)/

id{Id=Operator}:
  match /#$(IDENT)/

pseudoclass{PseudoClass=String}:
  match /:(active|after|any-link|auto-fill|before|checked|default|defined|dir|disabled|empty|enabled|first-child|first-of-type|first|focus-visible|focus-within|focus|fullscreen|has|hover|in-range|indeterminate|invalid|is|lang|last-child|last-of-type|left|link|modal|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|optional|out-of-range|placeholder-shown|popover-open|read-only|read-write|required|right|root|scope|state|target|user-invalid|user-valid|valid|visited|where)/

pseudoelement{PseudoElement=String}:
  match /::$(IDENT)/

identifier{Keyword}:
  keyword @css.property
  match /--$(IDENT)/
  match /$(SYMBOL)-$(IDENT)/
...property{Operator}:
  from : to ;
  @include webpage.include
  color{Color=String}:
    match /#[0-9A-Fa-f]{6}/
    match /#[0-9A-Fa-f]{3}/
    match /rgb\($(INTEGER),$(INTEGER),$(INTEGER)(,$(NUMBER))?\)/
    match /rgba\($(INTEGER),$(INTEGER),$(INTEGER),$(NUMBER)\)/
    match /hsl\($(INTEGER),$(INTEGER)%,$(INTEGER)%(,$(NUMBER))?\)/
    match /hsla\($(INTEGER),$(INTEGER)%,$(INTEGER)%,$(NUMBER)\)/
    keyword(ignorecase) @css.color
  number:
    match /$(NUMBER)($(IDENT)|%)?/
  important{Important=Constant}:
    match "!important"
  function:
    keyword var calc
  value{Symbol}:
    keyword @css.value
  specialvalue{Function}:
    match /--$(IDENT)/
  identifier{Symbol}:
    match /$(IDENT)/
  string:
    from " to "
    from ' to '
    string.escape{Escape}:
      match /$(ESCAPE)/
  operator:
    symbol ( ) ,

tag{Tag=Constant}:
  match /$(SYMBOL)/
type{TagAttribute=Keyword}:
  from [ to ]
  string{TagAttribute}:
    from ' to '
special{Constant}:
  symbol * &
operator:
  symbol > , + }
block{Operator}:
  limit
  match {
