:root {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --line: #d8d8dc;
  --panel: #f6f6f8;
  --error: #b3261e;
  --warning: #8a5a00;
  --ok: #1b6e3c;
  --active: #f0f0f4;
  --syntax-keyword: #7a1fa2;
  --syntax-comment: #6b6b70;
  --syntax-string: #1b6e3c;
  --syntax-escape: #0b5cad;
  --syntax-number: #a14a00;
  --syntax-type: #0b5cad;
  --syntax-operator: #8a2d55;
  --syntax-property: #355a7a;
  --syntax-tag: #a1260d;
  --syntax-attribute: #7a5a00;
  --syntax-def: #005f87;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --fg: #e8e8ea;
    --muted: #9a9aa0;
    --line: #34343a;
    --panel: #1f1f23;
    --error: #ff8a80;
    --warning: #ffd479;
    --ok: #7ee2a8;
    --active: #232328;
    --syntax-keyword: #d7a6ff;
    --syntax-comment: #8d8d95;
    --syntax-string: #9fe0a8;
    --syntax-escape: #8ec7ff;
    --syntax-number: #ffb77d;
    --syntax-type: #8ec7ff;
    --syntax-operator: #ff9ec7;
    --syntax-property: #a8c8e8;
    --syntax-tag: #ff9e86;
    --syntax-attribute: #ffd479;
    --syntax-def: #7fd3ff;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, sans-serif;
}

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

h1 {
  margin: 0;
  font-size: 16px;
}

#status {
  color: var(--muted);
}

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

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

#note {
  margin: 0;
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

#note a {
  color: inherit;
}

button {
  font: inherit;
}

#diagnostics {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#diagnostics p {
  margin: 8px 16px;
  color: var(--muted);
}

.diagnostic {
  display: block;
  width: 100%;
  padding: 6px 16px 0;
  border: 0;
  background: none;
  color: var(--error);
  font: 600 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: left;
  cursor: pointer;
}

.diagnostic.warning {
  color: var(--warning);
}

.diagnostic + pre {
  padding-top: 2px;
  white-space: pre-wrap;
}

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}

pre {
  font: 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  tab-size: 4;
}

pre {
  margin: 0;
  padding: 8px 16px;
  overflow: auto;
  white-space: pre;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  padding: 8px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  border-bottom-color: currentColor;
  color: var(--fg);
}

[role="tabpanel"] {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

[role="tabpanel"][hidden] {
  display: none;
}

/* The source's two editors (playground.md §4.6): a block, not a flex
   column, so CodeMirror's `height: 100%` fills it. After the rule above, so
   it wins; `[hidden]` above is more specific, so a hidden one stays hidden. */
.editor {
  display: block;
  flex: 2;
  min-height: 0;
  overflow: hidden;
}

iframe {
  flex: 2;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

#console {
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#console .error {
  color: var(--error);
}

#file {
  margin: 8px 16px;
  font: inherit;
}

#code,
#types-text,
#ownership-text {
  flex: 1;
  min-height: 0;
}

#code {
  overflow: hidden;
}

/* A dump of an older version of the input, until the new one arrives. */
.stale {
  opacity: 0.5;
}

@media (max-width: 720px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

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