:root {
  color-scheme: light dark;
  --background: #ffffff;
  --surface: #f5f6f8;
  --text: #1c1f24;
  --muted: #555b66;
  --border: #c9ced6;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --error-background: #fdecec;
  --error-text: #8a1c1c;
  --warning-background: #fff6dd;
  --warning-text: #754c00;
  /* Code colors, each at least 4.5:1 against --surface (WCAG AA). */
  --code-string: #1d6b2a;
  --code-keyword: #7a2a99;
  --code-function: #1d4e9e;
  --code-number: #8f4300;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #15171b;
    --surface: #1e2127;
    --text: #e6e8eb;
    --muted: #a3a9b4;
    --border: #3a3f48;
    --accent: #6ea0ff;
    --accent-text: #0b1020;
    --error-background: #3a1d1f;
    --error-text: #ffb4b4;
    --warning-background: #332b18;
    --warning-text: #f5d58a;
    --code-string: #8fd694;
    --code-keyword: #d7a6ff;
    --code-function: #8ab4ff;
    --code-number: #f0b37e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem 1.5rem 2rem;
  background: var(--background);
  color: var(--text);
  font: 16px/1.5 system-ui, sans-serif;
}

header,
main,
footer {
  max-width: 1200px;
  margin: 0 auto;
}

h1 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.6rem;
}

h2 {
  margin: 0;
  font-size: 1rem;
}

header p,
footer p {
  margin: 0;
  color: var(--muted);
}

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: end;
  margin: 1.25rem 0 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 100%;
  font-weight: 600;
}

select,
textarea,
button {
  font: inherit;
  color: inherit;
}

select,
textarea,
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

select {
  padding: 0.4rem 0.5rem;
  min-width: 14rem;
  /* A select is as wide as its longest option; on a phone, that can be
     wider than the screen. */
  max-width: 100%;
}

button {
  padding: 0.45rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

#copy {
  padding: 0.15rem 0.75rem;
}

.notice {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--error-background);
  color: var(--error-text);
}

#code .string {
  color: var(--code-string);
}

#code .keyword {
  color: var(--code-keyword);
}

#code .function {
  color: var(--code-function);
}

#code .number {
  color: var(--code-number);
}

kbd {
  font-family: var(--mono);
  font-size: 0.8em;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#status {
  min-height: 1.5em;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 800px) {
  .panes {
    grid-template-columns: 1fr;
  }
}

.pane-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

textarea,
pre {
  width: 100%;
  min-height: 28rem;
  margin: 0;
  padding: 0.75rem;
  font: 14px/1.5 var(--mono);
}

textarea {
  resize: vertical;
}

pre {
  overflow: auto;
}

#errors,
#warnings {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--error-background);
  color: var(--error-text);
  overflow-wrap: anywhere;
}

#warnings {
  background: var(--warning-background);
  color: var(--warning-text);
}

.input-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

#errors p,
#warnings p {
  margin: 0;
  font-weight: 600;
}

#errors ul,
#warnings ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

#errors .hint {
  font-weight: normal;
}

footer {
  margin-top: 1.5rem;
}
