.model-state-gallery { margin: 2rem 0; container-type: inline-size; }
.model-state-layout { display: grid; grid-template-columns: minmax(200px, .36fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.model-state-gallery .model-state-legend { padding: 1rem; border: 1px solid rgba(132,141,198,.25); border-radius: 12px; background: rgba(182,199,216,.18); min-width: 0; }
.model-state-gallery .model-state-label { margin: 0 0 .8rem; color: #141937; font-weight: 700; }
.model-state-gallery a { display: block; }
.model-state-gallery img { display: block; width: 100%; height: auto; max-width: 100%; margin: 0; background: #fff; border-radius: 8px; }
.model-state-carousel { min-width: 0; padding: 1rem; border: 1px solid rgba(132,141,198,.25); border-radius: 12px; background: rgba(182,199,216,.1); touch-action: pan-y; }
.model-state-gallery .model-state-slide { margin: 0; }
.model-state-gallery .model-state-slide[hidden] { display: none !important; }
.model-state-gallery figcaption { margin: .8rem 0; text-align: center; color: #141937; font-weight: 700; }
.model-state-controls { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .7rem 0; }
.model-state-gallery button { font: inherit; cursor: pointer; border: 1px solid #b6c7d8; border-radius: 8px; color: #141937; background: rgba(182,199,216,.23); }
.model-state-controls button { min-width: 44px; min-height: 44px; font-size: 1.2rem; }
.model-state-status { font-size: .85rem; text-align: center; color: #50556b; }
.model-state-selectors { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.model-state-selectors button { padding: .45rem .65rem; font-size: .8rem; min-height: 44px; }
.model-state-selectors button[aria-pressed="true"] { background: #141937; color: #fdfdf4; border-color: #141937; }
.model-state-gallery :is(a,button,.model-state-carousel):focus-visible { outline: 3px solid #848dc6; outline-offset: 3px; }
.model-state-gallery .model-state-help { margin: .9rem 0 0; font-size: .8rem; line-height: 1.5; color: #50556b; text-align: center; }
@container (max-width: 620px) { .model-state-layout { grid-template-columns: minmax(0,1fr); } .model-state-gallery .model-state-legend { max-width: 360px; width: 100%; margin: 0 auto; } }
@media (max-width: 700px) { .model-state-layout { grid-template-columns: minmax(0,1fr); } .model-state-gallery .model-state-legend { max-width: 360px; width: 100%; margin: 0 auto; } .model-state-carousel { padding: .65rem; } }

/* HTML legend scales with the carousel and inherits the wiki font. */
.model-state-gallery .model-state-legend { font-family: inherit; font-size: .86rem; line-height: 1.5; }
.model-state-gallery .model-state-label { margin-bottom: 1rem; font-size: 1rem; }
.model-state-gallery .model-legend-group + .model-legend-group { border-top: 1px solid rgba(132,141,198,.25); padding-top: .8rem; margin-top: .8rem; }
.model-state-gallery .model-legend-heading { margin: 0 0 .55rem; font-size: .77rem; letter-spacing: .05em; text-transform: uppercase; font-weight: 700; color: #59679e; }
.model-state-gallery .model-legend-list { list-style: none; padding: 0; margin: 0; }
.model-state-gallery .model-legend-list li { display: flex; align-items: center; gap: .65rem; padding: .25rem 0; margin: 0; color: #141937; text-align: left; }
.model-state-gallery .model-legend-node { display: inline-block; width: 15px; height: 15px; flex: 0 0 15px; border-radius: 3px; }
.model-state-gallery .model-legend-node.is-active { background: #2e7d32; }
.model-state-gallery .model-legend-node.is-inactive { background: #d32229; }
.model-state-gallery .model-legend-node.is-unmodelled { background: #77c7ec; }
.model-state-gallery .model-legend-note { margin: .65rem 0 0; color: #50556b; font-size: .78rem; line-height: 1.55; text-align: left; }
.model-state-gallery .model-legend-sizes { display: flex; align-items: center; gap: 5px; height: 22px; margin: 0 0 .35rem; }
.model-state-gallery .model-legend-sizes i { display: block; width: 9px; height: 9px; background: #848dc6; border-radius: 2px; }
.model-state-gallery .model-legend-sizes i:nth-child(2) { width: 14px; height: 14px; }
.model-state-gallery .model-legend-sizes i:nth-child(3) { width: 19px; height: 19px; }
.model-state-gallery .model-legend-line { display: inline-block; position: relative; flex: 0 0 26px; width: 26px; height: 0; border-top: 2px solid #141937; }
.model-state-gallery .model-legend-line.is-post { border-color: #979797; }
.model-state-gallery .model-legend-line.is-transcriptional { border-color: #0e5ba5; }
.model-state-gallery .model-legend-line.is-activation::after { content: ''; position: absolute; right: 0; top: -5px; width: 8px; height: 8px; border-top: 2px solid #141937; border-right: 2px solid #141937; transform: rotate(45deg); }
.model-state-gallery .model-legend-line.is-inhibition::after { content: ''; position: absolute; right: 0; top: -6px; height: 10px; border-right: 2px solid #141937; }
@container (max-width: 620px) { .model-state-gallery .model-state-legend { max-width: none; } .model-state-legend { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .7rem; } .model-state-gallery .model-state-label { grid-column: 1 / -1; margin: 0; } .model-state-gallery .model-legend-group + .model-legend-group { border: 0; margin: 0; padding: 0; } }
@media (max-width: 480px) { .model-state-legend { display: block; } .model-state-gallery .model-state-legend { max-width: none; } .model-state-gallery .model-legend-group + .model-legend-group { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid rgba(132,141,198,.25); } .model-state-gallery .model-state-label { margin-bottom: .7rem; } }

/* Size the complete viewer around the available viewport, without cropping SVGs. */
.model-state-gallery { width: 100%; max-width: 1180px; min-width: 0; margin: 1.5rem auto; scroll-margin-top: 115px; }
.model-state-layout { grid-template-columns: minmax(190px, 220px) minmax(0, 1fr); gap: .85rem; }
.model-state-gallery *, .model-state-gallery *::before, .model-state-gallery *::after { box-sizing: border-box; }
.model-state-gallery .model-state-carousel { width: 100%; min-width: 0; padding: .8rem; }
.model-state-gallery .model-state-slides { min-width: 0; }
.model-state-gallery .model-state-slide > a {
  display: flex; align-items: center; justify-content: center; width: 100%; min-width: 0;
  height: clamp(180px, calc(100vh - 340px), 560px);
  height: clamp(180px, calc(100svh - 340px), 560px);
  background: #fff; border-radius: 8px;
}
.model-state-gallery .model-state-slide img { width: 100%; height: 100%; object-fit: contain; }
.model-state-gallery figcaption { margin: .55rem 0; font-size: .95rem; }
.model-state-gallery .model-state-controls { margin: .45rem 0; }
.model-state-gallery .model-state-help { margin-top: .55rem; }
.model-state-gallery .model-state-selectors button { padding: .35rem .55rem; }
@container (max-width: 620px) {
  .model-state-layout { grid-template-columns: minmax(0, 1fr); }
  .model-state-gallery .model-state-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; max-width: none; width: 100%; padding: .8rem; }
  .model-state-gallery .model-state-label { grid-column: 1 / -1; margin: 0; font-size: .9rem; }
  .model-state-gallery .model-legend-group + .model-legend-group { margin: 0; padding: 0; border: 0; }
  .model-state-gallery .model-legend-list li { gap: .4rem; font-size: .74rem; overflow-wrap: anywhere; }
  .model-state-gallery .model-legend-heading { font-size: .68rem; letter-spacing: .02em; }
  .model-state-gallery .model-legend-note { font-size: .68rem; }
  .model-state-gallery .model-legend-line { flex-basis: 18px; width: 18px; }
  .model-state-gallery .model-state-slide > a { height: clamp(180px, calc(100vh - 440px), 440px); height: clamp(180px, calc(100svh - 440px), 440px); }
}
@media (max-width: 700px) {
  .model-state-layout { grid-template-columns: minmax(0, 1fr); }
  .model-state-gallery .model-state-slide > a { height: clamp(180px, calc(100vh - 440px), 440px); height: clamp(180px, calc(100svh - 440px), 440px); }
}
