/* Right Rail Buttons — prototype-right-rail-nav.md */
/* 1. Overall container — now draggable + collapsible to single icon */
.proto-right-rail-btns {
  position: fixed;
  right: 0;
  top: 40%;        /* default position, overridden by drag */
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  cursor: grab;
  user-select: none;
}

.proto-right-rail-btns.is-dragging {
  cursor: grabbing;
}

/* 2. Collapsed state — show only a single expand icon */
.proto-right-rail-btns.is-collapsed .proto-right-rail-btns__btn,
.proto-right-rail-btns.is-collapsed .proto-right-rail-btns__drag-handle,
.proto-right-rail-btns.is-collapsed .proto-right-rail-btns__btn-collapse {
  display: none;
}

.proto-right-rail-btns.is-collapsed {
  cursor: pointer;
}

.proto-right-rail-btns__collapse-toggle {
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  letter-spacing: 0;
  padding: 0;
  background: #1677ff;
  color: #fff;
  border-radius: 6px 0 0 6px;
}

.proto-right-rail-btns.is-collapsed .proto-right-rail-btns__collapse-toggle {
  display: flex;
}

.proto-right-rail-btns__collapse-toggle:hover {
  background: #4096ff;
  color: #fff;
}

/* 3. Drag handle */
.proto-right-rail-btns__drag-handle {
  width: auto;
  min-width: 76px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: grab;
  user-select: none;
  background: #1677ff;
  color: rgba(255,255,255,0.7);
  border-radius: 6px 0 0 0;
}
.proto-right-rail-btns__drag-handle:hover {
  color: #fff;
}

/* 4. Buttons — 横排文字 */
.proto-right-rail-btns__btn {
  width: auto;
  min-width: 76px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  padding: 0 10px;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s;
  background: #1677ff;
  color: #fff;
}

.proto-right-rail-btns__btn:first-of-type {
  border-radius: 0;
}

.proto-right-rail-btns__btn:hover {
  background: #4096ff;
}

.proto-right-rail-btns__btn.is-active {
  background: #1677ff;
  color: #fff;
  box-shadow: none;
}

.proto-right-rail-btns__btn--flow {
  color: #fff;
}

.proto-right-rail-btns__btn--changes {
  color: #fff;
}

.proto-right-rail-btns__btn-collapse {
  color: rgba(255,255,255,0.75);
  height: 28px;
  font-size: 12px;
  background: #1677ff;
}
.proto-right-rail-btns__btn-collapse:hover {
  color: #fff;
  background: #4096ff;
}

/* 5. Panel (floating to the left of buttons) */
.proto-right-rail-btns__panel {
  position: fixed;
  right: 76px;
  width: min(320px, 28vw);
  max-height: min(500px, 75vh);
  z-index: 2099;
  background: #fff;
  border-radius: 8px 0 0 8px;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  border: 1px solid #e8e8e8;
  border-right: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.85);
  /* top/transform set by JS to follow button group */
}

.proto-right-rail-btns__panel.is-hidden {
  display: none;
}

.proto-right-rail-btns__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  /* 蓝底白字 */
  background: #1677ff;
  color: #fff;
  flex-shrink: 0;
}

.proto-right-rail-btns__panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.proto-right-rail-btns__panel-title--global {
  color: #fff;
}

.proto-right-rail-btns__panel-title--flow {
  color: #fff;
}

.proto-right-rail-btns__panel-title--changes {
  color: #fff;
}

.proto-right-rail-btns__panel-close {
  font-size: 16px;
  line-height: 1;
  border: none;
  background: none;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  padding: 2px 4px;
  border-radius: 4px;
}

.proto-right-rail-btns__panel-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.proto-right-rail-btns__panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* 6. Global content — only legend now */
.proto-right-rail-btns__global h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.proto-right-rail-btns__global section {
  margin-bottom: 10px;
}

.proto-right-rail-btns__global ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.proto-right-rail-btns__global li {
  margin-bottom: 3px;
}

/* 7. Flow — simplified chart + zoom */
.proto-right-rail-btns__flow-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.proto-right-rail-btns__flow-item {
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
}

.proto-right-rail-btns__flow-item:hover {
  background: #fafafa;
}

.proto-right-rail-btns__flow-item.is-active {
  background: rgba(19, 194, 194, 0.08);
  border-color: rgba(19, 194, 194, 0.35);
}

.proto-right-rail-btns__flow-title {
  font-size: 12px;
  font-weight: 600;
}

.proto-right-rail-btns__flow-source {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 2px;
}

.proto-right-rail-btns__flow-steps {
  display: none;
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 11px;
  line-height: 1.5;
}

.proto-right-rail-btns__flow-item.is-active .proto-right-rail-btns__flow-steps {
  display: block;
}

.proto-right-rail-btns__flow-tips {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 6px;
}

