*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --purple-50: #faf5ff; --purple-100: #f3e8ff; --purple-200: #e9d5ff; --purple-300: #d8b4fe;
  --purple-400: #c084fc; --purple-500: #a855f7; --purple-600: #9333ea; --purple-700: #7c3aed;
  --pink-100: #fce7f3; --pink-200: #fbcfe8; --pink-300: #f9a8d4; --pink-400: #f472b6;
  --blue-100: #dbeafe; --blue-200: #bfdbfe; --blue-300: #93c5fd;
  --green-100: #d1fae5; --green-200: #bbf7d0; --green-500: #22c55e;
  --amber-100: #fef3c7; --amber-200: #fde68a;
  --bg: #f8f7fc; --surface: #ffffff; --border: #ede8f5;
  --text: #3b3264; --text-dim: #8b83a8; --text-muted: #b5aec8;
  --radius: 14px; --radius-sm: 10px; --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased;
}

.topbar {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-700));
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; display: flex; align-items: center;
  justify-content: space-between; gap: 18px; padding: 12px 28px;
}
.logo { display: flex; align-items: center; gap: 11px; color: #fff; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; flex-shrink: 0; }
.logo span { font-size: 1.2rem; }

.search-box {
  flex: 0 1 420px; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm); padding: 8px 14px;
  transition: background 0.2s, border-color 0.2s;
}
.search-box:focus-within { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.4); }
.search-box svg { flex-shrink: 0; color: rgba(255,255,255,0.7); }
.search-box input {
  flex: 1; border: none; background: none; outline: none;
  font-family: var(--font); font-size: 0.875rem; color: #fff;
}
.search-box input::placeholder { color: rgba(255,255,255,0.55); }
.search-clear {
  background: none; border: none; color: rgba(255,255,255,0.6);
  cursor: pointer; padding: 2px; display: flex; border-radius: 4px; transition: color 0.15s;
}
.search-clear:hover { color: #fff; }

.nav-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.btn {
  padding: 10px 20px; border-radius: var(--radius-sm); border: none;
  font-family: var(--font); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s ease, transform 0.15s ease;
  display: inline-flex; align-items: center; gap: 8px; letter-spacing: -0.01em;
  white-space: nowrap;
}
.btn-primary { background: #fff; color: var(--purple-700); }
.btn-primary:hover { background: #ede5ff; }
.btn-outline { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.btn-outline:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.35); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--purple-50); color: var(--purple-600); }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fde8e8; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: var(--radius-xs); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.layout { display: flex; max-width: 1400px; margin: 0 auto; min-height: calc(100vh - 57px); }

.sidebar {
  width: 250px; flex-shrink: 0; padding: 28px 22px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-sticky { position: sticky; top: 77px; }
.filter-section { margin-bottom: 26px; }
.filter-section h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: 12px; font-weight: 700;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 0.8rem; font-family: var(--font); font-weight: 500;
  transition: all 0.2s ease;
}
.chip:hover { border-color: var(--purple-400); color: var(--purple-600); background: var(--purple-50); }
.chip.active { background: var(--purple-600); border-color: var(--purple-600); color: #fff; font-weight: 600; }

.gallery {
  flex: 1; padding: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px; align-content: start;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: border-color 0.2s ease;
}
.card:hover { border-color: var(--purple-300); }
.card-img-wrap { position: relative; overflow: hidden; background: var(--purple-50); }
.card-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; transition: transform 0.3s ease; }
.card:hover .card-img { transform: scale(1.04); }
.card-body { padding: 15px 18px; }
.card-title { font-size: 0.88rem; font-weight: 600; margin-bottom: 9px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.card-tags { display: flex; gap: 7px; flex-wrap: wrap; }
.tag {
  padding: 4px 11px; border-radius: 20px; font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.01em;
}
.tag.category { background: var(--purple-100); color: var(--purple-700); }
.tag.style { background: var(--green-100); color: #065f46; }

.loading, .empty {
  grid-column: 1 / -1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 80px 20px;
  color: var(--text-dim); gap: 16px; text-align: center;
}
.empty h3 { color: var(--text); font-size: 1.1rem; }
.empty p { max-width: 360px; color: var(--text-dim); font-size: 0.9rem; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--purple-100);
  border-top-color: var(--purple-500); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(59,50,100,0.45); backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; max-width: 520px; width: 92%;
  max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { margin-bottom: 24px; }
.modal h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.modal-sub { color: var(--text-dim); font-size: 0.88rem; margin-top: 5px; line-height: 1.4; }
.modal label { display: block; margin-bottom: 16px; }
.modal label > span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  transition: border-color 0.2s;
}
.input-wrap:focus-within { border-color: var(--purple-400); }
.input-wrap svg { flex-shrink: 0; color: var(--text-muted); }
.input-wrap input {
  flex: 1; border: none; background: none; outline: none;
  font-family: var(--font); font-size: 0.9rem; color: var(--text);
}
.input-wrap input::placeholder { color: var(--text-muted); }
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 28px; text-align: center; cursor: pointer; transition: all 0.2s;
  color: var(--text-dim); position: relative;
}
.upload-zone:hover { border-color: var(--purple-300); background: var(--purple-50); }
.upload-zone p { font-size: 0.88rem; margin-top: 8px; }
.upload-zone .browse { color: var(--purple-600); font-weight: 600; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview { width: 100%; max-height: 200px; object-fit: contain; margin-top: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.or-divider { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; color: var(--text-muted); font-size: 0.78rem; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.status { margin-top: 14px; font-size: 0.85rem; font-weight: 500; padding: 10px 14px; border-radius: var(--radius-sm); }
.status.success { background: var(--green-100); color: #065f46; }
.status.error { background: #fef2f2; color: #991b1b; }
.status.loading { background: var(--purple-50); color: var(--purple-600); }

.detail-modal { max-width: 780px; padding: 0; overflow: hidden; position: relative; }
.modal-close-btn {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  background: rgba(255,255,255,0.85); border: none; border-radius: 50%;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.modal-close-btn:hover { background: #fff; }
.detail-img-wrap { background: var(--purple-50); display: flex; align-items: center; justify-content: center; min-height: 220px; }
#detail-img { width: 100%; max-height: 400px; object-fit: contain; display: block; }
.detail-info { padding: 26px 30px 30px; }
.detail-info h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.detail-tags { display: flex; gap: 9px; margin: 10px 0 18px; }
.prompt-box { background: var(--purple-50); border: 1px solid var(--purple-100); border-radius: var(--radius-sm); padding: 18px; margin-bottom: 18px; }
.prompt-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.prompt-header h4 { font-size: 0.82rem; font-weight: 600; color: var(--purple-700); flex: 1; }
.prompt-header .btn { margin-left: auto; }
.prompt-box pre { white-space: pre-wrap; font-size: 0.82rem; color: var(--text); line-height: 1.65; font-family: var(--font); }
.detail-footer { display: flex; gap: 10px; align-items: center; }
.detail-footer a { text-decoration: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 14px 18px; }
  .sidebar-sticky { position: static; display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
  .filter-section { margin-bottom: 0; }
  .gallery { padding: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .search-box { flex: 1 1 auto; }
}
