/* ===== CSS Variables ===== */
:root {
  --primary: #4F6EF7;
  --primary-light: #EEF1FE;
  --primary-dark: #3B55E6;
  --bg: #F5F6FA;
  --bg-white: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --danger: #EF4444;
  --success: #10B981;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-lg: 20px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --header-height: 52px;
  --input-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* 数字人外观变量 */
  --dh-hair-color: #3D1C2E;
  --dh-hair-color2: #5C2D42;
  --dh-skin-color: #FFE4D0;
  --dh-skin-color2: #FDD4BC;
  --dh-dress-color1: #F9A8D4;
  --dh-dress-color2: #F472B6;
  --dh-skirt-color1: #FBCFE8;
  --dh-skirt-color2: #EC4899;
  --dh-shoe-color: #1E1B2E;
  --dh-shoe-color2: #F472B6;
  --dh-mouth-color: #F2928E;
  --dh-blush-color: rgba(255,160,150,0.45);
  --dh-bow-color1: #FB7185;
  --dh-bow-color2: #E11D48;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { border: none; background: none; cursor: pointer; font: inherit; color: inherit; }
input, textarea { font: inherit; border: none; outline: none; background: none; resize: none; }
a { color: var(--primary); text-decoration: none; }
svg { display: block; flex-shrink: 0; }

/* ===== App Layout ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 100vw;
  position: relative;
}

/* ===== Top Bar ===== */
#topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 12px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
}
.logo-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.header-title a {
  display: inline-flex;
}
.icon-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--primary-light); }

/* ===== Sidebar ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 1; transition: opacity 0.25s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-white);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}
#sidebar.closed { transform: translateX(-100%); }
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header a { display: inline-flex; }
.sidebar-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}
.sidebar-title { font-size: 16px; font-weight: 600; }
.sidebar-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
  width: 100%;
}
.nav-item:active, .nav-item.active { background: var(--primary-light); color: var(--primary); }

/* 侧边栏分组 */
.nav-group { display: flex; flex-direction: column; }
.nav-group-parent { position: relative; }
.nav-group-parent .nav-group-chevron { margin-left: auto; transition: transform 0.3s; }
.nav-group-parent.open .nav-group-chevron { transform: rotate(180deg); }
.nav-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.nav-group-children.open { max-height: 800px; }
.nav-sub-item { padding-left: 40px; font-size: 13px; }
.nav-sub-item svg { width: 16px; height: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.version { font-size: 11px; color: var(--text-muted); }

/* ===== Main Content ===== */
#mainContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* ===== Welcome Page ===== */
.welcome-page {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px;
}
.welcome-content { text-align: center; max-width: 380px; width: 100%; }
.welcome-logo {
  width: 72px; height: 72px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  margin: 0 auto 16px;
}
.welcome-page h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.welcome-desc { color: var(--text-secondary); margin-bottom: 32px; font-size: 15px; }
.suggestion-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.suggestion-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}
.suggestion-card:active { transform: scale(0.97); box-shadow: var(--shadow-lg); }
.card-icon { font-size: 20px; margin-bottom: 6px; }

/* ===== Chat Page ===== */
.chat-page { display: flex; flex-direction: column; }
.chat-messages { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }

