.demo-player-page {
  --demo-bg: #f4f6f8;
  --demo-surface: #ffffff;
  --demo-surface-2: #f1f5f8;
  --demo-border: #d5dde6;
  --demo-text: #151d27;
  --demo-muted: #647386;
  --demo-accent: #2563eb;
  --demo-accent-dark: #1d4ed8;
  --demo-danger: #b91c1c;
  color: var(--demo-text);
  background: var(--demo-bg);
  min-height: calc(100vh - 120px);
  padding: 18px;
}

.demo-player-page,
.demo-player-page * {
  box-sizing: border-box;
}

.demo-player-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, auto);
  gap: 16px;
  align-items: end;
  max-width: 1500px;
  margin: 0 auto 16px;
}

.demo-player-kicker {
  margin: 0 0 4px;
  color: var(--demo-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.demo-player-toolbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.demo-player-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: end;
  gap: 8px;
}

.demo-player-controls label:not(.demo-player-upload) {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--demo-muted);
  font-size: 12px;
  font-weight: 700;
}

.demo-player-controls select,
.demo-player-upload {
  min-height: 40px;
  border: 1px solid var(--demo-border);
  border-radius: 8px;
  background: var(--demo-surface);
  color: var(--demo-text);
  padding: 8px 10px;
  font: inherit;
}

.demo-player-controls select {
  min-width: min(360px, 70vw);
}

.demo-player-upload {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
}

.demo-player-upload:hover,
.demo-player-controls select:hover {
  border-color: #b8c4d1;
}

.demo-player-upload input {
  display: none;
}

.demo-player-alert,
.demo-player-status:not(:empty) {
  max-width: 1500px;
  margin: 0 auto 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #92400e;
  padding: 10px 12px;
  font-size: 13px;
}

.demo-player-status.error:not(:empty) {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--demo-danger);
}

.demo-player-shell {
  display: grid;
  grid-template-columns: minmax(0, 2.7fr) minmax(320px, 1fr);
  gap: 16px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

/* Right-hand column: steps (scrollable) on top, one-page guide below. Sticky so
   both stay in view while the video plays — no scrolling up/down to switch
   scenes. */
.demo-player-sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  max-height: calc(100vh - 150px);
}

.demo-player-scenes,
.demo-player-main,
.demo-player-guide {
  background: var(--demo-surface);
  border: 1px solid var(--demo-border);
  border-radius: 8px;
  overflow: hidden;
}

