/*
 * Qubibyte Chemistry: the page's own layout, on Qubibyte Graphics' tokens and
 * controls (tokens.css, base.css, playground.css), like Qubibyte 3D.
 *
 * Every size that decides the layout is fixed here, at every width, so the
 * first frame is the final one (see the no-transient-frames skill):
 *   1200 px and up: library | stage | details, all one screen high.
 *   760 to 1199 px: library | stage, and the details fold under the stage.
 *   under 760 px:   one column; the panels are accordions under the stage.
 */

/* Fonts: the page's own small subsets, declared and preloaded in index.html
   (font-display: optional, so no face ever swaps after the first paint).
   The fallbacks are Arial and Courier New scaled to the same metrics. */
:root {
  --font-ui: 'Molecule Inter', 'Molecule Inter Fallback', system-ui, sans-serif;
  --font-code: 'Molecule Mono', 'Molecule Mono Fallback', ui-monospace, monospace;
}

:root {
  --mol-lib-w: 248px;
  --mol-side-w: 296px;
  --mol-tabs-h: 40px;
  --mol-readout-h: 32px;
  --mol-row-h: 48px;
  --mol-ink: var(--text);
  /* Periodic table tints: quiet, the same lightness, readable in both themes. */
  --pt-alkali: color-mix(in oklab, #e0795f 26%, transparent);
  --pt-alkaline: color-mix(in oklab, #d9a35b 26%, transparent);
  --pt-transition: color-mix(in oklab, #8f9bb3 22%, transparent);
  --pt-post: color-mix(in oklab, #6fae9a 24%, transparent);
  --pt-metalloid: color-mix(in oklab, #a3a65a 26%, transparent);
  --pt-nonmetal: color-mix(in oklab, #5b8def 26%, transparent);
  --pt-halogen: color-mix(in oklab, #4fb3bf 26%, transparent);
  --pt-noble: color-mix(in oklab, #9a7fd1 26%, transparent);
  --pt-lanthanide: color-mix(in oklab, #c77fa8 24%, transparent);
  --pt-actinide: color-mix(in oklab, #b0707a 26%, transparent);
  --pt-unknown: color-mix(in oklab, #86847e 14%, transparent);
}

/* ── Shell ───────────────────────────────────────────────────────── */

.mol-app {
  min-width: 0;
}

.mol-workspace {
  display: grid;
  grid-template-columns: var(--mol-lib-w) minmax(0, 1fr) var(--mol-side-w);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}

.mol-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.mol-lib {
  border-right: var(--hairline) solid var(--border);
}

.mol-side {
  border-left: var(--hairline) solid var(--border);
}

.wordmark-text {
  letter-spacing: -0.005em;
}

.topbar .icon,
.btn .icon {
  width: var(--icon);
  height: var(--icon);
}

.btn.sm .icon {
  width: 14px;
  height: 14px;
}

/* The theme button shows the theme it switches to. */
:root:not([data-ui-theme='light']) .mol-ic-moon,
:root[data-ui-theme='light'] .mol-ic-sun {
  display: none;
}

.panel-header .section-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fold buttons: the library folds on phones only; the three sections on
   the right fold at every width (their header is the switch). */
.acc-tog {
  display: none;
}

.side-sec > .acc-head {
  cursor: pointer;
  user-select: none;
}

.side-sec .acc-tog {
  display: inline-grid;
}

.side-sec.acc:not(.is-open) > .acc-body {
  display: none;
}

.side-sec.acc.is-open .acc-tog .icon {
  transform: rotate(180deg);
}

/* A folded section's header says what is inside. */
.acc-sum {
  display: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-sec.acc:not(.is-open) > .acc-head .section-title {
  flex: none;
}

.side-sec.acc:not(.is-open) > .acc-head .acc-sum:not(:empty) {
  display: block;
}

/* A chart section with nothing in it is not shown. On Drug, the facts are
   the ligand's, so with no complex open there are none to show. */
.side-chart:has(> #chart:empty),
.mol-app[data-tab='drug']:not([data-kind='pdb']) .mol-side > .side-sec:first-child {
  display: none;
}

/* Folded headers stack with one hairline between them. */
.side-sec.acc:not(.is-open):not(:last-child) > .acc-head {
  border-bottom-color: transparent;
}

.mol-app[data-tab='structure'] .side-run.acc:not(.is-open) > .acc-head {
  border-bottom-color: var(--border);
}

.acc-tog .icon {
  width: 14px;
  height: 14px;
  transition: transform var(--dur-fast) var(--ease-standard);
}

/* ── Library ─────────────────────────────────────────────────────── */

.lib-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.lib-count {
  flex: none;
  color: var(--text-faint);
  font-size: var(--text-xs);
}

.lib-search {
  position: relative;
  flex: none;
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.lib-search .icon {
  position: absolute;
  left: calc(var(--space-3) + 9px);
  top: calc(var(--space-3) + 8px);
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}

.lib-search .input {
  height: 30px;
  padding-left: 30px;
  font-size: var(--text-md);
}

.lib-search .input::-webkit-search-cancel-button {
  filter: grayscale(1) opacity(0.6);
}

.lib-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-0);
  flex: none;
  margin: 0 var(--space-3) var(--space-2);
  padding: var(--space-0);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
}

.lib-tabs button {
  height: 22px;
  padding: 0 var(--space-1);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-tabs button:hover {
  color: var(--text);
}

/* Categories toggle: none picked searches everything, a picked one limits the list to it. */
.lib-tabs button[aria-pressed='true'] {
  background: var(--accent-solid);
  color: var(--on-accent);
  font-weight: var(--weight-semibold, 600);
}

.lib-tabs button[aria-pressed='true']:hover {
  background: var(--accent-solid-hover);
  color: var(--on-accent);
}

.lib-tabs button:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: -2px;
}

/* One fixed-height line between the tabs and the list: a filter, a field or a button. */
.lib-extra {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  height: 36px;
  padding: 0 var(--space-3) var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* The Sort menu and the order button, under that line (LIB-SORT; paint-boot.js fills it first). */
.lib-sort {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: none;
  height: 32px;
  padding: 0 var(--space-3) var(--space-2);
  border-bottom: var(--hairline) solid var(--border);
}

.lib-sort .lib-sort-by {
  /* As wide as its longest option needs, not the whole row. */
  flex: 0 1 auto;
  min-width: 0;
  height: var(--control-h-sm);
  border-color: var(--mol-field-edge);
  background: var(--mol-field);
}

.lib-sort .lib-sort-by:hover {
  background: var(--surface-hover);
}

.lib-sort .lib-sort-by select {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  padding-right: var(--space-5);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
}

.lib-sort .lib-sort-dir {
  flex: none;
  border-color: var(--mol-field-edge);
  background: var(--mol-field);
}

.lib-sort .lib-sort-dir:hover:not(:disabled) {
  background: var(--surface-hover);
}

.lib-sort .lib-sort-dir:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.lib-sort .lib-sort-dir .icon {
  width: 14px;
  height: 14px;
}

/* The order button sits at the panel's right edge: its tip opens leftwards. */
.lib-sort .lib-sort-dir[data-tip]::after {
  left: auto;
  right: 0;
  transform: none;
}

.lib-extra .input {
  height: 26px;
  font-size: var(--text-sm);
}

.lib-extra .btn {
  flex: none;
}

.lib-extra .lib-wide {
  flex: 1;
}

.lib-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.lib-check .check {
  width: 14px;
  height: 14px;
}

.lib-extra .lib-note {
  margin-left: auto;
  color: var(--text-faint);
  white-space: nowrap;
}

.lib-list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
  overscroll-behavior: contain;
}

.lib-spacer {
  position: relative;
  width: 100%;
}

.lib-row {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  height: var(--mol-row-h);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.lib-row:hover {
  background: var(--surface-hover);
}

.lib-row[aria-selected='true'] {
  background: var(--accent-wash);
}

/* The open entry: a tinted row and a stronger name, clear in both themes. */
.lib-row.is-active,
.lib-row.is-active:hover {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
}

.lib-row.is-active .lib-name {
  color: var(--accent-text);
  font-weight: var(--weight-semibold, 600);
}

.lib-thumb {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text-muted);
  overflow: hidden;
}

.lib-thumb .m2-thumb {
  display: block;
}

.lib-thumb--sym {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.lib-thumb--code {
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  letter-spacing: -0.02em;
}

.lib-main {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.lib-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: 18px;
}

.lib-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 15px;
}

.lib-sub .num {
  margin-left: 6px;
}

/* The value the list is sorted by, first on the line (LIB-SORT). */
.lib-sub .lib-sortval {
  margin-left: 0;
  margin-right: 6px;
  color: var(--text);
}

.lib-sub .num,
.lib-sub.num {
  font-family: var(--font-code);
  font-size: var(--text-2xs);
}

.lib-flag {
  justify-self: end;
  padding: 0 5px;
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  line-height: 15px;
  white-space: nowrap;
}

.lib-flag.is-q {
  border-color: var(--accent-line);
  color: var(--accent-text);
}

.lib-empty {
  padding: var(--space-4) var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.lib-empty strong {
  color: var(--text);
  font-weight: var(--weight-medium);
}

/* A kind's header in the list (30px; library.js GROUP_H). */
.lib-group {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 30px;
  padding: 0 var(--space-3) 6px;
  color: var(--text-faint);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.lib-group .num {
  font-family: var(--font-code);
  font-weight: var(--weight-regular);
  letter-spacing: 0;
}

/* "Show all" under a kind with more than it shows (34px; library.js MORE_H). */
.lib-row.lib-more {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 34px;
  padding-left: calc(var(--space-3) + 36px + var(--space-3));
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.lib-row.lib-more:hover,
.lib-row.lib-more:focus-visible {
  color: var(--text);
}

.lib-more .icon {
  width: 12px;
  height: 12px;
}

/* ── Centre: tabs, stage, readout ────────────────────────────────── */

.mol-centre {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--stage);
}

.mol-tabs {
  flex: none;
  height: var(--mol-tabs-h);
  gap: var(--space-5);
  padding: 0 var(--space-4);
  background: var(--surface);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.mol-tabs::-webkit-scrollbar {
  display: none;
}

.mol-tabs [role='tab'][aria-selected='true']::after {
  bottom: 0;
}

.mol-tabs [role='tab'] {
  flex: none;
  font-size: var(--text-md);
  white-space: nowrap;
}

.mol-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
}

.mol-2d,
.mol-3d,
.mol-card,
.tab-pane {
  position: absolute;
  inset: 0;
}

.mol-2d {
  display: block;
  width: 100%;
  height: 100%;
}

.mol-3d {
  display: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.mol-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  touch-action: none;
}

.mol-card,
.tab-pane,
.stage-note {
  display: none;
}

/* What the stage shows: the mode and the kind of subject decide it. */
.mol-app[data-mode='3d'] .mol-2d { display: none; }
.mol-app[data-mode='3d'] .mol-3d { display: block; }
.mol-app[data-kind='element'][data-mode='2d'] .mol-2d { display: none; }
.mol-app[data-kind='element'][data-mode='2d'] .mol-card { display: grid; }
.mol-app[data-kind='pdb'] .mol-2d { display: none; }
.mol-app[data-kind='pdb'] .mol-3d { display: block; }
.mol-app[data-kind='pdb'] #mode-seg,
.mol-app[data-kind='pdb'] #h-btn { display: none; }
.mol-app[data-kind='peptide'][data-mode='2d'] .mol-2d { display: none; }
.mol-app[data-kind='peptide'][data-mode='2d'] .mol-card { display: grid; }

.mol-app:not([data-tab='structure']) .stage-tools { display: none; }
.mol-app:not([data-tab='structure']) .mol-2d,
.mol-app:not([data-tab='structure']) .mol-card { visibility: hidden; }
.mol-app[data-tab='hamiltonian'] .tab-pane[data-pane='hamiltonian'],
.mol-app[data-tab='ground'] .tab-pane[data-pane='ground'],
.mol-app[data-tab='dynamics'] .tab-pane[data-pane='dynamics'],
.mol-app[data-tab='folding'] .tab-pane[data-pane='folding'],
.mol-app[data-tab='drug'] .tab-pane[data-pane='drug'] {
  display: block;
}

/* Folding and Drug draw in the 3D view; their panes only hold overlays. */
.mol-app[data-tab='folding'] .mol-3d,
.mol-app[data-tab='drug'] .mol-3d { display: block; }
.mol-app[data-tab='folding'] .tab-pane,
.mol-app[data-tab='drug'] .tab-pane { pointer-events: none; }
.mol-app[data-tab='folding'] .tab-pane > *,
.mol-app[data-tab='drug'] .tab-pane > * { pointer-events: auto; }
.mol-app[data-tab='hamiltonian'] .mol-3d,
.mol-app[data-tab='ground'] .mol-3d,
.mol-app[data-tab='dynamics'] .mol-3d { display: none; }

.stage-note {
  position: absolute;
  inset: 0;
  place-items: center;
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  pointer-events: none;
}

.stage-note:not(:empty) {
  display: grid;
}

.mol-app:not([data-tab='structure']) .stage-note { display: none; }

/* Nothing picked: no drawing, one quiet line in the middle of the stage. */
.mol-app[data-kind='none'] .mol-2d,
.mol-app[data-kind='none'] .mol-3d,
.mol-app[data-kind='none'] .mol-card {
  display: none;
}

.mol-app[data-kind='none'] #h-btn,
.mol-app[data-kind='none'] #view-seg,
.mol-app[data-kind='none'] #fit-btn,
.mol-app[data-kind='none'] #spin-btn,
.mol-app[data-kind='none'] #measure-btn {
  visibility: hidden;
}

.stage-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  max-width: 340px;
}

.stage-empty b {
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.stage-empty span {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* The tools float in the stage's corners. */
.stage-tools {
  position: absolute;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  top: var(--space-3);
}

.stage-tl {
  left: var(--space-3);
  right: 240px;
  flex-wrap: wrap;
}

.stage-tr {
  right: var(--space-3);
}

.stage-tools .seg {
  background: var(--surface);
}

.stage-tools .select {
  height: var(--control-h-sm);
  background: var(--surface);
}

.stage-tools .select:hover {
  background: var(--surface-hover);
}

.stage-tools .select select {
  font-size: var(--text-xs);
  padding-right: var(--space-5);
}

.stage-tools .btn.sm {
  height: var(--control-h-sm);
  gap: var(--space-1);
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.stage-tools .btn.sm:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.stage-tools .btn[aria-pressed='true'] {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent-text);
}

.stage-tools .icon-btn.sm {
  border: var(--hairline) solid var(--border);
  background: var(--surface);
}

.stage-tools .icon-btn .icon {
  width: 14px;
  height: 14px;
}

#h-btn {
  min-width: 28px;
  font-weight: var(--weight-semibold);
}

.mol-app[data-mode='2d'] .st-3d { display: none; }
.mol-app:not([data-kind='pdb']) .st-pdb,
.mol-app[data-kind='pdb'] .st-mol { display: none; }
.mol-app[data-kind='pdb'] .st-3d:not(.st-mol) { display: inline-flex; }
/* The H toggle works in 3D too (stage.js passes hydrogens to the viewer). */
.mol-app[data-kind='element'] #h-btn,
.mol-app[data-kind='element'] #labels-select,
.mol-app[data-kind='element'] #measure-btn,
.mol-app[data-kind='peptide'][data-mode='2d'] #h-btn,
.mol-app[data-kind='peptide'][data-mode='2d'] #labels-select { display: none; }
.mol-app[data-kind='element'] .select:has(#labels-select),
.mol-app[data-kind='peptide'][data-mode='2d'] .select:has(#labels-select),
.mol-app[data-kind='element'] .select:has(#style-select) { display: none; }

.mol-stage.is-drop::after {
  content: '';
  position: absolute;
  inset: var(--space-2);
  border: 2px dashed var(--accent-line);
  border-radius: var(--radius-lg);
  pointer-events: none;
}

.mol-stage.is-measuring .mol-3d {
  cursor: crosshair;
}

/* One line of numbers under the stage. */
.mol-readout {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: none;
  height: var(--mol-readout-h);
  padding: 0 var(--space-4);
  border-top: var(--hairline) solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
}

.mol-readout > span {
  flex: none;
}

.mol-readout b {
  color: var(--text);
  font-weight: 400;
}

.mol-readout .ro-end {
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.mol-readout .ro-hint {
  font-family: var(--font-ui);
}

.mol-readout .ro-measure {
  color: var(--accent-text);
}

/* ── Skeletal formulas (view2d/draw2d.js) ───────────────────────── */

.m2 {
  color: var(--mol-ink);
  overflow: visible;
}

.m2-bonds,
.m2-hash {
  stroke: var(--mol-ink);
  fill: none;
}

.m2-wedge {
  fill: var(--mol-ink);
}

.m2-l,
.m2-chg {
  fill: color-mix(in oklab, var(--c) 64%, var(--text));
  font-family: var(--font-ui);
  font-weight: var(--weight-medium);
}

.m2-sub,
.m2-chg {
  font-size: 0.72em;
}

.m2-dot {
  fill: color-mix(in oklab, var(--c) 70%, var(--text));
}

.m2-thumb .m2-bonds {
  stroke: color-mix(in oklab, var(--text) 78%, transparent);
}

.m2-hl circle {
  fill: var(--accent-wash);
  stroke: var(--accent-line);
  stroke-width: 1;
}

.m2-idx text {
  fill: var(--text-faint);
  font-family: var(--font-code);
  font-size: 10px;
}

/* ── The element card (2D view of an element) ───────────────────── */

.mol-card {
  place-items: center;
  padding: var(--space-8);
}

.el-card {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: var(--space-8);
  max-width: 100%;
}

.el-tile {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  width: 184px;
  height: 184px;
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--tint, var(--surface));
}

.el-tile-z {
  position: absolute;
  top: 12px;
  left: 14px;
  font-family: var(--font-code);
  font-size: var(--text-md);
  color: var(--text-muted);
}

.el-tile-mass {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--font-code);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.el-tile-sym {
  font-size: 64px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: -0.02em;
}

.el-tile-name {
  margin-top: var(--space-2);
  font-size: var(--text-md);
  color: var(--text-muted);
}

.el-shells {
  display: block;
}

.el-shells circle.orbit {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1;
}

.el-shells circle.e {
  fill: var(--accent);
}

.el-shells circle.nucleus {
  fill: var(--text);
}

.el-shells text {
  fill: var(--text-faint);
  font-family: var(--font-code);
  font-size: 10px;
}

.pep-card {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  max-width: 100%;
}

.pep-seq {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 560px;
}

.pep-res {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 52px;
  padding: var(--space-2) 0;
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--tint, var(--surface));
}

.pep-res b {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.pep-res span {
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.pep-cap {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ── Inspector ───────────────────────────────────────────────────── */

.side-sec {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mol-side {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
}

/* 1200 px and up: one column, one screen high. On Structure the facts fill
   it and scroll inside, with the qubit count under them. On the other tabs
   the sections keep their natural height and the column scrolls as one, so
   nothing is cut off at any window height. */
@media (min-width: 1200px) {
  .mol-side {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .side-sec {
    flex: none;
  }

  .side-scroll {
    flex: none;
    overflow: visible;
  }

  /* The scrollbar's room is kept, so the column's width never changes
     when its content grows past the window. */
  .mol-app:not([data-tab='structure']) .mol-side {
    scrollbar-gutter: stable;
  }

  .mol-app[data-tab='structure'] .mol-side {
    overflow-y: hidden;
  }

  .mol-app[data-tab='structure'] .side-sec.is-open:first-child {
    flex: 1 1 auto;
  }

  .mol-app[data-tab='structure'] .side-sec:first-child .side-scroll {
    flex: 1;
    overflow: auto;
  }

  /* Drug: pick the complex first, then read about its ligand. */
  .mol-app[data-tab='drug'] .side-run {
    order: -1;
    border-top: 0;
  }

  .mol-app[data-tab='drug'] .mol-side > .side-sec:first-child {
    border-top: var(--hairline) solid var(--border);
  }
}

.mol-app[data-tab='structure'] .side-chart {
  display: none;
}

.side-run,
.side-chart {
  border-top: var(--hairline) solid var(--border);
}

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

#inspector {
  padding: var(--space-4);
}

.in-name {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.in-formula {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-md);
}

.in-formula .fml {
  color: var(--text);
}

.fml sub,
.fml sup {
  font-size: 0.74em;
  line-height: 0;
}

.in-formula a {
  flex: none;
  font-size: var(--text-xs);
}

.in-aka {
  margin: var(--space-2) 0 0;
  color: var(--text);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
  overflow-wrap: anywhere;
}

.in-aka span {
  color: var(--text-muted);
}

.in-desc {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.in-block {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: var(--hairline) solid var(--border);
}

.in-block h3 {
  margin: 0 0 var(--space-2);
  color: var(--text-faint);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.in-dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
}

.in-dl dt {
  color: var(--text-muted);
  white-space: nowrap;
}

.in-dl dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-xs);
  line-height: 18px;
  white-space: nowrap;
}

.in-dl dd.txt {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: 18px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.in-dl dd .unit {
  color: var(--text-faint);
}

.in-dl dd.none {
  color: var(--text-faint);
}

.in-id {
  margin-top: var(--space-2);
}

.in-id:first-of-type {
  margin-top: 0;
}

.in-id-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.in-id-label .icon-btn {
  width: 20px;
  height: 20px;
}

.in-id-label .icon {
  width: 13px;
  height: 13px;
}

.in-id-value {
  margin-top: 2px;
  padding: 5px var(--space-2);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-xs);
  line-height: 16px;
  overflow-wrap: anywhere;
  word-break: break-all;
  max-height: 72px;
  overflow: auto;
}

.in-id-value.txt {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  word-break: normal;
}

.in-source {
  margin: var(--space-4) 0 0;
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.in-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.in-tag {
  padding: 0 6px;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: var(--text-2xs);
  line-height: 16px;
}

.in-chains {
  display: grid;
  gap: 4px;
}

.in-chain {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--text-sm);
}

.in-chain b {
  font-family: var(--font-code);
  font-weight: 400;
  color: var(--text);
}

.in-chain span:last-child {
  font-family: var(--font-code);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.in-ie {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-family: var(--font-code);
  font-size: var(--text-xs);
  color: var(--text);
}

.in-ie span {
  color: var(--text-faint);
}

/* ── Run panel ───────────────────────────────────────────────────── */

#run-panel {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.run-pane {
  display: none;
}

.mol-app[data-tab='structure'] .run-pane[data-run='structure'],
.mol-app[data-tab='hamiltonian'] .run-pane[data-run='hamiltonian'],
.mol-app[data-tab='ground'] .run-pane[data-run='ground'],
.mol-app[data-tab='dynamics'] .run-pane[data-run='dynamics'],
.mol-app[data-tab='folding'] .run-pane[data-run='folding'],
.mol-app[data-tab='drug'] .run-pane[data-run='drug'] {
  display: block;
}

.run-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
}

.run-field {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.run-field--wide {
  grid-column: 1 / -1;
}

.run-field .select,
.run-field .input {
  width: 100%;
  height: 28px;
}

.run-field .select select {
  width: 100%;
}

.run-field .input.num {
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

/* Fields. An enabled one is filled and edged (a dark well, or white on the
   light panels); a disabled one is flat with faint text: grey in light, no
   fill in dark. Selects in the side panels match the text fields. */
:root {
  --mol-field: var(--bg-sunken);
  --mol-field-edge: var(--border);
  --mol-field-off: transparent;
}

:root[data-ui-theme='light'] {
  --mol-field: var(--surface-raised);
  --mol-field-edge: var(--border-strong);
  --mol-field-off: var(--bg-sunken);
}

.mol-app .input,
.mol-side .select {
  border-color: var(--mol-field-edge);
  background: var(--mol-field);
}

.mol-side .select:hover:not(:has(select:disabled)) {
  background: var(--surface-hover);
}

.mol-app .input:disabled,
.mol-side .select:has(select:disabled) {
  border-color: var(--border);
  background: var(--mol-field-off);
}

.mol-app .input:disabled,
.mol-side .select select:disabled {
  color: var(--text-faint);
  -webkit-text-fill-color: var(--text-faint);
  opacity: 1;
  cursor: not-allowed;
}

.mol-app input[type='checkbox'].check:not(:checked) {
  background: var(--mol-field);
}

.mol-app input[type='checkbox'].check:disabled {
  border-color: var(--border);
  background: var(--mol-field-off);
  cursor: not-allowed;
}

.mol-app input[type='checkbox'].check:disabled:checked {
  background: var(--text-faint);
}

.run-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-size: var(--text-sm);
  cursor: pointer;
}

.run-btns {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.run-btns .btn.primary {
  flex: 1;
}

.run-help {
  margin: var(--space-2) 0 0;
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.run-help:empty {
  display: none;
}

.run-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-1);
}

.run-fact {
  display: grid;
  gap: 1px;
  padding: var(--space-2);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.run-fact b {
  font-family: var(--font-code);
  font-size: var(--text-lg);
  font-weight: 400;
  line-height: 20px;
  color: var(--text);
}

.run-fact span {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.run-wide {
  width: 100%;
  margin-top: var(--space-3);
}

/* ── Charts (chart.js) ───────────────────────────────────────────── */

.mol-chart,
.mol-chart.qchart {
  position: relative;
  height: 216px;
  padding: 0;
}

.qchart {
  /* The background a label's knockout stroke is painted in. */
  --qc-knock: var(--surface);
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.mol-stage .qchart {
  --qc-knock: var(--stage);
}

.qchart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.qc-grid line {
  stroke: var(--border);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.qc-axis line {
  stroke: var(--border-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.qc-tick {
  fill: var(--text-faint);
  font-family: var(--font-code);
  font-size: 10px;
}

.qc-label {
  fill: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
}

.qc-band {
  fill: color-mix(in oklab, var(--success) 12%, transparent);
}

.qc-band-label {
  fill: var(--success);
  font-family: var(--font-ui);
  font-size: 10px;
}

.qc-ref {
  stroke: var(--text-faint);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  shape-rendering: crispEdges;
}

.qc-ref-label {
  fill: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 10px;
}

.qc-series-label,
.qc-cap-label {
  font-family: var(--font-ui);
  font-size: 10px;
}

.qc-cap-label {
  fill: var(--text-muted);
}

/* A label sits on its own patch of background: grid and reference lines
   under it stop short of the text instead of striking through it. */
.qc-knock {
  paint-order: stroke fill;
  stroke: var(--qc-knock);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.qc-line {
  fill: none;
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.qc-dot {
  stroke: var(--surface);
  stroke-width: 1.5;
}

.qc-cursor {
  stroke: var(--text-faint);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.qc-tip {
  position: absolute;
  z-index: var(--z-overlay);
  padding: 4px 8px;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: var(--shadow-popover);
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  line-height: 15px;
  white-space: nowrap;
  pointer-events: none;
}

.qc-tip span {
  color: var(--text-muted);
}

.qc-empty {
  display: grid;
  place-items: center;
  height: 100%;
  padding: var(--space-4);
  color: var(--text-faint);
  font-size: var(--text-xs);
  text-align: center;
}

.qc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--space-3);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.qc-legend i {
  display: inline-block;
  width: 10px;
  height: 2px;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--c);
}

/* ── Tab panes (wave 2 fills them) ───────────────────────────────── */

.pane-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  padding: var(--space-5) var(--space-6) var(--space-4);
  gap: var(--space-3);
}

.pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.pane-head h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.pane-head p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.pane-body {
  position: relative;
  min-height: 0;
}

.pane-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  line-height: var(--leading-ui);
}

.pane-empty p {
  max-width: 420px;
}

.pane-float {
  position: absolute;
  left: var(--space-4);
  bottom: var(--space-4);
  max-width: min(420px, calc(100% - 32px));
  padding: var(--space-3) var(--space-4);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.pane-float b {
  color: var(--text);
  font-weight: var(--weight-medium);
}

/* ── Periodic table popover ──────────────────────────────────────── */

.pt-pop {
  position: absolute;
  z-index: var(--z-popover);
  top: calc(var(--topbar-h) + var(--space-2));
  left: calc(var(--mol-lib-w) + var(--space-2));
  width: min(820px, calc(100vw - var(--mol-lib-w) - 16px));
  padding: var(--space-4);
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-popover);
}

.pt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.pt-head h2 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.pt-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  grid-template-rows: repeat(7, auto) 10px repeat(2, auto);
  gap: 3px;
}

.pt-cell {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  aspect-ratio: 1 / 1;
  min-width: 0;
  padding: 0;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--tint, transparent);
  color: var(--text);
  cursor: pointer;
}

.pt-cell:hover,
.pt-cell:focus-visible {
  border-color: var(--text-muted);
}

.pt-cell.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.pt-cell b {
  font-size: clamp(10px, 1.3vw, 16px);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
}

.pt-cell i {
  position: absolute;
  top: 2px;
  left: 3px;
  font-family: var(--font-code);
  font-size: 8px;
  font-style: normal;
  color: var(--text-muted);
}

.pt-info {
  height: 18px;
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.pt-info b {
  color: var(--text);
  font-weight: var(--weight-semibold);
}

.pt-info .num {
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.pt-gap {
  grid-column: 1 / -1;
}

.pt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.pt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pt-legend i {
  width: 12px;
  height: 12px;
  border: var(--hairline) solid var(--border-strong);
  border-radius: 2px;
  background: var(--tint);
  box-shadow: inset 0 0 0 12px var(--tint);
}

.pt-key {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

[data-cat='alkali-metal'] { --tint: var(--pt-alkali); }
[data-cat='alkaline-earth-metal'] { --tint: var(--pt-alkaline); }
[data-cat='transition-metal'] { --tint: var(--pt-transition); }
[data-cat='post-transition-metal'] { --tint: var(--pt-post); }
[data-cat='metalloid'] { --tint: var(--pt-metalloid); }
[data-cat='nonmetal'] { --tint: var(--pt-nonmetal); }
[data-cat='halogen'] { --tint: var(--pt-halogen); }
[data-cat='noble-gas'] { --tint: var(--pt-noble); }
[data-cat='lanthanide'] { --tint: var(--pt-lanthanide); }
[data-cat='actinide'] { --tint: var(--pt-actinide); }
[data-cat='unknown'] { --tint: var(--pt-unknown); }

/* Export menu */
.ex-list {
  display: grid;
  gap: var(--space-1);
}

.ex-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.ex-row:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.ex-row:disabled {
  opacity: 0.5;
  cursor: default;
}

.ex-row b {
  font-weight: var(--weight-medium);
  font-size: var(--text-md);
}

.ex-row span {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.ex-row code {
  color: var(--text-faint);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
}

.qb-text {
  width: 100%;
  min-height: 14em;
  font-family: var(--font-code);
  font-size: var(--code-size);
  line-height: var(--leading-code);
}

.linkish {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}

.linkish:hover {
  text-decoration: underline;
}

/* ── Medium widths: the details fold under the stage ────────────── */

@media (max-width: 1399px) {
  :root {
    --mol-lib-w: 232px;
    --mol-side-w: 280px;
  }
}

@media (max-width: 1199px) {
  body {
    overflow: auto;
  }

  .app.mol-app {
    height: auto;
    min-height: 100dvh;
  }

  .mol-workspace {
    grid-template-columns: var(--mol-lib-w) minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: auto;
  }

  .mol-lib {
    grid-row: 1 / span 2;
    position: sticky;
    top: 0;
    height: calc(100dvh - var(--topbar-h));
    align-self: start;
  }

  .mol-centre {
    height: min(640px, calc(100dvh - var(--topbar-h)));
  }

  .mol-side {
    grid-column: 2;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    border-left: 0;
    border-top: var(--hairline) solid var(--border);
  }

  .mol-side > .side-sec:first-child {
    grid-row: 1 / span 2;
    border-right: var(--hairline) solid var(--border);
  }

  .side-run {
    border-top: 0;
  }

  .mol-app[data-tab='structure'] .side-run {
    grid-row: 1 / span 2;
  }

  .side-scroll {
    overflow: visible;
  }

  .stage-tl {
    right: 200px;
  }

  .mol-hide-sm .btn-label {
    display: none;
  }

  .mol-hide-sm {
    padding: 0 var(--space-2);
  }
}

/* Medium widths with the facts folded: their header runs across the top,
   and the controls and the chart sit side by side under it. */
@media (min-width: 760px) and (max-width: 1199px) {
  .mol-side > .side-sec:first-child:not(.is-open) {
    grid-column: 1 / -1;
    grid-row: 1;
    border-right: 0;
  }

  .mol-side > .side-sec:first-child:not(.is-open) ~ .side-run {
    grid-column: 1;
    grid-row: 2;
    border-top: var(--hairline) solid var(--border);
    border-right: var(--hairline) solid var(--border);
  }

  .mol-side > .side-sec:first-child:not(.is-open) ~ .side-chart {
    grid-column: 2;
    grid-row: 2;
  }

  .mol-app[data-tab='structure'] .mol-side > .side-sec:first-child:not(.is-open) ~ .side-run,
  .mol-app[data-tab='folding'] .mol-side > .side-sec:first-child:not(.is-open) ~ .side-run {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .mol-app[data-tab='drug']:not([data-kind='pdb']) .side-run {
    grid-column: 1 / -1;
    grid-row: 1;
    border-right: 0;
  }
}

/* ── Phones: one column, the panels fold ─────────────────────────── */

@media (max-width: 759px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-2) var(--space-3);
    row-gap: var(--space-1);
  }

  .topbar-left {
    gap: var(--space-2);
    flex: 1 1 100%;
    min-width: 0;
  }

  .topbar-left .divider-v,
  .topbar-right .divider-v {
    display: none;
  }

  .docs-btn {
    margin-left: auto;
    max-width: 50%;
  }

  .topbar-right {
    flex: 1 1 100%;
    justify-content: space-between;
    gap: var(--space-1);
  }

  .topbar-right .btn {
    padding: 0 var(--space-2);
  }

  #qubi-btn .btn-label,
  #open-btn .btn-label {
    display: none;
  }

  .qa-nav {
    margin-left: auto;
  }

  .mol-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
  }

  .mol-lib {
    position: static;
    grid-row: 3;
    height: auto;
    border-right: 0;
    border-top: var(--hairline) solid var(--border);
  }

  .mol-centre {
    grid-row: 1;
    height: auto;
  }

  .mol-stage {
    flex: none;
    height: auto;
    aspect-ratio: 1 / 1;
    max-height: 72vh;
  }

  .mol-side {
    grid-row: 2;
    grid-column: 1;
    display: block;
  }

  .mol-side > .side-sec:first-child {
    border-right: 0;
  }

  .side-run,
  .side-chart {
    border-top: var(--hairline) solid var(--border);
  }

  .acc-head {
    cursor: pointer;
  }

  .acc-tog {
    display: inline-grid;
  }

  .acc:not(.is-open) > .acc-body {
    display: none;
  }

  .acc.is-open .acc-tog .icon {
    transform: rotate(180deg);
  }

  .lib-list {
    flex: none;
    height: 432px;
  }

  .stage-tl {
    right: auto;
    left: var(--space-2);
    top: var(--space-2);
  }

  .stage-tr {
    top: auto;
    bottom: var(--space-2);
    right: var(--space-2);
  }

  .mol-readout {
    gap: var(--space-3);
    padding: 0 var(--space-3);
  }

  .mol-readout .ro-end {
    display: none;
  }

  .el-card {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--space-4);
  }

  .el-tile {
    width: 140px;
    height: 140px;
  }

  .el-tile-sym {
    font-size: 48px;
  }

  .pt-pop {
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    right: var(--space-2);
    width: auto;
    max-height: calc(100dvh - 16px);
    overflow: auto;
    padding: var(--space-3);
  }

  .pt-grid {
    gap: 1px;
  }

  .pt-cell i {
    display: none;
  }

  .pt-cell b {
    font-size: 9px;
  }

  .pane-wrap {
    padding: var(--space-4);
  }
}

/* Dynamics tab */

/* One hue per spatial orbital (the site's validated categorical order, as on /ai);
   beta spin orbitals take the same hue mixed towards the text colour (lighter on dark, darker on light). */
:root {
  --dyn-k1: #3987e5;
  --dyn-k2: #d95926;
  --dyn-k3: #199e70;
  --dyn-k4: #c98500;
  --dyn-k5: #d55181;
  --dyn-k6: #008300;
  --dyn-k7: #9085e9;
  --dyn-k8: #e66767;
}

:root[data-ui-theme='light'] {
  --dyn-k1: #2a78d6;
  --dyn-k2: #eb6834;
  --dyn-k3: #1baf7a;
  --dyn-k4: #eda100;
  --dyn-k5: #e87ba4;
  --dyn-k6: #008300;
  --dyn-k7: #4a3aa7;
  --dyn-k8: #e34948;
}

.mol-app {
  --dyn-b1: color-mix(in oklab, var(--dyn-k1) 55%, var(--text));
  --dyn-b2: color-mix(in oklab, var(--dyn-k2) 55%, var(--text));
  --dyn-b3: color-mix(in oklab, var(--dyn-k3) 55%, var(--text));
  --dyn-b4: color-mix(in oklab, var(--dyn-k4) 55%, var(--text));
  --dyn-b5: color-mix(in oklab, var(--dyn-k5) 55%, var(--text));
  --dyn-b6: color-mix(in oklab, var(--dyn-k6) 55%, var(--text));
  --dyn-b7: color-mix(in oklab, var(--dyn-k7) 55%, var(--text));
  --dyn-b8: color-mix(in oklab, var(--dyn-k8) 55%, var(--text));
}

.run-pane[data-run='dynamics']:not(.is-quench) .dyn-quench {
  display: none;
}

.run-pane[data-run='dynamics'] .dyn-ref.is-off {
  color: var(--text-faint);
  cursor: default;
}

.dyn-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1.55fr) minmax(0, 1.1fr) auto auto;
  gap: var(--space-3);
}

.dyn-body > .pane-empty {
  grid-row: 1 / -1;
}

.dyn-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--space-1);
  min-height: 0;
}

.dyn-panel header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 24px;
  min-width: 0;
}

.dyn-panel h3 {
  flex: none;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.dyn-stat {
  margin-left: auto;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dyn-plot {
  position: relative;
  min-height: 0;
}

.dyn-plot svg {
  display: block;
  overflow: visible;
}

.dyn-plot .qc-line.is-thin {
  stroke-width: 1;
}

.dyn-plot .qc-line.dyn-ref-line {
  stroke-width: 1.25;
  stroke-linecap: butt;
}

.dyn-plot .qc-line.is-dim {
  opacity: 0.1;
}

.dyn-zero {
  stroke: var(--border-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.dyn-cursor {
  stroke: var(--text);
  stroke-width: 1.5;
}

.dyn-plot .qc-cursor {
  stroke: var(--text-faint);
  stroke-dasharray: 2 3;
}

.dyn-legend {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-1);
  min-width: 0;
}

.dyn-key {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 var(--space-1);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  cursor: default;
}

.dyn-key:hover {
  background: var(--surface-hover, var(--bg-sunken));
  color: var(--text);
}

.dyn-key i,
.dyn-key-note i {
  display: inline-block;
  width: 8px;
  height: 3px;
  border-radius: 1px;
  background: var(--c, var(--text-muted));
}

.dyn-key i.b {
  margin-right: 3px;
  background: color-mix(in oklab, var(--c) 55%, var(--text));
}

.dyn-key small {
  color: var(--text-faint);
  font-family: var(--font-ui);
  font-size: 10px;
}

.dyn-key.is-dim {
  opacity: 0.4;
}

.dyn-key-note {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: var(--space-2);
  color: var(--text-faint);
  font-size: var(--text-2xs);
  white-space: nowrap;
}

.dyn-key-note i.a {
  background: var(--text-muted);
}

.dyn-key-note i.b {
  margin-left: var(--space-1);
  background: color-mix(in oklab, var(--text-muted) 45%, var(--stage));
}

.dyn-mode {
  flex: none;
  margin-left: auto;
}

.dyn-mode button {
  min-width: 28px;
  justify-content: center;
  font-family: var(--font-code);
}

.dyn-scrub {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}

.dyn-time {
  min-width: 190px;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
  text-align: right;
  white-space: nowrap;
}

.dyn-facts {
  display: grid;
  gap: 2px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.dyn-facts p:empty {
  display: none;
}

.dyn-tip {
  min-width: 120px;
}

.dyn-tip-occ {
  margin-top: 2px;
  border-collapse: collapse;
}

.dyn-tip-occ th,
.dyn-tip-occ td {
  padding: 0 0 0 var(--space-2);
  font-weight: 400;
  text-align: right;
}

.dyn-tip-occ th:first-child {
  padding-left: 0;
  color: var(--text-muted);
  text-align: left;
}

.dyn-tip-occ tr:first-child th {
  color: var(--text-faint);
}

.dyn-tip-occ i {
  display: inline-block;
  width: 8px;
  height: 3px;
  margin: 0 5px 2px 0;
  border-radius: 1px;
  background: var(--c);
}

.dyn-tip-occ tr.is-dim {
  opacity: 0.4;
}

#chart .dyn-side-key text {
  fill: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 10px;
}

#chart .dyn-bars.is-dim {
  opacity: 0.25;
}

#chart .dyn-bar-ref {
  stroke: var(--text);
  stroke-width: 1.5;
}

#chart .dyn-role {
  fill: var(--text-faint);
  font-family: var(--font-ui);
  font-size: 9px;
}

@media (max-width: 759px) {
  .dyn-wrap .pane-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .mol-app[data-tab='dynamics'] .mol-stage:has(.dyn-panel) {
    aspect-ratio: auto;
    height: 720px;
    max-height: none;
  }

  .dyn-panel header {
    flex-wrap: wrap;
    gap: 2px var(--space-2);
  }

  .dyn-panel--occ .dyn-legend {
    order: 3;
    flex-basis: 100%;
  }

  .dyn-stat {
    flex-basis: 100%;
    margin-left: 0;
  }

  .dyn-time {
    min-width: 0;
    font-size: var(--text-2xs);
  }
}

/* Ground state tab */

.gs-status {
  min-height: 16px;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-status.is-live {
  color: var(--text);
}

.gs-status.is-error {
  color: var(--danger);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  white-space: normal;
}

.gs-curve-btn[hidden] {
  display: none;
}

.gs-head {
  align-items: center;
}

.gs-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
}

.gs-title h2 {
  flex: none;
}

.gs-title p {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-seg {
  flex: none;
}

.gs-body {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.gs[data-view='conv'] .gs-body--curve,
.gs[data-view='curve'] .gs-body:not(.gs-body--curve) {
  display: none;
}

.gs-body:not(.gs-body--curve) {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.gs-chart {
  flex: none;
  height: clamp(220px, 38vh, 340px);
}

.gs-body--curve {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.gs-chart.gs-chart--curve {
  height: 100%;
  min-height: 200px;
}

.gs-sec {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.gs-sec-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: var(--hairline) solid var(--border);
}

.gs-sec-head h3 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.gs-sec-head span {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.gs-circuit {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.gs-circuit .gc {
  display: block;
}

/* The wire names stay put while a long circuit scrolls under them. */
.gc-wrap {
  display: flex;
  width: max-content;
}

.gc-names-col {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  background: var(--stage);
}

.gc-body {
  flex: none;
}

/* Givens gates (G1, G2): a quiet tint of the builder's purple. */
.gc-giv rect {
  fill: color-mix(in oklab, #6b5fc7 24%, var(--stage));
  stroke: #7a6fd3;
  stroke-width: 1.25;
}

.gc-giv-bus {
  stroke: #7a6fd3;
  stroke-width: 1.5;
}

.gc-giv text {
  fill: color-mix(in oklab, #b9b0ff 70%, var(--text));
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 600;
}

.gc-giv text.gc-giv-p {
  fill: var(--text-muted);
  font-family: var(--font-code);
  font-size: 9.5px;
  font-weight: 400;
}

/* QG Mono has no theta: the letter comes from Inter, the digits stay mono. */
.gc-th {
  font-family: var(--font-ui);
  font-style: italic;
}

:root[data-ui-theme='light'] .gc-giv text:not(.gc-giv-p) {
  fill: #4a3fa8;
}

.gc-giv:hover rect {
  fill: color-mix(in oklab, #6b5fc7 40%, var(--stage));
}

.gc-wires line {
  stroke: #6b5fc7;
  stroke-opacity: 0.6;
  stroke-width: 2;
}

.gc-names text {
  fill: var(--text-muted);
  font-family: var(--font-code);
  font-size: 11px;
}

.gc-tile {
  stroke-width: 1.5;
}

.gc-t {
  fill: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
}

.gc-t-sm {
  font-size: 9px;
}

.gc-t-sub {
  fill: #fff;
  fill-opacity: 0.88;
  font-family: var(--font-code);
  font-size: 10px;
}

.gc-c {
  fill: #fff;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
}

.gc-param {
  fill: var(--text-faint);
  font-family: var(--font-code);
  font-size: 10px;
}

.gc-pin {
  fill: #fff;
  fill-opacity: 0.9;
}

.gc-skip {
  stroke-width: 1.5;
  stroke-dasharray: 2 3;
}

.gs-caption {
  margin: 0;
  color: var(--text-faint);
  font-size: var(--text-2xs);
  line-height: var(--leading-ui);
}

.gs-caption:empty {
  display: none;
}

.gs-qubi {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.gs-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
}

.gs-qbtns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.gs-qmsg {
  margin: 0;
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.gs-qmsg.is-error {
  color: var(--danger);
}

.gs-wait {
  margin: 0;
  padding: var(--space-3) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.gs-params {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  column-gap: var(--space-5);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.gs-prow {
  display: grid;
  grid-template-columns: 3.4em 2.6em minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: baseline;
  padding: 3px 0;
  border-bottom: var(--hairline) solid var(--border);
  white-space: nowrap;
}

.gs-pi {
  color: var(--text-muted);
}

.gs-pg,
.gs-pw {
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-pv {
  color: var(--text);
  text-align: right;
}

.gs-prow.is-zero .gs-pv {
  color: var(--text-faint);
}

.gs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--space-4);
  min-height: 16px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.gs-legend i {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  vertical-align: middle;
  border-top: 2px solid var(--c);
}

.gs-legend i.is-dashed {
  border-top-style: dashed;
}

.gs-curve-note {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

@media (max-width: 759px) {
  /* On a phone the stage grows with the tab, so the whole ansatz circuit
     (every wire) and the parameter table are on the page. */
  .mol-app[data-tab='ground'] .mol-stage {
    aspect-ratio: auto;
    max-height: none;
  }

  .mol-app[data-tab='ground'] .tab-pane[data-pane='ground'] {
    position: relative;
    inset: auto;
  }

  .mol-app[data-tab='ground'] .gs {
    height: auto;
  }

  .gs-body:not(.gs-body--curve) {
    overflow: visible;
  }

  .gs-body--curve {
    height: 420px;
  }

  .gs-chart {
    height: 220px;
  }

  .gs-title p {
    display: none;
  }

  .gs-params {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Hamiltonian tab ───────────────────────────────────────────────── */

.ham-wrap {
  grid-template-rows: auto minmax(0, 1fr);
}

.ham-wrap .pane-head p {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ham-body {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: var(--space-5);
  min-height: 0;
}

.ham-ladder,
.ham-terms {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
}

.ham-ladder {
  grid-template-rows: auto auto auto;
  align-content: start;
  overflow: hidden;
}

.ham-terms {
  grid-template-rows: auto minmax(0, 1fr);
}

.ham-wrap.is-stale .ham-ladder-rows,
.ham-wrap.is-stale .ham-table {
  opacity: 0.45;
}

.ham-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 28px;
  padding-bottom: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.ham-faint {
  color: var(--text-faint);
}

/* The ladder: one row per spatial orbital, highest energy on top, at the
   top of its column like the term table beside it, with the qubit count
   right under it (tabs/hamiltonian.js ladderFit sizes the rows to fit). */

.ham-ladder-rows {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
  user-select: none;
}

.hl-list {
  position: relative;
}

.hl-row,
.hl-more {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 64px 40px;
  align-items: center;
  gap: var(--space-3);
  height: var(--hl-row, 24px);
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
}

.hl-more {
  display: flex;
  color: var(--text-faint);
}

.hl-i {
  color: var(--text-faint);
  text-align: right;
}

.hl-bar {
  display: flex;
  align-items: center;
}

.hl-bar i {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 2px;
}

.hl-row.is-occ .hl-bar i {
  background: var(--text-muted);
}

.hl-row.is-virt .hl-bar i {
  box-shadow: inset 0 0 0 1px var(--text-muted);
}

.hl-row.is-act.is-occ .hl-bar i {
  background: var(--accent);
}

.hl-row.is-act.is-virt .hl-bar i {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.hl-row.is-frozen .hl-bar i,
.hl-row.is-dropped .hl-bar i {
  opacity: 0.4;
}

.hl-e {
  color: var(--text);
  text-align: right;
  font-family: var(--font-code);
}

.hl-row.is-frozen .hl-e,
.hl-row.is-dropped .hl-e {
  color: var(--text-faint);
}

.hl-tag {
  color: var(--text-muted);
  font-size: var(--text-2xs);
  letter-spacing: 0.02em;
}

.hl-bracket {
  position: absolute;
  left: 0;
  right: 0;
  border: var(--hairline) solid var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--accent) 7%, transparent);
  pointer-events: none;
}

.hl-grip {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 14px;
  margin-left: -20px;
  cursor: ns-resize;
  pointer-events: auto;
  touch-action: none;
  outline: none;
}

.hl-grip::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 5px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.hl-grip--hi {
  top: -7px;
}

.hl-grip--lo {
  bottom: -7px;
}

.hl-grip:hover::after,
.hl-grip:focus-visible::after {
  left: 4px;
  right: 4px;
  background: var(--accent-text);
}

.hl-grip:focus-visible {
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.ham-ladder-foot {
  display: grid;
  gap: 2px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: var(--hairline) solid var(--border);
  color: var(--text);
  font-size: var(--text-sm);
}

.ham-ladder-foot .ham-faint {
  font-size: var(--text-xs);
}

.hl-key {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-1);
  color: var(--text-faint);
  font-size: var(--text-2xs);
}

.hl-key span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hl-key i {
  display: inline-block;
  width: 14px;
  height: 5px;
  border-radius: 2px;
}

.hl-k-occ {
  background: var(--text-muted);
}

.hl-k-virt {
  box-shadow: inset 0 0 0 1px var(--text-muted);
}

.hl-k-act {
  background: var(--accent);
}

/* The term table: virtual rows of 26 px. */

.ham-count {
  color: var(--text-muted);
  white-space: nowrap;
}

.ham-count b {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.ham-search {
  position: relative;
  flex: 0 1 220px;
  min-width: 120px;
}

.ham-search .icon {
  position: absolute;
  left: 8px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  color: var(--text-faint);
  pointer-events: none;
}

.ham-search .input {
  width: 100%;
  height: 26px;
  padding-left: 28px;
  font-size: var(--text-xs);
}

.ham-table {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.ham-tr {
  display: grid;
  grid-template-columns: 48px minmax(120px, max-content) 124px minmax(60px, 1fr);
  align-items: center;
  column-gap: var(--space-4);
  height: 26px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.ham-th {
  height: 30px;
  border-bottom: var(--hairline) solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Column titles stay on one line; a narrow column cuts its title with an ellipsis. */
.ham-th > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ham-th button {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.ham-th button:hover {
  color: var(--text);
}

.ham-th .ham-c-v {
  justify-content: flex-end;
}

.ham-sort {
  width: 12px;
  height: 12px;
  transform: rotate(180deg);
}

.ham-sort.is-down {
  transform: none;
}

.ham-scroll {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
}

.ham-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px var(--border-focus);
}

.ham-spacer {
  position: relative;
}

.ham-spacer > .ham-tr {
  position: absolute;
  left: 0;
  right: 0;
}

.ham-spacer > .ham-tr:hover {
  background: var(--surface-hover);
}

.ham-c-n {
  color: var(--text-faint);
  text-align: right;
}

.ham-spacer .ham-c-s {
  font-family: var(--font-code);
  white-space: nowrap;
}

.ham-c-s i {
  font-style: normal;
}

.ham-c-s i.g {
  margin-left: 0.45em;
}

.ham-c-s .pI {
  color: var(--text-faint);
  opacity: 0.6;
}

.ham-c-s .pX,
.ham-c-s .pY,
.ham-c-s .pZ {
  color: var(--text);
}

.ham-spacer .ham-c-v {
  font-family: var(--font-code);
  text-align: right;
  color: var(--text);
}

.ham-mag {
  display: block;
  height: 6px;
  border-radius: 2px;
  background: var(--bg-sunken);
}

.ham-mag i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

.ham-const {
  color: var(--text-faint);
  font-size: var(--text-2xs);
}

.ham-none {
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.ham-stale-note,
.ham-wait {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.ham-stale-note {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--text-xs);
}

.ham-empty {
  align-content: center;
  gap: var(--space-3);
}

.ham-empty p {
  margin: 0;
}

.ham-empty b {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.ham-spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ham-spin 0.8s linear infinite;
}

@keyframes ham-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Run pane extras */

.ham-run .is-locked select {
  color: var(--text-muted);
  cursor: not-allowed;
}

.ham-bond {
  margin-top: var(--space-3);
}

.ham-bond-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.ham-bond-head b {
  color: var(--text);
  font-weight: var(--weight-regular);
  font-size: var(--text-sm);
}

.ham-bond-ends {
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: var(--text-2xs);
}

.ham-dyn > .run-field {
  margin-top: var(--space-3);
}

.ham-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px var(--space-3);
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
}

.ham-facts dt {
  color: var(--text-muted);
}

.ham-facts dd {
  margin: 0;
  color: var(--text);
}

.ham-facts b {
  font-weight: var(--weight-medium);
}

.ham-exact {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
}

.ham-reset {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
}

.ham-btns .btn.primary[disabled] {
  opacity: 1;
}

.ham-btns .btn {
  min-width: 0;
}

.ham-btns .btn.primary > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1199px) {
  .ham-body {
    grid-template-columns: 252px minmax(0, 1fr);
    gap: var(--space-4);
  }

  .ham-tr {
    grid-template-columns: 36px minmax(110px, max-content) 112px minmax(40px, 1fr);
    column-gap: var(--space-3);
  }
}

@media (max-width: 759px) {
  .mol-app[data-tab='hamiltonian'] .mol-stage {
    aspect-ratio: auto;
    max-height: none;
  }

  .mol-app[data-tab='hamiltonian'] .tab-pane[data-pane='hamiltonian'] {
    position: relative;
    inset: auto;
  }

  .ham-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .ham-ladder-rows {
    height: 312px;
  }

  .ham-terms {
    height: 420px;
  }

  .ham-terms-head {
    flex-wrap: wrap;
  }

  .ham-search {
    flex: 1 1 100%;
  }

  .ham-tr {
    grid-template-columns: 28px minmax(0, max-content) 96px minmax(24px, 1fr);
    column-gap: var(--space-2);
    padding: 0 var(--space-2);
  }

  .ham-wrap .pane-head {
    flex-wrap: wrap;
    row-gap: 2px;
  }
}
/* Build from Qubi dialog (js/qubi-build.js), the same dialog as 3D's. */
.qb-build.modal {
  width: min(640px, 100%);
}

.qf-modal .qf-list,
.qf-modal .qf-paste,
.qf-modal .qf-group {
  min-width: 0;
  max-width: 100%;
}

.qf-modal .modal-body {
  overflow-x: hidden;
}

.qf-paste textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 15em;
  padding: var(--space-2);
  font-family: var(--font-code);
  font-size: var(--code-size);
  line-height: var(--leading-code);
  resize: vertical;
}

.qf-paste-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.qf-modal .qf-paste-row .qf-sub {
  flex: 1 1 220px;
  min-width: 0;
  white-space: normal;
  line-height: var(--leading-ui);
}

.qf-modal .qf-paste-row .btn {
  flex: none;
  margin-left: auto;
}

.qb-from {
  margin: 0 0 var(--space-2);
  white-space: normal;
}

.qb-problems {
  display: grid;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: var(--hairline) solid color-mix(in oklab, var(--danger) 45%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--danger-wash);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.qb-problem {
  display: flex;
  gap: var(--space-2);
  color: var(--text);
}

.qb-problem .linkish {
  flex: none;
  font-family: var(--font-code);
}

.qf-modal code.mono {
  white-space: nowrap;
  font-family: var(--font-code);
  font-size: 0.92em;
}
.qb-build .qf-tabs {
  overflow-x: auto;
  scrollbar-width: none;
}

.qb-build .qf-tabs::-webkit-scrollbar {
  display: none;
}

.qb-build .qf-tab {
  flex: none;
  white-space: nowrap;
}
/* End of Hamiltonian tab */

/* Drug tab */

/* No complex open: the 3D view would show whatever the Structure tab left in it. */
.mol-app[data-tab='drug'][data-drug-empty] .mol-3d { visibility: hidden; }

.drug-field {
  display: grid;
  gap: 3px;
  margin-bottom: var(--space-2);
}

.drug-label {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.drug-pick {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-2) 0 var(--space-3);
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.drug-pick:hover { border-color: var(--text-faint); }
.drug-pick[aria-expanded='true'] { border-color: var(--border-focus); }

.drug-pick-main {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drug-pick-id {
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.drug-pick .icon { color: var(--text-muted); }

.drug-run .drug-grid { grid-template-columns: 96px minmax(0, 1fr); }

.drug-selbtns {
  display: flex;
  gap: var(--space-1);
}

.drug-selbtns .btn {
  height: var(--control-h);
  padding: 0 var(--space-3);
}

.mol-app[data-tab='drug'] #chart { height: 156px; }

.drug-run .run-help.is-error { color: var(--danger); }

.drug-rule {
  margin-top: var(--space-2);
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.drug-rule summary {
  color: var(--text-muted);
  cursor: pointer;
}

.drug-rule summary:hover { color: var(--text); }
.drug-rule p { margin: var(--space-1) 0 0; }

/* The complex picker. */
.drug-pop {
  position: fixed;
  z-index: var(--z-popover);
  display: flex;
  flex-direction: column;
  border: var(--hairline) solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}

.drug-pop-search {
  position: relative;
  flex: none;
  padding: var(--space-2);
  border-bottom: var(--hairline) solid var(--border);
}

.drug-pop-search .icon {
  position: absolute;
  left: calc(var(--space-2) + 8px);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.drug-pop-search .input {
  width: 100%;
  height: var(--control-h);
  padding-left: 28px;
}

.drug-pop-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--space-1);
}

.drug-opt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "main id" "sub id";
  column-gap: var(--space-3);
  width: 100%;
  padding: 6px var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.drug-opt:hover,
.drug-opt.is-at { background: var(--surface-hover); }
.drug-opt[aria-selected='true'] { background: var(--accent-wash); }

.drug-opt-main {
  grid-area: main;
  font-size: var(--text-sm);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drug-opt-sub {
  grid-area: sub;
  color: var(--text-muted);
  font-size: var(--text-xs);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drug-opt-id {
  grid-area: id;
  align-self: center;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.drug-pop-none,
.drug-pop-foot {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.drug-pop-foot {
  flex: none;
  border-top: var(--hairline) solid var(--border);
}

/* The stage overlays. */
.drug-float p { margin: var(--space-2) 0 0; }

.drug-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  color: var(--text);
}

.drug-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.drug-legend .sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.sw-lig { background: #4fb89a; }
.sw-sel { background: var(--accent); }
.sw-pk { background: #9a9890; }

.drug-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
}

.drug-empty h2 {
  margin: 0;
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

.drug-empty p {
  max-width: 440px;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-md);
  line-height: var(--leading-ui);
}

.drug-quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  max-width: 520px;
  margin-top: var(--space-2);
}

.drug-quick .btn { gap: var(--space-2); }

.drug-quick .btn .num {
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.drug-quick .btn.primary .num { color: inherit; }

/* Inspector. */
.drug-2d {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) 0 0;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.drug-2d svg {
  display: block;
  width: 100%;
  height: auto;
}

.drug-2d figcaption {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 6px var(--space-3);
  border-top: var(--hairline) solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.drug-2d figcaption .fml {
  color: var(--text);
  font-size: var(--text-sm);
}

.drug-2d figcaption a { margin-left: auto; }

.drug-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.drug-tbl th,
.drug-tbl td {
  padding: 4px 0;
  border-bottom: var(--hairline) solid var(--border);
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}

.drug-tbl tr:last-child th,
.drug-tbl tr:last-child td { border-bottom: 0; }

.drug-tbl th:first-child {
  color: var(--text-muted);
  text-align: left;
}

.drug-tbl td.num {
  padding-left: var(--space-3);
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.drug-tbl td.lim { color: var(--text-faint); }

.drug-tbl td.na {
  color: var(--text-faint);
  font-size: var(--text-xs);
}

.drug-tbl thead th {
  padding-top: 0;
  color: var(--text-faint);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.drug-tbl.as td.q { font-weight: var(--weight-semibold); }

.ro5-mark {
  display: inline-block;
  min-width: 46px;
  margin-left: var(--space-3);
  padding: 0 6px;
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  line-height: 16px;
  text-align: center;
  text-transform: uppercase;
}

.ro5-mark.ok {
  background: color-mix(in oklab, var(--success) 16%, transparent);
  color: var(--success);
}

.ro5-mark.bad {
  background: var(--danger-wash);
  color: var(--danger);
}

.ro5-mark.unk { color: var(--text-faint); }

.drug-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.drug-verdict {
  margin: var(--space-2) 0 0;
  color: var(--text);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.drug-note {
  margin: var(--space-2) 0 0;
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-ui);
}

.drug-sel {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.drug-text {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.drug-refs {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  line-height: 1.7;
}

.in-block h3 .drug-count {
  margin-left: var(--space-2);
  color: var(--text-muted);
  font-family: var(--font-code);
  letter-spacing: 0;
}

.drug-ct-head,
.drug-ct {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: var(--space-2);
}

.drug-ct-head {
  padding: 0 6px 4px;
  color: var(--text-faint);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.drug-ct-head span:last-child { text-align: right; }

.drug-cts {
  display: grid;
  gap: 1px;
}

.drug-ct {
  width: 100%;
  min-height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
}

button.drug-ct { cursor: pointer; }
button.drug-ct:hover { background: var(--surface-hover); }
.drug-ct.is-on { background: var(--accent-wash); }
.drug-ct.is-het { color: var(--text-muted); }

.drug-ct .ck {
  width: 12px;
  height: 12px;
  border: var(--hairline) solid var(--text-faint);
  border-radius: 3px;
}

.drug-ct.is-het .ck { border-color: transparent; }

.drug-ct.is-on .ck {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2 5 8.2 9 3.8' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.drug-ct .rn {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drug-ct .pr {
  display: inline-flex;
  gap: 4px;
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.drug-ct .pr .to {
  color: var(--text-faint);
  font-family: var(--font-ui);
}

.drug-ct .d {
  font-family: var(--font-code);
  font-size: var(--text-xs);
  text-align: right;
}

/* The fragment banner over the Hamiltonian, Ground state and Dynamics tabs. */
.frag-banner { display: none; }

.mol-app:is([data-tab='hamiltonian'], [data-tab='ground'], [data-tab='dynamics']) .frag-banner:not(:empty) {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  min-height: 40px;
  padding: 6px var(--space-4);
  border-bottom: var(--hairline) solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
}

.fb-text {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-3);
  min-width: 0;
}

.fb-text b {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.fb-text span {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.frag-banner .btn { flex: none; }

@media (max-width: 759px) {
  .drug-empty {
    position: static;
    min-height: 100%;
    padding: var(--space-5) var(--space-4);
  }

  .drug-empty h2 { font-size: var(--text-lg); }

  .mol-app:is([data-tab='hamiltonian'], [data-tab='ground'], [data-tab='dynamics']) .frag-banner:not(:empty) {
    padding: 6px var(--space-3);
  }

  /* A long workspace name (a complex such as "HIV-1 protease with Indinavir") must not widen the page:
     a percentage max-width counts as none when the row sizes itself, a viewport unit does not. */
  .docs-btn { max-width: 50vw; }
}
/* End of Drug tab */

/* Folding tab */

/* Residue classes, the same colours as the beads in view3d (CLASS_COLOURS). */
[data-cls='hydrophobic'], [data-cls='H'] { --c: #d9a15b; }
[data-cls='aromatic'] { --c: #b58fc9; }
[data-cls='polar'], [data-cls='P'] { --c: #62b0a6; }
[data-cls='positive'] { --c: #6f95dc; }
[data-cls='negative'] { --c: #d6776b; }
[data-cls='special'] { --c: #a79fd0; }

:root {
  --fold-dock-w: 344px;
}

.fold-run .fold-seq {
  letter-spacing: 0.12em;
}

.fold-aa {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;
  margin-top: var(--space-2);
}

.fold-aa-btn {
  height: 24px;
  padding: 0;
  border: var(--hairline) solid color-mix(in oklab, var(--c) 45%, transparent);
  border-radius: var(--radius-xs);
  background: color-mix(in oklab, var(--c) 16%, var(--surface));
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 22px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}

.fold-aa-btn:hover {
  background: color-mix(in oklab, var(--c) 32%, var(--surface));
}

.fold-aa-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.fold-msg {
  min-height: 16px;
  margin: var(--space-1) 0 var(--space-2);
  color: var(--text-faint);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fold-msg.is-bad {
  color: var(--danger);
  font-family: var(--font-ui);
}

.fold-run .run-grid + .run-grid {
  margin-top: var(--space-2);
}

.run-grid.fold-grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fold-facts {
  margin-top: var(--space-3);
}

.fold-run .btn.primary[disabled] {
  opacity: 0.5;
  cursor: default;
}

.fold-status {
  min-height: 16px;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-2xs);
  line-height: 16px;
}

/* The stage: the 3D view on the left, the result docked on the right. */
.tab-pane[data-pane='folding'] {
  font-size: var(--text-sm);
}

.mol-app[data-tab='folding'] .mol-3d {
  right: var(--fold-dock-w);
}

.fold-view {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  display: grid;
  justify-items: start;
  gap: var(--space-2);
}

.fold-seg {
  background: var(--surface);
}

.fold-seg button[disabled] {
  opacity: 0.45;
  cursor: default;
}

.fold-cap {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.fold-key {
  position: absolute;
  left: var(--space-4);
  bottom: var(--space-3);
  right: calc(var(--fold-dock-w) + var(--space-4));
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-xs);
  pointer-events: none;
}

.mol-app[data-tab='folding'] .fold-key {
  pointer-events: none;
}

.fold-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fold-key i[data-cls] {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
}

.fold-dash {
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 2px dashed #e3c27a;
}

:root[data-ui-theme='light'] .fold-dash {
  border-top-color: #8a5a12;
}

.fold-mini {
  display: none;
}

.fold-dock {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--fold-dock-w);
  overflow-x: hidden;
  overflow-y: auto;
  border-left: var(--hairline) solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  line-height: var(--leading-ui);
  scrollbar-width: thin;
}

.fold-sec {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline) solid var(--border);
}

.fold-sec:last-child {
  border-bottom: 0;
}

.fold-sec--verdict {
  padding-top: var(--space-4);
}

.fold-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.fold-sec-head b {
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.fold-sec-head span {
  color: var(--text-faint);
  font-size: var(--text-2xs);
}

.fold-empty {
  margin: 0;
  color: var(--text-faint);
  font-size: var(--text-xs);
}

.fold-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.fold-title .num {
  letter-spacing: 0.06em;
}

.fold-title span + span {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fold-line {
  margin: 0;
  color: var(--text);
  font-size: var(--text-sm);
}

.fold-line.is-found {
  color: var(--success);
}

.fold-line.is-missed {
  color: var(--warning);
}

.fold-sub {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
}

.fold-nums {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
}

.fold-nums dt {
  color: var(--text-faint);
  font-size: var(--text-2xs);
}

.fold-nums dd {
  margin: 0;
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.fold-note {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-size: var(--text-xs);
}

.fold-contacts {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fold-contacts li {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: baseline;
  font-size: var(--text-xs);
}

.fold-contacts li .num:first-child {
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
}

.fold-contacts li b {
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  font-weight: 400;
}

.fold-contacts .fold-total {
  margin-top: 2px;
  padding-top: 3px;
  border-top: var(--hairline) solid var(--border);
}

.fold-chart.qchart {
  height: 156px;
}

.fold-rows {
  display: grid;
  margin: 0 calc(-1 * var(--space-1));
}

.fold-row {
  display: grid;
  grid-template-columns: 14px max-content minmax(24px, 1fr) 38px 60px 38px;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 22px;
  padding: 0 var(--space-1);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fold-row:hover {
  background: var(--bg-sunken);
}

.fold-row.is-shown {
  background: var(--surface-active);
}

.fold-rank {
  color: var(--text-faint);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  text-align: right;
}

.fold-row code {
  color: var(--text);
  font-family: var(--font-code);
  font-size: var(--text-2xs);
}

.fold-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.fold-row.is-shown .fold-bar {
  background: var(--surface);
}

.fold-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.fold-bar i.is-ground {
  background: var(--success);
}

.fold-bar i.is-bad {
  background: var(--text-faint);
}

.fold-p,
.fold-e {
  font-family: var(--font-code);
  font-size: var(--text-2xs);
  text-align: right;
  white-space: nowrap;
}

.fold-e {
  color: var(--text);
}

.fold-e.is-bad {
  color: var(--text-faint);
}

.fold-row em {
  color: var(--success);
  font-size: var(--text-2xs);
  font-style: normal;
}

.fold-top-note {
  margin: var(--space-2) 0 0;
  color: var(--text-faint);
  font-size: var(--text-2xs);
  line-height: 1.45;
}

/* The side panel's chart section is for phones (the dock has the chart). */
.fold-side-top {
  padding: var(--space-2) var(--space-4) var(--space-3);
}

.fold-side-top:empty {
  display: none;
}

.mol-app[data-tab='folding'] #chart {
  height: auto;
}

@media (min-width: 760px) {
  .mol-app[data-tab='folding'] .side-chart {
    display: none;
  }
}

@media (max-width: 1399px) {
  :root {
    --fold-dock-w: 320px;
  }
}

@media (max-width: 759px) {
  .mol-app[data-tab='folding'] .mol-3d {
    right: 0;
  }

  .fold-dock,
  .fold-key,
  .fold-cap {
    display: none;
  }

  .fold-view {
    top: var(--space-2);
    left: var(--space-2);
  }

  .fold-mini {
    position: absolute;
    left: var(--space-2);
    right: var(--space-2);
    bottom: var(--space-2);
    display: block;
    padding: var(--space-2) var(--space-3);
    border: var(--hairline) solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .fold-mini .fold-line {
    font-size: var(--text-xs);
  }
}
/* End of Folding tab */

/* SIDEBAR: the choice before a library row replaces a drawing in Build mode (library.js askAboutDrawing). */
.modal.lib-ask {
  width: min(440px, 100%);
}

@media (max-width: 480px) {
  /* Phones: the three choices stacked, full width, the main one on top. */
  .lib-ask .cm-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* A toast with a button in it (app.toast action): Undo after opening something over your work. */
.toast.toast--act {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: calc(100vw - 32px);
  padding-right: var(--space-2);
}

.toast-act {
  flex: none;
}

/* ── Library preview (LIB-PREVIEW, js/library/preview.js) ─────────────
   A row clicked once shows in #inspector-preview while #inspector (what is
   open, the part the first frame caches) is hidden but kept as it is. */
#inspector-preview {
  padding: 0 var(--space-4) var(--space-4);
}

.side-sec:not(.is-previewing) > #inspector-preview,
.side-sec.is-previewing > #inspector,
.side-sec:not(.is-previewing) .pv-title,
.side-sec.is-previewing > .acc-head #inspector-title,
.side-sec.is-previewing > .acc-head #inspector-sum {
  display: none;
}

.side-sec.is-previewing > .acc-head .pv-title {
  flex: 1;
  min-width: 0;
  color: var(--accent-text);
}

/* Shown on every tab while previewing (Drug hides the facts with no complex open). */
.mol-app .mol-side > .side-sec.acc.is-previewing:first-child[data-acc] {
  display: flex;
}

.pv-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-4)) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline) solid var(--border);
  background: color-mix(in oklab, var(--accent) 9%, var(--surface));
}

.pv-acts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  width: 100%;
}

.pv-acts .btn.sm {
  flex: none;
}

.pv-bar .pv-back {
  flex: 0 1 auto;
  gap: var(--space-1);
  min-width: 0;
  max-width: 100%;
  margin-left: calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
  color: var(--text-muted);
}

.pv-bar .pv-back:hover {
  color: var(--text);
}

.pv-bar .pv-back span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pv-bar .pv-back .icon {
  flex: none;
  width: 14px;
  height: 14px;
}

/* While a preview shows, the controls below name what they still belong to. */
.pv-for {
  display: none;
}

.side-sec.is-previewing ~ .side-sec > .acc-head .pv-for:not(:empty) {
  display: block;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The previewed row: a ring, so it reads apart from the open row's fill. */
.lib-row.is-preview,
.lib-row.is-preview:hover {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: color-mix(in oklab, var(--accent) 8%, transparent);
}

.lib-row.is-preview.is-active {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
}

.side-sec.is-previewing ~ .side-run > .acc-head .section-title {
  flex: none;
}