.chat-bubble {
  display: flex;
  gap: 8px;
  max-width: 90%;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble.assistant { align-self: flex-start; }

.bubble-avatar {
  width: 32px; height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-bubble.assistant .bubble-avatar { background: var(--primary); color: #fff; }
.chat-bubble.user .bubble-avatar { background: #E0E7FF; color: var(--primary); }

.bubble-content {
  background: var(--bg-white);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chat-bubble.user .bubble-content {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  border-top-right-radius: 4px;
}
.bubble-content p { margin: 4px 0; }
.bubble-content p:first-child { margin-top: 0; }
.bubble-content p:last-child { margin-bottom: 0; }
.bubble-content ul, .bubble-content ol { margin: 6px 0; padding-left: 18px; }
.bubble-content li { margin: 3px 0; }
.bubble-content strong { font-weight: 600; }
.bubble-content code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.bubble-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 6px 0;
  font-size: 13px;
}

/* 语音播报按钮 */
.speak-btn {
  padding: 3px 6px;
  border-radius: 4px;
  color: #6B7280;
  font-size: 0;
  transition: all 0.15s;
}
.speak-btn.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* ===== Media Blocks ===== */
.media-block {
  margin: 8px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0,0,0,0.03);
}
.media-image {
  display: block;
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.media-image:hover { opacity: 0.9; }
.media-video {
  display: block;
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.media-actions {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
}
.media-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  font-size: 12px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.media-dl-btn:active { opacity: 0.8; }

/* ===== Media Viewer (全屏) ===== */
.media-viewer {
  position: fixed; inset: 0; z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer.hidden { display: none; }
.media-viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
}
.media-viewer-img {
  position: relative;
  max-width: 94vw;
  max-height: 94vh;
  border-radius: 8px;
  z-index: 1;
}
.media-viewer-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.media-viewer-close:hover { background: rgba(255,255,255,0.3); }

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); } 30% { opacity: 1; transform: scale(1.1); } }

/* ===== Input Bar ===== */
#inputBar {
  flex-shrink: 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 100;
}
.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border-radius: 24px;
  padding: 6px 8px 6px 12px;
}
.input-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}
.input-btn:active { background: rgba(79,110,247,0.1); color: var(--primary); }
.input-btn.recording { background: var(--danger); color: #fff; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); } 50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } }

.message-input {
  flex: 1;
  min-height: 22px;
  max-height: 120px;
  padding: 7px 4px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
  transition: all 0.15s;
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { background: var(--border); color: var(--text-muted); }

/* Voice Status */
.voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}
.voice-wave { display: flex; gap: 3px; align-items: center; }
.voice-wave span {
  width: 3px; height: 14px;
  background: var(--danger);
  border-radius: 2px;
  animation: wave 0.6s infinite alternate;
}
.voice-wave span:nth-child(2) { height: 22px; animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { height: 28px; animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { height: 22px; animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { height: 14px; animation-delay: 0.4s; }
@keyframes wave { to { transform: scaleY(0.6); } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
  position: relative;
  background: var(--bg-white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 28px; height: 28px;
  font-size: 22px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-desc { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }

/* ===== Forms ===== */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.input-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 15px;
  border: 1.5px solid transparent;
  transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--primary); background: #fff; }
.phone-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  transition: border-color 0.2s;
}
.phone-input-wrap:focus-within { border-color: var(--primary); background: #fff; }
.phone-prefix { padding: 0 10px 0 14px; color: var(--text-secondary); font-size: 14px; border-right: 1px solid var(--border); }
.phone-input-wrap input { border: none; background: transparent; }
.code-input { text-align: center; font-size: 20px !important; letter-spacing: 8px; }
.code-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 16px; }

.primary-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s;
}
.primary-btn:active { transform: scale(0.98); opacity: 0.9; }
.primary-btn:disabled { background: var(--border); color: var(--text-muted); }
.link-btn {
  width: 100%;
  padding: 10px;
  color: var(--primary);
  font-size: 13px;
  margin-top: 8px;
}

/* ===== Dropdown ===== */
.dropdown-menu {
  position: fixed;
  top: 52px;
  right: 8px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 6px;
  z-index: 250;
  animation: fadeIn 0.15s ease;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100%;
  transition: background 0.1s;
}
.dropdown-item:active { background: var(--bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== Profile ===== */
.profile-avatar {
  width: 64px; height: 64px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  margin: 0 auto 16px;
  cursor: pointer;
  overflow: hidden;
  transition: opacity 0.2s;
}
.profile-avatar:hover { opacity: 0.85; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { margin-bottom: 20px; }
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.info-row label { font-size: 14px; color: var(--text-secondary); }
.info-row input {
  text-align: right;
  font-size: 14px;
  max-width: 180px;
}
.info-row span { font-size: 14px; color: var(--text-muted); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff;
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; z-index: 999;
  animation: fadeIn 0.2s ease;
  white-space: nowrap;
}
.toast.hidden { display: none; }

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ==============================
   Mobile Portrait (default + fine-tune)
   ============================== */
@media (max-width: 767px) {
  #sidebar {
    width: min(300px, 85vw);
  }
  /* iOS: prevent input zoom */
  .message-input, input[type="tel"], input[type="text"] {
    font-size: 16px !important;
  }
  .chat-bubble { max-width: 86%; }
  .chat-messages { padding: 12px 16px; gap: 12px; }
  .bubble-content { font-size: 14px; padding: 10px 14px; }
  .bubble-avatar { width: 28px; height: 28px; border-radius: 6px; font-size: 12px; }

  .welcome-page { padding: 16px; }
  .welcome-logo { width: 56px; height: 56px; border-radius: 14px; }
  .welcome-page h1 { font-size: 20px; }
  .welcome-desc { font-size: 14px; margin-bottom: 24px; }
  .suggestion-cards { gap: 8px; }
  .suggestion-card { padding: 12px 10px; font-size: 12px; }
  .card-icon { font-size: 18px; margin-bottom: 4px; }

  #inputBar { padding: 6px 10px; padding-bottom: calc(6px + var(--safe-bottom)); }
  .input-container { padding: 4px 6px 4px 10px; gap: 6px; }
  .input-btn, .send-btn { width: 34px; height: 34px; }
  .message-input { padding: 6px 2px; font-size: 15px; }

  .dropdown-menu { top: 48px; right: 4px; min-width: 140px; }
  .dropdown-item { padding: 10px 12px; font-size: 13px; }

  .toast { top: 60px; font-size: 12px; padding: 8px 16px; max-width: 90vw; white-space: normal; text-align: center; }

  .modal-content { border-radius: 20px 20px 0 0; padding: 24px 16px 32px; padding-bottom: calc(32px + var(--safe-bottom)); }
  .modal-body h2 { font-size: 18px; }
  .modal-close { top: 12px; right: 12px; }

  .profile-avatar { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }
  .info-row { padding: 8px 0; }
  .info-row label, .info-row input, .info-row span { font-size: 13px; }
}

/* ===== Mobile Landscape ===== */
@media (max-width: 767px) and (orientation: landscape) {
  #topBar { height: 40px; padding: 0 10px; }
  .header-title { font-size: 14px; }
  .logo-icon { width: 22px; height: 22px; border-radius: 5px; }
  .icon-btn { width: 30px; height: 30px; }
  #mainContent { max-height: calc(100dvh - 40px - 52px); }
  #inputBar { padding: 4px 10px; padding-bottom: calc(4px + var(--safe-bottom)); }
  .input-container { padding: 3px 5px 3px 8px; border-radius: 20px; }
  .input-btn, .send-btn { width: 28px; height: 28px; }
  .message-input { padding: 4px 2px; font-size: 14px; min-height: 18px; max-height: 60px; }

  .welcome-page { padding: 8px 12px; }
  .welcome-logo { width: 36px; height: 36px; border-radius: 10px; }
  .welcome-page h1 { font-size: 16px; margin-bottom: 2px; }
  .welcome-desc { margin-bottom: 10px; font-size: 12px; }
  .suggestion-cards { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .suggestion-card { padding: 8px 6px; font-size: 10px; }
  .card-icon { font-size: 14px; margin-bottom: 2px; }

  .chat-messages { padding: 8px 16px; gap: 8px; }
  .chat-bubble { max-width: 88%; }
  .bubble-content { font-size: 13px; padding: 8px 12px; }
  .bubble-avatar { width: 24px; height: 24px; border-radius: 5px; font-size: 10px; }

  .modal-content { max-height: 90vh; padding: 16px; }
  .modal-body h2 { font-size: 16px; }
  .modal-desc { font-size: 12px; margin-bottom: 12px; }
}

/* ===== Desktop / Tablet ===== */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
    flex-wrap: wrap;
  }
  #topBar { display: none; }
  #sidebar {
    position: relative;
    height: 100dvh;
    transform: none !important;
    box-shadow: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }
  #sidebar.closed { transform: none !important; }
  #sidebarOverlay { display: none !important; }
  #mainContent {
    flex: 1;
    height: calc(100dvh - var(--input-height) - 16px - var(--safe-bottom));
  }
  #inputBar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    border-left: 1px solid var(--border);
  }
  .chat-bubble { max-width: 60%; }
  .modal {
    align-items: center;
  }
  .modal-content {
    border-radius: var(--radius-lg);
    max-height: 70vh;
    animation: fadeIn 0.2s ease;
  }
  #userBtn { display: none; }
}

/* ===== 数据分析弹窗 ===== */
.data-textarea {
  width: 100%; min-height: 120px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px; color: var(--text);
  resize: vertical; outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.data-textarea:focus { border-color: var(--primary); }
.data-textarea::placeholder { color: var(--text-muted); }

.data-file-row {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.secondary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
}
.secondary-btn:hover { border-color: var(--primary); color: var(--primary); }
.file-name {
  font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}
.ref-clear-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ref-clear-btn:hover { border-color: var(--red); color: var(--red); }
.ref-indicator {
  font-size: 11px; color: var(--primary); padding: 2px 8px;
  background: rgba(79,110,247,0.1); border-radius: 10px;
  white-space: nowrap;
}

.analyze-status {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 10px; color: var(--primary); font-size: 14px;
}

.modal-actions { margin-top: 16px; }
.profile-actions {
  display: flex; gap: 10px; margin-top: 20px;
}
.profile-actions .primary-btn { flex: 1; }
.profile-actions .secondary-btn {
  padding: 10px 18px; border-radius: 8px; font-size: 13px; cursor: pointer;
  min-width: 80px; min-height: 44px; touch-action: manipulation;
  background: transparent; border: 1px solid rgba(239,68,68,0.4); color: #EF4444;
}

/* ===== 图片生成尺寸选择 ===== */
.size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.size-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 6px; border-radius: 8px;
  background: transparent;
  border: 1px solid rgba(148,163,184,0.15);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.size-btn span {
  font-size: 10px; color: var(--text-muted);
  font-weight: 400; margin-top: 2px;
}
.size-btn:hover { border-color: var(--primary); color: var(--text); }
.size-btn.selected {
  border-color: var(--primary);
  background: rgba(59,130,246,0.1);
  color: var(--primary);
}
.size-btn.selected span { color: var(--primary); }

/* ===== 图表容器 ===== */
.chart-wrap {
  margin-top: 12px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  position: relative;
  width: 100%;
}
.chart-wrap canvas {
  width: 100% !important;
  max-height: 280px;
}

@media (max-width: 767px) {
  .chart-wrap canvas { max-height: 220px; }
}

/* ===== Word 文档下载 ===== */
.docx-download {
  transition: border-color 0.2s;
}
.docx-download:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
}
.docx-dl-btn:hover {
  filter: brightness(1.1);
}

.modal-actions .primary-btn { width: 100%; }

@media (max-width: 767px) {
  .data-textarea { min-height: 100px; font-size: 16px !important; }
  .secondary-btn { font-size: 12px; padding: 8px 10px; }
}

/* Fullscreen mode (看板) */
#app.fullscreen #mainContent {
  height: 100dvh;
}
#app.fullscreen #inputBar {
  display: none;
}
#app.fullscreen #topBar {
  display: none;
}

