/* ============================================================
   實體裝置外框（老闆本次特殊要求）：
   Mobile 頁面包 iPhone 直向 mockup。
   外框本身純裝飾用途，不影響內頁灰階內容；一律灰階配色。
   （2026-09-14 PM 指示本次僅展示 App／手機版，PAD 版 mockup 與裝置
   切換 UI 已移除；PAD 靜態線框稿本身不受影響，見 README 說明。）
   ============================================================ */

:root {
  /* 裝置外框（中間 mockup 機身，與 Untitled 外殼分開） */
  --shell-color: #1c1c1e;
  --shell-edge: #050506;

  /* Untitled UI 灰階（neutral） */
  --gray-25: #fcfcfd;
  --gray-50: #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #eaecf0;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #101828;

  /* Untitled UI brand scale，主色改 DR.WU 紅（小紅瓶／識別紅） */
  --brand-25: #fffbfa;
  --brand-50: #fef3f2;
  --brand-100: #fee4e2;
  --brand-200: #fecdca;
  --brand-300: #fda29b;
  --brand-500: #f04438;
  --brand-600: #e31c23;
  --brand-700: #b42318;
  --brand-800: #912018;

  --bg: var(--gray-50);
  --panel: #ffffff;
  --ink: var(--gray-900);
  --ink-soft: var(--gray-600);
  --accent: var(--brand-600);
  --line: var(--gray-200);
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);

  /* 側欄固定寬。收合只滑動整片面板，不拿這兩個值去擠壓內部文字。 */
  --sidemenu-width: 320px;
  --test-panel-width: 300px;
  --panel-slide: 0.22s ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    "PingFang TC",
    "Noto Sans TC",
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  /* 鎖死等於視窗高度（不是 min-height）：.stage 的 flex:1 才能量到
     「視窗扣掉頂部列後剩下的真實空間」，而不是被內容自然撐開之後的假高度——
     這正是先前 mockup 在矮視窗下被裁切的根因：body 用 min-height 允許長得
     比視窗高，.stage 量到的可用高度因此偏大，算出的縮放比例跟著失準。 */
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- 頂部列：品牌名 ＋ sidemenu 收合／展開按鈕 ----
   A/B/C 流程切換已改由左側 sidemenu 承擔（sidemenu 展開時照三條流程分組
   列出所有頁面，本身就是更完整的導覽，不需要再疊一套按鈕列跟它打架）。 */
.topbar {
  flex: none;
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.topbar__mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  background: var(--brand-600);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.topbar__spacer {
  flex: 1;
}

.sidemenu-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  border: 1px solid var(--gray-300);
  background: #fff;
  padding: 0 14px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}
.sidemenu-toggle:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}
.sidemenu-toggle:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}
.sidemenu-toggle[hidden] {
  display: none !important;
}
.sidemenu-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.sidemenu-toggle__icon--close {
  display: none;
}
.sidemenu-toggle[aria-expanded="true"] .sidemenu-toggle__icon--open {
  display: none;
}
.sidemenu-toggle[aria-expanded="true"] .sidemenu-toggle__icon--close {
  display: block;
}
.sidemenu-toggle--trail .sidemenu-toggle__icon--open {
  display: none;
}

/* ---- 三欄版面：sidemenu ／ stage ／ test-panel ----
   收合＝整片面板滑出（translateX），不是把欄內文字當 flex/autolayout
   擠窄。slot 裁切＋grid 欄寬同步歸零，中欄 .stage 補位；JS 在過渡期間
   重算 iPhone 縮放（fitActiveFrameDuringTransition）。 */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidemenu-width) 1fr var(--test-panel-width);
  transition: grid-template-columns var(--panel-slide);
  overflow: hidden;
}
.layout.sidemenu-collapsed {
  grid-template-columns: 0px 1fr var(--test-panel-width);
}
.layout.test-panel-collapsed {
  grid-template-columns: var(--sidemenu-width) 1fr 0px;
}
.layout.sidemenu-collapsed.test-panel-collapsed {
  grid-template-columns: 0px 1fr 0px;
}

.sidemenu-slot,
.test-panel-slot {
  min-width: 0;
  overflow: hidden;
}

