/* ============================================================
   Fusion Design System — Vercel × Stripe × Framer
   High-tech, bright, premium — for AI 创意工坊
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Backgrounds */
  --bg-page: #fafbfc;
  --bg-white: #ffffff;
  --bg-subtle: #f5f7fa;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255,255,255,0.7);
  --bg-gradient-start: #eef2ff;
  --bg-gradient-end: #f0f9ff;

  /* Text — Vercel-inspired hierarchy */
  --text-primary: #0a0a23;
  --text-heading: #0a0a23;
  --text-secondary: #4a4a6a;
  --text-tertiary: #8a8aaa;
  --text-quaternary: #b0b0c8;
  --text-muted: #c8c8dd;
  --text-on-brand: #ffffff;

  /* Brand — Stripe purple core */
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-light: #818cf8;
  --brand-subtle: rgba(99,102,241,0.08);
  --brand-glow: rgba(99,102,241,0.15);
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-gradient-soft: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 50%, #fdf2f8 100%);

  /* Accent — Framer blue */
  --accent: #0099ff;
  --accent-subtle: rgba(0,153,255,0.08);

  /* Status */
  --success: #10b981;
  --success-subtle: rgba(16,185,129,0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245,158,11,0.1);
  --error: #ef4444;
  --error-subtle: rgba(239,68,68,0.1);

  /* Borders — Vercel shadow-as-border */
  --border-subtle: rgba(0,0,0,0.04);
  --border-default: rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.10);
  --border-brand: rgba(99,102,241,0.3);

  /* Shadows — Stripe blue-tinted multi-layer */
  --shadow-sm: 0px 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0px 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0px 12px 32px -8px rgba(50,50,93,0.15), 0px 4px 12px rgba(0,0,0,0.06);
  --shadow-xl: 0px 20px 48px -12px rgba(50,50,93,0.20), 0px 8px 24px rgba(0,0,0,0.08);
  --shadow-card: 0px 0px 0px 1px rgba(0,0,0,0.04), 0px 2px 4px rgba(0,0,0,0.03);
  --shadow-card-hover: 0px 0px 0px 1px rgba(99,102,241,0.2), 0px 8px 24px rgba(99,102,241,0.12);
  --shadow-input-focus: 0px 0px 0px 3px rgba(99,102,241,0.12);

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 24px;
  --r-full: 9999px;

  /* Spacing */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-8: 16px;
  --space-10: 20px;
  --space-12: 24px;
  --space-14: 28px;
  --space-16: 32px;
  --space-20: 40px;
  --space-24: 48px;
  --space-32: 64px;

  /* Fonts */
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Fira Code', monospace;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--brand); color: white; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4e0; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0c0; }

/* ===== Layout ===== */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-16) var(--space-10) var(--space-32);
}

/* ===== Glass Card ===== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--r-lg);
}

/* ===== Header ===== */
.header {
  padding: var(--space-12) var(--space-2) var(--space-10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-8);
}
.header-left { display: flex; align-items: center; gap: var(--space-6); }
.logo {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--text-heading);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--brand);
  background: var(--brand-subtle);
  padding: 2px 8px;
  border-radius: var(--r-full);
  border: 1px solid rgba(99,102,241,0.15);
}
.header-desc {
  font-size: 14px;
  color: var(--text-tertiary);
  width: 100%;
  margin-top: var(--space-1);
}

/* ===== Back link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
}
.back-link:hover { color: var(--brand); background: var(--brand-subtle); }

/* ===== Cards ===== */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--space-10);
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-brand);
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-8);
  color: var(--text-heading);
}

/* ===== Forms ===== */
.field { margin-bottom: var(--space-8); }
.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  transition: all 0.15s ease;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: var(--shadow-input-focus);
}
.input::placeholder, textarea::placeholder { color: var(--text-quaternary); }
textarea { resize: vertical; min-height: 48px; }
select {
  cursor: pointer;
  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='%238a8aaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 20px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
  background: var(--bg-white);
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand-gradient);
  color: white;
  border: none;
  box-shadow: 0px 2px 8px rgba(99,102,241,0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0px 4px 16px rgba(99,102,241,0.35);
  transform: translateY(-1px);
}
.btn-primary:disabled { background: #a5b4fc; box-shadow: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  width: auto;
}
.btn-ghost:hover { background: var(--brand-subtle); color: var(--brand); border-color: var(--border-brand); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-icon:hover { background: var(--bg-subtle); color: var(--brand); border-color: var(--border-brand); }

/* ===== Chat Messages ===== */
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-subtle);
  border-radius: var(--r-lg);
  padding: var(--space-8);
  border: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-height: 400px;
  max-height: 60vh;
}
.chat-welcome {
  text-align: center;
  padding: var(--space-24) var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}
