/* ───────────────────────────────────────────────────────────
   WORKBENCH / STAGE
   ─────────────────────────────────────────────────────────── */
.stage {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--stage);
  color: var(--chalk);
  visibility: hidden;
  pointer-events: none;
  clip-path: inset(50% 0 50% 0);
  transition: clip-path 0.7s var(--ease-io), visibility 0.7s;
  overscroll-behavior: contain;
}
.stage.is-open {
  visibility: visible;
  pointer-events: auto;
  clip-path: inset(0 0 0 0);
}
.stage:focus {
  outline: none;
}
body.is-stage .cursor {
  opacity: 0 !important;
}
body.is-palette .cursor {
  opacity: 0 !important;
}
body.has-cursor .palette button {
  cursor: pointer;
}
body.has-cursor .palette input {
  cursor: text;
}
body.is-stage .stage input {
  cursor: text;
}
body.is-stage .stage button,
body.is-stage .stage input,
body.is-stage .stage a {
  cursor: pointer;
}
body.is-stage .stage-view canvas {
  cursor: crosshair;
}
.stage-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.stage-hidden-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 30;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(7, 8, 9, 0.8);
  border: 1px solid rgba(244, 240, 230, 0.2);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.6);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.stage.chrome-hidden .stage-hidden-hint {
  opacity: 1;
}
.stage.is-closing {
  pointer-events: none;
}
.stage-shell {
  height: 100svh;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr) 58px;
  position: relative;
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  z-index: 3;
}
.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 18px 0 22px;
  border-bottom: 1px solid rgba(244, 240, 230, 0.14);
  position: relative;
  z-index: 6;
  background: var(--stage);
}
.stage-ident {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.stage-brand {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.055em;
  color: var(--chalk);
  flex: 0 0 auto;
}
.stage-brand i {
  font-style: normal;
  color: var(--signal);
  font-size: 9px;
  vertical-align: top;
}
.stage-div {
  width: 1px;
  height: 20px;
  background: rgba(244, 240, 230, 0.16);
  flex: 0 0 auto;
}
.stage-num {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--signal);
  flex: 0 0 auto;
}
.stage-name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-top-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  flex: 0 0 auto;
}
.stage-top-mid .dot {
  width: 5px;
  height: 5px;
  background: var(--fam);
}
.stage-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}
.stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.65);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}
.stage-btn:hover {
  color: var(--chalk);
  border-color: rgba(244, 240, 230, 0.25);
}
.stage-btn.is-on {
  color: var(--signal);
}
.stage-btn .dot {
  width: 4px;
  height: 4px;
  background: currentColor;
  border-radius: 50%;
}
.stage-btn--close {
  margin-left: 6px;
  border-color: rgba(244, 240, 230, 0.28);
  color: var(--chalk);
  padding: 0 10px;
}
.stage-btn--close:hover {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--paper-soft);
}
.stage-btn--close kbd {
  border-color: currentColor;
  opacity: 0.6;
}

.stage-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 334px;
  min-height: 0;
  transition: grid-template-columns 0.55s var(--ease);
  position: relative;
  z-index: 2;
}
.stage-view {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #030405;
  overflow: hidden;
  margin: 14px 0 14px 14px;
  border: 1px solid rgba(244, 240, 230, 0.14);
  isolation: isolate;
}
.stage-view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 79px,
      rgba(244, 240, 230, 0.035) 79px,
      rgba(244, 240, 230, 0.035) 80px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 79px,
      rgba(244, 240, 230, 0.035) 79px,
      rgba(244, 240, 230, 0.035) 80px
    );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  mix-blend-mode: screen;
}
.stage-view:hover::before {
  opacity: 0.5;
}
.stage-view canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.4s var(--ease);
  touch-action: none;
}
.stage-view.is-swapping canvas {
  opacity: 0;
}
.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 110px 20px rgba(0, 0, 0, 0.35);
}
.stage-corners span {
  position: absolute;
  z-index: 4;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(244, 240, 230, 0.45);
  pointer-events: none;
}
.stage-corners span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.stage-corners span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.stage-corners span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.stage-corners span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.stage-hud {
  position: absolute;
  z-index: 5;
  left: 14px;
  top: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 8px;
  background: rgba(7, 8, 9, 0.38);
  border: 1px solid rgba(244, 240, 230, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.52);
  pointer-events: none;
  flex-wrap: wrap;
}
.stage-hud .state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(244, 240, 230, 0.7);
}
.stage-hud .state i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #7ddc62;
  box-shadow: 0 0 6px rgba(125, 220, 98, 0.7);
}
.stage-hud .state.is-paused i {
  background: var(--signal);
  box-shadow: none;
}
.stage-hint {
  position: absolute;
  z-index: 5;
  right: 14px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  background: rgba(7, 8, 9, 0.38);
  border: 1px solid rgba(244, 240, 230, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.5);
  pointer-events: none;
  text-align: right;
}
.stage-hint::before {
  content: "";
  width: 16px;
  height: 1px;
  background: rgba(244, 240, 230, 0.3);
}

