/* Generation workspace: independently scrollable records and review surfaces. */
.main:has(.sd-page) { overflow: hidden; padding: 22px 24px 24px; min-height: 0; }
.sd-page { display: flex; flex-direction: column; max-width: 1680px; height: 100%; min-height: 0; }
.sd-page > .page-head, .sd-page > .tabs { flex: none; }
.sd-page #sdRuns { flex: 1; min-height: 0; }
.sd-layout { grid-template-columns: clamp(258px, 27%, 310px) minmax(0, 1fr); gap: 18px; height: 100%; min-height: 0; align-items: stretch; }
.sd-side { position: static; height: 100%; min-height: 0; max-height: none; padding: 16px 10px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-1); overflow: hidden; }
.sd-side-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 0 6px 13px; }
.sd-side-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.sd-side-head > span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sd-filter { gap: 6px; margin: 0 3px 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sd-filter button { font-size: 11.5px; padding: 4px 9px; min-height: 30px; border-radius: 8px; }
.sd-filter button.on { border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.sd-filter button b { margin-left: 5px; font-variant-numeric: tabular-nums; }
.sd-list { flex: 1; min-height: 0; gap: 5px; padding: 2px 4px 4px; scrollbar-width: thin; }
.sd-item { gap: 11px; padding: 11px 9px; border-radius: 11px; min-height: 88px; position: relative; }
.sd-item.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: none; }
.sd-item.on::before { content: ""; position: absolute; left: -1px; top: 22px; bottom: 22px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.sd-item .sd-th { width: 46px; height: 58px; border-radius: 8px; background-size: cover; }
.sd-item .t { font-size: 13px; line-height: 1.55; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sd-item .m { gap: 4px 8px; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.sd-item .m > :last-child { color: var(--dim); }
.sd-item .tk-kind { font-size: 10.5px; line-height: 1.6; padding: 1px 6px; }
.sd-item .st.needs_attention { color: var(--warn); }
.sd-detail { min-width: 0; min-height: 0; height: 100%; overflow: auto; padding: 22px; border-radius: 16px; scrollbar-width: thin; scrollbar-gutter: stable; container: sd-detail / inline-size; }
.sd-dh { flex-direction: column; gap: 12px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.sd-dt { min-width: 0; width: 100%; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.sd-dt h2 { flex: 1 1 200px; font-size: 20px; line-height: 1.45; letter-spacing: -.3px; overflow-wrap: anywhere; }
.sd-dt-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sd-dt .badge { margin-left: 0; }
.sd-act { width: 100%; gap: 8px; }
.sd-act #sdDel { margin-left: auto; color: var(--muted); }
.sd-act #sdDel:hover { color: var(--cut); background: var(--cut-soft); }
.sd-steps { margin-bottom: 18px; gap: 6px 0; flex-wrap: wrap; }
.sd-steps li { font-size: 11px; min-width: 70px; }
.sd-steps .dot { width: 21px; height: 21px; font-size: 10px; }
.sd-steps li.hold .dot { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.sd-steps .lb { margin: 0; font-size: inherit; color: inherit; }
.sd-steps li:not(:last-child)::after { min-width: 4px; margin: 0 7px; height: 1px; }
.sd-workbench { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "preview" "quality" "files"; gap: 18px; align-items: start; margin-bottom: 18px; }
.sd-preview-column { grid-area: preview; display: grid; gap: 16px; min-width: 0; }
.sd-workbench > .sd-quality { grid-area: quality; }
.sd-workbench > .sd-attachments { grid-area: files; }
.sd-preview-card { min-width: 0; border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: var(--bg-1); }
.sd-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sd-section-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
.sd-section-head > span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sd-media-stage { display: flex; justify-content: center; min-width: 0; background: #090d14; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sd-media-stage video.sd-video { display: block; width: 100%; max-width: min(100%, calc(min(48vh, 480px) * var(--media-ratio))); height: auto; max-height: none; aspect-ratio: var(--media-aspect); object-fit: contain; border-radius: 0; background: #090d14; }
.sd-versions { display: grid; gap: 6px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.sd-versions select { width: 100%; max-width: 100%; min-width: 0; font-size: 12px; }
.sd-attachments { min-width: 0; border: 1px solid var(--line); border-radius: 13px; padding: 0 14px; background: var(--bg-1); }
.sd-attachments > summary { display: flex; align-items: center; gap: 8px; padding: 13px 0; list-style: none; cursor: pointer; font-size: 13px; font-weight: 650; }
.sd-attachments > summary::-webkit-details-marker { display: none; }
.sd-attachments > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 16px; font-weight: 400; }
.sd-attachments[open] > summary::after { content: "−"; }
.sd-attachments > summary span { color: var(--muted); font-size: 11px; font-weight: 400; }
.sd-files { min-width: 0; padding-bottom: 6px; }
.sd-files-h { font-size: 12px; color: var(--muted); margin: 14px 0 8px; }
.sd-file { padding: 9px; gap: 8px; border-radius: 8px; font-size: 12px; background: var(--bg-2); }
.sd-file .ic { width: 15px; height: 15px; color: var(--accent); }
.sd-file small { color: var(--muted); font-size: 10.5px; flex: none; }
.sd-imgs { gap: 8px; }
.sd-imgs img { height: 96px; max-width: 160px; object-fit: contain; border-radius: 7px; background: var(--bg); }
.sd-files .hint { font-size: 11.5px; margin: 10px 0; }
.sd-quality { min-width: 0; padding: 18px; border: 1px solid var(--line-2); border-radius: 13px; background: var(--bg-1); margin: 0; }
.sd-quality-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.sd-quality h3 { margin: 0; font-size: 15px; font-weight: 650; }
.sd-quality-count { flex: none; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sd-quality-progress { height: 4px; border-radius: 4px; background: var(--bg-4); overflow: hidden; margin-bottom: 14px; }
.sd-quality-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--keep); }
.sd-quality-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 7px; margin-bottom: 14px; }
/* Explicit foreground AND background prevent light-on-light status labels. */
.sd-quality-item { display: flex; gap: 9px; align-items: center; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3); color: var(--ink); font-size: 12px; line-height: 1.5; }
.sd-quality-icon { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-2); border-radius: 50%; color: var(--muted); font-size: 11px; font-weight: 700; }
.sd-quality-name { min-width: 0; font-weight: 550; }
.sd-quality-state { margin-left: auto; flex: none; color: var(--muted); font-size: 11px; }
.sd-quality-item.passed { background: var(--keep-soft); border-color: color-mix(in srgb, var(--keep) 30%, transparent); }
.sd-quality-item.passed .sd-quality-state, .sd-quality-item.passed .sd-quality-icon { color: var(--keep); }
.sd-quality-item.passed .sd-quality-icon { border-color: currentColor; }
.sd-quality-item.failed { background: var(--cut-soft); border-color: color-mix(in srgb, var(--cut) 30%, transparent); }
.sd-quality-item.failed .sd-quality-state, .sd-quality-item.failed .sd-quality-icon { color: var(--cut); }
.sd-quality-item.failed .sd-quality-icon { border-color: currentColor; }
.sd-quality-item.not_reviewed .sd-quality-state { color: var(--warn); }
.sd-quality > .hint { font-size: 12px; margin: 0 0 12px; }
.sd-quality > ul { padding-left: 18px; color: var(--err-ink); font-size: 12px; overflow-wrap: anywhere; }
.sd-review-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 7px; margin: 12px 0 0; }
.sd-review-checks label { display: flex; gap: 9px; align-items: center; min-height: 36px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 12px; line-height: 1.6; cursor: pointer; background: var(--bg-2); }
.sd-review-checks label:hover { border-color: var(--line-2); }
.sd-review-checks input { width: 15px; height: 15px; margin: 0; flex: none; }
.sd-review-checks label:has(:checked) { background: var(--accent-soft); border-color: var(--accent); }
.sd-review-checks label:has(:disabled) { color: var(--muted); cursor: not-allowed; }
.sd-review-checks input:disabled { opacity: .7; }
.sd-quality-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.sd-quality-actions .btn { flex: 1 1 auto; white-space: normal; }
.sd-detail > .card { padding: 16px; border-radius: 13px; background: var(--bg-1); box-shadow: none; }
.sd-detail > .card h3 { font-size: 13px; margin: 0 0 6px; }
.sd-detail > .card .hint { font-size: 12px; margin-bottom: 6px; }
.sd-detail > .card .hint:last-child { margin-bottom: 0; }
.sd-detail > .card code { font-size: 11px; overflow-wrap: anywhere; }
.sd-meta { gap: 12px 24px; padding: 16px 0; margin-bottom: 12px; font-size: 12px; }
.sd-meta dt { color: var(--muted); margin-bottom: 3px; }
.sd-logbox { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.sd-logbox summary { font-size: 12px; }
.sd-logbox .sd-log { margin-bottom: 8px; }
@container sd-detail (min-width: 620px) {
  .sd-workbench.v { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-areas: "preview quality" "files quality"; }
  .sd-workbench.v .sd-quality-list, .sd-workbench.v .sd-review-checks { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) and (min-width: 861px) {
  .sd-layout { grid-template-columns: 258px minmax(0, 1fr); gap: 14px; }
  .sd-detail { padding: 18px; }
}
@media (max-width: 860px) {
  .main:has(.sd-page) { overflow-y: auto; padding: 18px; }
  .sd-page { height: auto; min-height: 100%; }
  .sd-page #sdRuns { flex: none; }
  .sd-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .sd-side { height: auto; max-height: 310px; }
  .sd-side-head { padding-bottom: 8px; }
  .sd-filter { padding-bottom: 10px; margin-bottom: 8px; }
  .sd-list { max-height: 195px; }
  .sd-item { min-height: 76px; }
  .sd-detail { height: auto; overflow: visible; scrollbar-gutter: auto; }
}
@media (max-width: 560px) {
  .main:has(.sd-page) { padding: 16px 12px; }
  .sd-detail { padding: 14px; }
  .sd-dt h2 { font-size: 18px; }
  .sd-quality { padding: 14px; }
  .sd-quality-list, .sd-review-checks { grid-template-columns: minmax(0, 1fr); }
  .sd-quality-head { align-items: flex-start; flex-wrap: wrap; }
  .sd-act { gap: 6px; }
  .sd-act .btn { white-space: normal; }
  .sd-steps { row-gap: 10px; }
  .sd-steps .lb, .sd-steps li.now .lb { display: inline; }
  .sd-steps li { flex: 1 1 96px; align-items: flex-start; }
  .sd-steps .lb { white-space: normal; overflow: visible; line-height: 1.5; }
  .sd-steps li:not(:last-child)::after { display: none; }
}

/* ---------- 制作流程步骤条（sdStepper）：圆点在上、步骤名在下，名字完整显示 ---------- */
.sd-flow { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-1); padding: 14px 16px 14px; margin: 0 0 16px; }
.sd-flow-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 14px; }
.sd-flow-h h3 { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--ink); letter-spacing: 0; }
.sd-flow-h .sum { font-size: 12.5px; color: var(--muted); }
.sd-flow.running .sd-flow-h .sum { color: var(--accent); font-weight: 600; }
.sd-flow.failed .sd-flow-h .sum, .sd-flow.interrupted .sd-flow-h .sum { color: var(--cut); font-weight: 600; }
.sd-flow.done .sd-flow-h .sum { color: var(--keep); font-weight: 600; }
.sd-flow-h .cnt { margin-left: auto; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.sd-flow-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); }
.sd-flow-steps li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; min-width: 0; padding: 0 3px; color: var(--dim); }
/* 两点之间的连线：画在后一步左半边，走到这一步就上色 */
.sd-flow-steps li::before { content: ""; position: absolute; top: 13px; left: calc(-50% + 19px); right: calc(50% + 19px); height: 2px; border-radius: 2px; background: var(--line-2); }
.sd-flow-steps li:first-child::before { display: none; }
.sd-flow-steps li:not(.todo)::before { background: var(--keep); }
.sd-flow-steps .dot { position: relative; z-index: 1; width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--bg-1); border: 1.5px solid var(--line-2); color: var(--dim); transition: background .2s, border-color .2s; }
.sd-flow-steps .dot svg { width: 15px; height: 15px; display: block; }
.sd-flow-steps .lb { font-size: 12.5px; line-height: 1.35; font-weight: 550; color: inherit; max-width: 100%; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.sd-flow-steps small { font-size: 11px; line-height: 1.3; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sd-flow-steps li.todo .lb { color: var(--dim); font-weight: 500; }
.sd-flow-steps li.ok { color: var(--ink); }
.sd-flow-steps li.ok .dot { background: var(--keep); border-color: var(--keep); color: #fff; }
.sd-flow-steps li.now { color: var(--ink); }
.sd-flow-steps li.now .lb { font-weight: 700; }
.sd-flow-steps li.now .dot { border: 2px solid var(--accent); color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }
.sd-flow-steps li.now small { color: var(--accent); font-weight: 600; }
.sd-flow-steps li.stop { color: var(--ink); }
.sd-flow-steps li.stop .dot { background: var(--bg-3); border-color: var(--line-2); color: var(--muted); }
.sd-flow-steps li.stop small { color: var(--muted); font-weight: 600; }
.sd-flow-steps li.stop::before { background: var(--line-2); }
.sd-flow-steps li.bad { color: var(--ink); }
.sd-flow-steps li.bad .dot { background: var(--cut); border-color: var(--cut); color: #fff; }
.sd-flow-steps li.bad small { color: var(--cut); font-weight: 600; }
.sd-flow-steps li.hold { color: var(--ink); }
.sd-flow-steps li.hold .dot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.sd-flow-steps li.hold small { color: var(--warn); font-weight: 600; }
.sd-flow.cancelled .sd-flow-steps li.todo, .sd-flow.failed .sd-flow-steps li.todo, .sd-flow.interrupted .sd-flow-steps li.todo { opacity: .6; }
/* 详情面板窄（或步骤多到放不下两行字）时：改成竖向列表，连线竖着走 */
@container sd-detail (max-width: 620px) {
  .sd-flow-steps { grid-template-columns: minmax(0, 1fr); }
  .sd-flow-steps li { flex-direction: row; align-items: center; text-align: left; gap: 10px; padding: 0 0 12px; }
  .sd-flow-steps li:last-child { padding-bottom: 0; }
  .sd-flow-steps li::before { top: auto; bottom: calc(100% - 2px); left: 13px; right: auto; width: 2px; height: 14px; }
  .sd-flow-steps .lb { flex: 1; -webkit-line-clamp: 1; }
  .sd-flow-steps small { margin-left: auto; }
}
/* 已取消：中性灰，不是报错红 */
.sd-stopped { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.sd-stopped-ic { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--bg-1); border: 1px solid var(--line-2); color: var(--muted); }
.sd-stopped-ic svg { width: 15px; height: 15px; }
.sd-stopped b { font-size: 14px; color: var(--ink); }
.sd-stopped p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.sd-stopped p.hint { color: var(--dim); }
@media (prefers-reduced-motion: reduce) { .sd-flow-steps li.now .dot { animation: none; } }
