:root {
  color: #202124;
  background: #f3f5f8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 1080px;
  margin: 0;
}

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

.topbar {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  color: #fff;
  background: linear-gradient(135deg, #1677ff, #0958d9);
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
}

.topbar p {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.topbar a {
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
}

.workspace {
  display: grid;
  height: calc(100vh - 76px);
  grid-template-columns: minmax(620px, 1fr) minmax(420px, 0.78fr);
  gap: 16px;
  padding: 16px;
}

.config-panel,
.preview-panel {
  min-height: 0;
  border: 1px solid #e2e6ec;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(20, 40, 80, 0.06);
}

.config-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid #edf0f4;
}

.toolbar label {
  display: grid;
  flex: 1;
  gap: 6px;
  color: #626b78;
  font-size: 13px;
}

.toolbar select,
.field-control,
.field-textarea {
  width: 100%;
  border: 1px solid #d7dce3;
  border-radius: 6px;
  outline: none;
  background: #fff;
}

.toolbar select,
.field-control {
  height: 38px;
  padding: 0 10px;
}

.field-textarea {
  min-height: 96px;
  padding: 10px;
  line-height: 1.6;
  resize: vertical;
}

.table-cell-textarea {
  min-height: 76px;
  white-space: pre-wrap;
}

.toolbar select:focus,
.field-control:focus,
.field-textarea:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

button {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button.primary {
  color: #fff;
  background: #1677ff;
}

button.secondary {
  color: #334155;
  background: #edf2f7;
}

button.danger {
  color: #cf1322;
  background: #fff1f0;
}

.form-container {
  flex: 1;
  padding: 16px;
  overflow: auto;
}

.section-switches {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #b8d5ff;
  border-radius: 8px;
  background: #f4f8ff;
}

.section-switches-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  color: #263245;
}

.section-switches-header span {
  color: #7d8999;
  font-size: 12px;
}

.section-switches-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.section-switch {
  display: flex;
  min-height: 62px;
  align-items: flex-start;
  gap: 9px;
  padding: 11px;
  border: 1px solid #d9e5f7;
  border-radius: 7px;
  cursor: pointer;
  background: #fff;
}

.section-switch:has(input:checked) {
  border-color: #69a8ff;
  background: #eaf3ff;
}

.section-switch input {
  margin-top: 3px;
  accent-color: #1677ff;
}

.section-switch span,
.section-switch strong,
.section-switch small {
  display: block;
}

.section-switch strong {
  color: #334155;
  font-size: 13px;
}

.section-switch small {
  margin-top: 4px;
  color: #8792a2;
  font-size: 11px;
}

.object-group,
.array-group {
  margin-bottom: 14px;
  border: 1px solid #e5e9ef;
  border-radius: 8px;
  background: #fafbfd;
}

.group-title {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid #e5e9ef;
  color: #263245;
  font-size: 15px;
  font-weight: 600;
}

.group-title small {
  color: #8b95a5;
  font-size: 12px;
  font-weight: 400;
}

.group-content {
  padding: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.field-row:last-child {
  margin-bottom: 0;
}

.field-label {
  padding-top: 9px;
  color: #4a5565;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.field-label code {
  display: block;
  margin-top: 3px;
  color: #9aa3af;
  font-size: 11px;
}

.radio-group {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 18px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
}

.array-items {
  display: grid;
  gap: 10px;
}

.array-item {
  position: relative;
  padding: 12px;
  border: 1px solid #dfe4ea;
  border-radius: 7px;
  background: #fff;
}

.array-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #607089;
  font-size: 12px;
}

.array-item-actions {
  display: flex;
  gap: 6px;
}

.array-item-actions button,
.add-item {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.array-item-actions button {
  background: #edf2f7;
}

.add-item {
  margin-top: 10px;
  color: #1677ff;
  background: #eaf3ff;
}

.json-preview {
  border-top: 1px solid #edf0f4;
}

.json-preview summary {
  padding: 10px 16px;
  cursor: pointer;
  color: #526173;
  font-size: 13px;
}

.json-preview pre {
  max-height: 220px;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  color: #d6deeb;
  background: #1f2937;
  font:
    12px/1.55 Consolas,
    monospace;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-title {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #edf0f4;
  font-weight: 600;
}

#statusText {
  color: #7b8492;
  font-size: 12px;
  font-weight: 400;
}

.preview-container {
  position: relative;
  flex: 1;
  padding: 18px;
  overflow: auto;
  background: #eef1f5;
}

.empty-preview {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: #98a1ad;
}

.empty-preview[hidden] {
  display: none;
}

.image-list {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.preview-item {
  width: min(100%, 520px);
}

.preview-item-label {
  margin-bottom: 6px;
  color: #596577;
  font-size: 12px;
}

.preview-item img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 3px 14px rgba(28, 45, 75, 0.12);
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.loading[hidden] {
  display: none;
}

.loading span {
  width: 22px;
  height: 22px;
  border: 3px solid #cfe1ff;
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#clipboardFallback {
  position: fixed;
  top: -1000px;
  left: -1000px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
