/* AI 创作平台 —— 全局样式 */
:root {
  --brand: #6c5ce7;
  --brand-2: #a29bfe;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #8a90a2;
  --border: #e6e8f0;
  --ok: #10b981;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
}

/* ── 导航 ───────────────────────────────── */
.app-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(20, 20, 40, .04);
}
.app-nav .navbar-brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-dot {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: inline-block;
}
.app-nav .nav-link { color: #5a6072; font-size: 14px; padding: .5rem .8rem; border-radius: 8px; }
.app-nav .nav-link:hover { color: var(--brand); background: #f2f1fe; }
.app-nav .nav-link.active { color: var(--brand); font-weight: 600; background: #f2f1fe; }
.admin-link { color: #e07a5f !important; }

.credit-chip {
  background: linear-gradient(135deg, #fff5e0, #ffe9c7);
  color: #a86b00;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

/* ── 卡片 / 面板 ───────────────────────── */
.panel-card { border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 2px 10px rgba(20,20,40,.04); background: var(--card); }
.panel-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── 模式选择 ───────────────────────────── */
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mode-btn {
  border: 1.5px solid var(--border); background: #fff; border-radius: 10px;
  padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; color: #6b7182; cursor: pointer; transition: all .15s;
}
.mode-btn i { font-size: 17px; }
.mode-btn:hover { border-color: var(--brand-2); color: var(--brand); }
.mode-btn.active { border-color: var(--brand); background: #f4f3ff; color: var(--brand); font-weight: 600; }

/* ── 表单 ───────────────────────────────── */
.form-control, .form-select { border-radius: 9px; border-color: var(--border); font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(108,92,231,.12); }
.form-label { font-size: 13px; color: #5a6072; }

.cost-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: #f8f8fc; border-radius: 9px; font-size: 13px; color: var(--muted);
}
.cost-row strong { color: var(--brand); font-size: 15px; }

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #5a4bd0; border-color: #5a4bd0; }

/* ── 参考图 ─────────────────────────────── */
.ref-preview { position: relative; margin-bottom: 8px; }
.ref-preview img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #fafaff; }
.ref-clear { position: absolute; top: 6px; right: 6px; }

/* ── 结果网格 ───────────────────────────── */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; min-height: 260px; }
.result-item {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff;
  position: relative; transition: transform .15s, box-shadow .15s;
}
.result-item:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20,20,40,.09); }
.result-item img, .result-item video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #101322; }
.result-item .meta { padding: 8px 10px; font-size: 11.5px; color: var(--muted); }
.result-item .meta .t { color: var(--text); font-weight: 600; font-size: 12px; }
.result-item .bar {
  position: absolute; inset: 0; background: rgba(16,19,34,.72); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-size: 13px;
}
.result-item .acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.result-item:hover .acts { opacity: 1; }
.result-item .acts a, .result-item .acts button {
  background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 7px; padding: 4px 8px; font-size: 12px; text-decoration: none;
}
.empty-state { grid-column: 1/-1; text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state i { font-size: 42px; opacity: .35; display: block; margin-bottom: 12px; }

/* ── 表格 ───────────────────────────────── */
.table { font-size: 13.5px; }
.table thead th { background: #fafaff; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.table td { vertical-align: middle; }
.badge-soft { background: #f2f1fe; color: var(--brand); font-weight: 600; }
.badge-ok { background: #e7f8f1; color: #0a8f63; font-weight: 600; }
.badge-fail { background: #fdecec; color: #c53030; font-weight: 600; }
.badge-run { background: #fff4e0; color: #b45309; font-weight: 600; }
.badge-gray { background: #f1f2f6; color: #6b7182; font-weight: 600; }

/* ── 登录 / 注册 ────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #eceafe 0%, #f5f6fa 45%, #e8f4ff 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(30,30,60,.09); }
.auth-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-card .btn { width: 100%; padding: 10px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ── 落地页 ─────────────────────────────── */
.landing-hero { text-align: center; padding: 60px 20px 40px; }
.landing-hero h1 { font-size: 38px; font-weight: 800; letter-spacing: -.02em; }
.landing-hero .lead { color: var(--muted); font-size: 16px; max-width: 620px; margin: 14px auto 26px; }
.feature-card { border: 1px solid var(--border); border-radius: 14px; padding: 20px; height: 100%; background: #fff; }
.feature-card i { font-size: 24px; color: var(--brand); }
.feature-card h5 { font-size: 15px; font-weight: 700; margin: 10px 0 6px; }
.feature-card p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.7; }

/* ── 画布 ───────────────────────────────── */
.canvas-shell { position: relative; height: calc(100vh - 190px); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fbfbfe; }
/* 🔴 工具栏在画布【外部】（静态条）—— 之前浮在画布上会盖住节点标题栏 */
.canvas-toolbar { display: flex; gap: 8px; background: #fff; padding: 8px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.canvas-toolbar .btn { font-size: 13px; }
/* 🔴 属性面板要能滚动：父容器 .canvas-shell 是 overflow:hidden，
   面板内容一多就被裁掉且滚不动 → 「配置选项无法滑动」。 */
.node-palette {
  position: absolute; top: 12px; right: 12px; z-index: 10; background: #fff;
  border-radius: 12px; box-shadow: 0 4px 16px rgba(20,20,40,.1);
  padding: 12px; width: 210px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* 滚动条可见一点，避免用户以为不能滚 */
.node-palette::-webkit-scrollbar { width: 8px; }
.node-palette::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.node-palette::-webkit-scrollbar-track { background: transparent; }
/* 表单控件不要超出面板宽度 */
.node-palette input, .node-palette select, .node-palette textarea { max-width: 100%; box-sizing: border-box; }
.node-palette h6 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.palette-item { border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; cursor: grab; background: #fff; }
.palette-item:hover { border-color: var(--brand); color: var(--brand); }
#stage { display: block; width: 100%; height: 100%; cursor: crosshair; }
.canvas-list-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: #fff; display: flex; justify-content: space-between; align-items: center; }

/* ── 模型配置表单 ───────────────────────── */
/* 标签 / 控件 / 说明 三栏网格，textarea 用顶部对齐避免与标签错位 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  align-items: start;
}
.form-grid .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-grid .field.span2 { grid-column: 1 / -1; }
.form-grid .field > label {
  font-size: 13px; font-weight: 600; color: #1f2430;
  display: flex; align-items: center; gap: 4px;
}
.form-grid .field > label .req { color: #e17055; }
.form-grid .field > input,
.form-grid .field > select,
.form-grid .field > textarea { width: 100%; }
.form-grid .field > textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.55; }
.form-grid .field > small.hint { display: block; font-size: 12px; line-height: 1.6; color: var(--muted); }
.form-grid .check-row { display: flex; flex-wrap: wrap; gap: 14px; padding-top: 4px; }
.form-grid .check-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; font-weight: 400; }
.form-grid .form-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; border-top: 1px solid var(--border); }
.form-grid .video-only { display: none; }
.form-grid[data-protocol="culclaw_video"] .video-only { display: flex; }
@media (max-width: 900px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .field.span2 { grid-column: auto; }
}

/* ── 管理端 ─────────────────────────────── */
.admin-side { background: #fff; border-right: 1px solid var(--border); min-height: calc(100vh - 58px); padding: 16px 10px; }
.admin-side a { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 9px; color: #5a6072; font-size: 14px; text-decoration: none; margin-bottom: 2px; }
.admin-side a:hover { background: #f4f3ff; color: var(--brand); }
.admin-side a.active { background: #f2f1fe; color: var(--brand); font-weight: 600; }
.admin-side .side-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; padding: 12px 12px 6px; font-weight: 700; }
.stat-card { border: 1px solid var(--border); border-radius: 13px; padding: 15px 16px; background: #fff; height: 100%; }
.stat-card .n { font-size: 25px; font-weight: 800; line-height: 1.2; }
.stat-card .l { font-size: 12.5px; color: var(--muted); }
.stat-card .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; }

.code-block {
  background: #1e2233; color: #d7dbeb; border-radius: 10px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  line-height: 1.65; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto;
}
.cap-chip { display: inline-block; background: #f2f1fe; color: var(--brand); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; margin: 2px 4px 2px 0; font-weight: 600; }
.card-secret { font-family: ui-monospace, monospace; font-size: 12px; }

/* 响应式 */
@media (max-width: 992px) {
  .panel-card.sticky-top { position: static !important; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .landing-hero h1 { font-size: 28px; }
}
