:root {
  --truth-font-desktop: 11px;
  --truth-font-mobile: 10px;
  color-scheme: dark;
  --ink: #f1f6f7;
  --muted: #9fb0b6;
  --line: rgba(160, 197, 205, 0.2);
  --panel: rgba(6, 17, 21, 0.84);
  --panel-strong: rgba(5, 14, 18, 0.95);
  --red: #d44a48;
  --amber: #b8782f;
  --vapor: #e2cfb3;
  --cyan: #4fa4b8;
  --green: #5a9f72;
  font-family:
    Inter,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  background: #071014;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overflow-x: hidden;
  background: #071014;
  color: var(--ink);
}

button {
  color: inherit;
  font: inherit;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at 51% 42%,
      rgba(50, 107, 118, 0.38),
      transparent 35%
    ),
    radial-gradient(
      circle at 66% 17%,
      rgba(184, 120, 47, 0.11),
      transparent 27%
    ),
    linear-gradient(158deg, #13272e 0%, #081519 56%, #050b0e 100%);
}

canvas#stage {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.floor-grid {
  position: absolute;
  z-index: 2;
  right: 17%;
  bottom: 0;
  left: 17%;
  height: 38%;
  pointer-events: none;
  background:
    linear-gradient(rgba(113, 164, 174, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 164, 174, 0.09) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75),
    transparent 93%
  );
}

.topbar,
.intro,
.process-panel,
.flow-truth-note,
.qualification,
.corner-actions,
.control-hint {
  position: absolute;
  z-index: 10;
}

.topbar {
  top: 24px;
  right: 32px;
  left: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: rgba(6, 17, 21, 0.74);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid rgba(212, 74, 72, 0.86);
  color: #f17c78;
  font-size: 21px;
  font-weight: 900;
}

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

.brand strong {
  font-size: 19px;
  letter-spacing: 0.04em;
}

.brand small {
  margin-top: 3px;
  color: #82989f;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.demo-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #8ca0a7;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.demo-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #68b98c;
  box-shadow: 0 0 12px rgba(104, 185, 140, 0.72);
}

.intro {
  top: 124px;
  left: 42px;
  width: min(330px, 25vw);
}

.eyebrow {
  margin: 0 0 10px;
  color: #75aab5;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.15em;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 2.55vw, 41px);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

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

.equipment-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 16px;
}

.equipment-button {
  min-height: 66px;
  padding: 9px 10px;
  border: 1px solid rgba(143, 180, 188, 0.16);
  background: rgba(7, 18, 22, 0.68);
  color: #9eb0b6;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.equipment-button strong,
.equipment-button span {
  display: block;
}

.equipment-button strong {
  font-size: 11px;
}

.equipment-button span {
  margin-top: 6px;
  color: #71858c;
  font-size: 8px;
  line-height: 1.25;
}

.equipment-button:hover,
.equipment-button:focus-visible,
.equipment-button[aria-pressed="true"] {
  border-color: rgba(97, 197, 213, 0.52);
  background: rgba(67, 153, 169, 0.14);
  color: #f2f8f9;
  outline: none;
}

.equipment-button[aria-pressed="true"] {
  transform: translateY(-2px);
}

.equipment-button[aria-pressed="true"] span {
  color: #83c3ce;
}

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

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 7px;
  border: 1px solid rgba(148, 184, 192, 0.14);
  background: rgba(7, 16, 20, 0.58);
  color: #9babb1;
  font-size: 9px;
  font-weight: 750;
}

.legend i {
  display: block;
  width: 15px;
  height: 3px;
}

.legend .process-liquid {
  background: var(--amber);
}

.legend .process-vapor {
  background: var(--vapor);
}

.legend .condensate {
  background: var(--cyan);
}

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

.process-panel {
  top: 112px;
  right: 32px;
  width: min(310px, 23.5vw);
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(17px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head small,
.panel-head strong {
  display: block;
}

.panel-head small {
  margin-bottom: 4px;
  color: #69bac9;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.13em;
}

.panel-head strong {
  font-size: 18px;
}

.panel-head em {
  color: #758990;
  font-size: 10px;
  font-style: normal;
}

#stageDesc {
  min-height: 38px;
  margin: 11px 0 14px;
  color: #9aabb1;
  font-size: 11px;
  line-height: 1.58;
}

.stage-rail {
  display: grid;
  gap: 6px;
}

.stage-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 41px;
  padding: 7px 10px;
  border: 1px solid rgba(139, 177, 185, 0.12);
  background: rgba(139, 177, 185, 0.04);
  color: #9cabb0;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.stage-button span {
  color: #60757c;
  font-size: 9px;
  font-weight: 850;
}

