.experiment { padding-block: 1.4rem 3rem; }
.experiment-head { display: grid; gap: .65rem; margin-bottom: 1.2rem; }
.back-link { justify-self: start; font-size: .9rem; font-weight: 650; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.experiment-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.experiment-heading h1 { overflow-wrap: anywhere; }
.experiment-heading .code { font-size: .85rem; font-weight: 650; color: var(--muted); margin-bottom: .35rem; }
.shared-by { font-size: .9rem; color: var(--muted); margin-top: .35rem; }
.record-actions .button { font-size: .85rem; min-height: 2.25rem; }
.save-state {
  display: inline-flex; align-items: center; gap: .45rem; flex-shrink: 0;
  padding: .3rem .65rem; border-radius: 1rem; color: #135a52; background: var(--wash); font-size: .86rem; font-weight: 700;
}
.save-state::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.save-state[data-state="saving"] { color: #425e66; background: #dfe9eb; }
.save-state[data-state="failed"], .save-state[data-state="conflict"] { color: var(--alert); background: var(--signal); }
.save-feedback {
  display: grid; gap: .5rem; margin-bottom: 1rem; padding: .7rem 1rem;
  color: var(--alert); border-left: 3px solid var(--alert); background: var(--signal);
}
.experiment > .operation-status { margin-bottom: .8rem; }

.builder-grid { display: grid; grid-template-columns: minmax(8rem, 10.5rem) minmax(0, 1fr) minmax(0, 1.05fr); gap: 1rem; align-items: start; }
.builder-grid:has(.preview-pane:first-child) { grid-template-columns: minmax(0, 48rem); justify-content: center; }
.block-library, .editor-pane, .preview-pane { min-width: 0; }
.block-library { padding-top: .6rem; position: sticky; top: .6rem; }
.block-library p { color: var(--muted); font-size: .85rem; margin: .35rem 0 .8rem; }
.library-items { display: grid; gap: .4rem; }
.library-item, .block-toggle { display: flex; align-items: center; gap: .5rem; text-align: left; font-weight: 650; }
.library-item { min-height: 2.5rem; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--surface); }
.library-item:hover:not(:disabled) { border-color: var(--accent); }
.library-plus { margin-left: auto; color: var(--accent); }
.block-icon {
  display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem;
  border-radius: .25rem; color: var(--accent); background: var(--wash); font-size: .9rem; flex: none;
}
.pane-label { display: flex; justify-content: space-between; align-items: baseline; padding: .6rem 0 .7rem; }
.pane-label span { font-size: .84rem; color: var(--muted); font-weight: 600; }
.preview-label { align-items: center; gap: .6rem; }
.pane-switch { display: none; }
.block-stack { display: grid; gap: .7rem; }
.block-card { background: var(--surface); border: 1px solid var(--line); border-radius: .5rem; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .35rem; padding: .5rem .65rem; }
.block-toggle { border: 0; background: transparent; padding: .3rem 0; }
.block-toggle::after { content: "⌄"; color: var(--muted); }
.block-toggle[aria-expanded="false"]::after { content: "›"; }
.drag-grip { cursor: grab; padding-inline: .2rem; color: var(--muted); user-select: none; }
.block-tools { display: flex; flex-wrap: wrap; gap: .22rem; margin-left: auto; }
.block-tools .button { min-height: 2rem; padding: .2rem .36rem; font-size: .8rem; }
.block-body { border-top: 1px solid var(--line); padding: .9rem; }
.row-editor { border: 1px solid var(--line); border-radius: .35rem; margin: 0; min-width: 0; padding: .75rem; }
.row-editor legend { font-weight: 650; padding-inline: .3rem; }
.row-editor > .button { margin-top: .4rem; }
.cocktail-fields {
  display: grid; grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(0, 1fr));
  gap: .45rem; overflow-wrap: anywhere;
}
.cocktail-fields > .field:nth-child(-n+3) { grid-row: span 2; grid-template-rows: subgrid; }
.cocktail-fields > .field:last-child { grid-column: 1 / -1; }
.treatment-schedule { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }

