:root {
  color-scheme: dark;
  --bg: #151515;
  --panel: #222;
  --panel-soft: #282828;
  --editor: #2b2b2b;
  --border: #3a3a3a;
  --muted: rgba(255, 255, 255, 0.55);
  --subtle: rgba(255, 255, 255, 0.34);
  --text: rgba(255, 255, 255, 0.92);
  --orange: #f97316;
  --violet: #7c3aed;
  --green: #34d399;
  --red: #fb7185;
  --cyan: #22d3ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 340px;
  gap: 16px;
  min-height: 100vh;
  padding: 18px;
}

.creator {
  display: grid;
  align-content: start;
  gap: 14px;
}

.hero,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero {
  padding: 8px 2px;
}

.hero p {
  color: var(--orange);
  font-size: 12px;
  text-transform: uppercase;
}

.hero h1 {
  margin-top: 4px;
  font-size: 28px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wechat-contact {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 8px;
  padding: 7px 12px;
  color: #d9fbff;
  background: rgba(34, 211, 238, 0.06);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.panel h2 {
  font-size: 15px;
}

.panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.ghost-button {
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid rgba(124, 58, 237, 0.55);
  color: #f5efff;
  background: rgba(124, 58, 237, 0.56);
}

.primary-button:hover {
  background: rgba(124, 58, 237, 0.7);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.ghost-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.asset-board {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.asset-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 64px;
  gap: 8px;
  min-height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.12);
}

.row-label {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #b8e7ff;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

.asset-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-start;
}

.asset-card,
.add-card {
  position: relative;
  flex: 0 0 104px;
  width: 104px;
  height: 58px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.asset-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: rgba(0, 0, 0, 0.32);
}

.asset-name {
  position: absolute;
  inset-inline: 4px;
  bottom: 4px;
  height: 18px;
  border: 0;
  border-radius: 5px;
  padding: 0 4px;
  color: white;
  background: rgba(0, 0, 0, 0.68);
  font-size: 11px;
  text-align: center;
}

.remove-asset {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: white;
  background: rgba(0, 0, 0, 0.68);
}

.add-card {
  display: grid;
  place-items: center;
  align-content: center;
  border-style: dashed;
  color: var(--muted);
}

.add-card span {
  font-size: 20px;
  line-height: 1;
}

.add-card em {
  font-style: normal;
  font-size: 11px;
}

.add-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.import-button {
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
  min-width: 104px;
  height: 36px;
  overflow: hidden;
  border: 1px solid rgba(124, 58, 237, 0.5);
  border-radius: 8px;
  color: #f5efff;
  background: rgba(124, 58, 237, 0.42);
  font-size: 13px;
  font-weight: 800;
}

.asset-import-info {
  min-height: auto;
  margin-top: 8px;
  padding: 7px 10px;
}

.import-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.prompt-panel {
  min-height: 430px;
}

#prompt {
  width: 100%;
  min-height: 390px;
  margin-top: 12px;
  border: 1px solid rgba(249, 115, 22, 0.45);
  border-radius: 8px;
  outline: none;
  padding: 14px;
  color: var(--text);
  background: var(--editor);
  line-height: 1.72;
  resize: vertical;
}

#prompt:focus {
  border-color: rgba(249, 115, 22, 0.72);
}

.link-info {
  margin-top: 10px;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
  font-size: 12px;
}

.link-info strong {
  color: var(--green);
}

.link-info .missing {
  color: var(--red);
}

