*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* --- Editorial Palette (magazine-grade) --- */
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f5f5f5;
  --bg-accent: #f0ede8;
  --text: #1a1a1a;
  --text-secondary: #555555;
  --text-tertiary: #6a6a6a;   /* 对比度 ≥4.5:1（原 #b0b0b0 只有 2.2:1） */
  --border: #e8e8e8;
  --border-light: #f0f0f0;
  --accent: #c4956a;
  --accent-light: #f5ede4;
  --accent-dark: #85592f;     /* 用作文字/链接，对比度 ≥5:1 */
  --accent-strong: #9a6a3c;   /* 主按钮底色，白字 ≥4.6:1 */
  --success: #4f7a5c;
  --success-light: #e8f2e9;
  --danger: #b5473a;
  --danger-light: #fcebeb;
  --info: #3f6796;
  --info-light: #edf4fb;
  --ai: #6c5ce7;
  --ai-light: #f2f0ff;
  --warning: #d4a24c;
  --warning-strong: #9a6a12;  /* 白字底色 */
  --warning-text: #7a5410;
  --warning-light: #fdf5e6;
  --board-bg: #f6f2ec;

  /* --- Editorial Typography --- */
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-body: "PingFang SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;

  /* --- Spacious Radius & Shadows --- */
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-xl: 0 8px 40px rgba(0,0,0,0.08);
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.app { display: flex; width: 100%; height: 100%; }

.sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ===== SIDEBAR ===== */
.sidebar-header {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.brand { flex: 1; }
.brand h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}
.brand-tagline {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.brand-sub {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
}
.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-actions {
  padding: 16px 24px;
  display: flex;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-tertiary); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-dark));
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(196, 149, 106, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-dark));
  box-shadow: 0 4px 16px rgba(196, 149, 106, 0.35);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(196, 149, 106, 0.2); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b85a4f; border-color: #b85a4f; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}

.sidebar-filters {
  padding: 0 24px 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.filter-chip:hover { border-color: var(--text-tertiary); background: var(--bg-hover); }
.filter-chip.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: var(--accent);
  font-weight: 500;
}

.sidebar-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 24px;
}
.sidebar-items::-webkit-scrollbar { width: 4px; }
.sidebar-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.item-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1.5px solid transparent;
  margin-bottom: 6px;
}
.item-card:hover { background: var(--bg-hover); transform: translateX(2px); }
.item-card.selected { background: var(--accent-light); border-color: var(--accent); }
.item-card.dragging { opacity: 0.5; }

.item-card-thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-xs);
  background: var(--bg-accent);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}
.item-card-thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--text-tertiary);
}
.item-card-info { flex: 1; min-width: 0; }
.item-card-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.item-card-colors { display: flex; gap: 4px; margin-top: 4px; }
.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}

.item-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ===== MAIN AREA ===== */
.main-nav {
  display: flex;
  gap: 0;
  padding: 20px 32px 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
}
.nav-tab {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  position: relative;
  font-family: inherit;
  transition: color 0.2s ease;
  letter-spacing: 0.02em;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent-dark); }
.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== WARDROBE VIEW ===== */
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.wardrobe-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.wardrobe-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

.wardrobe-card-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-accent);
  background-size: cover;
  background-position: center;
  position: relative;
}
.wardrobe-card-img .favorite-star {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
  transition: transform 0.15s;
}
.wardrobe-card-img .favorite-star:hover { transform: scale(1.2); }

.wardrobe-card .card-delete-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.wardrobe-card:hover .card-delete-btn { opacity: 1; }
.wardrobe-card .card-delete-btn:hover { background: rgba(207,107,94,0.85); }

.wardrobe-card-body { padding: 12px; }
.wardrobe-card-body h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.wardrobe-card-body .meta { font-size: 11px; color: var(--text-secondary); }

