/* ==========================================================================
   Apple 组件皮肤层（v7.0.0）
   --------------------------------------------------------------------------
   覆盖面：外壳（侧栏/顶栏/导航）→ 按钮 → 表单 → 数据展示 → 浮层（弹窗/抽屉/
   下拉/Toast/提示）→ 新增 iOS 组件（Switch / Inset Grouped List / Apple Alert）。

   与 soft-ui.css 的区别：soft-ui 用**双向拟物阴影**做层次；这一层按 Apple 的做法
   ——**发丝描边（0.5px）+ 极浅大扩散阴影 + 毛玻璃材质**，按压反馈改成「变暗 + 微缩」
   而不是「阴影变内凹」。加载顺序必须在 soft-ui.css 之后。

   本层不新增 DOM 结构，也不改任何页面布局参数（尺寸/间距/栅格一律不动），
   只改颜色、圆角、阴影、材质、字体、动效曲线与按压态。
   ========================================================================== */

/* ==========================================================================
   1. 全局
   ========================================================================== */
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

::selection {
  background: rgba(0, 0, 0, 0.14);
  color: var(--text-primary);
}

[data-theme='dark'] ::selection {
  background: rgba(255, 255, 255, 0.22);
}

/* 焦点环：Apple 用「外扩软环」，不用描边变色 */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* 滚动条：细，Apple 式无轨道 */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

/* ==========================================================================
   2. 外壳：侧栏 / 顶栏 / 导航（毛玻璃 + 发丝线）
   ========================================================================== */
.app-sidebar {
  background: var(--sidebar-bg);
  border-right: var(--hairline) solid var(--sidebar-border);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  box-shadow: none;
}

.app-topbar {
  background: var(--topbar-bg);
  border-bottom: var(--hairline) solid var(--border-subtle);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  box-shadow: none;
}

.app-footer {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  border-top: var(--hairline) solid var(--border-subtle);
  background: transparent;
}