/* ===== 浮动虚拟形象 ===== */
.digi-float {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  animation: digiFloat 3.5s ease-in-out infinite;
}
@keyframes digiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---- 容器 ---- */
.digi-girl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 默认：竖屏手机 */
.digi-float {
  bottom: 80px;
  right: 8px;
  --s: 0.7;
}
.digi-girl { width: calc(130px * var(--s)); }

/* 长发后层 */
.digi-hair-back {
  position: absolute;
  background: linear-gradient(180deg, var(--dh-hair-color) 0%, var(--dh-hair-color2) 100%);
  border-radius: 50%;
  z-index: 0;
  width: calc(94px * var(--s)); height: calc(146px * var(--s));
  top: calc(8px * var(--s)); left: 50%; transform: translateX(-50%);
}

/* 头部 */
.digi-head {
  position: relative;
  z-index: 1;
  width: calc(68px * var(--s)); height: calc(74px * var(--s));
}
/* 脸部 */
.digi-face {
  position: relative;
  background: linear-gradient(145deg, var(--dh-skin-color) 0%, var(--dh-skin-color2) 100%);
  border-radius: 50%;
  width: 100%; height: 100%;
  z-index: 2;
  box-shadow: 0 3px 8px rgba(0,0,0,0.07), inset 0 -2px 4px rgba(0,0,0,0.03);
}
/* 齐刘海 */
.digi-bangs {
  position: absolute;
  background: var(--dh-hair-color);
  z-index: 4;
  top: -6%;
  left: 50%;
  transform: translateX(-50%);
  width: calc(74px * var(--s)); height: calc(28px * var(--s));
  border-radius: calc(50px * var(--s)) calc(50px * var(--s)) calc(8px * var(--s)) calc(8px * var(--s));
}
/* 大眼睛 */
.digi-eye {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
  width: calc(28px * var(--s)); height: calc(30px * var(--s));
  top: calc(20px * var(--s));
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.05);
}
/* 长睫毛 */
.digi-eye::before {
  content: '';
  position: absolute;
  top: calc(-3px * var(--s)); left: 50%;
  transform: translateX(-50%);
  width: 125%; height: 45%;
  border-top: calc(2px * var(--s)) solid var(--dh-hair-color);
  border-radius: 50%;
}
.digi-eye-l { left: 14%; }
.digi-eye-r { right: 14%; }
/* 瞳孔 + 高光 */
.digi-pupil {
  background: var(--dh-hair-color);
  border-radius: 50%;
  position: relative;
  width: calc(16px * var(--s)); height: calc(17px * var(--s));
}
.digi-pupil::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 50%;
  width: calc(6px * var(--s)); height: calc(6px * var(--s));
  top: calc(3px * var(--s)); left: calc(3px * var(--s));
}
/* 小嘴（粉色） */
.digi-mouth {
  position: absolute;
  background: var(--dh-mouth-color);
  transition: all 0.08s ease;
  bottom: calc(14px * var(--s)); left: 50%;
  transform: translateX(-50%);
  height: calc(5px * var(--s)); width: calc(14px * var(--s));
  border-radius: 2.5px;
}
/* 腮红 */
.digi-blush {
  position: absolute;
  background: var(--dh-blush-color);
  border-radius: 50%;
  width: calc(14px * var(--s)); height: calc(7px * var(--s));
  top: calc(38px * var(--s));
}
.digi-blush-l { left: 6%; }
.digi-blush-r { right: 6%; }
/* 脖子 */
.digi-neck {
  background: var(--dh-skin-color2);
  z-index: 0;
  width: calc(12px * var(--s)); height: calc(16px * var(--s));
  margin-top: calc(-2px * var(--s));
}
/* 身体 */
.digi-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}
/* 粉色上衣（蝴蝶结装饰） */
.digi-dress {
  background: linear-gradient(145deg, var(--dh-dress-color1) 0%, var(--dh-dress-color2) 100%);
  z-index: 1;
  width: calc(56px * var(--s)); height: calc(46px * var(--s));
  margin-top: -1px;
  border-radius: calc(16px * var(--s)) calc(16px * var(--s)) calc(2px * var(--s)) calc(2px * var(--s));
  box-shadow: 0 4px 12px rgba(244,114,182,0.3);
  position: relative;
}
/* 领口蝴蝶结 */
.digi-dress::after {
  content: '';
  position: absolute;
  top: calc(8px * var(--s)); left: 50%;
  transform: translateX(-50%);
  width: calc(14px * var(--s)); height: calc(10px * var(--s));
  background: radial-gradient(ellipse, var(--dh-bow-color1) 0%, var(--dh-bow-color2) 100%);
  border-radius: 50%;
  box-shadow: calc(-5px * var(--s)) 0 0 calc(-1px * var(--s)) var(--dh-bow-color1),
              calc(5px * var(--s)) 0 0 calc(-1px * var(--s)) var(--dh-bow-color1);
}
/* 手臂 */
.digi-arm {
  position: absolute;
  background: var(--dh-skin-color2);
  border-radius: calc(5px * var(--s));
  z-index: 0;
  width: calc(9px * var(--s)); height: calc(46px * var(--s));
  top: 0;
}
.digi-arm-l { left: calc(-5px * var(--s)); transform: rotate(8deg); }
.digi-arm-r { right: calc(-5px * var(--s)); transform: rotate(-8deg); }
/* 粉色蓬蓬裙 */
.digi-skirt {
  background: linear-gradient(180deg, var(--dh-dress-color2) 0%, var(--dh-skirt-color2) 100%);
  width: calc(68px * var(--s)); height: calc(32px * var(--s));
  margin-top: -2px;
  border-radius: 0 0 calc(24px * var(--s)) calc(24px * var(--s));
}
/* 腿 */
.digi-legs {
  position: relative;
  display: flex;
  justify-content: center;
  gap: calc(14px * var(--s));
  z-index: 0;
}
.digi-leg {
  background: var(--dh-skin-color2);
  border-radius: 0 0 calc(5px * var(--s)) calc(5px * var(--s));
  width: calc(10px * var(--s)); height: calc(48px * var(--s));
}
/* 粉色圆头鞋 */
.digi-shoe {
  position: absolute;
  background: var(--dh-shoe-color);
  border-radius: calc(6px * var(--s));
  width: calc(13px * var(--s)); height: calc(8px * var(--s));
  bottom: calc(-8px * var(--s));
}
.digi-shoe::after {
  content: '';
  position: absolute;
  top: calc(2px * var(--s)); left: 50%;
  transform: translateX(-50%);
  width: calc(5px * var(--s)); height: calc(3px * var(--s));
  background: var(--dh-skirt-color1);
  border-radius: 50%;
}
.digi-shoe-l { left: 0; }
.digi-shoe-r { right: 0; }

