* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

body { background: var(--bg-color); color: var(--text-main); min-height: 100vh; }

/* Navbar */
.glass-navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}
.nav-container {
  max-width: 1200px; margin: 0 auto; padding: 1rem;
  display: flex; justify-content: space-between; align-items: center;
}
.logo-area { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon {
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center;
}
.logo-text { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.logo-subtext { font-size: 0.75rem; color: var(--text-muted); }

/* Layout Grid */
.main-container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }
.grid-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .grid-layout { grid-template-columns: 2fr 3fr; } }

/* Cards & Components */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: 1.5rem;
}

.input-group label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--text-main); margin-bottom: 0.5rem; }
.input-group label i { width: 1rem; height: 1rem; color: var(--text-muted); }
.custom-select, input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%; padding: 0.75rem 0.875rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: #fff;
  font-size: 0.875rem; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); outline: none;
  font-family: inherit;
}
.custom-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
  padding-right: 2.5rem; cursor: pointer;
}
.custom-select:hover { border-color: #999; }
.custom-select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }
textarea { resize: none; }

/* Buttons */
.btn-primary {
  width: 100%; padding: 0.75rem; border: none; border-radius: var(--radius-sm);
  background: var(--primary); color: white;
  font-weight: 500; font-size: 0.875rem; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-outline {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
  background: white; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 0.875rem; color: var(--text-main); cursor: pointer; transition: all 0.2s; font-weight: 500;
}
.btn-outline:hover { border-color: var(--text-main); }

.tab-btn { flex: 1; padding: 0.75rem; border: none; background: transparent; cursor: pointer; border-bottom: 2px solid transparent; font-size: 0.875rem; color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: all 0.2s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn.is-disabled { color: #94a3b8; background: rgba(148, 163, 184, 0.08); border-bottom-color: transparent; }
.tab-btn.is-disabled:not(.active):hover { color: #64748b; background: rgba(148, 163, 184, 0.12); }
.tabs-container { display: flex; border-bottom: 1px solid #e5e7eb; margin-bottom: 1.5rem; }

/* Utils */
.mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.hidden { display: none !important; } .h-full { height: 100%; }
.flex-col { display: flex; flex-direction: column; }
.w-full { width: 100%; }

/* Grid Parameters */
.params-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; border-top: 1px solid var(--border-color); padding-top: 1rem; }
.param-box label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; display: block; }

/* Code Blocks & Previews */
.debug-section { margin-top: 1.5rem; border-top: 1px solid var(--border-color); padding-top: 1.5rem; }
.debug-header { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.75rem; display: flex; align-items: center; justify-content: space-between; }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; gap: 0.25rem; }
.btn-text:hover { color: var(--text-main); }
.code-block { background: #f5f5f5; border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.75rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; overflow-wrap: break-word; color: #333; margin-bottom: 1rem; max-width: 100%; }
details summary { cursor: pointer; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; outline: none; }

/* Results */
.results-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.results-header span { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1rem; }
.results-body { flex: 1; display: flex; flex-direction: column; padding: 1.5rem 0 0; min-height: 300px; }
.empty-state { text-align: center; color: var(--text-muted); margin: auto; }
.empty-state .icon-bg { width: 3rem; height: 3rem; background: #f5f5f5; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; color: var(--text-muted); }
.gallery-grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 280px)); gap: 1rem; align-content: start; justify-content: center; }
.gallery-grid[data-count="1"] { grid-template-columns: minmax(260px, 420px); }
.gallery-img-wrapper { width: 100%; max-width: 420px; position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; box-shadow: 0 4px 6px rgba(0,0,0,0.05); transition: transform 0.2s; cursor: pointer; background: #f5f5f5; }
.gallery-img-wrapper:hover { border-color: var(--primary); transform: scale(1.02); }
.gallery-img-wrapper img { width: 100%; height: auto; display: block; }
.btn-dl { position: absolute; bottom: 0.5rem; right: 0.5rem; background: rgba(255,255,255,0.9); border: none; border-radius: 4px; padding: 0.25rem 0.5rem; font-size: 0.75rem; cursor: pointer; opacity: 0; transition: opacity 0.2s; display: flex; align-items: center; gap: 0.25rem; }
.gallery-img-wrapper:hover .btn-dl { opacity: 1; }

.error-msg { width: 100%; background: #fee2e2; border: 1px solid #ef4444; color: #b91c1c; padding: 1rem; border-radius: var(--radius-sm); font-size: 0.875rem; white-space: pre-wrap; word-break: break-all; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease-out; }
.modal-content { width: 90%; max-width: 500px; animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); }
.btn-icon:hover { color: var(--text-main); }
.modal-desc { font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }
.help-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Lightbox */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 200; display: flex; align-items: center; justify-content: center; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.absolute-top-right { position: absolute; top: 1rem; right: 1rem; color: white; padding: 0.5rem; }

/* Upload Area */
.upload-area { width: 100%; border: 1px dashed var(--border-color); border-radius: var(--radius-sm); padding: 1.5rem; background: #fafafa; color: var(--text-muted); font-size: 0.875rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; cursor: pointer; transition: all 0.2s; }
.upload-area:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.preview-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.preview-item { width: 4rem; height: 4rem; border-radius: var(--radius-sm); overflow: hidden; position: relative; border: 1px solid var(--border-color); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-remove { position: absolute; top: 0; right: 0; background: rgba(0,0,0,0.7); color: white; border: none; width: 1.25rem; height: 1.25rem; cursor: pointer; display: flex; align-items: center; justify-content: center; border-bottom-left-radius: 4px; }
.preview-remove:hover { background: red; }

/* Model Hint */
.model-hint { margin-top: 0.5rem; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.8rem; line-height: 1.5; color: var(--text-muted); background: rgba(139, 92, 246, 0.05); border: 1px dashed rgba(139, 92, 246, 0.2); }
.model-hint strong { color: var(--primary); }

/* Textarea wrapper for optimize button */
.textarea-wrapper {
  position: relative;
}

/* Optimize button - AI sparkle icon at bottom-right of textarea */
.btn-optimize {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  height: 30px;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #a78bfa 0%, #818cf8 100%);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.25s;
  z-index: 5;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.25);
  white-space: nowrap;
}
.btn-optimize::after {
  content: 'AI 优化';
}
.btn-optimize:hover {
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}
.btn-optimize:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(139, 92, 246, 0.2);
}
.btn-optimize.loading {
  pointer-events: none;
  opacity: 0.8;
}
.btn-optimize.loading::after {
  content: '优化中...';
}
.btn-optimize.loading i {
  animation: spin 0.8s linear infinite;
}

/* Optimize dropdown */
.optimize-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 20;
  min-width: 200px;
  padding: 0.375rem 0;
  animation: fadeIn 0.15s ease-out;
}
.optimize-dropdown-header {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.optimize-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-main);
  text-align: left;
  transition: background 0.15s;
  font-family: inherit;
}
.optimize-option:hover {
  background: rgba(139, 92, 246, 0.08);
  color: var(--primary);
}
.optimize-option i {
  color: var(--text-muted);
  flex-shrink: 0;
}
.optimize-option:hover i {
  color: var(--primary);
}

/* Modal separator */
.modal-separator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.modal-separator::before,
.modal-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* Optimize toast */
.optimize-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.2s ease-out;
  max-width: 90vw;
}