/* ===== Preview Popover ===== */
.preview-popover {
  position: fixed;
  z-index: 1000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 14px;
  min-width: 240px;
  max-width: 380px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.preview-popover.visible {
  opacity: 1;
  transform: translateY(0);
}
.preview-popover .popover-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.preview-popover.arrow-top .popover-arrow {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(135deg);
}
.preview-popover.arrow-bottom .popover-arrow {
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(-45deg);
}
.preview-popover .popover-section {
  margin-bottom: 10px;
}
.preview-popover .popover-section:last-child { margin-bottom: 0; }
.preview-popover .popover-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.preview-popover .popover-section-title .count {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 10px;
}
.preview-popover .popover-thumbnails {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.popover-thumbnails::-webkit-scrollbar { height: 4px; }
.popover-thumbnails::-webkit-scrollbar-track { background: transparent; }
.popover-thumbnails::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.preview-popover .popover-thumb {
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: var(--radius-xs);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-accent);
  cursor: zoom-in;
  border: 1.5px solid transparent;
  transition: border-color 0.12s, transform 0.12s;
  flex-shrink: 0;
}
.preview-popover .popover-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}
.preview-popover .popover-thumb.primary {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.preview-popover .popover-empty {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  padding: 4px 0;
}

/* ===== Image Lightbox ===== */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.lightbox-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-overlay .lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  cursor: default;
}

/* ===== Sidebar item delete ===== */
.item-card .item-delete-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: all 0.15s;
  margin-left: 4px;
}
.item-card:hover .item-delete-btn { opacity: 1; }
.item-card .item-delete-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ===== STUDIO VIEW ===== */
.studio-layout { display: flex; gap: 24px; height: 100%; }

.studio-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

@keyframes progress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* ===== 穿搭画板 ===== */
#view-studio { height: 100%; }
.studio-layout { min-height: 0; }
.studio-panel { min-height: 0; max-height: 100%; }
.studio-canvas { flex-direction: column; align-items: stretch; gap: 10px; min-width: 0; }
.studio-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.studio-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.studio-title small { font-family: var(--font-body); font-size: 12px; font-weight: 400; color: var(--text-tertiary); margin-left: 6px; }
.studio-toolbar-actions { display: flex; gap: 6px; }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; container-type: size; }
.board {
  position: relative;
  aspect-ratio: 3 / 4;
  width: min(100cqw, 75cqh);
  background: var(--board-bg);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  isolation: isolate; /* 单品层级只在画板内部生效，不会盖住弹窗 */
}
.board.drag-over { box-shadow: inset 0 0 0 2px var(--accent); }
.board-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 13px; text-align: center; line-height: 1.8; pointer-events: none; padding: 24px;
}
.board-empty .big { font-size: 40px; opacity: 0.5; margin-bottom: 8px; }
.board-item { position: absolute; cursor: grab; }
.board-item img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.board-item.cutout img { filter: drop-shadow(0 6px 10px rgba(0,0,0,0.12)); }
.board-item.original img { border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.10); }
.board-item.dragging { cursor: grabbing; }
.board-item.selected { outline: 1.5px dashed var(--accent); outline-offset: 4px; }
.board-handle {
  position: absolute; right: -10px; bottom: -10px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; display: none;
}
.board-item.selected .board-handle { display: block; }
.board-item-tools {
  position: absolute; left: 50%; top: -38px; transform: translateX(-50%);
  display: none; gap: 2px; background: #fff; border-radius: 8px; padding: 3px;
  box-shadow: var(--shadow-lg); white-space: nowrap; z-index: 1000;
}
.board-item.selected .board-item-tools { display: flex; }
.board-item.tools-below .board-item-tools { top: auto; bottom: -40px; }
.board-item-tools button {
  border: none; background: none; font-size: 12px; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--text-secondary);
}
.board-item-tools button:hover { background: var(--bg-hover); color: var(--text); }
.board-item-tools button.danger:hover { background: var(--danger-light); color: var(--danger); }
.board-hint { text-align: center; font-size: 12px; color: var(--text-tertiary); }
.item-card.on-board { background: var(--accent-light); }
.item-card.on-board .item-card-name::after { content: ' ✓'; color: var(--accent-dark); }