/* 浮动形象男性修饰 */
.digi-girl.dh-gender-male .digi-hair-back {
  height: calc(86px * var(--s));
  width: calc(76px * var(--s));
  top: calc(2px * var(--s));
}
.digi-girl.dh-gender-male .digi-bangs {
  height: calc(10px * var(--s));
  width: calc(50px * var(--s));
  top: 0;
  border-radius: 0 0 calc(4px * var(--s)) calc(4px * var(--s));
}
.digi-girl.dh-gender-male .digi-blush { display: none; }
.digi-girl.dh-gender-male .digi-face {
  border-radius: 48% 48% 44% 44%;
}
.digi-girl.dh-gender-male .digi-neck {
  width: calc(16px * var(--s));
}
.digi-girl.dh-gender-male .digi-dress {
  width: calc(62px * var(--s));
  border-radius: calc(8px * var(--s)) calc(8px * var(--s)) calc(2px * var(--s)) calc(2px * var(--s));
}
.digi-girl.dh-gender-male .digi-dress::after {
  top: calc(4px * var(--s));
  width: calc(6px * var(--s));
  height: calc(18px * var(--s));
  border-radius: calc(2px * var(--s));
  background: var(--dh-bow-color2);
  box-shadow: none;
}
.digi-girl.dh-gender-male .digi-skirt {
  width: calc(40px * var(--s));
  border-radius: calc(2px * var(--s)) calc(2px * var(--s)) calc(6px * var(--s)) calc(6px * var(--s));
  background: linear-gradient(180deg, var(--dh-dress-color2) 0%, var(--dh-skirt-color2) 100%);
}
.digi-girl.dh-gender-male .digi-arm {
  width: calc(12px * var(--s));
}
.digi-girl.dh-gender-male .digi-legs { gap: calc(8px * var(--s)); }
.digi-girl.dh-gender-male .digi-leg {
  width: calc(13px * var(--s));
}

/* 浮动形象发型变体 */
.digi-girl.dh-hair-short .digi-hair-back {
  height: calc(86px * var(--s));
  width: calc(76px * var(--s));
  top: calc(2px * var(--s));
}
.digi-girl.dh-hair-short .digi-bangs {
  height: calc(8px * var(--s));
  width: calc(48px * var(--s));
  top: 0;
  border-radius: 0 0 calc(6px * var(--s)) calc(6px * var(--s));
}
.digi-girl.dh-hair-bob .digi-hair-back {
  height: calc(110px * var(--s));
  width: calc(88px * var(--s));
  top: calc(4px * var(--s));
}
.digi-girl.dh-hair-bob .digi-bangs {
  height: calc(22px * var(--s));
  width: calc(70px * var(--s));
  border-radius: calc(40px * var(--s)) calc(40px * var(--s)) calc(6px * var(--s)) calc(6px * var(--s));
}

/* ---- 浮动位置响应式 ---- */
/* 桌面端 */
@media (min-width: 768px) {
  .digi-float {
    bottom: 90px;
    right: 20px;
    --s: 0.85;
  }
}
/* 横屏手机 */
@media (max-width: 767px) and (orientation: landscape) {
  .digi-float {
    bottom: 56px;
    right: 4px;
    --s: 0.45;
  }
}
/* 看板全屏：浮动虚拟形象保持可见 */

/* ===== 门店数字人（全屏） ===== */
.digital-human-page {
  background: radial-gradient(ellipse at 50% 35%, #1E2A4A 0%, #0B1120 70%);
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  -webkit-transform: translateZ(0); /* Safari 强制独立合成层 */
}
.dh-close {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.45); border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 40px; font-weight: 300; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-appearance: none; appearance: none; padding: 0; margin: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.dh-close:hover { background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.5); }
.dh-close:active { background: rgba(0,0,0,0.7); }
.dh-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; padding: 20px;
}
.dh-character { --s: 2.4; margin-bottom: 20px; }
@media (max-width: 767px) { .dh-character { --s: 1.6; } }
@media (max-width: 400px) { .dh-character { --s: 1.2; } }

