:root {
  --bg-page: #F2F3F5;
  --bg-canvas: #FAF8F5;
  --bg-card: #FFFFFF;
  --border-warm: #ECE8E1;
  --border-green: #B7E4C7;
  --border-light: #E5E7EB;
  --text-main: #111827;
  --text-body: #374151;
  --text-muted: #6B7280;
  --amber-500: #F59E0B;
  --amber-600: #D97706;
  --amber-700: #B85B06;
  --green-700: #1B6B46;
  --green-soft: #F4FBF6;
  --ledger-dark: #23180D;
  --danger: #DC2626;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* 真实企微侧边栏模式：去掉调试栏与模拟群聊，侧边栏 100% 铺满 */
body.is-wecom-env {
  background: var(--bg-canvas);
}
body.is-wecom-env .dev-bar,
body.is-wecom-env .mock-chat-pane {
  display: none !important;
}
body.is-wecom-env .workspace-stage {
  padding: 0;
  max-width: 100%;
  display: block;
}
body.is-wecom-env .wecom-sidebar {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

/* 桌面调试顶栏 */
.dev-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  padding: 10px 20px;
}
.dev-bar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dev-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dev-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #F59E0B, #B85B06);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.dev-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}
.dev-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}
.dev-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.scene-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.scene-pill {
  border: 1px solid var(--border-light);
  background: #F9FAFB;
  color: var(--text-body);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.scene-pill:hover {
  border-color: var(--amber-600);
  color: var(--amber-700);
}
.scene-pill.active {
  background: var(--ledger-dark);
  border-color: var(--ledger-dark);
  color: #FDE68A;
  font-weight: 600;
}

/* 主舞台 */
.workspace-stage {
  max-width: 1060px;
  margin: 18px auto 32px;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
}

/* 左侧模拟企微群聊 */
.mock-chat-pane {
  flex: 1;
  min-width: 320px;
  background: #FFFFFF;
  border-radius: 14px;
  border: 1px solid #E2E5EB;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  height: 760px;
  overflow: hidden;
}
.mock-chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.mock-chat-title {
  font-size: 14px;
  font-weight: 700;
}
.mock-chat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.mock-chat-list {
  flex: 1;
  background: #F5F6F8;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-item {
  display: flex;
  flex-direction: column;
}
.chat-item.staff {
  align-items: flex-end;
}
.chat-meta {
  font-size: 11px;
  color: #9CA3AF;
  margin-bottom: 4px;
}
.chat-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 11px;
  line-height: 1.55;
  font-size: 12.5px;
  white-space: pre-line;
  word-break: break-word;
}
.chat-item.customer .chat-bubble {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-top-left-radius: 3px;
}
.chat-item.staff .chat-bubble {
  background: #D9EBFF;
  color: #111827;
  border-top-right-radius: 3px;
}
.mock-chat-input {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  background: #FFFFFF;
}
.mock-chat-input input {
  flex: 1;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
}
.mock-chat-input input:focus {
  border-color: var(--amber-600);
}

/* 企微「设计AI」侧边栏本体 */
.wecom-sidebar {
  width: 396px;
  flex-shrink: 0;
  background: var(--bg-canvas);
  border-radius: 14px;
  border: 1px solid #E2E5EB;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.09);
  overflow: hidden;
  min-height: 760px;
}