/* 抠图中标记 */
.is-cutting { position: relative; }
.wardrobe-card.is-cutting .wardrobe-card-img::after,
.item-card.is-cutting .item-card-thumb::after {
  content: '抠图中'; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 10px; background: rgba(0,0,0,0.55); color: #fff; padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}
.item-card-thumb { position: relative; }
.wardrobe-card-img { background-size: contain !important; background-repeat: no-repeat; background-position: center; background-color: #faf8f5; }

/* 弹窗里的抠图预览 */
.cutout-section { display: flex; gap: 14px; margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); align-items: center; }
.cutout-preview { width: 96px; height: 96px; flex-shrink: 0; border-radius: var(--radius-xs); background-size: contain; background-repeat: no-repeat; background-position: center; }
.checkerboard {
  background-color: #fff;
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 12px 12px; background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.cutout-preview.checkerboard { background-size: contain, contain; }
.cutout-info { flex: 1; min-width: 0; }
.cutout-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.cutout-status { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.cutout-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-toggle button { border: none; background: #fff; font-size: 12px; padding: 4px 12px; cursor: pointer; color: var(--text-secondary); }
.seg-toggle button.active { background: var(--accent-strong); color: #fff; }

/* 设置弹窗 */
.settings-section-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-row-text { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.path-code { font-size: 11px; background: var(--bg-hover); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.backup-list { margin-top: 8px; border: 1px solid var(--border-light); border-radius: var(--radius-xs); max-height: 150px; overflow-y: auto; }
.backup-list:empty { display: none; }
.backup-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-size: 12px; border-bottom: 1px solid var(--border-light); }
.backup-row:last-child { border-bottom: none; }
.backup-row small { color: var(--text-tertiary); margin-left: 8px; }
.backup-row .btn-sm { padding: 3px 10px; }

/* ===== 我的搭配 ===== */
.outfits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.outfit-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); transition: box-shadow 0.2s, transform 0.2s; cursor: pointer; }
.outfit-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.outfit-card-img { aspect-ratio: 3 / 4; background: var(--board-bg) center / cover no-repeat; }
.outfit-card-body { padding: 12px 14px; }
.outfit-card-body h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outfit-card-body .meta { font-size: 12px; color: var(--text-tertiary); }
.outfit-card-actions { display: flex; gap: 6px; padding: 0 14px 12px; }
.outfit-card-actions .btn { flex: 1; justify-content: center; font-size: 12px; padding: 5px 0; }

/* ===== 穿着记录 & 统计 ===== */
.toast.toast-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 20px; }
.toast-action button { white-space: nowrap; flex-shrink: 0; background: rgba(255,255,255,0.16); color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.toast-action button:hover { background: rgba(255,255,255,0.28); }
.wear-info { align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 16px; background: var(--accent-light); border-radius: var(--radius-sm); font-size: 13px; color: var(--accent-dark); }
.outfit-wear-btn { font-size: 12px !important; padding: 7px 0 !important; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.2; color: var(--text); }
.stat-value small { font-family: var(--font-body); font-size: 12px; font-weight: 400; color: var(--text-tertiary); margin-left: 4px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1000px) { .stats-grid { grid-template-columns: minmax(0, 1fr); } }
.stats-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.stats-card.stats-wide { grid-column: 1 / -1; }
.stats-card h3 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.stats-card h3 small { font-family: var(--font-body); font-size: 12px; font-weight: 400; color: var(--text-tertiary); margin-left: 6px; }
.stats-note { font-size: 13px; color: var(--text-secondary); }
.stat-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 120px)); gap: 12px; }
.stat-item { cursor: pointer; min-width: 0; }
.stat-item-img { aspect-ratio: 1; border-radius: var(--radius-xs); background: #faf8f5 center / contain no-repeat; border: 1px solid var(--border-light); margin-bottom: 6px; transition: transform 0.2s; }
.stat-item:hover .stat-item-img { transform: translateY(-2px); }
.stat-item-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-item-sub { font-size: 11px; color: var(--text-tertiary); }
.cat-bars { display: flex; flex-direction: column; gap: 12px; }
.cat-bar-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.cat-bar-label { color: var(--text-secondary); }
.cat-bar-track { height: 10px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.cat-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cat-bar-row:hover .cat-bar-fill { background: var(--accent-dark); }
.cat-bar-value { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wear-log { display: flex; flex-direction: column; }
.wear-day { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.wear-day:last-child { border-bottom: none; }
.wear-date { font-size: 13px; font-weight: 600; padding-top: 8px; }
.wear-entries { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wear-entry { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wear-thumbs { display: flex; gap: 4px; flex-shrink: 0; }
.wear-thumb { width: 36px; height: 36px; border-radius: 6px; background: #faf8f5 center / contain no-repeat; border: 1px solid var(--border-light); }
.wear-names { flex: 1; min-width: 0; font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wear-del { opacity: 0; padding: 3px 9px !important; }
.wear-entry:hover .wear-del { opacity: 1; }

.restore-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 24px 0; padding: 10px 14px; background: var(--accent-light); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-size: 13px; color: var(--accent-dark); }
.restore-banner span { flex: 1; min-width: 200px; }
/* ===== 搜索 & 筛选 ===== */
.sidebar-search { padding: 14px 24px 10px; }
.sidebar-search .form-input { padding: 8px 12px; font-size: 13px; }
.more-filters-bar { display: flex; align-items: center; gap: 8px; padding: 0 24px 10px; font-size: 12px; }
.link-btn { background: none; border: none; padding: 0; font-size: 12px; color: var(--accent-dark); cursor: pointer; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.filter-badge { font-weight: 600; }
.filter-result { flex: 1; text-align: right; color: var(--text-tertiary); }
.more-filters-panel { padding: 0 24px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; border-bottom: 1px solid var(--border-light); margin-bottom: 8px; }
.mf-label { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.mf-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.mf-chips .chip-option { padding: 3px 10px; font-size: 11px; }
.mf-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.mf-colors .color-swatch { width: 20px; height: 20px; }

/* ===== STUDIO PANEL ===== */
.studio-panel {
  width: 380px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.studio-panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.studio-panel-header h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.studio-panel-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ===== OUTFIT CARDS (grouped by zone) ===== */
.outfit-group {
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.outfit-group:hover { box-shadow: var(--shadow); }
.outfit-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-hover);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: default;
  user-select: none;
  letter-spacing: 0.02em;
}
.outfit-group-header .zone-icon {
  font-size: 16px;
  line-height: 1;
}
.outfit-group-body {
  padding: 14px 16px;
}
.outfit-group-empty {
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-tertiary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}
.outfit-group-empty:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.outfit-item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  margin-bottom: 10px;
}
.outfit-item-row:last-child { margin-bottom: 0; }
.outfit-item-thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-xs);
  background: var(--bg-accent);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}
.outfit-item-info { flex: 1; min-width: 0; }
.outfit-item-info h4 { font-size: 13px; font-weight: 500; margin: 0; }
.outfit-item-info p { font-size: 11px; color: var(--text-secondary); margin: 2px 0 0 0; }

/* Swap panel — horizontal scroll */
.swap-panel {
  background: var(--bg-hover);
  padding: 10px 16px;
  margin: 0;
  border-top: 1px solid var(--border-light);
}
.swap-panel-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.swap-options {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.swap-options::-webkit-scrollbar { height: 4px; }
.swap-options::-webkit-scrollbar-track { background: transparent; }
.swap-options::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.swap-option {
  width: 48px; height: 48px;
  min-width: 48px;
  border-radius: var(--radius-xs);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-accent);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.swap-option:hover { border-color: var(--accent); transform: scale(1.08); }
.swap-option.empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-accent);
  font-size: 18px;
  color: var(--text-tertiary);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.modal-close:hover { background: var(--bg-accent); color: var(--text); }
.modal-body { padding: 24px; }

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238c8070' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea.form-input { resize: vertical; min-height: 60px; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-option {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.chip-option:hover { border-color: var(--text-tertiary); }
.chip-option.selected {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: var(--accent);
  font-weight: 500;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--bg-hover);
  position: relative;
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-light); }
.upload-area.has-image { padding: 0; border-style: solid; border-color: var(--border); }
.upload-area.has-image img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-xs);
}
.upload-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.upload-text { font-size: 14px; color: var(--text-secondary); }
.upload-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 6px; }

/* ===== IMAGE GRID ===== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.image-card {
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.image-card:hover { border-color: var(--text-tertiary); }
.image-card.active { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-light); }
.image-card .card-img {
  width: 100%; height: 80px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-accent);
  position: relative;
}
.image-card .card-status {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 14px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.img-delete-btn {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.image-card:hover .img-delete-btn { opacity: 1; }
.img-delete-btn:hover { background: rgba(207,107,94,0.85); }
.image-card .card-footer {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.image-card .card-type-select {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.image-card .card-type-select:focus { outline: none; border-color: var(--ai); }
.image-card .card-ai-btn {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--ai);
  background: var(--ai-light);
  color: var(--ai);
  cursor: pointer;
  white-space: nowrap;
}
.image-card .card-ai-btn:hover { background: var(--ai); color: #fff; }
.image-card .card-ai-btn.done { background: var(--success-light); color: var(--success); border-color: var(--success); }
.image-card .card-ai-btn.loading { opacity: 0.6; pointer-events: none; }
.image-card .card-result-preview {
  padding: 0 8px 6px;
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.image-card .card-result-preview strong { color: var(--text); }
.image-card .card-result-preview .result-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Role tabs & primary badge */
.role-tabs { display: flex; gap: 2px; flex-shrink: 0; }
.role-tab {
  width: 22px; height: 22px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-card);
  font-size: 11px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.role-tab:hover { background: var(--bg-hover); }
.role-tab.active { background: var(--ai-light); border-color: var(--ai); }

.primary-badge {
  position: absolute; bottom: 4px; left: 4px;
  background: var(--warning-strong); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 6px;
  pointer-events: none;
}
.card-primary-btn {
  font-size: 9px; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--warning); background: var(--warning-light);
  color: var(--warning-text); cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.card-primary-btn:hover { background: var(--warning); color: #fff; }
.card-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.image-card.is-primary { box-shadow: 0 0 0 2px var(--warning); border-radius: var(--radius); }
.image-card.is-primary .card-img { border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0; }

/* Primary image cropper modal */
#modal-crop .crop-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 8px;
}
#modal-crop .crop-main {
  flex: 1;
  min-width: 0;
}
#modal-crop .crop-container {
  position: relative;
  display: inline-block;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
#modal-crop .crop-img {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  border-radius: var(--radius-sm);
  pointer-events: none;
}
#modal-crop .crop-box {
  position: absolute;
  outline: 2px dashed rgba(255,255,255,0.9);
  outline-offset: -1px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  z-index: 2;
  pointer-events: none;
  border-radius: 2px;
  cursor: move;
}
#modal-crop .crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 3px;
  z-index: 3;
  pointer-events: auto;
  touch-action: none;
}
#modal-crop .crop-handle[data-handle="nw"] { cursor: nwse-resize; }
#modal-crop .crop-handle[data-handle="ne"] { cursor: nesw-resize; }
#modal-crop .crop-handle[data-handle="sw"] { cursor: nesw-resize; }
#modal-crop .crop-handle[data-handle="se"] { cursor: nwse-resize; }
#modal-crop .crop-sidebar {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#modal-crop .crop-preview-label {
  font-size: 11px;
  color: var(--text-secondary);
}
#modal-crop .crop-result-thumb {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#modal-crop .crop-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.5;
}
#modal-crop .crop-size-info {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-hover);
  padding: 4px 10px;
  border-radius: 10px;
}

