/* Reset */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	color: #1f2937;
	background: #f7f7fb;
}

/* Header */
.app-header {
	position: sticky;
	top: 0;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	background: #ffffff;
	border-bottom: 1px solid #e5e7eb;
	z-index: 10;
}
.logo-wrap { display: flex; align-items: center; }
.logo { height: 36px; width: auto; display: block; }
.app-title {
	margin: 0;
	text-align: center;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: #111827;
}
.header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}
.nav-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 6px 12px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: #fff;
	color: #111827;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	transition: all 0.2s ease;
	min-width: 120px;
}
.nav-btn:hover {
	background: #f3f4f6;
}
.nav-btn.active {
	background: #2563eb;
	color: #ffffff;
	border-color: #2563eb;
	box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}
.nav-btn.active:hover {
	background: #1d4ed8;
	border-color: #1d4ed8;
}

/* Control Bar */
.control-bar {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
	align-items: end;
	padding: 10px 16px;
	background: #ffffff;
	border-bottom: 1px solid #e5e7eb;
}
.control-item { display: grid; gap: 6px; }
.control-label { font-size: 12px; color: #6b7280; }
input[type="file"], select {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	font-size: 14px;
	color: #111827;
}
.primary-btn {
	height: 36px;
	padding: 0 16px;
	border: none;
	border-radius: 8px;
	background: #2563eb;
	color: #ffffff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}
.primary-btn:hover { background: #1d4ed8; }
.primary-btn:active { background: #1e40af; }

/* Content */
.content {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	padding: 12px 16px 16px;
	height: calc(100vh - 132px);
}
.panel {
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	overflow: hidden;
}
.panel-title {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 12px;
	font-size: 14px;
	font-weight: 600;
	background: #f9fafb;
	border-bottom: 1px solid #e5e7eb;
}
.panel-body {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 12px;
}
.result-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}
.view-toggle {
	display: inline-flex;
	border: 1px solid #d1d5db;
	border-radius: 999px;
	overflow: hidden;
	background: #fff;
}
.toggle-btn {
	border: none;
	background: transparent;
	padding: 6px 14px;
	font-size: 13px;
	color: #6b7280;
	cursor: pointer;
	transition: background 0.2s, color 0.2s;
}
.toggle-btn.active {
	background: #2563eb;
	color: #fff;
}
.toggle-btn:not(.active):hover {
	background: #f3f4f6;
}
.placeholder {
	color: #9ca3af;
	font-size: 14px;
	text-align: center;
	padding: 24px 0;
}

/* Raw viewer basics */
#rawViewer {
	display: grid;
	place-items: center;
	background: #fcfcfe;
}
#rawViewer img, #rawViewer iframe, #rawViewer .text-view {
	max-width: 100%;
	max-height: 100%;
	border: none;
}
.text-view {
	width: 100%;
	white-space: pre-wrap;
	word-break: break-word;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 13px;
	line-height: 1.6;
	color: #111827;
}

/* Result viewer */
#resultViewer {
	background: #fff;
}
.result-json {
	white-space: pre-wrap;
	word-break: break-word;
	overflow-wrap: break-word;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 13px;
	line-height: 1.5;
	background: #0b1020;
	color: #e5e7eb;
	padding: 12px;
	border-radius: 8px;
	max-width: 100%;
}

/* Loading state */
.loading-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	gap: 20px;
}

