:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #5f6c66;
  --line: #ccd7d2;
  --panel: #ffffff;
  --page: #f5f7f6;
  --primary: #004eec;
  --primary-dark: #003bb8;
  --primary-soft: #eef4ff;
  --amber: #a56a12;
  --red: #b42318;
  --shadow: 0 14px 40px rgba(23, 32, 29, 0.08);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

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

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.embed-attribution {
  display: none;
}

.embedded body {
  background: transparent;
}

.embedded .app-shell {
  width: 100%;
  padding: 0;
}

.embedded .topbar,
.embedded .faq-panel {
  display: none;
}

.embedded .embed-attribution {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.embedded .embed-attribution a {
  display: inline-flex;
}

.embedded .embed-attribution img {
  display: block;
  width: 78px;
  height: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-link {
  display: block;
}

.brand-logo {
  display: block;
  width: min(192px, 42vw);
  height: auto;
}

.product-name {
  color: #41427e;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.output-label {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 4px;
}

.output-label .eyebrow {
  margin: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.05;
}

h2 {
  max-width: 34rem;
  overflow-wrap: anywhere;
  font-size: 1.1rem;
  line-height: 1.3;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 6px;
  padding: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.github-link {
  border: 0;
  color: #555;
  text-decoration: none;
}

.github-link:hover {
  background: #fff;
  color: var(--ink);
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  overflow: hidden;
}

.input-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.source-tabs,
.output-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
  background: #eef3f0;
}

.panel-head .source-tabs,
.panel-head .output-tabs {
  min-width: 160px;
}

.tab {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 32, 29, 0.08);
}

.tab:disabled {
  color: #9aa6a1;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 168px;
  border: 1px dashed #9caea5;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 20px;
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-title {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.drop-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.field span,
.toggles {
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 0.8rem;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: help;
  white-space: nowrap;
}

.toggles input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.primary {
  border-color: var(--primary-dark);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.faq-panel {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
}

.faq-panel h2 {
  font-size: 1rem;
}

.faq-panel details {
  padding-top: 12px;
}

.faq-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-panel p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.result-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: min(580px, 90vh);
  max-height: 90vh;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 57px;
  padding: 8px 14px;
}

.input-head .eyebrow {
  margin: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-tooltip {
  display: inline-flex;
}

.output-name:empty {
  display: none;
}

.output-pane {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
}

.output-status {
  z-index: 1;
  display: flex;
  grid-column: 1;
  grid-row: 2;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #fbfcfc;
  color: var(--red);
  text-align: center;
}

.output-status[data-state="error"] {
  background: #fdf6e3;
}

.output-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: output-spin 0.8s linear infinite;
}

.output-error-icon {
  display: none;
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.output-download-prompt {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.output-download-prompt .icon-button {
  color: var(--ink);
}

.output-status[data-state="error"] .output-spinner {
  display: none;
}

.output-status[data-state="error"] .output-error-icon {
  display: block;
}

.output-status[data-state="download"] .output-spinner {
  display: none;
}

.output-status[data-state="download"] .output-download-prompt {
  display: flex;
}

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

.preview {
  margin: 0;
  overflow: auto;
  padding: 18px;
  background: #fdf6e3;
  color: #657b83;
  font:
    0.9rem/1.55 ui-monospace,
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview code,
pre.preview[class*="language-"],
.preview code[class*="language-"] {
  background: transparent;
  font: inherit;
  font-family:
    ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    monospace !important;
  text-shadow: none;
  white-space: break-spaces;
}

.preview code {
  display: block;
}

.tree-view {
  overflow: auto;
  padding: 16px 18px;
  background: #fbfcfc;
  font:
    0.9rem/1.5 "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace;
}

.tree-node,
.tree-leaf {
  margin: 2px 0;
}

.tree-node summary,
.tree-leaf {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 28px;
}

.tree-node summary {
  cursor: pointer;
  list-style: none;
}

.tree-node summary::-webkit-details-marker {
  display: none;
}

.tree-node summary::before {
  display: inline-grid;
  flex: 0 0 18px;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--primary);
  content: "+";
  font-weight: 700;
  line-height: 1;
}

.tree-node[open] > summary::before {
  content: "-";
}

.tree-leaf::before {
  flex: 0 0 18px;
  width: 18px;
  content: "";
}

.tree-children {
  margin-left: 18px;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.tree-key {
  color: var(--primary);
  font-weight: 700;
}

.tree-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.tree-value-string {
  color: var(--primary);
}

.tree-value-number,
.tree-value-boolean {
  color: var(--amber);
}

.tree-value-null {
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding: 16px 0;
  }

  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .input-panel {
    border-right: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
  }

  .result-panel {
    min-height: min(420px, 90vh);
    border-radius: 0 0 8px 8px;
  }
}

@media (max-width: 520px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: min(150px, 42vw);
  }

  .product-name {
    font-size: 1.55rem;
  }
}
