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

body {
  background: #fff;
  color: #333;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 15px;
  line-height: 1.6;
  padding: 0 20px 60px;
}

h1, h2, h3 {
  color: #333;
  font-weight: normal;
}

h1 { font-size: 22px; }
h2 { font-size: 16px; font-weight: bold; }

a {
  color: #1a0dab;
}

a:visited {
  color: #681da8;
}

/* greeting */
#greeting-bar {
  display: none;
  text-align: center;
  padding: 12px 0 0;
  font-size: 15px;
  color: #333;
}

#greeting-bar.visible {
  display: block;
}

/* cost counter */
#cost-bar {
  display: none;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  color: #999;
  border-bottom: 1px solid #ddd;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 100;
}

#cost-bar.visible {
  display: block;
}

#cost-bar .amount {
  font-weight: bold;
  color: #333;
}

/* sections */
.step {
  display: none;
  max-width: 720px;
  margin: 0 auto;
}

.step.active {
  display: block;
}

/* auth */
#step-auth {
  padding-top: 30px;
  text-align: center;
}

#auth-demo {
  margin: 0 auto 20px;
  border: none;
  opacity: 0.85;
}

#step-auth p {
  margin-bottom: 16px;
  color: #555;
}

/* inputs */
input[type="text"],
input[type="password"],
textarea,
select {
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  padding: 8px 10px;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 15px;
  width: 100%;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #333;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* buttons */
button {
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  padding: 8px 20px;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  border-color: #333;
}

button:disabled {
  opacity: 0.3;
  cursor: default;
}

button.secondary {
  color: #999;
  border-color: #ddd;
}

button.secondary:hover {
  color: #333;
  border-color: #999;
}

/* randomize / surprise me button */
.randomize-btn {
  padding: 3px 10px;
  font-size: 12px;
  color: #999;
  border: 1px solid #ddd;
  background: #fff;
  margin-bottom: 4px;
}

.randomize-btn:hover {
  color: #333;
  border-color: #999;
}

/* (?) tooltip */
.tip {
  display: inline-block;
  position: relative;
  color: #bbb;
  font-size: 11px;
  cursor: help;
  margin-left: 2px;
}

.tip:hover {
  color: #666;
}

.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 11px;
  font-weight: normal;
  padding: 5px 8px;
  border-radius: 3px;
  white-space: normal;
  width: 200px;
  line-height: 1.4;
  z-index: 10;
  margin-bottom: 4px;
  pointer-events: none;
}

/* tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid #ddd;
}

.tab {
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid #ddd;
  border-bottom: none;
  color: #999;
  font-size: 14px;
}

.tab.active {
  color: #333;
  border-color: #ccc;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
}

/* tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* form layout */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  color: #666;
  font-size: 13px;
}

.row {
  display: flex;
  gap: 12px;
}

.row .field {
  flex: 1;
}

/* details / advanced */
details {
  margin: 16px 0;
  border: 1px solid #ddd;
  padding: 10px;
}

details summary {
  cursor: pointer;
  color: #999;
  font-size: 13px;
}

details[open] summary {
  margin-bottom: 10px;
}

/* error */
.error {
  color: #c00;
  margin-top: 8px;
  font-size: 13px;
}

/* processing */
#step-processing {
  text-align: center;
  padding-top: 40px;
}

.proc-backstory {
  font-style: italic;
  color: #666;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.spinner {
  font-size: 18px;
  margin-bottom: 12px;
  color: #333;
}

.elapsed {
  color: #999;
  font-size: 13px;
}

/* preview area */
.preview-area {
  margin-top: 24px;
  text-align: left;
}

.preview-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.preview-row img {
  max-width: 200px;
  max-height: 300px;
  image-rendering: pixelated;
  border: 1px solid #ddd;
}

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

/* xterm container */
.xterm-wrap {
  border: 1px solid #ddd;
  display: inline-block;
  line-height: 0;
}

.xterm-wrap .xterm-viewport::-webkit-scrollbar {
  display: none;
}

/* result */
#step-result {
  padding-top: 20px;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.controls span {
  color: #999;
  font-size: 13px;
}

.result-actions {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

/* terminal instructions */
.instructions code {
  display: block;
  background: #f5f5f5;
  padding: 8px 10px;
  margin: 6px 0;
  border: 1px solid #ddd;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  color: #333;
}

.instructions p {
  margin-top: 12px;
  color: #555;
  font-size: 14px;
}

/* gallery */
#gallery {
  display: none;
  max-width: 720px;
  margin: 40px auto 0;
  border-top: 1px solid #ddd;
  padding-top: 24px;
}

#gallery.visible {
  display: block;
}

#gallery h2 {
  margin-bottom: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.gallery-card {
  border: 1px solid #ddd;
  padding: 10px;
  cursor: pointer;
}

.gallery-card:hover {
  border-color: #333;
}

.gallery-card .card-name {
  color: #333;
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 14px;
}

.gallery-card .card-prompt {
  font-size: 12px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card .card-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* gallery player */
#gallery-player {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #ddd;
  display: none;
}

#gallery-player.visible {
  display: block;
}

#gallery-player .close-player {
  float: right;
  cursor: pointer;
  color: #999;
  font-size: 13px;
}

#gallery-player .close-player:hover {
  color: #333;
}

/* file upload */
.upload-area {
  border: 1px dashed #ccc;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  color: #999;
}

.upload-area:hover {
  border-color: #333;
}

.upload-area.has-file {
  border-style: solid;
}

