:root {
  --bg: #f4f5f3;
  --surface: #fff;
  --surface-soft: #f8f9f7;
  --ink: #111513;
  --ink-2: #4f5a55;
  --ink-3: #8a928e;
  --line: #dfe4df;
  --line-dark: #cdd4ce;
  --teal: #108f82;
  --teal-soft: #e1f4ef;
  --orange: #b86a14;
  --orange-soft: #f7e8cf;
  --red: #c43b31;
  --red-soft: #f8e4e0;
  --black: #111612;
  --shadow: 0 1px 2px rgba(17, 21, 19, .05), 0 18px 38px rgba(17, 21, 19, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, dl, dd { margin: 0; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.console-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.console-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.console-brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: 0;
}
.console-brand small {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 12px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--black);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.brand-mark i {
  width: 14px;
  height: 18px;
  display: block;
  border-radius: 2px;
  background: linear-gradient(90deg, #fff 0 43%, transparent 43% 58%, #f15b3d 58% 100%);
}
.system-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.system-pill {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #eef1ee;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}
.system-pill i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(16,143,130,.13);
}
.system-pill.ok { background: var(--teal-soft); color: #087469; }
.system-pill.warn { background: var(--orange-soft); color: #97520a; }
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { border-color: var(--line-dark); background: var(--surface-soft); }
.icon-btn.subtle { background: var(--surface-soft); }

.video-console {
  min-height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 286px minmax(620px, 1fr) 304px;
  background: var(--bg);
}
.template-rail, .queue-panel {
  min-height: calc(100vh - 58px);
  background: var(--surface);
}
.template-rail {
  border-right: 1px solid var(--line);
  padding: 20px 10px 16px;
  overflow: auto;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 14px;
}
.rail-head h1, .queue-head h2 {
  font-size: 16px;
  letter-spacing: 0;
}
.rail-head span {
  color: var(--ink-3);
  font-weight: 700;
}
.filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 4px 12px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 650;
}
.filter-chip.active {
  background: var(--black);
  border-color: var(--black);
  color: #fff;
}
.template-list {
  display: grid;
  gap: 9px;
}
.template-card {
  width: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  padding: 8px;
  text-align: left;
  color: var(--ink);
}
.template-card:hover { background: var(--surface-soft); }
.template-card.active {
  background: var(--black);
  color: #fff;
}
.template-card.active .template-meta,
.template-card.active p { color: rgba(255,255,255,.72); }
.template-card img {
  width: 72px;
  height: 84px;
  object-fit: cover;
  border-radius: 5px;
  background: #ecefeb;
}
.template-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.template-card p {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-meta {
  margin-top: 7px;
  display: flex;
  gap: 10px;
  color: var(--ink-3);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
}
.workspace-form {
  min-height: calc(100vh - 58px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.template-hero {
  min-height: 178px;
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 18px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.hero-thumb {
  position: relative;
  width: 144px;
  height: 144px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8ebe7;
  box-shadow: var(--shadow);
}
.hero-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #e8ebe7;
}
.hero-copy { min-width: 0; }
.title-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.title-line h2 {
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.05;
}
.quality-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}
.hero-copy p {
  margin-top: 12px;
  max-width: 68ch;
  color: var(--ink-2);
}
.spec-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}
.spec-row div {
  display: flex;
  align-items: center;
  gap: 6px;
}
.spec-row dt {
  color: var(--ink-3);
  font-size: 12px;
}
.spec-row dd {
  color: var(--ink);
  font-weight: 800;
}

.material-panel {
  padding: 22px 72px 96px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.panel-head h3, .requirements h3 {
  font-size: 16px;
}
.panel-head p {
  margin-top: 5px;
  max-width: 74ch;
  color: var(--ink-2);
  font-size: 13px;
}
.ghost-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}
.ghost-action svg { width: 15px; height: 15px; }
.material-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(250px, 360px);
  gap: 14px;
}
.upload-drop {
  position: relative;
  min-height: 224px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed #bfc8c1;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  overflow: hidden;
}
.upload-drop:hover, .mini-upload:hover {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16,143,130,.08);
}
.upload-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--teal);
}
.upload-icon svg { width: 30px; height: 30px; }
.upload-drop strong { font-size: 17px; }
.upload-drop small, .mini-upload small { color: var(--ink-2); }
.upload-drop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  padding: 10px;
}
.upload-drop.has-file {
  border-style: solid;
}
.side-uploads {
  display: grid;
  align-content: start;
  gap: 10px;
}
.mini-upload {
  min-height: 65px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
  text-align: left;
}
.mini-upload.required {
  border-color: #d97757;
  background: #fffaf7;
}
.mini-upload strong, .mini-upload small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--teal-soft);
  color: var(--teal);
}
.mini-icon.warm {
  background: var(--red-soft);
  color: var(--red);
}
.mini-icon svg { width: 20px; height: 20px; }
.mini-upload .chevron {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
}