/* Steps panel keeps its natural (capped) height at the top of the sidebar. */
.demo-player-scenes {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Guide sits below the steps and grows to fill the rest of the sidebar,
   scrolling internally. */
.demo-player-guide {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 220px;
}

.demo-player-scenes-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--demo-border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.demo-player-scenes-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-player-scenes-head span {
  color: var(--demo-muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

/* Overall demo summary (manifest.meta.description), shown under the title in
   the scenes panel head. Spans both grid columns. */
.demo-player-description {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--demo-muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Per-scene summary (scene.description), shown between the video stage and the
   transport controls. */
.demo-player-scene-description {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--demo-surface-2);
  border: 1px solid var(--demo-border);
  border-radius: 8px;
  color: var(--demo-text);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.demo-player-description.is-empty,
.demo-player-scene-description.is-empty {
  display: none;
}

.demo-player-guide-head {
  padding: 14px;
  border-bottom: 1px solid var(--demo-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.demo-player-guide-head span {
  color: var(--demo-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.demo-player-guide-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.demo-player-guide-content {
  color: var(--demo-text);
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.demo-player-guide-content h1,
.demo-player-guide-content h2,
.demo-player-guide-content h3 {
  line-height: 1.2;
  margin: 0 0 10px;
}

.demo-player-guide-content h1 { font-size: 24px; }
.demo-player-guide-content h2 { font-size: 20px; }
.demo-player-guide-content h3 { font-size: 17px; }

.demo-player-guide-content p,
.demo-player-guide-content ul,
.demo-player-guide-content ol {
  margin: 0 0 12px;
}

.demo-player-guide-content img,
.demo-player-guide-content video {
  max-width: 100%;
  height: auto;
}

.demo-player-guide-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.demo-player-guide-empty {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  color: var(--demo-muted);
}

.demo-player-guide-empty strong {
  color: var(--demo-text);
}

.demo-player-scene-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Cap to ~4 visible scene cards on desktop; scroll for the rest. Prevents
     long demos (e.g. 16 scenes) from pushing the transport bar off-screen. */
  max-height: min(360px, 50vh);
  overflow-y: auto;
}

.demo-player-scene {
  width: 100%;
  /* min-width: 0 lets the 1fr child shrink so long titles can ellipsize
     instead of expanding the button past the sidebar width. */
  min-width: 0;
  text-align: left;
  border: 1px solid var(--demo-border);
  border-radius: 8px;
  background: var(--demo-surface);
  color: var(--demo-text);
  padding: 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
}

.demo-player-scene:hover {
  background: #f8fafc;
}

.demo-player-scene.active {
  border-color: var(--demo-accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .12);
}

.demo-player-scene-number {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--demo-surface-2);
  color: var(--demo-muted);
  font-weight: 800;
  font-size: 12px;
}

.demo-player-scene.active .demo-player-scene-number {
  background: var(--demo-accent);
  color: #fff;
}

/* The 2nd grid cell of the scene button is an unnamed <span> wrapping the
   title + meta. Force it to behave like a block-level grid item that can
   shrink, so the title's ellipsis actually engages. */
.demo-player-scene > span:last-child {
  display: block;
  min-width: 0;
  overflow: hidden;
}

.demo-player-scene-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.demo-player-scene-meta {
  color: var(--demo-muted);
  font-size: 12px;
  margin-top: 2px;
}

.demo-player-main {
  min-width: 0;
}

.demo-player-stage {
  position: relative;
  background: #0b0f16;
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.demo-player-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #0b0f16;
}

.demo-player-empty {
  color: #cbd5e1;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
}

.demo-player-empty strong {
  color: #fff;
  font-size: 18px;
}

.demo-player-slide {
  width: 100%;
  height: 100%;
  background: #d6dbe2;
  color: #151d27;
  padding: clamp(34px, 6vw, 76px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.demo-player-slide h1,
.demo-player-slide h2,
.demo-player-slide p,
.demo-player-slide ul {
  margin-top: 0;
}

.demo-player-slide h1 {
  font-size: clamp(30px, 4.6vw, 58px);
  line-height: 1.05;
  margin-bottom: 18px;
}

.demo-player-slide h2 {
  font-size: clamp(24px, 3.4vw, 42px);
  line-height: 1.15;
  margin-bottom: 14px;
}

.demo-player-slide p,
.demo-player-slide li {
  font-size: clamp(18px, 2.1vw, 28px);
  line-height: 1.35;
}

.demo-player-overlay {
  position: absolute;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(8, 13, 23, .78);
  color: #fff;
  font-weight: 650;
  pointer-events: none;
}

.demo-player-overlay.top-left { top: 16px; left: 16px; }
.demo-player-overlay.top-center { top: 16px; left: 50%; transform: translateX(-50%); }
.demo-player-overlay.top-right { top: 16px; right: 16px; }
.demo-player-overlay.middle-center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.demo-player-overlay.bottom-left { bottom: 16px; left: 16px; }
.demo-player-overlay.bottom-center { bottom: 16px; left: 50%; transform: translateX(-50%); }
.demo-player-overlay.bottom-right { bottom: 16px; right: 16px; }

.demo-player-transport {
  display: grid;
  grid-template-columns: auto auto auto minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--demo-border);
}

.demo-player-transport button {
  min-height: 36px;
  border: 1px solid var(--demo-border);
  border-radius: 8px;
  background: var(--demo-surface-2);
  color: var(--demo-text);
  padding: 7px 11px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.demo-player-transport button:hover:not(:disabled) {
  background: #e3eaf2;
}

.demo-player-transport button:disabled,
.demo-player-transport input:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.demo-player-transport input[type="range"] {
  width: 100%;
  accent-color: var(--demo-accent);
}

#demo-player-time {
  color: var(--demo-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .demo-player-shell {
    grid-template-columns: 1fr;
  }

  .demo-player-sidebar {
    position: static;
    max-height: none;
  }

  .demo-player-guide {
    flex: 0 0 auto;
    min-height: 0;
  }

  .demo-player-guide-body {
    max-height: 420px;
  }
}

@media (max-width: 900px) {
  .demo-player-page {
    padding: 12px;
  }

  .demo-player-toolbar,
  .demo-player-shell {
    grid-template-columns: 1fr;
  }

  .demo-player-controls {
    justify-content: flex-start;
  }

  .demo-player-controls select {
    min-width: 100%;
  }

  .demo-player-stage {
    min-height: 0;
  }

  .demo-player-transport {
    grid-template-columns: repeat(3, 1fr);
  }

  .demo-player-transport input[type="range"],
  #demo-player-time {
    grid-column: 1 / -1;
  }

  .demo-player-scenes-head {
    grid-template-columns: 1fr;
  }

  .demo-player-scenes-head span {
    text-align: left;
    white-space: normal;
  }

  .demo-player-scene-list {
    grid-template-columns: 1fr;
    max-height: 260px;
  }
}
