:root {
  --bg: #090d13;
  --panel: rgba(12, 17, 24, 0.96);
  --panel-soft: rgba(16, 22, 30, 0.82);
  --line: rgba(210, 224, 232, 0.16);
  --line-strong: rgba(210, 224, 232, 0.28);
  --text: #eef2f1;
  --muted: #879397;
  --cyan: #69d7ff;
  --green: #62e6ad;
  --amber: #ffbd52;
  --red: #ff6969;
  --mono: 'SFMono-Regular', 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

.version-lab {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 70% 45%, rgba(255, 189, 82, 0.035), transparent 36%),
    var(--bg);
}

.version-rail {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 26px 22px 20px;
  border-right: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(22, 29, 38, 0.95), rgba(8, 12, 17, 0.98)),
    var(--panel);
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.24);
}

.rail-header {
  padding: 0 4px 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.stage-title span,
.stage-mode span,
.version-brief > span {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.rail-header h1 {
  margin-top: 9px;
  color: #f3f5f4;
  font-family: var(--mono);
  font-size: clamp(24px, 2vw, 30px);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.rail-header p {
  margin-top: 14px;
  color: #929da0;
  font-size: 11px;
  line-height: 1.65;
}

.project-root {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(105, 215, 255, 0.035);
}

.project-root-icon {
  display: grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid rgba(105, 215, 255, 0.28);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 12px;
}

.project-root span:last-child {
  display: grid;
  gap: 3px;
}

.project-root b {
  color: #dce7e8;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 650;
}

.project-root em {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
}

.version-line {
  position: relative;
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-left: 18px;
}

.version-line::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 5px;
  width: 1px;
  background: linear-gradient(var(--cyan), var(--amber) 36%, rgba(255, 189, 82, 0.2));
}

.version-item {
  --item-accent: #6f7b82;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  width: 100%;
  min-height: 69px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.version-item:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.version-item.active {
  --item-accent: var(--amber);
  border-color: color-mix(in srgb, var(--item-accent) 52%, transparent);
  background: color-mix(in srgb, var(--item-accent) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--item-accent), 0 10px 26px rgba(0, 0, 0, 0.2);
  transform: translateX(2px);
}

.version-item[data-version='original'].active {
  --item-accent: var(--cyan);
}

.version-node {
  position: absolute;
  top: 26px;
  left: -17px;
  width: 9px;
  height: 9px;
  border: 2px solid #67747b;
  border-radius: 50%;
  background: #111820;
  box-shadow: 0 0 0 4px #111820;
}

.version-item.active .version-node {
  border-color: var(--item-accent);
  background: var(--item-accent);
  box-shadow: 0 0 0 4px #111820, 0 0 14px var(--item-accent);
}

.version-number {
  grid-column: 1;
  color: var(--item-accent);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.version-item strong {
  grid-column: 1;
  font-size: 12px;
  font-weight: 650;
}

.version-item em {
  grid-column: 1;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.version-state {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.version-state.locked {
  border-color: rgba(105, 215, 255, 0.28);
  color: var(--cyan);
}

.version-state.current {
  border-color: rgba(255, 189, 82, 0.34);
  color: var(--amber);
}

.version-state.ready {
  border-color: rgba(98, 230, 173, 0.22);
  color: var(--green);
}

.version-brief {
  margin-top: auto;
  padding: 14px 15px 15px;
  border: 1px solid var(--line);
  border-top-color: rgba(255, 189, 82, 0.38);
  background: rgba(255, 255, 255, 0.025);
}

.version-brief strong {
  display: block;
  margin-top: 7px;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
}

.version-brief p {
  margin-top: 8px;
  color: #929da0;
  font-size: 9px;
  line-height: 1.6;
}

.factory-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #0b1018;
}

body[data-active-version="1.2"] .stage-footer { display: none; }
.stage-actions a[hidden] { display: none; }

#factory-stage-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b1018;
}

.stage-header {
  position: absolute;
  z-index: 12;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 32px;
  min-height: 78px;
  padding: 17px 24px 20px;
  border-bottom: 1px solid rgba(210, 224, 232, 0.13);
  background: linear-gradient(180deg, rgba(7, 11, 17, 0.94), rgba(7, 11, 17, 0.34), transparent);
  pointer-events: none;
}

.stage-title {
  text-align: left;
}

.stage-title strong {
  display: block;
  margin-top: 5px;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 680;
  letter-spacing: 0.02em;
}

.stage-mode {
  display: grid;
  text-align: right;
  gap: 4px;
}

.stage-mode strong {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.stage-mode em {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
}

.stage-actions {
  position: absolute;
  z-index: 18;
  top: 82px;
  right: 18px;
  display: flex;
  gap: 7px;
}

.stage-actions button,
.stage-actions a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(8, 12, 18, 0.78);
  color: #9aa5a8;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.stage-actions button:hover,
.stage-actions a:hover {
  border-color: rgba(255, 189, 82, 0.46);
  color: var(--text);
}

.stage-loading {
  position: absolute;
  z-index: 16;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(10px);
  opacity: 1;
  visibility: visible;
  transition: opacity 280ms ease, visibility 280ms ease;
  pointer-events: none;
}

.stage-loading.ready {
  opacity: 0;
  visibility: hidden;
}

.loading-ring {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 189, 82, 0.15);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.stage-loading strong {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.stage-loading em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.stage-footer {
  position: absolute;
  z-index: 12;
  right: 20px;
  bottom: 17px;
  left: 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  color: #758187;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.stage-footer b {
  color: #c8cfce;
  font-weight: 650;
}

.footer-rule {
  color: #a08f6a;
}

@media (max-width: 1050px) {
  .version-lab {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .version-rail {
    padding: 20px 15px 16px;
  }

  .version-item {
    min-height: 64px;
    padding: 9px 8px;
  }

  .stage-header {
    gap: 12px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .stage-mode em,
  .stage-footer .footer-rule {
    display: none;
  }
}

@media (max-height: 760px) {
  .version-rail {
    padding-top: 18px;
  }

  .rail-header {
    padding-bottom: 14px;
  }

  .rail-header p {
    display: none;
  }

  .version-line {
    margin-top: 12px;
  }

  .version-item {
    min-height: 58px;
  }

  .version-brief {
    padding: 10px 12px;
  }
}
