.rhythm-main {
  display: grid;
  gap: clamp(1.1rem, 2.5vw, 2rem);
  padding-block: clamp(2rem, 5vw, 4.5rem);
}

.rhythm-main > *,
.rhythm-heading > *,
.rhythm-workbench > *,
.rhythm-variants > * { min-width: 0; }

.rhythm-heading {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 2rem;
  align-items: start;
  justify-content: space-between;
}

.rhythm-heading > div { flex: 1 1 34rem; }
.rhythm-heading h1 { font-size: clamp(2rem, 1.4rem + 3vw, 4rem); }
.rhythm-heading p, .rhythm-panel p { max-width: 68ch; }
.rhythm-page :is(main, header, footer) { overflow-wrap: anywhere; }

#experiment {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.75rem);
}

#experiment[hidden] { display: none; }

.rhythm-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: clamp(.75rem, 3vw, 1.75rem);
}

.rhythm-panel :is(h2, h3, h4) { color: var(--forest); }
.rhythm-panel h2 { font-size: 1.6rem; }
.rhythm-observation {
  border-top: .24rem solid var(--forest);
  background: #eef1e9;
}

.rhythm-observation-copy p:last-child { margin-bottom: 1rem; }
.rhythm-panel figure { margin: 0; }
.rhythm-panel figcaption { color: var(--ink); margin-top: .7rem; }

.rhythm-grid {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: .45rem;
}

.rhythm-octet {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: .08rem;
  padding: .4rem .16rem .3rem;
  border: 1px solid var(--line);
  border-radius: .2rem;
  background: var(--surface);
}

@container (max-width: 9.5rem) {
  .rhythm-octet {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    row-gap: .35rem;
  }
}

.rhythm-pulse {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: .15rem;
  min-width: 0;
  font-size: .66rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.rhythm-pulse::before {
  width: min(.68rem, 64%);
  aspect-ratio: 1;
  border: 1px solid #7d8b81;
  border-radius: 50%;
  content: "";
}

.rhythm-pulse[data-mark="observed"]::before {
  border-color: var(--forest);
  background: var(--forest);
}

.rhythm-pulse[data-mark="extra"]::before {
  border-color: var(--accent-text);
  border-radius: 0;
  background: var(--accent-text);
  transform: rotate(45deg) scale(.78);
}

.rhythm-workbench {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 1.5rem;
}

.rhythm-choices { display: grid; gap: .45rem; }
.rhythm-choices button {
  display: grid;
  text-align: start;
  width: 100%;
  gap: .18rem;
  padding: .7rem .8rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: .25rem solid var(--line);
  border-radius: .3rem;
  cursor: pointer;
}
.rhythm-choices button:hover { border-color: var(--forest); }
.rhythm-choices button[aria-pressed="true"] {
  border-color: var(--forest);
  color: var(--forest);
  background: #eff3eb;
}
.rhythm-choices button span { font-size: .9em; }

.rhythm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  margin-top: .85rem;
}
.rhythm-actions .action, .rhythm-heading .action { white-space: normal; text-align: start; }
.rhythm-actions button:disabled { opacity: .6; cursor: default; }

.rhythm-next { margin: .7rem 0 1rem; }

#result {
  background: #2f5143;
  color: #fffcf2;
  border-radius: .35rem;
  padding: .85rem 1rem;
  margin-bottom: 0;
}
#result p { margin: .35rem 0 0; }
.rhythm-verdict {
  display: block;
  font: 500 1.65rem/1.15 var(--serif);
}

.rhythm-variants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: .7rem;
}

.rhythm-card {
  border: 1px solid var(--line);
  border-top: .2rem solid var(--forest);
  border-radius: .3rem;
  background: #f5f7f1;
  padding: clamp(.55rem, 2vw, .9rem);
}

.rhythm-card[data-compatible="false"] {
  border-top-color: var(--accent-text);
  background: #faf1eb;
}
.rhythm-card h4 { font: 500 1.22rem/1.2 var(--serif); margin: 0; }
.rhythm-card p { margin: .5rem 0; }
.rhythm-card .rhythm-status { font-weight: 700; }
.rhythm-card .rhythm-grid { gap: .25rem; }
.rhythm-card .rhythm-octet { background: #fffefb; }
.rhythm-details summary { cursor: pointer; font: 600 1.24rem/1.3 var(--serif); }
.rhythm-details p:last-child { margin-bottom: 0; }
.rhythm-error { color: var(--accent-text); font-weight: 650; }

@media (min-width: 67rem) {
  .rhythm-workbench { grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); }
}

@media (forced-colors: active) {
  .rhythm-pulse[data-mark="observed"]::before,
  .rhythm-pulse[data-mark="extra"]::before { forced-color-adjust: none; background: CanvasText; border-color: CanvasText; }
  .rhythm-choices button[aria-pressed="true"] { border: 2px solid Highlight; }
}
