* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0e1116;
  color: #d8dde6;
  font-size: 14px;
}

.app {
  display: grid;
  grid-template-columns: 240px 280px 1fr;
  height: 100vh;
}

.pane {
  border-right: 1px solid #1d2330;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.pane:last-child { border-right: none; }

.pane-detail {
  overflow-y: auto;
}

.pane-header {
  padding: 12px 16px;
  border-bottom: 1px solid #1d2330;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #0e1116;
  z-index: 1;
  gap: 12px;
}
.pane-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8a93a6;
}

.meta-inline { color: #6b7689; font-size: 12px; }

.btn-primary, .btn {
  background: #2d6cdf;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn {
  background: #232a37;
  color: #d8dde6;
  border: 1px solid #2c3548;
}
.btn:hover { background: #2c3445; }
.btn-primary:hover:not(:disabled) { background: #3978ec; }
.btn-primary:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; }

.list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.list li {
  padding: 8px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.list li:hover { background: #161c27; }
.list li.active {
  background: #182236;
  border-left-color: #2d6cdf;
}
.list .item-meta {
  font-size: 11px;
  color: #6b7689;
  margin-top: 2px;
}

.list .item-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.list .item-main {
  flex: 1;
  min-width: 0;
}
.list .item-delete {
  background: transparent;
  border: none;
  color: #6b7689;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.list li:hover .item-delete { opacity: 0.8; }
.list .item-delete:hover {
  background: #4a1f24;
  color: #ff7a7a;
  opacity: 1;
}

.btn-danger {
  background: #2a1820;
  color: #e88a8a;
  border: 1px solid #4a1f24;
}
.btn-danger:hover { background: #4a1f24; color: #ff9a9a; }

.empty {
  padding: 32px;
  color: #6b7689;
  font-style: italic;
}

.viewer-section {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #1d2330;
}

.mesh-viewport {
  position: relative;
  width: 100%;
  height: 420px;
  background: #14181f;
}
.mesh-viewport canvas { display: block; width: 100% !important; height: 100% !important; }

.viewer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4d5468;
  pointer-events: none;
  font-style: italic;
}
.viewer-overlay[hidden] { display: none; }

.light-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #8a93a6;
}
.light-control input[type="range"] { width: 80px; }
.light-control input[type="checkbox"] { margin: 0; }

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid #1d2330;
  background: #11151c;
}
.viewer-toolbar .spacer { flex: 1; }

.action-bar {
  padding: 12px 16px;
  border-bottom: 1px solid #1d2330;
}
.action-bar form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.action-bar input[type="number"] {
  width: 60px;
  background: #1a2030;
  border: 1px solid #2c3548;
  color: #d8dde6;
  padding: 3px 6px;
  border-radius: 3px;
}
.action-bar label { font-size: 12px; color: #8a93a6; display: inline-flex; align-items: center; gap: 4px; }
.upload-temp summary { cursor: pointer; user-select: none; font-size: 13px; }

/* ── Image timeline ──────────────────────────────────────────── */
.timeline-section {
  border-bottom: 1px solid #1d2330;
  padding: 12px 16px;
}
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.timeline-header h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  color: #8a93a6;
}
.timeline-tools { display: flex; gap: 8px; align-items: center; }
.upload-label { cursor: pointer; }

.timeline-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  min-height: 110px;
  align-items: center;
}
.timeline-empty { padding: 20px; }

.thumb {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #14181f;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.selected { border-color: #2d6cdf; }
.thumb.has-mesh { box-shadow: inset 0 0 0 1px #59c2ff; }
.thumb.has-parent::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #4a5468;
  transform: translateY(-1px);
}
.thumb-badges {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 3px;
}
.thumb-id {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #c4cad8;
  font-size: 10px;
  padding: 2px 4px;
  text-align: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}
.badge-source { background: #4a5468; }
.badge-chosen { background: #2da373; }
.badge-starred { background: #d8a13c; color: #1f1500; }
.badge-mesh { background: #59c2ff; color: #0b1a26; padding: 0 3px; width: auto; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
  color: #c4cad8;
}
.checkbox-row input[type="checkbox"] { margin: 0; }

.timeline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.prompt-hint {
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modals ─────────────────────────────────────────────────── */
dialog {
  background: #161c27;
  color: #d8dde6;
  border: 1px solid #2c3548;
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 420px;
  max-width: 600px;
}
dialog::backdrop { background: rgba(0,0,0,0.5); }
dialog h3 { margin: 0 0 14px; font-size: 15px; }
dialog label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: #8a93a6;
}
dialog label input, dialog label textarea {
  display: block;
  width: 100%;
  background: #1a2030;
  border: 1px solid #2c3548;
  color: #d8dde6;
  padding: 6px 8px;
  border-radius: 4px;
  font: inherit;
  margin-top: 4px;
}
dialog textarea { resize: vertical; }
.modal-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.modal-row label { margin-bottom: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.pane-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

#cover-modal { max-width: 620px; }
#cover-result {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#cover-result-img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 6px;
  border: 1px solid #2c3548;
}

.cover-history-title {
  margin: 16px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: #8a93a6;
  letter-spacing: 0.04em;
}
.cover-history {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.cover-history-item {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #2c3548;
  background: #14181f;
  cursor: pointer;
}
.cover-history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-history-item .ch-del {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.65);
  color: #ff9a9a;
  border: none;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.cover-history-item:hover .ch-del { opacity: 1; }
.cover-history-item .ch-del:hover { background: rgba(74, 31, 36, 0.9); }

.cover-banner {
  padding: 10px 16px;
  border-bottom: 1px solid #1d2330;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #11151c;
}
.cover-banner[hidden] { display: none; }
.cover-banner img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid #2c3548;
  cursor: pointer;
  display: block;
}
.cover-banner .cover-banner-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #8a93a6;
}
.cover-banner-prompt {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #1d2330;
}
.notes {
  padding: 16px 24px;
}
.notes h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  color: #8a93a6;
}
.notes textarea {
  width: 100%;
  min-height: 60px;
  background: #14181f;
  color: #d8dde6;
  border: 1px solid #2c3548;
  border-radius: 4px;
  padding: 8px;
  font: inherit;
  resize: vertical;
}
.list .item-thumb {
  width: 100%;
  height: 60px;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: 4px;
  margin-bottom: 4px;
  background-color: #14181f;
}
.btn-link {
  background: none;
  border: none;
  color: #4f8de8;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.muted { color: #6b7689; }

/* ── Queue dock ─────────────────────────────────────────────── */
#queue-dock {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 540px;
  background: #11151c;
  border-left: 1px solid #1d2330;
  border-top: 1px solid #1d2330;
  font-size: 12px;
  z-index: 50;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
}
.qd-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.qd-header:hover { background: #161c27; }
.qd-counts {
  white-space: nowrap;
  color: #c4cad8;
  flex-shrink: 0;
}
.qd-icon { color: #8a93a6; margin-right: 4px; }
.qd-bars {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.qd-bar-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.qd-bar-label {
  color: #8a93a6;
  font-size: 10px;
  flex-shrink: 0;
}
.qd-bar {
  flex: 1;
  height: 6px;
  background: #1a2030;
  border-radius: 3px;
  overflow: hidden;
  min-width: 30px;
}
.qd-bar-fill {
  display: block;
  height: 100%;
  background: #2da373;
  width: 0;
  transition: width 0.3s ease;
}
.qd-bar-text {
  font-size: 10px;
  color: #6b7689;
  white-space: nowrap;
  flex-shrink: 0;
}
.qd-toggle {
  background: none;
  border: none;
  color: #8a93a6;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
}

.qd-body {
  border-top: 1px solid #1d2330;
  max-height: 50vh;
  overflow-y: auto;
}
.qd-section {
  padding: 8px 12px;
  border-bottom: 1px solid #1d2330;
}
.qd-section h4 {
  margin: 0 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  color: #8a93a6;
  letter-spacing: 0.05em;
}
.qd-empty {
  color: #6b7689;
  font-style: italic;
  padding: 4px 0;
}
.qd-job, .qd-recent {
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  background: #14181f;
  border: 1px solid transparent;
}
.qd-job-head, .qd-recent {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qd-recent { padding: 4px 8px; }
.qd-job-icon { font-size: 14px; flex-shrink: 0; }
.qd-job-label { color: #d8dde6; flex-shrink: 0; }
.qd-spacer { flex: 1; }
.qd-cancelling { color: #d8a13c; font-size: 10px; }
.qd-cancel, .qd-retry {
  background: none;
  border: 1px solid #2c3548;
  color: #c4cad8;
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  font-size: 10px;
}
.qd-cancel:hover, .qd-retry:hover { background: #1f2533; }
.qd-cancel:disabled, .qd-retry:disabled { opacity: 0.5; cursor: not-allowed; }
.qd-job-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.qd-progress-bar {
  flex: 1;
  height: 4px;
  background: #1a2030;
  border-radius: 2px;
  overflow: hidden;
}
.qd-progress-fill {
  height: 100%;
  background: #2d6cdf;
  transition: width 0.3s ease;
}
.qd-progress-text {
  color: #8a93a6;
  font-size: 10px;
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}
.qd-recent-status {
  font-size: 10px;
  text-transform: uppercase;
  color: #8a93a6;
}
.qd-status-succeeded .qd-recent-status { color: #2da373; }
.qd-status-failed .qd-recent-status { color: #d8543c; }
.qd-status-cancelled .qd-recent-status { color: #d8a13c; }
.qd-recent-ts { color: #6b7689; font-size: 10px; flex-shrink: 0; }
.qd-err {
  color: #d8543c;
  font-weight: bold;
  cursor: help;
}

.qd-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  padding: 8px 12px;
  align-items: end;
}
.qd-config label {
  font-size: 10px;
  color: #8a93a6;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.qd-config input {
  background: #1a2030;
  border: 1px solid #2c3548;
  color: #d8dde6;
  padding: 3px 6px;
  border-radius: 3px;
  font: inherit;
  font-size: 11px;
}
.qd-cfg-apply {
  background: #2d6cdf;
  border: none;
  color: #fff;
  border-radius: 3px;
  padding: 5px 10px;
  cursor: pointer;
  grid-column: span 1;
  align-self: end;
}
.qd-cfg-status {
  font-size: 10px;
  grid-column: span 2;
  min-height: 12px;
}

/* Pause / kill / cancel-all controls in dock header */
.qd-pause, .qd-kill, .qd-cancel-all {
  background: #1a2030;
  border: 1px solid #2c3548;
  color: #c4cad8;
  border-radius: 3px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}
.qd-pause:hover, .qd-kill:hover:not(:disabled), .qd-cancel-all:hover:not(:disabled) {
  background: #232a3b;
}
.qd-pause.qd-paused {
  background: #d8a13c;
  border-color: #d8a13c;
  color: #11151c;
}
.qd-kill { color: #d8543c; }
.qd-kill:hover:not(:disabled) { background: #2a1a1a; border-color: #d8543c; }
.qd-kill:disabled, .qd-cancel-all:disabled { opacity: 0.4; cursor: not-allowed; }

.qd-paused-badge {
  margin-left: 8px;
  background: #d8a13c;
  color: #11151c;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

/* Now-playing strip (current job summary in collapsed header) */
.qd-now-playing {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.qd-now-thumb {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #2c3548;
}
.qd-now-label {
  font-size: 11px;
  color: #d8dde6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Per-job thumbnail in expanded list */
.qd-job-thumb, .qd-recent-thumb {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #2c3548;
}
.qd-recent-thumb {
  width: 20px;
  height: 20px;
}
.qd-job-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.qd-job-text .qd-job-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qd-job-sub {
  font-size: 10px;
}
.qd-recent .qd-job-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