@media (max-width: 600px) {
  #modal-crop .crop-layout { flex-direction: column; }
  #modal-crop .crop-sidebar {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }
  #modal-crop .crop-result-thumb { width: 64px; height: 64px; }
}

.batch-ai-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.batch-ai-bar .ai-btn {
  margin-top: 0;
  flex: 1;
}
.batch-ai-bar .batch-progress {
  font-size: 12px;
  color: var(--text-secondary);
}

.image-add-btn {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  color: var(--text-tertiary);
  font-size: 11px;
  transition: all 0.15s;
  gap: 4px;
}
.image-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.image-add-btn .add-icon { font-size: 24px; }

.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.1); }

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  letter-spacing: 0.01em;
}
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.hidden { display: none !important; }

/* ===== AI ANALYSIS ===== */
.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--ai), #5a4bd1);
  color: #fff;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
}
.ai-btn:hover { background: linear-gradient(135deg, #5a4bd1, var(--ai)); box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3); transform: translateY(-2px); }
.ai-btn:active { transform: translateY(0); }
.ai-btn.loading { pointer-events: none; opacity: 0.7; }

.ai-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-result {
  margin-top: 8px;
  padding: 12px;
  background: var(--success-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--success);
  display: none;
}
.ai-result.show { display: block; }

.ai-settings-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  margin-left: auto;
}
.ai-settings-btn:hover { background: var(--bg-hover); color: var(--text); }
.ai-settings-btn.configured { color: var(--ai); border-color: var(--ai); }

.api-key-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.5;
}
.api-key-hint a { color: var(--info); }