/* Flow chart — 朴素渲染，不加复杂样式 */
.proto-right-rail-btns__flow-chart {
  margin-top: 8px;
  border-top: 1px dashed #e8e8e8;
  padding-top: 8px;
  position: relative;
}

.proto-right-rail-btns__flow-chart-inline svg,
.proto-right-rail-btns__flow-chart img,
.proto-right-rail-btns__flow-chart svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.proto-right-rail-btns__flow-chart-actions {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.proto-right-rail-btns__flow-chart-zoom {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #d9d9d9;
  background: #fff;
  cursor: pointer;
  color: rgba(0,0,0,0.65);
  transition: all 0.15s;
}

.proto-right-rail-btns__flow-chart-zoom:hover {
  border-color: #13c2c2;
  color: #13c2c2;
}

/* 8. Zoom overlay — 支持拖动边框放大/缩小 */
.proto-right-rail-btns__zoom-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: protoZoomFadeIn 0.2s ease;
}

.proto-right-rail-btns__zoom-overlay.is-hidden {
  display: none;
}

.proto-right-rail-btns__zoom-container {
  position: relative;
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  resize: both;
  overflow: auto;
  min-width: 200px;
  min-height: 150px;
  max-width: 95vw;
  max-height: 95vh;
}

.proto-right-rail-btns__zoom-svg-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.proto-right-rail-btns__zoom-svg-wrap svg {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: block;
}

.proto-right-rail-btns__zoom-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,0.65);
  transition: all 0.15s;
}

.proto-right-rail-btns__zoom-close:hover {
  background: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.85);
}

@keyframes protoZoomFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 9. Changes */
.proto-right-rail-btns__version-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.proto-right-rail-btns__version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
}

.proto-right-rail-btns__version-item:hover {
  background: #fafafa;
  border-color: #d9d9d9;
}

.proto-right-rail-btns__version-label {
  font-size: 12px;
  font-weight: 600;
}

.proto-right-rail-btns__version-count {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
}

.proto-right-rail-btns__changes-back {
  font-size: 11px;
  border: none;
  background: none;
  color: #722ed1;
  cursor: pointer;
  padding: 0;
  margin-right: 8px;
}

.proto-right-rail-btns__changes-hint {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  flex: 1;
}

.proto-right-rail-btns__toggle {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #d9d9d9;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.proto-right-rail-btns__toggle.is-on {
  border-color: #722ed1;
  color: #722ed1;
  background: rgba(114, 46, 209, 0.06);
}

.proto-right-rail-btns__change-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.proto-right-rail-btns__change-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.proto-right-rail-btns__change-item:hover {
  background: #fafafa;
  border-color: #f0f0f0;
}

.proto-right-rail-btns__change-item.is-active {
  background: rgba(114, 46, 209, 0.08);
  border-color: rgba(114, 46, 209, 0.25);
}

.proto-right-rail-btns__change-flow {
  display: none;
  flex: 1 1 100%;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #e8e8e8;
}

.proto-right-rail-btns__change-item.is-active .proto-right-rail-btns__change-flow {
  display: block;
}

.proto-right-rail-btns__change-flow-label {
  font-size: 11px;
  font-weight: 600;
  color: #13c2c2;
  margin-bottom: 6px;
}

.proto-right-rail-btns__change-item.is-active .proto-right-rail-btns__flow-steps {
  display: block;
}

.proto-right-rail-btns__change-badge {
  flex-shrink: 0;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  color: #fff;
  font-weight: 600;
  line-height: 1.4;
}

.proto-right-rail-btns__change-badge--add {
  background: #52c41a;
}

.proto-right-rail-btns__change-badge--modify {
  background: #faad14;
  color: rgba(0, 0, 0, 0.85);
}

.proto-right-rail-btns__change-badge--delete {
  background: #ff4d4f;
}

.proto-right-rail-btns__change-text {
  min-width: 0;
}

.proto-right-rail-btns__change-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.85);
}

.proto-right-rail-btns__change-summary {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 2px;
}

.proto-right-rail-btns__changes-empty {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  text-align: center;
  padding: 20px 0;
}

/* Version Context POC */
.proto-right-rail-btns__btn--version {
  border-left: 3px solid #595959;
}

.proto-right-rail-btns__btn--version.is-version-active,
.proto-right-rail-btns__btn--version.is-active {
  border-left-color: #722ed1;
  background: #9254de;
}

.proto-right-rail-btns__panel-title--version {
  color: #fff;
}

.proto-right-rail-btns__version-meta {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.proto-right-rail-btns__version-section {
  margin-bottom: 16px;
}

.proto-right-rail-btns__version-section h5 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.65);
}

.proto-right-rail-btns__changes-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.proto-right-rail-btns__change-has-flow {
  font-size: 10px;
  font-weight: 500;
  color: #13c2c2;
  margin-left: 4px;
}

.proto-right-rail-btns__flow-chart-loading {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 8px;
}
