:root {
  --bg: #eef3ef;
  --panel: #ffffff;
  --panel-soft: #f8faf8;
  --line: #d9e2da;
  --line-strong: #bed2c5;
  --text: #17221c;
  --muted: #66766c;
  --faint: #8a988f;
  --accent: #21745c;
  --accent-strong: #185d49;
  --accent-soft: #e5f3ed;
  --blue: #2f6f9f;
  --warning: #9b6a1d;
  --danger: #9a3a36;
  --shadow: 0 16px 42px rgba(21, 35, 28, 0.08);
  --shadow-soft: 0 6px 18px rgba(21, 35, 28, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 220px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(33, 116, 92, 0.28);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 80px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: stretch;
  gap: 14px;
  min-height: 0;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: rgba(251, 253, 251, 0.92);
  backdrop-filter: blur(16px);
}

.sidebar-toggle-button {
  position: absolute;
  top: 20px;
  left: 20px;
  flex: 0 0 auto;
  font-size: 18px;
  z-index: 2;
}

.brand-copy {
  min-width: 0;
}

.app-shell.sidebar-collapsed .sidebar {
  grid-template-rows: auto;
  align-content: start;
  padding: 20px;
}

.app-shell.sidebar-collapsed .brand-row {
  justify-content: start;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed #refreshButton,
.app-shell.sidebar-collapsed #newButton,
.app-shell.sidebar-collapsed .project-list {
  display: none;
}

.brand-row,
.topbar,
.panel-header,
.editor-head,
.prompt-head,
.dialog-head,
.dialog-actions,
.inline-form {
  display: flex;
  align-items: center;
}

.brand-row,
.topbar,
.panel-header,
.editor-head,
.prompt-head,
.dialog-head,
.dialog-actions {
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  min-height: 40px;
  padding-left: 52px;
}

.app-shell.sidebar-collapsed .brand-row {
  padding-left: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

#projectCount {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 22px 24px;
  overflow: hidden;
}

.workspace.settings-mode {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

.workspace.settings-mode > .topbar {
  display: none;
}

.workspace > .topbar,
.workspace > .workspace-body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: stretch;
  min-height: 48px;
}

.topbar > div:first-child,
.chat-head > div:first-child,
.editor-head > div:first-child,
.panel-header > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

#projectMeta,
#filePathLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex: 0 0 auto;
  justify-items: end;
  gap: 6px;
  margin-left: 8px;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.toolbar .primary-button {
  padding: 0 16px;
}

.toolbar .secondary-button {
  padding: 0 12px;
}

.toolbar .icon-button {
  width: 38px;
}

#settingsButton.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.primary-button,
.secondary-button,
.icon-button {
  height: 40px;
  border-radius: var(--radius);
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(33, 116, 92, 0.18);
}

.secondary-button {
  padding: 0 15px;
  color: var(--text);
  background: #edf3ee;
  border: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  color: var(--text);
  background: #edf3ee;
  border: 1px solid var(--line);
  font-size: 20px;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

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

.primary-button.danger-button {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(154, 58, 54, 0.18);
}

.primary-button.danger-button:hover {
  background: #7f2f2c;
}

.primary-button.warning-button {
  background: #b8791d;
  box-shadow: 0 8px 18px rgba(184, 121, 29, 0.18);
}

.primary-button.warning-button:hover {
  background: #985f12;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.compact {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 2px 4px 10px 0;
  scrollbar-gutter: stable;
}

.project-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.action-panel::-webkit-scrollbar,
.settings-panel::-webkit-scrollbar,
.delivery-center-home::-webkit-scrollbar,
.video-artifacts::-webkit-scrollbar,
.video-review-panel::-webkit-scrollbar,
.video-stage-strip::-webkit-scrollbar,
.file-editor::-webkit-scrollbar,
.markdown-viewer::-webkit-scrollbar,
.tabs::-webkit-scrollbar,
#promptText::-webkit-scrollbar,
.textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.project-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.action-panel::-webkit-scrollbar-thumb,
.settings-panel::-webkit-scrollbar-thumb,
.delivery-center-home::-webkit-scrollbar-thumb,
.video-artifacts::-webkit-scrollbar-thumb,
.video-review-panel::-webkit-scrollbar-thumb,
.video-stage-strip::-webkit-scrollbar-thumb,
.file-editor::-webkit-scrollbar-thumb,
.markdown-viewer::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb,
#promptText::-webkit-scrollbar-thumb,
.textarea::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(102, 118, 108, 0.36);
  background-clip: padding-box;
}

.project-item {
  display: block;
  width: 100%;
  min-height: 86px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.project-item.active {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow:
    0 0 0 2px rgba(33, 116, 92, 0.1),
    var(--shadow-soft);
}

.project-title-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0;
}

.project-name {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-item:hover .project-name,
.project-item:focus-visible .project-name {
  -webkit-line-clamp: unset;
}

.project-sub {
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.project-item:hover .project-sub,
.project-item:focus-visible .project-sub {
  white-space: normal;
}

.status-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  max-width: 140px;
  padding: 0 10px;
  overflow: hidden;
  border-radius: 999px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
}

.mini-pill.todo {
  color: var(--warning);
  background: #fbecd7;
}

.nav-stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-stage-row .view-switcher {
  min-width: 0;
  overflow: auto;
}

.nav-stage-row .progress-toggle-button {
  margin-left: auto;
}

.stage-area {
  position: relative;
  min-width: 0;
}

.stage-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--stage-count, 7), minmax(0, 1fr));
  gap: 0;
  min-width: 0;
  min-height: 48px;
  padding: 2px 4px 0;
  align-items: center;
  isolation: isolate;
}