.stage-info {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 24px 20px;
  border-left: 1px solid rgba(244, 240, 230, 0.14);
  margin: 14px 14px 14px 0;
  border-top: 1px solid rgba(244, 240, 230, 0.14);
  border-right: 1px solid rgba(244, 240, 230, 0.14);
  border-bottom: 1px solid rgba(244, 240, 230, 0.14);
  display: flex;
  flex-direction: column;
  background: rgba(10, 11, 13, 0.6);
  transition: opacity 0.3s, padding 0.5s;
}
.info-ghost {
  position: absolute;
  top: -2px;
  right: 8px;
  font-family: var(--serif);
  font-size: 104px;
  line-height: 1;
  letter-spacing: -0.06em;
  color: rgba(244, 240, 230, 0.055);
  pointer-events: none;
  z-index: 0;
  user-select: none;
}
.info-eyebrow {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.info-eyebrow::before {
  content: "";
  width: 13px;
  height: 1px;
  background: currentColor;
}
.info-title {
  position: relative;
  z-index: 1;
  font-size: clamp(26px, 2.5vw, 38px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
  margin-bottom: 16px;
}
.info-desc {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  line-height: 1.65;
  color: rgba(244, 240, 230, 0.62);
  margin-bottom: 20px;
}
.info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}
.info-tags .tag {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 6px;
  border: 1px solid rgba(244, 240, 230, 0.17);
  color: rgba(244, 240, 230, 0.55);
}
.info-spec {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(244, 240, 230, 0.14);
  margin-bottom: 22px;
}
.info-spec > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(244, 240, 230, 0.09);
}
.info-spec dt {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.35);
  padding-top: 2px;
}
.info-spec dd {
  font-size: 11.5px;
  line-height: 1.4;
  color: rgba(244, 240, 230, 0.82);
}
.info-keys {
  margin-top: auto;
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(244, 240, 230, 0.14);
  padding-top: 13px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 12px;
}
.info-keys div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.38);
}
.info-keys kbd {
  opacity: 0.8;
  flex: 0 0 auto;
}
.info-keys .audio-note {
  grid-column: 1 / -1;
  color: var(--signal);
  margin-top: 3px;
  display: none;
}
.info-keys .audio-note.is-visible {
  display: flex;
}

.info-live {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(244, 240, 230, 0.14);
  padding: 13px 0 15px;
}
.info-live__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.35);
}
.info-live__head i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 7px rgba(33, 201, 183, 0.7);
  animation: pulse-dot 2s infinite;
}
.info-live__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 9px;
  border: 1px solid rgba(244, 240, 230, 0.12);
  background: rgba(244, 240, 230, 0.1);
}
.info-live__grid div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px;
  background: rgba(8, 10, 12, 0.82);
}
.info-live__grid span {
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.3);
}
.info-live__grid b {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  color: rgba(244, 240, 230, 0.85);
  font-variant-numeric: tabular-nums;
}
.info-live__id {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.3);
}
.info-live__id code {
  font-family: var(--mono);
  font-size: 6px;
  color: rgba(227, 63, 27, 0.8);
}
.info-note {
  position: relative;
  z-index: 1;
  margin: 4px 0 18px;
  padding: 2px 0 2px 13px;
  border-left: 1px solid rgba(227, 63, 27, 0.6);
}
.info-note span {
  display: block;
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.3);
  margin-bottom: 7px;
}
.info-note p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: rgba(244, 240, 230, 0.62);
}

