/* ============================================================
   链接CMS · 组件样式
   手写组件类，视觉规范对齐 shadcn/ui (new-york style)
   依赖 tokens.css 中的 CSS 变量
   ============================================================ */

/* ================= 布局骨架 ================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s ease;
  z-index: 40;
}

.sidebar-header {
  height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem 0 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--foreground);
  overflow: hidden;
  white-space: nowrap;
}

.brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem;
}

.menu-group-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 0.875rem 0.5rem 0.375rem;
  white-space: nowrap;
}

.menu-group-title:first-child {
  padding-top: 0.25rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 3px);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 1px;
}

.menu-item:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.menu-item.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 600;
}

.menu-item svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 0.75rem;
  flex-shrink: 0;
}

/* 折叠状态 */
body.sidebar-collapsed .sidebar {
  width: 3.5rem;
}
body.sidebar-collapsed .brand span,
body.sidebar-collapsed .menu-item span,
body.sidebar-collapsed .menu-group-title {
  display: none;
}
body.sidebar-collapsed .menu-item {
  justify-content: center;
  padding: 0.5rem;
}
body.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}
body.sidebar-collapsed .sidebar-footer .user-meta {
  display: none;
}

/* ---------- 主区域 ---------- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-search {
  flex: 1;
  max-width: 20rem;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 2.25rem;
  padding-left: 2.25rem;
  padding-right: 3.5rem;
  border-radius: calc(var(--radius) - 3px);
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.8125rem;
  outline: none;
  cursor: pointer;
}

.topbar-search input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px oklch(from var(--ring) l c h / 0.15);
}

.topbar-search .search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  width: 1rem;
  height: 1rem;
  pointer-events: none;
}

.topbar-search .topbar-kbd {
  position: absolute;
  right: 0.4375rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 0.3125rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--background);
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: 0.6875rem;
  line-height: 1;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-desc {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* 面包屑 */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 0.125rem;
}
.breadcrumb a {
  color: var(--muted-foreground);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--foreground);
}
.breadcrumb .sep {
  opacity: 0.5;
}

/* ---------- 用户块（侧栏底部/顶栏） ---------- */
.user-block {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  overflow: hidden;
}
.user-block:hover {
  background: var(--sidebar-accent);
}
.user-meta {
  overflow: hidden;
  white-space: nowrap;
}
.user-meta .name {
  font-size: 0.8125rem;
  font-weight: 600;
}
.user-meta .email {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-sm { width: 1.5rem; height: 1.5rem; font-size: 0.6875rem; }
.avatar-lg { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: calc(var(--radius) - 3px);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn svg { width: 1rem; height: 1rem; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover { opacity: 0.85; }

.btn-outline {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
}
.btn-outline:hover { background: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background: var(--accent); }

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
.btn-destructive:hover { opacity: 0.9; }

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-lg { height: 2.5rem; padding: 0 1.5rem; }

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}
.btn-icon.btn-sm { width: 2rem; height: 2rem; }

/* ================= 卡片 ================= */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}

.card-header {
  padding: 1.25rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.card-header.flush { padding-bottom: 0; }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.card-body {
  padding: 1.25rem 1.5rem;
}
.card-footer {
  padding: 0 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ================= 徽章 ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  line-height: 1.4;
}
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { border-color: var(--border); color: var(--foreground); background: transparent; }
.badge-success {
  background: color-mix(in oklch, var(--success) 15%, transparent);
  color: var(--success);
}
.badge-warning {
  background: color-mix(in oklch, var(--warning) 18%, transparent);
  color: var(--warning);
}
.badge-destructive {
  background: color-mix(in oklch, var(--destructive) 15%, transparent);
  color: var(--destructive);
}

/* ================= 表单 ================= */
.form-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
}

.label .required::after {
  content: ' *';
  color: var(--destructive);
}

.input, .select, .textarea {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: calc(var(--radius) - 3px);
  border: 1px solid var(--input);
  background: transparent;
  color: var(--foreground);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  height: auto;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  padding-right: 2rem;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px oklch(from var(--ring) l c h / 0.15);
}

.input::placeholder, .textarea::placeholder {
  color: var(--muted-foreground);
}

.input-error, .select.error, .textarea.error {
  border-color: var(--destructive);
}

.error-text {
  font-size: 0.75rem;
  color: var(--destructive);
  display: none;
}
.error-text.show { display: block; }

.form-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* 开关 */
.switch {
  position: relative;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 9999px;
  background: var(--input);
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  left: 0.125rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 9999px;
  background: var(--background);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: left 0.2s;
}
.switch.on {
  background: var(--primary);
}
.switch.on::after {
  left: calc(100% - 1.25rem);
}

/* 复选框 */
.checkbox {
  width: 1rem;
  height: 1rem;
  border-radius: calc(var(--radius) - 8px);
  border: 1px solid var(--input);
  appearance: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  background: transparent;
}
.checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 0.28rem;
  top: 0.09rem;
  width: 0.3rem;
  height: 0.55rem;
  border: solid var(--primary-foreground);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ================= 表格 ================= */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  height: 2.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--muted);
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

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

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}