.sb-top {
  padding: 12px 14px 10px;
  background: var(--bg-canvas);
}
.sb-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sb-brand-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber-600);
}
.brand-name {
  font-size: 13.5px;
  font-weight: 700;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.sb-brand-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-green {
  padding: 2px 8px;
  border-radius: 999px;
  background: #E6F4EA;
  color: #15803D;
  border: 1px solid #C6E8D0;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #FFFFFF;
  color: var(--text-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.icon-btn:hover {
  border-color: var(--amber-600);
  color: var(--amber-600);
}

/* 群身份卡片 */
.identity-card {
  background: #FFFFFF;
  border: 1px solid var(--border-warm);
  border-radius: 11px;
  padding: 10px 12px;
}
.identity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.identity-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.tag {
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
}
.tag-amber { background: #FEF3C7; color: #B45309; }
.tag-gray { background: #F3F4F6; color: #4B5563; }
.tag-green { background: #DCFCE7; color: #15803D; }
.tag-red { background: #FEE2E2; color: #B91C1C; }
.identity-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* 2x4 八宫格 */
.module-grid-wrap {
  padding: 0 14px 12px;
  border-bottom: 1px solid #EFECE6;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.grid-btn {
  height: 34px;
  border-radius: 9px;
  border: 1px solid #E9E6E1;
  background: #FFFFFF;
  color: var(--text-body);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.grid-btn:hover {
  border-color: var(--amber-600);
  color: #B45309;
  background: #FFFBF5;
}
.grid-btn.active {
  background: linear-gradient(180deg, #D97706 0%, #B85B06 100%);
  border-color: #B85B06;
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(184, 91, 6, 0.25);
}
.grid-btn.dashed {
  border-style: dashed;
  color: var(--text-muted);
  background: #FCFBFA;
}
.grid-btn.dashed.active {
  border-style: solid;
  color: #FFFFFF;
}
.badge-num {
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: #F59E0B;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.grid-btn.active .badge-num {
  background: #FFFFFF;
  color: #B85B06;
}

/* 主体面板通用卡片 */
.panel-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-body.white-bg {
  background: #FFFFFF;
}
.card {
  background: #FFFFFF;
  border: 1px solid var(--border-warm);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-green-border {
  border-color: var(--border-green);
}
.card-auto {
  background: var(--green-soft);
  border: 1px solid #86EFAC;
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.row-start {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.sub-muted {
  font-size: 11px;
  color: var(--text-muted);
}
.orange-label {
  font-size: 12px;
  font-weight: 700;
  color: #C25E00;
}
.redline-text {
  font-size: 11px;
  color: #C25E00;
  font-weight: 600;
  line-height: 1.5;
}
.ok-banner {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #15803D;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
}
.warn-banner {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #B45309;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
}

/* AI 建议回复专属 */
.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #F9FAFB;
  border: 1px solid #F1F5F9;
  border-radius: 9px;
  padding: 8px 10px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
  flex-shrink: 0;
}
.textarea-blue {
  width: 100%;
  border: 2px solid #86B2F5;
  border-radius: 11px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  resize: vertical;
  background: #FFFFFF;
}
.textarea-plain {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: 11px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  resize: vertical;
  background: #FFFFFF;
}
.textarea-plain:focus {
  border-color: var(--amber-600);
}

/* 深棕黑表头明细框 */
.ledger-box {
  border: 1px solid var(--border-light);
  border-radius: 9px;
  overflow: hidden;
  background: #FFFFFF;
}
.ledger-head {
  background: var(--ledger-dark);
  color: #FFFFFF;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ledger-accent {
  color: #FDE68A;
}
.ledger-row {
  padding: 8px 11px;
  border-top: 1px solid #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.ledger-foot {
  padding: 7px 11px;
  background: #FAFAFA;
  border-top: 1px solid #F3F4F6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 平面图画布与快捷标签 */
.plan-frame {
  border: 1px solid #E5DFD5;
  border-radius: 9px;
  overflow: hidden;
  background: #FFFDF9;
}
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.chip {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid var(--border-light);
  background: #F3F4F6;
  color: var(--text-body);
  cursor: pointer;
}
.chip.active-red {
  background: #DC2626;
  border-color: #DC2626;
  color: #FFFFFF;
  font-weight: 600;
}
.chip.active-dark {
  background: var(--ledger-dark);
  border-color: var(--ledger-dark);
  color: #FDE68A;
  font-weight: 600;
}
.pin-num {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: #DC2626;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dim-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.dim-field {
  background: #FAF8F5;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  padding: 5px 7px;
}
.dim-field label {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}
.dim-field input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
  margin-top: 2px;
}

/* 风格色卡 */
.palette-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.swatch {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* 预览话术块 */
.preview-text-box {
  background: #FAF8F5;
  border: 1px solid var(--border-warm);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-body);
  white-space: pre-line;
}

/* 开关 Switch */
.switch {
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: #15803D;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.switch.off {
  background: #CBD5E1;
}
.switch::after {
  content: '';
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: #FFFFFF;
  position: absolute;
  top: 2px;
  right: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch.off::after {
  transform: translateX(-17px);
}

/* 按钮家族 */
.btn-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-row-flex {
  display: flex;
  gap: 8px;
}
.flex-1 {
  flex: 1;
}
.btn-amber {
  background: linear-gradient(180deg, #F59E0B 0%, #DF7D08 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-orange {
  background: var(--amber-600);
  color: #FFFFFF;
  border: none;
  border-radius: 9px;
  padding: 8.5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-orange:hover { background: #C26705; }
.btn-green {
  background: var(--green-700);
  color: #FFFFFF;
  border: none;
  border-radius: 9px;
  padding: 8.5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-green:hover { background: #145336; }
.btn-outline {
  background: #FFFFFF;
  color: var(--text-body);
  border: 1px solid #D1D5DB;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn-outline:hover {
  border-color: var(--green-700);
  color: var(--green-700);
}
.btn-outline-sm {
  background: #FFFFFF;
  color: var(--text-body);
  border: 1px solid #D1D5DB;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #2563EB;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn-orange {
  background: none;
  border: none;
  padding: 0;
  color: #D97706;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn-danger {
  background: none;
  border: none;
  padding: 0;
  color: #9CA3AF;
  font-size: 11px;
  cursor: pointer;
}
.link-btn-danger:hover {
  color: var(--danger);
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  background: #FFFFFF;
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-head {
  background: var(--ledger-dark);
  color: #FFFFFF;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 14px;
  font-weight: 700;
}
.modal-sub {
  font-size: 11px;
  color: #D6C7B2;
  margin-top: 2px;
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  cursor: pointer;
}
.modal-body {
  padding: 14px;
  max-height: 68vh;
  overflow-y: auto;
  background: #FAF8F5;
  text-align: center;
}
.poster-img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #E5DFD5;
  display: block;
}
.modal-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1F2937;
  color: #FFFFFF;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  z-index: 60;
}

.loading-box {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 820px) {
  .workspace-stage {
    flex-direction: column;
    align-items: center;
  }
  .mock-chat-pane {
    width: 100%;
    max-width: 420px;
    height: 360px;
  }
  .wecom-sidebar {
    width: 100%;
    max-width: 420px;
  }
}
