* {
  box-sizing: border-box;
}

html {
  position: fixed;
  height: 100%;
  width: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior-x: none;
}

body {
  position: relative;
  height: 100%;
  width: 100%;
  font-family: Raleway, sans-serif;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background-color: #e0e0e0;
  overflow: hidden;
}

h1 {
  font-weight: 900;
}

code {
  font-family: monospace;
}

#topbar {
  position: absolute;
  top: 0;
  height: 50px;
}

#display-panel {
  position: absolute;
  top: 50px;
  bottom: 65px;
}

.multi #display-panel {
  bottom: 50%;
}

#input-panel {
  position: absolute;
  bottom: 0;
  height: 65px;
}

.multi #input-panel {
  height: 50%;
}

#topbar, #display-panel, #input-panel {
  left: 0;
  right: 400px;
}

[dir=rtl] #topbar, [dir=rtl] #display-panel, [dir=rtl] #input-panel {
  right: 0;
  left: 400px;
}


#sidebar-header {
  position: absolute;
  width: 400px;
  top: 0;
  height: 120px;
}

#sidebar {
  position: absolute;
  width: 400px;
  top: 120px;
  bottom: 0;
  overflow: hidden;
}

#sidebar-header, #sidebar {
  left: auto;
  right: 0;
}

[dir=rtl] #sidebar-header, [dir=rtl] #sidebar {
  right: auto;
  left: 0;
}

.panel {
  overflow: hidden;
}

.inner {
  position: absolute;
  margin: 0;
  padding: 0;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
}

/* Header */

#topbar {
  white-space: nowrap;
  padding-left: 8pt;
}

#topbar h1,
#topbar-links,
#topbar-altlinks {
  margin: 2pt;
  display: inline-block;
}

#topbar-altlinks {
  display: none;
}

/* Side Bars */

#sidebar-header ul {
  margin: 5px 10px;
  padding: 0;
}

#sidebar-header ul li {
  list-decoration: none;
}

#sidebar #about,
#sidebar #reference,
#sidebar #examples,
#sidebar #history,
#sidebar #links,
#sidebar #extras,
#sidebar #library {
  border: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: none;
  overflow-x: hidden;
  overflow-y: auto;
}

#sidebar.about #about,
#sidebar.reference #reference,
#sidebar.examples #examples,
#sidebar.history #history,
#sidebar.library #library,
#sidebar.extras #extras,
#sidebar.links #links {
  display: block;
}

.snippet pre {
  white-space: pre-wrap;
  margin-top: 0;
  margin-bottom: 5px;
  padding: 2px;
  background-color: #eeeeee;
  font-family: monospace;
}

.snippet pre:hover {
  background-color: white;
}

#links ul {
  padding-left: 20px;
}

#links ul li {
  margin-bottom: 5px;
}

#library,
#history,
#examples,
#extras,
#links {
  margin: 10px;
}

#about, #reference {
  width: 100%;
  height: 100%;
}

/* Graphical and Textual Display */

#display {
  position: absolute;
  overflow: hidden;
  top: 5px;
  bottom: 5px;
  border: none;
  border-radius: 5px;
  background-color: white;
  left: 10px;
  right: 5px;
}

[dir=rtl] #display {
  right: 10px;
  left: 5px;
}

#display #error {
  position: absolute;
  padding: 3px 20px;
  bottom: 0;
  border-radius: 2px;

  font-size: 14pt;
  font-weight: bold;
  color: white;
  background-color: #e01010;
  display: none;
  z-index: 9999;
  left: 0;
  right: auto;
}

[dir=rtl] #display #error {
  right: 0;
  left: auto;
}

#display #error.shown {
  display: block;
}

#sandbox span {
  /* Error in case of no canvas */
  color: red;
  background-color: yellow;
  font-weight: bold;
}

#floor {
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  position: absolute;
}

#overlay {
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  padding: 10px;
  margin: 0;
  position: absolute;
  z-index: 2;
  background-color: transparent;
  overflow: hidden;
  white-space: pre-wrap;
  font-family: monospace;
}

#overlay, #error {
  pointer-events: none;
}

/* User Input */

#input {
  position: absolute;
  overflow: hidden;
  top: 5px;
  bottom: 10px;
  border: 1px solid black;
  border-radius: 5px;
  color: black;
  background-color: white;
  left: 10px;
  right: 85px;
}

[dir=rtl] #input {
  right: 10px;
  left: 85px;
}


#logo-cm-multi-line,
#logo-cm-single-line,
#logo-ta-single-line,
#logo-ta-multi-line {
  position: absolute;
  overflow: hidden;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  font-family: monospace;
  display: none;
}

.single #logo-cm-single-line,
.single #logo-ta-single-line,
.multi #logo-cm-multi-line,
.multi #logo-ta-multi-line {
  display: block;
}

#input #toggle {
  cursor: pointer;

  position: absolute;
  overflow: hidden;
  z-index: 1000;
  top: 1px;
  width: 20px;
  height: 20px;
  text-shadow: 0 0 1px black;
  left: auto;
  right: 1px;
}

[dir=rtl] #input #toggle {
  right: auto;
  left: 1px;
}

.single #toggle #collapse-label {
  display: none;
}

.multi #toggle #expand-label {
  display: none;
}

#run, #stop, #clear {
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

  position: absolute;
  border: 1px solid black;
  border-radius: 5px;
  background-color: white;
}

#run, #stop {
  top: 5px;
  bottom: 35px;
  width: 70px;
}

#run, #stop {
  top: 5px;
  bottom: 35px;
  width: 70px;
}

#run {
  display: block;
}

#stop {
  display: none;
}

.running #run {
  display: none;
}

.running #stop {
  display: block;
}

#clear {
  height: 19px;
  bottom: 10px;
  width: 70px;
}

#run, #stop, #clear {
  right: 5px;
  left: auto;
}

[dir=rtl] #run, [dir=rtl] #clear, [dir=rtl] #stop {
  left: 5px;
  right: auto;
}

#run:hover, #clear:hover, #stop:hover {
  background-color: #eeeeee;
}

#run .label, #clear .label, #stop .label {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  height: 20px;
  text-align: center;
  display: block;
}

#history .placeholder {
  text-align: center;
  font-style: italic;
  padding: 50px;
}

#history .snippets:not(:empty) + .placeholder {
  display: none;
}


@media only screen and (max-width: 1000px) {
  #topbar-links {
    display: none;
  }
}

@media only screen and (max-width: 800px) {
  #topbar, #display-panel, #input-panel {
    left: 0;
    right: 200px;
  }

  [dir=rtl] #topbar, [dir=rtl] #display-panel, [dir=rtl] #input-panel {
    right: 0;
    left: 200px;
  }

  #sidebar-header, #sidebar {
    width: 200px;;
  }

  .linkdesc {
    display: none;
  }
}

@media only screen and (max-width: 600px) {
  #topbar, #display-panel, #input-panel {
    left: 0;
    right: 0;
  }

  [dir=rtl] #topbar, [dir=rtl] #display-panel, [dir=rtl] #input-panel {
    right: 0;
    left: 0;
  }

  #sidebar-header, #sidebar {
    display: none;
  }

  #topbar-altlinks {
    display: inline-block;
  }

  #topbar h1 {
    font-size: 14pt;
  }

  #topbar {
    height: 28px;
  }

  #display-panel {
    top: 28px;
  }
}

@media only screen and (max-width: 420px) {
  #run, #stop {
    height: auto;
    bottom: 10px;
  }

  #clear {
    display: none;
  }
}
