.viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (width >= 56rem) {
  .viewer {
    grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr);
    align-items: start;
  }
}

.stage {
  position: relative;
  outline: none;
  aspect-ratio: 1;
  inline-size: 100%;
  max-block-size: 80vh;
  border: 1px solid var(--color-border, #d9d9de);
  border-radius: 0.5rem;
  overflow: hidden;
}

/* After the base rule, so it wins: the model stays in view while the reader goes down the long
   structure list beside it. */
@media (width >= 56rem) {
  .stage {
    position: sticky;
    inset-block-start: 1rem;
  }
}

.stage :global(.heart-viewer-canvas) {
  position: absolute;
  inset: 0;
}

.stage :global(.heart-viewer-canvas:focus-visible) {
  outline: 3px solid var(--color-accent, #b3122e);
  outline-offset: -3px;
}

.stage :global(.heart-viewer-label) {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 75%);
  color: #fff;
  font-size: 0.875rem;
  white-space: nowrap;
}

.stage :global(.heart-viewer-marker) {
  padding: 0.125rem 0.5rem;
  border: 2px solid #9b4dca;
  border-radius: 0.25rem;
  background: rgb(255 255 255 / 90%);
  color: #4a1a6b;
  font-size: 0.875rem;
  white-space: nowrap;
}

.disease {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding-inline-start: 0.75rem;
  border-inline-start: 4px solid #9b4dca;
}

.disease > div {
  display: grid;
  gap: 0.25rem;
}

.disease p,
.disease ul {
  margin: 0;
}

.poster {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

.load,
.overlay {
  position: absolute;
  inset-block-end: 1rem;
  inset-inline: 1rem;
  margin: 0;
  text-align: center;
}

.load {
  /* A pill in the corner, on one line: it covers as little of the heart as it can. */
  inset-block-end: 0.75rem;
  inset-inline: auto 0.75rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--color-accent, #b3122e);
  border-radius: 999px;
  background: var(--color-accent, #b3122e);
  color: var(--color-on-accent, #fff);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  max-inline-size: calc(100% - 1.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.load:focus-visible {
  outline: 3px solid var(--color-text, #1b1b1f);
  outline-offset: 2px;
}

.overlay {
  padding: 0.5rem;
  background: var(--color-bg, #fff);
}

.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  font-size: 0.9375rem;
}

.help,
.note,
.attribution {
  margin: 0;
  color: var(--color-muted, #55565c);
  font-size: 0.875rem;
}

.selected {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.selected p {
  margin: 0;
}

.selected button {
  font: inherit;
}

/* Keeps the status region in the accessibility tree while it is empty. */
.hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.options {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--color-border, #d9d9de);
  border-radius: 0.375rem;
}

.heartbeat {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}

.options label,
.field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.list-title {
  margin: 0;
  font-size: 1rem;
}

.group-title {
  margin: 0;
  margin-block-end: 0.25rem;
  color: var(--color-muted, #55565c);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
}

.group ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.group button {
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--color-border, #d9d9de);
  border-radius: 1rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1b1b1f);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.group button[aria-pressed='true'] {
  border-color: var(--color-accent, #b3122e);
  background: var(--color-accent, #b3122e);
  color: var(--color-on-accent, #fff);
}

.pick {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
}

.pick p {
  margin: 0;
}

/* Long disease names must not widen a phone screen. */
.pick select {
  min-inline-size: 0;
  max-inline-size: 100%;
}

.view {
  display: inline-flex;
  flex-wrap: wrap;
  justify-self: start;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-muted, #5a6b86);
  border-radius: 1.125rem;
  overflow: hidden;
}

.view legend {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.view label {
  flex: 1 1 auto;
  padding-block: 0.375rem;
  padding-inline: 1rem;
  text-align: center;
  cursor: pointer;
}

.view label:has(:checked) {
  background: var(--color-accent, #b3122e);
  color: var(--color-on-accent, #fff);
}

.view label:has(:focus-visible) {
  outline: 2px solid currentcolor;
  outline-offset: -4px;
}

.view input,
.toggle input {
  position: absolute;
  opacity: 0;
}

/* Switches in the style of the structure chips: a pill, filled when on. */
.options .toggle {
  display: inline-flex;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-muted, #5a6b86);
  border-radius: 1rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1b1b1f);
  font-size: 0.875rem;
  cursor: pointer;
}

.options .toggle:has(:checked) {
  border-color: var(--color-accent, #b3122e);
  background: var(--color-accent, #b3122e);
  color: var(--color-on-accent, #fff);
}

/* A check mark as well as the fill, so the state reads without colour and in forced colours. */
.options .toggle:has(:checked)::before,
.view label:has(:checked)::before {
  content: '✓' / '';
}

.view label:has(:checked)::before {
  margin-inline-end: 0.25rem;
}

@media (forced-colors: active) {
  .options .toggle:has(:checked),
  .view label:has(:checked) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

.options .toggle:has(:focus-visible) {
  outline: 2px solid var(--color-accent, #b3122e);
  outline-offset: 2px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.panel select {
  padding-block: 0.25rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--color-border, #d9d9de);
  border-radius: 1rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1b1b1f);
  font: inherit;
  font-size: 0.875rem;
}

.panel input[type='range'] {
  accent-color: var(--color-accent, #b3122e);
}

.heartbeat > button {
  padding-block: 0.375rem;
  padding-inline: 1rem;
  border: 2px solid var(--color-accent, #b3122e);
  border-radius: 999px;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1b1b1f);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.heartbeat > button[data-running='true'] {
  background: var(--color-accent, #b3122e);
  color: var(--color-on-accent, #fff);
}