.chat-welcome svg { color: var(--text-quaternary); }
.chat-welcome p { font-size: 15px; color: var(--text-tertiary); }
.chat-welcome small { font-size: 12px; color: var(--text-quaternary); }

.msg { display: flex; flex-direction: column; animation: fadeUp 0.2s ease; }
.msg-user { align-items: flex-end; }
.msg-ai { align-items: flex-start; }
.msg-bubble {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-user .msg-bubble {
  background: var(--brand-gradient);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-ai .msg-bubble {
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.msg-ai .msg-bubble.thinking { color: var(--text-tertiary); font-style: italic; }
.msg-ai .msg-bubble img { max-width: 100%; border-radius: var(--r-sm); margin-top: 6px; }
.msg-actions { display: flex; gap: 4px; margin-top: 4px; }
.msg-actions button {
  background: none; border: none; color: var(--text-quaternary);
  font-size: 11px; cursor: pointer; padding: 2px 6px;
  border-radius: var(--r-sm); transition: all 0.15s ease; font-family: var(--font);
}
.msg-actions button:hover { background: var(--bg-subtle); color: var(--brand); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Chat Input */
.chat-input-area {
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  background: var(--bg-white);
  margin-top: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.chat-input-row { display: flex; gap: var(--space-4); align-items: flex-end; }
.chat-input-field { flex: 1; min-height: 40px; max-height: 100px; margin-bottom: 0; }
.chat-tools { display: flex; gap: var(--space-2); align-items: center; }
.chat-tool {
  cursor: pointer; padding: var(--space-4); border-radius: var(--r-sm);
  color: var(--text-quaternary); transition: all 0.15s ease;
  display: flex; align-items: center; line-height: 1;
  background: none; border: none; font-family: var(--font);
}
.chat-tool:hover { color: var(--brand); background: var(--brand-subtle); }
.chat-send { width: auto; padding: 8px 16px; white-space: nowrap; }
.chat-preview-bar {
  display: flex; align-items: center; gap: var(--space-3);
  margin-top: var(--space-4); padding: 6px 10px;
  background: var(--bg-subtle); border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
}
.chat-preview-bar img { max-height: 48px; border-radius: var(--r-sm); }
.chat-preview-remove { background: none; border: none; color: var(--error); cursor: pointer; font-size: 14px; font-family: var(--font); padding: 2px 4px; }

/* Sidebar */
.sb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-6); }
.sb-title { font-size: 12px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }
.sb-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 500px; overflow-y: auto; }
.sb-item {
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  transition: all 0.15s ease; border: 1px solid transparent;
}
.sb-item:hover { background: var(--bg-subtle); border-color: var(--border-default); }
.sb-item.active { background: var(--brand-subtle); border-color: var(--border-brand); }
.sb-item-title { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item-meta { font-size: 11px; color: var(--text-quaternary); }
.sb-item .sb-del { float: right; background: none; border: none; color: var(--text-quaternary); cursor: pointer; font-size: 14px; padding: 0 2px; opacity: 0; transition: opacity 0.15s ease; line-height: 1; }
.sb-item:hover .sb-del { opacity: 1; }
.sb-item .sb-del:hover { color: var(--error); }
.sb-empty { text-align: center; color: var(--text-quaternary); font-size: 13px; padding: var(--space-10) 0; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--r-sm);
  background: var(--text-primary); color: white;
  font-family: var(--font); font-size: 12px; font-weight: 500;
  z-index: 9999; animation: toastUp 0.2s ease;
  box-shadow: var(--shadow-lg); white-space: nowrap;
}
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }
@keyframes toastUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Footer */
.footer {
  text-align: center; padding: var(--space-20) var(--space-8) var(--space-12);
  color: var(--text-quaternary); font-size: 12px;
  display: flex; justify-content: center; gap: var(--space-5); align-items: center;
  margin-top: var(--space-10); border-top: 1px solid var(--border-default);
}

/* ===== Gradient text utility ===== */
.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Glass effect ===== */
.glass-effect {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.8);
}

/* ===== Skeleton loading ===== */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, #f0f0f5 25%, #e8e8ef 50%, #f0f0f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app { padding: var(--space-10) var(--space-6) var(--space-16); }
  .header { padding: var(--space-8) var(--space-2); }
  .logo { font-size: 22px; }
}
@media (max-width: 768px) {
  .msg-bubble { max-width: 88%; font-size: 13px; }
  .card { padding: var(--space-8); }
}
