:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2128;
  --muted: #5d6673;
  --border: #d4d9e0;
  --accent: #b7410e;
  --ok: #1a7f37;
  --error: #c4291f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --text: #e3e7ed;
    --muted: #98a2b0;
    --border: #343b46;
    --accent: #f08a4b;
    --ok: #57c26f;
    --error: #ff7b72;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
}

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

.muted {
  color: var(--muted);
  font-weight: normal;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 1.15rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

select,
button {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: var(--muted);
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

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

.pane.expression {
  grid-column: 1 / -1;
  height: 35vh;
  height: 35dvh;
}

.pane.expression textarea {
  min-height: 0;
  resize: none;
}

label,
h2 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

kbd {
  font: 0.75rem var(--mono);
  font-weight: normal;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.25rem;
}

textarea,
pre {
  flex: 1;
  margin: 0;
  padding: 0.6rem 0.75rem;
  font: 14px/1.5 var(--mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  tab-size: 2;
}

textarea {
  resize: vertical;
}

textarea:focus,
pre:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.output[data-state="ok"] pre {
  border-left: 4px solid var(--ok);
}

.output[data-state="error"] pre {
  border-left: 4px solid var(--error);
  color: var(--error);
}

.output[data-state="error"] #status {
  color: var(--error);
}

footer {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.8rem;
}

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

@media (max-width: 800px) {
  body {
    height: auto;
  }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .pane.input textarea {
    min-height: 16rem;
  }

  .pane.output pre {
    min-height: 10rem;
  }

  nav {
    margin-left: 0;
  }
}
