/* ============================================================
   proto-panel.css — prototype-html skill 注釋面板樣式
   ============================================================ */

:root {
  --proto-panel-width: 25vw;
  --proto-panel-effective-width: clamp(280px, var(--proto-panel-width, calc(30vw - var(--sidebar-width, 240px) * 0.3)), 480px);
}

[hidden], [data-proto-local-control][hidden] {
  display: none !important;
}

/* ── 右側面板實體占位（不懸浮遮擋業務內容，而是實體佔用右側空間） ── */
body:not(.proto-disabled):not(.proto-panel-hidden) .app-main,
body:not(.proto-disabled):not(.proto-panel-hidden) .main-wrapper,
body:not(.proto-disabled):not(.proto-panel-hidden) .layout-container > .main-wrapper {
  margin-right: var(--proto-panel-effective-width, 320px) !important;
  transition: margin-right 0.3s ease;
}

body.proto-disabled .app-main,
body.proto-panel-hidden .app-main,
body.proto-disabled .main-wrapper,
body.proto-panel-hidden .main-wrapper,
body.proto-disabled .layout-container > .main-wrapper,
body.proto-panel-hidden .layout-container > .main-wrapper {
  margin-right: 0 !important;
}

/* ── 右側固定面板 ── */
#proto-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 200;
  width: var(--proto-panel-effective-width);
  height: 100vh;
  overflow-y: auto;
  background: #fffbeb;
  border-left: 2px dashed #f59e0b;
  box-shadow: -4px 0 24px rgba(245,158,11,0.12);
  transition: transform 0.3s ease, width 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: #f59e0b #fffbeb;
}

#proto-panel::-webkit-scrollbar { width: 4px; }
#proto-panel::-webkit-scrollbar-track { background: #fffbeb; }
#proto-panel::-webkit-scrollbar-thumb { background: #f59e0b; border-radius: 2px; }

#proto-panel.hidden {
  transform: translateX(100%);
}

/* ── 面板標題區 (與「原型設置」同在一行) ── */
.proto-panel-header {
  position: sticky;
  top: 0;
  z-index: 300;
  padding: 8px 12px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
}

.proto-panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.proto-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.proto-panel-badge .badge-label {
  padding: 2px 8px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.proto-panel-badge .badge-title {
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
}

.proto-panel-hint {
  font-size: 11px;
  color: #b45309;
  line-height: 1.5;
  margin: 0;
}

.proto-panel-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
}

/* ── 面板切換按鈕 ── */
#proto-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 201;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 64px;
  border: none;
  border-radius: 6px 0 0 6px;
  background: #f59e0b;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  box-shadow: -2px 0 8px rgba(245,158,11,0.25);
  transition: background 0.2s, right 0.3s;
}

#proto-toggle:hover {
  background: #d97706;
}

#proto-panel:not(.hidden) ~ #proto-toggle {
  right: var(--proto-panel-effective-width);
}

/* ── 說明卡片 ── */
.proto-desc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 16px;
}

.proto-desc {
  position: relative;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: #fffbeb;
  cursor: grab;
  transition: all 0.2s ease;
}

.proto-desc.dragging {
  cursor: grabbing;
  opacity: 0.72;
}

.proto-desc:hover,
.proto-desc.active-highlight {
  background: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(245,158,11,0.18);
}

.proto-desc.active-highlight {
  background: #fde68a;
  border-color: #d97706;
  box-shadow: 0 2px 8px rgba(245,158,11,0.28);
}

.proto-desc-inner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.proto-desc-num {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #f59e0b;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.proto-desc-body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px !important;
  line-height: 1.55 !important;
  color: #374151;
  word-break: break-word;
}

.proto-desc-body h3 {
  margin: 0 0 6px;
  font-size: 13px !important;
  font-weight: 700;
  color: #111827;
  line-height: 1.4;
}

.proto-desc-body p,
.proto-desc-body div,
.proto-desc-body span,
.proto-desc-body li {
  font-size: 12px !important;
  line-height: 1.55 !important;
  color: #4b5563;
}

.proto-desc-body p:last-child {
  margin-bottom: 0;
}

.proto-desc-body ol,
.proto-desc-body ul {
  margin: 4px 0 0;
  padding-left: 16px;
  font-size: 12px !important;
  color: #4b5563;
  line-height: 1.55 !important;
}

.proto-desc-body li + li {
  margin-top: 2px;
}

.proto-desc-body code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(120, 53, 15, 0.08);
  color: #92400e;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.proto-desc-body a {
  color: #b45309;
  text-decoration: underline;
}

/* ── 左側元素高亮已移除，保持頁面原生樣式 ── */

/* ── SVG 連線層 ── */
#proto-connections {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1010;
  overflow: visible;
}

