/* Seeddance Proxy 前端样式
 * 主色蓝 #2563eb · 白底 · 简约精致直观
 * 不依赖任何外部库
 */

:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --gray-50:  #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;

  --green-50: #ecfdf5;
  --green-600: #059669;
  --red-50:   #fef2f2;
  --red-600:  #dc2626;
  --amber-50: #fffbeb;
  --amber-600:#d97706;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.04), 0 4px 12px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 4px 8px rgb(0 0 0 / 0.06), 0 16px 40px rgb(0 0 0 / 0.10);

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas,
               "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--gray-800);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--gray-100);
  padding: 2px 4px;
  border-radius: 4px;
}
pre {
  padding: 12px 16px;
  overflow-x: auto;
  line-height: 1.5;
  border: 1px solid var(--gray-200);
}

/* ───── topbar ───── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .logo {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--blue-600);
  display: inline-block;
}
.brand .title {
  font-weight: 600;
  font-size: 15px;
  color: var(--gray-900);
}
.brand .subtitle {
  color: var(--gray-500);
  font-size: 13px;
  margin-left: 4px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}
.tab {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-600);
  transition: background 150ms, color 150ms;
}
.tab:hover { background: var(--gray-100); color: var(--gray-800); }
.tab.active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 500;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-indicator {
  font-size: 12px;
  color: var(--gray-500);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-100);
}
.auth-indicator.set {
  color: var(--green-600);
  background: var(--green-50);
}

/* ───── buttons ───── */
.btn {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  color: var(--gray-800);
  padding: 8px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms, border-color 150ms, transform 80ms;
}
.btn:hover { background: var(--gray-200); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}
.btn.primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--gray-600);
}
.btn.ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.btn.danger {
  background: #fff;
  border-color: var(--gray-200);
  color: var(--red-600);
}
.btn.danger:hover { background: var(--red-50); border-color: var(--red-600); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ───── main / panels ───── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px 64px;
}
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}
.card-header-actions { display: flex; gap: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
}
.required { color: var(--red-600); }

.field input[type="text"],
.field input[type="number"],
.field input[type="url"],
.field input[type="password"],
.field select,
.field textarea {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  color: var(--gray-900);
  transition: border-color 150ms, box-shadow 150ms;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.radios, .checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}
.radios label, .checkboxes .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13.5px;
}
.checkboxes .checkbox {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.hint-btn {
  width: 18px;
  height: 18px;
  font-size: 11px;
  border: 1px solid var(--gray-300);
  background: #fff;
  color: var(--gray-500);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.hint-btn:hover {
  background: var(--blue-50);
  color: var(--blue-600);
  border-color: var(--blue-200);
}
.hint-panel {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--blue-50);
  border-left: 3px solid var(--blue-500);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-700);
}
.hint-panel .example {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-600);
  background: #fff;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  word-break: break-all;
}

.json-preview {
  margin-top: 24px;
  border-top: 1px dashed var(--gray-200);
  padding-top: 16px;
}
.json-preview summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  user-select: none;
}
.json-preview summary:hover { color: var(--gray-800); }
.json-preview pre {
  margin-top: 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  font-size: 12.5px;
  max-height: 320px;
  overflow: auto;
}

/* ───── content editor ───── */
.content-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.content-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: start;
}
.content-item-type {
  background: var(--blue-50);
  color: var(--blue-700);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.content-item-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.content-item-fields textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
}
.content-item-fields input { width: 100%; }
/* URL prefix select + input combo */
.url-input-group {
  display: flex; gap: 0; width: 100%;
}
.url-prefix-select {
  flex-shrink: 0; max-width: 100px; font-size: 12px;
  border-radius: 6px 0 0 6px; border-right: none;
  padding: 6px 4px; background: #f1f5f9;
}
.url-input-group input[data-key="url"] {
  border-radius: 0 6px 6px 0; flex: 1; min-width: 0;
}
.content-item-remove {
  background: transparent;
  border: 0;
  color: var(--gray-500);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
}
.content-item-remove:hover { color: var(--red-600); }

.content-add-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ───── task list ───── */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar input[type="text"],
.filter-bar input[type="datetime-local"],
.filter-bar select {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
}
.filter-bar input[type="text"] { flex: 1; max-width: 380px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: 0;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.auto-refresh-indicator {
  font-size: 12px;
  color: var(--blue-600);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pagination-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--gray-500);
}

