:root {
  --page: #f6f5f1;
  --editor: #ffffff;
  --panel: #ffffff;
  --text: #1d1f22;
  --faint: #8a8f98;
  --line: #dddbd3;
  /* The cursor's line: translucent, since CodeMirror draws a selection
     behind the text. Over --editor, it's #f3f1ea. */
  --active: rgba(195, 185, 150, 0.2);
  --selection: #d7e4f7;
  --accent: #2458c6;
  --accent-text: #ffffff;
  --error: #b3261e;
  --keyword: #8739b8;
  --number: #1a7f5a;
  --string: #a6541b;
  --comment: #7c828c;
  --type: #1f6fa8;
  --function: #3d4ea6;
  --meta: #b0306e;
  --operator: #5b616b;
  --same: #e8e2c8;
  --code-bg: #efece3;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #16181c;
    --editor: #1d2025;
    --panel: #23262c;
    --text: #e3e5e8;
    --faint: #7d838d;
    --line: #33373e;
    --active: rgba(59, 65, 74, 0.3); /* #262a30 over --editor */
    --selection: #2f4466;
    --accent: #6d9cf2;
    --accent-text: #0f1726;
    --error: #ff8a80;
    --keyword: #c792ea;
    --number: #7fd4a8;
    --string: #f0b37e;
    --comment: #7f8791;
    --type: #7cc4f0;
    --function: #9fb0ff;
    --meta: #f08bbd;
    --operator: #a6adb8;
    --same: #3a3a2a;
    --code-bg: #262a30;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
h1 span { color: var(--faint); font-weight: 450; }

select, input, button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
}

#examples { max-width: min(460px, 100%); }
input[type="number"] { width: 7.5em; }
input[type="checkbox"] { padding: 0; }

.actions { display: flex; gap: 8px; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.options { position: relative; }
.options summary { cursor: pointer; color: var(--faint); padding: 5px 0; }
.options .panel {
  position: absolute;
  z-index: 10;
  right: 0;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.14);
}
.options label { display: flex; align-items: center; gap: 8px; }
#sampling { display: flex; gap: 12px; }
#sampling[hidden] { display: none; }

main {
  display: grid;
  /* The editor's share, which the divider changes. */
  grid-template-columns: minmax(0, calc(var(--share, 52%) - 3px)) 6px minmax(0, 1fr);
  min-height: 0;
}

#editor { min-height: 0; overflow: hidden; }
#divider { cursor: col-resize; background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; touch-action: none; }
#divider:hover, #divider:focus-visible, #divider.dragging { background-image: linear-gradient(var(--accent), var(--accent)); background-size: 2px 100%; outline: none; }
#editor .cm-editor { height: 100%; font-size: 14px; }
#editor .cm-scroller { font-family: var(--mono); line-height: 1.5; }
#editor .cm-focused { outline: none; }

#side { display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--faint);
  padding: 8px 10px 6px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pane { flex: 1; min-height: 0; overflow: auto; }
.pane[hidden] { display: none; }
#output:not([hidden]) { display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 12px; min-height: 38px; padding: 8px 16px; color: var(--faint); font-size: 14px; }
progress { flex: 0 1 200px; }

pre {
  margin: 0;
  padding: 4px 16px 16px;
  font: 13.5px/1.5 var(--mono);
  white-space: pre;
  overflow-x: auto;
}
#printed { color: var(--faint); border-bottom: 1px dashed var(--line); padding-bottom: 10px; margin-bottom: 8px; }
#result.error { color: var(--error); }
/* A report too long for the pane wraps at its ` · ` separators, under its
   values. */
