:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #171a1f;
  --muted: #626a76;
  --line: #d9dee7;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --accent: #16715f;
  --accent-strong: #0f5c4e;
  --accent-soft: #dff2ec;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(18, 28, 45, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 0;
}

.workspace,
.results {
  padding: 32px;
}

.workspace {
  border-right: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #2d3440;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.nav-link:hover {
  border-color: #adb7c5;
  background: #f8fafc;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.status-pill {
  min-width: 86px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.is-active {
  border-color: rgba(22, 113, 95, 0.35);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.is-error {
  border-color: rgba(180, 35, 24, 0.3);
  background: #fff0ee;
  color: var(--danger);
}

.panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.wide {
  grid-column: 1 / -1;
}

label,
.check-row {
  color: #343a43;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(22, 113, 95, 0.6);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(22, 113, 95, 0.12);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.preview {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.preview img {
  width: 112px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 4px;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 750;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    opacity 0.16s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  min-width: 140px;
  background: var(--accent);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: #2d3440;
}

.ghost:hover:not(:disabled) {
  border-color: #adb7c5;
  background: #f8fafc;
}

.results {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 20px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.task-head,
.task-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.task-head {
  align-items: center;
  padding: 18px 20px 10px;
}

.task-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.task-head strong {
  color: var(--accent-strong);
}

.task-meta {
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.progress-area {
  padding: 0 20px 18px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf2;
}

.progress-track span {
  display: block;
  width: 2%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.progress-area p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.resume-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 20px 18px;
}

.resume-task button {
  min-width: 92px;
}

.log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 14px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.log-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.log {
  min-height: 132px;
  max-height: 230px;
  margin: 0;
  padding: 14px 20px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #111820;
  color: #d9f5e9;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-content: start;
  gap: 16px;
  min-height: 360px;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 360px;
  display: grid;
  place-items: center;
  border: 1px dashed #bcc5d1;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(18, 28, 45, 0.09);
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--panel-2);
}

.image-card a {
  padding: 10px 12px;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
}

.image-card a:hover {
  text-decoration: underline;
}

.image-actions {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.image-actions a + a {
  border-left: 1px solid var(--line);
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.section-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.history-list {
  max-height: 360px;
  overflow: auto;
}

.history-empty {
  margin: 0;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  display: grid;
  width: 100%;
  min-height: 0;
  gap: 6px;
  padding: 14px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item:hover {
  background: #f7faf9;
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-item strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 12px;
}

.history-status.error {
  color: var(--danger);
}

.history-prompt,
.history-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-prompt {
  color: #343a43;
  font-size: 13px;
}

.history-meta {
  color: var(--muted);
  font-size: 12px;
}

.task-library-page {
  padding: 32px;
}

.library-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.library-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.library-notice {
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.task-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.task-library-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(18, 28, 45, 0.08);
}

.library-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-task-id {
  min-width: 0;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-prompt,
.library-meta {
  margin: 0;
}

.library-prompt {
  color: #343a43;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.library-meta {
  color: var(--muted);
  font-size: 12px;
}

.library-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.library-images img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-2);
}

.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.compact-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: #2d3440;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.library-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 30px;
  border: 1px dashed #bcc5d1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .workspace {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .results {
    min-height: 60vh;
  }
}

@media (max-width: 640px) {
  .resume-task {
    grid-template-columns: 1fr;
  }

  .resume-task button {
    width: 100%;
  }

  .workspace,
  .results {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .topbar-actions {
    align-items: center;
    justify-content: space-between;
  }

  .status-pill {
    align-self: flex-start;
  }

  .panel {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .preview {
    grid-template-columns: 78px 1fr;
  }

  .preview img {
    width: 78px;
  }

  .task-head,
  .task-meta {
    flex-direction: column;
    gap: 6px;
  }

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

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

  .task-library-page {
    padding: 18px;
  }

  .library-topbar {
    flex-direction: column;
    gap: 14px;
  }

  .library-tools,
  .task-library-grid {
    grid-template-columns: 1fr;
  }

  .library-tools .compact-button {
    width: 100%;
  }

  button {
    flex: 1 1 145px;
  }
}
