:root {
  /* 现代极简色彩系统 */
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-border: #eaeaea;
  --color-border-hover: #cccccc;
  
  --color-text: #111111;
  --color-text-muted: #666666;
  --color-text-light: #999999;
  
  --color-primary: #000000;
  --color-primary-hover: #333333;
  --color-primary-light: #f5f5f5;
  
  --color-accent: #3b82f6; /* 局部高亮蓝 */
  
  --color-danger: #e3342f;
  --color-success: #0070f3;
  
  /* 干净的弥散阴影 */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 { 
  font-weight: 600; 
  color: var(--color-text); 
  letter-spacing: -0.02em;
}

a { 
  text-decoration: none; 
  color: var(--color-text); 
  transition: color 0.2s;
}
a:hover {
  color: var(--color-text-muted);
}

button { 
  font-family: inherit; 
  cursor: pointer; 
  border: none; 
  background: none; 
  outline: none;
}

input, textarea, select { 
  font-family: inherit; 
  outline: none;
  border: none;
}

/* Utilities */
.hidden { display: none !important; }
.flex-1 { flex: 1; }

/* 背景光晕装饰 */
.bg-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}
.blur-blue {
  top: -100px;
  left: -100px;
  background: #3b82f6;
}
.blur-purple {
  bottom: -100px;
  right: -100px;
  background: #8b5cf6;
}

/* Modern Components */
.modern-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modern-input {
  width: 100%;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--color-text);
  font-size: 14px;
  transition: all 0.2s ease;
}
.modern-input:hover {
  border-color: var(--color-border-hover);
}
.modern-input:focus {
  background-color: var(--color-surface);
  border-color: var(--color-text);
  box-shadow: 0 0 0 1px var(--color-text);
}
.modern-input::placeholder {
  color: var(--color-text-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background-color: var(--color-bg);
  border-color: var(--color-border-hover);
}
.btn-ghost {
  color: var(--color-text-muted);
}
.btn-ghost:hover {
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* --- Auth Layout (index.html) --- */
.top-logo {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 24px;
  animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-card {
  padding: 48px;
  box-shadow: var(--shadow-lg);
}
.auth-header {
  text-align: center;
  margin-bottom: 32px;
}
.auth-header h1 {
  font-size: 24px;
  margin-bottom: 8px;
}
.auth-header p {
  color: var(--color-text-muted);
  font-size: 14px;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
#loginButton {
  margin-top: 12px;
}

/* --- App Layout (home.html) --- */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--color-bg);
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  padding: 16px 32px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-brand h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}
.header-balance {
  font-size: 14px;
  color: var(--color-text-muted);
}
.header-balance strong {
  color: var(--color-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  overflow: hidden;
}

/* Creator Panel */
.creator-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 32px;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
}
/* 优雅的滚动条 */
.creator-panel::-webkit-scrollbar { width: 4px; }
.creator-panel::-webkit-scrollbar-thumb { background-color: var(--color-border); border-radius: 4px; }
.creator-panel::-webkit-scrollbar-thumb:hover { background-color: var(--color-border-hover); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

textarea.modern-input {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

select.modern-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666666' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* Upload & Reference Grid */
.reference-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ref-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--color-border);
  position: relative;
  background-color: var(--color-surface);
}
.ref-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 悬浮触发删除按钮：8px圆角方形 */
.ref-item .delete-ref-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.85);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.ref-item:hover .delete-ref-btn {
  opacity: 1;
}

.ref-item .delete-ref-btn:hover {
  background-color: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

.upload-trigger {
  position: relative;
  border: 1px dashed var(--color-border-hover);
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: var(--color-bg);
  transition: all 0.2s;
}
.upload-trigger:hover {
  border-color: var(--color-text);
  background-color: var(--color-surface);
}
.upload-trigger .file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}
.upload-trigger svg {
  color: var(--color-text-muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

/* Result Panel */
.result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow-y: auto;
}

.result-empty {
  text-align: center;
  color: var(--color-text-muted);
}
.empty-icon {
  font-size: 32px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.result-empty h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--color-text);
}
.result-empty p {
  font-size: 14px;
}

.result-content, .result-skeleton {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.image-wrapper {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-actions {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.cost-badge {
  font-size: 13px;
  color: var(--color-text-muted);
}
.cost-badge span {
  color: var(--color-text);
  font-weight: 500;
}
.action-links {
  display: flex;
  gap: 12px;
}

/* Skeleton for Modern Clean */
@keyframes skeletonLoading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton {
  background-color: #f3f4f6;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}
.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: skeletonLoading 1.5s infinite;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

.skeleton-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background-color: #f3f4f6;
  border: 1px solid var(--color-border);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.skeleton-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: skeletonLoading 1.5s infinite;
}

/* Toasts */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}
.toast {
  padding: 16px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
  display: flex;
  align-items: flex-start;
  min-width: 300px;
  max-width: 400px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid #f5a623; }
.toast-info { border-left: 3px solid var(--color-accent); }

.toast-content {
  margin-left: 8px;
}
.toast-title { 
  font-weight: 500; 
  font-size: 14px;
  margin-bottom: 4px; 
}
.toast-message { 
  color: var(--color-text-muted); 
  font-size: 13px; 
  line-height: 1.4; 
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

/* Responsive */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .creator-panel {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    overflow-y: visible;
  }
  .result-panel {
    overflow-y: visible;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    height: auto;
  }
  .app-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .app-main {
    overflow: visible;
  }
}