:root {
  --truth-font-desktop: 11px;
  --truth-font-mobile: 10px;
  color-scheme: dark;
  font-family:
    Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ink: #eef8f8;
  --muted: rgba(232, 245, 245, 0.7);
  --panel: rgba(11, 29, 32, 0.78);
  --line: rgba(211, 240, 240, 0.18);
  --red: #d6444d;
  --green: #35a968;
  --blue: #55bee2;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #9db5b9;
}

button {
  min-height: 44px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid #85e5ff;
  outline-offset: 3px;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 640px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 75% 12%, rgba(255, 255, 255, 0.46), transparent 34%),
    linear-gradient(145deg, #b7cdd0, #77969a);
}

#stage,
.poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#stage {
  display: block;
  touch-action: none;
}

.poster {
  z-index: 2;
  object-fit: cover;
  opacity: 1;
  transition: opacity 480ms ease;
}

.poster.is-hidden {
  pointer-events: none;
  opacity: 0;
}

.topbar,
.intro,
.stage-summary,
.stage-controls,
.technical-panel,
.tour-controls,
.truth-bar {
  position: absolute;
  z-index: 10;
}

.topbar {
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 74px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 24, 27, 0.88), rgba(8, 24, 27, 0.24));
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: var(--red);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.demo-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.demo-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #79d79f;
  box-shadow: 0 0 12px #79d79f;
}

.variant-nav {
  display: flex;
  max-width: min(560px, 46vw);
  gap: 5px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 23, 26, 0.54);
  scrollbar-width: none;
}

.variant-nav::-webkit-scrollbar {
  display: none;
}

.variant-nav a {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  text-decoration: none;
  white-space: nowrap;
}

.variant-nav a[aria-current="page"] {
  background: rgba(50, 147, 103, 0.34);
  box-shadow: inset 0 0 0 1px rgba(114, 224, 174, 0.42);
  color: var(--ink);
}

.intro {
  top: 104px;
  left: 28px;
  width: min(390px, 30vw);
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(9, 28, 31, 0.9), rgba(17, 42, 45, 0.7));
  box-shadow: 0 22px 60px rgba(7, 21, 24, 0.2);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 8px;
  color: #87ddbc;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.intro h1 {
  margin: 0;
  font-size: clamp(25px, 2.2vw, 38px);
  line-height: 1.06;
}

.intro-copy {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.intro-details > summary,
.technical-panel > summary {
  display: none;
}

.stage-summary > summary {
  display: block;
  list-style: none;
}

.stage-summary > summary::-webkit-details-marker {
  display: none;
}

.presentation-toggle,
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.presentation-toggle button,
.control-grid button,
.tour-controls button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
}

button[aria-pressed="true"] {
  border-color: rgba(114, 224, 174, 0.7);
  background: rgba(50, 147, 103, 0.28);
  box-shadow: inset 0 0 0 1px rgba(114, 224, 174, 0.12);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 13px;
  margin-top: 15px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend .red {
  background: var(--red);
}

.legend .green {
  background: var(--green);
}

.legend .blue {
  background: var(--blue);
}

.color-note {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
}

.stage-summary {
  top: 104px;
  right: 28px;
  width: min(330px, 26vw);
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.stage-summary small {
  color: #88dec0;
  font-size: 9px;
  letter-spacing: 0.14em;
}

.stage-summary h2 {
  margin: 7px 0 8px;
  font-size: 20px;
}

.stage-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.progress {
  height: 2px;
  margin-top: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: #7bd6ae;
}

.stage-controls {
  right: 28px;
  bottom: 78px;
  left: 28px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(7, 23, 26, 0.78);
  backdrop-filter: blur(18px);
}

.stage-controls button {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.stage-controls b {
  color: #7fd5b2;
  font-size: 10px;
}

.stage-controls span {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.technical-panel {
  top: 330px;
  right: 28px;
  display: none;
  width: min(330px, 26vw);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  backdrop-filter: blur(15px);
}

#app[data-presentation="technical"] .technical-panel {
  display: block;
}

.technical-panel section + section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.technical-panel p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.technical-panel .control-grid {
  grid-template-columns: repeat(3, 1fr);
}

.technical-panel .control-grid.two {
  grid-template-columns: repeat(2, 1fr);
}

.technical-panel button {
  min-height: 40px;
  font-size: 10px;
}

.tour-controls {
  bottom: 21px;
  left: 28px;
  display: flex;
  gap: 7px;
}

.tour-controls button {
  min-width: 94px;
  padding: 0 14px;
  background: rgba(7, 23, 26, 0.82);
  backdrop-filter: blur(12px);
}

.truth-bar {
  right: 28px;
  bottom: 25px;
  display: flex;
  gap: 16px;
  color: rgba(243, 251, 251, 0.66);
  font-size: 9px;
}

.label-layer {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
}

.scene-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  background: rgba(10, 31, 33, 0.82);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
  color: #f2ffff;
  font-size: 10px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.scene-label::after {
  position: absolute;
  top: 50%;
  width: 14px;
  border-top: 1px solid rgba(242, 255, 255, 0.68);
  content: "";
}

.scene-label[data-side="left"]::after {
  right: -14px;
}

.scene-label[data-side="right"]::after {
  left: -14px;
}

.fallback {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(10, 30, 33, 0.72), rgba(10, 30, 33, 0.85)),
    url("/media/photobioreactor-five-ten-3d-poster.webp") center / cover;
}

#app[data-demo="photobioreactor-vertical"] .fallback {
  background:
    linear-gradient(rgba(10, 30, 33, 0.72), rgba(10, 30, 33, 0.85)),
    url("/media/photobioreactor-vertical-3d-poster.webp") center / cover;
}

#app[data-demo="photobioreactor-large-pipe"] .fallback {
  background:
    linear-gradient(rgba(10, 30, 33, 0.72), rgba(10, 30, 33, 0.85)),
    url("/media/photobioreactor-large-pipe-3d-poster.webp") center / cover;
}