.stage-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  border-top: 1px solid rgba(244, 240, 230, 0.14);
  background: var(--stage);
  position: relative;
  z-index: 6;
  transition: opacity 0.3s;
}
.stage-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  text-align: left;
  min-width: 0;
  color: rgba(244, 240, 230, 0.55);
  transition: color 0.2s, background 0.2s;
}
.stage-nav:hover {
  color: var(--chalk);
  background: rgba(244, 240, 230, 0.04);
}
.stage-nav--next {
  justify-content: flex-end;
  text-align: right;
}
.stage-nav .arrow {
  font-size: 15px;
  line-height: 1;
  color: var(--signal);
  flex: 0 0 auto;
}
.stage-nav .label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stage-nav .label span:first-child {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.32);
}
.stage-nav .label span:last-child {
  font-size: 12px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: currentColor;
}
.stage-tour {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 22px;
  border-left: 1px solid rgba(244, 240, 230, 0.12);
  border-right: 1px solid rgba(244, 240, 230, 0.12);
  min-width: 176px;
}
.stage-tour button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 240, 230, 0.55);
  transition: color 0.2s;
}
.stage-tour button:hover,
.stage-tour button.is-on {
  color: var(--chalk);
}
.stage-tour button .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(244, 240, 230, 0.35);
}
.stage-tour button.is-on .dot {
  background: var(--signal);
  animation: pulse-dot 1.6s infinite;
}
.tour-track {
  width: 100%;
  height: 1px;
  background: rgba(244, 240, 230, 0.16);
  overflow: hidden;
}
.tour-track span {
  display: block;
  height: 100%;
  background: var(--signal);
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
}
.stage-tour.is-active .tour-track span {
  animation: tour-fill var(--tour-duration, 9s) linear forwards;
}
@keyframes tour-fill {
  to { transform: scaleX(1); }
}

/* hide chrome mode */
.stage.chrome-hidden .stage-top,
.stage.chrome-hidden .stage-info,
.stage.chrome-hidden .stage-foot {
  opacity: 0;
  pointer-events: none;
}
.stage.chrome-hidden .stage-main {
  grid-template-columns: 1fr 0px;
}
.stage.chrome-hidden .stage-view {
  margin: 0;
  border-color: transparent;
}
.stage.chrome-hidden .stage-info {
  padding: 0;
  margin: 0;
  border: 0;
}
.stage.chrome-hidden .stage-shell {
  grid-template-rows: 0 minmax(0, 1fr) 0;
}
.stage.chrome-hidden .stage-top,
.stage.chrome-hidden .stage-foot {
  overflow: hidden;
}

/* mobile */
@media (max-width: 900px) {
  .stage {
    overflow-y: auto;
  }
  .stage-shell {
    height: auto;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
  }
  .stage-top {
    position: sticky;
    top: 0;
    min-height: 56px;
    padding: 0 12px;
    gap: 12px;
    z-index: 20;
  }
  .stage-top-mid,
  .stage-name,
  .stage-brand,
  .stage-div {
    display: none;
  }
  .stage-num {
    font-size: 8px;
  }
  .stage-actions {
    margin-left: auto;
  }
  .stage-btn {
    width: auto;
    justify-content: center;
    padding: 0 6px;
    gap: 5px;
  }
  .stage-btn span {
    display: inline;
    font-size: 6.5px;
    letter-spacing: 0.05em;
  }
  .stage-btn--close {
    width: auto;
    padding: 0 7px;
    gap: 5px;
  }
  .stage-btn--close span {
    display: inline;
    font-size: 6.5px;
  }
  .stage-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    transition: none;
  }
  .stage-view {
    margin: 8px;
    height: 52vh;
    min-height: 300px;
    flex: 0 0 auto;
  }
  .stage-info {
    margin: 0 8px 8px;
    border: 1px solid rgba(244, 240, 230, 0.14);
    border-top: 0;
    padding: 22px 18px;
    overflow: visible;
    max-height: none;
  }
  .info-ghost {
    font-size: 78px;
  }
  .info-title {
    font-size: 30px;
  }
  .info-keys {
    margin-top: 18px;
  }
  .stage-foot {
    position: sticky;
    bottom: 0;
    grid-template-columns: 1fr auto 1fr;
    min-height: 52px;
    z-index: 20;
  }
  .stage-nav {
    padding: 0 12px;
  }
  .stage-nav .label span:last-child,
  .stage-nav .label span:first-child {
    display: none;
  }
  .stage-tour {
    min-width: 120px;
    padding: 0 12px;
  }
  .stage.chrome-hidden .stage-shell {
    display: block;
    height: 100svh;
  }
  .stage.chrome-hidden .stage-main {
    display: flex;
  }
  .stage.chrome-hidden .stage-view {
    height: 100svh;
    min-height: 0;
    margin: 0;
  }
  .stage.chrome-hidden .stage-info {
    display: none;
  }
  .stage.chrome-hidden .stage-top,
  .stage.chrome-hidden .stage-foot {
    display: none;
  }
}

@media (max-width: 480px) {
  .stage-tour {
    min-width: 82px;
  }
  .stage-tour button {
    font-size: 6.5px;
    letter-spacing: 0.05em;
  }
  .stage-hud {
    gap: 8px;
    font-size: 6px;
  }
  .stage-hint {
    display: none;
  }
  .stage-view {
    height: 46vh;
  }
  .info-keys {
    grid-template-columns: 1fr;
  }
}