.loading-spinner {
	width: 40px;
	height: 40px;
	border: 4px solid #e5e7eb;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

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

.loading-text {
	font-size: 16px;
	color: #374151;
	font-weight: 500;
}

.loading-timer {
	font-size: 14px;
	color: #6b7280;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.loading-timer span {
	color: #2563eb;
	font-weight: 600;
}

/* Download button */
.download-btn {
	padding: 6px 12px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #f3f4f6;
	color: #9ca3af;
	font-size: 13px;
	font-weight: 500;
	cursor: not-allowed;
	transition: all 0.2s;
}

.download-btn:not(:disabled) {
	background: #2563eb;
	color: #ffffff;
	border-color: #2563eb;
	cursor: pointer;
}

.download-btn:not(:disabled):hover {
	background: #1d4ed8;
	border-color: #1d4ed8;
}

.download-btn:not(:disabled):active {
	background: #1e40af;
	border-color: #1e40af;
}

.markdown-view {
	color: #111827;
	font-family: "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
	line-height: 1.7;
}
.markdown-view h1,
.markdown-view h2,
.markdown-view h3,
.markdown-view h4,
.markdown-view h5,
.markdown-view h6 {
	margin: 16px 0 8px;
	font-weight: 600;
}
.markdown-view p {
	margin: 8px 0;
}
.markdown-view ul,
.markdown-view ol {
	margin: 8px 0 8px 20px;
}
.markdown-view blockquote {
	margin: 8px 0;
	padding-left: 12px;
	border-left: 3px solid #d1d5db;
	color: #6b7280;
	font-style: italic;
}
.markdown-view a {
	color: #2563eb;
	text-decoration: none;
}
.markdown-view table {
	width: 100%;
	border-collapse: collapse;
	margin: 16px 0;
	background: #fff;
	border: 1px solid #e5e7eb;
	overflow-x: auto;
	display: block;
	max-width: 100%;
}
.markdown-view table thead {
	background: #f9fafb;
}
.markdown-view table th {
	padding: 8px 12px;
	text-align: left;
	font-weight: 600;
	border: 1px solid #e5e7eb;
	background: #f9fafb;
}
.markdown-view table td {
	padding: 8px 12px;
	border: 1px solid #e5e7eb;
}
.markdown-view table tbody tr:nth-child(even) {
	background: #f9fafb;
}
.markdown-view table tbody tr:hover {
	background: #f3f4f6;
}
.markdown-view a:hover {
	text-decoration: underline;
}
.md-code {
	background: #0b1020;
	color: #e5e7eb;
	padding: 12px;
	border-radius: 8px;
	margin: 12px 0;
	overflow: auto;
}
.md-code code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 13px;
}
.md-inline-code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	background: #f3f4f6;
	padding: 2px 4px;
	border-radius: 4px;
}
.md-image {
	max-width: 100%;
	border-radius: 8px;
	margin: 12px 0;
	display: block;
}

.kv-coming {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 48px 16px;
}
.kv-card {
	max-width: 640px;
	width: 100%;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 24px 28px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.04);
}
.kv-title {
	font-size: 18px;
	font-weight: 700;
	color: #111827;
	margin-bottom: 12px;
}

/* Schema Editor */
.schema-editor {
	padding: 16px;
}

.schema-instruction {
	font-size: 14px;
	color: #6b7280;
	margin-bottom: 16px;
	line-height: 1.6;
}

.schema-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 16px;
	background: #fff;
}

.schema-table thead th {
	background: #f9fafb;
	padding: 12px;
	text-align: left;
	font-size: 13px;
	font-weight: 600;
	color: #374151;
	border: 1px solid #e5e7eb;
	border-bottom: 2px solid #d1d5db;
}

.schema-table .required {
	color: #ef4444;
	margin-left: 2px;
}

.schema-field-row {
	background: #fff;
}

.schema-field-row.child-field {
	background: #f9fafb;
}

.schema-field-row td {
	padding: 12px;
	border: 1px solid #e5e7eb;
	vertical-align: top;
}

.field-name-input,
.field-desc-input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	color: #111827;
	transition: border-color 0.2s;
}

.field-name-input:focus,
.field-desc-input:focus {
	outline: none;
	border-color: #2563eb;
}

.field-name-input.error {
	border-color: #ef4444;
}

.field-error {
	color: #ef4444;
	font-size: 12px;
	margin-top: 4px;
	display: none;
}

.field-type-select {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	color: #111827;
	background: #fff;
	cursor: pointer;
}

.field-delete-btn {
	background: none;
	border: none;
	color: #6b7280;
	font-size: 18px;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 4px;
	transition: all 0.2s;
}

.field-delete-btn:hover {
	background: #f3f4f6;
	color: #111827;
}

.field-config-row {
	background: #f9fafb;
}

.field-config {
	padding: 0 !important;
	border: none !important;
}

.config-panel {
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	background: #fff;
	margin: 8px 0;
}