.fallback[hidden] {
  display: none;
}

.fallback-card {
  width: min(640px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(7, 25, 28, 0.92);
}

.fallback-card h2 {
  margin: 0 0 12px;
}

.fallback-card p,
.fallback-card li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.truth-note {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.poster-mode .topbar,
.poster-mode .intro,
.poster-mode .stage-summary,
.poster-mode .stage-controls,
.poster-mode .technical-panel,
.poster-mode .tour-controls,
.poster-mode .truth-bar,
.poster-mode .label-layer {
  display: none;
}

.embed-mode .topbar {
  height: 58px;
}

.embed-mode .intro {
  top: 78px;
  width: min(330px, 29vw);
}

.embed-mode .intro-copy,
.embed-mode .truth-bar {
  display: none !important;
}

.embed-mode .stage-summary {
  top: 78px;
}

.embed-mode #app[data-presentation="technical"] .technical-panel {
  top: 250px;
  display: block;
}

@media (max-width: 900px) {
  #app {
    min-height: 0;
  }

  .topbar {
    height: 58px;
    padding: 0 14px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .demo-badge {
    display: none;
  }

  .variant-nav {
    max-width: 210px;
    margin-left: auto;
  }

  .variant-nav a {
    padding: 5px 7px;
    font-size: 8px;
  }

  .intro {
    top: 72px;
    left: 12px;
    width: calc(100% - 24px);
    padding: 13px 15px;
  }

  .intro h1 {
    font-size: 20px;
    line-height: 1.25;
  }

  .intro .eyebrow {
    display: none;
  }

  .intro-details {
    max-height: 32svh;
    margin-top: 6px;
    overflow-y: auto;
  }

  .intro-details > summary,
  .technical-panel > summary {
    display: list-item;
    min-height: 32px;
    padding: 7px 3px;
    color: #c5ebe1;
    font-size: 11px;
    cursor: pointer;
  }

  .presentation-toggle {
    margin-top: 6px;
  }

  .presentation-toggle button {
    min-height: 36px;
  }

  .intro-copy {
    margin: 7px 0 9px;
    font-size: 11px;
    line-height: 1.5;
  }

  .legend {
    margin-top: 9px;
  }

  .stage-summary {
    top: auto;
    right: 12px;
    bottom: calc(var(--mobile-truth-height, 36px) + 126px);
    left: 12px;
    width: auto;
    padding: 7px 11px;
  }

  .stage-summary small {
    display: none;
  }

  .stage-summary > summary {
    cursor: pointer;
  }

  .stage-summary h2::after {
    float: right;
    content: "+";
  }

  .stage-summary[open] h2::after {
    content: "−";
  }

  html:not(.embed-mode) .stage-summary[open] {
    max-height: 40svh;
    overflow-y: auto;
  }

  html:not(.embed-mode) .stage-summary[open] p {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }

  .stage-summary h2 {
    margin: 4px 0;
    font-size: 16px;
  }

  .stage-summary p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 10px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .stage-controls {
    right: 12px;
    bottom: 84px;
    left: 12px;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 6px;
    scroll-snap-type: x mandatory;
  }

  .stage-controls button {
    min-width: 124px;
    scroll-snap-align: start;
  }

  .technical-panel {
    top: auto;
    right: 12px;
    bottom: calc(var(--mobile-truth-height, 36px) + 126px);
    left: 12px;
    width: auto;
    max-height: 40svh;
    padding: 9px;
    overflow-y: auto;
  }

  #app[data-presentation="technical"] .stage-summary {
    display: none;
  }

  .technical-panel .control-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .technical-panel button {
    min-height: 38px;
  }

  .tour-controls {
    right: 12px;
    bottom: 24px;
    left: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tour-controls button {
    min-width: 0;
    padding: 0 5px;
    font-size: 10px;
  }

  .truth-bar {
    display: none;
  }

  .scene-label {
    padding: 5px 8px;
    font-size: 9px;
  }

  .embed-mode .intro {
    top: 66px;
    left: 12px;
    width: 210px;
    padding: 9px 11px;
  }

  .embed-mode #app {
    min-height: 0;
  }

  .embed-mode .intro .eyebrow,
  .embed-mode .intro h1,
  .embed-mode .intro-copy,
  .embed-mode .presentation-toggle {
    display: none;
  }

  .embed-mode .intro-details {
    max-height: none;
    margin-top: 0;
    overflow: visible;
  }

  .embed-mode .intro-details > summary {
    display: none;
  }

  .embed-mode #app[data-presentation="technical"] .technical-panel {
    top: auto;
    bottom: 112px;
  }

  .embed-mode .legend {
    gap: 5px 9px;
    margin-top: 0;
  }

  .embed-mode .color-note {
    display: block;
    margin-top: 6px;
    font-size: 9px;
  }

  .embed-mode .stage-summary {
    top: 66px;
    right: 12px;
    bottom: auto;
    left: auto;
    width: min(270px, calc(100% - 246px));
    padding: 9px 11px;
  }

  .embed-mode .stage-summary h2 {
    margin: 3px 0;
    font-size: 14px;
  }

  .embed-mode .stage-summary p {
    font-size: 9px;
    -webkit-line-clamp: 1;
  }

  .embed-mode .progress {
    margin-top: 7px;
  }

  .embed-mode .stage-controls {
    bottom: 56px;
  }

  .embed-mode .tour-controls {
    bottom: 6px;
  }
}

