:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #182033;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f8fafc;
  --blue: #276ef1;
  --blue-dark: #1e56c7;
  --green: #067647;
  --red: #b42318;
  --amber: #b7791f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
  background: var(--bg);
  color: var(--text);
  transition: grid-template-columns 0.18s ease;
}
body.sidebar-collapsed { grid-template-columns: 72px 1fr; }

.sidebar {
  background: #111827;
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 236px;
  min-height: 100vh;
  transition: width 0.18s ease, box-shadow 0.18s ease;
  z-index: 5;
  overflow: hidden;
}
body.sidebar-collapsed .sidebar { width: 72px; }
body.sidebar-collapsed .sidebar:hover {
  width: 236px;
  box-shadow: 14px 0 30px rgba(16, 24, 40, 0.18);
}
.brand { padding: 8px 10px 18px; }
.brand strong { display: block; font-size: 20px; }
.brand span { color: #a7b3c8; font-size: 12px; }
.sidebar-toggle {
  width: 44px;
  height: 38px;
  padding: 0;
  margin: 0 0 8px;
  border-color: #2b3850;
  background: #1f2937;
  color: #fff;
}
.nav {
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 12px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
}
.nav.active, .nav:hover { background: #25324a; color: #fff; }
body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .brand span,
body.sidebar-collapsed .nav {
  white-space: nowrap;
}
body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .brand span {
  opacity: 0;
}
body.sidebar-collapsed .nav {
  font-size: 0;
  text-align: center;
  padding: 12px 0;
}
body.sidebar-collapsed .nav::before {
  content: attr(data-short);
  font-size: 15px;
  font-weight: 700;
}
body.sidebar-collapsed .sidebar:hover .brand strong,
body.sidebar-collapsed .sidebar:hover .brand span {
  opacity: 1;
}
body.sidebar-collapsed .sidebar:hover .nav {
  font-size: 15px;
  text-align: left;
  padding: 12px 14px;
}
body.sidebar-collapsed .sidebar:hover .nav::before { content: ""; }

.shell { padding: 22px 24px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
h1 { margin: 0 0 6px; font-size: 24px; }
h2 { margin: 0; font-size: 21px; }
h3 { margin: 0 0 12px; font-size: 16px; }
p { margin: 0; color: var(--muted); line-height: 1.7; }

.view { display: none; }
.view.active { display: block; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 14px;
}
.page-head.compact-head { margin-bottom: 10px; }
.page-head p { max-width: 760px; }
.timer-pill {
  border: 1px solid #c7d7fe;
  background: #eef4ff;
  color: #244ba8;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
  white-space: nowrap;
}

.steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.step {
  border: 1px solid var(--line);
  background: #fff;
  color: #475467;
  border-radius: 7px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-align: left;
}
.step strong {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #eef2f7;
}
.step span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.active { border-color: #b2ccff; background: #eef4ff; color: #244ba8; }
.step.active strong { background: var(--blue); color: #fff; }

.flow-page { display: none; min-height: calc(100vh - 160px); }
.flow-page.active { display: block; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}
.split-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(480px, 1.2fr);
  gap: 16px;
}
.generation-layout {
  display: grid;
  grid-template-columns: 330px minmax(720px, 1fr);
  gap: 14px;
}
.result-workbench {
  display: grid;
  grid-template-columns: 300px minmax(460px, 1fr) 380px;
  gap: 16px;
  min-height: 520px;
}
.bottom-review {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 380px;
  gap: 18px;
}
.settings-layout {
  display: grid;
  gap: 16px;
}
.settings-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.category-editor {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.category-tabs {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 560px;
  overflow: auto;
}
.category-tab {
  display: grid;
  gap: 4px;
  justify-items: start;
  text-align: left;
  padding: 11px 12px;
}
.category-tab strong {
  line-height: 1.35;
}
.category-tab span {
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-tab.active {
  border-color: #b2ccff;
  background: #eef4ff;
  color: #244ba8;
}
.category-tab.active span {
  color: #3b5fb8;
}
.category-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--soft);
}
.category-form-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.category-form-head strong {
  font-size: 16px;
}
.category-form-head button {
  padding: 7px 10px;
  font-size: 13px;
}

label { display: grid; gap: 7px; color: #344054; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.check input { width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions.slim { margin-top: 0; }
button, .button-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
button.primary:hover { background: var(--blue-dark); }
button.secondary { background: #eef4ff; border-color: #c7d7fe; color: #244ba8; }
button.danger { color: var(--red); border-color: #f4b8b0; background: #fff7f6; }
.button-link { margin-top: 10px; color: #244ba8; background: #eef4ff; border-color: #c7d7fe; }
.button-link.disabled { opacity: 0.5; pointer-events: none; }

.flow-footer, .toolbar, .panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.flow-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.toolbar { margin-bottom: 10px; }
.toolbar strong { display: block; font-size: 17px; }
.toolbar span { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--soft);
}
.notice.error { color: var(--red); }
.save-status {
  align-self: center;
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.save-status.success { color: var(--green); }
.save-status.error { color: var(--red); }

.compact-list, .topic-list, .job-list {
  display: grid;
  gap: 10px;
  overflow: auto;
}
.compact-list { max-height: 560px; }
.topic-list { max-height: calc(100vh - 300px); }
.job-list { max-height: calc(100vh - 300px); }
.mini-card, .topic-item, .job, .result-job {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.mini-card { display: grid; gap: 4px; }
.mini-card span { color: var(--muted); }
.topic-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.topic-item div { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.topic-item input { width: auto; margin-top: 6px; }
.topic-item span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef4ff;
  color: #244ba8;
  font-size: 13px;
}
.topic-item strong { font-weight: 600; line-height: 1.55; }
.row-actions { flex: 0 0 auto; }
.row-actions button { padding: 7px 9px; font-size: 13px; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  background: var(--soft);
}
.stats strong { display: block; font-size: 20px; }
.stats span { color: var(--muted); font-size: 12px; }
.job strong, .result-job strong { display: block; line-height: 1.45; }
.job span, .result-job span { color: var(--muted); font-size: 13px; }
.job.running, .result-job.running { border-color: #b2ccff; background: #f5f8ff; }
.job.completed, .result-job.completed { border-color: #abefc6; background: #f6fef9; }
.job.failed, .result-job.failed { border-color: #fecdca; background: #fff7f6; }
.job.skipped, .result-job.skipped { opacity: 0.65; }

.timeline {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  color: #475467;
  min-width: 122px;
  flex: 0 0 122px;
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.timeline-item::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: #fff;
  flex: 0 0 auto;
}
.timeline-item strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-item span { color: var(--muted); font-size: 13px; }
.timeline-item.pending {
  border-color: #d8dee8;
  background: #f8fafc;
  color: #667085;
}
.timeline-item.running {
  border-color: #84adff;
  background: #eef4ff;
  color: #244ba8;
  box-shadow: 0 0 0 2px rgba(39, 110, 241, 0.08);
}
.timeline-item.running::before {
  border-color: var(--blue);
  background: radial-gradient(circle at center, var(--blue) 0 34%, #fff 38%);
}
.timeline-item.completed {
  border-color: #75e0a7;
  background: #f6fef9;
  color: #067647;
}
.timeline-item.completed::before {
  content: "✓";
  display: grid;
  place-items: center;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.timeline-item.failed {
  border-color: #fda29b;
  background: #fff7f6;
  color: #b42318;
}
.timeline-item.failed::before {
  content: "!";
  display: grid;
  place-items: center;
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.timeline-item.skipped {
  border-style: dashed;
  opacity: 0.68;
}

.live-preview {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 340px;
  gap: 14px;
  margin-bottom: 10px;
}
pre, .result {
  white-space: pre-wrap;
  background: #0b1220;
  color: #d6e2ff;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  margin: 0;
}
#liveText, #resultExcerpt {
  min-height: 260px;
  max-height: 360px;
  line-height: 1.75;
}
#liveText {
  min-height: calc(100vh - 370px);
  max-height: calc(100vh - 370px);
  overflow: auto;
  padding: 18px 22px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.9;
  border-radius: 8px;
}
#liveText h2,
#liveText h3,
#liveText h4,
#resultExcerpt h2,
#resultExcerpt h3,
#resultExcerpt h4 {
  margin: 22px 0 10px;
  color: #101828;
  line-height: 1.45;
}
#liveText h2, #resultExcerpt h2 { font-size: 20px; }
#liveText h3, #resultExcerpt h3 { font-size: 18px; }
#liveText h4, #resultExcerpt h4 { font-size: 16px; }
#liveText p,
#resultExcerpt p {
  margin: 0 0 16px;
  color: #182033;
  line-height: 1.9;
}
#liveText strong, #resultExcerpt strong { font-weight: 700; }
#liveText code,
#resultExcerpt code {
  background: #eef2f7;
  border-radius: 4px;
  padding: 1px 5px;
}
#liveText .image-ref,
#liveText .list-line,
#resultExcerpt .image-ref,
#resultExcerpt .list-line {
  color: #475467;
}
#resultExcerpt {
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--line);
  overflow: auto;
  padding: 18px 22px;
  border-radius: 8px;
  min-height: calc(100vh - 330px);
  max-height: calc(100vh - 330px);
}
.result.small { min-height: 80px; max-height: 112px; }
.reader-panel, .image-panel { min-width: 0; }
.image-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 322px);
}
.image-panel h3 { margin-bottom: 8px; }
.log-strip {
  border-top: 1px solid var(--line);
  align-self: end;
  margin-top: 14px;
  padding-top: 10px;
}
.log-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.log-strip-head button {
  padding: 5px 9px;
  font-size: 13px;
}
.current-event {
  min-height: 44px;
  border: 1px solid #c7d7fe;
  border-radius: 8px;
  background: #eef4ff;
  color: #244ba8;
  padding: 10px 11px;
  line-height: 1.55;
  font-size: 13px;
}

.thumb-grid, .image-card-grid {
  display: grid;
  gap: 10px;
  align-content: start;
}
.thumb-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: calc(100vh - 480px);
  overflow: auto;
}
.thumb-grid figure:first-child { grid-column: 1 / -1; }
.image-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.image-thumb-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #eef2f7;
  cursor: zoom-in;
}
.image-kind {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 1;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.4;
}
figure img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #eef2f7;
}
figcaption {
  display: grid;
  gap: 4px;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}
figcaption code, .artifact-list code {
  word-break: break-all;
  white-space: pre-wrap;
}

body.lightbox-open { overflow: hidden; }
.image-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
}
.image-lightbox.active { display: block; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 24, 0.82);
}
.lightbox-stage {
  position: absolute;
  inset: 28px;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
}
.lightbox-stage img {
  max-width: min(1400px, calc(100vw - 150px));
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
}
.lightbox-close {
  top: 0;
  right: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 28px;
}
.lightbox-nav {
  top: 50%;
  width: 46px;
  height: 64px;
  padding: 0;
  transform: translateY(-50%);
  font-size: 38px;
}
.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
.lightbox-caption {
  max-width: min(1100px, calc(100vw - 120px));
  margin-top: 12px;
  color: #dbe7ff;
  font-size: 13px;
  word-break: break-all;
  text-align: center;
}

