.schema-showcase {
  color-scheme: dark;
  --schema-bg: #0b1017;
  --schema-panel: #111a24;
  --schema-fg: #e3edf6;
  --schema-muted: #abbccf;
  --schema-border: #344456;
  --schema-cyan: #7bc8dc;
  --schema-magenta: #db94c6;
  --schema-grid: #9ab1d012;
  --schema-shadow: #0009;
  color: var(--schema-fg);
  background: var(--schema-bg);
  border: 1px solid var(--schema-border);
  margin-block: 0 clamp(3.5rem, 8vw, 7rem);
}

@media (prefers-color-scheme: light) {
  .schema-showcase {
    color-scheme: light;
    --schema-bg: #e8eef4;
    --schema-panel: #f9fbfd;
    --schema-fg: #182635;
    --schema-muted: #455d71;
    --schema-border: #a8bbca;
    --schema-cyan: #08718a;
    --schema-magenta: #933d77;
    --schema-grid: #4a61751c;
    --schema-shadow: #263c5550;
  }
}

.schema-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--schema-border);
}

.studio-page .studio-shell .schema-toolbar h3 {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.schema-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.15rem;
  list-style: none;
  margin: .7rem 0 0;
  padding: 0;
  font-size: .875rem;
  color: var(--schema-muted);
}

.schema-showcase [data-owner="client_owned_schema"] { --schema-accent: var(--schema-cyan); }
.schema-showcase [data-owner="app_internal_schema"] { --schema-accent: var(--schema-magenta); }

.schema-legend li::before {
  content: "";
  display: inline-block;
  width: .65em;
  height: .65em;
  margin-right: .45em;
  background: var(--schema-accent);
}

.schema-controls {
  display: flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--schema-border);
}

.schema-controls label { cursor: pointer; }

.schema-controls label span {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding-inline: .8rem;
  font-size: .875rem;
  color: var(--schema-muted);
}

.schema-controls input:checked + span {
  background: var(--schema-panel);
  box-shadow: inset 0 -2px var(--schema-cyan);
  color: var(--schema-fg);
}

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

.schema-controls input:focus-visible + span,
.studio-page .schema-viewport:focus-visible {
  outline: 2px solid var(--schema-cyan);
  outline-offset: -3px;
}

.schema-isometric { margin: 0; }

.schema-isometric figcaption {
  padding: .65rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--schema-border);
  color: var(--schema-muted);
  font-size: .875rem;
}

.schema-viewport {
  overflow-x: auto;
  background: radial-gradient(ellipse at 52% 50%, var(--schema-panel), var(--schema-bg) 78%);
}

.schema-stage {
  position: relative;
  width: 1300px;
  height: 640px;
  overflow: clip;
  zoom: .94;
}

.schema-plane {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1540px;
  height: 700px;
  transform-origin: 0 0;
  transform: matrix(.72, .18, -.34, .56, 220, 5);
  background-image: linear-gradient(var(--schema-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--schema-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.schema-ownership {
  position: absolute;
  inset: 28px 0 36px;
  display: grid;
  grid-template-columns: 380px 1fr;
  pointer-events: none;
}

.schema-ownership span {
  padding: 12px 24px;
  color: var(--schema-accent);
  font-size: 18px;
  font-weight: 650;
}

.schema-ownership span:first-child {
  border-inline-end: 3px solid var(--schema-magenta);
  background: color-mix(in srgb, var(--schema-magenta) 8%, transparent);
  padding-inline-start: 90px;
}

.schema-ownership span:last-child {
  border-inline-start: 2px solid var(--schema-cyan);
  background: color-mix(in srgb, var(--schema-cyan) 4%, transparent);
}

.schema-relationships {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  stroke: var(--schema-cyan);
  stroke-width: 1.45;
  opacity: .8;
}

.schema-panel {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  box-sizing: border-box;
  background: var(--schema-panel);
  box-shadow: 0 0 0 1px var(--schema-border), 4px 7px 0 var(--schema-border), 12px 18px 24px var(--schema-shadow);
  display: grid;
  align-content: center;
  height: var(--schema-panel-height);
  padding-inline: 1rem;
  border-top: 2px solid var(--schema-accent);
  font-size: 21px;
  font-weight: 650;
  line-height: 1.15;
}

.schema-panel[data-schema-anchor] {
  box-shadow: 0 0 0 1px var(--schema-cyan), 4px 7px 0 var(--schema-border), 13px 21px 28px var(--schema-shadow);
}

.schema-flat { display: none; }

.schema-showcase:has(input[value="flat"]:checked) .schema-isometric { display: none; }

.schema-showcase:has(input[value="flat"]:checked) .schema-flat {
  display: block;
  padding: clamp(1rem, 3vw, 2rem);
}

.schema-flat-relations h4 { margin: 0; font-size: 1rem; }
.schema-flat-relations ul { list-style: none; padding: 0; margin: .6rem 0 1.5rem; }

.schema-flat-relations li {
  display: flex;
  flex-wrap: wrap;
  column-gap: .6rem;
  font-size: .875rem;
}

.schema-flat-relations li span { color: var(--schema-muted); }

.schema-flat-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
}

.schema-flat-group {
  min-width: 0;
  border-top: 2px solid var(--schema-accent);
  padding: .85rem;
}

.schema-flat-group + .schema-flat-group {
  border-inline-start: 1px solid var(--schema-border);
}

.schema-flat-group h4 {
  margin: 0 0 .75rem;
  color: var(--schema-accent);
  font-size: .95rem;
}

.schema-flat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: .6rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.schema-flat-entity {
  min-width: 0;
  padding: .65rem .8rem;
  border: 1px solid var(--schema-border);
  border-inline-start: 2px solid var(--schema-accent);
  background: var(--schema-panel);
  font-size: .9rem;
}

@media (max-width: 700px) {
  .schema-stage { zoom: .75; }
  .schema-flat-groups { grid-template-columns: 1fr; }
  .schema-flat-group + .schema-flat-group { border-inline-start: 0; }
}