.proto-conn-label-bg {
  fill: #f59e0b;
  transition: r 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.proto-conn-label-bg.active {
  r: 12px !important;
}

.proto-conn-label {
  fill: #fff;
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  font-family: inherit;
  pointer-events: none;
  transition: font-size 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.proto-conn-label-bg.active + .proto-conn-label {
  font-size: 13px;
}

.proto-inline-badge {
  position: fixed;
  z-index: 9999;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.proto-inline-badge.active {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.4);
}

.proto-breadcrumb-interaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  margin-left: 8px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  background: #8b5cf6 !important;
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(139, 92, 246, 0.3);
  transition: all 0.2s ease;
}

.proto-breadcrumb-interaction:hover,
.proto-breadcrumb-interaction.active {
  background: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4);
}

/* ── 為頁面內容騰出右側空間，避免被面板遮擋 ── */
.page-content {
  padding-right: calc(var(--proto-panel-effective-width) + 16px) !important;
  transition: padding-right 0.3s ease;
}

#proto-panel.hidden ~ * .page-content,
body:has(#proto-panel.hidden) .page-content {
  padding-right: 32px !important;
}

/* ── 移動端：隱藏 proto 面板 ── */
@media (max-width: 1024px) {
  #proto-panel,
  #proto-toggle,
  #proto-connections,
  #proto-settings-container {
    display: none !important;
  }
  .page-content {
    padding-right: 16px !important;
  }
}

/* ── 左下角原型說明控制開關 (改為原型設置面版) ── */
#proto-settings-container {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 8px;
}

#proto-settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #fcd34d;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.15);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

#proto-settings-toggle:hover {
  background: #fffbeb;
  border-color: #f59e0b;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.22);
}

#proto-settings-toggle.active {
  background: #f59e0b;
  border-color: #d97706;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

#proto-settings-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 320;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#proto-settings-panel.hidden {
  display: none !important;
}

.proto-settings-header {
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.proto-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.proto-settings-row.pct-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.proto-settings-label-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.proto-settings-label {
  font-weight: 600;
  color: #475569;
}

#proto-pct-value {
  font-weight: 700;
  color: #f59e0b;
  font-size: 13px;
}

#proto-pct-range {
  width: 100%;
  accent-color: #f59e0b;
  cursor: pointer;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
  margin: 4px 0;
}

.proto-pct-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #94a3b8;
  margin-top: -2px;
}

.proto-switch-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
}

.proto-switch-slider {
  position: relative;
  width: 28px;
  height: 16px;
  background: #cbd5e1;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.proto-switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.proto-switch-btn.active .proto-switch-slider {
  background: #f59e0b;
}

.proto-switch-btn.active .proto-switch-slider::after {
  transform: translateX(12px);
}

.collapsed #proto-settings-container,
#appShell.collapsed ~ #proto-settings-container {
  right: 12px;
}

.collapsed #proto-settings-toggle,
#appShell.collapsed ~ #proto-settings-container #proto-settings-toggle {
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  justify-content: center;
}

.collapsed #proto-settings-toggle span,
#appShell.collapsed ~ #proto-settings-container #proto-settings-toggle span {
  display: none;
}

/* 當說明關閉時，隱藏面板與連線 */
body.proto-disabled #proto-panel,
body.proto-disabled #proto-toggle,
body.proto-disabled #proto-connections {
  display: none !important;
}

body.proto-disabled .page-content {
  padding-right: 16px !important;
}

/* ── 當處於 (副) 彈窗子頁面時，工作區分佈：左側彈窗佔 70%，右側說明面板佔 30% ── */
body.sub-page-mode .page-content {
  display: none !important;
}

body.sub-page-mode .modal-layer {
  left: var(--sidebar-width, 240px) !important;
  top: 52px !important;
  width: calc(100vw - var(--sidebar-width, 240px) - var(--proto-panel-effective-width)) !important;
  height: calc(100vh - 52px) !important;
  padding: 16px !important;
  overflow: auto !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border-right: 1px solid #e2e8f0;
  container-type: inline-size;
  container-name: sub-modal;
}

body.sub-page-mode #proto-panel {
  top: 0 !important;
  width: var(--proto-panel-effective-width) !important;
  height: 100vh !important;
  border-left: 2px dashed #f59e0b;
  transform: none !important; /* 強制顯示面板，不受折疊隱藏狀態限制 */
}

/* ── 當處於內嵌模板模式時（無頂部導覽列），面板佔滿整個高度 ── */
body.is-embedded-template #proto-panel {
  top: 0 !important;
  height: 100vh !important;
}

/* 在彈窗子頁面中，固定分欄顯示，因此不需要右側折疊拉手 */
body.sub-page-mode #proto-toggle {
  display: none !important;
}

