.page-demo {
  max-width: 46rem;
}

.demo-preflight h1 {
  margin-bottom: 0.7rem;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
}

.demo-preflight p {
  margin: 0 0 1.5rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
}

.demo-support-message {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.demo-support-message:empty {
  display: none;
}

.demo-support-message.error,
.demo-support-message.unsupported,
.demo-load-status.error {
  color: #a12c25;
}

.demo-enter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.demo-load-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.demo-load-status.ready {
  color: #267346;
}

.demo-root[hidden],
.demo-root [hidden] {
  display: none !important;
}

.demo-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #888;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
  user-select: none;
}

.demo-root:fullscreen {
  width: 100vw;
  height: 100vh;
}

.demo-canvas,
.demo-editor-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.demo-canvas {
  z-index: 1;
  image-rendering: auto;
  pointer-events: none;
}

.demo-editor-canvas {
  z-index: 2;
  cursor: default;
  touch-action: none;
}

.demo-stain-callout {
  position: absolute;
  left: 25%;
  top: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 200px));
  color: #000;
}

.demo-stain-arrow {
  display: block;
  width: 10px;
  height: 11vh;
  min-height: 56px;
  max-height: 120px;
  overflow: visible;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.25;
}

.demo-stain-callout p {
  margin: 0 0 10px;
  padding: 0;
  color: #000;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-align: center;
  max-width: min(22rem, 46vw);
}

.demo-fullscreen-loading {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: #858585;
  color: #fff;
  text-align: center;
}

.demo-fullscreen-loading span:last-child {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
}

.demo-spinner {
  width: 2.2rem;
  height: 2.2rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: demo-spin 800ms linear infinite;
}

@keyframes demo-spin {
  to { transform: rotate(360deg); }
}

.demo-app-window {
  position: absolute;
  z-index: 3;
  width: min(980px, calc(100vw - 32px));
  height: min(660px, calc(100vh - 32px));
  min-width: min(720px, calc(100vw - 32px));
  min-height: min(520px, calc(100vh - 32px));
  overflow: hidden;
  border: 1px solid #090909;
  border-radius: 7px;
  background: #1b1b1b;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.42);
  color: #b4b4b4;
  opacity: 0;
  pointer-events: none;
}

.demo-ready .demo-app-window {
  opacity: 1;
  pointer-events: auto;
}

.demo-title-bar {
  display: flex;
  height: 38px;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid #3c3c3c;
  background: #1b1b1b;
  color: #b4b4b4;
  font-size: 0.82rem;
  cursor: move;
  touch-action: none;
}

.demo-title-bar img {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 0;
}

.demo-title-controls {
  margin-left: auto;
  color: #aeb4bd;
  letter-spacing: 0.65rem;
}

.demo-app-body {
  height: calc(100% - 66px);
  overflow: auto;
  padding: 8px;
  background: #1b1b1b;
  font-size: 17px;
  line-height: 1.4;
  scrollbar-color: #606060 #1b1b1b;
}

.demo-app-body h2 {
  margin: 0 0 3px;
  color: #909090;
  font-size: 23px;
  font-weight: 400;
}

.demo-app-body hr {
  margin: 7px 0;
  border: 0;
  border-top: 1px solid #3c3c3c;
}

.demo-app-body button,
.demo-app-body select {
  min-height: 25px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: #3c3c3c;
  color: #b4b4b4;
  font: inherit;
}

.demo-app-body button {
  padding: 0 6px;
  cursor: pointer;
}

.demo-app-body button:hover:not(:disabled),
.demo-app-body button.selected {
  border-color: #909090;
  background: #484848;
}

.demo-app-body button.selected {
  border-color: transparent;
  background: #005b78;
  color: #d0e8f0;
}

.demo-app-body button:disabled {
  color: #797979;
  cursor: default;
}

.demo-display-row,
.demo-defect-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.demo-display-row select {
  min-width: 160px;
  padding: 0 4px;
}

.demo-display-row > label,
.demo-defect-row > span:not(.demo-disabled-wrap) {
  color: #909090;
}

.demo-enable {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  flex-direction: row-reverse;
}

.demo-enable input[type="checkbox"] {
  appearance: none;
  width: 46px;
  height: 25px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(110, 110, 118);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.demo-enable input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
}

.demo-enable input[type="checkbox"]:checked {
  background: rgb(70, 170, 110);
}

.demo-enable input[type="checkbox"]:checked::after {
  left: 24px;
}

.demo-defect-row input,
.demo-check-row input {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: #3c3c3c;
  cursor: pointer;
}

.demo-defect-row input:checked::after,
.demo-check-row input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #b4b4b4;
  border-width: 0 1px 1px 0;
  transform: rotate(35deg);
}

