/* =====================================================================
   PhotoStudio · 设计系统 (Design System)
   ---------------------------------------------------------------------
   加法式样式层，依赖 style.css 的 :root 品牌令牌（--bg/--primary 等）。
   本文件只「新增」：比例令牌、ds-* 组件、响应式工具类、移动端抽屉导航。
   不覆盖 style.css 既有组件样式，故对线上应用零回归。
   引入顺序：<link rel="stylesheet" href="/style.css">
             <link rel="stylesheet" href="/design-system.css">
   ===================================================================== */

/* ─── 1. 设计令牌：比例与层级 ─────────────────────────────────── */
:root {
  /* 间距比例（4 的倍数） */
  --ds-space-0: 0;
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-space-12: 48px;
  --ds-space-16: 64px;

  /* 字号比例 */
  --ds-text-xs: 12px;
  --ds-text-sm: 13px;
  --ds-text-base: 14px;
  --ds-text-md: 15px;
  --ds-text-lg: 16px;
  --ds-text-xl: 20px;
  --ds-text-2xl: 24px;
  --ds-text-3xl: 30px;
  --ds-leading-tight: 1.3;
  --ds-leading-normal: 1.55;
  --ds-weight-normal: 400;
  --ds-weight-medium: 500;
  --ds-weight-semibold: 600;
  --ds-weight-bold: 700;

  /* 圆角比例 */
  --ds-radius-xs: 4px;
  --ds-radius-sm: 6px;
  --ds-radius-md: 8px;
  --ds-radius-lg: 12px;
  --ds-radius-xl: 16px;
  --ds-radius-2xl: 20px;
  --ds-radius-full: 999px;

  /* 阴影 / 层级感 */
  --ds-shadow-xs: 0 1px 2px rgba(16, 24, 40, .06);
  --ds-shadow-sm: 0 2px 8px rgba(16, 24, 40, .08);
  --ds-shadow-md: 0 6px 18px rgba(16, 24, 40, .10);
  --ds-shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --ds-shadow-xl: 0 20px 48px rgba(16, 24, 40, .18);
  --ds-ring: 0 0 0 3px rgba(79, 70, 229, .18);

  /* z-index 层级 */
  --ds-z-base: 1;
  --ds-z-sticky: 20;
  --ds-z-drawer: 60;
  --ds-z-overlay: 70;
  --ds-z-toast: 90;
  --ds-z-tooltip: 100;

  /* 动效 */
  --ds-motion-fast: 140ms;
  --ds-motion-base: 200ms;
  --ds-motion-slow: 320ms;
  --ds-ease: cubic-bezier(.4, 0, .2, 1);
  --ds-ease-out: cubic-bezier(.16, 1, .3, 1);

  /* 布局容器 */
  --ds-container: 1200px;

  /* 中性灰阶（与品牌令牌互补） */
  --ds-neutral-50: #f8fafc;
  --ds-neutral-100: #f1f5f9;
  --ds-neutral-200: #e2e8f0;
  --ds-neutral-300: #cbd5e1;
  --ds-neutral-400: #94a3b8;
  --ds-neutral-500: #64748b;
  --ds-neutral-600: #475569;
  --ds-neutral-700: #334155;
  --ds-neutral-800: #1e293b;
  --ds-neutral-900: #0f172a;
}