/* 复用浮动形象的样式结构，加 dh- 前缀 */
.dh-girl { position: relative; display: flex; flex-direction: column; align-items: center; }
.dh-hair-back {
  position: absolute; background: linear-gradient(180deg, var(--dh-hair-color) 0%, var(--dh-hair-color2) 100%);
  border-radius: 50%; z-index: 0;
  width: calc(94px * var(--s)); height: calc(146px * var(--s));
  top: calc(8px * var(--s)); left: 50%; transform: translateX(-50%);
}
.dh-head { position: relative; z-index: 1; width: calc(68px * var(--s)); height: calc(74px * var(--s)); }
.dh-face {
  position: relative; background: linear-gradient(145deg, var(--dh-skin-color) 0%, var(--dh-skin-color2) 100%);
  border-radius: 50%; width: 100%; height: 100%; z-index: 2;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.05);
}
.dh-bangs {
  position: absolute; background: var(--dh-hair-color); z-index: 4;
  top: -6%; left: 50%; transform: translateX(-50%);
  width: calc(74px * var(--s)); height: calc(28px * var(--s));
  border-radius: calc(50px * var(--s)) calc(50px * var(--s)) calc(8px * var(--s)) calc(8px * var(--s));
}
.dh-eye {
  position: absolute; background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s ease;
  width: calc(28px * var(--s)); height: calc(30px * var(--s));
  top: calc(20px * var(--s));
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.05);
}
.dh-eye::before {
  content: ''; position: absolute;
  top: calc(-3px * var(--s)); left: 50%; transform: translateX(-50%);
  width: 125%; height: 45%;
  border-top: calc(2px * var(--s)) solid var(--dh-hair-color); border-radius: 50%;
}
.dh-eye-l { left: 14%; }
.dh-eye-r { right: 14%; }
.dh-pupil {
  background: var(--dh-hair-color); border-radius: 50%; position: relative;
  width: calc(16px * var(--s)); height: calc(17px * var(--s));
}
.dh-pupil::after {
  content: ''; position: absolute; background: #fff; border-radius: 50%;
  width: calc(6px * var(--s)); height: calc(6px * var(--s));
  top: calc(3px * var(--s)); left: calc(3px * var(--s));
}
.dh-mouth {
  position: absolute; background: var(--dh-mouth-color);
  transition: all 0.08s ease;
  bottom: calc(14px * var(--s)); left: 50%;
  transform: translateX(-50%);
  height: calc(5px * var(--s)); width: calc(14px * var(--s));
  border-radius: 2.5px;
}
.dh-blush {
  position: absolute; background: var(--dh-blush-color);
  border-radius: 50%;
  width: calc(14px * var(--s)); height: calc(7px * var(--s));
  top: calc(38px * var(--s));
}
.dh-blush-l { left: 6%; }
.dh-blush-r { right: 6%; }
.dh-neck {
  background: var(--dh-skin-color2); z-index: 0;
  width: calc(12px * var(--s)); height: calc(16px * var(--s));
  margin-top: calc(-2px * var(--s));
}
.dh-body { position: relative; display: flex; flex-direction: column; align-items: center; z-index: 1; }
.dh-dress {
  background: linear-gradient(145deg, var(--dh-dress-color1) 0%, var(--dh-dress-color2) 100%); z-index: 1;
  width: calc(56px * var(--s)); height: calc(46px * var(--s));
  margin-top: -1px;
  border-radius: calc(16px * var(--s)) calc(16px * var(--s)) calc(2px * var(--s)) calc(2px * var(--s));
  box-shadow: 0 4px 12px rgba(244,114,182,0.3); position: relative;
}
.dh-dress::after {
  content: ''; position: absolute;
  top: calc(8px * var(--s)); left: 50%; transform: translateX(-50%);
  width: calc(14px * var(--s)); height: calc(10px * var(--s));
  background: radial-gradient(ellipse, var(--dh-bow-color1) 0%, var(--dh-bow-color2) 100%); border-radius: 50%;
  box-shadow: calc(-5px * var(--s)) 0 0 calc(-1px * var(--s)) var(--dh-bow-color1),
              calc(5px * var(--s)) 0 0 calc(-1px * var(--s)) var(--dh-bow-color1);
}
.dh-arm {
  position: absolute; background: var(--dh-skin-color2); z-index: 0; top: 0;
  width: calc(9px * var(--s)); height: calc(46px * var(--s));
  border-radius: calc(5px * var(--s));
}
.dh-arm-l { left: calc(-5px * var(--s)); transform: rotate(8deg); }
.dh-arm-r { right: calc(-5px * var(--s)); transform: rotate(-8deg); }
.dh-skirt {
  background: linear-gradient(180deg, var(--dh-dress-color2) 0%, var(--dh-skirt-color2) 100%);
  width: calc(68px * var(--s)); height: calc(32px * var(--s));
  margin-top: -2px;
  border-radius: 0 0 calc(24px * var(--s)) calc(24px * var(--s));
}
.dh-legs { display: flex; gap: calc(14px * var(--s)); position: relative; }
.dh-leg {
  width: calc(10px * var(--s)); height: calc(48px * var(--s));
  background: var(--dh-skin-color2); border-radius: 0 0 calc(5px * var(--s)) calc(5px * var(--s));
}
.dh-shoe {
  position: absolute; bottom: calc(-8px * var(--s));
  width: calc(13px * var(--s)); height: calc(8px * var(--s));
  background: var(--dh-shoe-color); border-radius: calc(6px * var(--s));
}
.dh-shoe-l { left: 0; }
.dh-shoe-r { right: 0; }

/* ---- 男性角色修饰 ---- */
.dh-gender-male .dh-hair-back {
  height: calc(86px * var(--s));
  width: calc(76px * var(--s));
  top: calc(2px * var(--s));
}
.dh-gender-male .dh-bangs {
  height: calc(10px * var(--s));
  width: calc(50px * var(--s));
  top: 0;
  border-radius: 0 0 calc(4px * var(--s)) calc(4px * var(--s));
}
.dh-gender-male .dh-blush { display: none; }
.dh-gender-male .dh-face {
  border-radius: 48% 48% 44% 44%;
}
.dh-gender-male .dh-neck {
  width: calc(16px * var(--s));
}
.dh-gender-male .dh-dress {
  width: calc(62px * var(--s));
  border-radius: calc(8px * var(--s)) calc(8px * var(--s)) calc(2px * var(--s)) calc(2px * var(--s));
}
.dh-gender-male .dh-dress::after {
  /* 领带替代蝴蝶结 */
  top: calc(4px * var(--s));
  width: calc(6px * var(--s));
  height: calc(18px * var(--s));
  border-radius: calc(2px * var(--s));
  background: var(--dh-bow-color2);
  box-shadow: none;
}
.dh-gender-male .dh-skirt {
  width: calc(40px * var(--s));
  border-radius: calc(2px * var(--s)) calc(2px * var(--s)) calc(6px * var(--s)) calc(6px * var(--s));
  background: linear-gradient(180deg, var(--dh-dress-color2) 0%, var(--dh-skirt-color2) 100%);
}
.dh-gender-male .dh-arm {
  width: calc(12px * var(--s));
}
.dh-gender-male .dh-legs { gap: calc(8px * var(--s)); }
.dh-gender-male .dh-leg {
  width: calc(13px * var(--s));
}

/* ---- 发型变体 ---- */
.dh-hair-short .dh-hair-back {
  height: calc(86px * var(--s));
  width: calc(76px * var(--s));
  top: calc(2px * var(--s));
}
.dh-hair-short .dh-bangs {
  height: calc(8px * var(--s));
  width: calc(48px * var(--s));
  top: 0;
  border-radius: 0 0 calc(6px * var(--s)) calc(6px * var(--s));
}
.dh-hair-bob .dh-hair-back {
  height: calc(110px * var(--s));
  width: calc(88px * var(--s));
  top: calc(4px * var(--s));
}
.dh-hair-bob .dh-bangs {
  height: calc(22px * var(--s));
  width: calc(70px * var(--s));
  border-radius: calc(40px * var(--s)) calc(40px * var(--s)) calc(6px * var(--s)) calc(6px * var(--s));
}

