:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #20242a;
  --muted: #69717d;
  --line: #dce1e7;
  --accent: #216b5b;
  --accent-2: #184e44;
  --warning: #8a5a00;
  --warning-bg: #fff5db;
  --shadow: 0 14px 36px rgba(31, 39, 49, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "Segoe UI",
    Arial,
    sans-serif;
}

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

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.status-pill {
  width: 132px;
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid #f0d087;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--warning);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.top-actions {
  display: grid;
  grid-template-columns: repeat(5, 112px) 132px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.nav-link,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.nav-link {
  width: 112px;
  white-space: nowrap;
}

.nav-link.active {
  border-color: #9ac8bd;
  background: #eef7f4;
}

.nav-link:hover,
.secondary-button:hover {
  background: #eef7f4;
}

.secondary-button.muted:disabled {
  cursor: default;
  color: var(--muted);
  background: #f7f8fa;
}

.secondary-button:disabled {
  cursor: default;
  color: var(--muted);
  background: #f7f8fa;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  gap: 18px;
  align-items: start;
}

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

.config-panel {
  padding: 18px;
}

.side-stack {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 16px;
}

.section-block {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.section-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: #ddece8;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.upload-zone {
  display: block;
  margin-bottom: 14px;
  cursor: pointer;
}

.upload-zone.dragging .upload-preview {
  border-color: var(--accent);
  background: #eef8f5;
  box-shadow: 0 0 0 3px rgba(33, 107, 91, 0.12);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-preview {
  display: grid;
  min-height: 190px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #aeb8c3;
  border-radius: 8px;
  background: var(--surface-2);
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.upload-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}

.upload-empty {
  display: grid;
  gap: 6px;
  text-align: center;
  color: var(--muted);
}

.upload-empty strong {
  color: var(--text);
  font-size: 16px;
}

.upload-empty small {
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #3d4650;
  font-size: 13px;
  font-weight: 700;
}

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

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 74px;
  padding: 10px 11px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33, 107, 91, 0.12);
}

.prompt-input-wrap {
  position: relative;
}

.prompt-editor {
  width: 100%;
  min-height: 150px;
  padding: 10px 11px;
  overflow: auto;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  line-height: 1.55;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33, 107, 91, 0.12);
}

.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: #7c8794;
  pointer-events: none;
}

.prompt-mention {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 5px;
  border-radius: 5px;
  background: #eaf3ff;
  color: #1167c4;
  font-weight: 800;
  white-space: nowrap;
}

.mention-menu {
  position: absolute;
  z-index: 20;
  width: min(360px, calc(100vw - 48px));
  max-height: 260px;
  overflow: auto;
  border: 1px solid #c8d5e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(31, 39, 49, 0.16);
}

.mention-option,
.mention-empty {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
}

.mention-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  color: var(--text);
  cursor: pointer;
}

.mention-option:hover,
.mention-option.active {
  background: #eef8f5;
}

.mention-option img {
  width: 42px;
  height: 42px;
  border: 1px solid #d7dee6;
  border-radius: 6px;
  object-fit: cover;
}

.mention-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.mention-label {
  color: #1167c4;
  font-size: 13px;
  font-weight: 900;
}

.mention-name {
  overflow: hidden;
  color: #3d4650;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-status {
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f8f6;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.mention-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.binding-copy {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #d7e8e3;
  border-radius: 7px;
  background: #f1f8f6;
  color: #38544d;
  font-size: 13px;
  line-height: 1.45;
}

.asset-status {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #f7f8fa;
  color: #3b4652;
}

.asset-status strong {
  font-size: 13px;
}

.asset-status span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.asset-status.preparing {
  border-color: #b8d6ee;
  background: #f0f7fd;
}

.asset-status.ready {
  border-color: #c8e1d8;
  background: #f1f8f6;
}

.asset-status.configNeeded,
.asset-status.attention {
  border-color: #f0d087;
  background: #fffaf0;
}

.workflow-tips {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d7e8e3;
  border-radius: 7px;
  background: #f1f8f6;
  color: #38544d;
}

.workflow-tips strong {
  font-size: 13px;
}

.workflow-tips span {
  color: #47645d;
  font-size: 12px;
  line-height: 1.45;
}

.asset-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}