.model-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.model-option {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  transition: all 0.15s;
}
.model-option:hover { border-color: var(--text-tertiary); }
.model-option.selected {
  border-color: var(--ai);
  background: var(--ai-light);
  color: var(--ai);
}
.model-option .model-name { font-weight: 500; margin-bottom: 2px; }
.model-option .model-desc { font-size: 11px; color: var(--text-tertiary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ai { background: var(--ai-light); color: var(--ai); }
.badge-success { background: var(--success-light); color: var(--success); }

.analysis-preview {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  align-items: flex-start;
}
.analysis-preview-img {
  width: 60px; height: 60px;
  border-radius: var(--radius-xs);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.analysis-fields { flex: 1; }
.analysis-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.analysis-field-label {
  color: var(--text-tertiary);
  min-width: 36px;
  font-size: 11px;
}
.analysis-field-value { color: var(--text); }
.analysis-field-value.auto-filled { color: var(--ai); font-weight: 500; }

/* ===== RESPONSIVE ===== */
.mobile-header, .picker-head, .nav-icon, .mobile-only { display: none; }
.only-mobile { display: none; }

/* ===== 手机版 ===== */
@media (max-width: 768px) {
  .app { flex-direction: column; height: 100dvh; }

  /* 顶部栏 */
  .mobile-header {
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--bg-card); border-bottom: 1px solid var(--border-light);
  }
  .mobile-brand { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: 0.04em; }
  .mobile-count { flex: 1; font-size: 12px; color: var(--text-tertiary); }

  /* 左侧栏：衣橱页只留搜索和筛选；画板页变成底部弹出的"选衣服"面板；其他页隐藏 */
  .sidebar { width: 100%; min-width: 0; height: auto; flex-shrink: 0; border-right: none; border-bottom: 1px solid var(--border-light); }
  .sidebar-header, .sidebar-items, .sidebar-actions { display: none; }
  body:not([data-view="wardrobe"]) .sidebar { display: none; }
  .sidebar-search { padding: 10px 14px 6px; }
  .sidebar-filters { padding: 0 14px 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sidebar-filters::-webkit-scrollbar { display: none; }
  .filter-chip { white-space: nowrap; flex-shrink: 0; }
  .more-filters-bar { padding: 0 14px 8px; }
  .more-filters-panel { padding: 0 14px 10px; }

  body[data-view="studio"].picker-open .sidebar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 72dvh; z-index: 300;
    border-radius: 18px 18px 0 0; border: none; box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.picker-open .sidebar-items { display: block; padding: 4px 14px 14px; }
  body.picker-open .picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 4px; font-size: 13px; color: var(--text-secondary); }
  body.picker-open .more-filters-bar, body.picker-open .more-filters-panel { display: none; }

  /* 添加单品：右下角悬浮按钮 */
  body[data-view="wardrobe"] .sidebar-actions {
    display: block; position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 60; padding: 0;
  }
  .sidebar-actions .btn { border-radius: 28px; padding: 14px 22px; font-size: 15px; box-shadow: var(--shadow-xl); }

  /* 底部标签栏 */
  .main { flex: 1; min-height: 0; }
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    padding: 0 0 env(safe-area-inset-bottom); justify-content: space-around;
    border-top: 1px solid var(--border); border-bottom: none;
  }
  .nav-tab { flex: 1; padding: 8px 0 7px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; letter-spacing: 0; }
  .nav-tab.active::after { display: none; }
  .nav-tab.active { color: var(--accent-dark); font-weight: 600; }
  .nav-icon { display: block; font-size: 20px; line-height: 1; filter: grayscale(1); opacity: 0.55; }
  .nav-tab.active .nav-icon { filter: none; opacity: 1; }

  .main-content { padding: 14px 14px calc(86px + env(safe-area-inset-bottom)) !important; overflow: auto !important; }
  .restore-banner { margin: 10px 14px 0; }

  /* 衣橱 */
  .wardrobe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

  /* 画板 */
  .studio-layout { flex-direction: column; gap: 14px; }
  #view-studio, .studio-layout { height: auto !important; }
  .board-wrap { container-type: inline-size; }
  .board { width: 100%; }
  .board-hint { font-size: 11px; }
  .studio-panel { width: 100%; max-height: none; }
  .studio-toolbar { flex-direction: column; align-items: stretch; }
  .studio-toolbar-actions { flex-wrap: wrap; }
  .mobile-only { display: inline-flex; }
  .only-mobile { display: inline; }
  .only-desktop { display: none; }

  /* 搭配 & 统计 */
  .outfits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .outfit-card-actions { padding: 0 10px 10px; gap: 4px; }
  .outfit-card-actions .btn { font-size: 11px; padding: 5px 0; }
  .outfit-card-body { padding: 10px; }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 24px; }
  .stats-card { padding: 14px; }
  .stat-items { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
  .wear-day { grid-template-columns: 56px 1fr; }

  /* 弹窗全屏 */
  .modal-overlay { align-items: stretch; z-index: 400; }
  .modal-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .modal { width: 100%; max-width: none !important; max-height: none; height: 100dvh; border-radius: 0; margin: 0; }
  .modal-header { position: sticky; top: 0; z-index: 5; background: var(--bg-card); padding-top: calc(16px + env(safe-area-inset-top)); }

  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); }
}

