.vb-workspace .vb-side-stack {
  position: relative;
  display: grid;
  grid-template-columns: 58px 0;
  gap: 12px;
  align-content: start;
  transition: grid-template-columns 180ms ease;
}

.vb-workspace .vb-side-stack.vb-v3-has-open-panel {
  grid-template-columns: 58px minmax(300px, 390px);
}

.vb-v3-rail {
  position: sticky;
  top: 88px;
  z-index: 4;
  display: grid;
  gap: 8px;
  align-self: start;
}

.vb-v3-rail button {
  min-height: 52px;
  padding: 8px 5px;
  overflow: hidden;
  color: var(--muted, #b9ad93);
  background: color-mix(in srgb, var(--panel, #19150f) 92%, transparent);
  border: 1px solid var(--line, #4a3c27);
  border-radius: 14px;
  cursor: pointer;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  transition: 150ms ease;
}

.vb-v3-rail button:hover,
.vb-v3-rail button.active {
  color: #fff;
  background: #175cd3;
  border-color: #4c8dff;
  box-shadow: 0 10px 24px rgb(23 92 211 / 25%);
}

.vb-side-stack > [data-v3-panel] {
  display: none !important;
  min-width: 0;
  grid-column: 2;
  grid-row: 1 / span 8;
  animation: vb-v3-panel-in 160ms ease both;
}

.vb-side-stack > [data-v3-panel].vb-v3-panel-open {
  display: block !important;
}

/* Async cloud refreshes can replace the QA/activity card after V3 classified it.
   Keep the visible card derived from the active rail as a structural fallback. */
.vb-side-stack:has(.vb-v3-rail [data-v3-open-panel="tests"].active)
  > .vb-panel:has(.vb-qa-state),
.vb-side-stack:has(.vb-v3-rail [data-v3-open-panel="tests"].active)
  > .vb-panel:has([data-testid="visual-handoff"]),
.vb-side-stack:has(.vb-v3-rail [data-v3-open-panel="live"].active)
  > .vb-panel:has(.vb-activity),
.vb-side-stack:has(.vb-v3-rail [data-v3-open-panel="behaviors"].active)
  > .vb-panel:has([data-vb-behavior]),
.vb-side-stack:has(.vb-v3-rail [data-v3-open-panel="checklist"].active)
  > [data-testid="visual-screen-checklist"] {
  display: block !important;
  min-width: 0;
  grid-column: 2;
  grid-row: 1 / span 8;
  animation: vb-v3-panel-in 160ms ease both;
}

@keyframes vb-v3-panel-in {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.vb-v3-screen-unit {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.vb-v3-screen-unit .vb-screen-tab {
  padding-right: 72px;
}

.vb-v3-screen-quick {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  padding: 4px 7px;
  color: #a9c7ff;
  font-size: 10px;
  background: rgb(23 92 211 / 18%);
  border: 1px solid rgb(76 141 255 / 45%);
  border-radius: 8px;
  cursor: pointer;
}

.vb-v3-five-screens {
  margin-left: auto;
  padding: 8px 12px;
  color: #f4c85e;
  background: transparent;
  border: 1px dashed #6c5529;
  border-radius: 10px;
  cursor: pointer;
}

.vb-v3-item-percent {
  float: right;
  margin-left: 8px;
  padding: 4px 7px;
  color: #9fc1ff;
  font-size: 11px;
  background: rgb(23 92 211 / 16%);
  border: 1px solid rgb(76 141 255 / 35%);
  border-radius: 999px;
}

.vb-v3-summary-toggle {
  margin-top: 8px;
  padding: 0;
  color: #f4c85e;
  font: inherit;
  font-size: 11px;
  background: none;
  border: 0;
  cursor: pointer;
}

.vb-v2-check-items li:not(.vb-v3-summary-open) .vb-v2-check-copy > p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vb-v2-check-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
}

.vb-v2-check-actions .btn {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 10px;
}

.vb-v3-behavior-unit {
  padding-bottom: 8px;
}

.vb-v3-behavior-detail {
  margin: 0 0 8px;
  padding: 12px;
  background: rgb(23 92 211 / 9%);
  border: 1px solid rgb(76 141 255 / 25%);
  border-radius: 0 0 12px 12px;
}

.vb-v3-behavior-detail[hidden] {
  display: none;
}

.vb-v3-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 26px;
  color: #f7f0e4;
  background: #17130e;
  border: 1px solid #5b4829;
  border-radius: 22px;
  box-shadow: 0 28px 90px rgb(0 0 0 / 70%);
}

.vb-v3-dialog::backdrop {
  background: rgb(3 5 10 / 72%);
  backdrop-filter: blur(8px);
}

.vb-v3-dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  color: #fff;
  background: #2b241a;
  border: 1px solid #4a3d2a;
  border-radius: 10px;
  cursor: pointer;
}

.vb-v3-dialog textarea {
  width: 100%;
  min-height: 150px;
  margin: 12px 0;
  padding: 14px;
  color: #fff;
  background: #0d0b08;
  border: 1px solid #4d3e28;
  border-radius: 12px;
  resize: vertical;
}

.vb-v3-drop {
  display: grid;
  gap: 6px;
  padding: 24px;
  text-align: center;
  border: 1px dashed #806632;
  border-radius: 14px;
  cursor: pointer;
}

.vb-v3-drop.ready {
  color: #bcd3ff;
  background: rgb(23 92 211 / 13%);
  border-color: #4c8dff;
}

.vb-v3-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.vb-v3-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  color: #fff;
  background: #175cd3;
  border: 1px solid #4c8dff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 45%);
}

.vb-v3-toast.error {
  background: #8b2828;
  border-color: #e36a6a;
}

@media (max-width: 980px) {
  .vb-workspace .vb-side-stack,
  .vb-workspace .vb-side-stack.vb-v3-has-open-panel {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 40;
    display: block;
  }

  .vb-v3-rail {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 6px;
    background: #12100c;
    border: 1px solid #4a3c27;
    border-radius: 14px;
  }

  .vb-v3-rail button {
    min-height: 42px;
    writing-mode: horizontal-tb;
    transform: none;
  }

  .vb-side-stack > [data-v3-panel].vb-v3-panel-open {
    max-height: 68vh;
    margin-top: 8px;
    overflow: auto;
    box-shadow: 0 -20px 70px rgb(0 0 0 / 55%);
  }
}
