:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e3f;
  --accent: #7c6af7;
  --accent-hover: #9080ff;
  --green: #4caf7d;
  --red: #e05c5c;
  --yellow: #e0a545;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

header h1 span { color: var(--accent); }

.status-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  margin-right: 4px;
}
.dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.red   { background: var(--red); }

/* ── Main Layout ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ── Setup Panel ── */
.setup-panel {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.setup-panel .card {
  flex: 1;
  min-width: 260px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Buttons ── */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
}

button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #5dc990; }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #eb7070; }

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--border); }

.btn-lg {
  padding: 13px 24px;
  font-size: 15px;
  border-radius: var(--radius);
}

/* ── Folder input row ── */
.folder-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.folder-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.folder-row input:focus { border-color: var(--accent); }
.folder-row input::placeholder { color: var(--text-muted); }

/* ── Progress ── */
.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Photo Area ── */
.photo-area {
  display: flex;
  gap: 16px;
  flex: 1;
}

.photo-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.photo-card .photo-label {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.photo-card .filename {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  min-height: 400px;
  position: relative;
}

.photo-frame img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 4px;
}

.photo-frame .placeholder {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.photo-frame .placeholder svg {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* ── Spinner ── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.generating-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,15,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-muted);
  backdrop-filter: blur(4px);
  border-radius: 4px;
}

/* ── Prompt + Controls ── */
.controls-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.prompt-wrap {
  flex: 1;
}

.prompt-wrap label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.prompt-wrap textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
  transition: border-color 0.15s;
}

.prompt-wrap textarea:focus { border-color: var(--accent); }
.prompt-wrap textarea::placeholder { color: var(--text-muted); }

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Done screen ── */
.done-screen {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
}

.done-screen h2 {
  font-size: 26px;
  color: var(--text);
  margin-bottom: 10px;
}

.done-screen p { font-size: 15px; line-height: 1.6; }

/* ── Error toast ── */
#error-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--red);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  max-width: 360px;
  z-index: 999;
  display: none;
  animation: fadeIn 0.2s;
}

#error-toast.show { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ── Success flash ── */
.photo-card.flash-green {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(76,175,125,0.3);
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 18px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Toggle switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-row input { display: none; }

.toggle-track {
  width: 40px; height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: left 0.2s, background 0.2s;
}

.toggle-row input:checked ~ .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-row input:checked ~ .toggle-track .toggle-thumb { left: 20px; background: #fff; }

/* ── Batch results ── */
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}

.result-item .result-status {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.result-status.done    { background: var(--green); color: #fff; }
.result-status.error   { background: var(--red); color: #fff; }
.result-status.running { background: var(--accent); color: #fff; }
.result-status.pending { background: var(--surface2); color: var(--text-muted); }

.result-item .result-prompt {
  flex: 1;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-item .result-path {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Prompt list ── */
.prompt-item {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.prompt-item textarea {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 52px;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.prompt-item textarea:focus { border-color: var(--accent); }

.prompt-item .remove-btn {
  padding: 8px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.prompt-item .remove-btn:hover { color: var(--red); border-color: var(--red); }

/* ── Responsive ── */
@media (max-width: 780px) {
  .photo-area { flex-direction: column; }
  .controls-row { flex-direction: column; }
  .action-btns { flex-direction: row; }
}