/* 全局可访问性：键盘聚焦环 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary, #4f46e5);
  outline-offset: 2px;
  border-radius: var(--ds-radius-xs);
}

/* 尊重「减少动效」偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── 2. 布局工具类 ─────────────────────────────────────────── */
.ds-container { width: 100%; max-width: var(--ds-container); margin-inline: auto; }
.ds-stack { display: flex; flex-direction: column; gap: var(--ds-space-4); }
.ds-stack-sm { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-row { display: flex; align-items: center; gap: var(--ds-space-3); }
.ds-row-wrap { display: flex; align-items: center; gap: var(--ds-space-3); flex-wrap: wrap; }
.ds-grid { display: grid; gap: var(--ds-space-4); }
.ds-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ds-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ds-between { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-3); }
.ds-center { display: flex; align-items: center; justify-content: center; }
.ds-wrap { flex-wrap: wrap; }
.ds-grow { flex: 1 1 auto; min-width: 0; }
.ds-muted { color: var(--text-dim); }
.ds-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 间距工具 */
.ds-p-0 { padding: 0; } .ds-p-2 { padding: var(--ds-space-2); }
.ds-p-3 { padding: var(--ds-space-3); } .ds-p-4 { padding: var(--ds-space-4); }
.ds-p-5 { padding: var(--ds-space-5); } .ds-p-6 { padding: var(--ds-space-6); }
.ds-mt-2 { margin-top: var(--ds-space-2); } .ds-mt-3 { margin-top: var(--ds-space-3); }
.ds-mt-4 { margin-top: var(--ds-space-4); } .ds-mb-3 { margin-bottom: var(--ds-space-3); }
.ds-mb-4 { margin-bottom: var(--ds-space-4); }

/* 响应式显隐 */
.ds-only-mobile { display: none; }
.ds-only-desktop { display: initial; }
@media (max-width: 768px) {
  .ds-only-mobile { display: initial; }
  .ds-only-desktop { display: none; }
  .ds-grid-2, .ds-grid-3, .ds-grid-4 { grid-template-columns: 1fr; }
}

/* ─── 3. 基础组件（视觉与 style.css 一致，作为设计系统原语） ───── */
/* 按钮额外变体（基础 .btn / .btn-secondary / .btn-danger 由 style.css 提供） */
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius, 8px);
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; cursor: pointer;
  font-weight: var(--ds-weight-medium); transition: background var(--ds-motion-fast) var(--ds-ease), color var(--ds-motion-fast) var(--ds-ease);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius, 8px);
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: all var(--ds-motion-fast) var(--ds-ease);
}
.btn-icon:hover { background: var(--border); color: var(--text); }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px;
  margin: -7px 0 0 -7px; border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff; border-radius: 50%; animation: ds-spin .6s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* 开关 Switch */
.ds-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.ds-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-switch .track {
  width: 40px; height: 22px; border-radius: var(--ds-radius-full);
  background: var(--ds-neutral-300); transition: background var(--ds-motion-base) var(--ds-ease);
  position: relative; flex-shrink: 0;
}
.ds-switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; box-shadow: var(--ds-shadow-xs);
  transition: transform var(--ds-motion-base) var(--ds-ease-out);
}
.ds-switch input:checked + .track { background: var(--primary); }
.ds-switch input:checked + .track::after { transform: translateX(18px); }
.ds-switch input:focus-visible + .track { box-shadow: var(--ds-ring); }
.ds-switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* 分段控制器 Segmented */
.ds-segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius, 8px);
}
.ds-segmented button {
  border: none; background: transparent; color: var(--text-dim);
  padding: 6px 14px; border-radius: var(--radius-sm, 6px); cursor: pointer;
  font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium);
  transition: all var(--ds-motion-fast) var(--ds-ease);
}
.ds-segmented button.active {
  background: var(--bg-2); color: var(--primary);
  box-shadow: var(--ds-shadow-xs);
}