.asset-list-header > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-list-header strong {
  font-size: 14px;
}

.asset-list-header span {
  color: var(--muted);
  font-size: 12px;
}

.asset-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.asset-list-empty {
  padding: 12px;
  border: 1px dashed #cfd6df;
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.asset-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #fff;
}

.asset-thumb {
  width: 88px;
  height: 88px;
  overflow: hidden;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #f7f8fa;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-thumb-empty {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

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

.asset-title-row,
.asset-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-title-row {
  justify-content: space-between;
}

.asset-title {
  min-width: 0;
  overflow: hidden;
  color: #28323d;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0f7fd;
  color: #245f87;
  font-size: 12px;
  font-weight: 800;
}

.asset-badge.ready {
  background: #f1f8f6;
  color: var(--accent-2);
}

.asset-badge.attention,
.asset-badge.configNeeded {
  background: #fff5db;
  color: var(--warning);
}

.asset-role-select {
  width: min(180px, 100%);
  height: 34px;
}

.asset-mention {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #b8d8d0;
  border-radius: 7px;
  background: #eef8f5;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.asset-mention:hover {
  background: #ddece8;
}

.asset-id-copy {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family:
    Consolas,
    "Courier New",
    monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-remove {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: #3d4650;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.asset-remove:hover {
  background: #f7f8fa;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 68px;
  padding: 12px;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #fff;
}

.toggle-row.exception {
  background: #fffaf0;
  border-color: #f0d087;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.toggle-row span {
  display: grid;
  gap: 4px;
}

.toggle-row strong {
  font-size: 14px;
}

.toggle-row small,
.note-field p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.advanced-fields {
  align-items: start;
}

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

.option-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.option-button {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: #2d343c;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.option-button:hover {
  border-color: #8da299;
}

.option-button.active {
  border-color: var(--accent);
  background: #e3f1ed;
  color: var(--accent-2);
  font-weight: 800;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: #eef7f4;
}

.prompt-panel textarea {
  display: block;
  width: calc(100% - 32px);
  min-height: 360px;
  margin: 16px;
  border-color: #d7dee6;
  background: #fbfcfd;
  font-family:
    "Segoe UI",
    Arial,
    sans-serif;
  font-size: 14px;
}

.request-panel pre {
  width: calc(100% - 32px);
  max-height: 320px;
  min-height: 220px;
  margin: 16px;
  padding: 12px;
  overflow: auto;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #fbfcfd;
  color: #26313d;
  font-family:
    Consolas,
    "Courier New",
    monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 12px;
}

.result-panel {
  padding-bottom: 16px;
}

.submit-state {
  display: grid;
  gap: 6px;
  margin: 16px;
  padding: 13px;
  border: 1px solid #f0d087;
  border-radius: 7px;
  background: var(--warning-bg);
  color: #654100;
  line-height: 1.45;
}

.submit-state strong {
  font-size: 14px;
}

.submit-state span {
  font-size: 13px;
}

.primary-button {
  width: calc(100% - 32px);
  height: 44px;
  margin: 0 16px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.primary-button.full {
  width: 100%;
  margin: 0;
}

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

.primary-button:disabled {
  cursor: default;
  background: #97aaa4;
}

.video-result {
  display: grid;
  gap: 10px;
  margin: 12px 16px 0;
}

.video-result video {
  width: 100%;
  border-radius: 7px;
  background: #000;
}

.video-result a,
.video-result p {
  margin: 0;
  color: var(--accent-2);
  font-size: 13px;
  word-break: break-all;
}

.rating-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d7e8e3;
  border-radius: 7px;
  background: #f7fbfa;
}

.rating-panel.compact {
  align-content: start;
}

.rating-panel strong {
  color: #28323d;
  font-size: 13px;
}

.rating-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rating-button {
  display: inline-grid;
  width: 38px;
  height: 34px;
  place-items: center;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: #26313d;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.rating-button:hover,
.rating-button.active {
  border-color: var(--accent);
  background: #eef8f5;
  color: var(--accent-2);
}

.rating-button.bad {
  color: #a93030;
}

.rating-button.bad.active {
  border-color: #d6a5a5;
  background: #fff1f1;
  color: #a11c1c;
}

.rating-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 34, 45, 0.45);
}

.modal-backdrop[hidden] {
  display: none;
}

.library-picker {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(1120px, calc(100vw - 40px));
  max-height: min(860px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(24, 34, 45, 0.22);
}

.library-picker-header,
.library-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.library-picker-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.library-picker-footer > div {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.library-picker-footer span {
  color: var(--muted);
  font-size: 13px;
}

.library-picker-footer .primary-button,
.library-picker-footer .secondary-button {
  width: auto;
  min-width: 116px;
  margin: 0;
}

.library-picker-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 150px auto;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.library-search-field {
  min-width: 0;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: #3d4650;
  font-size: 13px;
  font-weight: 700;
}

.check-field input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.library-picker-meta {
  padding: 10px 16px;
  color: var(--muted);
  font-size: 13px;
}

.library-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 0 16px 16px;
}

.picker-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed #cfd6df;
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.picker-card {
  position: relative;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  min-height: 126px;
  padding: 10px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.picker-card:hover,
.picker-card.selected {
  border-color: var(--accent);
  background: #f1f8f6;
}

.picker-check {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf2f7;
  color: #3f4a56;
  font-size: 12px;
  font-weight: 800;
}

.picker-card.selected .picker-check {
  background: var(--accent);
  color: #fff;
}

.picker-thumb {
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #f7f8fa;
}

.picker-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.picker-main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding-right: 44px;
}

.picker-title,
.picker-asset-url,
.picker-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-title {
  color: #28323d;
  font-size: 13px;
  font-weight: 900;
}

.picker-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.picker-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f6;
  color: #3d4650;
  font-size: 12px;
  font-weight: 800;
}

.picker-asset-url {
  color: var(--muted);
  font-family:
    Consolas,
    "Courier New",
    monospace;
  font-size: 12px;
}

.picker-note {
  color: #66717d;
  font-size: 12px;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.library-panel {
  padding-bottom: 16px;
}

.library-tools,
.library-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.library-grid {
  display: grid;
  gap: 12px;
  padding: 0 16px;
}

.library-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

.library-thumb {
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #f7f8fa;
}

.library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.library-card-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.library-card-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.library-card-title input {
  height: 36px;
  font-weight: 800;
}

.library-card-title span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f8f6;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.library-asset-url,
.library-path {
  overflow: hidden;
  color: var(--muted);
  font-family:
    Consolas,
    "Courier New",
    monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-notes {
  min-height: 54px;
}

.library-card-foot,
.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

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

.library-card-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: #fff;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.library-card-actions button:hover {
  background: #eef7f4;
}

.library-card-actions button.danger {
  border-color: #e3b6b6;
  color: #a93030;
}

.library-card-actions button.danger:hover {
  background: #fff1f1;
}

.library-form-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.history-panel {
  padding-bottom: 16px;
}

.history-tools {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 160px 180px;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

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

.history-list {
  display: grid;
  gap: 14px;
  padding: 0 16px;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  padding: 14px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

.history-card-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.history-card-head {
  display: grid;
  gap: 6px;
}

.history-card-head > div {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.history-card-head strong {
  color: var(--accent-2);
  font-size: 14px;
}

.history-card-head span,
.history-card-head code {
  color: var(--muted);
  font-size: 12px;
}

.history-card-head code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card video {
  width: min(420px, 100%);
  border-radius: 7px;
  background: #000;
}

.history-card a,
.history-local-path {
  margin: 0;
  color: var(--accent-2);
  font-size: 13px;
  word-break: break-all;
}

.history-prompt {
  max-height: 150px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #fbfcfd;
  color: #28323d;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.history-param-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.history-param-grid span {
  min-width: 0;
  overflow: hidden;
  padding: 7px 8px;
  border-radius: 7px;
  background: #f3f6f8;
  color: #3d4650;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-assets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-asset-chip,
.history-empty-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef8f5;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.history-asset-chip small {
  color: var(--muted);
  font-weight: 700;
}

.history-card-side {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
}

.history-actions {
  display: grid;
  gap: 8px;
}

.history-action-button {
  width: 100%;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.62fr);
  gap: 18px;
  align-items: start;
}

.planner-panel {
  padding-bottom: 16px;
}

.planner-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.planner-script {
  min-height: 300px;
}

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

.checkbox-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

.checkbox-card.compact {
  min-height: 86px;
}

.checkbox-card input {
  width: auto;
  margin-top: 3px;
}

.checkbox-card span {
  display: grid;
  gap: 4px;
}

.checkbox-card strong {
  color: var(--text);
  font-size: 13px;
}

.checkbox-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.planner-actions,
.planner-side-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.planner-actions .primary-button,
.planner-side-actions .primary-button {
  width: auto;
  min-width: 180px;
  margin: 0;
}

.planner-markdown {
  min-height: 420px;
  max-height: 620px;
  margin: 16px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #d7dee6;
  border-radius: 7px;
  background: #fbfcfd;
  color: #2d3742;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.planner-side-actions {
  padding: 0 16px 12px;
}

.asset-planner-output {
  margin-top: 18px;
}

.history-meta.compact {
  padding: 0;
}

.visual-asset-list {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.visual-asset-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

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

.visual-asset-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.visual-asset-head strong {
  color: var(--accent-2);
  font-size: 14px;
}

.asset-ratio-badge {
  border: 1px solid #bfd4cc;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--accent-2);
  background: #f0faf7;
  font-size: 12px;
  font-weight: 700;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
}

.visual-asset-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) 150px minmax(180px, 1fr);
  gap: 12px;
}

.visual-asset-grid.strict {
  grid-template-columns: minmax(180px, 1fr) 180px;
}

.asset-reference-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fbfcfd;
}

.asset-reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

.asset-reference-head span {
  color: var(--muted);
  font-weight: 700;
}

.asset-reference-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-list-empty.inline {
  width: auto;
  padding: 6px 0;
}

.video-markdown {
  min-height: 520px;
}

.video-segment-list {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

.video-segment-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

.segment-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.video-segment-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px minmax(220px, 1.2fr);
  gap: 12px;
}

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

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

  .planner-layout,
  .visual-asset-grid,
  .visual-asset-grid.strict,
  .planner-toggles,
  .video-segment-grid,
  .video-fields-grid {
    grid-template-columns: 1fr;
  }

  .library-picker-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-tools,
  .history-card {
    grid-template-columns: 1fr;
  }

  .history-param-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-link,
  .status-pill {
    width: 100%;
    min-width: 0;
  }

  h1 {
    font-size: 24px;
  }

  .config-panel {
    padding: 14px;
  }

  .field-grid,
  .option-grid,
  .option-grid.compact,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .asset-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .asset-thumb {
    width: 72px;
    height: 72px;
  }

  .asset-meta-row {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-role-select,
  .asset-mention,
  .asset-remove {
    width: 100%;
  }

  .asset-list-header {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-list-header .secondary-button {
    width: 100%;
  }

  .upload-preview {
    min-height: 160px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .library-picker {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .library-picker-header,
  .library-picker-footer {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .library-picker-footer > div,
  .library-picker-footer .primary-button,
  .library-picker-footer .secondary-button {
    width: 100%;
  }

  .library-picker-grid {
    grid-template-columns: 1fr;
  }

  .history-tools,
  .history-param-grid {
    grid-template-columns: 1fr;
  }

  .library-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .library-thumb {
    width: 84px;
    height: 84px;
  }

  .library-card-title {
    grid-template-columns: 1fr;
  }
}
