/* ZR Orion V123.31 RC11.9.4 — structural grid repair
   Removes phantom tracks, empty companion cells, forced row heights, and text overlays. */

/* Every editorial block sizes from its own content. */
body.mi-system main :where(.mi-pillars,.mi-signal-grid,.mi-tension-grid,.mi-domain-bands,.mi-consequence-sequence,.mi-depth-grid,.mi-strategic-progression),
body.platform-content main :where(.pe-foundations,.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis,.pe-signal-bands,.pe-semantic-bands,.pe-boundaries,.pe-flow,.pe-engineering-flow){
  min-height:0!important;
  height:auto!important;
  grid-auto-rows:auto!important;
  align-items:stretch!important;
  align-content:start!important;
}
body.mi-system main :where(.mi-pillar,.mi-signal-grid>li,.mi-tension-grid>li,.mi-domain-bands>li,.mi-consequence-sequence>li,.mi-depth-grid>*,.mi-strategic-progression>li),
body.platform-content main :where(.pe-foundations>*,.pe-ledger>*,.pe-atlas>*,.pe-kernel>*,.pe-evidence-chain>*,.pe-memory>*,.pe-knowledge-basis>*,.pe-signal-bands>*,.pe-semantic-bands>*,.pe-boundaries>*,.pe-flow>*,.pe-engineering-flow>*){
  min-height:0!important;
  height:auto!important;
  grid-column:auto!important;
  grid-row:auto!important;
  overflow:visible!important;
}

/* Mission Intelligence foundation summary: exact 2 x 2 layout, never a fifth phantom track. */
body.mi-system .mi-pillars{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:1px!important;
  background:var(--mi-line,rgba(103,223,245,.2))!important;
}
body.mi-system .mi-pillars>.mi-pillar{
  display:block!important;
  padding:clamp(1.35rem,2.3vw,2.2rem)!important;
  background:#04111c!important;
  border:0!important;
  border-radius:0!important;
}

/* Five Foundations: one natural row per foundation with horizontal desktop alignment. */
body.platform-content .pe-foundations{
  display:flex!important;
  flex-direction:column!important;
  gap:1px!important;
  background:rgba(103,223,245,.18)!important;
  border:1px solid rgba(103,223,245,.18)!important;
}
body.platform-content .pe-foundations>.card{
  display:grid!important;
  grid-template-columns:minmax(220px,.8fr) minmax(0,1.25fr) minmax(260px,1fr)!important;
  align-items:start!important;
  gap:clamp(1rem,2.4vw,2rem)!important;
  padding:clamp(1.25rem,2.2vw,2rem)!important;
  background:#04111c!important;
  border:0!important;
  border-radius:0!important;
}
body.platform-content .pe-foundations>.card h3,
body.platform-content .pe-foundations>.card p,
body.platform-content .pe-foundations>.card .question{
  margin:0!important;
  writing-mode:horizontal-tb!important;
  word-break:normal!important;
  overflow-wrap:anywhere!important;
}
body.platform-content .pe-foundations>.card .question{
  grid-column:auto!important;
  padding-left:1rem!important;
  border-left:2px solid var(--pe-cyan,#22d3ee)!important;
}

/* Lists previously rendered as split tables become full-width natural bands. */
body.platform-content :where(.pe-signal-bands,.pe-semantic-bands),
body.mi-system :where(.mi-domain-bands,.mi-consequence-sequence){
  display:flex!important;
  flex-direction:column!important;
  gap:1px!important;
  padding:0!important;
  margin-top:clamp(1.4rem,2.2vw,2rem)!important;
  background:rgba(103,223,245,.18)!important;
  border:1px solid rgba(103,223,245,.18)!important;
}
body.platform-content :where(.pe-signal-bands,.pe-semantic-bands)>li,
body.mi-system :where(.mi-domain-bands,.mi-consequence-sequence)>li{
  display:block!important;
  width:100%!important;
  padding:1rem 1.25rem!important;
  margin:0!important;
  background:#04111c!important;
  border:0!important;
  line-height:1.5!important;
}
/* Remove generated labels that were painting over the real text. */
body.platform-content :where(.pe-signal-bands,.pe-semantic-bands)>li::before{
  content:none!important;
  display:none!important;
}

/* Card matrices: flex-wrap prevents any empty CSS-grid track from being drawn. */
body.platform-content :where(.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis,.pe-boundaries){
  display:flex!important;
  flex-wrap:wrap!important;
  gap:1px!important;
  padding:0!important;
  background:rgba(103,223,245,.18)!important;
  border:1px solid rgba(103,223,245,.18)!important;
}
body.platform-content :where(.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis,.pe-boundaries)>*{
  flex:1 1 300px!important;
  width:auto!important;
  max-width:none!important;
  padding:clamp(1.15rem,2vw,1.8rem)!important;
  background:#04111c!important;
  border:0!important;
  border-radius:0!important;
}
/* Last items naturally expand instead of leaving an empty companion cell. */
body.platform-content :where(.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis,.pe-boundaries)>*:last-child{
  flex-grow:2!important;
}

/* MIOS state and contract rows: no overlay, no generated numbering, no clipped text. */
body.platform-content :where(.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis) :where(li,div)::before{
  max-width:100%!important;
}
body.platform-content .pe-ledger>li{
  display:block!important;
  padding:1rem 1.2rem!important;
}
body.platform-content .pe-ledger>li::before{
  position:static!important;
  display:block!important;
  margin:0 0 .45rem!important;
  transform:none!important;
}

/* Sequential flows: content-width cards only; no manufactured blank final row. */
body.platform-content :where(.pe-flow,.pe-engineering-flow),
body.mi-system :where(.mi-path,.mi-loop,.mi-strategic-progression){
  display:flex!important;
  flex-wrap:wrap!important;
  gap:1px!important;
  background:rgba(103,223,245,.18)!important;
  border:1px solid rgba(103,223,245,.18)!important;
}
body.platform-content :where(.pe-flow,.pe-engineering-flow)>*,
body.mi-system :where(.mi-path,.mi-loop,.mi-strategic-progression)>*{
  flex:1 1 210px!important;
  width:auto!important;
  min-height:0!important;
  background:#04111c!important;
}
body.platform-content :where(.pe-flow,.pe-engineering-flow)>*:last-child,
body.mi-system :where(.mi-path,.mi-loop,.mi-strategic-progression)>*:last-child{
  flex-grow:2!important;
}

/* Compact section rhythm after removing phantom rows. */
body.mi-system .mi-section,
body.platform-content .section{
  padding-top:clamp(2.6rem,4vw,4.5rem)!important;
  padding-bottom:clamp(2.6rem,4vw,4.5rem)!important;
}

@media(max-width:900px){
  body.platform-content .pe-foundations>.card{grid-template-columns:1fr!important}
  body.platform-content .pe-foundations>.card .question{padding-left:0!important;padding-top:.9rem!important;border-left:0!important;border-top:1px solid rgba(103,223,245,.22)!important}
}
@media(max-width:700px){
  body.mi-system .mi-pillars{grid-template-columns:1fr!important}
  body.platform-content :where(.pe-ledger,.pe-atlas,.pe-kernel,.pe-evidence-chain,.pe-memory,.pe-knowledge-basis,.pe-boundaries)>*,
  body.platform-content :where(.pe-flow,.pe-engineering-flow)>*,
  body.mi-system :where(.mi-path,.mi-loop,.mi-strategic-progression)>*{flex-basis:100%!important}
}