/* 进度条 Progress */
.ds-progress { height: 8px; border-radius: var(--ds-radius-full); background: var(--bg-3); overflow: hidden; }
.ds-progress > i {
  display: block; height: 100%; border-radius: var(--ds-radius-full);
  background: linear-gradient(90deg, var(--primary), #a78bfa);
  transition: width var(--ds-motion-slow) var(--ds-ease);
}

/* 提示条 Alert */
.ds-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius, 8px);
  border: 1px solid var(--border); background: var(--bg-2); font-size: var(--ds-text-sm);
}
.ds-alert .ic { flex-shrink: 0; line-height: 1.4; }
.ds-alert.alert-info { background: rgba(56, 189, 248, .10); border-color: rgba(56, 189, 248, .35); color: #0369a1; }
.ds-alert.alert-success { background: rgba(34, 197, 94, .10); border-color: rgba(34, 197, 94, .35); color: #15803d; }
.ds-alert.alert-warning { background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .35); color: #b45309; }
.ds-alert.alert-danger { background: rgba(239, 68, 68, .10); border-color: rgba(239, 68, 68, .35); color: #b91c1c; }

/* 骨架屏 Skeleton */
.ds-skeleton {
  display: block; border-radius: var(--ds-radius-sm);
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-2) 37%, var(--bg-3) 63%);
  background-size: 400% 100%; animation: ds-shimmer 1.4s ease infinite;
}
@keyframes ds-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* 空状态 Empty */
.ds-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.ds-empty .em { font-size: 40px; margin-bottom: 12px; opacity: .8; }
.ds-empty h4 { font-size: var(--ds-text-lg); color: var(--text-dim); margin-bottom: 6px; font-weight: var(--ds-weight-semibold); }
.ds-empty p { font-size: var(--ds-text-sm); max-width: 320px; line-height: var(--ds-leading-normal); }

/* 统计卡 Stat */
.ds-stat {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg, 12px);
  padding: 16px 18px; box-shadow: var(--shadow, var(--ds-shadow-sm));
}
.ds-stat .label { font-size: var(--ds-text-xs); color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.ds-stat .value { font-size: var(--ds-text-2xl); font-weight: var(--ds-weight-bold); margin-top: 6px; letter-spacing: .5px; }
.ds-stat .delta { font-size: var(--ds-text-xs); margin-top: 4px; }
.ds-stat .delta.up { color: var(--success); }
.ds-stat .delta.down { color: var(--danger); }

/* 头像组 Avatar group */
.ds-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: var(--ds-weight-semibold); font-size: var(--ds-text-sm);
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
}
.ds-avatar-group { display: inline-flex; }
.ds-avatar-group .ds-avatar { border: 2px solid var(--bg-2); margin-left: -8px; }
.ds-avatar-group .ds-avatar:first-child { margin-left: 0; }

/* 加载指示 Spinner */
.ds-spinner {
  width: 22px; height: 22px; border: 2px solid var(--bg-3);
  border-top-color: var(--primary); border-radius: 50%;
  animation: ds-spin .7s linear infinite; display: inline-block;
}