/* ---- 左側 sidemenu：功能大項可展開，項目由登錄表產生 ---- */
.sidemenu {
  box-sizing: border-box;
  width: var(--sidemenu-width);
  min-width: var(--sidemenu-width);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  transform: translateX(0);
  transition: transform var(--panel-slide);
}
.layout.sidemenu-collapsed .sidemenu {
  transform: translateX(-100%);
  pointer-events: none;
}
.sidemenu__area {
  margin-bottom: 4px;
}
.sidemenu__area > summary,
.sidemenu__flow > summary {
  cursor: pointer;
  list-style: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: var(--gray-700);
  user-select: none;
  transition: background 0.1s ease, color 0.1s ease;
}
.sidemenu__area > summary:hover,
.sidemenu__flow > summary:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}
.sidemenu__area > summary::-webkit-details-marker,
.sidemenu__flow > summary::-webkit-details-marker {
  display: none;
}
.sidemenu__chevron {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--gray-400);
  transition: transform 0.15s ease;
}
.sidemenu__area > summary .sidemenu__chevron,
.sidemenu__flow > summary .sidemenu__chevron {
  transform: rotate(-90deg);
}
.sidemenu__area[open] > summary .sidemenu__chevron,
.sidemenu__flow[open] > summary .sidemenu__chevron {
  transform: rotate(0deg);
}
.sidemenu__area-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}
.sidemenu__area.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.sidemenu__area.is-disabled > .sidemenu__area-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: var(--gray-500);
  cursor: default;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
}
.sidemenu__area.is-disabled > summary {
  cursor: default;
  color: var(--gray-500);
}
.sidemenu__area.is-disabled > summary .sidemenu__chevron {
  visibility: hidden;
}
.sidemenu__tag {
  margin-left: auto;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 18px;
}
.sidemenu__flow {
  margin: 0 0 4px;
  padding-left: 8px;
}
.sidemenu__flow-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: 0.02em;
}
.sidemenu__empty {
  margin: 0;
  padding: 6px 8px 10px 28px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-500);
}
.sidemenu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  min-height: 36px;
  padding: 6px 8px 6px 28px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--gray-700);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.1s ease, color 0.1s ease;
}
.sidemenu__item:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}
.sidemenu__item:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}
.sidemenu__item.is-unplanned {
  opacity: 0.55;
  cursor: default;
  color: var(--gray-500);
}
.sidemenu__item.is-unplanned:hover {
  background: none;
  color: var(--gray-500);
}
.sidemenu__item .sidemenu__tag {
  margin-left: auto;
}
.sidemenu__code {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--gray-500);
  flex: none;
}
.sidemenu__item.is-active {
  background: var(--brand-50);
  color: var(--brand-800);
  font-weight: 600;
}
.sidemenu__item.is-active:hover {
  background: var(--brand-100);
  color: var(--brand-800);
}
.sidemenu__item--pin {
  padding-left: 8px;
  font-weight: 600;
  color: var(--gray-900);
}
.sidemenu__divider {
  border: none;
  height: 1px;
  margin: 8px 8px 12px;
  background: var(--line);
}

/* ---- 舞台：置中顯示裝置外框 ----
   .layout 用 grid 卡住三欄寬度，.stage 拿到的就是中欄剩餘空間；裝置外框
   再用 JS 依這個空間動態縮放，確保預設載入與每次切換（含 sidemenu 收合
   展開）都完整落在可視範圍內，不必捲動。
   ⚠️ 縮放技術決策已翻案（2026-09-14）：現在用 `transform: scale()`，
   不用 CSS `zoom`。原本選 `zoom` 是為了解決 transform 讓自動化點擊工具
   （CDP／Puppeteer／Playwright）算不準 iframe 內部座標的已知限制，但
   2026-09-14 老闆複驗發現：`zoom`（非 1 的縮放比例）會讓瀏覽器對
   「zoom 容器內的 iframe」回報不一致的尺寸——`getComputedStyle` 讀到縮放
   前的邏輯尺寸、`getBoundingClientRect` 讀到縮放後的視覺尺寸——這個不一致
   會讓 iframe 內部所有互動元件的點擊命中判定系統性偏移，**真人滑鼠點擊
   也會點不準**（不是只有自動化工具的問題）。已用 `elementFromPoint()`
   驗證 `transform: scale()` 下外層瀏覽器原生 hit-test 完全準確。改回
   transform 後，複測方式對應調整為 `fill()`＋`press_key('Enter')`
   （不經過座標點擊换算），細節見 index.html 的 fitActiveFrame() 註解。 */
.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.stage__panel {
  display: none;
}
.stage__panel.is-active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-zoom {
  flex: none;
}

/* ============================================================
   iPhone 直向外框
   內視窗 375×812（與線框原始尺寸一致，不縮放走樣）
   ============================================================ */
.iphone {
  --frame-pad: 14px;
  width: calc(375px + var(--frame-pad) * 2);
  height: calc(812px + var(--frame-pad) * 2);
  background: linear-gradient(160deg, #2b2b2d, var(--shell-color) 40%, var(--shell-edge));
  border-radius: 56px;
  padding: var(--frame-pad);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.04) inset;
  position: relative;
}
.iphone::before {
  /* 側邊按鍵線條（簡化示意） */
  content: "";
  position: absolute;
  left: -3px;
  top: 130px;
  width: 3px;
  height: 32px;
  background: #3a3a3c;
  border-radius: 2px 0 0 2px;
}
.iphone::after {
  content: "";
  position: absolute;
  left: -3px;
  top: 178px;
  width: 3px;
  height: 64px;
  background: #3a3a3c;
  border-radius: 2px 0 0 2px;
  box-shadow: 0 78px 0 #3a3a3c;
}
.iphone__screen {
  width: 375px;
  height: 812px;
  border-radius: 42px;
  overflow: hidden;
  background: #000;
  position: relative;
}
.iphone__screen iframe {
  width: 375px;
  height: 812px;
  border: none;
  display: block;
  background: #fff;
}