.config-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	background: #f9fafb;
	border-bottom: 1px solid #e5e7eb;
	cursor: pointer;
	user-select: none;
	font-size: 14px;
	font-weight: 600;
	color: #374151;
}

.config-header:hover {
	background: #f3f4f6;
}

.config-toggle {
	color: #6b7280;
	font-size: 12px;
}

.config-content {
	padding: 16px;
	display: block;
}

.child-table {
	margin-bottom: 12px;
}

.child-table thead th {
	background: #f3f4f6;
	font-size: 12px;
	padding: 8px;
}

.child-table td {
	padding: 8px;
}

.add-field-btn {
	width: 100%;
	padding: 10px 16px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: #fff;
	color: #374151;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	margin-top: 8px;
}

.add-field-btn:hover {
	background: #f9fafb;
	border-color: #9ca3af;
}

.array-element-type {
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	color: #111827;
	background: #fff;
	cursor: pointer;
}

.enum-values-list {
	margin-bottom: 12px;
}

.enum-value-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 12px;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	margin-bottom: 8px;
}

.enum-value-item span {
	font-size: 14px;
	color: #111827;
}

.remove-enum-btn {
	background: none;
	border: none;
	color: #ef4444;
	font-size: 20px;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	border-radius: 4px;
	transition: all 0.2s;
}

.remove-enum-btn:hover {
	background: #fee2e2;
}

.enum-input-container {
	display: flex;
	gap: 8px;
}

.enum-value-input {
	flex: 1;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	color: #111827;
}

.enum-value-input:focus {
	outline: none;
	border-color: #2563eb;
}

.add-enum-btn {
	padding: 8px 16px;
	border: 1px solid #2563eb;
	border-radius: 6px;
	background: #2563eb;
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
}

.add-enum-btn:hover {
	background: #1d4ed8;
	border-color: #1d4ed8;
}

/* Responsive */
@media (max-width: 960px) {
	.control-bar {
		grid-template-columns: 1fr 1fr;
	}
	.content {
		grid-template-columns: 1fr;
		height: auto;
	}
}

/* 键值对结果展示样式 */
.kv-result-container {
	padding: 16px;
}

.kv-result-table {
	width: 100%;
	border-collapse: collapse;
	background: #fff;
	margin-bottom: 0;
}

.kv-result-table thead th {
	background: #f9fafb;
	padding: 12px;
	text-align: left;
	font-size: 13px;
	font-weight: 600;
	color: #374151;
	border: 1px solid #e5e7eb;
	border-bottom: 2px solid #d1d5db;
}

.kv-result-table thead th:first-child {
	border-right: 2px solid #d1d5db;
}

.kv-result-row {
	background: #fff;
	transition: background-color 0.2s;
}

.kv-result-row:hover {
	background: #f9fafb;
}

.kv-result-row td {
	padding: 12px;
	border: 1px solid #e5e7eb;
	vertical-align: top;
	word-break: break-word;
}

.kv-field-name {
	font-weight: 600;
	color: #374151;
	font-size: 14px;
	border-right: 2px solid #d1d5db;
}

.kv-field-value {
	color: #111827;
	font-size: 14px;
	line-height: 1.6;
}

.kv-toggle-btn {
	background: none;
	border: none;
	color: #6b7280;
	font-size: 12px;
	cursor: pointer;
	padding: 2px 4px;
	border-radius: 4px;
	transition: all 0.2s;
	vertical-align: middle;
	font-family: monospace;
}

.kv-toggle-btn:hover {
	background: #f3f4f6;
	color: #374151;
}

.kv-nested-container {
	margin-left: 0;
}

.kv-nested-table {
	border: 1px solid #e5e7eb;
	border-radius: 4px;
	overflow: hidden;
	background: #f9fafb;
}

.kv-nested-table thead {
	display: none;
}

.kv-nested-table .kv-result-row {
	background: #f9fafb;
}

.kv-nested-table .kv-result-row:hover {
	background: #f3f4f6;
}

.kv-nested-table .kv-result-row:nth-child(even) {
	background: #fff;
}

.kv-nested-table .kv-result-row:nth-child(even):hover {
	background: #f9fafb;
}