.stage-strip::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 22px;
  right: calc(4px + var(--stage-edge, 7.142%));
  left: calc(4px + var(--stage-edge, 7.142%));
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #21745c 0%, #44a071 38%, #d7aa43 68%, #d7e3da 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.stage {
  appearance: none;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 14px 16px 16px;
  justify-items: center;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 0 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: default;
}

.stage::before {
  content: "";
  grid-row: 2;
  width: 10px;
  height: 10px;
  border: 2px solid #b9cec2;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 0 0 4px rgba(238, 243, 239, 0.86);
}

.stage.current {
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.stage.done {
  border-color: transparent;
}

.stage.done::before {
  border-color: var(--accent);
  background: var(--accent);
}

.stage.current::before {
  width: 17px;
  height: 17px;
  border-color: #fff;
  background: var(--accent);
  box-shadow:
    0 0 0 5px rgba(33, 116, 92, 0.14),
    0 0 0 10px rgba(33, 116, 92, 0.06);
}

.stage-key {
  grid-row: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 650;
}

.stage-label {
  grid-row: 3;
  max-width: 100%;
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 680;
}

.stage.done .stage-label {
  color: var(--accent);
}

.stage.current .stage-key {
  color: var(--accent);
}

.stage.current .stage-label {
  height: 20px;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid rgba(33, 116, 92, 0.24);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 4px 14px rgba(21, 35, 28, 0.08);
}

.stage.current:hover .stage-label,
.stage.current:focus-visible .stage-label {
  border-color: rgba(33, 116, 92, 0.46);
  background: #fff;
}

.stage-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 45;
  display: grid;
  gap: 14px;
  width: min(380px, calc(100vw - 40px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 48px rgba(21, 35, 28, 0.16);
}

.stage-popover::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.stage-popover-head,
.stage-progress-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.stage-popover-head > div,
.stage-progress-summary .section-title {
  min-width: 0;
}

.stage-popover h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-progress-summary {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stage-progress-summary .secondary-button {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.view-switcher {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.view-tab {
  height: 34px;
  padding: 0 16px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

.view-tab.active {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-soft);
}

.progress-toggle-button {
  position: relative;
  flex: 0 0 40px;
}

.progress-toggle-button.active,
.progress-toggle-button.has-progress {
  border-color: rgba(33, 116, 92, 0.38);
  color: var(--accent);
  background: #f4fbf7;
}

.progress-toggle-button.running::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(33, 116, 92, 0.12);
}

.progress-toggle-icon {
  display: inline-grid;
  grid-template-columns: repeat(3, 4px);
  align-items: end;
  justify-content: center;
  gap: 3px;
  width: 18px;
  height: 18px;
}

.progress-toggle-icon span {
  display: block;
  width: 4px;
  border-radius: 999px;
  background: currentColor;
}

.progress-toggle-icon span:nth-child(1) {
  height: 7px;
}

.progress-toggle-icon span:nth-child(2) {
  height: 14px;
}

.progress-toggle-icon span:nth-child(3) {
  height: 10px;
}

.view-stack {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.workspace-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.main-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.right-rail {
  position: fixed;
  top: 146px;
  right: 24px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(360px, 30vw);
  max-height: calc(100vh - 170px);
  overflow: auto;
  pointer-events: auto;
  scrollbar-gutter: stable;
}

.workspace.settings-mode .right-rail {
  display: none;
}

.execution-stage-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

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

.execution-stage-head h3 {
  font-size: 16px;
}

.right-rail .stage-area {
  min-width: 0;
}

.right-rail .stage-strip {
  display: grid;
  grid-template-columns: repeat(var(--stage-count, 4), minmax(0, 1fr));
  gap: 0;
  min-height: 66px;
  padding: 4px 4px 2px;
  isolation: isolate;
}

.right-rail .stage-strip::before {
  top: 30px;
  bottom: auto;
  right: calc(4px + var(--stage-edge, 12.5%));
  left: calc(4px + var(--stage-edge, 12.5%));
  width: auto;
  height: 3px;
  background: linear-gradient(90deg, #21745c 0%, #44a071 38%, #d7aa43 68%, #d7e3da 100%);
}

.right-rail .stage {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 16px 22px 20px;
  justify-items: center;
  align-items: center;
  min-height: 60px;
  padding: 0 2px;
  cursor: default;
}

.right-rail .stage::before {
  grid-row: 2;
  grid-column: 1;
  justify-self: center;
  width: 9px;
  height: 9px;
  box-shadow: 0 0 0 4px rgba(238, 243, 239, 0.9);
}

.right-rail .stage.current::before {
  width: 15px;
  height: 15px;
  box-shadow:
    0 0 0 4px rgba(33, 116, 92, 0.14),
    0 0 0 8px rgba(33, 116, 92, 0.06);
}

.right-rail .stage-key,
.right-rail .stage-label {
  grid-column: 1;
  max-width: 100%;
  margin: 0;
  text-align: center;
}

.right-rail .stage-key {
  grid-row: 1;
  font-size: 10px;
}

.right-rail .stage-label {
  grid-row: 3;
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
}

.right-rail .stage.current .stage-label {
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.right-rail .stage-popover {
  position: static;
  display: grid;
  gap: 12px;
  width: auto;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.right-rail .stage-popover::before {
  display: none;
}

.right-rail .stage-control {
  padding-top: 12px;
}

.view-pane {
  display: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.view-pane.active {
  display: grid;
}

.work-view {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.files-view {
  min-height: 0;
}

.materials-view {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.settings-view {
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.workspace.settings-mode .settings-view {
  height: 100%;
}

.deliveries-view {
  min-height: 0;
  overflow: hidden;
}

.delivery-center-home {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 2px 4px 18px 2px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.delivery-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.delivery-hero > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.delivery-hero p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.delivery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
}

.delivery-card {
  display: grid;
  grid-template-rows: auto minmax(96px, 1fr) auto auto;
  gap: 14px;
  min-width: 0;
  min-height: 244px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.delivery-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.delivery-card-head,
.delivery-actions,
.video-studio-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.delivery-card-head {
  justify-content: space-between;
}

.delivery-type-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 7px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 760;
}

.delivery-card.xiaohongshu .delivery-type-mark {
  color: #9a3a36;
  background: #fbeceb;
}

.delivery-card.image .delivery-type-mark {
  color: var(--blue);
  background: #e9f2f8;
}

.delivery-card.video .delivery-type-mark {
  color: #765312;
  background: #f8efd9;
}

.delivery-status {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.delivery-card h4 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.delivery-card p {
  color: var(--muted);
  line-height: 1.6;
}

.delivery-warning {
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.delivery-card.create-card {
  border-style: dashed;
  background: rgba(248, 250, 248, 0.72);
}

.video-create-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.video-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.video-create-grid label {
  display: grid;
  gap: 7px;
}

.video-preset-note {
  min-height: 46px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--panel-soft);
  line-height: 1.55;
}

.delivery-actions {
  flex-wrap: wrap;
}

.delivery-actions.end {
  justify-content: flex-end;
}

.delivery-actions.vertical {
  display: grid;
  width: 100%;
}

.delivery-run-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.72fr);
  gap: 8px;
  align-items: stretch;
}

.delivery-run-row .delivery-card-action,
.delivery-run-row .delivery-model-select {
  width: 100%;
  min-width: 0;
}

.delivery-run-row .delivery-model-select {
  height: 44px;
}

.delivery-model-note {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.xhs-delivery-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
}

.xhs-image-provider-notice {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e4c786;
  border-radius: 6px;
  color: #715319;
  background: #fff8e9;
}

.video-studio {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.xhs-studio {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.xhs-comfy-config {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.5fr) minmax(190px, 0.9fr) auto;
  align-items: end;
  gap: 10px 14px;
  padding: 14px 16px;
  border: 1px solid #b8d7ca;
  border-radius: var(--radius);
  background: #f7fbf8;
}

.xhs-comfy-config h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.xhs-comfy-config .field-label {
  gap: 6px;
  margin: 0;
}

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

.comfy-config-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.video-studio-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.video-studio-title {
  min-width: 0;
}

.video-studio-title h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-source-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #ead7af;
  border-radius: var(--radius);
  color: #715319;
  background: #fff9ed;
}

.video-stage-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(86px, 1fr));
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 2px 6px;
}

.video-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 7px;
  align-items: center;
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.8);
}

.video-stage-dot {
  grid-row: 1 / span 2;
  width: 9px;
  height: 9px;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
}

.video-stage strong,
.video-stage small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-stage strong {
  font-size: 12px;
}

.video-stage small {
  color: var(--faint);
  font-size: 10px;
}

.video-stage.completed {
  border-color: #bdd9ca;
  background: #f1f8f4;
}

.video-stage.completed .video-stage-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.video-stage.in_progress,
.video-stage.awaiting_human {
  border-color: #dec686;
  background: #fff9e9;
}

.video-stage.in_progress .video-stage-dot,
.video-stage.awaiting_human .video-stage-dot {
  border-color: #b9811e;
  background: #d9aa4c;
}

.video-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.xhs-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.video-artifact-panel,
.video-review-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.video-artifact-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.compact-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.video-artifacts {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  padding: 12px 14px 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.xhs-script-preview {
  min-height: 0;
  padding: 18px 22px 26px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.video-artifact {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.video-artifact summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  font-weight: 680;
}

.video-artifact summary small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
}

.artifact-body {
  border-top: 1px solid var(--line);
  background: #fff;
}

.artifact-view-switch {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 9px 12px 0;
}

.artifact-view-switch button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.artifact-view-switch button.active {
  border-color: var(--line);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

.artifact-readable-view {
  padding: 2px 14px 18px;
}

.artifact-readable {
  display: grid;
  gap: 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.artifact-readable.markdown-viewer {
  height: auto;
  padding: 10px 4px 16px;
  overflow: visible;
  font-size: 14px;
}

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

.artifact-fact {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.artifact-fact dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.artifact-fact dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.artifact-fact a,
.artifact-record a {
  color: var(--accent);
  text-decoration: none;
}

.artifact-fact a:hover,
.artifact-record a:hover {
  text-decoration: underline;
}

.artifact-section {
  margin-top: 2px;
}

.artifact-section > h4 {
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.artifact-section.depth-1 > h4,
.artifact-section.depth-2 > h4 {
  border-bottom: 0;
  font-size: 13px;
}

.artifact-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 20px;
}

.artifact-records {
  display: grid;
  gap: 8px;
}

.artifact-record {
  min-width: 0;
  padding: 11px 12px;
  border-left: 3px solid #8fc5b1;
  border-radius: 0 7px 7px 0;
  background: #f7faf8;
}

.artifact-record h5 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
}

.artifact-record .artifact-facts {
  grid-template-columns: 1fr;
}

.artifact-record .artifact-fact {
  padding: 7px 9px;
  background: #fff;
}

.artifact-empty-value {
  color: var(--muted);
}

.artifact-boolean {
  display: inline-flex;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 650;
}

.artifact-boolean.no {
  color: var(--muted);
  background: #edf0ee;
}

.artifact-raw-view,
.artifact-text-view {
  max-height: 420px;
  margin: 0;
  padding: 12px 14px 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #2e3b34;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

@media (max-width: 760px) {
  .artifact-facts {
    grid-template-columns: 1fr;
  }
}

.delivery-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
}

.video-preview {
  width: calc(100% - 28px);
  max-height: 360px;
  margin: 0 14px 14px;
  border-radius: 7px;
  background: #111;
}

.video-review-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.video-review-input {
  min-height: 150px;
}

.video-diagnostics {
  display: grid;
  gap: 10px;
  min-width: 0;
}

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

.video-quick-actions .secondary-button {
  width: 100%;
}

.video-diagnostic-block {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.video-diagnostic-block.failed {
  border-color: #e2b07c;
  background: #fff8ed;
}

.video-diagnostic-block.muted {
  color: var(--muted);
}

.video-diagnostic-block h4,
.video-diagnostic-head h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.video-diagnostic-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.video-diagnostic-head small {
  color: var(--muted);
  font-size: 11px;
}

.video-diagnostic-facts {
  display: grid;
  gap: 9px;
  margin: 0;
}

.video-diagnostic-facts dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.video-diagnostic-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.video-log-detail {
  min-width: 0;
}

.video-log-detail summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.video-log-detail pre {
  max-height: 280px;
  margin: 9px 0 0;
  padding: 10px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #2e3b34;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
}

.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.action-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-width: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

#chatTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-model-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.input.knowledge-mode-select {
  width: 126px;
  min-width: 126px;
  color: var(--muted);
  font-size: 13px;
}

.input.model-select {
  width: 178px;
  min-width: 178px;
  flex: 0 0 178px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(248, 250, 248, 0.95), rgba(248, 250, 248, 0.86)),
    #fbfcfa;
  scrollbar-gutter: stable;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(78%, 760px);
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message.pending {
  opacity: 0.72;
}

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

.message.user .message-meta {
  text-align: right;
}

.message-bubble {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.72;
  word-break: break-word;
  background: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.message-bubble.markdown-viewer {
  height: auto;
  max-height: none;
  min-height: 0;
  padding: 13px 15px;
  overflow: visible;
  font-size: 14px;
  line-height: 1.7;
}

.message-bubble.markdown-viewer h1 {
  padding-bottom: 6px;
  font-size: 20px;
}

.message-bubble.markdown-viewer h2 {
  font-size: 17px;
}

.message-bubble.markdown-viewer h3 {
  font-size: 15px;
}

.message-bubble.markdown-viewer p,
.message-bubble.markdown-viewer ul,
.message-bubble.markdown-viewer ol,
.message-bubble.markdown-viewer blockquote,
.message-bubble.markdown-viewer pre,
.message-bubble.markdown-viewer table {
  margin: 0.55em 0;
}

.message-bubble.markdown-viewer > :first-child {
  margin-top: 0;
}

.message-bubble.markdown-viewer > :last-child {
  margin-bottom: 0;
}

.message.user .message-bubble {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.message.user .message-bubble.markdown-viewer,
.message.user .message-bubble.markdown-viewer h1,
.message.user .message-bubble.markdown-viewer h2,
.message.user .message-bubble.markdown-viewer h3,
.message.user .message-bubble.markdown-viewer h4,
.message.user .message-bubble.markdown-viewer a {
  color: #fff;
}

.message.user .message-bubble.markdown-viewer h1 {
  border-bottom-color: rgba(255, 255, 255, 0.28);
}

.message.user .message-bubble.markdown-viewer code {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.message.user .message-bubble.markdown-viewer pre,
.message.user .message-bubble.markdown-viewer blockquote {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.message.pending.assistant .message-bubble {
  color: var(--muted);
  background: #f2f6f3;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 86px;
  max-height: 180px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  line-height: 1.55;
  color: var(--text);
  background: var(--panel-soft);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

#modelHint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.detail-text {
  color: var(--muted);
  line-height: 1.65;
}

.prompt-panel,
.material-panel,
.asset-panel,
.progress-panel,
.stage-control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.stage-rollback-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.rollback-button {
  border-color: rgba(173, 101, 40, 0.4);
  color: #8a4f1c;
  background: #fff8ed;
}

.rollback-button:hover,
.rollback-button:focus-visible {
  border-color: rgba(173, 101, 40, 0.72);
  color: #713b12;
  background: #fff2dd;
}

.prompt-panel {
  padding: 12px 16px 16px;
  background: #fff;
}

.progress-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-height: inherit;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
}

.progress-panel.complete {
  background: #f5faf7;
}

.progress-panel.failed {
  background: #fff8f7;
  border-color: rgba(154, 58, 54, 0.28);
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.progress-title-group {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.progress-title-group strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#progressElapsed {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-collapse-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 18px;
  line-height: 1;
}

.progress-collapse-button:hover {
  color: var(--accent);
  border-color: rgba(33, 116, 92, 0.32);
  background: var(--accent-soft);
}

.progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ece7;
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 28%;
  border-radius: inherit;
  background: var(--accent);
  animation: progressPulse 1.3s ease-in-out infinite;
}

.progress-panel.complete .progress-track span {
  width: 100%;
  animation: none;
}

.progress-panel.failed .progress-track span {
  width: 100%;
  background: var(--danger);
  animation: none;
}

.progress-events {
  display: grid;
  gap: 6px;
  max-height: min(160px, calc(100vh - 300px));
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.progress-event {
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.progress-event-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 11px;
}

.progress-event-message {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.progress-event.output .progress-event-message {
  color: var(--accent-strong);
}

.progress-event.error .progress-event-message {
  color: var(--danger);
}

@keyframes progressPulse {
  0% {
    transform: translateX(-90%);
  }
  50% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(340%);
  }
}

.material-panel,
.asset-panel {
  min-height: 0;
  padding: 18px;
  border-top: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.material-panel {
  align-content: start;
}

.asset-panel {
  align-content: start;
  gap: 14px;
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  height: 100%;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.workspace.settings-mode .settings-panel {
  padding: 22px;
}

.settings-section {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.settings-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.settings-back-button {
  width: 34px;
  height: 34px;
  font-size: 24px;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.settings-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-menu-card {
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.settings-menu-card strong {
  font-size: 18px;
}

.settings-menu-card span {
  color: var(--muted);
  line-height: 1.55;
}

.settings-menu-card:hover {
  border-color: rgba(33, 116, 92, 0.42);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 14px;
}

.model-settings-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  align-items: start;
}

.default-model-block {
  min-height: 170px;
}

.other-settings-grid .style-settings-block {
  grid-column: 1 / -1;
}

.settings-block {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.style-settings-block {
  grid-column: span 1;
}

.library-settings-block,
.knowledge-settings-block {
  grid-column: 1 / -1;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-note {
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.web-provider-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.web-provider-settings-block .provider-grid {
  grid-template-columns: 1fr;
}

.provider-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.provider-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.provider-card-head strong,
.provider-card-head p {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-card-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 720;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  outline: none;
}

.input {
  height: 40px;
  padding: 0 12px;
}

.textarea {
  min-height: 126px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.55;
}

.textarea.small {
  min-height: 118px;
}

.textarea.mini {
  min-height: 70px;
}

#promptText {
  width: 100%;
  min-height: 190px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-soft);
  line-height: 1.55;
}

.inline-form {
  gap: 8px;
}

.inline-form .input {
  flex: 1;
  min-width: 0;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border: 1px dashed #9baea2;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-soft);
  cursor: pointer;
}

.drop-zone input {
  display: none;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 184px));
  gap: 14px;
  justify-content: start;
  min-height: 28px;
  align-items: start;
}

.asset-list.compact {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

/* XHS cards are portrait assets. Keep every generated image in its own grid cell
   so long filenames never float over the following card. */
.xhs-asset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: start;
}

.xhs-asset-grid .asset-card {
  display: grid;
  grid-template-rows: auto minmax(38px, auto);
  flex: 0 0 calc((100% - 12px) / 2);
  max-width: calc((100% - 12px) / 2);
  min-width: 0;
}

.asset-list.compact.xhs-asset-grid .asset-card img {
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.xhs-asset-grid .asset-card span {
  position: static;
  min-width: 0;
  overflow: hidden;
  padding: 8px 9px;
  border-radius: 0;
  color: var(--ink);
  background: #f6f9f7;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: normal;
}

.asset-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.asset-chip.empty {
  grid-column: 1 / -1;
  min-height: 120px;
}

.asset-card {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f9f7;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #edf3ee;
}

.asset-list.compact .asset-card img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.asset-card span {
  display: block;
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  background: rgba(18, 30, 24, 0.62);
  font-size: 12px;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.editor-panel > .tabs,
.editor-panel > .editor-head,
.editor-panel > .markdown-viewer,
.editor-panel > .file-editor {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  padding: 12px 12px 0;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.tab {
  flex: 0 0 auto;
  height: 34px;
  max-width: 150px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  background: #f6f8f6;
  font-size: 13px;
}

.tab.active {
  color: var(--text);
  background: #fff;
  border-bottom-color: #fff;
}

.tab.ready::after {
  content: " 已填";
  color: var(--accent);
  font-size: 11px;
}

.editor-head {
  padding: 13px 16px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.file-mode-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f8f6;
}

.file-mode-button {
  height: 28px;
  min-width: 48px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.file-mode-button.active {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-soft);
}

.file-mode-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.file-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  border: 0;
  resize: none;
  outline: none;
  line-height: 1.68;
  color: var(--text);
  background: #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

.markdown-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 22px 28px 48px;
  overflow: auto;
  color: var(--text);
  background: #fff;
  line-height: 1.75;
  font-size: 15px;
}

.markdown-viewer > :first-child {
  margin-top: 0;
}

.markdown-viewer h1,
.markdown-viewer h2,
.markdown-viewer h3,
.markdown-viewer h4 {
  margin: 1.15em 0 0.55em;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: 0;
}

.markdown-viewer h1 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 24px;
}

.markdown-viewer h2 {
  font-size: 19px;
}

.markdown-viewer h3 {
  font-size: 16px;
}

.markdown-viewer p,
.markdown-viewer ul,
.markdown-viewer ol,
.markdown-viewer blockquote,
.markdown-viewer pre,
.markdown-viewer table {
  margin: 0.85em 0;
}

.markdown-viewer ul,
.markdown-viewer ol {
  padding-left: 1.45em;
}

.markdown-viewer li + li {
  margin-top: 0.28em;
}

.markdown-viewer code {
  padding: 2px 5px;
  border-radius: 5px;
  color: #1d4f42;
  background: #eef5f1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-viewer pre {
  overflow: auto;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f8f6;
}

.markdown-viewer pre code {
  padding: 0;
  background: transparent;
}

.markdown-viewer blockquote {
  padding: 1px 0 1px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

.markdown-viewer table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-viewer th,
.markdown-viewer td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown-viewer th {
  background: var(--panel-soft);
}

.markdown-viewer a {
  color: var(--accent-strong);
}

.markdown-viewer img {
  max-width: 100%;
  border-radius: var(--radius);
}

dialog {
  width: min(680px, calc(100vw - 48px));
  max-height: min(880px, calc(100vh - 48px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: auto;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(24, 33, 29, 0.34);
}

.dialog-body {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.dialog-body label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-body label .input,
.dialog-body label .textarea {
  color: var(--text);
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #223229;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1380px) {
  body {
    min-width: 1040px;
  }

  .app-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .toolbar .secondary-button {
    padding: 0 12px;
  }

  .delivery-grid {
    grid-template-columns: repeat(2, minmax(230px, 1fr));
  }

  .video-create-grid {
    grid-template-columns: repeat(2, minmax(210px, 1fr));
  }
}

@media (max-width: 1120px) {
  body {
    min-width: 0;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

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

  .project-list {
    max-height: 260px;
  }

  .workspace {
    min-height: 100vh;
    overflow: visible;
  }

  .topbar,
  .toolbar {
    flex-wrap: wrap;
  }

  .work-view,
  .materials-view {
    grid-template-columns: 1fr;
  }

  .delivery-grid,
  .video-create-grid,
  .video-studio-grid,
  .xhs-studio-grid,
  .xhs-comfy-config {
    grid-template-columns: 1fr;
  }

  .comfy-config-actions {
    justify-content: flex-start;
  }

  .delivery-run-row {
    grid-template-columns: 1fr;
  }

  .delivery-center-home,
  .video-studio,
  .xhs-studio {
    height: auto;
    min-height: 720px;
    overflow: visible;
  }

  .video-studio-grid,
  .xhs-studio-grid {
    overflow: visible;
  }

  .video-artifact-panel,
  .video-review-panel {
    min-height: 420px;
  }

  .video-studio-head {
    grid-template-columns: 1fr;
  }

  .video-studio-head .delivery-actions {
    justify-content: flex-start;
  }

  .nav-stage-row {
    width: 100%;
  }

  .right-rail {
    top: 96px;
    right: 14px;
    width: min(360px, calc(100vw - 28px));
    max-height: calc(100vh - 120px);
  }

  .chat-panel {
    min-height: 620px;
  }

  .chat-model-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .editor-panel {
    min-height: 520px;
  }
}
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background: radial-gradient(circle at top, #f3f0e8, #e8e3d8 60%, #ddd6ca);
}

.auth-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid rgba(82, 70, 52, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(55, 45, 32, 0.16);
}

.auth-brand {
  margin-bottom: 26px;
}

.auth-brand h1 {
  margin: 5px 0 8px;
}

.auth-brand p,
.form-note {
  color: var(--muted, #6f6a62);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label,
.admin-invite-section label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.account-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.account-dialog::backdrop {
  background: rgba(25, 22, 18, 0.48);
  backdrop-filter: blur(3px);
}

.account-dialog > * {
  margin-left: 24px;
  margin-right: 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 22px;
}

.admin-invite-section {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 18px;
  border-radius: 14px;
  background: #f5f2eb;
}

.invite-result textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
}

.account-dialog #logoutButton {
  margin-top: 22px;
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}