/* 批量操作栏：紧贴表格下方，选中后出现 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--muted);
}
.batch-bar[hidden] { display: none; }
.batch-bar .batch-count {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.batch-bar .batch-count strong {
  color: var(--primary);
  font-weight: 600;
}
.batch-bar .btn-outline { background: var(--card); }

/* 选中行：左侧主色竖条 + 灰底 */
.data-table tbody tr.is-selected {
  background: var(--muted);
}
.data-table tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

/* 表格行选择列 */
.data-table th.row-check,
.data-table td.row-check {
  width: 2.5rem;
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 0;
}
.data-table th.row-check input[type="checkbox"],
.data-table td.row-check input[type="checkbox"] {
  width: 0.9375rem;
  height: 0.9375rem;
  cursor: pointer;
  accent-color: var(--primary);
  vertical-align: middle;
}
.table-toolbar .search {
  position: relative;
  flex: 0 1 auto;
  min-width: 12rem;
}
.table-toolbar .search input {
  padding-left: 2rem;
}
.table-toolbar .search svg {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--muted-foreground);
  pointer-events: none;
}
.table-toolbar .spacer {
  flex: 1;
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.pagination .info {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-right: auto;
}
.page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}
.page-btn:hover:not(:disabled) { background: var(--accent); }
.page-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= 弹窗 ================= */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

.dialog {
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.15);
  width: 100%;
  max-width: 32rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: zoom-in 0.15s ease;
}
.dialog-sm { max-width: 24rem; }
.dialog-lg { max-width: 48rem; }
.dialog-xl { max-width: 76rem; }

/* ============ SKU 总览弹窗 ============ */
.sku-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.sku-filters .input,
.sku-filters .select {
  height: 2rem;
  font-size: 0.8125rem;
}
.sku-filters .input[data-sk-keyword] { width: 14rem; }
.sku-filters .input[data-sk-min],
.sku-filters .input[data-sk-max] { width: 6.5rem; }
.sku-filters .select { width: auto; min-width: 8rem; padding-right: 1.75rem; }

.sku-table-wrap {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  overflow: auto;
  max-height: 52vh;
}
.sku-table-wrap .data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.sku-table-wrap .data-table th,
.sku-table-wrap .data-table td {
  padding: 0.4375rem 0.625rem;
  font-size: 0.8125rem;
}
.sku-table-wrap .data-table td { vertical-align: middle; }

.sk-thumb {
  display: block;
  width: 2rem;
  height: 2rem;
  object-fit: cover;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
}
.sk-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
}
.sk-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.sk-num { text-align: right; white-space: nowrap; }
.sk-sub { font-size: 0.6875rem; color: var(--muted-foreground); }
.sk-empty { text-align: center; padding: 2rem; color: var(--muted-foreground); }