/* 状态文字 */
.dh-status {
  font-size: 15px; color: rgba(255,255,255,0.7); text-align: center;
  max-width: 360px; line-height: 1.5; padding: 0 16px; min-height: 24px;
}
/* 数字人名字 */
.dh-name-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 6px;
}
.dh-name-text {
  font-size: 13px; color: rgba(255,255,255,0.45); cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.2);
  padding: 1px 4px; transition: all 0.15s;
}
.dh-name-text:hover { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.4); }
.dh-name-edit {
  background: none; border: none; color: rgba(255,255,255,0.25);
  cursor: pointer; padding: 2px; display: flex; align-items: center;
  transition: color 0.15s;
}
.dh-name-edit:hover { color: rgba(255,255,255,0.6); }
.dh-name-input {
  background: rgba(255,255,255,0.08); border: 1px solid var(--primary);
  border-radius: 6px; color: #fff; font-size: 13px; padding: 2px 8px;
  width: 120px; text-align: center; outline: none;
}

/* 个性化按钮 */
.dh-customize-btn {
  position: fixed; top: 16px; right: 68px; z-index: 9999;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.45); border: 1.5px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.dh-customize-btn:hover { background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.5); color: #fff; }

/* 备忘录按钮 */
.dh-memo-btn {
  position: fixed; top: 16px; right: 116px; z-index: 9999;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.45); border: 1.5px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.dh-memo-btn:hover { background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.5); color: #fff; }

/* 备忘录弹窗 */
.dh-memo-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.dh-memo-overlay.hidden { display: none; }
.dh-memo-panel {
  background: #1A1F35; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px; max-height: 65vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
.dh-memo-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.dh-memo-header h3 { margin: 0; font-size: 18px; color: #fff; }
.dh-memo-close {
  background: none; border: none; color: rgba(255,255,255,0.6);
  font-size: 20px; cursor: pointer;
}
.dh-memo-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.dh-memo-item {
  padding: 12px; border-radius: 10px; background: rgba(255,255,255,0.05);
  margin-bottom: 8px; position: relative;
}
.dh-memo-item .memo-content { font-size: 14px; color: #e0e0e0; line-height: 1.5; margin-bottom: 6px; }
.dh-memo-item .memo-time { font-size: 11px; color: rgba(255,255,255,0.4); }
.dh-memo-item .memo-delete {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: rgba(255,255,255,0.3);
  font-size: 16px; cursor: pointer;
}
.dh-memo-item .memo-delete:hover { color: var(--danger); }

/* 个性化面板 */
.dh-custom-panel {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
}
.dh-custom-panel.hidden { display: none; }
.dh-custom-panel .dh-custom-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  transition: opacity 0.3s; opacity: 0;
}
.dh-custom-panel.active .dh-custom-backdrop { opacity: 1; }
.dh-custom-content {
  position: relative; z-index: 1;
  background: #1A1F35; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px; max-height: 70vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.dh-custom-panel.active .dh-custom-content { transform: translateY(0); }
.dh-custom-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.dh-custom-header h3 {
  font-size: 16px; font-weight: 600; color: #fff;
}
.dh-custom-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 24px; cursor: pointer; padding: 0; line-height: 1;
}
.dh-custom-close:hover { color: #fff; }
.dh-custom-body {
  flex: 1; overflow-y: auto; padding: 12px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.dh-custom-footer {
  padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08);
}
.dh-custom-section {
  display: flex; flex-direction: column; gap: 6px;
}
.dh-custom-label {
  font-size: 12px; color: rgba(255,255,255,0.45);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.dh-custom-options {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.dh-custom-opt {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  cursor: pointer; transition: all 0.15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.dh-custom-opt:hover { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); }
.dh-custom-opt.active {
  border-color: var(--primary);
  background: rgba(79,110,247,0.15);
  box-shadow: 0 0 0 1px rgba(79,110,247,0.3);
}
.dh-custom-opt-icon { font-size: 18px; }
.dh-custom-opt-label { font-size: 13px; color: #fff; }
.dh-custom-opt-desc {
  font-size: 11px; color: rgba(255,255,255,0.4);
  margin-left: auto;
}
.dh-custom-swatch {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* 音色试听按钮 */
.dh-voice-preview-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-left: auto; flex-shrink: 0;
  transition: all 0.15s;
}
.dh-voice-preview-btn:hover {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.dh-voice-preview-btn.playing {
  background: var(--primary); border-color: var(--primary); color: #fff;
  animation: dh-preview-pulse 1s infinite;
}
.dh-voice-preview-btn.playing svg { display: none; }
.dh-voice-preview-btn.playing::after {
  content: ''; width: 6px; height: 12px;
  border-left: 3px solid #fff; border-right: 3px solid #fff;
  border-radius: 2px;
}
@keyframes dh-preview-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,110,247,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(79,110,247,0); }
}

/* 底部输入栏 */
.dh-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.04); border-top: 1px solid rgba(255,255,255,0.06);
  width: 100%; max-width: 600px; margin: 0 auto;
}
.dh-text-input {
  flex: 1; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px; padding: 10px 16px; color: #fff; font-size: 14px;
  outline: none; transition: border-color 0.15s;
}
.dh-text-input:focus { border-color: var(--primary); }
.dh-text-input::placeholder { color: rgba(255,255,255,0.3); }
.dh-send-btn, .dh-voice-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.dh-send-btn { background: var(--primary); color: #fff; }
.dh-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dh-voice-btn { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }
.dh-voice-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dh-voice-btn.recording { background: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } }

/* 知识库图片弹窗（数字人页内） */
.dh-kb-popup {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
}
.dh-kb-popup.hidden { display: none; }
.dh-kb-popup-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6);
}
.dh-kb-popup-content {
  position: relative; z-index: 1;
  max-width: 85vw; max-height: 80vh;
  background: #1A1F35; border-radius: 16px;
  padding: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; align-items: center;
}
.dh-kb-popup-content img {
  max-width: 100%; max-height: 65vh;
  border-radius: 8px; object-fit: contain;
}
.dh-kb-popup-close {
  position: absolute; top: -12px; right: -12px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; z-index: 2;
}
.dh-kb-popup-close:hover { background: var(--red); border-color: var(--red); }
.dh-kb-popup-label {
  margin-top: 8px; font-size: 14px; color: rgba(255,255,255,0.6);
  text-align: center;
}

/* 知识库管理弹窗 */
.kb-type-tabs {
  display: flex; gap: 8px;
}
.kb-type-tab {
  flex: 1; padding: 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-dim); font-size: 14px; cursor: pointer;
  transition: all 0.15s;
}
.kb-type-tab.active {
  border-color: var(--primary); background: rgba(79,110,247,0.1);
  color: var(--primary);
}
.kb-image-preview {
  position: relative; display: inline-block; margin-bottom: 8px;
}
.kb-image-preview img {
  max-width: 200px; max-height: 160px; border-radius: 8px;
  border: 1px solid var(--border);
}
.kb-image-preview .ref-clear-btn {
  position: absolute; top: -8px; right: -8px;
}
.kb-list {
  margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px;
}
.kb-list-title {
  font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px;
}
.kb-list-items {
  display: flex; flex-direction: column; gap: 8px;
}
.kb-empty {
  text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px 0;
}
.kb-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--border);
}
.kb-list-item-info {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
}
.kb-thumb {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--border); flex-shrink: 0;
}
.kb-list-item-type { font-size: 16px; flex-shrink: 0; }
.kb-list-item-title {
  font-size: 14px; color: var(--text); font-weight: 500; flex-shrink: 0;
}
.kb-list-item-preview {
  font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1; min-width: 0;
}
.kb-list-item-del {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 4px; border-radius: 4px; flex-shrink: 0;
  transition: all 0.15s;
}
.kb-list-item-del:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* ===== 经营数据看板 ===== */
.dashboard-page {
  background: #0B1120;
  flex: 1;
  color: #E2E8F0;
  position: relative;
}
.dash-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
  -webkit-appearance: none;
  appearance: none;
  padding: 0; margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.dash-close:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}