.preview-page {
  container-type: inline-size;
  padding: clamp(.55rem, 1.3vw, 1.1rem); background: #dce7e5;
  border: 1px solid var(--line); border-radius: .5rem;
}
.paper {
  container-type: inline-size;
  width: 100%;
  background: #fff; padding: 9.5%; color: #1b2929; overflow-wrap: anywhere;
  font: .875rem/1.5 Arial, Aptos, sans-serif;
}
.preview-page > .paper { min-height: 141.43cqw; }
.record-header { padding-bottom: .9rem; border-bottom: 1px solid #9db3af; }
.record-code { color: #405f5b; font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.paper h1 { font-size: clamp(1.25rem, 2.1vw, 1.8rem); letter-spacing: -.035em; margin: .55rem 0; }
.record-meta { display: flex; flex-wrap: wrap; gap: .2rem .65rem; color: #405f5b; font-size: .78rem; }
.record-section { margin-top: 1rem; }
.record-section h2 { font-size: 1rem; margin-bottom: .35rem; }
.record-text, .record-facts dd, .record-table td, .record-steps li { white-space: pre-wrap; }
.record-facts { display: grid; grid-template-columns: minmax(5ch, 1fr) minmax(0, 1.4fr); gap: .25rem .55rem; margin: 0; }
.record-facts dt { font-weight: 700; }
.record-facts dd { margin: 0; }
.record-models { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-top: 1rem; }
.record-models > .record-section { margin: 0; padding: .55rem; border: 1px solid #b8c9c6; }
.record-models .record-facts { font-size: .8rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@container (width < 320px) {
  .record-models { grid-template-columns: minmax(0, 1fr); }
}
.record-table { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: .8rem; }
.record-table th, .record-table td { border: 1px solid #b8c9c6; text-align: left; padding: .3rem .4rem; vertical-align: top; }
.record-table th { background: #edf4f2; }
.group-table th:nth-child(2) { width: 15%; }
.group-table th:nth-child(3) { width: 51%; }
.cocktail-table th:first-child { width: 38%; }
.record-steps { margin: 0; padding-left: 1.3rem; }
.record-steps li + li { margin-top: .35rem; }
.protocol-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .8rem; }
.protocol-table caption { text-align: left; color: #405f5b; font-weight: 700; margin-bottom: .3rem; }
.protocol-table th, .protocol-table td { padding: .3rem .45rem; text-align: left; vertical-align: top; border: 1px solid #b8c9c6; }
.protocol-table thead th { background: #edf4f2; }
.protocol-table thead th:first-child { width: 23%; }
.protocol-table tbody th { font-variant-numeric: tabular-nums; }
.timeline-events { list-style: none; margin: 0; padding: 0; }
.timeline-events li + li { margin-top: .25rem; }
.timeline-route { display: inline-block; padding-inline: .3em; background: #edf4f2; color: #405f5b; }
.timeline-rest, .timeline-note { color: #405f5b; }
.timeline-note { font-size: .76rem; margin-top: .35rem; }
.history-item { border: 1px solid var(--line); padding: .7rem; border-radius: .35rem; }
.history-item summary { cursor: pointer; font-weight: 650; overflow-wrap: anywhere; }
.history-detail { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.history-item .paper { border: 1px solid var(--line); margin-top: .75rem; }

@media (max-width: 1110px) {
  .builder-grid { grid-template-columns: minmax(8rem, 10.5rem) minmax(0, 1fr); }
  .builder-grid[data-pane="editor"] .preview-pane { display: none; }
  .builder-grid[data-pane="preview"] .editor-pane, .builder-grid[data-pane="preview"] .block-library { display: none; }
  .builder-grid[data-pane="preview"] { grid-template-columns: minmax(0, 43rem); justify-content: center; }
  .pane-switch { display: flex; margin-bottom: .5rem; }
  .pane-switch [aria-pressed="true"] { background: var(--wash); border-color: var(--accent); }
}
@media (max-width: 690px) {
  .builder-grid { grid-template-columns: minmax(0, 1fr); gap: .55rem; }
  .block-library { position: static; }
  .library-items { grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); }
  .drag-grip { display: none; }
  .experiment-heading { align-items: flex-start; }
  .block-tools { margin-left: 0; }
}
@media (max-width: 355px) {
  .treatment-schedule { grid-template-columns: minmax(0, 1fr); }
}
