:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2329;
  --sub: #8a9099;
  --primary: #1a73e8;
  --primary-dark: #1668cf;
  --danger: #e5484d;
  --green: #17a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }

/* ---------- 通用控件 ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: #c9ced6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fff; border-color: #f3c2c4; color: var(--danger); }
.btn.danger:hover { background: #fdf1f1; }
.btn.ghost { background: #fff; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.input:focus { border-color: var(--primary); }
.input.area { width: 100%; resize: vertical; line-height: 1.7; }
.input.sm-num { width: 92px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 6px;
}
.field > span em { color: var(--danger); font-style: normal; }
.field.inline { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.field.inline > span { margin-bottom: 0; }
.field-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}

.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { width: 16px; height: 16px; cursor: pointer; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #eef2f7, #f8f9fb);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.login-box {
  width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 8px 30px rgba(20, 30, 50, .08);
}
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-sub { margin: 0 0 20px; color: var(--sub); font-size: 13px; }
.login-box .input { width: 100%; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 8px 0 0; }
#loginErr { white-space: pre-line; line-height: 1.7; }
.origin-tip { font-size: 12px; color: #8a94a6; margin: 6px 0 0; }
.origin-tip code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; color: #5b6472; }
.file-warn {
  margin-bottom: 16px; padding: 12px 14px;
  background: #fdf1f1; border: 1px solid #f6d8d9; border-radius: 8px;
  font-size: 12.5px; color: #8e2f33; line-height: 1.7;
}
.file-warn.warn { background: #fff8ea; border-color: #fbe3bd; color: #8a5a12; }
.file-warn p { margin: 6px 0 0; }
.file-warn code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

.login-tip {
  margin-top: 18px; padding: 12px 14px;
  background: #f7f9fc; border-radius: 8px;
  font-size: 12.5px; color: #5b6472; line-height: 1.7;
}
.login-tip ol { margin: 6px 0 0; padding-left: 18px; }
.login-tip code { background: #eceff3; padding: 1px 5px; border-radius: 4px; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.env-tag {
  font-size: 12px; color: var(--sub);
  background: #f1f3f6; padding: 3px 9px; border-radius: 20px;
}

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 20px 0;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .n { font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat-card .l { font-size: 12.5px; color: var(--sub); margin-top: 2px; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; padding: 16px 20px 0; }
.tab {
  border: none; background: none; cursor: pointer;
  padding: 8px 16px; font-size: 14px; color: var(--sub);
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-panel { padding: 14px 20px 40px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { min-width: 130px; }
.toolbar #kw { flex: 1; min-width: 180px; }

/* ---------- 批量操作栏 ---------- */
.batch-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #f0f5ff; border: 1px solid #d6e4fb; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}
.batch-info { font-size: 13px; color: var(--text); }
.batch-info b { color: var(--primary); font-weight: 600; }
.batch-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); }
.batch-label .input { min-width: 0; }
.input.sm { padding: 5px 8px; font-size: 13px; min-width: 0; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 13px; color: var(--sub);
  background: #fafbfc; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfd; }
.table th input[type="checkbox"],
.table td input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; vertical-align: middle; }

.cover-img {
  width: 48px; height: 48px; border-radius: 6px;
  object-fit: cover; background: #f0f1f3; display: block;
}
.cover-none {
  width: 48px; height: 48px; border-radius: 6px;
  background: #f0f1f3; color: #b6bcc4;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.t-title { font-weight: 500; }
.t-sub { color: var(--sub); font-size: 12px; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 12px; border: 1px solid transparent;
}
.tag.published { background: #e8f7ee; color: var(--green); border-color: #cdeedb; }
.tag.draft { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.tag.offline { background: #fdf1f1; color: var(--danger); border-color: #f6d8d9; }
.tag.ad { background: #fff5e6; color: #b45309; border-color: #fbe3bd; }
.tag.free { background: #eef4ff; color: var(--primary); border-color: #d6e4fb; }
.tag.top { background: #f3e8ff; color: #7c3aed; border-color: #e6d4fb; }
.tag.dim { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* 三维标签选择器 */
.tag-picker { display: flex; flex-direction: column; gap: 10px; }
.tag-pick-group { display: flex; align-items: flex-start; gap: 8px; }
.tag-pick-group > b { font-size: 13px; color: var(--sub); min-width: 32px; line-height: 26px; }
.tag-pick-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick-chip {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 13px; cursor: pointer; user-select: none;
  background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb;
}
.tag-pick-chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.empty { padding: 40px; text-align: center; color: var(--sub); }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.page-info { color: var(--sub); font-size: 13px; }

/* ---------- 弹窗（完全满屏 + 正文独立滚动，防滚动穿透） ---------- */
.modal {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: stretch; justify-content: stretch;
  padding: 0; overflow: hidden; z-index: 40;
}
.modal-box {
  width: 100%; max-width: 100%;
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 0;
}
.modal-head {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 600;
  background: var(--card);
}
.modal-body {
  flex: 1; overflow-y: auto; padding: 24px;
  overscroll-behavior: contain;
}
.modal-body .input { width: 100%; }
.modal-foot {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-top: 1px solid var(--line);
  background: var(--card);
}
.spacer { flex: 1; }

.var-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.var-tip { font-size: 12.5px; color: var(--sub); }
.var-tip b { color: var(--primary); font-weight: 600; }

/* 提示词正文：置于编辑器最底部，与上方字段用虚线分隔 */
.field-text {
  margin-top: 16px; margin-bottom: 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hint { font-size: 12.5px; color: var(--sub); }

.img-list { display: flex; gap: 10px; flex-wrap: wrap; }
.img-item {
  width: 96px; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #fff; cursor: grab;
}
.img-item img {
  width: 100%; height: 72px; object-fit: cover; display: block; background: #f0f1f3;
  cursor: zoom-in; -webkit-user-drag: none;
}
.img-item .ops { display: flex; }
.img-item .ops button {
  flex: 1; border: none; background: #fafbfc; cursor: pointer;
  font-size: 11px; padding: 4px 0; color: var(--sub); font-family: inherit;
}
.img-item .ops button:hover { background: #f0f1f3; color: var(--text); }
.img-item.is-cover { border-color: var(--primary); }
/* 拖拽排序状态 */
.img-item.dragging { opacity: .4; cursor: grabbing; }
.img-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26, 115, 232, .3); }

/* ---------- 大图预览 ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 12, 16, .9);
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
}
.lightbox img {
  max-width: 92vw; max-height: 88vh; display: block;
  border-radius: 6px; box-shadow: 0 10px 50px rgba(0, 0, 0, .5);
  background: #111;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 28px; line-height: 1; cursor: pointer; user-select: none;
}
.lb-nav:hover { background: rgba(255, 255, 255, .3); }
.lb-nav:disabled { opacity: .25; cursor: default; }
.lb-nav:disabled:hover { background: rgba(255, 255, 255, .15); }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-close {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.lb-close:hover { background: rgba(255, 255, 255, .3); }
.lb-count {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, .85); font-size: 13px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13.5px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