.dash-close:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.93);
}
.dash-scroll {
  padding: 20px 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.dash-section {
  margin-bottom: 24px;
}
.dash-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #94A3B8;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI 卡片网格 */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.dash-kpi-grid.dash-kpi-3 {
  grid-template-columns: repeat(3, 1fr);
}
.dash-kpi-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(8px);
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.kpi-icon.blue { background: rgba(59, 130, 246, 0.15); }
.kpi-icon.green { background: rgba(16, 185, 129, 0.15); }
.kpi-icon.orange { background: rgba(245, 158, 11, 0.15); }
.kpi-icon.purple { background: rgba(139, 92, 246, 0.15); }
.kpi-info { flex: 1; min-width: 0; }
.kpi-value {
  font-size: 22px; font-weight: 700;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-label {
  font-size: 12px; color: #64748B;
  margin-top: 2px;
}

/* 图表行 */
.dash-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dash-chart-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 12px;
  padding: 18px 16px;
  backdrop-filter: blur(8px);
}
.dash-chart-card .dash-section-title {
  margin-bottom: 12px;
}
.chart-container {
  position: relative;
  width: 100%;
  height: 260px;
}
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* 表格 */
.dash-table-wrap {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 12px;
  overflow-x: auto;
  backdrop-filter: blur(8px);
}
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dash-table th {
  text-align: left;
  padding: 12px 14px;
  color: #64748B;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}
.dash-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
}
.dash-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}
.code-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.12);
  color: #60A5FA;
  border-radius: 4px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
}

/* 看板响应式 */
@media (max-width: 767px) {
  .dash-scroll { padding: 14px 12px 24px; }
  .dash-kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-kpi-grid.dash-kpi-3 { grid-template-columns: 1fr 1fr; }
  .dash-kpi-card { padding: 14px 12px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 8px; font-size: 16px; }
  .kpi-value { font-size: 18px; }
  .dash-chart-row { grid-template-columns: 1fr; }
  .chart-container { height: 220px; }
  .dash-table { font-size: 11px; }
  .dash-table th, .dash-table td { padding: 8px 10px; }

  /* 表格 → 卡片布局 */
  .dash-table-wrap { overflow-x: visible; }
  .dash-table thead { display: none; }
  .dash-table, .dash-table tbody, .dash-table tr, .dash-table td { display: block; }
  .dash-table tr {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.12);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 4px 0;
  }
  .dash-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    white-space: normal;
    font-size: 13px;
  }
  .dash-table td:last-child { border-bottom: none; }
  .dash-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #64748B;
    font-size: 11px;
    flex-shrink: 0;
  }
  .dash-table td[data-label="操作"] { align-items: flex-end; }
  .dash-table td[data-label="操作"]::before { display: none; }

  .dash-pagination { font-size: 12px; gap: 6px; }
  .dash-pagination button { padding: 6px 12px; font-size: 12px; }
}

/* ===== 充值弹窗 ===== */
.recharge-opt-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.recharge-opt-card:hover { border-color: var(--primary); }
.recharge-opt-card.selected { border-color: var(--primary); box-shadow: 0 0 12px rgba(79,110,247,0.15); }
.recharge-opt-card .rc-amount { font-size: 16px; font-weight: 700; color: var(--primary); }
.recharge-opt-card .rc-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.recharge-opt-card .rc-bonus { font-size: 10px; color: var(--success); margin-top: 2px; }

@media (max-width: 767px) {
  #rechargeOptionsEl { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  .recharge-opt-card { padding: 10px 6px; }
  .recharge-opt-card .rc-amount { font-size: 14px; }
}

/* ===== 图片选择弹窗 ===== */
.image-picker-popup {
  position: relative;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.image-picker-popup .picker-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 13px; font-weight: 600;
}
.image-picker-popup .picker-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.image-picker-popup .picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  max-height: 260px; overflow-y: auto;
}
.picker-grid .picker-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.picker-grid .picker-item:hover { border-color: var(--primary); }
.picker-grid .picker-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,110,247,0.3); }
.picker-grid .picker-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-grid .picker-item .pick-check {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 12px;
}
.picker-grid .picker-item.selected .pick-check { display: flex; }
.picker-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
}
.picker-count { font-size: 12px; color: var(--text-dim); }

/* ===== 分页控件 ===== */
.dash-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 12px 0;
}
.dash-pagination button {
  padding: 8px 20px;
  background: rgba(59, 130, 246, 0.12);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.dash-pagination button:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.25);
}
.dash-pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.page-info {
  font-size: 13px;
  color: #64748B;
}

/* ===== 属性标签 ===== */
.attr-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.12);
  color: #34D399;
  border-radius: 4px;
  font-size: 11px;
  margin-right: 4px;
}

/* ===== 状态徽章 ===== */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(16, 185, 129, 0.12);
  color: #34D399;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* ===== 购物车弹窗 ===== */
