/* 方案乙 · 开发说明：索引 embed 隐藏；单页用 proto-page-layout 内联；旧 fixed 作兜底 */

html.proto-embed .dev-spec-rail,
html.proto-embed .dev-spec-drawer,
html.proto-embed .dev-spec-backdrop,
html.proto-embed .proto-spec-zone {
  display: none !important;
}

/* ── 单页（03-f2 等）：机模 + 右侧说明区，不 fixed、不挤机模 ── */
.proto-page-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  /* 与 index 中间区同量级，避免说明区被压成窄条 */
  max-width: min(1500px, 100vw);
  margin: 12px auto 28px;
  padding: 0 16px;
  box-sizing: border-box;
}

.proto-page-layout .proto-stage {
  width: auto;
  max-width: none;
  margin: 0;
  flex-shrink: 0;
}

.proto-page-layout .proto-spec-zone {
  flex: 1 1 520px;
  min-width: min(480px, calc(100vw - var(--iphone-w, 430px) - 64px));
  max-width: min(680px, calc(100vw - var(--iphone-w, 430px) - 48px));
  margin-left: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  align-self: stretch;
  min-height: calc(var(--iphone-h, 932px) + 48px);
}

.proto-page-layout .dev-spec-rail {
  position: static;
  right: auto;
  top: auto;
  transform: none;
  flex-shrink: 0;
  align-self: center;
  z-index: 1;
  padding: 10px 6px;
  border: none;
  border-radius: 6px 0 0 6px;
  background: linear-gradient(180deg, #f9b400, #ff770f);
  color: #000026;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
  cursor: pointer;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
}

.proto-page-layout .dev-spec-backdrop {
  display: none !important;
}

.proto-page-layout .dev-spec-drawer {
  position: static;
  left: auto !important;
  top: auto !important;
  flex: 1 1 auto;
  width: 100%;
  min-width: min(460px, 100%);
  max-width: none;
  max-height: min(calc(var(--iphone-h, 932px) + 80px), 92vh);
  display: none;
  flex-direction: column;
  opacity: 1;
  visibility: visible;
  transform: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.15);
  overflow: hidden;
  z-index: 1;
}

.proto-page-layout .dev-spec-drawer.is-open {
  display: flex;
}

.proto-page-layout .dev-spec-rail.is-open {
  box-shadow: -2px 0 16px rgba(249, 180, 0, 0.45);
}

/* 仅 tabs + 机模居中（无说明区时的旧页） */
.proto-stage {
  width: calc(var(--iphone-w) + var(--frame-pad) * 2);
  max-width: 100%;
  margin: 12px auto 28px;
}

/* ── 兜底：无 proto-page-layout 时右侧 fixed（尽量避免新页使用） ── */
body:not(:has(.proto-page-layout)) .dev-spec-rail {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 180;
  padding: 14px 8px;
  border: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(180deg, #f9b400, #ff770f);
  color: #000026;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.15em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  cursor: pointer;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

body:not(:has(.proto-page-layout)) .dev-spec-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
body:not(:has(.proto-page-layout)) .dev-spec-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

body:not(:has(.proto-page-layout)) .dev-spec-drawer {
  position: fixed;
  z-index: 200;
  width: min(380px, calc(100vw - 24px));
  max-height: min(85vh, 820px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateX(12px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  overflow: hidden;
}
body:not(:has(.proto-page-layout)) .dev-spec-drawer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

@media (max-width: 900px) {
  .proto-page-layout {
    flex-direction: column;
    align-items: center;
  }
  .proto-page-layout .proto-spec-zone {
    margin-left: 0;
    margin-top: 12px;
    max-width: 100%;
    width: 100%;
    min-height: 0;
  }
  .proto-page-layout .dev-spec-drawer.is-open {
    max-height: 70vh;
  }
}

/* ── 抽屉内容样式（共用） ── */
.dev-spec-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.dev-spec-drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
}
.dev-spec-drawer-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.dev-spec-drawer-close:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.dev-spec-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafafa;
  flex-shrink: 0;
}
.dev-spec-toolbar button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
}
.dev-spec-toolbar button:hover {
  border-color: #f9b400;
  color: #0f172a;
}
.dev-spec-toolbar a {
  font-size: 11px;
  padding: 4px 10px;
  color: #b45309;
  text-decoration: none;
}

.dev-spec-body {
  flex: 1;
  min-height: 0;
  padding: 10px 12px 8px;
  font-size: 12px;
  line-height: 1.55;
  color: #334155;
  overflow-y: auto;
  outline: none;
  --spec-chapter-size: 13px;
}
.dev-spec-body:focus {
  box-shadow: inset 0 0 0 2px rgba(249, 180, 0, 0.35);
}
/* 章节圈号：细线圆 + 圈内数字加粗（标题与正文引用共用） */
.dev-spec-body .spec-chapter-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  box-sizing: border-box;
  border: 1px solid #64748b;
  border-radius: 50%;
  font-size: 1em;
  font-weight: 400;
  line-height: 1;
  margin: 0;
  color: #0f172a;
}
.dev-spec-body .spec-chapter-digit {
  font-weight: 800;
  font-size: 0.58em;
  line-height: 1;
  letter-spacing: -0.02em;
}
.dev-spec-body .spec-chapter-num--inline {
  font-size: var(--spec-chapter-size);
  vertical-align: middle;
  margin: 0 0.05em;
  /* 圈 13px > 正文 12px：middle 对齐后再上移，使圆心 ≈ 汉字视觉中线 */
  transform: translateY(-0.11em);
}
.dev-spec-body strong .spec-chapter-num--inline {
  font-weight: 400;
}
.dev-spec-body h4 {
  margin: 12px 0 5px;
  font-size: var(--spec-chapter-size);
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.3em;
  line-height: 1;
}
.dev-spec-body h4 .spec-chapter-num {
  font-size: inherit;
}
.dev-spec-body h4:first-child { margin-top: 0; }
.dev-spec-body p { margin: 0 0 6px; }
.dev-spec-body ol {
  margin: 0 0 8px;
  padding-left: 1.2em;
  list-style: decimal;
}
.dev-spec-body ol li {
  padding-left: 0.25em;
}
.dev-spec-body ul {
  margin: 0 0 8px;
  padding-left: 0;
  list-style: none;
}
.dev-spec-body ul ul,
.dev-spec-body ol ol,
.dev-spec-body li > ul,
.dev-spec-body li > ol {
  margin: 4px 0 6px;
  padding-left: 0.85em;
  border-left: 2px solid #e2e8f0;
}
.dev-spec-body li {
  margin-bottom: 5px;
  padding-left: 0.65em;
  position: relative;
}
.dev-spec-body > ul > li::before,
.dev-spec-body > ol > li::before {
  content: "";
}
.dev-spec-body ul ul li,
.dev-spec-body ol ol li,
.dev-spec-body li > ul > li,
.dev-spec-body li > ol > li {
  font-size: 10.5px;
  color: #475569;
  margin-bottom: 3px;
}
.dev-spec-body ul ul li::marker,
.dev-spec-body li > ul > li {
  list-style: none;
}
.dev-spec-body li > ul > li::before {
  content: "– ";
  color: #94a3b8;
  margin-left: -0.85em;
  padding-right: 0.25em;
}