#result .line {
  --indent: min(var(--hang), 40%); /* a long label leaves room for the values */
  display: block;
  white-space: pre-wrap;
  padding-left: var(--indent);
  text-indent: calc(-1 * var(--indent));
}
#result .item { white-space: pre; }
#empty { margin: 0; padding: 4px 16px; color: var(--faint); max-width: 60ch; }
#empty[hidden] { display: none; }
kbd { font: 0.92em var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
button.link { font: inherit; color: var(--accent); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }

/* Probl's tokens: in the editor, the guide's programs and the
   descriptions of names. */
.tok-keyword { color: var(--keyword); }
.tok-number { color: var(--number); }
.tok-string { color: var(--string); }
.tok-comment { color: var(--comment); font-style: italic; }
.tok-type { color: var(--type); }
.tok-function { color: var(--function); }
.tok-meta { color: var(--meta); }
.tok-operator { color: var(--operator); }

/* The guide: the language overview. */
#guide { padding: 4px 22px 40px; line-height: 1.55; }
#guide h1 { font-size: 22px; margin: 18px 0 8px; }
#guide h2 { font-size: 18px; margin: 28px 0 8px; padding-top: 8px; border-top: 1px solid var(--line); }
#guide h3 { font-size: 15.5px; margin: 20px 0 6px; }
#guide p, #guide li { max-width: 72ch; }
#guide code { font-family: var(--mono); font-size: 0.92em; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
#guide pre { background: var(--code-bg); border-radius: 8px; padding: 10px 14px; margin: 0; overflow-x: auto; }
#guide pre code { background: none; padding: 0; font-size: 13px; }
#guide figure { margin: 12px 0; }
#guide button.try { margin-top: 6px; font-size: 13px; padding: 3px 10px; }
#guide table { border-collapse: collapse; margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
#guide th, #guide td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
#guide blockquote { margin: 12px 0; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--faint); }
#guide a { color: var(--accent); }
#guide .contents { margin: 16px 0; padding: 10px 16px 12px; background: var(--code-bg); border-radius: 8px; }
#guide .contents p { margin: 0 0 6px; font-weight: 600; }
#guide .contents ul { margin: 0; padding: 0; list-style: none; columns: 2 16em; column-gap: 28px; }
#guide .contents li { margin: 2px 0; break-inside: avoid; }
#guide .contents a { text-decoration: none; }
#guide .contents a:hover { text-decoration: underline; }

/* The reference. */
#reference { padding: 12px 18px 40px; }
#search { width: 100%; }
#reference .hint { color: var(--faint); font-size: 13.5px; margin: 10px 0 0; }
#reference h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); margin: 22px 0 6px; }
#reference section[hidden], #reference .entry[hidden] { display: none; }
#reference .entry.current { border-left: 3px solid var(--accent); margin-left: -13px; padding-left: 10px; }
#reference .entry.current .signature { color: var(--accent); }
.entry { padding: 7px 0; border-bottom: 1px solid var(--line); }
.entry .signature { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.entry p { margin: 3px 0 0; font-size: 14px; }
.entry p code, .cm-probl-doc code { font-family: var(--mono); font-size: 0.92em; background: var(--code-bg); padding: 0 3px; border-radius: 3px; }

/* Hovering and completing in the editor. */
.cm-probl-card { padding: 6px 10px; max-width: 460px; font: 13.5px/1.45 system-ui, sans-serif; }
.cm-probl-signature { display: block; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.cm-probl-signature-help b { color: var(--accent); }
.cm-probl-what { color: var(--faint); font-size: 12px; margin-top: 2px; }
.cm-probl-doc { margin-top: 5px; white-space: pre-wrap; }
.cm-tooltip.cm-completionInfo { padding: 0; }

footer { padding: 8px 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }

@media (max-width: 760px) {
  body { grid-template-rows: auto auto auto; height: auto; min-height: 100%; }
  #examples { flex: 1 1 100%; width: 100%; min-width: 0; max-width: none; }
  main { grid-template-columns: minmax(0, 1fr); }
  #divider { display: none; }
  #editor { height: 55vh; border-right: none; border-bottom: 1px solid var(--line); }
  #output { min-height: 40vh; }
  .options .panel { right: auto; left: 0; }
}
