body {
  margin: 0;
  overflow: hidden;
  font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Oxygen,
  Ubuntu, Cantarell, Roboto, "Open Sans", "Helvetica Neue", sans-serif;

  color-scheme: dark;
  color: #E1E2EB;
  background-color: #121316;
  --container-color: #44474E;
  --primary-color: #ADC6FF;
  --primary-on-color: #002E68;
  --surface-container-color: #1F1F23;
  --secondary-container-color: #3F4759;
  --secondary-on-container-color: #DAE2F9;
}

@media (prefers-color-scheme: light) {
  body {
    color-scheme: light;
    color: #191B22;
    background-color: #FAF8FD;
    --container-color: #E1E2EB;
    --primary-color: #005BC0;
    --primary-on-color: #FFFFFF;
    --surface-container-color: #EFEDF2;
    --secondary-container-color: #DAE2F9;
    --secondary-on-container-color: #131B2C;
  }
}

body > * {
  position: fixed;
}

body > canvas {
  /* no selection of canvas */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */
}

body > #app-text-field {
  opacity: 0;
  top: -10px;
  left: -10px;
  width: 0;
  height: 0;
}

body > #app-crash-dialog {
  width: 100vw;
  height: 100vh;
  top: 0;
  background-color: inherit;
  overflow: auto;
  padding: 8px;
}

/* Loader: */

#app-wasm-loader {
  top: 0;
  left: 0;
  z-index: 1000;
  width: calc(100vw - 2em);
  height: calc(100vh - 2em);
  overflow: hidden;

  display: flex;
  flex-direction: column;
  gap: 1em;
  padding: 1em;
}

#app-wasm-loader-header {
  display: flex;
  align-items: center;
  column-gap: 1em;
}

#app-wasm-loader-icon {
  width: 5em;
  height: 5em;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

#app-wasm-loader-title {
  font-size: 24px;
}

#app-wasm-loader-label {
  font-size: 16px;
}

#app-wasm-loader-progress {
  flex-grow: 1;

  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  height: 1em;
  border-radius: 100px;
  color: var(--primary-color);
  background-color: var(--container-color);
}

#app-wasm-loader-progress::-webkit-progress-bar {
  border-radius: 100px;
  background-color: var(--container-color);
}

#app-wasm-loader-progress::-webkit-progress-value {
  border-radius: 100px;
  background-color: var(--primary-color);
}

#app-wasm-loader-progress::-moz-progress-bar {
  border-radius: 100px;
  background-color: var(--primary-color);
}

/* Without a known progress, a band moves along the bar. */
#app-wasm-loader-progress:indeterminate {
  background: linear-gradient(90deg, var(--container-color) 25%, var(--primary-color) 50%, var(--container-color) 75%) 0 0 / 300% 100%;
  animation: app-wasm-loader-loading 1.5s linear infinite;
}

#app-wasm-loader-progress:indeterminate::-webkit-progress-bar {
  background: transparent;
}

#app-wasm-loader-progress:indeterminate::-moz-progress-bar {
  background: transparent;
}

@keyframes app-wasm-loader-loading {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: 0 0;
  }
}

#app-wasm-loader > main,
#app-wasm-loader > content {
  overflow: auto;
}

/* This reset is for the loader chrome and the automatically pre-rendered
   preview, which carries its own inline styles. A custom index page is
   excluded, as it needs normal browser defaults. */
#app-wasm-loader *:not(#app-index, #app-index *) {
  border: unset;
  margin-block: unset;
  font-family: unset;
}

#app-wasm-loader textarea {
  font-family: Roboto Mono, monospace;
  font-size: 16px;
}

/* Custom index page (index.html / index.md): */

#app-index {
  flex: 1;
  min-height: 0; /* required, or a flex child will not shrink and will not scroll */
  overflow: auto;
  max-width: 55em;
  margin-inline: auto;
  line-height: 1.6;
}

/* These defaults are wrapped in :where() so that they contribute zero
   specificity, which means that any styles in the custom index page itself
   override them. */

:where(#app-index) :where(h1, h2, h3, h4, h5, h6) {
  line-height: 1.25;
}

:where(#app-index) :where(a) {
  color: var(--primary-color);
}

:where(#app-index) :where(code, pre) {
  font-family: Roboto Mono, monospace;
  background-color: var(--surface-container-color);
  border-radius: 4px;
}

:where(#app-index) :where(code) {
  padding: 0.1em 0.3em;
}

:where(#app-index) :where(pre) {
  padding: 0.75em;
  overflow-x: auto;
}

:where(#app-index) :where(pre code) {
  padding: 0;
  background: none;
}

:where(#app-index) :where(blockquote) {
  margin-inline: 0;
  padding-inline-start: 1em;
  border-inline-start: 4px solid var(--container-color);
}

:where(#app-index) :where(table) {
  border-collapse: collapse;
}

:where(#app-index) :where(th, td) {
  border: 1px solid var(--container-color);
  padding: 0.4em 0.6em;
}

:where(#app-index) :where(img, svg, video) {
  max-width: 100%;
  height: auto;
}

:where(#app-index) :where(hr) {
  border: none;
  border-block-start: 1px solid var(--container-color);
}

/* The loader chrome becomes a compact strip when a custom index page is the
   content, instead of a full loading screen. */

#app-wasm-loader.has-index #app-wasm-loader-icon {
  width: 2em;
  height: 2em;
}

#app-wasm-loader.has-index #app-wasm-loader-title {
  font-size: 16px;
}

#app-wasm-loader.has-index #app-wasm-loader-label {
  font-size: 12px;
  opacity: 0.7;
}

#app-wasm-loader.has-index #app-wasm-loader-progress {
  height: 0.35em;
}