/* ─── 4. 交互组件 ───────────────────────────────────────────── */
/* Toast 通知 */
.ds-toast-region {
  position: fixed; z-index: var(--ds-z-toast); top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.ds-toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius, 8px);
  background: var(--bg-2); border: 1px solid var(--border); box-shadow: var(--ds-shadow-lg);
  font-size: var(--ds-text-sm); color: var(--text);
  animation: ds-toast-in var(--ds-motion-base) var(--ds-ease-out);
}
.ds-toast.leaving { animation: ds-toast-out var(--ds-motion-base) var(--ds-ease) forwards; }
.ds-toast .ic { flex-shrink: 0; font-size: 15px; line-height: 1.4; }
.ds-toast .body { flex: 1; min-width: 0; }
.ds-toast .title { font-weight: var(--ds-weight-semibold); margin-bottom: 2px; }
.ds-toast .msg { color: var(--text-dim); line-height: var(--ds-leading-normal); word-break: break-word; }
.ds-toast .close { flex-shrink: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.ds-toast .close:hover { color: var(--text); }
.ds-toast.t-info .ic { color: #0ea5e9; }
.ds-toast.t-success .ic { color: var(--success); }
.ds-toast.t-warning .ic { color: var(--warning); }
.ds-toast.t-danger .ic { color: var(--danger); }
.ds-toast.t-success { border-color: rgba(34, 197, 94, .4); }
.ds-toast.t-warning { border-color: rgba(245, 158, 11, .4); }
.ds-toast.t-danger { border-color: rgba(239, 68, 68, .4); }
@keyframes ds-toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes ds-toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Drawer 抽屉（侧滑面板） */
.ds-drawer-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: var(--ds-z-overlay); opacity: 0; visibility: hidden;
  transition: opacity var(--ds-motion-base) var(--ds-ease), visibility var(--ds-motion-base);
}
.ds-drawer-scrim.open { opacity: 1; visibility: visible; }
.ds-drawer {
  position: fixed; top: 0; bottom: 0; width: min(380px, 88vw);
  background: var(--bg-2); z-index: var(--ds-z-drawer);
  display: flex; flex-direction: column; box-shadow: var(--ds-shadow-xl);
  transition: transform var(--ds-motion-base) var(--ds-ease);
}
.ds-drawer.left { left: 0; transform: translateX(-100%); border-right: 1px solid var(--border); }
.ds-drawer.right { right: 0; transform: translateX(100%); border-left: 1px solid var(--border); }
.ds-drawer.open { transform: translateX(0); }
.ds-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.ds-drawer-head h3 { font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semibold); }
.ds-drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.ds-drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Tabs 选项卡 */
.ds-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ds-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: 10px 14px; font-size: var(--ds-text-sm); color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: var(--ds-weight-medium);
  transition: color var(--ds-motion-fast) var(--ds-ease), border-color var(--ds-motion-fast) var(--ds-ease);
}
.ds-tab:hover { color: var(--text); }
.ds-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.ds-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: var(--ds-radius-xs); }
.ds-tabpanel { padding-top: 16px; }
.ds-tabpanel[hidden] { display: none; }

/* Dropdown 下拉菜单 */
.ds-dropdown { position: relative; display: inline-block; }
.ds-menu {
  position: absolute; z-index: var(--ds-z-overlay); min-width: 180px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius, 8px);
  box-shadow: var(--ds-shadow-lg); padding: 6px; margin-top: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--ds-motion-fast) var(--ds-ease), transform var(--ds-motion-fast) var(--ds-ease), visibility var(--ds-motion-fast);
}
.ds-dropdown.open .ds-menu { opacity: 1; visibility: visible; transform: none; }
.ds-menu.align-right { right: 0; left: auto; }
.ds-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-sm, 6px); cursor: pointer;
  background: none; border: none; color: var(--text); font-size: var(--ds-text-sm);
  transition: background var(--ds-motion-fast) var(--ds-ease);
}
.ds-menu-item:hover, .ds-menu-item:focus-visible { background: var(--bg-3); outline: none; }
.ds-menu-item.danger { color: var(--danger); }
.ds-menu-item.danger:hover { background: rgba(239, 68, 68, .1); }
.ds-menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Tooltip 提示 */
.ds-tooltip {
  position: fixed; z-index: var(--ds-z-tooltip); max-width: 240px;
  background: var(--ds-neutral-900); color: #fff; font-size: var(--ds-text-xs);
  padding: 6px 10px; border-radius: var(--ds-radius-sm); pointer-events: none;
  box-shadow: var(--ds-shadow-md); opacity: 0; transform: translateY(2px);
  transition: opacity var(--ds-motion-fast) var(--ds-ease), transform var(--ds-motion-fast) var(--ds-ease);
}
.ds-tooltip.show { opacity: 1; transform: none; }

/* ─── 5. 移动端抽屉导航增强（适配现有 .sidebar） ──────────────── */
/* 汉堡按钮：仅移动端可见；由 ui.js 在检测到 .sidebar 时注入 */
.ds-nav-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 30;
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius, 8px);
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--ds-shadow-sm); cursor: pointer;
}
.ds-nav-toggle svg { width: 20px; height: 20px; }
.ds-nav-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 55; opacity: 0; visibility: hidden; transition: opacity var(--ds-motion-base) var(--ds-ease), visibility var(--ds-motion-base);
}
.ds-nav-scrim.open { opacity: 1; visibility: visible; }

