:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657086;
  --line: #d9dfeb;
  --primary: #1d5fd1;
  --primary-dark: #174da8;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

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

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button[type="submit"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 0 18px;
}

button:hover:not(:disabled) {
  border-color: var(--primary);
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

.status {
  min-height: 24px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

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

.result-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
}

.dataset-panel,
.markdown-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dataset-panel {
  padding: 16px;
}

.dataset-panel dl {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.dataset-panel dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.dataset-panel dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.markdown-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.button-row {
  display: flex;
  gap: 8px;
}

.button-row button {
  padding: 0 12px;
}

textarea {
  min-height: 560px;
  resize: vertical;
  border: 0;
  border-radius: 0 0 8px 8px;
  padding: 16px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
  }

  .controls,
  .result-layout {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