/* 触屏设备没有"悬停"，把只在悬停时出现的按钮直接显示出来 */
@media (hover: none) {
  .wear-del { opacity: 1; }
}

/* ===== 登录 ===== */
.login-screen { position: fixed; inset: 0; z-index: 500; background: var(--bg-accent); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 36px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { font-family: var(--font-display); font-size: 26px; font-weight: 600; text-align: center; letter-spacing: 0.04em; }
.login-sub { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.14em; color: var(--text-tertiary); text-align: center; margin-top: -10px; margin-bottom: 8px; }
.login-error { min-height: 18px; font-size: 12px; color: var(--danger); text-align: center; }

/* ===== 批量导入 ===== */
.sidebar-actions .btn:not(.btn-primary) { white-space: nowrap; }
.batch-progress-bar { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.batch-progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.batch-list { display: flex; flex-direction: column; gap: 8px; }
.batch-row { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); }
.batch-row.status-saved { border-color: var(--border); }
.batch-row.status-failed { border-color: var(--danger-light); background: #fffafa; }
.batch-thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: var(--radius-xs); background: #faf8f5 center / cover no-repeat; position: relative; display: flex; align-items: center; justify-content: center; }
.batch-thumb .ai-spinner { width: 18px; height: 18px; border-width: 2px; }
.batch-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.batch-name { padding: 6px 10px; font-size: 13px; }
.batch-cat { padding: 5px 30px 5px 10px; font-size: 12px; max-width: 140px; }
.batch-status { font-size: 13px; color: var(--text-secondary); }
.batch-warn { font-size: 11px; color: var(--danger); line-height: 1.5; }
.batch-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.batch-del { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg-hover); color: var(--text-tertiary); cursor: pointer; font-size: 13px; }
.batch-del:hover { background: var(--danger-light); color: var(--danger); }
.batch-chip { position: fixed; right: 20px; bottom: 24px; z-index: 250; border: none; border-radius: 20px; padding: 10px 16px; background: var(--text); color: #fff; font-size: 13px; box-shadow: var(--shadow-xl); cursor: pointer; font-family: inherit; }
.review-filter { padding: 0 24px 8px; }
.review-filter .filter-chip { border-color: var(--warning); color: var(--warning-text); background: var(--warning-light); }
.review-filter .filter-chip.active { background: var(--warning-strong); border-color: var(--warning-strong); color: #fff; }
.review-badge { position: absolute; right: 8px; top: 8px; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--warning-strong); color: #fff; }
.wardrobe-card-img { position: relative; }
.image-card .card-primary-btn { margin: 6px; }
@media (max-width: 768px) {
  body[data-view="wardrobe"] .sidebar-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
  .sidebar-actions .btn:not(.btn-primary) { padding: 10px 16px; font-size: 13px; background: var(--bg-card); }
  .batch-chip { bottom: calc(80px + env(safe-area-inset-bottom)); right: 14px; }
  .review-filter { padding: 0 14px 8px; }
}

/* ===== 无障碍：键盘焦点、可点按区域 ===== */
:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; border-radius: 6px; }
.form-input:focus-visible { outline: none; }
button.filter-chip, button.chip-option { font-family: inherit; line-height: inherit; }
button.color-swatch { padding: 0; appearance: none; -webkit-appearance: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 768px) {
  /* 手机上的按钮至少 40px 高，手指好点 */
  .filter-chip, .btn-sm, .outfit-card-actions .btn, .seg-toggle button { min-height: 40px; }
  .chip-option { min-height: 36px; display: inline-flex; align-items: center; }
  .ai-settings-btn, .modal-close { width: 40px; height: 40px; }
  .link-btn { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01s !important; }
  .toast, .modal, .studio-tryon-card { animation-duration: 0.01s !important; }
}

/* 不显眼的删除按钮：危险操作不和主要操作抢注意力 */
.btn-quiet-danger { background: transparent; border-color: transparent; color: var(--danger); box-shadow: none; }
.btn-quiet-danger:hover { background: var(--danger-light); border-color: transparent; }

/* ===== 今天穿什么 ===== */
.today-strip { margin-bottom: 20px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.today-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.today-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.today-status { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.today-status.done { color: var(--success); font-weight: 500; }
.today-cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.today-card { flex: 0 0 112px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; text-align: left; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-card); padding: 6px; cursor: pointer; font-family: inherit; transition: border-color 0.15s, transform 0.15s; }
.today-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.today-card.worn { border-color: var(--success); background: var(--success-light); }
.today-thumb { display: block; aspect-ratio: 3 / 4; border-radius: 8px; background: var(--board-bg) center / cover no-repeat; }
.today-plus { display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--accent-dark); }
.today-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-meta { font-size: 11px; color: var(--text-tertiary); }
@media (max-width: 768px) {
  .today-strip { margin: 0 0 14px; padding: 14px; }
  .today-card { flex-basis: 96px; }
  /* 手机：提示条放到顶部，不和右下角的"添加单品"按钮撞在一起；衣橱页底部留出按钮的位置 */
  .toast { top: calc(64px + env(safe-area-inset-top)); bottom: auto; }
  body[data-view="wardrobe"] .main-content { padding-bottom: calc(190px + env(safe-area-inset-bottom)) !important; }
  .batch-chip { left: 14px; right: auto; }
}

/* 文字链接按钮至少 24px 高（WCAG 2.5.8） */
.link-btn { padding: 4px 0; }
.batch-del { width: 36px; height: 36px; }
.wear-del { min-width: 36px; }

/* ===== 批量导入：一行一件，显示这件的几张照片 ===== */
.batch-photos { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.batch-thumb.small { width: 40px; height: 40px; }
.batch-more { font-size: 12px; color: var(--text-secondary); padding: 0 4px; }
.batch-line { display: flex; align-items: center; gap: 8px; }
.batch-count { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.batch-fix { display: flex; gap: 14px; flex-wrap: wrap; }
.batch-pool { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 768px) {
  .batch-row { flex-wrap: wrap; }
  .batch-photos { width: 100%; }
}

/* ===== 衣橱多选 ===== */
.grid-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grid-count { font-size: 13px; color: var(--text-secondary); }
.wardrobe-card.selecting { cursor: pointer; }
.wardrobe-card.is-selected { outline: 2.5px solid var(--accent-dark); outline-offset: 2px; }
.select-check { position: absolute; left: 8px; top: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,0.25); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.2); z-index: 2; }
.wardrobe-card.is-selected .select-check { background: var(--accent-dark); }
.select-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 260; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 10px 14px; max-width: calc(100% - 28px); }
.select-count { font-size: 13px; color: var(--text); margin-right: 4px; }
.select-bar .btn:disabled { opacity: 0.45; cursor: not-allowed; }
body.selecting .sidebar-actions { display: none !important; }
@media (max-width: 768px) {
  .select-bar { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 28px); }
  .select-count { width: 100%; text-align: center; margin: 0 0 2px; }
}