.stage-button strong {
  font-size: 12px;
}

.stage-button:hover,
.stage-button:focus-visible,
.stage-button[aria-pressed="true"] {
  border-color: rgba(91, 196, 214, 0.48);
  background: rgba(91, 196, 214, 0.1);
  color: #f1f7f8;
  outline: none;
}

.stage-button[aria-pressed="true"] {
  transform: translateX(-3px);
}

.stage-button[aria-pressed="true"] span {
  color: #6cc6d6;
}

.stage-labels {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
}

.stage-label {
  position: absolute;
  min-width: max-content;
  padding: 6px 9px;
  border: 1px solid rgba(106, 190, 203, 0.38);
  background: rgba(5, 15, 18, 0.86);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
  color: #e2edef;
  font-size: 10px;
  font-weight: 760;
}

.stage-label::before {
  position: absolute;
  top: 50%;
  right: 100%;
  width: 22px;
  height: 1px;
  background: rgba(106, 190, 203, 0.54);
  content: "";
}

.qualification {
  right: 50%;
  bottom: 23px;
  max-width: 660px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid rgba(148, 184, 192, 0.15);
  background: rgba(5, 14, 18, 0.7);
  color: #87999f;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(50%);
  backdrop-filter: blur(12px);
}

.flow-truth-note {
  right: 50%;
  bottom: 59px;
  max-width: 520px;
  margin: 0;
  color: #91a3a9;
  font-size: 8px;
  text-align: center;
  transform: translateX(50%);
}

.corner-actions {
  right: 32px;
  bottom: 22px;
  display: flex;
  gap: 7px;
}

.action-button {
  min-height: 39px;
  padding: 0 13px;
  border: 1px solid rgba(139, 177, 185, 0.22);
  background: rgba(7, 19, 23, 0.82);
  color: #c8d4d7;
  cursor: pointer;
  font-size: 10px;
  font-weight: 760;
}

.action-button:hover,
.action-button:focus-visible {
  border-color: rgba(91, 196, 214, 0.52);
  background: rgba(91, 196, 214, 0.14);
  outline: none;
}

.control-hint {
  bottom: 28px;
  left: 36px;
  margin: 0;
  color: #71838a;
  font-size: 9px;
}

.fallback {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  padding: 32px;
  background: #071014;
  color: #dfe7e9;
  text-align: center;
}

.fallback p {
  margin: 0 0 18px;
}

.fallback-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(104, 185, 140, 0.46);
  color: #b9dfca;
  text-decoration: none;
}

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

.bottom-ui {
  display: contents;
}

.embed-mode .topbar {
  display: none;
}

.embed-mode .intro,
.embed-mode .process-panel {
  top: 16px;
}

.embed-mode .control-hint,
.embed-mode .flow-truth-note {
  display: none;
}

.embed-mode .qualification,
.embed-mode .corner-actions {
  bottom: 8px;
}

