:root {
  /* —— 基础表面 / 背景 —— */
  --apple-bg: #f5f6f8;
  --apple-bg-elevated: #fbfbfd;
  --apple-panel: rgba(255, 255, 255, 0.72);
  --apple-panel-strong: rgba(255, 255, 255, 0.88);
  --apple-glass: rgba(255, 255, 255, 0.62);
  --apple-glass-border: rgba(255, 255, 255, 0.55);

  /* —— 描边 / 分隔 —— */
  --apple-line: rgba(15, 23, 42, 0.08);
  --apple-line-soft: rgba(15, 23, 42, 0.05);
  --apple-line-strong: rgba(15, 23, 42, 0.14);

  /* —— 多层阴影体系（ambient + key，带色相、更柔和） —— */
  --apple-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --apple-shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
  --apple-shadow: 0 20px 50px rgba(15, 23, 42, 0.10);
  --apple-shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --apple-shadow-lg: 0 32px 70px rgba(15, 23, 42, 0.14);
  --apple-shadow-blue: 0 12px 30px rgba(0, 113, 227, 0.18);

  /* —— 圆角体系 —— */
  --apple-radius-xl: 24px;
  --apple-radius-lg: 20px;
  --apple-radius-md: 16px;
  --apple-radius-sm: 12px;
  --apple-radius-xs: 10px;

  /* —— 文字 —— */
  --apple-text-1: #111114;
  --apple-text-2: #3c3c43;
  --apple-text-3: #6e6e73;
  --apple-text-4: #8a8a90;

  /* —— 强调色与梯度 —— */
  --apple-accent: #0071e3;
  --apple-accent-hover: #0077ed;
  --apple-accent-press: #005bbd;
  --apple-accent-soft: rgba(0, 113, 227, 0.1);
  --apple-accent-gradient: linear-gradient(135deg, #0a84ff 0%, #0060df 100%);

  /* —— 状态色 —— */
  --apple-green: #34c759;
  --apple-green-soft: rgba(52, 199, 89, 0.12);
  --apple-red: #ff3b30;
  --apple-red-soft: rgba(255, 59, 48, 0.12);
  --apple-orange: #ff9f0a;
  --apple-orange-soft: rgba(255, 159, 10, 0.14);
  --apple-purple: #af52de;
  --apple-purple-soft: rgba(175, 82, 222, 0.12);

  /* —— 动效 —— */
  --apple-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --apple-ease-soft: cubic-bezier(0.25, 0.8, 0.25, 1);
  --apple-dur-fast: 0.18s;
  --apple-dur: 0.3s;
  --apple-dur-slow: 0.5s;

  /* —— 聚焦环 —— */
  --apple-ring: 0 0 0 3px rgba(0, 113, 227, 0.28);

  /* —— 中性色阶 —— */
  --apple-neutral-50: #fbfbfd;
  --apple-neutral-100: #f2f3f5;
  --apple-neutral-200: #e8eaed;

  /* —— 组件共享 token（被多处内联样式引用，统一在此定义以保证桌面端一致） —— */
  --apple-badge-bg: rgba(0, 113, 227, 0.1);
  --apple-icon-bg: rgba(15, 23, 42, 0.05);
  --apple-border: var(--apple-line);
}

/* 修复下拉框在弹窗中的层级问题 */
.apple-select-dropdown-fix {
  z-index: 10005 !important;
}
.arco-select-dropdown {
  z-index: 10005 !important;
}
.arco-tree-select-dropdown {
  z-index: 10005 !important;
}
.arco-modal-wrapper {
  z-index: 10005; /* Fallback for general modals if needed */
}
.arco-message-wrapper {
  z-index: 10010 !important;
}

/* 钉钉免登加载动画 */
.apple-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 122, 255, 0.2);
  border-radius: 50%;
  border-top-color: #007AFF;
  animation: apple-spin 1s ease-in-out infinite;
}

@keyframes apple-spin {
  to { transform: rotate(360deg); }
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(0, 113, 227, 0.06), transparent 30%),
    radial-gradient(circle at 85% 5%, rgba(0, 113, 227, 0.04), transparent 22%),
    linear-gradient(180deg, #f8f9fb 0%, #eef1f5 100%);
  color: var(--apple-text-1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

#root {
  min-height: 100vh;
}

@media (max-width: 768px) {
  .apple-custom-modal {
    width: 90vw !important;
    max-height: 85vh !important;
    height: auto !important;
  }
  
  .apple-custom-modal-inner {
    flex-direction: column !important;
    overflow-y: auto !important;
  }

  .apple-settings-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 16px !important;
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    gap: 8px;
  }

  .apple-settings-sidebar > div {
    white-space: nowrap;
    margin-bottom: 0 !important;
    padding: 6px 12px !important;
  }

  .apple-settings-content {
    padding: 16px !important;
  }

  .apple-custom-drawer {
    width: 100% !important;
    height: 85vh !important;
    bottom: 0;
    top: auto !important;
    border-radius: 24px 24px 0 0 !important;
  }
  
  .apple-drawer-name {
    font-size: 20px !important;
  }
  
  .apple-settings-form .arco-form-item-content {
    flex: 1;
    min-width: 0;
  }
  
  .apple-settings-form .arco-form-item-label-col {
    padding-right: 8px !important;
  }

  .apple-settings-form .arco-form-item-content > div {
    justify-content: flex-end !important;
  }
  
  .arco-modal.apple-custom-modal {
    width: 90vw !important;
  }
}

/* ============================================================
   全局质感增强（设计精修 · 不改动任何 JS 逻辑）
   ============================================================ */

/* 键盘焦点可见环：可达性底线 */
:focus-visible {
  outline: none;
  box-shadow: var(--apple-ring);
  border-radius: var(--apple-radius-xs);
}

/* 滚动条美化（WebKit / Blink） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.16);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.28);
  background-clip: content-box;
}

/* 入场 / 悬浮动效 keyframes */
@keyframes appleFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes appleCardEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes appleShimmer {
  0%   { background-position: -468px 0; }
  100% { background-position: 468px 0; }
}

/* 通用入场工具类（可选由组件添加） */
.apple-reveal { animation: appleFadeUp 0.6s var(--apple-ease) both; }
.apple-reveal-delay-1 { animation-delay: 0.06s; }
.apple-reveal-delay-2 { animation-delay: 0.12s; }
.apple-reveal-delay-3 { animation-delay: 0.18s; }
.apple-reveal-delay-4 { animation-delay: 0.24s; }

/* 尊重 prefers-reduced-motion：关闭非必要动效（可达性底线） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
