/* R42.7 · explicit Universal Ledger workspace-state contract
   Apple iPhone reference principle: one coherent composition per state,
   deliberate responsive reflow, and consistent interaction semantics.

   State ownership:
   - data-workspace-state="browse": records own the workspace.
   - data-workspace-state="editing": editor is explicitly active.
   No :has() inference, no .open-driven geometry, no fixed editor overlays.
*/

.ledger-workspace{
  --ledger-editor-track:clamp(360px,34vw,520px);
  min-width:0!important;
  min-height:0!important;
  overflow:hidden!important;
}

.ledger-workspace[data-workspace-state="browse"]{
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
}

.ledger-workspace[data-workspace-state="browse"] .ledger-table-pane{
  display:block!important;
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  overflow:auto!important;
  border-right:0!important;
}

.ledger-workspace[data-workspace-state="browse"] .ledger-editor-pane{
  display:none!important;
}

.ledger-workspace[data-workspace-state="editing"]{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) var(--ledger-editor-track)!important;
}

.ledger-workspace[data-workspace-state="editing"] .ledger-table-pane{
  display:block!important;
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  overflow:auto!important;
  border-right:1px solid rgba(255,255,255,.08)!important;
}

.ledger-workspace[data-workspace-state="editing"] .ledger-editor-pane{
  display:block!important;
  position:static!important;
  inset:auto!important;
  z-index:auto!important;
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  min-height:0!important;
  overflow:auto!important;
}

/* Cards are owned by the records pane. They may reflow inside it, never paint outside it. */
.ledger-workspace .ledger-table-pane.cards-mode{
  overflow:auto!important;
}

.ledger-workspace #ledgerTable[data-view="cards"]{
  box-sizing:border-box!important;
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr))!important;
}

.ledger-workspace #ledgerTable[data-view="cards"] > *{
  min-width:0!important;
  max-width:100%!important;
}

/* Once the available main canvas becomes constrained, editing owns the whole workspace.
   This avoids two simultaneous interactive surfaces competing for attention or geometry. */
@media(max-width:1279px){
  .ledger-workspace[data-workspace-state="editing"]{
    grid-template-columns:minmax(0,1fr)!important;
  }

  .ledger-workspace[data-workspace-state="editing"] .ledger-table-pane{
    display:none!important;
  }

  .ledger-workspace[data-workspace-state="editing"] .ledger-editor-pane{
    grid-column:1!important;
    width:100%!important;
    max-width:100%!important;
    border-radius:0!important;
  }
}

@media(max-width:620px){
  .ledger-workspace[data-workspace-state="editing"] .ledger-editor-pane{
    overflow:auto!important;
  }

  .ledger-editor-head{
    flex-wrap:wrap!important;
  }

  .ledger-editor-head > div:first-child{
    flex:1 1 180px!important;
  }
}
