.stitch-hero-play {
  display: table;
  width: fit-content;
  margin-top: .8rem;
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .2em;
}

#stitch-preview {
  scroll-margin-top: 1.5rem;
}

.stitch-preview-purchase {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem 1.25rem;
  padding: .9rem 0 1.25rem;
}

.stitch-preview-purchase p {
  margin: 0;
}

.stitch-preview-notes {
  padding: 0 0 .5rem;
}

.stitch-preview-notes details {
  padding: .65rem .15rem;
  border-top: 1px solid #d9cbd2;
}

.stitch-preview-notes summary {
  padding: .3rem 0;
  cursor: pointer;
  font-weight: 650;
}

.stitch-preview-notes details p {
  margin: .45rem 0 .15rem;
}

.stitch-preview {
  --sp-ink: #362332;
  --sp-ink-soft: #604d59;
  --sp-accent: #673d60;
  --sp-line: #d9cbd2;
  --sp-surface: #fcf8f4;
  margin: 1rem 0;
  padding: clamp(.8rem, 2.5vw, 1.5rem);
  border: 1px solid var(--sp-line);
  border-radius: 1rem;
  background: var(--sp-surface);
  color: var(--sp-ink);
}

.stitch-preview [hidden] {
  display: none !important;
}

.stitch-preview__actions,
.stitch-preview__mark-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.stitch-preview__actions button,
.stitch-preview__view-controls button,
.stitch-preview__mark-actions button,
.stitch-preview__apply {
  min-height: 2.75rem;
  padding: .5rem .85rem;
  border: 1px solid var(--sp-accent);
  border-radius: .65rem;
  color: var(--sp-accent);
  background: #fff;
  font: inherit;
  font-size: .95rem;
  font-weight: 650;
  cursor: pointer;
}

.stitch-preview__actions button[aria-pressed="true"],
.stitch-preview__view-controls button[aria-pressed="true"],
.stitch-preview__apply {
  background: var(--sp-accent);
  color: #fff;
}

.stitch-preview button:focus-visible,
.stitch-preview input:focus-visible,
.stitch-preview summary:focus-visible {
  outline: 3px solid #315894;
  outline-offset: 3px;
}

.stitch-preview__mark-actions button:disabled {
  border-color: var(--sp-line);
  color: var(--sp-ink-soft);
  opacity: .65;
  cursor: default;
}

.stitch-preview .stitch-preview__help {
  margin: .7rem 0;
  color: var(--sp-ink-soft);
  font-size: .95rem;
  line-height: 1.55;
}

.stitch-preview .stitch-preview__file-help {
  margin-bottom: 0;
  font-size: .88rem;
}

.stitch-preview .stitch-preview__notice {
  margin: .4rem 0;
  color: var(--sp-ink);
  font-size: .92rem;
  font-weight: 650;
}

.stitch-preview .stitch-preview__notice:empty {
  margin: 0;
}

.stitch-preview__workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.stitch-preview__chart-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: .6rem;
  padding: clamp(.4rem, 1.5vw, .85rem);
  border: 1px solid var(--sp-line);
  border-radius: .8rem;
  background: #f4edf1;
}

.stitch-preview__view-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .65rem;
  width: min(100%, 25rem);
}

.stitch-preview .stitch-preview__scroll-help {
  margin: 0;
  font-size: .86rem;
}

.stitch-preview__viewport {
  width: 100%;
  max-height: min(65vh, 32rem);
  overflow: auto;
}

.stitch-preview__chart {
  --sp-aspect: 1;
  position: relative;
  width: min(100%, 25rem, 65vh);
  aspect-ratio: var(--sp-aspect);
  box-sizing: border-box;
  margin-inline: auto;
  border: 1px solid #84717b;
  background: #fffdf6;
}

.stitch-preview--image .stitch-preview__chart {
  width: min(100%, 30rem, calc(min(65vh, 32rem) * var(--sp-aspect)));
}

.stitch-preview .stitch-preview__viewport--enlarged .stitch-preview__chart {
  width: var(--sp-zoom-width);
  aspect-ratio: var(--sp-zoom-aspect);
  overflow: hidden;
}