@media (max-width: 560px) {
  .embed-mode .topbar {
    height: 48px;
  }

  .embed-mode .intro {
    top: 54px;
    right: 8px;
    left: 8px;
    width: auto;
    padding: 6px 8px;
  }

  .embed-mode .legend {
    flex-wrap: nowrap;
    justify-content: center;
  }

  .embed-mode .legend span,
  .embed-mode .color-note {
    font-size: 8px;
  }

  .embed-mode .color-note {
    margin-top: 4px;
    text-align: center;
  }

  .embed-mode .stage-summary {
    display: none;
  }

  .embed-mode .stage-controls {
    right: 8px;
    bottom: 54px;
    left: 8px;
  }

  .embed-mode .tour-controls {
    right: 8px;
    bottom: 5px;
    left: 8px;
  }
}

/* Short landscape screens keep information beside, not across, the model. */
@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  html:not(.embed-mode) .topbar {
    height: 48px;
  }

  html:not(.embed-mode) .intro {
    top: 58px;
    right: auto;
    left: 12px;
    width: 240px;
    max-height: calc(100% - 92px);
    padding: 10px;
    overflow-y: auto;
  }

  html:not(.embed-mode) #app .intro h1 {
    font-size: 17px;
  }

  html:not(.embed-mode) #app .stage-summary,
  html:not(.embed-mode) #app .technical-panel {
    top: auto;
    right: 12px;
    bottom: 150px;
    left: auto;
    width: 250px;
    max-height: calc(100% - 208px);
    overflow-y: auto;
  }

  html:not(.embed-mode) .stage-controls {
    right: 12px;
    bottom: 86px;
    left: auto;
    width: 250px;
  }

  html:not(.embed-mode) .tour-controls {
    right: 12px;
    bottom: 32px;
    left: auto;
    width: 250px;
  }
}

@media (max-height: 700px) and (min-width: 901px) {
  .intro {
    top: 86px;
    padding: 14px 16px;
  }

  .stage-summary {
    top: 86px;
  }

  .stage-controls {
    bottom: 66px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

.truth-bar,
.truth-note {
  font-size: var(--truth-font-desktop);
}

@media (max-width: 900px) {
  .truth-bar,
  .truth-note {
    font-size: var(--truth-font-mobile);
  }

  .truth-bar {
    right: 10px;
    bottom: 3px;
    left: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 12px;
    padding: 4px 8px;
    background: rgba(7, 23, 26, 0.82);
    line-height: 1.25;
    text-align: center;
  }

  .tour-controls {
    bottom: calc(var(--mobile-truth-height, 36px) + 10px);
  }

  .stage-controls {
    bottom: calc(var(--mobile-truth-height, 36px) + 70px);
  }
}