.task-list {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.task-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) 110px minmax(180px, 1.5fr) 100px 80px 130px 1fr;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
  cursor: pointer;
  transition: background 150ms;
}
.task-row:hover { background: var(--blue-50); }
.task-row:last-child { border-bottom: 0; }
.task-row.head {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: default;
}
.task-row.head:hover { background: var(--gray-50); }

.task-id {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-model {
  font-size: 12.5px;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-time {
  font-size: 12px;
  color: var(--gray-500);
}
.task-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.task-list-empty, .task-list-loading {
  padding: 48px;
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
}

/* ───── status badges ───── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status.queued    { background: var(--blue-50);  color: var(--blue-700); }
.status.running   { background: var(--blue-50);  color: var(--blue-700); }
.status.running::before { animation: pulse 1.4s ease-in-out infinite; }
.status.succeeded { background: var(--green-50); color: var(--green-600); }
.status.failed    { background: var(--red-50);   color: var(--red-600); }
.status.cancelled { background: var(--gray-100); color: var(--gray-600); }
.status.expired   { background: var(--amber-50); color: var(--amber-600); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ───── drawer ───── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 92vw);
  height: 100vh;
  background: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms ease;
}
.drawer:not([hidden]) { transform: translateX(0); }
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  z-index: 99;
}
.drawer-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}
.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.drawer-section {
  margin-bottom: 20px;
}
.drawer-section-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.drawer-kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.drawer-kv dt { color: var(--gray-500); }
.drawer-kv dd { margin: 0; color: var(--gray-800); word-break: break-all; }
.drawer-video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 8px;
}
.drawer-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.drawer-error {
  background: var(--red-50);
  color: var(--red-600);
  border-left: 3px solid var(--red-600);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* Inline error preview next to the failed-status pill in the task list.
   Truncates with ellipsis so the row doesn't blow out; full text on hover
   via the title= attribute. */
.task-error-preview {
  display: inline-block;
  margin-left: 6px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 12px;
  color: var(--red-600);
}

/* ───── modal ───── */
.modal {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  width: 92vw;
  background: #fff;
}
.modal::backdrop { background: rgb(0 0 0 / 0.4); }
.modal-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-content h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-content .muted {
  font-size: 12.5px;
  color: var(--gray-500);
  margin: 0;
}
.modal-content input[type="password"],
.modal-content input[type="text"] {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}
.modal-content input:focus {
  outline: 0;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ───── toast ───── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--gray-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  max-width: 380px;
  animation: toast-in 200ms ease;
}
.toast.error { background: var(--red-600); }
.toast.success { background: var(--green-600); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ───── responsive ───── */
@media (max-width: 880px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; gap: 12px; }
  .brand .subtitle { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: 1; }
  .task-row {
    grid-template-columns: 1fr 90px;
    gap: 8px;
  }
  .task-row > .task-model,
  .task-row > .task-time,
  .task-row.head > * { display: none; }
}

/* ───── SK gate (spec §2.13) ───── */
.sk-gate {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
}
/* The unconditional ``display: flex`` above outranks the browser's
   built-in ``[hidden] { display: none }`` because class selectors beat
   the universal attribute selector. Without this override, the JS does
   ``setAttribute('hidden', '')`` and the overlay never disappears. */
.sk-gate[hidden] { display: none; }
.sk-gate-card {
  background: #fff; border-radius: 12px;
  padding: 32px; min-width: 360px; max-width: 440px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.25);
}
.sk-gate-card h2 { margin: 0 0 8px; }
.sk-gate-card .muted { font-size: 13px; margin: 0 0 16px; color: var(--gray-500); }
.sk-gate-card input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--gray-300); border-radius: 8px;
  margin-bottom: 12px; box-sizing: border-box;
}
.sk-gate-card input:focus {
  outline: none; border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.sk-gate-error {
  background: #fee2e2; color: #b91c1c;
  padding: 8px 12px; border-radius: 6px;
  font-size: 13px; margin-bottom: 12px;
}
.sk-gate-actions { text-align: right; }

/* ───── billing panel ───── */
.billing-summary { font-size: 14px; }
.billing-totals {
  display: flex; gap: 24px; flex-wrap: wrap;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 14px 16px; margin: 16px 0;
}
.billing-totals .stat { min-width: 120px; }
.billing-totals .stat-label { color: var(--gray-500); font-size: 12px; }
.billing-totals .stat-value {
  font-size: 22px; font-weight: 600; color: var(--blue-600);
  font-variant-numeric: tabular-nums;
}
.billing-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.billing-table th, .billing-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--gray-200);
  text-align: left; font-variant-numeric: tabular-nums;
}
.billing-table th {
  font-size: 12px; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.billing-table td.num { text-align: right; }

/* 真人资源（§2.14） */
.asset-toolbar { margin: 12px 0 16px; }
.asset-group-card {
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fff;
}
.asset-group-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.asset-group-title { font-size: 14px; }
.asset-group-actions { display: flex; gap: 8px; }
.asset-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.asset-table th, .asset-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.asset-table th {
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--gray-500, #6b7280);
}
.empty-state { padding: 24px; text-align: center; }

/* H5 验证浮窗 */
.verify-panel {
  position: fixed; top: 80px; right: 24px; z-index: 60;
  max-width: 360px;
}
.verify-card {
  background: #fff;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
.verify-card h3 { margin: 0 0 6px; font-size: 14px; }
.verify-card p { margin: 0 0 12px; font-size: 13px; }
.verify-actions { margin-top: 12px; text-align: right; }

/* 真人验证模态浮窗（带二维码） */
.verify-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.verify-modal {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px 20px;
  width: 100%; max-width: 380px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
  text-align: center;
}
.verify-modal h3 {
  margin: 0 0 6px;
  font-size: 16px; font-weight: 600;
}
.verify-modal p { margin: 0 0 14px; font-size: 13px; }
.verify-close-x {
  position: absolute; top: 10px; right: 14px;
  background: transparent; border: 0;
  font-size: 22px; line-height: 1;
  color: var(--gray-500, #6b7280); cursor: pointer;
  padding: 4px 8px;
}
.verify-close-x:hover { color: #1f2937; }
.verify-qr-wrap {
  display: flex; justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px; margin: 4px 0 14px;
}
.verify-qr {
  /* 让 CSS 完全主导尺寸；segno SVG 的 width/height 属性已在 JS 里剥掉。
     aspect-ratio 1 + auto height 保证小屏（modal 自身被 padding 挤窄）时
     依然是正方形不变形。 */
  width: 100%;
  max-width: 240px;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
}
.verify-status {
  margin: 6px 0 4px; font-size: 13px;
}
.verify-modal .verify-actions {
  margin: 8px 0 4px;
  text-align: center;
}
.verify-hint {
  margin-top: 12px !important;
  font-size: 11px !important;
  color: var(--gray-500, #6b7280);
}

/* 资源选择器（创建任务表单中调用） */
.asset-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.asset-picker button {
  border: 1px solid var(--gray-200, #e5e7eb);
  background: #f8fafc; color: #1f2937;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
  font-size: 12px;
}
.asset-picker button:hover { background: #eff6ff; border-color: #93c5fd; }

/* 资源选择器（spec §2.17） */
.asset-selector-modal {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 18px 24px 16px;
  width: min(720px, 96vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}
.asset-selector-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.asset-selector-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.asset-selector-tags {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px; margin-bottom: 10px;
  font-size: 12px;
}
.asset-selector-tag-label {
  color: var(--gray-500, #6b7280);
}
.asset-selector-tag-sep {
  color: var(--gray-300, #d1d5db);
  padding: 0 4px;
}
.asset-selector-tag {
  border: 1px solid var(--gray-200, #e5e7eb);
  background: #fff; color: #374151;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.asset-selector-tag:hover {
  background: #f1f5f9; border-color: #cbd5e1;
}
.asset-selector-tag.active {
  background: #2563eb; color: #fff;
  border-color: #1d4ed8;
}
.asset-selector-tag[data-tag-kind="type"] {
  /* Structural / read-only — the field that opened the picker locks
     this. Show it greyed-out so users know it's informational. */
  background: #f1f5f9; color: #475569;
  border-style: dashed; cursor: default;
}
.asset-selector-tag[data-tag-kind="type"]:hover {
  background: #f1f5f9; border-color: var(--gray-200, #e5e7eb);
}
#asset-selector-search {
  width: 100%; padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--gray-300, #d1d5db); border-radius: 8px;
  margin-bottom: 12px;
}
#asset-selector-search:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.asset-selector-body {
  display: grid; grid-template-columns: 200px 1fr; gap: 12px;
  flex: 1; min-height: 0;
}
.asset-selector-groups {
  overflow-y: auto;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 8px;
  padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.asset-selector-group {
  background: transparent; border: 0; cursor: pointer;
  text-align: left; padding: 8px 10px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px;
}
.asset-selector-group:hover { background: #f1f5f9; }
.asset-selector-group.active { background: #dbeafe; color: #1e40af; }
.asset-selector-group-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.asset-selector-group-badge {
  display: inline-block; font-size: 10px; line-height: 1;
  padding: 2px 6px; border-radius: 999px; align-self: flex-start;
  font-weight: 600;
}
.asset-selector-group-badge.liveness {
  background: #fef3c7; color: #92400e;
}
.asset-selector-group-badge.aigc {
  background: #dbeafe; color: #1e40af;
}
.asset-selector-grid {
  overflow-y: auto;
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  align-content: start;
}
.asset-thumb {
  position: relative;
  border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px;
  padding: 6px; background: #fff;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}
.asset-thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
  border-color: #93c5fd;
}
.asset-thumb-img, .asset-thumb-placeholder {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 4px; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--gray-500, #6b7280);
}
.asset-thumb-label {
  font-size: 12px; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.asset-thumb-detail {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255, 255, 255, 0.92); border: 1px solid #e5e7eb;
  border-radius: 999px; width: 22px; height: 22px;
  cursor: pointer; font-size: 12px; line-height: 1;
  color: #1e40af;
}
.asset-thumb-detail:hover { background: #dbeafe; }

/* Asset detail modal */
.asset-detail-modal {
  position: relative;
  background: #fff; border-radius: 12px; padding: 24px 28px 20px;
  width: min(640px, 96vw); max-height: 92vh; overflow-y: auto;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}
.asset-detail-modal h3 { margin: 0 0 4px; font-size: 16px; }
.asset-detail-media {
  width: 100%; max-height: 50vh; object-fit: contain;
  border-radius: 8px; background: #0f172a;
}

/* Copy ID button (inline next to <code> in asset tables) */
.btn-copy-id {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  border-radius: 4px; padding: 1px 4px;
  font-size: 14px; line-height: 1; cursor: pointer;
  color: #6b7280; vertical-align: middle; margin-left: 4px;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.btn-copy-id:hover {
  color: #2563eb; border-color: #bfdbfe; background: #eff6ff;
}

/* ─── Themed modal overlay & panel ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.12s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  background: #fff; border-radius: 14px;
  padding: 24px 28px 20px; width: min(440px, 92vw);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.05);
  animation: slideUp 0.15s ease-out;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.modal-panel-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close-btn {
  background: none; border: none; font-size: 22px; line-height: 1;
  color: #94a3b8; cursor: pointer; padding: 2px 6px; border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.modal-close-btn:hover { background: #f1f5f9; color: #334155; }
.modal-form {
  display: flex; flex-direction: column; gap: 10px;
}
.modal-input {
  width: 100%; padding: 8px 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13px; background: #f8fafc;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.modal-input:focus {
  outline: none; border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.modal-divider {
  border: none; border-top: 1px solid #e2e8f0; margin: 6px 0;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

/* ─── Upload progress bar ─── */
.upload-progress-wrap {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
}
.upload-progress-bar {
  flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden;
}
.upload-progress-fill {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 999px; transition: width 0.2s ease;
  width: 0%;
}
.upload-progress-text {
  font-size: 12px; color: #64748b; min-width: 40px; text-align: right;
}

/* ─── Button spinner ─── */
.btn-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Virtual assets warning list */
.virtual-assets-warning {
  margin: 4px 0 12px 18px; padding: 0;
  font-size: 13px; line-height: 1.7;
}
.virtual-assets-warning li { list-style: disc; }

/* ───── SSO login gate ───── */
.sk-gate-login-form {
  margin-bottom: 16px;
}
.sk-gate-login-form input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--gray-300); border-radius: 8px;
  margin-bottom: 8px; box-sizing: border-box;
}
.sk-gate-login-form input:focus {
  outline: none; border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.sk-gate-other-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.sk-gate-other-methods .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  font-size: 13px;
}
.sk-gate-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--gray-400);
  font-size: 12px;
}
.sk-gate-divider::before,
.sk-gate-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ───── User info in topbar ───── */
.user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.user-name {
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───── Token management ───── */
.token-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  background: #fff;
  transition: background 150ms;
}
.token-card:hover {
  background: var(--gray-50);
}
.token-card.token-revoked {
  opacity: 0.6;
  background: var(--gray-50);
}
.token-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.token-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--gray-800);
}
.token-id {
  font-size: 12px;
  color: var(--gray-500);
}
.token-id code {
  font-size: 11px;
}
.token-status {
  margin-left: auto;
}
.token-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.token-actions {
  display: flex;
  gap: 8px;
}

/* Token created modal */
.token-created-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
}
.token-raw-value {
  flex: 1;
  word-break: break-all;
  font-size: 12px;
  background: transparent;
  padding: 0;
}
.asset-key-created-fields { display: flex; flex-direction: column; gap: 4px; }
.asset-key-created-fields label { font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: -8px; }
.asset-key-usage-example pre { font-size: 11px; white-space: pre-wrap; word-break: break-all; background: var(--gray-50); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }

/* ─────────── API 文档面板 ─────────── */

.api-docs-card {
  padding: 0;
  overflow: hidden;
}
.api-docs-card > .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
  gap: 12px;
}

.docs-subtabs {
  display: inline-flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius);
}
.docs-subtab {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 120ms, color 120ms;
}
.docs-subtab:hover { color: var(--gray-800); }
.docs-subtab.active {
  background: #fff;
  color: var(--blue-600);
  box-shadow: var(--shadow-sm);
}

.markdown-body {
  padding: 24px 32px 40px;
  max-width: 900px;
  margin: 0 auto;
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.7;
  overflow-x: hidden;
  word-wrap: break-word;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--gray-900);
  font-weight: 600;
  line-height: 1.3;
  margin: 1.6em 0 0.6em;
  scroll-margin-top: 80px;
}
.markdown-body h1 {
  font-size: 22px;
  margin-top: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.markdown-body h2 {
  font-size: 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-100);
}
.markdown-body h3 { font-size: 16px; }
.markdown-body h4 { font-size: 14px; color: var(--gray-700); }

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0.6em 0 0.9em;
}
.markdown-body ul,
.markdown-body ol { padding-left: 1.4em; }
.markdown-body li { margin: 0.25em 0; }
.markdown-body li > p { margin: 0.35em 0; }

.markdown-body a {
  color: var(--blue-600);
  text-decoration: none;
  word-break: break-all;
}
.markdown-body a:hover {
  text-decoration: underline;
  color: var(--blue-700);
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--gray-100);
  color: var(--gray-800);
  padding: 1px 6px;
  border-radius: 4px;
}
.markdown-body pre {
  background: #f8fafc;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0.8em 0 1.1em;
  font-size: 12.5px;
  line-height: 1.55;
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--gray-800);
  white-space: pre;
}

.markdown-body blockquote {
  margin: 0.8em 0;
  padding: 8px 14px;
  border-left: 3px solid var(--blue-500);
  background: var(--blue-50);
  color: var(--gray-700);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown-body blockquote p { margin: 0.3em 0; }

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--gray-200);
  margin: 1.6em 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0 1.1em;
  font-size: 13px;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
.markdown-body table thead {
  background: var(--gray-50);
}
.markdown-body table th,
.markdown-body table td {
  border: 1px solid var(--gray-200);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}
.markdown-body table th {
  color: var(--gray-800);
  font-weight: 600;
}
.markdown-body table tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.markdown-body strong { color: var(--gray-900); font-weight: 600; }
.markdown-body em { color: var(--gray-700); }

.markdown-fallback {
  padding: 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .markdown-body { padding: 16px; font-size: 13px; }
  .markdown-body h1 { font-size: 19px; }
  .markdown-body h2 { font-size: 16px; }
}