.demo-app-body input:focus-visible {
  outline: 2px solid #90c8e0;
  outline-offset: 2px;
}

.demo-defect-row input:hover,
.demo-check-row input:hover {
  border-color: #909090;
}

.demo-defect-row > span:not(.demo-disabled-wrap) {
  margin: 0 4px 0 8px;
}

.demo-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.demo-tool-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
  flex-shrink: 0;
}

.demo-disabled-wrap {
  display: inline-flex;
}

.demo-disabled-wrap > :disabled {
  pointer-events: none;
}

.demo-delete {
  background: #71362e !important;
  color: #fff;
}

.demo-parameters {
  margin: 5px 24px 0 18px;
  padding: 6px;
  border: 1px solid #3c3c3c;
  border-radius: 2px;
}

.demo-check-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}

.demo-source-controls {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0 0 11px;
  padding: 0;
  border: 0;
}

.demo-source-controls legend {
  padding: 0;
  margin-bottom: 5px;
  color: #909090;
  font: inherit;
}

.demo-slider-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 8px;
  color: #909090;
  --demo-track: #3c3c3c;
}

.demo-slider-row input[type="range"] {
  width: 100%;
  appearance: none;
  height: 25px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.demo-slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 2px;
  background: var(--demo-track);
}

.demo-slider-row input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 2px;
  background: var(--demo-track);
}

.demo-slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 20px;
  margin-top: -6px;
  border: 1px solid #b4b4b4;
  border-radius: 2px;
  background: var(--demo-track);
}

.demo-slider-row input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 15px;
  height: 20px;
  border: 1px solid #b4b4b4;
  border-radius: 2px;
  background: var(--demo-track);
}

.demo-slider-row.demo-red {
  --demo-track: #f00;
}

.demo-slider-row.demo-green {
  --demo-track: #0f0;
}

.demo-slider-row.demo-blue {
  --demo-track: #00f;
}

.demo-slider-row output {
  padding: 0 4px;
  border-radius: 2px;
  background: #3c3c3c;
  color: #b4b4b4;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.demo-disc-color {
  margin-top: 12px;
}

.demo-disc-color > div {
  margin-bottom: 3px;
  color: #909090;
}

#demo-disc-picker {
  display: block;
  width: 168px;
  height: 168px;
  border: 0;
  cursor: crosshair;
  touch-action: none;
}

.demo-notice {
  margin: 8px 0;
  padding: 0;
  color: #909090;
  font-size: 13px;
}

.demo-muted {
  color: #646464;
}

.demo-status-bar {
  display: flex;
  height: 28px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-top: 1px solid #3c3c3c;
  background: #1b1b1b;
  color: #646464;
  font-size: 11px;
}

.demo-tour {
  position: absolute;
  z-index: 4;
  bottom: 22px;
  left: 22px;
  width: min(390px, calc(100vw - 44px));
  padding: 17px 18px 15px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(24, 26, 29, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.36);
  color: #f5f5f5;
}

.demo-tour-count {
  margin: 0 0 5px;
  color: #70d4f0;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
}

.demo-tour h2 {
  margin: 0 0 5px;
  color: #fff;
  font-size: 18px;
}

.demo-tour > p:not(.demo-tour-count) {
  margin: 0;
  color: #ced2d7;
  font-size: 13px;
}

.demo-tour-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
}

.demo-tour-actions button {
  min-height: 31px;
  padding: 4px 11px;
  border: 1px solid #5b6068;
  border-radius: 5px;
  background: #34373c;
  color: #f5f5f5;
  font: inherit;
  cursor: pointer;
}

.demo-tour-actions button:disabled {
  color: #7f848c;
  cursor: default;
}

.demo-tour-actions #demo-tour-next {
  border-color: #2786a7;
  background: #176987;
}

.demo-tour-actions #demo-tour-skip {
  margin-left: auto;
  border-color: transparent;
  background: transparent;
  color: #b9bec5;
}

.demo-tour-highlight {
  position: relative;
  z-index: 1;
  outline: 3px solid #ffd65a !important;
  outline-offset: 3px;
  animation: demo-highlight 1.4s ease-in-out infinite;
}

@keyframes demo-highlight {
  50% { outline-color: #fff1a1; }
}

.demo-download {
  position: absolute;
  z-index: 7;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 7px;
  background: #111;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.demo-download svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.demo-exit-hint {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: 13px;
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 11px;
  text-shadow: 0 1px 3px #000;
}

@media (max-height: 700px) {
  .demo-app-body {
    padding-top: 12px;
  }

  .demo-tour {
    bottom: 12px;
    left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-spinner,
  .demo-tour-highlight {
    animation: none;
  }
}
