.monge-post {
  --scene-background: #faf9f6;
  --scene-ink: #292824;
  --scene-blue: #3c6f91;
  --scene-rust: #b56b47;
  --scene-green: #66806b;
  --scene-red: #b44743;
  max-width: 820px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
  line-height: 1.5;
}

.monge-post h1 {
  margin: 1.4rem 0 0.65rem;
  line-height: 1.2;
}

.monge-post .personal-comment {
  margin: 0 0 1.4rem;
}

.monge-post .construction-figure {
  margin: 0 0 1.6rem;
}

.monge-post #construction {
  position: relative;
  height: 460px;
  overflow: hidden;
  border: 1px solid var(--diagram-border);
  background: var(--scene-background);
  color: var(--scene-ink);
  isolation: isolate;
}

.monge-post #construction canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.monge-post #fallback,
.monge-post #scene-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.monge-post #fallback img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.monge-post #fallback[hidden],
.monge-post #scene-status[hidden],
.monge-post #construction canvas[hidden] {
  display: none;
}

.monge-post #scene-labels {
  z-index: 2;
  overflow: hidden;
}

.monge-post .scene-label {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 0 1px 3px var(--scene-background), 0 -1px 3px var(--scene-background);
}

.monge-post .circle-0 {
  color: var(--scene-blue);
}

.monge-post .circle-1 {
  color: var(--scene-rust);
}

.monge-post .circle-2 {
  color: var(--scene-green);
}

.monge-post .intersection-label {
  color: var(--scene-red);
}

.monge-post #construction canvas:focus-visible {
  outline: 2px solid var(--scene-blue);
  outline-offset: -3px;
}

.monge-post #scene-status,
.monge-post .no-script-note {
  position: absolute;
  z-index: 3;
  top: 0.65rem;
  left: 0.75rem;
  right: 0.75rem;
  width: fit-content;
  margin: 0 auto;
  padding: 0.25rem 0.5rem;
  background: var(--scene-background);
  color: var(--diagram-muted);
  font-size: 0.85rem;
  text-align: center;
}

.monge-post .no-script-note {
  top: auto;
  bottom: 0.65rem;
}

.monge-post #step-caption {
  min-height: 3em;
  margin: 0.7rem 0 0;
  line-height: 1.4;
}

.monge-post .construction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.monge-post .construction-actions {
  margin-top: 0.6rem;
}

.monge-post button,
.monge-post select {
  min-height: 2.25rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--diagram-border);
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.25;
}

.monge-post button:not(:disabled),
.monge-post summary,
.monge-post select:not(:disabled) {
  cursor: pointer;
}

.monge-post button:not(:disabled):hover {
  background: var(--scene-background);
}

.monge-post button[aria-pressed="true"] {
  border-color: currentColor;
  background: var(--scene-background);
}

.monge-post button:disabled,
.monge-post fieldset:disabled {
  opacity: 0.5;
}

.monge-post :is(button, select, input, summary, a):focus-visible {
  outline: 2px solid var(--scene-blue);
  outline-offset: 3px;
}

.monge-post .quiet-button {
  border-color: transparent;
  color: var(--diagram-muted);
}

.monge-post .explore-options {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.monge-post .explore-options label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.monge-post .circle-settings {
  margin-top: 0.9rem;
  font-size: 0.9rem;
}

.monge-post .circle-settings fieldset {
  max-width: 440px;
  margin: 0.8rem 0 0;
  padding: 0;
  border: 0;
}

.monge-post .circle-selector {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}

.monge-post .circle-slider {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 3rem;
  align-items: center;
  gap: 0.65rem;
  margin: 0.5rem 0;
}

.monge-post .circle-slider input {
  width: 100%;
  min-width: 0;
  margin: 0;
  accent-color: var(--scene-blue);
}

.monge-post .circle-slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.monge-post #configuration-status {
  margin: 0.6rem 0 0;
  color: var(--diagram-muted);
}

.monge-post #configuration-status:empty {
  display: none;
}

.monge-post .theorem-statement {
  max-width: 700px;
}

.monge-post .reading-recommendation {
  max-width: 700px;
  margin-top: 1.2rem;
}

.monge-post .credits {
  color: var(--diagram-muted);
  font-size: 0.85rem;
}

.monge-post .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .monge-post {
    margin-top: 1.2rem;
    padding: 0 0.6rem;
  }

  .monge-post h1 {
    font-size: 1.75rem;
  }

  .monge-post #construction {
    height: 360px;
  }

}

@media (prefers-color-scheme: dark) {
  .monge-post {
    --scene-background: #20211f;
    --scene-ink: #eceae3;
    --scene-blue: #85b4d2;
    --scene-rust: #dfa07e;
    --scene-green: #a2b6a0;
    --scene-red: #ed928b;
  }
}