.brand-mark {
  background: var(--fill-brand);
  color: var(--text-on-brand);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.brand-title {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-subtitle {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
}

/* v7.1.0：侧栏标题改用 logos 里的 big 图（logo-title.png，透明底）。
   高度锁 20px，宽度自适应但不超过 152px（侧栏收起时会被裁掉，见 layout.css 的 is-collapsed） */
.brand-logo {
  display: block;
  height: 20px;
  width: auto;
  max-width: 152px;
  object-fit: contain;
  object-position: left center;
}

/* v7.1.0：品牌方块换成 logos 里的 small 图（图标），不再是一个纯色方块 + 图标字形 */
.brand-mark--image {
  background: transparent;
  box-shadow: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.brand-mark__logo {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* 侧栏折叠后只剩图标，标题图随之隐藏 */
.app-sidebar.is-collapsed .brand-logo {
  display: none;
}

.topbar-title {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.breadcrumbs {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* 导航项：Apple 侧栏（选中 = 浅灰药丸，无描边无阴影） */
.nav-link {
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--m-press) var(--ease-ios), color var(--m-press) var(--ease-ios);
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: none;
}

.nav-link.is-active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: none;
}

.nav-link__badge {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
  border-radius: var(--radius-full);
}

.nav-section-label {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-submenu .nav-link {
  color: var(--text-secondary);
}

/* 滑块（选中药丸）跟着导航走，改成浅灰药丸 */
.nav-glider {
  background: var(--bg-active);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.sidebar-user {
  background: var(--bg-muted);
  border-radius: var(--radius-lg);
  border: var(--hairline) solid var(--border-subtle);
}

.sidebar-user:hover {
  background: var(--bg-hover);
}

.sidebar-scrim {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
}

/* ==========================================================================
   3. 页面头
   ========================================================================== */
.page-header__title {
  font-weight: 700;
  letter-spacing: -0.028em;
  color: var(--text-primary);
}

.page-header__desc {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

/* ==========================================================================
   4. 按钮：Apple 四式（filled / tinted / gray / plain）+ 胶囊
   ========================================================================== */
.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: var(--radius-md);
  border: var(--hairline) solid transparent;
  box-shadow: none;
  transition:
    background-color var(--m-press) var(--ease-ios),
    opacity var(--m-press) var(--ease-ios),
    transform var(--m-press) var(--ease-ios),
    color var(--m-press) var(--ease-ios);
}

/* 按压 = iOS 式「变暗 + 微缩」，不做阴影内凹 */
.btn:active:not(:disabled) {
  transform: scale(0.975);
  opacity: 0.88;
}

.btn:disabled {
  opacity: 0.4;
  box-shadow: none;
}

/* 主按钮：纯黑填充（夜间反转为白） */
.btn--primary {
  background: var(--fill-brand);
  color: var(--text-on-brand);
  border-color: transparent;
  box-shadow: var(--shadow-xs);
}

.btn--primary:hover:not(:disabled) {
  background: var(--fill-brand-strong);
  box-shadow: var(--shadow-sm);
}

/* 次按钮：iOS 灰底按钮 */
.btn--secondary {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: transparent;
}

.btn--secondary:hover:not(:disabled) {
  background: var(--bg-active);
}

/* 幽灵按钮：透明 + 悬停浅灰 */
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 危险按钮：iOS 破坏性红填充 */
.btn--danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-xs);
}

.btn--danger:hover:not(:disabled) {
  filter: brightness(0.94);
}

/* 弱危险按钮：浅红底 + 红字 */
.btn--soft-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn--soft-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}

.btn--soft {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: transparent;
}

.btn--soft:hover:not(:disabled) {
  background: var(--bg-active);
}

/* 新增（v7）：胶囊按钮，Apple 的主行动按钮形态 */
.btn--capsule {
  border-radius: var(--radius-full);
  padding-inline: 20px;
}

/* 按钮里的波纹层在 Apple 语言里是多余的（按压反馈交给 opacity/scale） */
.btn .btn__ripple {
  display: none;
}

/* 图标按钮：圆形触达区，按压变暗 */
.icon-button {
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  background: transparent;
  box-shadow: none;
  transition: background var(--m-press) var(--ease-ios), color var(--m-press) var(--ease-ios);
}

.icon-button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: none;
}

.icon-button:active {
  background: var(--bg-active);
  transform: scale(0.94);
}

/* 行内操作 / 页码按钮 */
.row-action {
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  box-shadow: none;
}

.row-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-btn {
  border-radius: var(--radius-sm);
  border: var(--hairline) solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-shadow: none;
  transition: background var(--m-press) var(--ease-ios), color var(--m-press) var(--ease-ios);
}

.page-btn:hover:not(:disabled):not(.is-active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-btn.is-active {
  background: var(--fill-brand);
  color: var(--text-on-brand);
  border-color: transparent;
  font-weight: 600;
}

.pagination__info,
.pagination__ellipsis {
  color: var(--text-tertiary);
}

/* ==========================================================================
   5. 表单：输入框改为「白底 + 1px 描边 + 焦点软环」
   ========================================================================== */
.input,
.select,
.textarea {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: none;
  transition:
    border-color var(--m-press) var(--ease-ios),
    box-shadow var(--m-press) var(--ease-ios),
    background var(--m-press) var(--ease-ios);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--text-primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-muted);
  color: var(--text-tertiary);
  opacity: 1;
}

.field.is-invalid .input,
.field.is-invalid .select,
.field.is-invalid .textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0;
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.input-group {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.search-box .input {
  background: var(--bg-muted);
  border-color: transparent;
  border-radius: var(--radius-md);
}

.search-box .input:focus {
  background: var(--bg-surface);
  border-color: var(--border-default);
}

.search-box__icon {
  color: var(--text-tertiary);
}

/* 复选 / 单选：Apple 风格 —— 方形 6px 圆角 + 选中纯黑 */
.checkbox input,
.radio input {
  border: var(--hairline) solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: none;
  transition: background var(--m-press) var(--ease-ios), border-color var(--m-press) var(--ease-ios);
}

.checkbox input:checked,
.radio input:checked {
  background: var(--fill-brand);
  border-color: var(--fill-brand);
  box-shadow: none;
}

/* 开关：iOS Switch（51×31 轨道 + 27px 滑块，开启绿走 --success） */
.switch input {
  background: var(--bg-surface-sunken);
  border: var(--hairline) solid var(--border-subtle);
  box-shadow: none;
  transition: background var(--m-sheet) var(--ease-ios);
}

.switch input::after {
  background: #fff;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform var(--m-sheet) var(--ease-ios);
}

.switch input:checked {
  background: var(--success);
  border-color: transparent;
  box-shadow: none;
}

.switch input:checked::after {
  background: #fff;
}

/* 设置行 / 信息行：Inset Grouped List 的语言（44px、发丝分隔、右侧值） */
.setting-row,
.info-item {
  border-bottom: var(--hairline) solid var(--border-subtle);
  padding-block: 12px;
}

.setting-row:last-child,
.info-item:last-child {
  border-bottom: none;
}

.info-item__label,
.setting-row__desc {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.form-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* 标签 / 小徽章：胶囊 */
.chip {
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: var(--hairline) solid transparent;
  font-weight: 500;
  box-shadow: none;
}

.chip--brand {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: transparent;
}

/* ==========================================================================
   6. 数据展示：卡片 / 统计卡 / 表格 / 徽章 / 进度
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card--interactive:hover,
.group-card:hover,
.stat-card:hover {
  transform: none;
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}

.card--glass {
  background: var(--bg-glass);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border-color: var(--border-subtle);
}

.card--highlight {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-default);
}

.stat-card {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.stat-card__icon {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.stat-card__label {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card__value {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* 表格：灰表头 11px·600·字距 0.06em / 48px 行高 / 发丝分隔（WordPress 后台 + Apple 列表） */
.table-wrap {
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: none;
  overflow: hidden;
}

.table thead th {
  background: var(--bg-surface);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: var(--hairline) solid var(--border-default);
  padding-block: 10px;
}

.table tbody td {
  border-bottom: var(--hairline) solid var(--border-subtle);
  color: var(--text-primary);
  font-size: var(--text-sm);
  height: 48px;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background var(--m-press) var(--ease-ios);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table tbody tr.is-selected {
  background: var(--bg-active);
}

.table__number {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.table__desc {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.badge {
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 2px 8px;
  border: var(--hairline) solid transparent;
  box-shadow: none;
}

.score-pill {
  border-radius: var(--radius-full);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: none;
}

.trend-up {
  color: var(--success);
}

.trend-down {
  color: var(--danger);
}

.meter,
.bar-track {
  background: var(--bg-surface-sunken);
  border-radius: var(--radius-full);
  box-shadow: none;
  overflow: hidden;
}

.meter__fill,
.bar-fill {
  background: var(--fill-brand);
  border-radius: var(--radius-full);
}

.bar-row__label,
.bar-row__value {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.bar-row__value {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* 空状态 / 骨架 / 加载 */
.empty-state__icon {
  background: var(--bg-muted);
  color: var(--text-tertiary);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.empty-state__title {
  color: var(--text-primary);
  font-weight: 600;
}

.skeleton {
  background: var(--skeleton-base);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.spinner {
  border-color: var(--border-default);
  border-top-color: var(--text-primary);
}

.loading-overlay {
  background: color-mix(in srgb, var(--bg-app) 72%, transparent);
  backdrop-filter: var(--material-blur-thin);
  -webkit-backdrop-filter: var(--material-blur-thin);
}

/* 步骤 / 时间线 / 头像 / 键盘键 */
.step__marker {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: var(--hairline) solid var(--border-default);
  box-shadow: none;
}

.step.is-active .step__marker {
  background: var(--fill-brand);
  color: var(--text-on-brand);
  border-color: transparent;
}

.step__title {
  color: var(--text-primary);
  font-weight: 600;
}

.step__desc,
.timeline__time {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.timeline::before {
  background: var(--border-default);
}

.timeline__dot {
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  box-shadow: none;
}

.timeline__title {
  color: var(--text-primary);
  font-weight: 600;
}

.avatar {
  background: var(--bg-muted);
  color: var(--text-primary);
  font-weight: 600;
  border: var(--hairline) solid var(--border-subtle);
  box-shadow: none;
}

.kbd,
.file-pill,
.code-block {
  background: var(--bg-muted);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  box-shadow: none;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* 提示条：灰底 + 语义色边（Apple 的 notice 形态） */
.alert {
  border-radius: var(--radius-md);
  border: var(--hairline) solid var(--border-subtle);
  background: var(--bg-muted);
  box-shadow: none;
}

.alert__title {
  font-weight: 600;
  color: var(--text-primary);
}

/* 顶部进度条 */
.top-progress__bar {
  background: var(--text-primary);
  box-shadow: none;
}

/* ==========================================================================
   7. 浮层：弹窗（Dialog）/ 抽屉 / 下拉 / Toast / 提示
   ========================================================================== */
.overlay {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: var(--material-blur-thin);
  -webkit-backdrop-filter: var(--material-blur-thin);
}

.modal {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal__header {
  background: var(--bg-muted);
  border-bottom: var(--hairline) solid var(--border-subtle);
  padding-block: 14px;
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.modal__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* 头部图标：Apple 不用彩色圆底，用中性灰方块 */
.modal__icon {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.modal__icon--danger {
  color: var(--danger);
}

.modal__icon--warning {
  color: var(--warning);
}

.modal__icon--success {
  color: var(--success);
}

.modal__footer {
  background: var(--bg-surface);
  border-top: var(--hairline) solid var(--border-subtle);
  padding-block: 12px;
}

.drawer {
  background: var(--bg-surface);
  border-left: var(--hairline) solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
}

/* 下拉菜单：iOS 上下文菜单（毛玻璃 + 12px 圆角 + 44px 行） */
.dropdown__menu {
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}

.dropdown__item {
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-base);
  min-height: 36px;
  transition: background var(--m-press) var(--ease-ios);
}

.dropdown__item:hover {
  background: var(--bg-hover);
}

.dropdown__header {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dropdown__divider {
  background: var(--border-subtle);
  height: var(--hairline);
}

/* Toast：Apple 通知条 —— 顶部居中、毛玻璃、大圆角 */
.toast-stack {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(94vw, 420px);
}

.toast {
  pointer-events: auto;
  width: 100%;
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  padding: 12px 14px;
  animation: apple-toast-in var(--m-toast) var(--ease-ios) both;
}

.toast__icon {
  color: var(--text-primary);
  background: transparent;
  box-shadow: none;
}

.toast--success .toast__icon {
  color: var(--success);
}

.toast--error .toast__icon {
  color: var(--danger);
}

.toast--warning .toast__icon {
  color: var(--warning);
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.toast__detail {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.toast__timer {
  background: var(--border-strong);
}

.toast.is-leaving {
  animation: apple-toast-out var(--m-toast) var(--ease-ios) both;
}

@keyframes apple-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes apple-toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

/* 提示气泡 / 命令面板 */
.tooltip {
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
}

.command-palette__panel {
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.command-palette__input {
  border-bottom: var(--hairline) solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
}

.command-item {
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.command-item:hover,
.command-item.is-active {
  background: var(--bg-hover);
}

.command-item__hint {
  color: var(--text-tertiary);
}

/* 公告弹窗 / 公告横幅：Apple 通知卡 */
.ann-popup {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.ann-banner {
  background: var(--bg-muted);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.dropzone {
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--text-primary);
  background: var(--bg-active);
}

.dropzone__icon {
  color: var(--text-tertiary);
}

/* 分段控件（tabs）：iOS UISegmentedControl 的黑白版 */
.tabs {
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 2px;
}

.tab {
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  font-weight: 500;
  box-shadow: none;
  transition: background var(--m-press) var(--ease-ios), color var(--m-press) var(--ease-ios);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tab__count {
  background: var(--bg-active);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-weight: 600;
}

.tabs--underline .tab.is-active {
  background: transparent;
  box-shadow: none;
}

.tabs--underline .tab.is-active::after {
  background: var(--text-primary);
  border-radius: var(--radius-full);
}

/* ==========================================================================
   8. 新增 iOS 组件（v7）：分段标题 / Inset Grouped List / iOS Switch / 按钮组
   ========================================================================== */
.ios-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 18px 0 6px;
  padding-inline: 4px;
}

/* Inset Grouped List：容器圆角 + 行间发丝线（用 + 选择器，避免首行有线） */
.ios-group {
  background: var(--bg-surface);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-group);
  overflow: hidden;
}

.ios-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text-primary);
  font-size: var(--text-base);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: default;
}

/* 分隔线用 border 而不是伪元素：伪元素没有定位上下文时会乱跑，首行也容易多一条线 */
.ios-list-row + .ios-list-row {
  border-top: var(--hairline) solid var(--border-subtle);
}

a.ios-list-row,
button.ios-list-row {
  cursor: pointer;
  transition: background var(--m-press) var(--ease-ios);
}

a.ios-list-row:hover,
button.ios-list-row:hover {
  background: var(--bg-hover);
}

.ios-list-row:active {
  background: var(--bg-active);
}

.ios-list-row__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ios-list-row__value {
  color: var(--text-tertiary);
  font-size: var(--text-base);
}

.ios-list-row--destructive,
.ios-list-row--destructive .ios-list-row__label {
  color: var(--danger);
}

/* iOS Switch（独立版：不带 input::after，用显式 track/knob） */
.ios-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  width: 51px;
  height: 31px;
  cursor: pointer;
}

.ios-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.ios-switch__track {
  width: 51px;
  height: 31px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-sunken);
  box-shadow: inset 0 0 0 var(--hairline) var(--border-subtle);
  transition: background var(--m-sheet) var(--ease-ios);
  position: relative;
}

.ios-switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform var(--m-sheet) var(--ease-ios);
}

.ios-switch input:checked ~ .ios-switch__track {
  background: var(--success);
  box-shadow: none;
}

.ios-switch input:checked ~ .ios-switch__track::after {
  transform: translateX(20px);
}

.ios-switch input:focus-visible ~ .ios-switch__track {
  box-shadow: var(--shadow-focus);
}

/* ==========================================================================
   9. 用户中心窗口（.me-win，v7.1.0）
   --------------------------------------------------------------------------
   需求：「点击头像的用户中心卡片给我做成 DEMO 里的那种」。
   结构由 core/accountWindow.js 生成：
     .me-win > .me-win__head(手柄/标题/完成) + .me-win__scroll(账号头 + ios-group 列表)
   要点：可拖动（标题栏 cursor: grab）、拖动时抬升层级、入场动画播完锁死（is-entered）。
   窗口是**非模态**的：不锁背景滚动，点外部才关闭。
   ========================================================================== */
.me-win {
  position: fixed;
  z-index: 400;
  width: min(360px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: me-win-in var(--m-panel-in) var(--ease-ios) both;
}

/* 入场动画只播一次：拖动/换内容时不能再弹一次（名片窗口踩过同一个坑） */
.me-win.is-entered {
  animation: none;
}

.me-win.is-leaving {
  animation: me-win-out var(--m-panel-out) var(--ease-ios) both;
}

.me-win__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border-bottom: var(--hairline) solid var(--border-subtle);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.me-win.is-dragging .me-win__head {
  cursor: grabbing;
}

.me-win__grip {
  display: inline-grid;
  place-items: center;
  color: var(--text-tertiary);
  flex: none;
}

.me-win__title {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.me-win__done {
  flex: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--m-press) var(--ease-ios);
}

.me-win__done:hover {
  background: var(--bg-hover);
}

.me-win__done:active {
  background: var(--bg-active);
}

.me-win__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 14px;
}

/* ---------- 账号头 ---------- */
.me-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 4px 12px;
}

.me-account__avatar {
  width: 52px;
  height: 52px;
  font-size: var(--text-lg);
  flex: none;
}

.me-account__text {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.me-account__name {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-account__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.me-dot {
  width: 3px;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--text-tertiary);
  flex: none;
}

.me-account--skeleton .me-account__text {
  flex: 1;
}

/* ---------- 职务 / 奖项 标签 ---------- */
.me-meta {
  display: grid;
  gap: 8px;
  padding: 0 4px 12px;
}

.me-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.me-meta-row__label {
  flex: none;
  width: 32px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  padding-top: 3px;
}

.me-meta-row__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.me-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  border: var(--hairline) solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: 1.6;
  white-space: nowrap;
}

/* 奖项用一点琥珀语义色区分（仍在三支语义色范围内） */
.me-chip--award {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: transparent;
}

/* ---------- 列表行补充 ---------- */
.ios-list-row__icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  color: var(--text-secondary);
  flex: none;
}

.ios-list-row--destructive .ios-list-row__icon {
  color: var(--danger);
}

.me-row-chevron {
  display: inline-grid;
  place-items: center;
  color: var(--text-tertiary);
  flex: none;
}

.me-footnote {
  margin: 14px 0 0;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

@keyframes me-win-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes me-win-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* 手机上不做可拖动窗口：改成贴底的卡片，宽度占满（拖动在小屏上没有意义） */
@media (max-width: 640px) {
  .me-win {
    left: 12px !important;
    right: 12px;
    top: auto !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    width: auto;
    max-height: min(70vh, 520px);
  }

  .me-win__head {
    cursor: default;
    touch-action: auto;
  }
}

/* ==========================================================================
   11. 统一名片（v7.1.0）
   --------------------------------------------------------------------------
   需求：「全系统需要显示用户 id、用户名、batch_id、record_id，全部统一加名片显示」
         +「名片中增加撤销重做按钮（包括批量操作与单次操作）」。
   结构由 core/nameCard.js 生成：.name-card > 若干 .name-card__kv + .name-card__actions
   触发器 = 行内 .name-card-trigger（像普通文字，但可点）。
   ========================================================================== */
.name-card-trigger {
  appearance: none;
  border: 0;
  background: none;
  padding: 0 1px;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-bottom: 1px dashed var(--border-strong);
  border-radius: 2px;
  transition: background var(--m-press) var(--ease-ios), color var(--m-press) var(--ease-ios);
}

.name-card-trigger:hover {
  background: var(--bg-active);
  border-bottom-color: var(--text-primary);
}

.name-card-trigger:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.name-card {
  position: fixed;
  z-index: 500;
  width: min(330px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  animation: name-card-in var(--m-panel-in) var(--ease-ios) both;
}

.name-card.is-leaving {
  animation: name-card-out var(--m-panel-out) var(--ease-ios) both;
}

.name-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.name-card__head--compact {
  margin-bottom: 8px;
}

.name-card__avatar {
  width: 42px;
  height: 42px;
  flex: none;
}

.name-card__title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.name-card__name {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-card__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  min-width: 0;
}

/* 键值行：左固定标签宽度，右自适应（长内容换行，不撑破名片） */
.name-card__kv {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-top: var(--hairline) solid var(--border-subtle);
}

.name-card__kv:first-of-type {
  border-top: 0;
}

.name-card__kv-label {
  flex: none;
  width: 60px;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  padding-top: 2px;
}

.name-card__kv-value {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  word-break: break-word;
}

.name-card__chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

/* 批次里的成员摘要 */
.name-card__list {
  margin-top: 8px;
  border-top: var(--hairline) solid var(--border-subtle);
  padding-top: 8px;
  display: grid;
  gap: 4px;
}

.name-card__list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.name-card__list-row .truncate {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.name-card__list-state {
  flex: none;
  color: var(--success);
}

.name-card__list-state.is-off {
  color: var(--text-tertiary);
}

.name-card__list-more {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  padding-top: 2px;
}

/* 撤销 / 重做：右下角一排 */
.name-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: var(--hairline) solid var(--border-subtle);
}

.name-card__error {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: var(--text-sm);
  padding: 6px 0;
}

.name-card__foot {
  margin-top: 8px;
}

.name-card__loading {
  padding: 4px 0;
}

@keyframes name-card-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes name-card-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-3px) scale(0.99);
  }
}

/* ==========================================================================
   12. Apple 确认弹窗（L0–L4 引擎的渲染层）
   --------------------------------------------------------------------------
   结构由 core/apple.js 生成：
     .apple-alert-scrim > .apple-alert(.apple-alert--l2/3/4)
       > .apple-alert__head(icon/title/message/detail/input) + .apple-alert__actions
   Apple 原生 Alert：270px 宽、居中文字、按钮竖向排列、按钮之间 0.5px 发丝线。
   ========================================================================== */
.apple-alert-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: var(--material-blur-thin);
  -webkit-backdrop-filter: var(--material-blur-thin);
  animation: apple-scrim-in var(--m-scrim) var(--ease-ios) both;
}

.apple-alert-scrim.is-leaving {
  animation: apple-scrim-out var(--m-panel-out) var(--ease-ios) both;
}

.apple-alert {
  width: min(300px, 92vw);
  background: var(--bg-glass-strong);
  backdrop-filter: var(--material-blur);
  -webkit-backdrop-filter: var(--material-blur);
  border: var(--hairline) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  text-align: center;
  animation: apple-alert-in var(--m-panel-in) var(--ease-ios) both;
}

.apple-alert-scrim.is-leaving .apple-alert {
  animation: apple-alert-out var(--m-panel-out) var(--ease-ios) both;
}

.apple-alert__head {
  padding: 20px 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.apple-alert__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.apple-alert--l3 .apple-alert__icon,
.apple-alert--l4 .apple-alert__icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.apple-alert__title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.apple-alert__message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
}

.apple-alert__detail {
  font-size: var(--text-xs);
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  width: 100%;
  line-height: 1.5;
}

.apple-alert__field {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.apple-alert__field label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.apple-alert__field .input {
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* 按钮区：竖向堆叠 + 发丝线分隔（Apple Alert 的标准排布） */
.apple-alert__actions {
  display: flex;
  flex-direction: column;
  border-top: var(--hairline) solid var(--border-subtle);
}

.apple-alert__actions button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 400;
  padding: 13px 16px;
  cursor: pointer;
  transition: background var(--m-press) var(--ease-ios);
}

.apple-alert__actions button + button {
  border-top: var(--hairline) solid var(--border-subtle);
}

.apple-alert__actions button:hover {
  background: var(--bg-hover);
}

.apple-alert__actions button:active {
  background: var(--bg-active);
}

.apple-alert__actions button[data-alert-ok] {
  font-weight: 600;
}

.apple-alert__actions button.is-destructive {
  color: var(--danger);
  font-weight: 600;
}

.apple-alert__actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 横向排布（按钮少且文案短时更紧凑，Apple 在两按钮时也常用横排） */
.apple-alert--row .apple-alert__actions {
  flex-direction: row;
}

.apple-alert--row .apple-alert__actions button {
  flex: 1;
}

.apple-alert--row .apple-alert__actions button + button {
  border-top: 0;
  border-left: var(--hairline) solid var(--border-subtle);
}

@keyframes apple-scrim-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes apple-scrim-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes apple-alert-in {
  from {
    opacity: 0;
    transform: scale(1.06);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes apple-alert-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* 减少动效：浮层直接出现，不做缩放/位移 */
@media (prefers-reduced-motion: reduce) {
  .apple-alert,
  .apple-alert-scrim,
  .toast {
    animation: none !important;
  }
  .btn:active:not(:disabled) {
    transform: none;
  }
}