.result-list, .result-media { overflow: hidden; }
.result-text, .result-media, .result-list { min-height: 520px; }
.result-job {
  width: 100%;
  text-align: left;
  display: block;
}
.result-job.active { outline: 2px solid #b2ccff; }
.artifact-list { display: grid; gap: 7px; margin-top: 12px; }
.artifact-list code {
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  color: #475467;
  background: var(--soft);
}
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.quality-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}
.quality-item strong, .quality-item span { display: block; }
.quality-item span { color: var(--muted); font-size: 13px; }
.quality-item p { font-size: 13px; }
.quality-item.pass { border-color: #abefc6; background: #f6fef9; }
.quality-item.fail { border-color: #fecdca; background: #fff7f6; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card code {
  display: block;
  color: #475467;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

@media (max-width: 1280px) {
  .split-layout, .generation-layout, .result-workbench, .bottom-review, .live-preview { grid-template-columns: 1fr; }
  .result-text, .result-media, .result-list { min-height: auto; }
  .category-editor { grid-template-columns: 1fr; }
  .category-tabs {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    max-height: none;
  }
}
@media (max-width: 860px) {
  body, body.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar, body.sidebar-collapsed .sidebar, body.sidebar-collapsed .sidebar:hover { width: 100%; min-height: auto; }
  body.sidebar-collapsed .brand strong, body.sidebar-collapsed .brand span { opacity: 1; }
  body.sidebar-collapsed .nav { font-size: 15px; text-align: left; padding: 12px 14px; }
  body.sidebar-collapsed .nav::before { content: ""; }
  .shell { padding: 16px; }
  .grid, .steps, .stats, .thumb-grid, .image-card-grid { grid-template-columns: 1fr; }
  .topic-item { align-items: stretch; flex-direction: column; }
  .page-head, .toolbar, .flow-footer { align-items: stretch; flex-direction: column; }
}
