:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #607086;
  --line: #d8e0ec;
  --accent: #1769e0;
  --accent-dark: #0e56bd;
  --danger: #b42318;
  --ok: #067647;
  --code: #111827;
}

* {
  box-sizing: border-box;
}

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

.app {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 18px;
  width: min(1440px, calc(100vw - 32px));
  margin: 16px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.06);
}

.input-panel {
  padding: 20px;
}

.topbar,
.output-head,
.actions,
.toggles,
.import-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar,
.output-head {
  justify-content: space-between;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
}

p,
.field span,
.status,
.toggles {
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

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

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

textarea {
  min-height: 280px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input,
select {
  height: 42px;
  padding: 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
}

.toggles {
  flex-wrap: wrap;
  margin-top: 16px;
}

.toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

.import-row input {
  min-width: 0;
  flex: 1;
}

.import-row button {
  flex: 0 0 auto;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover {
  border-color: #a9b8ce;
}

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

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.status {
  min-height: 24px;
  margin-top: 14px;
}

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

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

.output-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.output-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

pre {
  min-height: calc(100vh - 98px);
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #dbeafe;
  background: var(--code);
  border-radius: 0 0 8px 8px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

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

  pre {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .app {
    width: calc(100vw - 20px);
    margin: 10px auto;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .import-row {
    align-items: stretch;
    flex-direction: column;
  }

  .input-panel {
    padding: 16px;
  }

  textarea {
    min-height: 220px;
  }
}
