/* The playground's whole stylesheet: no framework, no build step. */

:root {
  --bg: #10131a;
  --bg-raised: #171b24;
  --bg-input: #0c0f15;
  --border: #262c39;
  --fg: #d7dce5;
  --fg-dim: #8a93a5;
  --accent: #63b3ff;
  --ok: #64d29a;
  --error: #ff7b72;
  --warn: #e3b341;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-raised: #ffffff;
    --bg-input: #ffffff;
    --border: #d9dde5;
    --fg: #1c2430;
    --fg-dim: #5d6675;
    --accent: #0b62c4;
    --ok: #157f4a;
    --error: #c0392b;
    --warn: #9a6b00;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

code {
  font-family: var(--mono);
}

/* ---------------------------------------------------------------- header */

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.header h1 .sub {
  color: var(--fg-dim);
  font-weight: 400;
}

.tagline {
  margin: 2px 0 0;
  color: var(--fg-dim);
  font-size: 13px;
}

.links {
  display: flex;
  gap: 14px;
  font-size: 13px;
}

.note {
  margin: 0;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg-dim);
  font-size: 12.5px;
}

/* ----------------------------------------------------------------- panes */

.panes {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane-editor {
  border-right: 1px solid var(--border);
}

.pane-head,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  min-height: 38px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.pane-head label {
  color: var(--fg-dim);
  font-size: 12.5px;
}

select {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 6px;
  font: inherit;
  font-size: 13px;
  max-width: 60%;
}

/* The Run button sits with the example picker, not with the tabs: it acts on
   what is in the editor. */
.run {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-input);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.run:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.run:disabled {
  color: var(--fg-dim);
  cursor: default;
}

.hint {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 12px;
  white-space: nowrap;
}

.editor {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--bg-input);
}

/* The <textarea> the page falls back to when the CodeMirror CDN is
   unreachable, and CodeMirror itself, share the same box. */
.editor textarea,
.editor .cm-editor {
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 8px 10px;
  background: var(--bg-input);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 4;
}

.cm-editor {
  padding: 0;
}

.cm-editor .cm-scroller {
  font-family: var(--mono);
  line-height: 1.55;
}

.cm-editor.cm-focused {
  outline: none !important;
}

.example-description {
  margin: 0;
  padding: 5px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg-dim);
  font-size: 12px;
  min-height: 26px;
}

/* ------------------------------------------------------------------ tabs */

.tabs {
  gap: 2px;
  overflow-x: auto;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: 13px;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--fg);
}

.tab[aria-selected="true"] {
  color: var(--fg);
  background: var(--bg-input);
  border-color: var(--border);
}

.badge {
  margin-left: 6px;
  color: var(--error);
  font-variant-numeric: tabular-nums;
}

.panels {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.panel {
  margin: 0;
  height: 100%;
  overflow: auto;
  padding: 8px 10px;
  background: var(--bg-input);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
}

.panel[hidden] {
  display: none;
}

.panel.empty {
  color: var(--fg-dim);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------- program output */

/* What the program wrote to fd 2, told apart from its stdout without
   reordering the two: they share one pane, in the order they were written. */
.stream-err {
  color: var(--error);
}

/* The playground's own commentary in the Output pane — the exit line, the
   10 s termination note — never the program's own output. */
/* Inline, not a block: the note carries its own newlines so that it lands on
   its own line inside the <pre> without a blank one around it. */
.run-note {
  color: var(--fg-dim);
  font-style: italic;
}

.run-note.ok {
  color: var(--ok);
  font-style: normal;
}

.run-note.bad {
  color: var(--error);
  font-style: normal;
}

/* ------------------------------------------------------------ status bar */

.status {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
}

.status .state.ok {
  color: var(--ok);
}

.status .state.error {
  color: var(--error);
}

.status .state.busy {
  color: var(--warn);
}

.timings {
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 800px) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 45vh) minmax(220px, 1fr);
  }

  .pane-editor {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .hint {
    display: none;
  }

  .links {
    font-size: 12px;
  }
}
