/* Workspace grid by work mode, column resizers, the node index and the empty state. */
.workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--left-width, 300px) 0 minmax(0, 1fr) 0 var(--right-width, 380px);
  grid-template-rows: minmax(0, 1fr);
}
.workspace:focus {
  outline: none;
}
.workspace > .library { grid-area: 1 / 1; }
.workspace > #leftResize { grid-area: 1 / 2; }
.workspace > .stage { grid-area: 1 / 3; }
.workspace > #rightResize { grid-area: 1 / 4; }
.workspace > .inspector { grid-area: 1 / 5; }
/* The route dock shares the graph's cell and floats over its bottom edge. */
.workspace > .route-dock { grid-area: 1 / 3; }
.workspace > .empty-state { grid-area: 1 / 1 / 2 / -1; }

/* Story settings, catalogs and preview use the whole width. */
.workspace:not([data-mode="node"]) > :is(.library, .stage, .panel-resize, .route-dock) {
  display: none;
}
.workspace:not([data-mode="node"]) > .inspector {
  grid-area: 1 / 1 / 2 / -1;
  border-left: 0;
}
#app[data-empty="true"] .workspace > :not(.empty-state) {
  display: none;
}

.panel {
  min-height: 0;
  min-width: 0;
  background: var(--color-surface);
}
.panel-resize {
  position: relative;
  z-index: var(--z-resizer);
  width: 12px;
  margin-inline: -6px;
  cursor: col-resize;
  touch-action: none;
}
.panel-resize::after {
  content: "";
  position: absolute;
  inset: 0 5px;
  background: transparent;
}
.panel-resize:hover::after,
.panel-resize:focus-visible::after,
body.resizing-panels .panel-resize::after {
  background: var(--color-accent);
}
.panel-resize:focus-visible {
  outline: none;
}
body.resizing-panels {
  cursor: col-resize;
  user-select: none;
}

/* Node index */
.library {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
}
.library-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-7) var(--space-7) var(--space-6);
}
.library-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.library-title h2 {
  font: 700 var(--font-size-2xl)/1.3 var(--font-serif);
}
.mono-count {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--control-height);
  padding: 0 var(--space-6);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.search-field:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.search-field .icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}
.search-field input {
  min-height: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.search-field input:focus-visible {
  outline: none;
}
.library-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 var(--space-4) var(--space-4);
}
.list-count {
  margin: 0 var(--space-4) var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.node-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.node-row {
  display: flex;
  gap: var(--space-5);
  width: 100%;
  padding: var(--space-5);
  border-radius: var(--radius-md);
  text-align: left;
}
.node-row:hover {
  background: var(--color-hover);
}
.node-row.active {
  background: var(--color-accent-tint);
}
.node-row:focus-visible {
  outline-offset: -2px;
}
.kind-marker {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
}
.kind-marker--filled { background: var(--color-marker-text); }
.kind-marker--ring { box-shadow: inset 0 0 0 2px var(--color-marker-ring); }
.kind-marker--accent { background: var(--color-accent); }
.kind-marker--positive { background: var(--color-positive); }
.node-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.node-row-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
}
.node-row-id {
  font: 500 var(--font-size-xs)/1.5 var(--font-mono);
}
.node-row-points {
  flex: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.node-row-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-text-2);
  font-size: var(--font-size-sm);
}
.library-foot {
  flex: none;
  padding: var(--space-6) var(--space-7);
  border-top: 1px solid var(--color-border);
}
.empty {
  padding: var(--space-9) var(--space-7);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.empty strong {
  display: block;
  margin-bottom: var(--space-3);
  color: var(--color-text);
  font: 700 var(--font-size-md) var(--font-serif);
}

/* Empty state (no story in this browser) */
.empty-state {
  display: grid;
  place-items: center;
  padding: var(--space-9) var(--space-7);
  overflow: auto;
  background: var(--color-surface);
}
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  max-width: 420px;
  text-align: center;
}
.empty-state picture {
  display: contents;
}
.empty-state-mark {
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-3);
}
.empty-state h1 {
  font: 700 var(--font-size-3xl)/1.3 var(--font-serif);
  letter-spacing: 0.02em;
}
.empty-state p {
  margin: 0;
  color: var(--color-text-muted);
  line-height: 1.7;
}
.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-5);
  margin-top: var(--space-4);
}
.empty-state-actions button {
  min-width: 140px;
  min-height: var(--touch-target);
}
.empty-state .link-button {
  min-height: var(--touch-target);
}