.sku-pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.sku-pager .info {
  margin-right: auto;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.sku-pager .page-indicator {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.dialog-header {
  padding: 1.25rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.dialog-title {
  font-size: 1.0625rem;
  font-weight: 600;
}
.dialog-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.dialog-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
}
.dialog-footer {
  padding: 0 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes zoom-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ================= 详情面板 / 代码块 ================= */
/* 键值列表：<dl class="kv-list"><dt>键</dt><dd>值</dd>…</dl> */
.kv-list {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.45rem 0.75rem;
  font-size: 0.8125rem;
}
.kv-list dt {
  color: var(--muted-foreground);
}
.kv-list dd {
  margin: 0;
  word-break: break-all;
}

/* 详情弹窗内的分段 */
.detail-section {
  margin-top: 1rem;
}
.detail-section:first-child {
  margin-top: 0;
}
.detail-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}
.detail-text {
  font-size: 0.8125rem;
  word-break: break-all;
}
.detail-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-all;
}

/* JSON / 长文本代码块 */
.code-block {
  margin: 0;
  padding: 0.625rem 0.75rem;
  background: var(--muted);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--foreground);
  max-height: 15rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 表格单元格单行省略（配合 title 属性看全文） */
.cell-ellipsis {
  display: inline-block;
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* 通用弱化文字色 */
.text-muted {
  color: var(--muted-foreground);
}

/* ================= 图片组（主图 / 拖拽排序） ================= */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
/* 空态提示：与「添加」格子同行 */
.gallery-empty {
  align-self: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
/* 「添加图片」格子：与图片同尺寸，跟在最后一张后面 */
.gallery-add {
  width: 5.5rem;
  height: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border: 1px dashed var(--border);
  border-radius: 0.375rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.gallery-add:hover {
  border-color: var(--ring);
  color: var(--foreground);
  background: var(--accent);
}
.gallery-add svg {
  width: 1.25rem;
  height: 1.25rem;
}

.gallery-item {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item[draggable="true"] {
  cursor: grab;
}
.gallery-item.dragging {
  opacity: 0.4;
}
.gallery-item.drag-over {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--ring) 35%, transparent);
}
.gallery-item.is-main {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* 主图角标 */
.gallery-badge {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0.0625rem 0.375rem;
  font-size: 0.6875rem;
  line-height: 1.6;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 0 0.375rem 0 0.375rem;
}

/* 悬浮操作按钮 */
.gallery-actions {
  position: absolute;
  right: 0.125rem;
  bottom: 0.125rem;
  display: flex;
  gap: 0.125rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.gallery-item:hover .gallery-actions {
  opacity: 1;
}
.gallery-btn {
  width: 1.375rem;
  height: 1.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  cursor: pointer;
}
.gallery-btn:hover {
  background: rgb(0 0 0 / 0.82);
}
.gallery-btn-danger:hover {
  background: var(--destructive);
}
.gallery-note {
  margin-bottom: 0.625rem;
}

/* ================= 富文本编辑器（wangEditor v5） ================= */
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.editor-box {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
  /* 覆盖 wangEditor 默认配色变量，跟随后台主题 */
  --w-e-toolbar-bg-color: transparent;
  --w-e-toolbar-color: var(--foreground);
  --w-e-toolbar-active-color: var(--foreground);
  --w-e-toolbar-active-bg-color: var(--accent);
  --w-e-toolbar-border-color: var(--border);
  --w-e-toolbar-disabled-color: var(--muted-foreground);
  --w-e-textarea-bg-color: transparent;
  --w-e-textarea-color: var(--foreground);
  --w-e-textarea-border-color: var(--border);
  --w-e-textarea-slight-border-color: var(--border);
  --w-e-textarea-slight-bg-color: var(--accent);
  --w-e-textarea-selected-border-color: var(--ring);
}
.editor-toolbar {
  border-bottom: 1px solid var(--border);
  background: var(--secondary);
}
.editor-toolbar .w-e-toolbar {
  background: transparent;
}
.editor-body {
  height: 22rem;
}
.editor-box .w-e-text-container [data-slate-editor] {
  padding: 0 0.75rem;
}

/* ================= AI 助手弹窗（公用，LC.openAiAssistant） ================= */
.ai-chat {
  display: flex;
  height: 62vh;
  min-height: 22rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
}
.ai-chat-side {
  width: 13rem;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--secondary);
}
.ai-chat-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 500;
}
.ai-chat-sessions {
  flex: 1;
  overflow: auto;
  padding: 0.375rem;
}
.ai-chat-session {
  padding: 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
}
.ai-chat-session:hover { background: var(--muted); }
.ai-chat-session.active { background: var(--primary); color: var(--primary-foreground); }
.ai-chat-session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-session-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}
.ai-chat-session.active .ai-chat-session-meta {
  color: var(--primary-foreground);
  opacity: 0.8;
}
.ai-chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ai-chat-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.ai-chat-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.ai-chat-tip {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  background: color-mix(in oklch, var(--accent) 60%, transparent);
}
.ai-chat-msgs {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ai-chat-msg {
  max-width: 82%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
}
.ai-chat-msg.assistant { align-self: flex-start; background: var(--secondary); }
.ai-chat-msg.error {
  align-self: flex-start;
  background: var(--secondary);
  border: 1px solid var(--destructive);
  color: var(--destructive);
}
.ai-chat-msg-meta {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  opacity: 0.7;
}
.ai-chat-foot {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}
.ai-chat-foot .textarea {
  max-height: 7rem;
  resize: none;
}
.ai-chat-empty {
  margin: auto;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

/* ================= 系统配置页（cfg-* 前缀，避免与 .settings-nav 旧样式冲突） ================= */
.cfg-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--background);
}
.cfg-nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--muted);
  border-radius: var(--radius);
}
.cfg-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.cfg-nav-item:hover { color: var(--foreground); }
.cfg-nav-item.active {
  background: var(--card);
  color: var(--foreground);
  font-weight: 500;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.cfg-nav-item svg { width: 0.9375rem; height: 0.9375rem; }

/* ================= 产品表单（多规格 / SKU） ================= */
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  cursor: pointer;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem 1rem;
}
.form-section {
  margin: 1.25rem 0 0.75rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}
