/* ============================================================
   外殼 SaaS 化（2026-10-22）：參考 Untitled UI 元件語彙，主色 DR.WU 紅。
   只蓋外殼（頂欄／左側選單／舞台底／右側面板＋模式切換），
   手機畫面內的線框不受影響。載入順序在 device.css 之後，靠覆寫生效。
   ============================================================ */

:root {
  --test-panel-width: 380px;
  --sidemenu-width: 288px;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);
  --ring-brand: 0 0 0 4px rgba(227, 28, 35, 0.12);
  --radius-xl: 12px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- 頂欄 ---------- */
.topbar {
  height: 60px;
  padding: 0 16px;
  gap: 12px;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}
.topbar__brand {
  font-size: 15px;
  gap: 10px;
}
.topbar__mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(180deg, #f04438 0%, #c4161c 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 1px 2px rgba(180, 35, 24, 0.35);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.version-bar {
  margin-left: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--gray-200);
  height: 28px;
}
.version-bar__select {
  height: 36px;
  min-width: 156px;
  font-weight: 500;
  border-radius: var(--radius-lg);
}

/* 次要按鈕（頁面／工程標註開關） */
.sidemenu-toggle {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-color: var(--gray-300);
  box-shadow: var(--shadow-xs);
}
.sidemenu-toggle svg {
  width: 18px;
  height: 18px;
}

/* 模式切換：Untitled UI button group（分段控制） */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: var(--gray-50);
}
.mode-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--gray-500);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.mode-switch__btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mode-switch__btn:hover {
  color: var(--gray-700);
}
.mode-switch__btn.is-active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: var(--shadow-sm);
}
.mode-switch__btn.is-active svg {
  color: var(--brand-600);
}
.mode-switch__btn:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 1px;
}

/* ---------- 左側選單 ---------- */
.sidemenu {
  padding: 12px 12px 24px;
  background: #fff;
}
.sidemenu__area {
  margin-bottom: 2px;
}
.sidemenu__area > summary,
.sidemenu__flow > summary {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
}
.sidemenu__area-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}
.sidemenu__flow {
  padding-left: 6px;
  margin-bottom: 2px;
}
.sidemenu__flow-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}
.sidemenu__item {
  position: relative;
  min-height: 34px;
  padding: 6px 8px 6px 26px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  gap: 8px;
}
/* 狀態頁碼縮排在主頁面底下 */
.sidemenu__item--state {
  padding-left: 46px;
  min-height: 30px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--gray-600);
}
.sidemenu__item--state .sidemenu__code {
  min-width: 52px;
  font-size: 10.5px;
  background: transparent;
  border: 1px solid var(--gray-200);
}
.sidemenu__item--state.is-active .sidemenu__code {
  border-color: var(--brand-200);
}
.sidemenu__item[hidden] {
  display: none;
}
.sidemenu__code {
  flex: none;
  min-width: 44px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}
.sidemenu__item:hover .sidemenu__code {
  background: var(--gray-200);
}
.sidemenu__item.is-active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.sidemenu__item.is-active .sidemenu__code {
  background: var(--brand-100);
  color: var(--brand-700);
}
.sidemenu__item--pin {
  padding-left: 8px;
  font-weight: 500;
}
.sidemenu__tag {
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 500;
  line-height: 16px;
}
.sidemenu__divider {
  margin: 8px 4px 10px;
}

/* ---------- 舞台：淡點陣畫布 ---------- */
.stage {
  background-color: var(--gray-50);
  background-image: radial-gradient(circle, var(--gray-200) 1px, transparent 1.2px);
  background-size: 18px 18px;
}
.layout--doc .stage {
  background-image: none;
}
.is-mode-notes .stage {
  background-color: #fbf7f7;
}

/* ---------- 右側面板 ---------- */
.test-panel {
  padding: 20px 20px 32px;
  background: #fff;
}
.test-panel__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.test-panel__block + .test-panel__block {
  padding-top: 20px;
  margin-top: 4px;
}
.test-panel__block-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gray-500);
}
.test-panel__list > li {
  padding: 14px;
  border-radius: var(--radius-xl);
  background: #fff;
  border-color: var(--gray-200);
  gap: 6px;
}
.test-panel__logic-link {
  display: inline-flex;
  width: auto;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid #b2ddff;
  background: #eff8ff;
  color: #175cd3;
  font-size: 12px;
}
.test-panel__logic-link::after {
  content: "→";
  font-weight: 500;
}
.test-panel__api-link {
  color: #175cd3;
  text-decoration-color: rgba(23, 92, 211, 0.35);
}
.test-panel__all-rules {
  color: var(--brand-700);
  text-decoration: none;
}
.test-panel__all-rules:hover {
  text-decoration: underline;
}

