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

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --secondary: #00b894;
  --danger: #d63031;
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #2d2d44;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Header */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 2px solid var(--primary);
  padding: 24px 0;
  text-align: center;
}
header h1 {
  font-size: 2rem;
  color: var(--primary);
  letter-spacing: 2px;
}
header .subtitle { color: var(--text-muted); margin-top: 4px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin: 24px 0 0;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: 10px 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; padding: 24px 0; }
.tab-content.active { display: block; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.9rem; color: var(--text-muted); }
.form-group.checkboxes {
  flex-direction: row;
  gap: 20px;
  align-items: center;
}
.form-group.checkboxes label {
  display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text);
}

input[type="text"], input[type="number"], select {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

/* Upload */
.upload-area {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  overflow: hidden;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); }
.upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-placeholder { color: var(--text-muted); }
.upload-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.upload-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  margin-top: 16px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 0.85rem; margin-top: 0; }

/* Results */
.result-area {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.result-area h3 { margin-bottom: 12px; color: var(--primary); }
.result-area pre {
  background: var(--bg-input);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.result-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.result-file {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 8px;
  text-align: center;
}
.result-file img {
  max-width: 100%;
  max-height: 160px;
  border-radius: 4px;
  image-rendering: pixelated;
}
.result-file .filename {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  word-break: break-all;
}
.result-file a {
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.8rem;
}

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-muted); font-weight: 500; }
tr:hover { background: rgba(108, 92, 231, 0.05); }

.status {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}
.status-completed { background: rgba(0, 184, 148, 0.2); color: var(--secondary); }
.status-failed { background: rgba(214, 48, 49, 0.2); color: var(--danger); }
.status-processing { background: rgba(108, 92, 231, 0.2); color: var(--primary); }
.status-pending { background: rgba(136, 136, 136, 0.2); color: var(--text-muted); }

/* Loading */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 1000;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay p { margin-top: 16px; color: var(--text); }

/* Footer */
footer {
  margin-top: 48px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
footer a { color: var(--primary); text-decoration: none; }

/* Prompt sections */
.prompt-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.prompt-section:last-child { border-bottom: none; margin-bottom: 0; }
.prompt-section h3 { margin-bottom: 10px; color: var(--primary); font-size: 1rem; }

.alt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.alt-chip {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.alt-chip:hover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.15);
}

.tip-box {
  background: rgba(108, 92, 231, 0.1);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.related-job {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-input);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.related-job-images {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.related-job-images img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 4px;
  background: #1a1a2e;
  image-rendering: pixelated;
}
.related-job-info { flex: 1; min-width: 0; }
.related-job-info .rj-time { font-size: 0.75rem; color: var(--text-muted); }
.related-job-info .rj-diff {
  font-size: 0.8rem;
  color: #fdcb6e;
  margin-top: 4px;
}
.related-job-info .rj-diff span {
  display: inline-block;
  background: rgba(253, 203, 110, 0.1);
  padding: 1px 8px;
  border-radius: 10px;
  margin: 2px 2px 2px 0;
}

.btn-copy { margin-top: 8px; }

/* Home page */
.home-hero {
  text-align: center;
  padding: 32px 0 24px;
}
.home-hero h2 { font-size: 1.6rem; color: var(--primary); }
.home-hero p { color: var(--text-muted); margin-top: 6px; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.home-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.home-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.home-card h3 { margin: 10px 0 8px; font-size: 1rem; }
.home-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.home-card code {
  background: rgba(108, 92, 231, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
}
.hc-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 1.1rem; color: #fff;
}
.hc-tag {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 184, 148, 0.2);
  color: var(--secondary);
}

.home-section {
  margin-bottom: 28px;
}
.home-section h3 {
  font-size: 1.05rem;
  margin-bottom: 14px;
  color: var(--primary);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.compare-table th {
  background: var(--bg-card);
  padding: 10px;
  text-align: center;
  color: var(--primary);
}
.compare-table th:first-child { width: 80px; text-align: right; }
.compare-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.compare-table td:first-child {
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.workflow-steps { display: flex; flex-direction: column; gap: 12px; }
.wf-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.wf-num {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; color: #fff; flex-shrink: 0;
  font-size: 0.9rem;
}
.wf-body { flex: 1; }
.wf-body strong { display: block; margin-bottom: 4px; }
.wf-body p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; margin: 0; }
.wf-body a { color: var(--primary); }

/* Generated image actions */
.gen-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
  .tab { padding: 8px 16px; font-size: 0.9rem; }
  header h1 { font-size: 1.5rem; }
}