.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.form-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.form-section-title .hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted-foreground);
}

.spec-group {
  margin-bottom: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--secondary);
}
.spec-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.spec-group-name {
  font-size: 0.8125rem;
  font-weight: 500;
}
.spec-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}
.spec-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--background);
  font-size: 0.75rem;
}
.spec-chip button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  line-height: 1;
  cursor: pointer;
}
.spec-chip button:hover { color: var(--destructive); }
.spec-add-input {
  width: 6rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

.sku-wrap {
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}
.sku-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.sku-table th,
.sku-table td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.sku-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-weight: 500;
  white-space: nowrap;
}
.sku-table tbody tr:last-child td { border-bottom: 0; }
.sku-table .input {
  height: 1.875rem;
  padding: 0 0.375rem;
  font-size: 0.75rem;
}
.sku-combo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.sku-combo span {
  padding: 0.0625rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--accent);
  font-size: 0.6875rem;
}
.sku-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

/* ================= 列表缩略图 / 大图预览（灯箱） ================= */
.thumb-zoom {
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.thumb-zoom:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.3);
}

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: rgb(0 0 0 / 0.82);
  overflow: hidden;
  user-select: none;
}
.img-lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 0.375rem;
  box-shadow: 0 8px 40px rgb(0 0 0 / 0.5);
  background: var(--background);
  transform-origin: center center;
  will-change: transform;
}
.img-lightbox img.is-zoomed { cursor: grab; }
.img-lightbox img.is-dragging { cursor: grabbing; }

.img-lightbox-toolbar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 9999px;
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(6px);
}
.img-lightbox-toolbar button {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.img-lightbox-toolbar button:hover {
  background: rgb(255 255 255 / 0.18);
}
.img-lightbox-scale {
  min-width: 3rem;
  text-align: center;
  font-size: 0.75rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ================= 详情弹窗 ================= */
.detail-grid {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1.25rem;
  align-items: start;
}
.detail-media {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--secondary);
}
.detail-media img {
  display: block;
  width: 100%;
  cursor: zoom-in;
}
.detail-media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 8rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
  min-width: 0;
}
.detail-field { min-width: 0; }
.detail-field.is-full { grid-column: 1 / -1; }
.detail-label {
  display: block;
  margin-bottom: 0.125rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.detail-value {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.6;
  word-break: break-word;
}
.detail-value.is-mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.detail-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.detail-content {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.75;
  max-height: 22rem;
  overflow: auto;
}
.detail-content img { max-width: 100%; height: auto; border-radius: 0.25rem; }
.detail-content p { margin: 0.5rem 0; }
.detail-content h1,
.detail-content h2,
.detail-content h3,
.detail-content h4 { margin: 0.875rem 0 0.5rem; font-weight: 600; }
.detail-content blockquote {
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--muted-foreground);
}
.detail-content ul,
.detail-content ol { margin: 0.5rem 0; padding-left: 1.375rem; }
.detail-content table { border-collapse: collapse; width: 100%; }
.detail-content th,
.detail-content td { border: 1px solid var(--border); padding: 0.375rem 0.5rem; }
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-fields { grid-template-columns: 1fr; }
}
.cfg-actions {
  flex: none;
  display: flex;
  gap: 0.5rem;
}