.requirements {
  margin-top: 24px;
}
.requirements-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.requirements-head small { color: var(--ink-3); }
.requirements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 20px;
}
.requirements-head { grid-column: 1 / -1; }
.requirements label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
}
.requirements input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  flex: 0 0 auto;
}
.task-fields {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(260px, 2fr) minmax(130px, .8fr);
  gap: 12px;
}
.prompt-fields {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.task-fields label, .prompt-fields label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid rgba(16,143,130,.35);
  outline-offset: 2px;
}

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(255,255,255,.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.submit-bar span {
  color: var(--ink-2);
  font-size: 13px;
}
.submit-btn {
  min-width: 150px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: var(--black);
  color: #fff;
  font-weight: 800;
}
.submit-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}
.submit-btn:disabled {
  background: #b8beb8;
  cursor: default;
}

.queue-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.queue-head {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.queue-stats {
  margin-top: 9px;
  display: flex;
  gap: 12px;
  color: var(--ink-2);
  font-size: 12px;
}
.queue-stats b { color: var(--ink); }
.queue-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px;
}
.queue-empty {
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--ink-3);
  text-align: center;
}
.queue-empty svg {
  width: 34px;
  height: 34px;
}
.queue-empty strong { color: var(--ink-2); }
.job-card {
  width: 100%;
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 11px;
  text-align: left;
}
.job-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16,143,130,.08);
}
.job-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-card small {
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf0ed;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
}
.status.ok { background: var(--teal-soft); color: #087469; }
.status.run, .status.review { background: var(--orange-soft); color: var(--orange); }
.status.bad { background: var(--red-soft); color: var(--red); }
.result-drawer {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  background: var(--surface-soft);
}
.drawer-empty {
  display: grid;
  gap: 4px;
  color: var(--ink-3);
}
.drawer-empty strong {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-video {
  display: grid;
  gap: 10px;
}
.result-video video {
  width: 100%;
  max-height: 260px;
  border-radius: 7px;
  background: #000;
}
.review-banner {
  border-radius: 6px;
  background: var(--orange-soft);
  color: var(--orange);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}
.evidence {
  display: grid;
  gap: 6px;
}
.evidence div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
}
.evidence dt { color: var(--ink-3); }
.evidence dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.download-row, .review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 750;
}
.btn.dark, .btn.approve-btn {
  border-color: var(--black);
  background: var(--black);
  color: #fff;
}
.btn.ghost {
  color: var(--red);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 50;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(17,21,19,.94);
  color: #fff;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .video-console {
    grid-template-columns: 250px minmax(0, 1fr);
  }
  .queue-panel {
    grid-column: 1 / -1;
    min-height: auto;
    border-top: 1px solid var(--line);
  }
  .queue-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 320px;
  }
  .queue-empty {
    grid-column: 1 / -1;
    min-height: 140px;
  }
}

@media (max-width: 860px) {
  .console-topbar {
    height: auto;
    min-height: 58px;
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 12px;
  }
  .system-strip {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .video-console {
    display: block;
  }
  .template-rail, .queue-panel {
    min-height: auto;
    border-right: 0;
  }
  .template-rail {
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
  }
  .template-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .template-card {
    flex: 0 0 238px;
  }
  .workspace-form {
    min-height: auto;
  }
  .template-hero {
    grid-template-columns: 112px minmax(0, 1fr);
    padding: 16px;
  }
  .hero-thumb {
    width: 112px;
    height: 112px;
  }
  .material-panel {
    padding: 18px 16px 92px;
  }
  .material-grid, .requirements, .task-fields, .prompt-fields {
    grid-template-columns: 1fr;
  }
  .queue-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .console-brand strong { font-size: 16px; }
  .title-line h2 { font-size: 24px; }
  .template-hero {
    grid-template-columns: 1fr;
  }
  .hero-thumb {
    width: 100%;
    height: 220px;
  }
  .title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .spec-row {
    gap: 12px;
  }
  .panel-head, .submit-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .submit-btn {
    width: 100%;
  }
}