@media (max-width: 768px) {
  /* Darkroom 风格：手机端左侧固定竖排图标导航，始终显示，不用汉堡抽屉 */
  .ds-nav-toggle { display: none; }
  .ds-nav-scrim { display: none; }
  .sidebar {
    display: flex !important; flex-direction: column; align-items: stretch;
    width: 62px !important; max-width: 62px; padding: 8px 0;
    transform: none; transition: none; box-shadow: none; z-index: auto;
  }
  .app-layout.nav-open .sidebar { transform: none; }
  .main { margin-left: 62px !important; max-width: calc(100vw - 62px) !important; padding: 12px 10px !important; }
}

/* ─── 6. 表单组件（设计系统原语，加法式，不覆盖 style.css .field） ── */
/* 与 style.css 的 .field 并存；本套以 ds- 命名、基于设计令牌，供新页面 / 重构使用 */
.ds-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--ds-space-4); }
.ds-field-label, .ds-field > label { font-size: var(--ds-text-sm); color: var(--text-dim); font-weight: var(--ds-weight-medium); }
.ds-hint { font-size: var(--ds-text-xs); color: var(--text-muted); line-height: 1.45; }
.ds-error { font-size: var(--ds-text-xs); color: var(--danger); line-height: 1.45; font-weight: var(--ds-weight-medium); }

.ds-input, .ds-textarea, .ds-select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-light); border-radius: var(--radius, 8px);
  font-size: var(--ds-text-base); line-height: 1.45;
  transition: border-color var(--ds-motion-fast) var(--ds-ease), box-shadow var(--ds-motion-fast) var(--ds-ease);
}
.ds-textarea { resize: vertical; min-height: 84px; }
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--text-muted); }
.ds-input:focus, .ds-textarea:focus, .ds-select:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ds-ring);
}
/* 无效态：字段级或控件级均可触发 */
.ds-input.invalid, .ds-textarea.invalid, .ds-select.invalid,
.ds-field.invalid .ds-input, .ds-field.invalid .ds-textarea, .ds-field.invalid .ds-select {
  border-color: var(--danger); background: rgba(239, 68, 68, .06);
}
.ds-field.invalid > label { color: var(--danger); }

/* 只读展示：用于详情页 label/value 对 */
.ds-field.is-readonly { margin-bottom: var(--ds-space-3); }
.ds-field.is-readonly:last-child { margin-bottom: 0; }
.ds-field-value {
  font-size: var(--ds-text-base); color: var(--text); line-height: 1.5;
  min-height: 24px; word-break: break-word;
}
.ds-field-value a { color: var(--primary); text-decoration: none; }
.ds-field-value a:hover { text-decoration: underline; }
.ds-field-value .dim { color: var(--text-muted); }

/* 输入组：前后缀 / 按钮 */
.ds-input-group { display: flex; align-items: stretch; gap: 8px; }
.ds-input-group .ds-input { flex: 1 1 auto; min-width: 0; }
.ds-input-group .ds-addon {
  display: inline-flex; align-items: center; padding: 0 12px;
  background: var(--bg-3); border: 1px solid var(--border-light); border-radius: var(--radius, 8px);
  color: var(--text-dim); font-size: var(--ds-text-sm); white-space: nowrap;
}
.ds-input-group .btn { flex-shrink: 0; }

/* 自定义复选 / 单选（保留原生 input，保证键盘与读屏可访问） */
.ds-check, .ds-radio {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--ds-text-base); color: var(--text); cursor: pointer; user-select: none;
}
.ds-check input, .ds-radio input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; cursor: pointer; }