.cfg-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}
.cfg-row:last-child { border-bottom: 0; }
.cfg-row.is-block { flex-direction: column; gap: 0.625rem; }
.cfg-row-main { flex: 1 1 auto; min-width: 0; }
.cfg-row-label {
  font-size: 0.875rem;
  font-weight: 500;
}
.cfg-row-desc {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted-foreground);
}
.cfg-row-control {
  flex: 0 0 20rem;
  width: 20rem;
  max-width: 100%;
}
.cfg-row.is-block .cfg-row-control {
  flex: 1 1 auto;
  width: 100%;
}
.cfg-row-control .input,
.cfg-row-control .textarea {
  width: 100%;
}
.cfg-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}
.cfg-switch {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.cfg-switch-text {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  min-width: 2.5rem;
  text-align: right;
}
.cfg-upload {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.cfg-upload-preview {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 0.375rem;
  background: var(--secondary);
  color: var(--muted-foreground);
  overflow: hidden;
}
.cfg-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cfg-upload-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}
@media (max-width: 768px) {
  .cfg-row { flex-direction: column; gap: 0.5rem; }
  .cfg-row-control { flex: 1 1 auto; width: 100%; }
  .cfg-nav { flex: 1 1 100%; }
}

/* ================= 下拉菜单 ================= */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 11rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.1);
  padding: 0.3rem;
  z-index: 90;
  display: none;
  animation: zoom-in 0.12s ease;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--foreground);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--accent); }
.dropdown-item.danger { color: var(--destructive); }
.dropdown-item.danger:hover { background: color-mix(in oklch, var(--destructive) 10%, transparent); }
.dropdown-item svg { width: 0.9375rem; height: 0.9375rem; }
.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 0.25rem -0.3rem;
}
.dropdown-label {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  padding: 0.375rem 0.625rem;
}

/* ================= Toast ================= */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  animation: slide-in 0.2s ease;
}

.toast .t-icon {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.0625rem;
}
.toast-success .t-icon { color: var(--success); }
.toast-error .t-icon { color: var(--destructive); }
.toast-warning .t-icon { color: var(--warning); }
.toast-info .t-icon { color: var(--ring); }

.toast .t-title {
  font-weight: 600;
}
.toast .t-msg {
  color: var(--muted-foreground);
}

.toast.hide {
  animation: fade-out 0.2s ease forwards;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fade-out {
  to { opacity: 0; transform: translateY(-0.25rem); }
}

/* ================= Dashboard ================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.25rem;
}
.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  font-weight: 500;
}
.stat-card .stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.stat-card .stat-trend {
  font-size: 0.75rem;
  font-weight: 500;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--destructive); }

/* 纯 CSS 柱状图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 12rem;
  padding: 0.5rem 0;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  height: 100%;
  justify-content: flex-end;
}
.bar-col .bar {
  width: 60%;
  max-width: 2.5rem;
  border-radius: calc(var(--radius) - 6px) calc(var(--radius) - 6px) 2px 2px;
  background: var(--primary);
  opacity: 0.85;
  min-height: 2px;
  transition: height 0.6s ease;
}
.bar-col:hover .bar { opacity: 1; }
.bar-col .bar-label {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

/* 进度条 */
.progress {
  height: 0.5rem;
  background: var(--muted);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ================= 登录页 ================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--background);
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
}
.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 0.25rem;
}
.auth-sub {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ================= 空状态 / 404 ================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--muted-foreground);
  text-align: center;
}
.empty-state svg {
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0.5;
}