/* 文件頁（欄位驗證規則）：拿掉手機外框，中欄改成整頁文件 */
.layout--doc .stage {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
.layout--doc .stage__panel.is-active {
  display: block;
  width: 100%;
  height: 100%;
}
.layout--doc .device-zoom {
  width: 100%;
  height: 100%;
}
.layout--doc .iphone {
  width: 100%;
  height: 100%;
  background: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.layout--doc .iphone::before,
.layout--doc .iphone::after {
  display: none;
}
.layout--doc .iphone__screen,
.layout--doc .iphone__screen iframe {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #fff;
}
/* 動態島刻意不在外框層另外畫：每個內頁本身的 .statusbar__island
   （見 shared.css）已經畫了忠於線框稿的動態島（180×35px）。外框層
   若再疊一個 .iphone__notch（先前是 96×26px），兩層尺寸、位置都不
   對齊，會變成老闆截圖抓到的「瀏海與動態島重疊、邊緣沒對齊」的瑕疵。
   外殼只留機身本體，動態島完全交給內頁畫，兩者合起來剛好是一層乾淨
   的形狀。（2026-09-14 老闆截圖回饋修正） */

/* iPad 橫向外框樣式已移除（2026-09-14 PM 指示本次僅展示 Mobile 版）。
   PAD 靜態線框稿本身不受影響，仍在 .worktrees/chat-redesign/canvas/
   底下唯讀保留；本檔只是拿掉這個互動原型專案裡的 iPad mockup 外殼。 */

/* ============================================================
   右側測試值對照表：老闆要求把「填什麼值會觸發哪個分支」的提示
   移到 mockup 畫布外面，不再寫進畫面內容本身（2026-09-14 修正）。
   ============================================================ */
.test-panel {
  box-sizing: border-box;
  width: var(--test-panel-width);
  min-width: var(--test-panel-width);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 20px 16px;
  transform: translateX(0);
  transition: transform var(--panel-slide);
}
.layout.test-panel-collapsed .test-panel {
  transform: translateX(100%);
  pointer-events: none;
}
.test-panel__kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}
.test-panel__title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--gray-900);
}
.test-panel__block {
  margin: 0;
  padding: 0 0 16px;
}
.test-panel__block + .test-panel__block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 4px;
}
.test-panel__block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}
.test-panel__block-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}
.test-panel__block-head .test-panel__block-title {
  margin: 0;
}
.test-panel__all-rules {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700);
  cursor: pointer;
  text-decoration: underline;
}
.test-panel__logic-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.test-panel__logic-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--gray-200);
  background: #eff8ff;
  color: #175cd3;
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.test-panel__logic-link:hover {
  background: #d1e9ff;
}
.test-panel__page {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-700);
}
.test-panel__hint {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-600);
}
.test-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.test-panel__list > li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--gray-25);
  box-shadow: var(--shadow-xs);
  font-size: 13px;
  line-height: 1.5;
}
.test-panel__item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gray-900);
}
.test-panel__inputs-label {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}
.test-panel__inputs {
  margin: 0;
  padding: 0 0 0 1.15em;
  list-style: disc;
  color: var(--gray-700);
}
.test-panel__inputs li {
  display: list-item;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  font-size: 13px;
  line-height: 1.5;
}
.test-panel__arrow {
  display: none;
}
.test-panel__result {
  margin: 4px 0 0;
  color: var(--gray-700);
}
.test-panel__result-label {
  font-weight: 600;
  color: var(--gray-900);
}
.test-panel__empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-500);
}
.test-panel__empty-inline {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--gray-500);
}
.test-panel__feature-list {
  margin: 4px 0 0;
  padding: 0 0 0 1.15em;
  list-style: disc;
  color: var(--gray-700);
}
.test-panel__feature-list li {
  display: list-item;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  font-size: 13px;
  line-height: 1.5;
}
.test-panel__feature-body {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-700);
}

/* ---- 灰置裝飾按鈕的 tooltip ---- */
[data-decor] {
  position: relative;
}
[data-decor]:hover::after {
  content: attr(data-decor);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1e;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}

/* 三欄欄寬由 .layout 的 grid-template-columns 卡死；收合時 slot 歸零、
   內層面板仍是固定寬並整片滑出。舞台縮放交給 JS，不需要額外斷點。 */