/* 选择胶囊（单选 / 多选视觉，内部含 input） */
.ds-choice {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-full); color: var(--text); cursor: pointer;
  font-size: var(--ds-text-sm); transition: all var(--ds-motion-fast) var(--ds-ease);
}
.ds-choice:hover { border-color: var(--primary); }
.ds-choice input { accent-color: var(--primary); margin: 0; }
.ds-choice:has(input:checked) { background: rgba(79, 70, 229, .10); border-color: var(--primary); color: var(--primary); font-weight: var(--ds-weight-medium); }
.ds-choice-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ─── 7. 模态框（设计系统版 ds-modal，与 style.css .modal 并存） ─── */
.ds-modal-mask {
  position: fixed; inset: 0; z-index: var(--ds-z-overlay);
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  opacity: 0; transition: opacity var(--ds-motion-base) var(--ds-ease);
}
.ds-modal-mask.open { opacity: 1; }
.ds-modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 80px); overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px); box-shadow: var(--ds-shadow-xl);
  transform: translateY(8px) scale(.98); opacity: 0;
  transition: transform var(--ds-motion-base) var(--ds-ease-out), opacity var(--ds-motion-base) var(--ds-ease-out);
}
.ds-modal-mask.open .ds-modal { transform: none; opacity: 1; }
.ds-modal.wide { max-width: 760px; }
.ds-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.ds-modal-head h3 { font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semibold); }
.ds-modal-body { padding: 20px; }
.ds-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ─── 8. 响应式网格增强 ─────────────────────────────────────── */
/* auto-fit 自适应网格：通过 --ds-min 控制最小列宽（默认 220px） */
.ds-grid-auto {
  display: grid; gap: var(--ds-space-4);
  grid-template-columns: repeat(auto-fit, minmax(var(--ds-min, 220px), 1fr));
}
/* 平板中间态：在大屏多列、手机单列之间增加 2 列过渡（原仅 768 单断点） */
@media (max-width: 1024px) {
  .ds-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 触控目标：移动端确保 ≥44px 可点区域；输入字号 16px 防止 iOS 聚焦缩放 */
@media (max-width: 768px) {
  .ds-input, .ds-select, .ds-textarea { font-size: 16px; }
  .ds-choice, .ds-segmented button, .ds-tab, .ds-menu-item, .ds-check, .ds-radio { min-height: 44px; }
}

/* ─── 9. 订单详情页「顾客信息」Tab（对齐 darkroom 参考） ─── */
.customer-tab {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .customer-tab { grid-template-columns: 1fr; }
}
.customer-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.customer-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.customer-section-body { padding: 20px; }
.customer-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.customer-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 600;
}
.customer-meta { flex: 1; min-width: 0; display: grid; gap: 10px; }
.customer-meta-row { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.customer-meta-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.customer-meta-value { font-size: 13px; color: var(--text); word-break: break-all; }
.customer-fields { display: grid; gap: 12px; }
.customer-field { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.customer-field-label {
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
  min-width: 72px; text-align: right;
}
.customer-field-value { font-size: 13px; color: var(--text); word-break: break-all; flex: 1; min-width: 0; }
.customer-field-value a { color: var(--link); }
.customer-field-value a:hover { text-decoration: underline; }
.customer-field-value .dim { color: var(--text-muted); }
.customer-tag {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
}
.customer-tag-unbound { background: var(--bg-3); color: var(--text-dim); border: 1px solid var(--border); }
.customer-tag-bound { background: rgba(22,163,74,0.12); color: var(--success); border: 1px solid rgba(22,163,74,0.25); }
.customer-mini-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 600; margin-right: 4px; vertical-align: middle;
}
.customer-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.customer-actions .btn { padding: 6px 12px; font-size: 12px; }
.customer-alert {
  background: rgba(217,119,6,0.10);
  border: 1px solid rgba(217,119,6,0.22);
  color: var(--text-dim);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 16px;
}