:root {
  /* Original tokens (retained for backward compatibility) */
  --bg-deep: #0d1117;
  --bg-base: #161b22;
  --bg-card: #21262d;
  --bg-hover: #30363d;
  --border: #30363d;
  --border-light: #484f58;
  --text: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --green: #238636;
  --green-bg: rgba(35,134,54,0.15);
  --red: #f85149;
  --warn: #d29922;
  --blue: #58a6ff;
  --purple: #a371f7;
  --purple-bg: rgba(163,113,247,0.15);
  --radius: 10px;
  --radius-sm: 6px;

  /* Semantic aliases (prefer these in new code) */
  --primary: var(--green);
  --primary-hover: #16a34a;
  --primary-bg: var(--green-bg);
  --danger: var(--red);
  --danger-bg: rgba(248,81,73,0.1);
  --warning: var(--warn);
  --info: var(--blue);
  --surface-1: var(--bg-deep);
  --surface-2: var(--bg-base);
  --surface-3: var(--bg-card);
  --surface-hover: var(--bg-hover);
  --on-surface: var(--text);
  --on-surface-muted: var(--text-muted);
  --on-surface-dim: var(--text-dim);
  --border-default: var(--border);
  --radius-lg: var(--radius);
  --radius-md: var(--radius-sm);

  /* Z-index layers (use these in new code) */
  --z-content: 1;
  --z-tooltip: 100;
  --z-overlay: 50;
  --z-drawer: 500;
  --z-modal: 600;
  --z-modal-toolbar: 610;
  --z-floating-panel: 700;
  --z-context-menu: 800;
  --z-context-sub: 810;
  --z-confirm-modal: 850;
  --z-welcome-modal: 860;
  --z-toast: 900;
  --z-unlock: 900;
}
[data-theme="light"] {
  --bg-deep: #f0f9ff;
  --bg-base: #ffffff;
  --bg-card: #f8fbff;
  --bg-hover: #e0f2fe;
  --border: #cbd5e1;
  --border-light: #94a3b8;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --green: #10b981;
  --green-bg: rgba(16,185,129,0.12);
  --red: #dc2626;
  --warn: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --purple-bg: rgba(139,92,246,0.12);
  /* Gradient presets for light theme */
  --gradient-body: linear-gradient(135deg, #f0f9ff 0%, #f0f4ff 50%, #f5f3ff 100%);
  --gradient-sidebar: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  --gradient-surface: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  --gradient-card: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
  --gradient-item: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  --gradient-item-hover: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  --gradient-workspace: linear-gradient(135deg, #f0f9ff 0%, #f0f4ff 100%);
}
* { margin:0; padding:0; box-sizing:border-box; }
html { height:100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background:var(--bg-deep); color:var(--text); height:100%; min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; overflow:hidden; }
[data-theme="light"] body { background: var(--gradient-body); }
[data-theme="light"] .toolbar-panel { background: var(--gradient-sidebar); }
[data-theme="light"] .tool-sidebar { background: var(--gradient-sidebar); }
[data-theme="light"] .right-panel { background: var(--gradient-sidebar); }
[data-theme="light"] .cp-workspace { background: var(--gradient-workspace); }
[data-theme="light"] .cp-toolbar { background: var(--gradient-surface); }
[data-theme="light"] .cp-bottom-bar { background: var(--gradient-surface); }
[data-theme="light"] .panel-card { background: var(--gradient-card); }
[data-theme="light"] .lp-pl-item { background: var(--gradient-item); }
[data-theme="light"] .history-item { background: var(--gradient-item); border-color: rgba(0,0,0,0.04); }
[data-theme="light"] .pl-item { background: var(--gradient-item); }
[data-theme="light"] .lp-pl-item:hover { background: var(--gradient-item-hover); }
[data-theme="light"] .history-item:hover { background: var(--gradient-item-hover); border-color: rgba(100,150,255,0.2); }
[data-theme="light"] .pl-item:hover { background: var(--gradient-item-hover); }
button { font-family:inherit; border:none; cursor:pointer; background:none; color:inherit; }
button:focus-visible, [role="button"]:focus-visible, select:focus-visible, a:focus-visible { outline:2px solid var(--green); outline-offset:2px; }
input:focus-visible, textarea:focus-visible { outline:none; } /* inputs use border-color change instead */
input, select, textarea { font-family:inherit; }

/* ===== 客服联系侧边吸附按钮 ===== */
.cs-fab {
  position: fixed;
  right: 0;
  bottom: 80px;
  width: 26px;
  padding: 6px 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: linear-gradient(180deg, var(--green), #2ea043);
  box-shadow: -2px 0 8px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  z-index: var(--z-floating-panel);
  transition: width .2s ease, box-shadow .2s ease;
  color: #fff;
}
.cs-fab:hover {
  width: 30px;
  box-shadow: -3px 0 12px rgba(0,0,0,0.4);
}
.cs-fab svg { width: 14px; height: 14px; }
.cs-fab-label {
  font-size: 9px;
  font-weight: 600;
  writing-mode: vertical-rl;
  letter-spacing: 1px;
  line-height: 1;
}

/* 客服弹窗 */
.cs-popup {
  position: fixed;
  right: 38px;
  bottom: 80px;
  transform: translateX(8px) scale(0.96);
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: var(--z-floating-panel);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.cs-popup.show {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}
.cs-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.cs-popup-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.cs-popup-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}
.cs-popup-close:hover { background: var(--bg-hover); color: var(--text); }
.cs-popup-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.cs-qr-section { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cs-qr-img {
  width: 160px; height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
}
.cs-qr-tip { font-size: 12px; color: var(--text-muted); }
.cs-contact-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.cs-contact-label { font-size: 13px; color: var(--text-muted); }
.cs-contact-value { font-size: 13px; color: var(--text); font-weight: 500; }
.cs-copy-btn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--green-bg);
  color: var(--green);
  cursor: pointer;
  white-space: nowrap;
}
.cs-copy-btn:hover { background: var(--green); color: #fff; }

/* ===== Utility Classes ===== */
.u-flex-1 { flex: 1; }
.u-hidden { display: none !important; }
.u-sr-only { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.u-btn-row-padding { padding: 12px 14px 0 2px; }