/* 开发说明 · 语义配色（默认灰；linkify 脚本自动加 spec-* class） */
.dev-spec-body code,
.preview-spec-body code {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: #f8fafc;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400;
}
/* 元素 ID · data-spec-id（紫 · 加粗） */
.dev-spec-body code.spec-id,
.preview-spec-body code.spec-id {
  background: #f3e8ff;
  color: #7c3aed;
  font-weight: 600;
}
/* 接口路径（绿） */
.dev-spec-body code.spec-api,
.preview-spec-body code.spec-api {
  background: #ecfdf5;
  color: #047857;
  font-weight: 500;
}
/* 埋点事件（橙 · 虚线下划线） */
.dev-spec-body code.spec-event,
.preview-spec-body code.spec-event {
  background: #fff7ed;
  color: #c2410c;
  font-weight: 500;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
/* 其它技术词（灰） */
.dev-spec-body code.spec-generic,
.preview-spec-body code.spec-generic {
  background: #f1f5f9;
  color: #475569;
}

/* 原型页 · 蓝色下划线 */
.dev-spec-body a.dev-spec-page-link,
.preview-spec-body a.dev-spec-page-link {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 500;
}
.dev-spec-body a.dev-spec-page-link:hover,
.preview-spec-body a.dev-spec-page-link:hover {
  color: #1d4ed8;
}
.dev-spec-body code a.dev-spec-page-link {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: #2563eb !important;
  font-weight: 500;
  text-decoration: underline;
}
.dev-spec-body code a.dev-spec-page-link:hover {
  color: #1d4ed8 !important;
}

/* dev-notes 文档链（琥珀 · 与页面链区分） */
.dev-spec-body a[href*="dev-notes"],
.preview-spec-body a[href*="dev-notes"] {
  color: #b45309;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dev-spec-body a[href*="dev-notes"]:hover,
.preview-spec-body a[href*="dev-notes"]:hover {
  color: #92400e;
}


.dev-spec-body .spec-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  margin-right: 4px;
}

.dev-spec-hint {
  flex-shrink: 0;
  font-size: 10px;
  color: #64748b;
  padding: 8px 10px;
  border-top: 1px dashed #e2e8f0;
  background: #fffbeb;
}

[data-spec-id] { position: relative; }

/* 仅可交互控件悬停高亮，避免纯展示元素（AI 标、计数、清单等）误导可点击 */
.proto-body:not(.proto-spec-off) [data-spec-id]:is(
  a,
  button,
  input,
  textarea,
  select,
  summary,
  [role="button"],
  [role="link"],
  [role="tab"],
  .spec-interactive
):hover {
  outline: 2px dashed rgba(249, 180, 0, 0.75);
  outline-offset: 2px;
}

.proto-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 220;
  max-width: 90%;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.4;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.92);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.proto-toast.show { opacity: 1; }

@media (max-width: 900px) {
  body:not(:has(.proto-page-layout)) .dev-spec-drawer {
    left: 12px !important;
    right: 12px !important;
    width: auto;
    max-width: none;
  }
}
