:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-border: #d8dee4;
  --text: #172026;
  --muted: #64717d;
  --accent: #126c83;
  --accent-hover: #0d5b6f;
  --danger: #b42318;
  --success: #177245;
  --field-bg: #f9fbfc;
  --focus: rgba(18, 108, 131, 0.2);
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

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

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.input-panel,
.editor-panel,
.output-panel {
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.output-panel {
  grid-column: 1 / -1;
  min-height: 300px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-header.compact {
  align-items: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.panel-header p,
.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #34424d;
  font-weight: 700;
  font-size: 0.86rem;
}

textarea,
.field-control {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  background: var(--field-bg);
}

textarea:focus,
.field-control:focus {
  outline: 3px solid var(--focus);
  border-color: var(--accent);
}

#jsonInput,
#jsonOutput {
  min-height: 260px;
  flex: 1;
  resize: vertical;
  padding: 12px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

#jsonOutput {
  min-height: 220px;
}

.actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.actions {
  margin-top: 12px;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

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

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary-button {
  background: #eaf3f5;
  border-color: #b9d1d8;
  color: #0e5365;
}

.secondary-button:hover:not(:disabled) {
  background: #dcecef;
}

.ghost-button {
  background: transparent;
  border-color: var(--panel-border);
  color: #455560;
}

.ghost-button:hover:not(:disabled) {
  background: #f0f3f5;
}

.message {
  min-height: 22px;
  margin-top: 10px;
  font-size: 0.92rem;
  font-weight: 700;
}

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

.message.success {
  color: var(--success);
}

.fields-form {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.9fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #fbfcfd;
}

.field-path {
  min-width: 0;
}

.field-path code {
  display: block;
  overflow-wrap: anywhere;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  color: #23323c;
}

.field-type {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-control {
  min-height: 38px;
  padding: 8px 10px;
}

textarea.field-control {
  min-height: 82px;
  resize: vertical;
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 38px;
}

.checkbox-wrap input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed #c8d0d7;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

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

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

  .output-panel {
    grid-column: auto;
  }

  .panel-header,
  .panel-header.compact {
    align-items: stretch;
    flex-direction: column;
  }

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