* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;
  --accent: #7c5cfc;
  --accent-end: #6366f1;
  --accent-soft: rgba(124,92,252,0.06);
  --accent-border: rgba(124,92,252,0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --apple-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; }

/* ─── 左侧导航 ─── */
.sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-header { padding: 0 20px 24px; }

.app-brand {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -2px;
  position: relative;
}

.app-brand::after {
  content: "✦";
  position: absolute;
  top: -6px;
  right: -18px;
  font-size: 16px;
  color: #7042ff;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(0,0,0,0.03); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon { width: 20px; font-size: 16px; text-align: center; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

/* ─── 主区域 ─── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 顶栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.toolbar-left { display: flex; align-items: baseline; gap: 12px; }

.page-title { font-size: 16px; font-weight: 600; }

.page-desc { font-size: 12px; color: var(--text-3); }

.toolbar-right { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

/* ─── 拆分页面 ─── */
.split-page {
  flex: 1;
  display: flex;
  gap: 20px;
  overflow: hidden;
  height: 100%;
}

/* 中间区域 */
.split-center {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.split-source { flex: 1; display: flex; min-width: 0; }
.split-result { flex: 1; display: flex; min-width: 0; }

.split-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-shrink: 0;
  width: 140px;
}

.action-info {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.6;
}

/* 面板通用 */
.panel {
  background: rgba(255,255,255,0.72);
  border-radius: var(--radius);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.04),
    0 12px 32px rgba(0,0,0,0.06),
    inset 0 0 0 0.5px rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  padding: 16px 20px 0;
  color: var(--text);
}

/* 原图预览 */
.source-panel { padding-bottom: 16px; }

.source-image {
  flex: 1;
  margin: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  padding-top: 0;
  border: 2px dashed rgba(0,0,0,0.08);
}

.source-image.drag-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
}

.upload-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 4px;
}

.upload-placeholder p { font-size: 13px; color: var(--text-2); }
.upload-placeholder span { font-size: 11px; }

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
}

.source-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px;
}

/* 按钮 */
.btn-secondary {
  padding: 8px 18px;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.25s var(--apple-ease);
}

.btn-secondary:hover { border-color: var(--accent-border); color: var(--accent); }

.primary-btn {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.25s var(--apple-ease), transform 0.25s var(--apple-ease);
  box-shadow: 0 4px 14px rgba(124,92,252,0.25);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
  pointer-events: none;
}

.primary-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 下载按钮 */
.download-btn {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 50px;
  background: #10b981;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.25s var(--apple-ease), transform 0.25s var(--apple-ease);
  box-shadow: 0 4px 14px rgba(16,185,129,0.25);
  position: relative;
  overflow: hidden;
}

.download-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
  pointer-events: none;
}

.download-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.download-btn:active { transform: scale(0.97); }

/* 拆分结果 */
.result-panel { flex: 1; }

.result-content {
  flex: 1;
  padding: 0 20px 16px;
  overflow-y: auto;
}

.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--text-3);
  gap: 4px;
}

.result-empty p { font-size: 13px; color: var(--text-2); }
.result-empty span { font-size: 11px; }

/* 拆分结果 - 图片展示 */
.result-image-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
}

.result-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* 切图网格（备用） */
.crop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  padding: 12px 0;
}

.crop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  transition: all 0.25s var(--apple-ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
}

.crop-item:hover {
  background: var(--accent-soft);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
}

.crop-thumb-wrap {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#e8e8e8 0% 25%, #fff 0% 50%) 50% / 12px 12px;
  border-radius: 6px;
  overflow: hidden;
}

.crop-thumb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.crop-meta {
  text-align: center;
  width: 100%;
}

.crop-name {
  display: block;
  font-size: 10px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crop-type-tag {
  display: inline-block;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  margin-top: 2px;
}

.crop-count {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 12px 0 4px;
}

/* 加载进度 */
.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  gap: 12px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(124,92,252,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-loading p { font-size: 13px; color: var(--text-2); }
.loading-hint { font-size: 11px; color: var(--text-3); }

.copy-error-btn {
  margin-top: 12px;
  padding: 6px 14px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}

.copy-error-btn:hover { background: rgba(0,0,0,0.04); }

.progress-track {
  width: 180px;
  height: 4px;
  background: rgba(0,0,0,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-end));
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
}

/* 组件卡片 */
.comp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  margin-bottom: 8px;
  transition: background 0.25s var(--apple-ease);
  cursor: pointer;
}

.comp-card:hover { background: var(--accent-soft); }

.comp-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: rgba(124,92,252,0.1);
  flex-shrink: 0;
}

.comp-info { flex: 1; min-width: 0; }
.comp-info h4 { font-size: 13px; font-weight: 500; }
.comp-info p { font-size: 11px; color: var(--text-3); }

.comp-type {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ─── 右侧图片列表 ─── */
.split-sidebar {
  width: 200px;
  flex-shrink: 0;
}

.list-panel {
  height: 100%;
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.list-desc {
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 20px 12px;
}

.image-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.25s var(--apple-ease);
  font-size: 12px;
  color: var(--text-2);
}

.list-item:hover { background: rgba(0,0,0,0.03); }
.list-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.list-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
}

.list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-source {
  font-size: 10px;
  color: var(--text-3);
}

.list-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* 滚动条 */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 2px; }

/* 页面容器 */
.page-container { flex: 1; overflow: hidden; }
.page-view { display: none; height: 100%; overflow-y: auto; padding: 24px; }
.page-view.active { display: block; }
#page-split { overflow: hidden; } /* 拆分页面不需要滚动 */
#page-home {
  overflow: hidden;
  padding: 0 24px 18px;
  background:
    radial-gradient(circle at 78% 8%, rgba(122,86,255,0.16), transparent 24%),
    radial-gradient(circle at 16% 16%, rgba(125,183,255,0.1), transparent 28%),
    linear-gradient(135deg, #fbfcff 0%, #f4f2ff 52%, #fbfdff 100%);
} /* 首页一屏展示 + 紫色渐变底板 */
.placeholder-page { display: flex; align-items: center; justify-content: center; height: 300px; color: var(--text-3); font-size: 14px; }


/* ─── 侧边栏底部模块 ─── */
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 10px;
}

.sidebar-bottom .join-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  color: var(--text-2);
}

.sidebar-community-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.sidebar-community {
  height: 52px;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-decoration: none;
  backdrop-filter: blur(8px);
  letter-spacing: 0.1px;
}

.sidebar-community:hover {
  background: rgba(124,92,252,0.06);
}

.sidebar-community:active {
  opacity: 0.7;
}

.sidebar-community svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.sidebar-community:hover svg {
  opacity: 1;
}

.sidebar-cta {
  height: 40px;
  margin-top: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(116,76,255,0.08), rgba(255,255,255,0.85));
  border: 1px solid rgba(230,226,255,0.95);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  color: #6b38ff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease;
}

.sidebar-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.02);
}

.sidebar-cta .cta-arrow {
  margin-left: auto;
}

