* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: #ffffff;
  color: #111;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: 28px;
  border-bottom: 1px solid #f0f0f0;
}
header h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.model-pick { display: flex; align-items: center; gap: 10px; }
.model-pick label { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.06em; }
.model-pick select {
  border: 1px solid #e5e5e5; background: #fff; padding: 7px 10px;
  border-radius: 6px; font-size: 13px; color: #111; font-family: inherit;
  outline: none; cursor: pointer;
}
.model-pick select:hover { border-color: #d0d0d0; }
.model-pick select:focus { border-color: #111; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 36px;
  align-items: start;
}

.left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.preview {
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fafafa;
  min-height: 420px;
  max-height: 680px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 12px;
}
.preview.has-file { background: #f4f4f4; }
.preview img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.08);
  background: #fff;
}
.preview-empty { text-align: center; color: #aaa; }
.preview-empty-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: #bbb; font-weight: 600; }
.preview-empty-hint { font-size: 13px; margin-top: 6px; color: #aaa; }

.file-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #fafafa;
  border: 1px solid #eee; border-radius: 8px; font-size: 13px;
}
.file-bar .file-name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-bar .file-meta { color: #999; font-variant-numeric: tabular-nums; font-size: 12px; }
.file-bar .file-clear {
  background: none; border: none; color: #ccc; cursor: pointer;
  font-size: 18px; width: 22px; height: 22px; line-height: 1; border-radius: 4px;
}
.file-bar .file-clear:hover { color: #b91c1c; background: #fef2f2; }

.dropzone {
  border: 2px dashed #dcdcdc;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.dropzone:hover { border-color: #bbb; }
.dropzone.drag { border-color: #111; background: #fafafa; }
.dropzone.compact { padding: 18px; }
.dz-title { font-weight: 500; font-size: 14px; }
.dz-hint { color: #999; font-size: 12px; margin-top: 4px; }

.samples { display: flex; flex-direction: column; gap: 10px; }
.samples-title {
  font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}
.samples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.sample-chip {
  border: 1px solid #ebebeb; border-radius: 10px; background: #fff;
  padding: 8px; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 6px;
  font-family: inherit; text-align: left; overflow: hidden;
}
.sample-chip:hover { border-color: #999; }
.sample-chip.active { border-color: #111; box-shadow: 0 0 0 1px #111 inset; }
.sample-chip img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  border-radius: 4px; background: #fafafa; display: block;
}
.sample-name {
  font-size: 11px; color: #555;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, "SF Mono", monospace;
}

button { font-family: inherit; }
button.primary {
  background: #111; color: #fff; border: none;
  padding: 13px 18px; border-radius: 9px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s;
}
button.primary:hover:not(:disabled) { opacity: 0.88; }
button.primary:disabled { background: #d4d4d4; color: #fff; cursor: not-allowed; }

.error {
  background: #fef2f2; color: #b91c1c;
  padding: 11px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid #fecaca;
}

.result {
  border: 1px solid #efefef; border-radius: 12px; padding: 20px 22px;
  background: #fff;
}
.result-meta {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid #f4f4f4;
  font-variant-numeric: tabular-nums;
}
.result-meta .timing { font-weight: 600; font-size: 15px; color: #111; }
.muted { color: #999; font-size: 12px; }

.result table { width: 100%; border-collapse: collapse; }
.result td { padding: 9px 0; border-bottom: 1px solid #f6f6f6; vertical-align: top; }
.result tr:last-child td { border-bottom: none; }
.result td.key {
  width: 38%; color: #888; font-size: 12px; font-family: ui-monospace, "SF Mono", monospace;
  padding-right: 16px; white-space: nowrap;
}
.result td.value { font-weight: 500; word-break: break-word; }
.result td.value .null { color: #ddd; font-weight: 400; }

.raw { margin-top: 16px; }
.raw summary { font-size: 12px; color: #888; cursor: pointer; padding: 4px 0; }
.raw summary:hover { color: #111; }
.raw pre {
  background: #fafafa; border: 1px solid #f0f0f0; border-radius: 8px;
  padding: 14px; font-size: 12px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", monospace; color: #333;
  margin-top: 8px;
}

.right { display: flex; flex-direction: column; gap: 8px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.section-head h2 {
  font-size: 11px; font-weight: 600; color: #888;
  text-transform: uppercase; letter-spacing: 0.08em; margin: 0;
}
.section-head .count {
  font-size: 11px; color: #888; background: #f5f5f5; padding: 2px 8px;
  border-radius: 10px; font-variant-numeric: tabular-nums;
}

.field {
  display: grid; grid-template-columns: 120px 1fr 24px;
  gap: 6px; margin-bottom: 6px; align-items: center;
}
.field input {
  border: 1px solid #ebebeb; background: #fff;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; outline: none; font-family: inherit;
  width: 100%; min-width: 0;
}
.field input:focus { border-color: #111; }
.field-key { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; }
.field .remove {
  background: none; border: none; color: #ccc;
  cursor: pointer; font-size: 18px; padding: 0; line-height: 1;
  width: 24px; height: 24px; border-radius: 4px;
}
.field .remove:hover { color: #b91c1c; background: #fef2f2; }

button.add {
  background: none; border: 1px dashed #d4d4d4;
  padding: 10px; border-radius: 7px;
  cursor: pointer; font-size: 13px; color: #777;
  width: 100%; margin-top: 4px; transition: all 0.15s;
}
button.add:hover { border-color: #111; color: #111; }

.aside-hint {
  margin: 16px 4px 0; font-size: 12px; color: #999; line-height: 1.55;
}

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .app { padding: 20px; }
}
