:root {
  --bg: #f5f7fb;
  --panel: #fff;
  --text: #18212f;
  --muted: #6f7b8e;
  --line: #e4e8ef;
  --accent: #6d5dfc;
  --accent-dark: #5142da;
  --danger: #b42626;
  --ok: #247a50;
  --warning: #8f6600;
  --shadow: 0 8px 30px rgba(31, 41, 55, .08);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, summary { touch-action: manipulation; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  padding: 10px 28px;
  background: #161b27;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand { font-size: 18px; font-weight: 800; white-space: nowrap; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 15px; font-size: 14px; }
.top-actions a { color: #dce2ef; }
.top-actions a:hover { color: #fff; }
.user-chip { padding: 8px 12px; border-radius: 999px; background: #2a3142; white-space: nowrap; }

.shell { width: min(1440px, 100%); margin: 0 auto; padding: 24px; }
.page-head { margin: 12px 0 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-head h1 { margin: 0 0 8px; font-size: 28px; }
.page-head p { margin: 0; color: var(--muted); }

.panel {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.project-nav {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.project-nav a, .project-nav strong { padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.project-nav a:hover { background: #f1f3f8; }
.project-nav strong { background: #eeeefe; color: #4437b6; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.project-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); transition: transform .2s, border-color .2s; }
.project-card:hover { border-color: #c8c3ff; transform: translateY(-2px); }
.project-icon { width: 46px; height: 46px; border-radius: 12px; background: #eeeefe; color: #5b4ae2; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.project-card h3 { margin: 20px 0 10px; }
.project-card span { color: var(--accent); font-size: 14px; }

.section-title { margin: 0 0 14px; font-size: 18px; font-weight: 800; }
summary.section-title, details > summary { cursor: pointer; }
.details-form { margin-top: 18px; }

.provider-model-import {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #dcd8ff;
  border-radius: 14px;
  background: #fbfaff;
}
.provider-model-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.provider-model-heading h3 { margin: 0 0 5px; color: var(--text); font-size: 16px; }
.provider-model-heading p, .provider-model-footer p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.provider-model-heading button { flex: 0 0 auto; }
.provider-model-status { margin-top: 14px; padding: 10px 12px; border: 1px solid #dbe0e8; border-radius: 10px; background: #fff; color: #4c596d; font-size: 13px; }
.provider-model-status.success { border-color: #b9e7ce; background: #e8f7ef; color: var(--ok); }
.provider-model-status.warning { border-color: #f0d38c; background: #fff7e3; color: #795500; }
.provider-model-status.error { border-color: #ffc8c8; background: #ffeaea; color: var(--danger); }
.provider-model-form { margin-top: 14px; }
.provider-model-search { margin-bottom: 10px; display: grid; grid-template-columns: max-content minmax(220px, 1fr); align-items: center; gap: 10px; color: var(--text); font-size: 13px; font-weight: 750; }
.provider-model-search input { width: 100%; min-height: 40px; }
.provider-model-toolbar { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.provider-model-toolbar .check { color: var(--text); font-weight: 750; }
.provider-model-count { color: var(--muted); font-size: 12px; }
.provider-model-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 10px; }
.provider-model-option {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
  gap: 11px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.provider-model-option:hover { border-color: #bdb6ff; box-shadow: 0 5px 18px rgba(81, 66, 218, .08); }
.provider-model-option[hidden] { display: none !important; }
.provider-model-option:has(input:checked) { border-color: var(--accent); background: #f7f5ff; box-shadow: 0 0 0 1px var(--accent); }
.provider-model-option.not-importable { border-color: #e0e3e9; background: #f7f8fa; cursor: not-allowed; }
.provider-model-option.not-importable:hover { border-color: #e0e3e9; box-shadow: none; }
.provider-model-option > input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.provider-model-option > input:disabled { cursor: not-allowed; }
.provider-model-option-body { min-width: 0; display: grid; gap: 7px; }
.provider-model-option-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.provider-model-option-title strong { min-width: 0; overflow-wrap: anywhere; color: var(--text); font-size: 14px; }
.provider-model-badges { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.provider-model-id { overflow-wrap: anywhere; color: #5e6879; font-size: 12px; }
.provider-model-price { width: fit-content; padding: 5px 8px; border-radius: 8px; background: #fff4dc; color: #795500; font-size: 12px; font-weight: 800; }
.provider-model-capabilities { display: flex; flex-wrap: wrap; gap: 6px; }
.provider-model-capabilities > span { padding: 4px 7px; border-radius: 999px; background: #f0f2f7; color: #536074; font-size: 11px; font-weight: 650; }
.provider-model-reason { padding: 8px 9px; border-radius: 8px; background: #fff1f1; color: var(--danger); font-size: 12px; line-height: 1.45; }
.provider-model-empty { padding: 22px 12px; border: 1px dashed #cfd4df; border-radius: 10px; background: #fff; color: var(--muted); text-align: center; font-size: 13px; }
.provider-model-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.provider-model-footer button { flex: 0 0 auto; }

.form-grid { display: grid; gap: 14px; align-items: end; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.model-parameter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) repeat(3, minmax(100px, .8fr)) max-content;
  gap: 12px;
  align-items: end;
}
.model-parameter-row .model-generate-button {
  min-width: clamp(180px, 13vw, 260px);
  min-height: 65px;
  padding: 14px 28px;
  font-size: 17px;
  white-space: nowrap;
}
.span2 { grid-column: span 2; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label { display: flex; flex-direction: column; gap: 7px; color: #475467; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid #d6dce6; border-radius: 10px; outline: none; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: #8b80ff; box-shadow: 0 0 0 3px rgba(109, 93, 252, .12); }
input:disabled, select:disabled, textarea:disabled { background: #f1f3f6; color: #8d96a5; cursor: not-allowed; }
textarea { min-height: 320px; resize: vertical; line-height: 1.65; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Microsoft YaHei", monospace; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }

.primary, .secondary, .danger, .btn {
  min-height: 40px;
  padding: 10px 15px;
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: #eef1f6; color: #253044; }
.secondary:hover { background: #e2e6ed; }
.danger { background: #ffeaea; color: var(--danger); }
.danger:hover { background: #ffdddd; }
.primary:disabled, .secondary:disabled, .danger:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.disabled { background: #e7eaf0; color: #7d8797; cursor: not-allowed; pointer-events: none; }
.small { min-height: 32px; padding: 7px 10px; font-size: 12px; }
.big { margin-top: 18px; padding: 14px 26px; font-size: 16px; }
.full { width: 100%; }
.hidden { display: none !important; }

.filterbar, .asset-toolbar { margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.filterbar input, .asset-toolbar input { max-width: 440px; }
.hint, .muted { margin-top: 8px; color: var(--muted); font-size: 12px; }

.flash, .alert { margin: 10px 0 20px; padding: 12px 14px; border: 1px solid transparent; border-radius: 10px; }
.flash ul { margin: 9px 0 0; padding-left: 22px; }
.flash.success { border-color: #b9e7ce; background: #e8f7ef; color: var(--ok); }
.flash.warning { border-color: #f0d38c; background: #fff7e3; color: #795500; }
.flash.error, .alert.error { border-color: #ffc8c8; background: #ffeaea; color: var(--danger); }

.task-toast-region { position: fixed; z-index: 140; top: 82px; right: 28px; width: min(360px, calc(100vw - 32px)); display: grid; gap: 10px; pointer-events: none; }
.modal-task-toast-region { position: absolute; top: 12px; right: 12px; width: min(360px, calc(100% - 24px)); }
.task-toast { padding: 15px 18px; border: 1px solid transparent; border-radius: 12px; color: #fff; font-size: 16px; font-weight: 800; box-shadow: 0 14px 38px rgba(17, 24, 39, .22); opacity: 0; transform: translateY(-10px); transition: opacity .18s ease, transform .18s ease; }
.task-toast.visible { opacity: 1; transform: translateY(0); }
.task-toast.success { border-color: #47a778; background: #247a50; }
.task-toast.failed { border-color: #d66767; background: #b42626; }

.asset-grid, .asset-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.asset-picker-grid { min-height: 180px; max-height: calc(100vh - 270px); padding: 2px; overflow: auto; }
.asset-card, .picker-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.picker-card { position: relative; }
.picker-card { transition: border-color .15s, background .15s; }
.picker-card:hover { border-color: #bdb6ff; }
.picker-card.added:not(.selected) { border-color: #cbd2de; background: #f8f9fb; }
.picker-card.selected { border: 2px solid var(--accent); background: #f5f3ff; }
.picker-selected-badge { position: absolute; z-index: 2; top: 15px; right: 15px; padding: 5px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; box-shadow: 0 3px 10px rgba(81, 66, 218, .28); }
.picker-selected-badge.inactive { background: #e4e8ef; color: #596579; box-shadow: none; }
.picker-media-preview {
  width: 100%;
  height: 150px;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  background: #f0f2f6;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.picker-media-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.audio-preview-button { background: #f2f0ff; }
.picker-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.asset-preview { height: 150px; margin-bottom: 10px; border-radius: 9px; overflow: hidden; background: #f0f2f6; display: flex; align-items: center; justify-content: center; }
.asset-preview-link { width: 100%; height: 100%; display: block; }
.asset-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.audio-preview { height: auto; min-height: 150px; padding: 10px; flex-direction: column; gap: 12px; overflow: visible; }
.audio-preview audio, .picker-card audio { width: 100%; min-width: 0; }
.audio-icon { color: #7b6df5; font-size: 44px; line-height: 1; text-align: center; }
.audio-duration { color: var(--muted); font-size: 12px; font-weight: 700; }
.asset-name { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta { margin: 5px 0 9px; color: var(--muted); font-size: 12px; }
.inline-form { margin: 7px 0; display: flex; gap: 6px; }
.inline-form input { min-width: 110px; padding: 7px 8px; font-size: 12px; }

.selected-wrap { margin: 4px 0 24px; }
.selected-heading { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.selected-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.selected-assets {
  min-height: 150px;
  padding: 12px;
  border: 1px dashed #cfd5e0;
  border-radius: 13px;
  background: #fafbfc;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}
.selected-empty { grid-column: 1 / -1; min-height: 124px; color: var(--muted); display: grid; place-items: center; text-align: center; }
.selected-asset-card { position: relative; min-width: 0; padding: 9px; border: 2px solid #d8dde6; border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(31, 41, 55, .05); cursor: grab; transition: border-color .15s, background .15s, opacity .15s; }
.selected-asset-card.reference-active { border-color: var(--accent); background: #fcfbff; }
.selected-asset-card.reference-inactive { background: #f8f9fb; }
.selected-asset-card:active { cursor: grabbing; }
.selected-reference-badge { margin-bottom: 8px; padding: 5px 8px; border-radius: 999px; background: #e9e6ff; color: #4337b0; display: inline-flex; font-size: 11px; font-weight: 800; }
.selected-reference-badge.inactive { background: #e6e9ef; color: #657084; }
.selected-remove { position: absolute; z-index: 2; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #7a8494; font-size: 18px; line-height: 1; box-shadow: 0 2px 9px rgba(31, 41, 55, .15); cursor: pointer; }
.selected-remove:hover { background: #ffeaea; color: var(--danger); }
.selected-asset-preview { width: 100%; height: 120px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #f0f2f6; display: grid; place-items: center; cursor: zoom-in; }
.selected-asset-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reference-inactive .selected-asset-preview img { opacity: .66; filter: saturate(.65); }
.selected-asset-details { margin-top: 9px; }
.selected-asset-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.asset-dialog {
  width: min(1120px, calc(100vw - 36px));
  max-width: none;
  max-height: calc(100vh - 36px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(17, 24, 39, .28);
}
.asset-dialog::backdrop { background: rgba(17, 24, 39, .58); backdrop-filter: blur(2px); }
.asset-dialog-shell { max-height: calc(100vh - 36px); display: flex; flex-direction: column; }
.asset-dialog-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.asset-dialog-header h2 { margin: 0; font-size: 20px; }
.asset-dialog-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.dialog-close { width: 38px; height: 38px; flex: 0 0 38px; padding: 0; border: 0; border-radius: 10px; background: #eef1f6; color: #394457; font-size: 25px; line-height: 1; cursor: pointer; }
.dialog-close:hover { background: #e2e6ed; }
.asset-dialog-body { min-height: 0; padding: 18px 20px; overflow: hidden; }
.asset-dialog-footer { padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.asset-dialog-footer span { color: var(--muted); font-size: 13px; }
.asset-picker-dialog {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  width: min(440px, calc(100vw - 24px));
  height: 100vh;
  max-height: none;
  margin: 0;
  border-radius: 0 18px 18px 0;
}
.asset-picker-dialog .asset-dialog-shell { height: 100vh; max-height: none; }
.asset-picker-dialog .asset-dialog-body { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.asset-picker-dialog .asset-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.asset-picker-dialog .asset-toolbar select { grid-column: 1 / -1; }
.asset-picker-dialog .asset-toolbar input { max-width: none; }
.asset-picker-dialog .asset-picker-grid { min-height: 0; max-height: none; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
body.asset-picker-open { overflow-x: hidden; }
body.asset-picker-open .shell { width: calc(100% - 440px); max-width: none; margin-right: 0; margin-left: 440px; padding-left: 16px; }
body.asset-picker-open .workbench-layout { width: 100%; margin-left: 0; transform: none; grid-template-columns: 1fr; }
body.asset-picker-open .recent-video-panel { position: static; height: auto; min-height: 620px; }
body.asset-picker-open .recent-video-list,
body.asset-picker-open .recent-active-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.asset-preview-dialog { width: min(920px, calc(100vw - 36px)); }
.asset-preview-body { min-height: min(320px, calc(100vh - 180px)); padding: 20px; overflow: auto; background: #f3f5f8; display: grid; place-items: center; }
.asset-preview-body img { max-width: 100%; max-height: calc(100vh - 210px); border-radius: 10px; object-fit: contain; box-shadow: 0 10px 36px rgba(17, 24, 39, .16); }
.asset-preview-body audio { width: min(680px, 100%); }
.preview-footer { justify-content: flex-end; }

.prompt-editor { width: 100%; margin: 6px 0 28px; }
.prompt-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.prompt-heading .section-title { margin-bottom: 8px; }
.prompt-actions { display: flex; align-items: center; gap: 8px; }
.prompt-textarea-wrap { position: relative; }
.prompt-editor textarea { width: 100%; min-height: 440px; padding: 18px; font-size: 17px; line-height: 1.8; }
.prompt-meta { padding: 10px 2px 4px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.prompt-meta b { color: #3e32bd; }
.mention-menu {
  position: absolute;
  z-index: 12;
  top: 12px;
  left: 12px;
  width: min(430px, calc(100% - 24px));
  max-height: 260px;
  padding: 7px;
  border: 1px solid #ccc6ff;
  border-radius: 12px;
  overflow-y: auto;
  background: #fff;
  box-shadow: 0 14px 40px rgba(31, 41, 55, .18);
}
.mention-option { width: 100%; padding: 10px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left; cursor: pointer; }
.mention-option:hover, .mention-option.active { background: #eeeefe; color: #4337b0; }
.mention-option span { color: var(--muted); font-size: 12px; }
.mention-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }
.prompt-editor:fullscreen { padding: 24px; overflow: auto; background: var(--bg); }
.prompt-editor:fullscreen textarea { height: calc(100vh - 110px); min-height: 0; resize: none; }

.workbench-layout {
  width: min(1760px, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(450px, 35vw, 620px);
  gap: 20px;
  align-items: start;
}
.recent-video-panel {
  position: sticky;
  top: 84px;
  height: clamp(620px, calc(100vh - 140px), 780px);
  overflow-y: auto;
}
.recent-video-heading { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.recent-video-heading .section-title { margin-bottom: 4px; }
.recent-video-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.recent-video-heading a { color: var(--accent); font-size: 12px; white-space: nowrap; }
.recent-active-section { margin-bottom: 18px; }
.recent-section-label { margin: 10px 0 9px; color: #4a5568; font-size: 12px; font-weight: 800; }
.recent-active-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; align-items: start; gap: 12px; }
.recent-task-item { min-width: 0; padding: 12px; border: 1px solid #d7d2ff; border-radius: 14px; background: linear-gradient(145deg, #fff 25%, #f7f5ff); box-shadow: 0 5px 18px rgba(67, 55, 176, .07); }
.recent-task-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.recent-task-heading .recent-video-name { margin-top: 0; }
.recent-task-heading .status { flex: 0 0 auto; }
.recent-video-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; align-items: start; gap: 16px; }
.recent-video-item { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 5px 18px rgba(31, 41, 55, .055); transition: border-color .18s, box-shadow .18s, transform .18s; }
.recent-video-item:hover { border-color: #c8c3ff; box-shadow: 0 9px 24px rgba(31, 41, 55, .09); transform: translateY(-1px); }
.recent-video-item video { width: 100%; border-radius: 9px; aspect-ratio: 16 / 9; background: #000; display: block; }
.video-load-error { margin-top: 8px; padding: 8px 9px; border-radius: 8px; background: #ffeaea; color: var(--danger); font-size: 12px; }
.video-expired-placeholder { width: 100%; min-height: 120px; border-radius: 9px; aspect-ratio: 16 / 9; background: #edf0f5; color: #717b8c; display: grid; place-items: center; font-size: 15px; font-weight: 800; text-align: center; }
.recent-video-name { min-width: 0; margin: 12px 0 10px; display: grid; gap: 4px; }
.recent-video-name span { color: var(--muted); font-size: 11px; font-weight: 700; }
.recent-video-name strong { overflow: hidden; color: var(--text); font-size: 15px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.recent-video-meta { margin: 0 0 12px; padding: 9px 10px; border-radius: 10px; background: #f7f8fb; display: grid; gap: 7px; font-size: 12px; }
.recent-video-meta div { min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 7px; }
.recent-video-meta dt { color: var(--muted); }
.recent-video-meta dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #303a4b; font-weight: 700; }
.recent-task-progress { margin: 12px 0; display: grid; gap: 7px; }
.recent-task-progress-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.recent-task-progress-label strong { color: #4437b6; font-variant-numeric: tabular-nums; }
.recent-task-progress-track { height: 8px; border-radius: 999px; overflow: hidden; background: #e6e8ef; }
.recent-task-progress-fill { width: var(--task-progress, 0%); height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6d5dfc, #8d82ff); transition: width .25s ease; }
.recent-task-progress-pending { color: var(--muted); font-size: 11px; line-height: 1.45; }
.recent-video-actions { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 8px; }
.recent-video-actions .btn { min-width: 0; min-height: 42px; padding-right: 8px; padding-left: 8px; text-align: center; white-space: normal; }
.empty.compact { grid-column: 1 / -1; min-height: 500px; padding: 20px 8px; display: grid; place-items: center; }
.empty.compact.has-active-tasks { min-height: 120px; }

.pagination { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #fafbfc; color: #647084; white-space: nowrap; }
.task-table { min-width: 1040px; }
.detail-row td, .prompt-row td { padding-top: 4px; background: #fcfcfd; }
.detail-row summary, .prompt-row summary { padding: 7px 0; font-weight: 700; color: #4c43aa; }
.prompt-row h3 { margin: 18px 0 8px; font-size: 14px; }
pre { max-height: 360px; margin: 8px 0; padding: 12px; overflow: auto; border-radius: 10px; background: #f7f8fb; white-space: pre-wrap; word-break: break-word; }
.status { padding: 4px 8px; border-radius: 999px; background: #eef1f6; font-size: 11px; white-space: nowrap; }
.status.success { background: #e8f7ef; color: var(--ok); }
.status.failed { background: #ffeaea; color: var(--danger); }
.status.generating { background: #fff5db; color: var(--warning); }
.error-text { max-width: 280px; margin-top: 6px; color: var(--danger); font-size: 11px; }
.action-row { display: flex; flex-wrap: wrap; gap: 6px; }
.action-row form { margin: 0; }
.live-note { padding: 10px 13px; border-radius: 999px; background: #fff5db; color: var(--warning); font-size: 13px; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #e8a700; display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.asset-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.asset-group { padding: 10px; border-radius: 10px; background: #f7f8fb; }
.asset-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.asset-tag { padding: 5px 8px; border-radius: 999px; background: #eae8ff; color: #493eb1; font-size: 12px; }
.task-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.task-video-card { padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.task-video-card video { width: 100%; margin-bottom: 8px; border-radius: 8px; aspect-ratio: 16 / 9; background: #000; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.video-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.video-card video { width: 100%; border-radius: 9px; aspect-ratio: 16 / 9; background: #000; }
.video-title { margin: 10px 0; overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.video-card-meta { margin: 0 0 12px; display: grid; gap: 6px; font-size: 12px; }
.video-card-meta div { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
.video-card-meta dt { color: var(--muted); }
.video-card-meta dd { margin: 0; overflow-wrap: anywhere; }

.user-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.user-admin-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 11px; }
.user-admin-card h3 { margin: 0; }
.user-admin-card h3 span { color: var(--muted); font-size: 12px; }
.user-admin-card form { display: flex; flex-direction: column; gap: 11px; }
.admin-card { background: #fafbfc; }
.admin-badge { padding: 4px 8px; border-radius: 999px; background: #ece9ff; color: #493eb1; font-size: 11px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.permission-list { max-height: 260px; padding: 10px; overflow: auto; border-radius: 10px; background: #f8f9fc; display: flex; flex-direction: column; gap: 7px; }
.project-rename-form { min-width: 310px; margin: 0; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px; color: var(--muted); text-align: center; }

.consumption-page-head { align-items: center; }
.consumption-admin-note { padding: 7px 11px; border-radius: 999px; background: #ece9ff; color: #493eb1; font-size: 12px; font-weight: 800; white-space: nowrap; }
.consumption-metrics { margin-bottom: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.consumption-metric-card { min-width: 0; min-height: 150px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.consumption-metric-card.today { border-color: #d8d3ff; background: linear-gradient(135deg, #fff 32%, #f2f0ff); }
.consumption-metric-card.month { border-color: #cce7da; background: linear-gradient(135deg, #fff 32%, #edf9f3); }
.consumption-metric-card > span { color: var(--muted); font-size: 13px; font-weight: 750; }
.consumption-metric-card > strong { overflow-wrap: anywhere; font-size: clamp(27px, 3vw, 38px); line-height: 1.1; }
.consumption-metric-card > small { color: var(--muted); line-height: 1.5; }
.consumption-legend { display: flex; flex-wrap: wrap; gap: 7px; }
.billing-badge { width: fit-content; padding: 5px 8px; border-radius: 999px; background: #eef1f6; color: #566173; font-size: 11px; font-weight: 800; white-space: nowrap; }
.billing-badge.actual { background: #e8f7ef; color: var(--ok); }
.billing-badge.estimated { background: #fff5db; color: var(--warning); }
.billing-badge.unbilled { background: #eef1f6; color: #5d6879; }
.consumption-breakdown-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.consumption-breakdown-card { min-width: 0; }
.compact-table-wrap { max-height: 330px; }
.compact-table-wrap table { width: 100%; min-width: 0; }
.amount-cell { color: #332b91; font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.consumption-detail-panel { padding: 0; overflow: hidden; }
.consumption-detail-heading { padding: 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.consumption-detail-heading .section-title { margin-bottom: 6px; }
.consumption-detail-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.consumption-date-filter { display: flex; align-items: flex-end; justify-content: flex-end; gap: 9px; }
.consumption-date-filter label { min-width: 150px; }
.consumption-date-filter .secondary { white-space: nowrap; }
.consumption-detail-panel > .alert { margin: 16px 20px 0; }
.consumption-detail-panel > .table-wrap { padding: 0 20px 20px; }
.consumption-detail-table { min-width: 1120px; }
.consumption-detail-table th { top: 0; }
.date-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.billing-note { min-width: 180px; max-width: 320px; color: var(--muted); line-height: 1.5; }
.consumption-detail-panel > .pagination { margin: 0; padding: 0 20px 20px; }
.model-billing-summary { min-width: 140px; white-space: nowrap; }
.model-billing-summary strong { color: #332b91; }
.model-billing-summary > span:not(.muted) { margin-top: 5px; display: block; color: var(--warning); font-size: 11px; }
.billing-failure-option { grid-column: span 2; align-self: center; line-height: 1.45; }

.login-body { min-height: 100vh; padding: 20px; background: radial-gradient(circle at 20% 20%, #dedaff 0, transparent 38%), #f4f6fb; display: grid; place-items: center; }
.login-card { width: min(420px, 92vw); padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 1250px) {
  .workbench-layout { width: 100%; margin-left: 0; transform: none; grid-template-columns: 1fr; }
  .recent-video-panel { position: static; height: auto; min-height: 620px; }
  .recent-video-list, .recent-active-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 900px) {
  .form-grid.three, .form-grid.four { grid-template-columns: 1fr 1fr; }
  .model-parameter-row { grid-template-columns: 1fr 1fr; }
  .model-parameter-row .model-generate-button { grid-column: 1 / -1; justify-self: start; }
  .recent-video-panel { min-height: 520px; }
  .shell { padding: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .consumption-metrics, .consumption-breakdown-grid { grid-template-columns: 1fr; }
  .consumption-breakdown-grid { gap: 0; }
  .consumption-detail-heading { align-items: stretch; flex-direction: column; }
  .consumption-date-filter { justify-content: flex-start; flex-wrap: wrap; }
}

@media (max-width: 1000px) {
  .asset-picker-dialog { width: 100vw; border-radius: 0; }
  body.asset-picker-open .shell { width: 100%; margin-left: 0; padding-left: 14px; }
}

@media (max-width: 700px) {
  .selected-heading { align-items: stretch; flex-direction: column; }
}

@media (max-width: 600px) {
  .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .model-parameter-row { grid-template-columns: 1fr; }
  .model-parameter-row .model-generate-button { grid-column: auto; justify-self: stretch; }
  .span2 { grid-column: auto; }
  .page-head { flex-direction: column; }
  .filterbar, .asset-toolbar { align-items: stretch; flex-direction: column; }
  .filterbar input, .asset-toolbar input { max-width: none; }
  .topbar { padding: 12px 14px; }
  .shell { padding: 10px; }
  .prompt-heading { align-items: flex-start; }
  .project-rename-form { min-width: 250px; }
  .provider-model-heading, .provider-model-toolbar, .provider-model-footer { align-items: stretch; flex-direction: column; }
  .provider-model-search { grid-template-columns: 1fr; }
  .provider-model-heading button, .provider-model-footer button { width: 100%; }
  .provider-model-list { grid-template-columns: 1fr; }
  .consumption-page-head { align-items: flex-start; }
  .consumption-date-filter { align-items: stretch; flex-direction: column; }
  .consumption-date-filter label { min-width: 0; }
  .consumption-date-filter .primary, .consumption-date-filter .secondary { width: 100%; }
  .billing-failure-option { grid-column: auto; }
}
