.json-tool-shell {
  position: relative;
}

.json-tool-shell::before {
  background:
    radial-gradient(circle at top left, rgba(201, 106, 42, 0.16), transparent 30%),
    radial-gradient(circle at right 20%, rgba(47, 95, 134, 0.14), transparent 28%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.json-tool-shell .container {
  position: relative;
}

.json-tool-hero {
  align-items: start;
  display: grid;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.json-tool-hero__copy {
  display: grid;
  gap: var(--space-4);
}

.json-tool-hero__copy h1 {
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 0.98;
  margin: 0;
  max-width: 12ch;
}

.json-tool-hero__summary {
  color: var(--color-muted);
  font-size: var(--font-size-lg);
  line-height: 1.7;
  margin: 0;
  max-width: 44rem;
}

.json-tool-hero__actions,
.json-tool__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.json-stat-card,
.json-tool__panel,
.json-schema-panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 253, 0.94));
  border: 1px solid var(--color-border);
  border-radius: 1.4rem;
  box-shadow: var(--shadow-soft);
}

.json-stat-card {
  min-width: 0;
  padding: 1rem 1.1rem;
}

.json-stat-card__label {
  color: var(--color-muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

.json-stat-card__value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

.json-tool {
  display: grid;
  gap: var(--space-4);
}

.json-tool__panel,
.json-schema-panel {
  padding: 1.2rem;
}

.json-tool__panel-header,
.json-schema-panel__header {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.json-tool__panel-header > div:first-child {
  min-width: 0;
}

.json-tool__panel-stats {
  align-self: stretch;
  display: grid;
  gap: 0.75rem;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
  width: min(100%, 28rem);
}

.json-tool__panel-stats .json-stat-card {
  background: rgba(27, 29, 33, 0.03);
  border: 1px solid rgba(27, 29, 33, 0.08);
  border-radius: 1rem;
  box-shadow: none;
  padding: 0.8rem 0.9rem;
}

.json-tool__panel-stats .json-stat-card__label {
  font-size: 0.74rem;
  margin-bottom: 0.25rem;
}

.json-tool__panel-stats .json-stat-card__value {
  font-size: 1rem;
}

.json-tool__panel-header h2,
.json-schema-panel__header h2 {
  font-size: 1.4rem;
  line-height: 1.1;
  margin: 0.15rem 0 0;
}

.json-tool__eyebrow {
  color: var(--color-build);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0;
  text-transform: uppercase;
}

.json-output-switcher {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.55rem;
  margin-top: 0.35rem;
  max-width: 100%;
  overflow-x: auto;
}

.json-output-switcher__button {
  background: rgba(27, 29, 33, 0.04);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.34rem 0.62rem;
  white-space: nowrap;
}

.json-output-switcher__button.is-active {
  background: rgba(201, 106, 42, 0.12);
  border-color: rgba(201, 106, 42, 0.18);
  color: var(--color-build-strong);
}

.json-tool__actions .app-card__cta.is-active {
  background: rgba(201, 106, 42, 0.12);
  border-color: rgba(201, 106, 42, 0.18);
  color: var(--color-build-strong);
}

.json-tool__output-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: space-between;
  margin-top: 1rem;
}

.json-upload {
  align-items: center;
  background: rgba(201, 106, 42, 0.08);
  border: 1px solid rgba(201, 106, 42, 0.18);
  border-radius: var(--radius-pill);
  color: var(--color-build-strong);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 600;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}

.json-upload input {
  display: none;
}

.json-tool__textarea,
.json-tool__code {
  background: #12161d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.1rem;
  color: #edf2ff;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.93rem;
  line-height: 1.65;
  min-height: 24rem;
  overflow: auto;
  padding: 1rem;
  width: 100%;
}

.json-tool__textarea {
  height: 24rem;
  margin: 0 0 1rem;
  resize: vertical;
}

.json-tool__code {
  height: 24rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-tool__feedback {
  color: var(--color-muted);
  margin: 0.85rem 0 0;
}

.json-tool__feedback.is-error {
  color: #a13f26;
}

.json-tool__feedback.is-success {
  color: #2c6e63;
}

.json-schema-panel {
  margin-top: var(--space-5);
}

.json-schema-panel__tabs {
  display: inline-flex;
  gap: 0.5rem;
}

.json-schema-panel__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.json-schema-panel__tab {
  background: rgba(27, 29, 33, 0.04);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
}

.json-schema-panel__tab.is-active {
  background: rgba(201, 106, 42, 0.12);
  border-color: rgba(201, 106, 42, 0.18);
  color: var(--color-build-strong);
}

.json-schema-tree {
  display: grid;
  gap: 0.9rem;
}

.json-erd {
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.json-schema-tree__empty {
  color: var(--color-muted);
  margin: 0;
}

.json-schema-node {
  background: rgba(248, 250, 253, 0.82);
  border: 1px solid rgba(27, 29, 33, 0.08);
  border-radius: 1rem;
  padding: 0.95rem 1rem;
}

.json-schema-node[open] {
  background: rgba(255, 255, 255, 0.92);
}

.json-schema-node__header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.json-schema-node > summary {
  cursor: pointer;
  list-style: none;
}

.json-schema-node > summary.json-schema-node__header {
  align-items: flex-start;
  position: relative;
  padding-left: 1.35rem;
}

.json-schema-node > summary .json-schema-node__meta {
  flex-basis: 100%;
  margin-top: -0.15rem;
}

.json-schema-node > summary::-webkit-details-marker {
  display: none;
}

.json-schema-node > summary.json-schema-node__header::before {
  color: var(--color-build-strong);
  content: "▸";
  font-size: 1rem;
  line-height: 1;
  left: 0;
  position: absolute;
  top: 0.18rem;
  transform: translateY(0.02rem);
  transition: transform 160ms ease;
}

.json-schema-node[open] > summary.json-schema-node__header::before {
  transform: rotate(90deg) translateX(0.02rem);
}

.json-schema-node > summary.json-schema-node__header:hover .json-schema-node__name {
  color: var(--color-build-strong);
}

.json-schema-node__name {
  font-size: 1rem;
  font-weight: 700;
}

.json-schema-node__type {
  background: rgba(47, 95, 134, 0.1);
  border-radius: var(--radius-pill);
  color: var(--color-accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
}

.json-schema-node__meta {
  color: var(--color-muted);
  font-size: 0.88rem;
}

.json-schema-node__children {
  border-left: 2px solid rgba(201, 106, 42, 0.12);
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
  padding-left: 1rem;
}

.json-schema-panel__view[hidden] {
  display: none;
}

.json-erd__layout {
  display: grid;
  gap: 1rem;
}

.json-erd__stage {
  background:
    linear-gradient(180deg, rgba(255, 253, 250, 0.92), rgba(247, 250, 253, 0.9));
  border: 1px solid rgba(27, 29, 33, 0.08);
  border-radius: 1rem;
  min-height: 32rem;
  min-width: max-content;
  overflow: hidden;
  position: relative;
  transform-origin: top left;
}

.json-erd__svg {
  inset: 0;
  overflow: visible;
  pointer-events: none;
  position: absolute;
}

.json-erd__cards {
  inset: 0;
  position: absolute;
  z-index: 1;
}

.json-erd__measure {
  left: -9999px;
  pointer-events: none;
  position: absolute;
  top: 0;
  visibility: hidden;
  width: 300px;
}

.json-erd-card {
  background:
    linear-gradient(180deg, rgba(255, 248, 242, 0.96), rgba(255, 255, 255, 0.98));
  border: 1px solid rgba(201, 106, 42, 0.18);
  border-radius: 1.1rem;
  box-shadow: 0 12px 32px rgba(29, 26, 23, 0.06);
  overflow: hidden;
  position: absolute;
}

.json-erd-card__header {
  background: linear-gradient(135deg, rgba(201, 106, 42, 0.12), rgba(47, 95, 134, 0.08));
  border-bottom: 1px solid rgba(201, 106, 42, 0.14);
  padding: 0.95rem 1rem 0.85rem;
}

.json-erd-card__title {
  font-size: 1.05rem;
  line-height: 1.1;
  margin: 0;
}

.json-erd-card__kind {
  color: var(--color-muted);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  margin: 0.35rem 0 0;
  text-transform: uppercase;
}

.json-erd-card__fields {
  display: grid;
}

.json-erd-card__field {
  align-items: baseline;
  display: grid;
  gap: 0.3rem;
  grid-template-columns: minmax(0, 1fr);
  padding: 0.8rem 1rem;
}

.json-erd-card__field + .json-erd-card__field {
  border-top: 1px solid rgba(27, 29, 33, 0.06);
}

.json-erd-card__field-name {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.93rem;
  font-weight: 700;
}

.json-erd-card__field-meta {
  color: var(--color-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.json-erd__relationships {
  background: rgba(248, 250, 253, 0.7);
  border: 1px dashed rgba(47, 95, 134, 0.22);
  border-radius: 1rem;
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
}

.json-erd__relationship {
  color: var(--color-accent-strong);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.json-erd__connector {
  fill: none;
  stroke: rgba(158, 79, 24, 0.7);
  stroke-width: 2.5;
}

.json-erd__connector-label {
  fill: #7c3d14;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 12px;
  font-weight: 700;
}

.json-erd__connector-label-bg {
  fill: rgba(255, 249, 243, 0.96);
  stroke: rgba(201, 106, 42, 0.18);
}

@media (min-width: 62rem) {
  .json-tool {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 39.99rem) {
  .json-tool__panel,
  .json-schema-panel {
    padding: 1rem;
  }

  .json-tool__panel-header,
  .json-schema-panel__header {
    flex-direction: column;
  }

  .json-tool__panel-stats {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .json-tool__textarea,
  .json-tool__code {
    height: 20rem;
    min-height: 20rem;
  }

  .json-tool__actions .app-card__cta,
  .json-tool-hero__actions .app-card__cta {
    width: 100%;
  }

  .json-schema-panel__controls .app-card__cta {
    width: 100%;
  }

  .json-output-switcher {
    display: flex;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .json-tool__output-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .json-erd__stage {
    min-height: 26rem;
  }
}