.page-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
}
.error-code {
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(180deg, var(--foreground), var(--muted-foreground));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ================= 骨架屏 ================= */
.skeleton {
  background: linear-gradient(90deg, var(--muted) 25%, var(--accent) 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: calc(var(--radius) - 4px);
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ================= 提示块 ================= */
.alert {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}
.alert svg { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.125rem; }
.alert-info {
  border-color: color-mix(in oklch, var(--ring) 40%, transparent);
  background: color-mix(in oklch, var(--ring) 8%, transparent);
}
.alert-warning {
  border-color: color-mix(in oklch, var(--warning) 40%, transparent);
  background: color-mix(in oklch, var(--warning) 10%, transparent);
}

/* 滑块 */
input[type="range"].range {
  width: 100%;
  height: 1.25rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* 快捷范围按钮组 */
.chip-group {
  display: inline-flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.chip {
  height: 1.75rem;
  padding: 0 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chip:hover { background: var(--accent); color: var(--accent-foreground); }
.chip.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

/* 文件拖拽区 */
.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  color: var(--muted-foreground);
}
.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--primary);
  background: var(--accent);
  color: var(--accent-foreground);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-drop .file-drop-icon { width: 2rem; height: 2rem; }
.file-drop .file-drop-text { font-size: 0.875rem; font-weight: 500; }
.file-drop .hint { font-size: 0.75rem; }

/* 文件预览卡片 */
.file-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  margin-top: 0.75rem;
}
.file-thumb {
  width: 3rem;
  height: 3rem;
  border-radius: calc(var(--radius) - 4px);
  object-fit: cover;
  background: var(--muted);
  flex-shrink: 0;
}
.file-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.875rem; font-weight: 500; word-break: break-all; }
.file-meta { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 0.125rem; }

/* "查看用法"折叠代码块 */
.code-example {
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--foreground);
  overflow-x: auto;
  line-height: 1.65;
  white-space: pre;
}
.code-example code { font-family: inherit; }
.code-example[hidden] { display: none; }
.code-toggle-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.code-toggle-row .hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* 设置页布局 */
.settings-layout {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1.5rem;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 4.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.settings-nav a {
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 3px);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}
.settings-nav a:hover { background: var(--accent); color: var(--accent-foreground); }
.settings-nav a.active {
  background: var(--accent);
  color: var(--foreground);
  font-weight: 600;
}
.settings-stack { display: flex; flex-direction: column; gap: 1.5rem; }

/* 设置行（左标题描述 + 右控件） */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; padding-bottom: 0; }
.setting-meta strong { display: block; font-size: 0.875rem; font-weight: 500; }
.setting-meta small { display: block; font-size: 0.75rem; color: var(--muted-foreground); margin-top: 0.125rem; }

/* 主题选项（胶囊式 radio 组） */
.theme-options {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--muted);
  border-radius: calc(var(--radius) - 2px);
}
.theme-option {
  position: relative;
  padding: 0.4375rem 1.125rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted-foreground);
  transition: all 0.15s;
}
.theme-option:has(input:checked) {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }

@media (max-width: 767px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
  }
}

/* ================= 组件演示页排版 ================= */
.demo-section {
  margin-bottom: 2rem;
}

.demo-section-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.demo-section-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.demo-block {
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.demo-block.column {
  flex-direction: column;
  align-items: stretch;
}

.demo-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  width: 100%;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.demo-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 767px) {
  .demo-grid-2 { grid-template-columns: 1fr; }
}

/* 单选按钮 */
.radio {
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 1px solid var(--input);
  appearance: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  background: transparent;
}
.radio:checked {
  border-color: var(--primary);
  background: var(--primary);
}
.radio:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--primary-foreground);
}

/* 头像颜色变体 */
.avatar-accent { background: var(--accent); color: var(--accent-foreground); }
.avatar-primary { background: var(--primary); color: var(--primary-foreground); }
.avatar-muted { background: var(--muted); color: var(--muted-foreground); }

/* 侧滑面板 Sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
  animation: fade-in 0.15s ease;
}
.sheet {
  width: 100%;
  max-width: 24rem;
  height: 100%;
  background: var(--popover);
  color: var(--popover-foreground);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: sheet-in 0.2s ease;
}
@keyframes sheet-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.sheet-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-title { font-size: 1rem; font-weight: 600; }
.sheet-body { flex: 1; padding: 1.25rem 1.5rem; overflow-y: auto; }
.sheet-footer {
  padding: 0 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* 原生 Popover */