.upload-thumb {
  max-width: 150px;
  max-height: 150px;
  margin-top: 8px;
  image-rendering: pixelated;
}

/* tech footer */
#tech-footer {
  max-width: 720px;
  margin: 40px auto 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #bbb;
  text-align: center;
  line-height: 1.8;
}

#tech-footer a {
  color: #aaa;
  text-decoration: none;
}

#tech-footer a:hover {
  color: #666;
  text-decoration: underline;
}

/* version tag */
#version {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  color: #ccc;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  pointer-events: none;
  z-index: 50;
}

/* cost estimate */
.cost-hint {
  color: #999;
  font-size: 12px;
  margin-top: 8px;
}

/* ===================================================================
   PIPELINE MAP WIDGET
   SYNC WITH PIPELINE: If you change steps in server/pipeline.py,
   update the PIPELINE_STEPS definition in app.js.
   =================================================================== */

.pipeline-map {
  margin: 20px 0;
  padding: 16px 0;
  border: 1px solid #ddd;
  overflow: hidden;
}

.pipeline-nodes {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  padding: 0 8px;
}

.pipeline-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  width: 72px;
}

.pipeline-node-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ccc;
  background: #fff;
  position: relative;
  z-index: 1;
}

.pipeline-node-label {
  font-size: 10px;
  color: #999;
  margin-top: 4px;
  text-align: center;
  line-height: 1.2;
}

.pipeline-node-meta {
  font-size: 9px;
  color: #bbb;
  margin-top: 2px;
  text-align: center;
  line-height: 1.2;
}

.pipeline-node-model {
  font-size: 9px;
  color: #aac;
  margin-top: 1px;
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}

.pipeline-node-model:hover {
  color: #669;
  text-decoration: underline;
}

.pipeline-arrow {
  flex-shrink: 1;
  width: 16px;
  height: 2px;
  background: #ddd;
  position: relative;
  margin: 0;
  /* vertically center with the dot (14px box-sizing:border-box, center=7px; arrow is 2px, center=1px) */
  align-self: flex-start;
  margin-top: 6px; /* (14/2) - (2/2) = 6px to align arrow center with dot center */
}

.pipeline-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  border: 4px solid transparent;
  border-left-color: #ddd;
}

/* --- Pipeline node states --- */

/* Pending (default) — gray */
.step-pending .pipeline-node-dot {
  border-color: #ccc;
  background: #fff;
}

/* Done — green */
.step-done .pipeline-node-dot {
  border-color: #6a9;
  background: #6a9;
}

.step-done .pipeline-node-label {
  color: #6a9;
}

.step-done + .pipeline-arrow {
  background: #6a9;
}

.step-done + .pipeline-arrow::after {
  border-left-color: #6a9;
}

/* Active — pulsing dark */
.step-active .pipeline-node-dot {
  border-color: #333;
  background: #333;
  animation: pipeline-pulse 1.5s ease-in-out infinite;
}

.step-active .pipeline-node-label {
  color: #333;
  font-weight: bold;
}

@keyframes pipeline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Paused — yellow/amber */
.step-paused .pipeline-node-dot {
  border-color: #b90;
  background: #b90;
}

.step-paused .pipeline-node-label {
  color: #b90;
  font-weight: bold;
}

/* ===================================================================
   CHARACTER GALLERY + FOCUS VIEW
   =================================================================== */

/* Character gallery (same style as shared gallery) */
#char-gallery {
  display: none;
  max-width: 720px;
  margin: 40px auto 0;
  border-top: 1px solid #ddd;
  padding-top: 24px;
}

#char-gallery.visible {
  display: block;
}

#char-gallery h2 {
  margin-bottom: 16px;
}

.gallery-card .card-anim-count {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* Focus view */
#char-focus {
  max-width: 720px;
  margin: 0 auto;
  padding-top: 20px;
}

.focus-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.focus-backstory {
  color: #666;
  font-size: 14px;
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.5;
}

.focus-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Keyframe strip */
.kf-strip {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.kf-strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
}

.kf-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  border: 1px solid #ddd;
  background: #1e1e1e;
}

.kf-thumb-label {
  font-size: 10px;
  color: #999;
  text-align: center;
}

/* Animation list (fallback when no timeline) */
.anim-list-item {
  border: 1px solid #ddd;
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.anim-list-item:hover {
  border-color: #333;
}

.anim-list-item .anim-info {
  flex: 1;
}

.anim-list-item .anim-info .anim-prompt {
  font-size: 14px;
  color: #333;
}

.anim-list-item .anim-info .anim-meta {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

/* Keyframe picker (for add animation) */
.kf-picker {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.kf-picker-item {
  cursor: pointer;
  border: 2px solid transparent;
  padding: 4px;
  text-align: center;
}

.kf-picker-item.selected {
  border-color: #333;
}

.kf-picker-item img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #1e1e1e;
  display: block;
}

.kf-picker-item .kf-picker-label {
  font-size: 10px;
  color: #999;
  margin-top: 4px;
}

/* Add animation panel */
#add-anim-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #ddd;
}

#add-anim-panel h3 {
  margin-bottom: 12px;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .pipeline-nodes {
    justify-content: flex-start;
    padding: 0 4px;
  }

  .pipeline-node {
    width: 54px;
  }

  .pipeline-node-label {
    font-size: 9px;
  }

  .pipeline-node-meta {
    font-size: 8px;
  }

  .pipeline-node-model {
    display: none;
  }

  .pipeline-arrow {
    width: 10px;
  }
}