/* 當處於 (副) 彈窗子頁面且原型說明關閉時，彈窗寬度自動擴展到 100% */
body.proto-disabled.sub-page-mode .modal-layer {
  width: calc(100vw - var(--sidebar-width, 240px)) !important;
}

/* ── 多顏色主題連線與標註支持 ── */

/* Theme 1: Amber/Orange */
.proto-conn-label-bg.proto-color-1 { fill: #f59e0b; }
.proto-inline-badge.proto-color-1 { background: #f59e0b; }
.proto-desc.proto-color-1 .proto-desc-num { background-color: #f59e0b; }
.proto-desc.proto-color-1:hover {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
}
.proto-desc.proto-color-1.active-highlight {
  background: #fde68a !important;
  border-color: #d97706 !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.18) !important;
}

/* Theme 2: Emerald/Green */
.proto-conn-label-bg.proto-color-2 { fill: #10b981; }
.proto-inline-badge.proto-color-2 { background: #10b981; }
.proto-desc.proto-color-2 .proto-desc-num { background-color: #10b981; }
.proto-desc.proto-color-2:hover {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
}
.proto-desc.proto-color-2.active-highlight {
  background: #d1fae5 !important;
  border-color: #059669 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.18) !important;
}

/* Theme 3: Blue/Azure */
.proto-conn-label-bg.proto-color-3 { fill: #3b82f6; }
.proto-inline-badge.proto-color-3 { background: #3b82f6; }
.proto-desc.proto-color-3 .proto-desc-num { background-color: #3b82f6; }
.proto-desc.proto-color-3:hover {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
}
.proto-desc.proto-color-3.active-highlight {
  background: #dbeafe !important;
  border-color: #2563eb !important;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.18) !important;
}

/* Theme 4: Purple/Amethyst */
.proto-conn-label-bg.proto-color-4 { fill: #8b5cf6; }
.proto-inline-badge.proto-color-4 { background: #8b5cf6; }
.proto-desc.proto-color-4 .proto-desc-num { background-color: #8b5cf6; }
.proto-desc.proto-color-4:hover {
  background: #f5f3ff !important;
  border-color: #8b5cf6 !important;
}
.proto-desc.proto-color-4.active-highlight {
  background: #ede9fe !important;
  border-color: #7c3aed !important;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.18) !important;
}

/* Theme 5: Rose/Red */
.proto-conn-label-bg.proto-color-5 { fill: #ef4444; }
.proto-inline-badge.proto-color-5 { background: #ef4444 !important; color: #ffffff !important; }
.proto-desc.proto-color-5 .proto-desc-num { background-color: #ef4444 !important; color: #ffffff !important; }
.proto-desc.proto-color-5:hover { background: #fef2f2 !important; border-color: #ef4444 !important; }
.proto-desc.proto-color-5.active-highlight { background: #fee2e2 !important; border-color: #dc2626 !important; box-shadow: 0 4px 14px rgba(239, 68, 68, 0.18) !important; }

/* Theme 6: Cyan/Teal */
.proto-conn-label-bg.proto-color-6 { fill: #06b6d4; }
.proto-inline-badge.proto-color-6 { background: #06b6d4 !important; color: #ffffff !important; }
.proto-desc.proto-color-6 .proto-desc-num { background-color: #06b6d4 !important; color: #ffffff !important; }
.proto-desc.proto-color-6:hover { background: #ecfeff !important; border-color: #06b6d4 !important; }
.proto-desc.proto-color-6.active-highlight { background: #cffafe !important; border-color: #0891b2 !important; box-shadow: 0 4px 14px rgba(6, 182, 212, 0.18) !important; }

/* Theme 7: Slate */
.proto-conn-label-bg.proto-color-7 { fill: #64748b; }
.proto-inline-badge.proto-color-7 { background: #64748b !important; color: #ffffff !important; }
.proto-desc.proto-color-7 .proto-desc-num { background-color: #64748b !important; color: #ffffff !important; }
.proto-desc.proto-color-7:hover { background: #f1f5f9 !important; border-color: #64748b !important; }
.proto-desc.proto-color-7.active-highlight { background: #e2e8f0 !important; border-color: #475569 !important; box-shadow: 0 4px 14px rgba(100, 116, 139, 0.18) !important; }

/* ── 可視化編輯模式 ── */
.proto-authoring-hover {
  outline: 2px dashed #3b82f6 !important;
  outline-offset: 2px !important;
  cursor: crosshair !important;
  background-color: rgba(59, 130, 246, 0.08) !important;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2) !important;
}

.proto-authoring-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10010;
  transition: opacity 0.25s ease;
}

.proto-authoring-modal.hidden {
  display: none !important;
}

/* ── 確認彈窗（刪除、放棄修改） ── */
.proto-confirm-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10020;
}

.proto-confirm-modal.hidden {
  display: none !important;
}

.proto-confirm-card {
  width: min(400px, 100%);
  padding: 20px;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.06);
  animation: protoModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.proto-confirm-title {
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
}

.proto-confirm-message {
  margin: 10px 0 20px;
  color: #475569;
  font-size: 13px;
  line-height: 1.6;
}

.proto-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.proto-confirm-footer .auth-btn.danger {
  margin-right: 0;
}

.proto-authoring-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 800px;
  max-width: 95%;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  animation: protoModalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes protoModalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.proto-authoring-header {
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.proto-authoring-body {
  padding: 20px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
}

.proto-authoring-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proto-authoring-field label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-align: left;
}

.proto-authoring-field input[type="text"],
.proto-authoring-field textarea {
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  background-color: #ffffff;
  color: #0f172a;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  width: 100%;
}

.proto-authoring-field textarea {
  min-height: 180px;
  resize: vertical;
}

.proto-authoring-field input[type="text"]:disabled {
  background-color: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.proto-authoring-field input[type="text"]:focus:not(:disabled),
.proto-authoring-field textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.proto-auth-colors {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 4px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.color-chip input[type="radio"] {
  accent-color: #f59e0b;
  margin: 0;
  cursor: pointer;
}

.proto-authoring-footer {
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
}

.proto-authoring-save-status {
  flex: 1;
  min-width: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.3;
}

.proto-authoring-save-status.is-error {
  color: #dc2626;
}

/* ── 按鈕通用樣式 ── */
.auth-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  transition: all 0.2s ease;
  font-family: inherit;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.auth-btn.primary {
  background: #f59e0b;
  border-color: #d97706;
  color: #ffffff;
}

.auth-btn.primary:hover {
  background: #d97706;
  border-color: #b45309;
}

.auth-btn.danger {
  background: #ef4444;
  border-color: #dc2626;
  color: #ffffff;
  margin-right: auto; /* 靠左排列 */
}

.auth-btn.danger:hover {
  background: #dc2626;
  border-color: #b91c1c;
}

.proto-settings-row.export-row {
  display: flex;
}

.proto-settings-row.export-row .auth-btn {
  width: 100%;
  height: 32px;
}

/* ── 九宮格位置選擇器 (Word 樣式) ── */
.proto-pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 120px;
  margin-top: 4px;
}

.pos-cell {
  aspect-ratio: 1;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  height: 32px;
  width: 32px;
  box-sizing: border-box;
}

.pos-cell:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.pos-cell.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #d97706;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.proto-settings-divider {
  height: 1px;
  background-color: #e2e8f0;
  margin: 10px 0;
  border: none;
}

/* ── 說明卡片編輯與刪除按鈕 ── */
.proto-desc-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
}

.proto-desc:hover .proto-desc-actions {
  opacity: 1;
}

.proto-panel-readonly .proto-desc-actions {
  display: none !important;
}

.proto-action-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #cbd5e1;
  padding: 4px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.proto-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.proto-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.proto-action-btn:disabled:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: #cbd5e1;
  color: #64748b;
  transform: none;
}

.proto-action-btn.delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}

/* 避免 actions 被文字覆蓋或影響滑鼠事件 */
.proto-desc-inner {
  padding-right: 92px; /* 保留足夠空間給右上角移動、編輯與刪除按鈕 */
}

.proto-switch-btn:disabled, .proto-switch-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── 富文本編輯器 (Rich Text Editor) ── */
.proto-rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 8px;
}

.proto-rich-toolbar .rich-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-weight: 500;
}

.proto-rich-toolbar .rich-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.proto-rich-toolbar .rich-btn:active {
  transform: scale(0.95);
}

.proto-rich-toolbar .rich-divider {
  width: 1px;
  height: 16px;
  background: #cbd5e1;
  margin: 0 4px;
}

.proto-rich-contenteditor {
  min-height: 130px;
  max-height: 260px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0 0 6px 6px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.proto-rich-contenteditor:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.proto-rich-contenteditor[placeholder]:empty:before {
  content: attr(placeholder);
  color: #94a3b8;
}

/* 面板內富文本卡片內容渲染樣式 */
.proto-desc-body p {
  margin: 4px 0;
  line-height: 1.6;
}
.proto-desc-body ul, .proto-desc-body ol {
  margin: 6px 0;
  padding-left: 20px;
}
.proto-desc-body li {
  margin: 2px 0;
}
.proto-desc-body b, .proto-desc-body strong {
  font-weight: 700;
}
.proto-desc-body i, .proto-desc-body em {
  font-style: italic;
}
.proto-desc-body img,
.proto-rich-contenteditor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 6px 0;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: block;
}