.popover-demo {
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
  padding: 1rem;
  max-width: 18rem;
}
.popover-demo h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.25rem; }
.popover-demo:popover-open {
  position: fixed;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
}

/* 工具提示 Tooltip（纯 CSS） */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-text {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--foreground);
  color: var(--background);
  font-size: 0.75rem;
  padding: 0.3125rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  z-index: 50;
}
.tooltip-wrap:hover .tooltip-text,
.tooltip-wrap:focus-within .tooltip-text {
  opacity: 1;
  visibility: visible;
}

/* 命令面板 Command */
.command-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 110;
  animation: fade-in 0.15s ease;
}
.command-panel {
  width: 100%;
  max-width: 32rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.2);
  overflow: hidden;
  animation: zoom-in 0.15s ease;
}
.command-input {
  width: 100%;
  height: 3rem;
  padding: 0 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  font-size: 0.9375rem;
  outline: none;
}
.command-list { max-height: 20rem; overflow-y: auto; padding: 0.3rem; }
.command-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5625rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--foreground);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.command-item:hover, .command-item.active { background: var(--accent); }
.command-item svg { width: 1rem; height: 1rem; flex-shrink: 0; color: var(--muted-foreground); }
.command-empty { padding: 1.5rem; text-align: center; color: var(--muted-foreground); font-size: 0.8125rem; }

/* 状态视图 State */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
}
.state h3 { font-size: 0.9375rem; font-weight: 600; color: var(--foreground); }
.state p { font-size: 0.8125rem; }
.state svg { width: 2.25rem; height: 2.25rem; opacity: 0.5; }

/* 步骤条 Steps */
.demo-steps {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.demo-steps span {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}
.demo-steps span.current {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* 头像成员组 */
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--background); margin-left: -0.5rem; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* 标签页 Tabs */
.tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--muted);
  border-radius: calc(var(--radius) - 2px);
}
.tab {
  padding: 0.375rem 0.875rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.tab[aria-selected="true"] {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}
.tab-panel { padding: 1rem 0 0; }
.tab-panel h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.25rem; }

/* 折叠面板 Accordion */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.accordion details { border-bottom: 1px solid var(--border); }
.accordion details:last-child { border-bottom: none; }
.accordion summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: '+';
  color: var(--muted-foreground);
  font-size: 1rem;
  transition: transform 0.15s;
}
.accordion details[open] summary::after { transform: rotate(45deg); }
.accordion summary:hover { background: var(--muted); }
.accordion details > p { padding: 0 1rem 0.875rem; font-size: 0.8125rem; color: var(--muted-foreground); }

/* 分隔线 & 键盘键 */
.separator { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
kbd {
  padding: 0.125rem 0.375rem;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--border);
  background: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* 滚动区域 */
.scroll-area { max-height: 12rem; overflow-y: auto; padding-right: 0.5rem; }
.scroll-area p { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.scroll-area p:last-child { border-bottom: none; }

/* 登录页左右分栏布局 */
.auth-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 100dvh;
}
.auth-story {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-story .brand-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 0.9375rem;
}
.auth-story .brand-logo {
  background: var(--primary-foreground);
  color: var(--primary);
}
.auth-story h2 {
  font-size: 2.375rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -1.2px;
  margin-bottom: 1.25rem;
}
.auth-story .story-desc {
  font-size: 0.875rem;
  opacity: 0.75;
  max-width: 27rem;
}
.auth-story .auth-footnote { font-size: 0.75rem; opacity: 0.55; }

.auth-pattern {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin: 3rem 0;
}
.auth-pattern span {
  height: 3.625rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  opacity: 0.12;
}
.auth-pattern span:nth-child(4n) {
  opacity: 0.32;
  background: currentColor;
}

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}
.auth-theme { position: absolute; top: 1.5rem; right: 1.5rem; }
.auth-form { width: 100%; max-width: 22.5rem; }
.auth-form h1 { font-size: 1.5625rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.auth-form .auth-sub {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
}
.auth-note {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 1rem;
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { display: none; }
}

/* ================= 响应式 ================= */
.mobile-only { display: none; }

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 16rem;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgb(0 0 0 / 0.3);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }
  .content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .topbar-search { display: none; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  z-index: 35;
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }
::-webkit-scrollbar-track { background: transparent; }