.stitch-preview__viewport--enlarged .stitch-preview__image {
  position: absolute;
  top: var(--sp-image-top);
  left: var(--sp-image-left);
  width: var(--sp-image-width);
  height: var(--sp-image-height);
  max-width: none;
}

.stitch-preview__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.stitch-preview__grid {
  position: absolute;
  inset: var(--sp-grid-inset, 0);
  display: grid;
  grid-template-columns: repeat(var(--sp-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--sp-rows), minmax(0, 1fr));
  border-left: 1px solid #42364375;
  border-top: 1px solid #42364375;
}

.stitch-preview__viewport--enlarged .stitch-preview__grid {
  inset: 0;
}

.stitch-preview .stitch-preview__cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid #42364375;
  border-bottom: 1px solid #42364375;
  border-radius: 0;
  background: var(--sp-cell-bg, transparent);
  color: var(--sp-cell-text, #55434c);
  font: inherit;
  font-size: clamp(.65rem, 2.5vw, 1rem);
  line-height: 1;
  touch-action: manipulation;
  cursor: pointer;
}

.stitch-preview__cell[data-tone="background"] { --sp-cell-bg: #fffdf6; --sp-cell-text: #7c6c75; }
.stitch-preview__cell[data-tone="petal-edge"] { --sp-cell-bg: #f7deee; --sp-cell-text: #65395b; }
.stitch-preview__cell[data-tone="petal"] { --sp-cell-bg: #ecbfd6; --sp-cell-text: #653455; }
.stitch-preview__cell[data-tone="petal-shadow"] { --sp-cell-bg: #d89fbd; --sp-cell-text: #4c2742; }
.stitch-preview__cell[data-tone="center"] { --sp-cell-bg: #ffdc9d; --sp-cell-text: #734807; }
.stitch-preview__cell[data-tone="stem"] { --sp-cell-bg: #d6e8d2; --sp-cell-text: #2c5d42; }
.stitch-preview__cell[data-tone="leaf"] { --sp-cell-bg: #bad8b4; --sp-cell-text: #265039; }

.stitch-preview__cell:focus-visible {
  z-index: 1;
  outline-offset: -3px !important;
}

.stitch-preview .stitch-preview__cell[aria-pressed="true"] {
  background: #285e49;
  color: #fff;
}

.stitch-preview .stitch-preview__cell[aria-pressed="true"] .stitch-preview__symbol {
  visibility: hidden;
}

.stitch-preview__cell[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  inset: 22% 36% 28% 37%;
  transform: rotate(43deg);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.stitch-preview__toolbar {
  display: flex;
  flex-wrap: wrap;
  width: min(100%, 25rem);
  align-items: center;
  justify-content: space-between;
  gap: .4rem .75rem;
}

.stitch-preview .stitch-preview__progress {
  margin: 0;
  font-weight: 650;
  font-size: .93rem;
}

.stitch-preview__align {
  padding: .7rem .9rem;
  border: 1px solid var(--sp-line);
  border-radius: .8rem;
  background: #fff;
}

.stitch-preview__align fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.stitch-preview__align legend {
  margin-bottom: .55rem;
  font-weight: 700;
}

.stitch-preview__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem .65rem;
}

.stitch-preview__fields label {
  display: grid;
  gap: .2rem;
  font-size: .86rem;
  font-weight: 650;
}

.stitch-preview__fields input {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  padding: .3rem .45rem;
  border: 1px solid #998591;
  border-radius: .35rem;
  background: #fff;
  color: var(--sp-ink);
  font: inherit;
  font-size: 1rem;
}

.stitch-preview__edges {
  margin-top: .55rem;
}

.stitch-preview__edges summary {
  width: fit-content;
  padding: .35rem 0;
  color: var(--sp-accent);
  font-weight: 650;
  cursor: pointer;
}

.stitch-preview__edges .stitch-preview__fields {
  margin-top: .25rem;
}

@media (min-width: 43rem) {
  .stitch-preview--image .stitch-preview__workspace {
    grid-template-columns: minmax(0, 1.3fr) minmax(15rem, 1fr);
  }

  .stitch-preview--image .stitch-preview__chart-panel {
    grid-area: 1 / 1;
  }

  .stitch-preview--image .stitch-preview__align {
    grid-area: 1 / 2;
  }
}