@media (max-width: 1120px) {
  .intro {
    width: 270px;
  }

  .intro-copy {
    font-size: 11px;
  }

  .process-panel {
    width: 280px;
  }
}

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

  .topbar {
    top: 8px;
    right: 10px;
    left: 10px;
    min-height: 54px;
    padding: 7px 9px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 35px;
    height: 35px;
    font-size: 17px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small,
  .demo-status {
    font-size: 7px;
  }

  .demo-status {
    max-width: 108px;
    text-align: right;
  }

  .intro {
    top: 75px;
    left: 14px;
    width: calc(100% - 28px);
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: 7px;
  }

  h1 {
    font-size: 26px;
  }

  .intro-copy {
    max-width: 355px;
    margin-top: 6px;
    font-size: 9px;
    line-height: 1.45;
  }

  .equipment-selector {
    width: min(100%, 355px);
    gap: 6px;
    margin-top: 8px;
  }

  .equipment-button {
    min-height: 48px;
    padding: 6px 8px;
  }

  .equipment-button strong {
    font-size: 9px;
  }

  .equipment-button span {
    margin-top: 4px;
    font-size: 7px;
  }

  .legend {
    gap: 4px;
    margin-top: 6px;
  }

  .legend span {
    min-height: 21px;
    padding: 3px 5px;
    font-size: 7px;
  }

  .process-panel {
    top: auto;
    right: 10px;
    bottom: 123px;
    left: 10px;
    width: auto;
    padding: 10px;
  }

  .panel-head strong {
    font-size: 14px;
  }

  .panel-head em {
    display: none;
  }

  #stageDesc {
    min-height: 0;
    margin: 5px 0 8px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage-rail {
    display: flex;
    gap: 6px;
    padding-bottom: 3px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .stage-button,
  .action-button {
    min-height: 42px;
  }

  .stage-button {
    flex: 0 0 98px;
    grid-template-columns: 20px 1fr;
    padding: 5px 6px;
  }

  .stage-button strong {
    font-size: 10px;
  }

  .stage-button[aria-pressed="true"] {
    transform: none;
  }

  .qualification {
    right: 10px;
    bottom: 56px;
    left: 10px;
    width: auto;
    max-width: none;
    padding: 4px 6px;
    font-size: 7px;
    transform: none;
  }

  .flow-truth-note {
    right: 10px;
    bottom: 91px;
    left: 10px;
    width: auto;
    max-width: none;
    font-size: 7px;
    transform: none;
  }

  .corner-actions {
    right: 10px;
    bottom: 8px;
  }

  .action-button {
    padding: 0 10px;
    font-size: 9px;
  }

  .control-hint {
    bottom: 22px;
    left: 12px;
    font-size: 7px;
  }

  .floor-grid {
    right: 3%;
    bottom: 24%;
    left: 3%;
    height: 29%;
  }

  .stage-label {
    padding: 5px 7px;
    font-size: 8px;
  }

  .stage-label::before {
    width: 13px;
  }

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

  .embed-mode .intro {
    top: 11px;
    left: 11px;
    width: 245px;
  }

  .embed-mode .eyebrow {
    margin-bottom: 4px;
    font-size: 6px;
  }

  .embed-mode h1 {
    font-size: 21px;
  }

  .embed-mode .intro-copy,
  .embed-mode .legend {
    display: none;
  }

  .embed-mode .equipment-selector {
    width: 245px;
    margin-top: 7px;
  }

  .embed-mode .equipment-button {
    min-height: 43px;
  }

  .embed-mode .process-panel {
    top: 11px;
    right: 11px;
    bottom: auto;
    left: auto;
    width: 260px;
    padding: 9px;
  }

  .embed-mode .panel-head strong {
    font-size: 12px;
  }

  .embed-mode .panel-head small {
    font-size: 7px;
  }

  .embed-mode #stageDesc {
    display: none;
  }

  .embed-mode .stage-rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 7px;
    padding: 0;
    overflow: visible;
  }

  .embed-mode .stage-button {
    min-height: 32px;
    grid-template-columns: 16px 1fr;
    padding: 4px 5px;
  }

  .embed-mode .stage-button strong {
    font-size: 8px;
  }

  .embed-mode .stage-button[aria-pressed="true"] {
    transform: none;
  }

  .embed-mode .qualification {
    right: 50%;
    bottom: 7px;
    left: auto;
    width: min(420px, calc(100% - 290px));
    padding: 3px 5px;
    font-size: 6px;
    transform: translateX(50%);
  }

  .embed-mode .corner-actions {
    right: 9px;
    bottom: 7px;
  }

  .embed-mode .action-button {
    min-height: 32px;
    padding: 0 7px;
    font-size: 7px;
  }
}

@media (max-width: 560px) {
  .demo-status {
    display: none;
  }

  .intro-copy {
    max-width: 94%;
  }

  .control-hint {
    display: none;
  }
}

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

.flow-truth-note,
.qualification,
.control-hint {
  font-size: var(--truth-font-desktop);
}

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

  .flow-truth-note,
  .qualification {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .bottom-ui {
    position: absolute;
    z-index: 10;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    pointer-events: none;
  }

  .bottom-ui > .process-panel,
  .bottom-ui > .flow-truth-note,
  .bottom-ui > .qualification,
  .bottom-ui > .corner-actions {
    position: static;
    min-width: 0;
    width: auto;
    max-width: none;
    margin: 0;
    transform: none;
  }

  .bottom-ui > .process-panel,
  .bottom-ui button {
    pointer-events: auto;
  }

  .bottom-ui > .flow-truth-note,
  .bottom-ui > .qualification {
    line-height: 1.4;
  }

  .bottom-ui > .corner-actions {
    justify-self: end;
  }

  .embed-mode .bottom-ui {
    display: contents;
  }

  .embed-mode .bottom-ui > .process-panel,
  .embed-mode .bottom-ui > .qualification,
  .embed-mode .bottom-ui > .corner-actions {
    position: absolute;
  }

  .embed-mode .bottom-ui > .process-panel {
    width: 260px;
  }

  .embed-mode .bottom-ui > .qualification {
    width: min(420px, calc(100% - 290px));
    transform: translateX(50%);
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  .intro-copy,
  .legend,
  .panel-head small,
  #stageDesc {
    display: none;
  }

  .process-panel {
    padding: 8px;
  }

  .stage-rail {
    margin-top: 6px;
  }
}
