/* ============================================================
   原型外壳：预览台 + 手机模拟器 + 导航框架
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: #171A21;
}

body {
  display: flex;
  overflow: hidden;
}

/* ---------------- 左侧索引栏 ---------------- */
.deck {
  width: 268px;
  flex: none;
  height: 100vh;
  background: #1E222B;
  border-right: 1px solid #2C313C;
  display: flex;
  flex-direction: column;
  color: #C7CCD6;
}

.deck-hd {
  padding: 18px 18px 14px;
  border-bottom: 1px solid #2C313C;
}

.deck-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--fs-15);
  font-weight: 600;
  color: #F2F4F8;
  letter-spacing: 0.2px;
}

.deck-logo .mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: var(--fs-13);
  font-weight: 700;
}

.deck-sub {
  margin-top: 7px;
  font-size: var(--fs-11);
  color: #79808F;
  line-height: 1.6;
}

.deck-role {
  padding: 14px 18px;
  border-bottom: 1px solid #2C313C;
}

.deck-label {
  font-size: var(--fs-11);
  color: #6E7787;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #171A21;
  border: 1px solid #2C313C;
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}

.role-switch button {
  border: 0;
  background: transparent;
  color: #8A92A2;
  font-size: var(--fs-12);
  font-family: inherit;
  padding: 6px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.role-switch button.on {
  background: var(--brand-600);
  color: #fff;
  font-weight: 500;
}

.deck-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 24px;
}

.deck-group {
  margin-bottom: 4px;
}

.deck-group > p {
  margin: 14px 8px 6px;
  font-size: var(--fs-11);
  color: #6E7787;
  letter-spacing: 0.6px;
}

