:root {
  color-scheme: dark;
  --background: #111315;
  --panel: #1a1d21;
  --panel-strong: #22262b;
  --text: #eceff1;
  --muted: #a8b0b7;
  --line: #343a41;
  --accent: #30a46c;
  --accent-dark: #238459;
  --error-bg: #341d18;
  --error-line: #8f4634;
  --error-text: #ffb7a5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 700;
}

h2 {
  font-size: 18px;
}

.page-header p {
  max-width: 700px;
  margin-top: 8px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(420px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.controls {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.field,
fieldset {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #2b3137;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.radio,
.checks label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 500;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent);
  color: #f5fbf7;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

.output {
  min-height: 720px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

textarea {
  min-height: 620px;
  resize: vertical;
  padding: 14px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--error-line);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-text);
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

summary {
  cursor: pointer;
  font-weight: 650;
}

pre {
  overflow: auto;
  margin: 10px 0 0;
  white-space: pre-wrap;
}

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

  .output {
    min-height: 520px;
  }

  textarea {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding: 18px 0;
  }

  .panel {
    padding: 14px;
  }

  .grid,
  .grid.compact,
  .checks {
    grid-template-columns: 1fr;
  }
}