.dh-cart-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dh-cart-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.dh-cart-panel {
  position: relative;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.dh-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.dh-cart-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.dh-cart-close:hover { background: var(--bg); color: var(--text); }
.dh-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}
.dh-cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.dh-cart-item:last-child { border-bottom: none; }
.dh-cart-item-info { flex: 1; min-width: 0; }
.dh-cart-item-name { font-weight: 600; font-size: 14px; color: var(--text); }
.dh-cart-item-attrs { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.dh-cart-item-qty { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.dh-cart-item-price { font-size: 14px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.dh-cart-item-remove {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #FEE2E2;
  color: #EF4444;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.dh-cart-item-remove:hover { background: #FECACA; }
.dh-cart-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.dh-cart-total {
  font-size: 16px;
  color: var(--text);
  display: block;
  margin-bottom: 12px;
}
.dh-cart-total strong { color: var(--primary); font-size: 20px; }
.dh-cart-actions {
  display: flex;
  gap: 12px;
}
.dh-cart-actions button { flex: 1; }
.dh-cart-badge {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}
.dh-cart-badge button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.4);
  transition: transform 0.15s;
}
.dh-cart-badge button:active { transform: scale(0.96); }
.dh-pay-body {
  padding: 24px 20px;
  text-align: center;
}
.dh-pay-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}
.dh-pay-qrcode {
  margin-bottom: 8px;
}

/* ===== Loading Spinner ===== */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 设备商城 ===== */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.store-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  backdrop-filter: blur(8px);
}
.store-card:active { transform: scale(0.97); border-color: var(--primary); }
.store-card-img {
  width: 100%;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  background-color: rgba(0,0,0,0.2);
}
.store-card-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.store-card-body { padding: 10px 12px; }
.store-card-name { font-size: 14px; font-weight: 600; color: #E2E8F0; margin-bottom: 2px; }
.store-card-code { font-size: 11px; color: #64748B; margin-bottom: 6px; }
.store-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.store-card-price { font-size: 16px; font-weight: 700; color: #60A5FA; }
.store-card-sales { font-size: 11px; color: #64748B; white-space: nowrap; }

/* 视频播放器 */
.store-video {
  display: block;
  width: 100%;
  background: #000;
}

/* 图片画廊 — 上下平铺排列 */
.store-gallery {
  display: flex;
  flex-direction: column;
}
.store-gallery-img {
  display: block;
  width: 100%;
}

/* 订单卡片 */
.store-order-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

/* 评价评分按钮 */
.review-rating-btn {
  padding: 8px 16px;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.review-rating-btn[data-rating="good"] {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
  border-color: rgba(22, 163, 74, 0.35);
}
.review-rating-btn[data-rating="medium"] {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
  border-color: rgba(217, 119, 6, 0.35);
}
.review-rating-btn[data-rating="bad"] {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}
.review-rating-btn:hover { filter: brightness(1.2); }
.review-rating-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px currentColor;
  filter: brightness(1.35);
}

@media (max-width: 767px) {
  .store-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .store-card-name { font-size: 13px; }
  .store-card-price { font-size: 13px; }
  .store-card-body { padding: 8px 10px; }
}

/* ===== 商品库编辑/删除按钮 ===== */
.product-edit-btn:hover {
  color: var(--primary-dark) !important;
  background: rgba(79,110,247,0.1) !important;
  border-radius: 4px;
}
.product-del-btn:hover {
  color: var(--danger) !important;
  background: rgba(239,68,68,0.1) !important;
  border-radius: 4px;
}

/* ===== 小票打印机 - 开关 ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== 小票打印机 - 名称编辑 ===== */
.printer-name-row { display: flex; align-items: center; gap: 6px; }
.printer-name-text { font-size: 14px; font-weight: 600; cursor: pointer; }
.printer-name-edit {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 2px; border-radius: 4px; display: inline-flex; align-items: center;
  opacity: 0; transition: opacity 0.15s;
}
.printer-name-row:hover .printer-name-edit { opacity: 1; }
.printer-name-edit:hover { color: var(--primary); }

/* ===== 素材库 ===== */
.mat-lib-modal { max-width: 780px; width: 95vw; }
.mat-lib-body { padding: 0 !important; }
.mat-lib-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.mat-lib-header h2 { font-size: 18px; font-weight: 600; margin: 0; }
.mat-lib-layout { display: flex; height: 460px; }
.mat-lib-sidebar {
  width: 160px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 8px 0;
}
.mat-group-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; cursor: pointer; transition: background 0.1s;
  font-size: 13px; color: var(--text);
}
.mat-group-item:hover { background: var(--primary-light); }
.mat-group-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.mat-group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-group-count {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg); padding: 1px 7px; border-radius: 10px;
}
.mat-group-item.active .mat-group-count { background: rgba(79,110,247,0.15); color: var(--primary); }
.mat-group-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.mat-group-del, .mat-group-edit {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 2px 5px; line-height: 1;
  display: inline-flex; align-items: center; border-radius: 4px;
  opacity: 0.55; transition: opacity 0.15s, color 0.15s;
}
.mat-group-edit { font-size: 13px; }
.mat-group-del:hover, .mat-group-item:hover .mat-group-del { color: var(--danger); opacity: 1; }
.mat-group-edit:hover, .mat-group-item:hover .mat-group-edit { color: var(--primary); opacity: 1; }
.mat-lib-main { flex: 1; overflow-y: auto; padding: 12px; }
.mat-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.mat-empty {
  grid-column: 1 / -1; text-align: center;
  padding: 60px 20px; color: var(--text-muted); font-size: 14px;
}
.mat-card {
  background: var(--bg); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.mat-card:hover { box-shadow: var(--shadow-lg); }
.mat-card-img-wrap {
  position: relative; width: 100%; height: 130px;
  cursor: pointer; overflow: hidden; background: var(--bg);
}
.mat-card-img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.mat-video-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.mat-card-info { padding: 6px 10px 2px; }
.mat-card-group {
  font-size: 11px; color: var(--primary); font-weight: 500;
}
.mat-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.mat-card-actions {
  display: flex; justify-content: flex-end; gap: 4px;
  padding: 4px 8px 8px;
}
.mat-card-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
  color: var(--text-dim); display: flex; align-items: center;
  transition: all 0.12s;
}
.mat-card-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.mat-card-btn-danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.08); }

/* 素材预览浮层 */
.mat-preview-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}
.mat-preview-overlay.hidden { display: none; }
.mat-preview-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7);
}
.mat-preview-content {
  position: relative; z-index: 1;
  max-width: 85vw; max-height: 85vh;
  background: var(--bg-white); border-radius: var(--radius-lg);
  padding: 12px; box-shadow: var(--shadow-lg);
}
.mat-preview-content img,
.mat-preview-content video {
  max-width: 100%; max-height: 70vh;
  border-radius: 8px; display: block;
}
.mat-preview-close {
  position: absolute; top: -14px; right: -14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-white); border: 1px solid var(--border);
  color: var(--text); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.mat-preview-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.mat-preview-info {
  margin-top: 8px; font-size: 13px; color: var(--text-secondary);
  text-align: center; max-width: 400px; word-break: break-all;
}
@media (max-width: 600px) {
  .mat-lib-layout { flex-direction: column; height: auto; }
  .mat-lib-sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px;
  }
  .mat-group-item { padding: 6px 10px; border-radius: 14px; font-size: 12px; }
  .mat-lib-main { max-height: 340px; }
  .mat-lib-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