.param-grid {
  display: grid;
  grid-template-columns: 160px 160px minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.param-info {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
  font-size: 12px;
}

.tasks {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.task-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.task-title {
  font-size: 13px;
  font-weight: 800;
}

.job .task-title {
  margin-bottom: 5px;
}

.cancel-job {
  min-height: 28px;
  padding: 4px 8px;
  color: #ffd9df;
  border-color: rgba(251, 113, 133, 0.28);
}

.job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.delete-job {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 8px;
  color: #ffd9df;
  border-color: rgba(251, 113, 133, 0.28);
}

.task-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 10px;
  padding: 10px;
}

.task-prompt {
  min-height: 180px;
  border: 1px solid rgba(249, 115, 22, 0.32);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  background: var(--editor);
  line-height: 1.65;
  resize: vertical;
}

.task-side {
  display: grid;
  align-content: start;
  gap: 8px;
}

.task-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-asset {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  width: 112px;
  height: 40px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
}

.mini-asset img {
  width: 34px;
  height: 40px;
  object-fit: cover;
}

.mini-asset span {
  overflow: hidden;
  padding: 0 6px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-status {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  outline: none;
  padding: 0 9px;
  color: var(--text);
  background: var(--editor);
}

input:focus {
  border-color: rgba(249, 115, 22, 0.58);
}

.queue {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.jobs {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.job {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.14);
}

.job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-title-wrap {
  min-width: 0;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.badge.queued {
  color: #ffe2b8;
  background: rgba(249, 115, 22, 0.16);
}

.badge.running {
  color: #dcf4ff;
  background: rgba(34, 211, 238, 0.16);
}

.badge.done {
  color: #ddfff1;
  background: rgba(52, 211, 153, 0.16);
}

.badge.failed {
  color: #ffe1e6;
  background: rgba(251, 113, 133, 0.18);
}

.meta {
  color: var(--subtle);
  font-size: 11px;
}

.job-prompt {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.progress-row {
  display: grid;
  gap: 5px;
}

.progress-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--violet));
  transition: width 240ms ease;
}

.download-link {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.log-head {
  align-items: flex-start;
}

.log-actions {
  display: flex;
  gap: 8px;
}

.log-tab {
  position: fixed;
  left: 0;
  top: 42%;
  z-index: 36;
  min-height: 108px;
  border: 1px solid rgba(34, 211, 238, 0.34);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  padding: 10px 7px;
  color: #d9fbff;
  background: rgba(15, 22, 28, 0.94);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.log-tab:hover {
  color: white;
  background: rgba(20, 34, 42, 0.98);
}

.log-overlay {
  position: fixed;
  inset: 18px 374px 18px 18px;
  z-index: 35;
}

.log-overlay[hidden] {
  display: none;
}

.log-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 8px;
  padding: 14px;
  background: rgba(23, 23, 23, 0.98);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.46);
}

.log-grid {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.log-block {
  display: grid;
  grid-template-rows: auto minmax(0, auto);
  min-height: 0;
}

.comfy-log-block {
  grid-template-rows: auto minmax(0, 1fr);
}

.log-block h3 {
  margin: 0 0 6px;
  color: #d9fbff;
  font-size: 13px;
}

.log-view {
  width: 100%;
  min-height: 0;
  margin: 0;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(0, 0, 0, 0.28);
  font: 11px/1.5 Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.gpu-log-view {
  height: 170px;
  max-height: 28vh;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 78px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--subtle);
  font-size: 12px;
}

.mention-popup {
  position: fixed;
  z-index: 40;
  width: 310px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid rgba(249, 115, 22, 0.42);
  border-radius: 8px;
  padding: 6px;
  background: rgba(32, 32, 32, 0.98);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.44);
}

.mention-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 6px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.mention-option:hover,
.mention-option.active {
  background: rgba(249, 115, 22, 0.16);
}

.mention-option img {
  width: 42px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
}

.mention-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-type,
.mention-empty {
  color: var(--muted);
  font-size: 12px;
}

.mention-empty {
  padding: 12px;
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 1fr;
  }

  .log-overlay {
    inset: 12px;
  }

  .queue {
    position: static;
    max-height: none;
  }

  .param-grid {
    grid-template-columns: 1fr;
  }

  .task-body {
    grid-template-columns: 1fr;
  }
}