/* 四區標題改 Untitled badge（顏色區分類別） */
.test-panel__item-title[data-section] {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
.test-panel__item-title[data-section]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.test-panel__item-title[data-section="前端驗證"] { border-color: #b2ddff; background: #eff8ff; color: #175cd3; }
.test-panel__item-title[data-section="前端互動"] { border-color: #d9d6fe; background: #f4f3ff; color: #5925dc; }
.test-panel__item-title[data-section="顯示規則"] { border-color: #fedf89; background: #fffaeb; color: #b54708; }
.test-panel__item-title[data-section^="API"] { border-color: #abefc6; background: #ecfdf3; color: #067647; }

/* ---------- 資訊備註模式（notes-mode.js） ---------- */
.notes-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
}
.notes-head__code {
  padding: 0 8px;
  border-radius: 6px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 22px;
}
.notes-head__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gray-900);
}
.notes-tip {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--gray-500);
}
.notes-tip--warn {
  padding: 10px 12px;
  border: 1px solid #fedf89;
  border-radius: var(--radius-lg);
  background: #fffcf5;
  color: #b54708;
}
.notes-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.notes-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-xs);
  color: var(--gray-700);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.notes-chip:hover {
  border-color: var(--brand-300);
  color: var(--brand-700);
  box-shadow: var(--ring-brand);
}
.notes-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gray-600);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.notes-back:hover {
  color: var(--gray-900);
}
.notes-region {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-xl);
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
}
.notes-region__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-800);
}
.notes-region__count {
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--brand-200);
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}
.notes-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.notes-fields__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}
.notes-fields .test-panel__logic-list {
  flex-direction: row;
  flex-wrap: wrap;
}
.notes-state {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.notes-state.is-on-screen {
  border-color: var(--brand-300);
  box-shadow: var(--ring-brand);
}
.notes-state__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.notes-state__title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.notes-state__index {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}
.is-on-screen .notes-state__index {
  background: var(--brand-600);
  color: #fff;
}
.notes-state__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: var(--gray-900);
}
.notes-state__code {
  margin: 4px 0 0 28px;
  font-size: 12px;
  color: var(--gray-500);
}
.notes-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
.notes-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-600);
}
.notes-state__summary {
  margin: -14px;
  padding: 14px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  outline: none;
}
.notes-state__summary:hover {
  background: var(--gray-50);
}
.notes-state.is-on-screen .notes-state__summary {
  cursor: default;
}
.notes-state.is-on-screen .notes-state__summary:hover {
  background: transparent;
}
.notes-state__summary:focus-visible {
  box-shadow: var(--ring-brand);
}
.notes-state.is-expanded .notes-state__summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.notes-state__side {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notes-chevron {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
}
.notes-chevron:hover {
  border-color: var(--gray-300);
  background: #fff;
  color: var(--gray-900);
}
.notes-chevron svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}
.notes-state.is-expanded .notes-chevron svg {
  transform: rotate(90deg);
}
.notes-state-tools {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: -4px 0 8px;
}
.notes-state-tools__btn {
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-600);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.notes-state-tools__btn:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}
.notes-state__body {
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--gray-100);
}
/* 狀態卡內的四區與測試值攤平，不再一層一層包框 */
.notes-state__body .test-panel__list,
.notes-block .test-panel__list {
  gap: 14px;
}
.notes-state__body .test-panel__list > li,
.notes-block .test-panel__list > li {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
.notes-sub {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}
.notes-state__body .test-panel__list + .notes-sub {
  padding-top: 12px;
  border-top: 1px dashed var(--gray-200);
}
.notes-state__body .notes-sub + .test-panel__list > li {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--gray-50);
}
.notes-state__body .notes-sub:first-child {
  margin-top: 0;
}

/* 資訊備註模式：右側面板一律展開，不顯示「工程標註」開關 */
.is-mode-notes #test-panel-toggle {
  display: none !important;
}
