:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #1d2129;
  --sub: #6b7280;
  --faint: #9aa1ab;
  --brand: #ff2e4d;
  --brand-soft: #fff0f2;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); display: flex;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

/* 侧栏 */
.sidebar {
  width: 220px; flex-shrink: 0; background: #14161a; color: #d1d5db;
  display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; }
.logo {
  width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: #7b818c; margin-top: 2px; }
nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: #b4b9c2; transition: background .15s;
}
nav a:hover { background: #1f2228; color: #fff; }
nav a.active { background: #262a31; color: #fff; }
nav .ico { width: 18px; text-align: center; opacity: .8; }
.badge {
  margin-left: auto; background: var(--brand); color: #fff; font-size: 11px;
  border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.side-foot { margin-top: auto; padding: 16px 18px; font-size: 12px; color: #7b818c; line-height: 1.8; }

/* 主区 */
main { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; }
.page { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }
.page-head .spacer { flex: 1; }
.crumb { color: var(--sub); font-size: 13px; }
.crumb a:hover { color: var(--brand); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.section-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--sub); }
.faint { color: var(--faint); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* 按钮与表单 */
.btn {
  border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #c9cdd4; background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #e8233f; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
label.field > span b { color: var(--brand); font-weight: normal; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--sub); font-size: 13px; }

/* 提取栏 */
.extract-bar textarea { min-height: 64px; font-size: 13px; }
.extract-bar .row { margin-top: 10px; }

/* 平台标签 */
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; flex-wrap: wrap; align-items: center; }
.tab {
  padding: 6px 14px; border-radius: 16px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--text); border-color: var(--text); color: #fff; }
.tab .n { opacity: .6; margin-left: 4px; }

/* 内容卡片网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform .15s, box-shadow .15s; position: relative;
}
.item:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.item .thumb { aspect-ratio: 3/4; background: #eceef1 center/cover no-repeat; position: relative; }
.item .thumb .plat {
  position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.item .thumb .kind { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; }
.item .thumb .rep { position: absolute; bottom: 8px; right: 8px; background: var(--brand); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.item .body { padding: 10px 12px 12px; }
.item .title { font-size: 13px; line-height: 1.45; height: 38px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--sub); }
.item .sel {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.3); z-index: 2; display: none;
}
.selecting .item .sel { display: block; }
.selecting .item .kind { display: none; }
.item.picked { outline: 3px solid var(--brand); outline-offset: -3px; }
.item.picked .sel { background: var(--brand); }
.item.picked .sel::after { content: "✓"; color: #fff; font-size: 12px; display: grid; place-items: center; height: 100%; }
.empty { text-align: center; padding: 70px 20px; color: var(--sub); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .4; }

/* 详情页 */
.detail { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.media-box { background: #000; border-radius: var(--radius); overflow: hidden; }
.media-box video, .media-box img { width: 100%; display: block; max-height: 640px; object-fit: contain; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.stat { text-align: center; background: #f7f8fa; border-radius: 8px; padding: 8px 4px; }
.stat b { display: block; font-size: 15px; }
.stat span { font-size: 11px; color: var(--sub); }
.kv { font-size: 13px; line-height: 2; color: var(--sub); }
.kv b { color: var(--text); font-weight: normal; }
.desc { white-space: pre-wrap; line-height: 1.75; font-size: 13.5px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag { background: var(--brand-soft); color: var(--brand); font-size: 12px; padding: 2px 9px; border-radius: 10px; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.subtab { padding: 10px 16px; cursor: pointer; color: var(--sub); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtab.active { color: var(--text); border-color: var(--brand); font-weight: 500; }
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.frames figure { margin: 0; }
.frames img { width: 100%; border-radius: 6px; display: block; cursor: zoom-in; background: #eee; }
.frames figcaption { font-size: 12px; color: var(--sub); text-align: center; margin-top: 4px; }
.comment { padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; line-height: 1.6; }
.comment .who { color: var(--sub); font-size: 12px; }
.report-list .r { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.report-list .r:hover { border-color: var(--brand); }

/* 报告渲染 */
.md { line-height: 1.8; font-size: 14.5px; max-width: 900px; }
.md h1 { font-size: 22px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.md h2 { font-size: 18px; margin-top: 28px; }
.md h3 { font-size: 15.5px; margin-top: 22px; }
.md img { max-width: 100%; max-height: 420px; border-radius: 8px; margin: 6px 6px 6px 0; vertical-align: top; }
.md p > img + img { max-width: 32%; }
.md table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: #f7f8fa; }
.md blockquote { margin: 12px 0; padding: 8px 14px; background: #fff8e6; border-left: 3px solid var(--warn); color: #6b4e16; border-radius: 0 6px 6px 0; }
.md code { background: #f2f3f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md pre { background: #f7f8fa; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; }
.md pre code { background: none; padding: 0; }

/* 任务 */
.task-row { display: grid; grid-template-columns: 70px 110px 1fr 150px 130px; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.task-row:hover { background: #fafbfc; }
.task-row.head { font-size: 12px; color: var(--sub); cursor: default; background: #fafbfc; }
.status { font-size: 12px; padding: 2px 9px; border-radius: 10px; display: inline-block; }
.status.queued { background: #f2f3f5; color: var(--sub); }
.status.running { background: #e8f0ff; color: var(--info); }
.status.success { background: #e7f7ed; color: var(--ok); }
.status.failed { background: #fdecec; color: var(--err); }
.status.cancelled { background: #f2f3f5; color: var(--faint); }
.status.running::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; animation: pulse 1s infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .2; } }
.log {
  background: #0f1115; color: #c9d1d9; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px;
  border-radius: 8px; padding: 12px 14px; height: 460px; overflow-y: auto; line-height: 1.7;
}
.log .t { color: #6e7681; margin-right: 8px; }
.log .tool { color: #79c0ff; }
.log .text { color: #e6edf3; }
.log .error { color: #ff7b72; }
.log .success { color: #56d364; }

/* 创作 */
.create-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.picker { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.picker .p { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.picker .p:last-child { border-bottom: 0; }
.picker .p img { width: 36px; height: 48px; object-fit: cover; border-radius: 4px; background: #eee; }
.picker .p.on { background: var(--brand-soft); }
.history .h { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.history .h:hover .ht { color: var(--brand); }
.drop { border: 1.5px dashed #cfd3da; border-radius: 8px; padding: 14px; text-align: center; color: var(--sub); cursor: pointer; font-size: 13px; }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.filelist { font-size: 12px; color: var(--sub); margin-top: 6px; line-height: 1.8; }

/* 设置 */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 18px; }
.check-item { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.check-item .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.check-item.ok .dot { background: var(--ok); }
.check-item.bad .dot { background: var(--err); }

/* 提示 & 弹窗 */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: #1d2129; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 13px; animation: fadein .2s; }
.toast-msg.err { background: var(--err); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: grid; place-items: center; }
.modal-box { background: #fff; border-radius: 12px; padding: 22px; width: min(560px, 92vw); max-height: 88vh; overflow: auto; }
.modal-box.wide { width: min(1100px, 95vw); }
.lightbox img { max-width: 100%; max-height: 82vh; display: block; margin: auto; }

@media (max-width: 1000px) {
  .detail, .create-grid { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .brand > div:last-child { display: none; }
  nav a { font-size: 0; }
  nav .ico { font-size: 16px; }
  .side-foot { display: none; }
}

/* 设置页：AI 引擎切换 */
.engine-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.engine-opt { text-align: left; padding: 14px 16px; border: 2px solid var(--line, #e5e7eb); border-radius: 10px; background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, background .15s; }
.engine-opt:hover { border-color: var(--brand); }
.engine-opt span { font-size: 12px; color: #6b7280; line-height: 1.5; }
.engine-opt.active { border-color: var(--brand); background: var(--brand-soft); }
.engine-opt.active b::before { content: "✓ "; color: var(--brand); }
@media (max-width: 720px) { .engine-switch { grid-template-columns: 1fr; } }

.side-logout { display: block; margin: 8px 16px 16px; font-size: 12px; color: #9ca3af; text-decoration: none; }
.side-logout:hover { color: #fff; }