.deck-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #B4BAC6;
  font-family: inherit;
  font-size: var(--fs-13);
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.deck-item:hover { background: #262B35; color: #E8EBF0; }
.deck-item.on { background: rgba(42, 109, 219, 0.16); color: #7FADF2; }
.deck-item .idx {
  font-size: var(--fs-11);
  color: #5D6575;
  min-width: 18px;
  font-variant-numeric: tabular-nums;
}
.deck-item.on .idx { color: #4E7FC8; }

.deck-ft {
  padding: 12px 14px 16px;
  border-top: 1px solid #2C313C;
  display: flex;
  gap: 8px;
}

.deck-ft button {
  flex: 1;
  border: 1px solid #333945;
  background: #222630;
  color: #AEB5C2;
  font-family: inherit;
  font-size: var(--fs-12);
  padding: 8px 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.deck-ft button:hover { border-color: #45506180; color: #E4E8EE; }

/* ---------------- 舞台 ---------------- */
.stage {
  flex: 1;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    radial-gradient(1100px 620px at 50% -10%, #262C38 0%, #171A21 62%);
  overflow: hidden;
}

.stage::after {
  /* 极淡的施工图网格底纹 */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-size: var(--fs-12);
  color: #5D6575;
  z-index: 2;
}

/* 视口不足以完整放下手机时，隐藏底部提示，避免与机身重叠 */
@media (max-height: 940px) {
  .stage-hint { display: none; }
}

/* ---------------- 手机 ---------------- */
.phone {
  position: relative;
  z-index: 1;
  transform-origin: center center;
  transition: transform 160ms var(--ease);
  width: 414px;
  height: 872px;
  border-radius: 52px;
  padding: 12px;
  background: linear-gradient(160deg, #3A414F, #22262F 45%, #12151B);
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  flex: none;
}

.phone::before {
  content: "";
  position: absolute;
  right: -3px;
  top: 190px;
  width: 3px;
  height: 78px;
  border-radius: 0 3px 3px 0;
  background: #3D4553;
}

.screen {
  position: relative;
  width: 390px;
  height: 848px;
  border-radius: 42px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------------- 状态栏 ---------------- */
.statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--sbh);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px 0 30px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--ink-900);
  transition: color 200ms var(--ease);
}

.statusbar.on-dark { color: #fff; }

.statusbar .sb-r { display: flex; align-items: center; gap: 5px; }

.notch {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 108px;
  height: 27px;
  border-radius: var(--r-pill);
  background: #0B0D11;
  z-index: 40;
}

/* ---------------- 页面容器与转场 ---------------- */
.viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page.enter { animation: pushIn var(--dur) var(--ease); }
.page.leave { animation: pushOut var(--dur) var(--ease) forwards; }
.page.enter-back { animation: popIn var(--dur) var(--ease); }
.page.leave-back { animation: popOut var(--dur) var(--ease) forwards; }
.page.fade { animation: fadeIn 200ms var(--ease); }

@keyframes pushIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pushOut { from { transform: translateX(0); } to { transform: translateX(-24%); filter: brightness(0.92); } }
@keyframes popIn { from { transform: translateX(-24%); filter: brightness(0.92); } to { transform: translateX(0); filter: none; } }
@keyframes popOut { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.scroll.has-nav { padding-top: calc(var(--sbh) + 48px); }
.scroll::-webkit-scrollbar { width: 0; }

/* ---------------- 导航栏（含 46px 状态栏安全区） ---------------- */
.navbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: calc(var(--sbh) + 48px);
  padding: var(--sbh) 8px 0;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.navbar .nav-t {
  position: absolute;
  left: 50%;
  top: var(--sbh);
  height: 48px;
  line-height: 48px;
  transform: translateX(-50%);
  font-size: var(--fs-16);
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.navbar .nav-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-700);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.navbar .nav-btn:active { background: var(--line-soft); }
.navbar .nav-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.navbar .nav-text {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-14);
  color: var(--brand-600);
  padding: 6px 10px;
  cursor: pointer;
}

/* 透明导航（用于深色头部页面） */
.navbar.ghost {
  background: transparent;
  border-bottom: 0;
  color: #fff;
}
.navbar.ghost .nav-btn { color: #fff; }
.navbar.ghost .nav-t { color: #fff; }
.navbar.ghost .nav-text { color: #fff; }

/* ---------------- 底部标签栏 ---------------- */
.tabbar {
  flex: none;
  height: calc(54px + var(--sbb));
  padding-bottom: var(--sbb);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-nav);
  display: flex;
  align-items: flex-start;
  position: relative;
  z-index: 25;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-400);
  font-family: inherit;
  font-size: var(--fs-11);
  cursor: pointer;
}
.tab.on { color: var(--brand-600); font-weight: 500; }
.tab svg { width: 23px; height: 23px; }

.tab-fab {
  flex: 1;
  position: relative;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 7px;
  gap: 3px;
  font-family: inherit;
  font-size: var(--fs-11);
  color: var(--brand-700);
  font-weight: 500;
}

.tab-fab .fab {
  width: 46px;
  height: 46px;
  margin-top: -20px;
  border-radius: 15px;
  background: linear-gradient(155deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(19, 71, 149, 0.36);
  transition: transform 150ms var(--ease);
}
.tab-fab:active .fab { transform: scale(0.94); }
.tab-fab .fab svg { width: 24px; height: 24px; }

.home-bar {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 132px;
  height: 5px;
  border-radius: 3px;
  background: var(--ink-900);
  opacity: 0.22;
  z-index: 60;
  pointer-events: none;
}

/* ---------------- 移动端菜单按钮与遮罩（窄屏才出现） ---------------- */
.m-menu, .deck-backdrop { display: none; }

/* ============================================================
   手机浏览器适配：去掉模拟机身，页面铺满视口，索引栏改为抽屉
   ============================================================ */
@media (max-width: 820px) {
  :root {
    --sbh: max(env(safe-area-inset-top, 0px), 10px);
    --sbb: max(env(safe-area-inset-bottom, 0px), 6px);
  }

  html, body { background: var(--bg); overscroll-behavior: none; }
  body { display: block; height: 100dvh; overflow: hidden; }

  /* 索引栏变为左侧抽屉 */
  .deck {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 84vw;
    max-width: 310px;
    height: 100dvh;
    z-index: 320;
    transform: translateX(-102%);
    transition: transform 280ms var(--ease);
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  body.deck-open .deck { transform: none; }

  .deck-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 310;
    background: rgba(9, 11, 15, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms var(--ease);
  }
  body.deck-open .deck-backdrop { opacity: 1; pointer-events: auto; }

  /* 舞台与机身铺满 */
  .stage {
    height: 100dvh;
    width: 100vw;
    background: var(--bg);
    display: block;
  }
  .stage::after, .stage-hint { display: none; }

  .phone {
    width: 100%;
    height: 100dvh;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    transform: none !important;
  }
  .phone::before { display: none; }

  .screen {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  /* 真机自带状态栏与手势条，隐藏模拟件 */
  .notch, .statusbar, .home-bar { display: none; }

  /* 悬浮的原型索引入口 */
  .m-menu {
    display: grid;
    place-items: center;
    position: fixed;
    left: 12px;
    bottom: calc(78px + var(--sbb));
    z-index: 300;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 13px;
    background: rgba(16, 24, 40, .78);
    backdrop-filter: blur(8px);
    color: #fff;
    box-shadow: 0 6px 16px rgba(16, 24, 40, .3);
  }
  .m-menu:active { transform: scale(.94); }
  .m-menu svg { width: 21px; height: 21px; }

  /* 规范面板单列化 */
  .sp-box { width: 94vw; max-height: 88dvh; }
  .sp-bd { padding: 4px 14px 20px; }
  .sp-principles { grid-template-columns: 1fr; }
  .sp-swatches { grid-template-columns: repeat(3, 1fr); }
  .sp-tokens { grid-template-columns: repeat(3, 1fr); }
  .sp-table th, .sp-table td { padding: 8px 6px; font-size: var(--fs-11); }
}

/* ---------------- 规范 / 对照面板 ---------------- */
.spec-panel { position: fixed; inset: 0; z-index: 200; }
.sp-mask { position: absolute; inset: 0; background: rgba(9, 11, 15, 0.62); animation: fadeMask 200ms var(--ease); }
.sp-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(880px, 88vw); max-height: 86vh;
  background: #FFFFFF; border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
  animation: dlgIn 240ms var(--ease);
}
.sp-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.sp-hd h3 { margin: 0; font-size: var(--fs-16); font-weight: 600; letter-spacing: .3px; }
.sp-x { border: 0; background: transparent; color: var(--ink-400); cursor: pointer; padding: 4px; }
.sp-bd { overflow-y: auto; padding: 4px 20px 26px; }
.sp-sec {
  font-size: var(--fs-13); font-weight: 600; color: var(--ink-700);
  padding: 20px 0 10px; letter-spacing: .4px;
}
.sp-note { font-size: var(--fs-13); color: var(--ink-600); line-height: 1.8; margin: 16px 0 0; }
.sp-note b { color: var(--brand-700); }

.sp-principles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sp-pr { padding: 12px 14px; background: var(--bg); border-radius: var(--r-sm); border: 1px solid var(--line-soft); }
.sp-pr b { font-size: var(--fs-13); }
.sp-pr p { margin: 5px 0 0; font-size: var(--fs-12); color: var(--ink-600); line-height: 1.75; }

.sp-cg { margin-bottom: 12px; }
.sp-cg-t { font-size: var(--fs-12); color: var(--ink-500); }
.sp-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.sw { border: 1px solid var(--line-soft); border-radius: var(--r-sm); overflow: hidden; padding-bottom: 8px; }
.sw i { display: block; height: 42px; }
.sw b { display: block; font-size: var(--fs-11); padding: 7px 8px 0; font-family: var(--font-num); }
.sw span { display: block; font-size: 10px; color: var(--ink-500); padding: 2px 8px 0; }

.sp-type { display: grid; gap: 10px; }
.sp-t { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid var(--line-soft); }
.sp-t em { font-style: normal; font-size: var(--fs-11); color: var(--ink-400); }

.sp-tokens { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.tk { text-align: center; }
.tk i { display: block; height: 46px; background: var(--brand-050); border: 1px solid var(--brand-100); }
.tk b { display: block; font-size: var(--fs-12); margin-top: 7px; }
.tk span { font-size: 10px; color: var(--ink-500); }

.sp-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.sp-table th, .sp-table td {
  text-align: left; font-size: var(--fs-12); padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft); vertical-align: top; line-height: 1.65;
}
.sp-table th { background: var(--bg); color: var(--ink-600); font-weight: 600; }
.sp-table td:first-child { color: var(--ink-500); }
.sp-table tr:hover td { background: var(--brand-050); }
