:root {
  --xhs-red: #ff2442;
  --xhs-red-soft: #ff6680;
  --ink: #1f1f1f;
  --muted: #8a8a8a;
  --line: #ededed;
  --bg: #f7f7f8;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--xhs-red); color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .btn.ghost { margin-top: 0; }
.btn.sm { padding: 6px 12px; font-size: 13px; line-height: 1.4; }
.btn.xs { padding: 4px 8px; font-size: 11px; line-height: 1.3; }

/* 设置弹层 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: var(--radius); width: min(440px, 92vw);
  max-height: 88vh; overflow: auto; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.modal-head .x { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-card h4 { margin: 18px 0 6px; font-size: 14px; }
.hint-text { font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.modal-card input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; margin-bottom: 10px; background: #fafafa; font-family: inherit;
}
.modal-card input:focus { outline: none; border-color: var(--xhs-red-soft); background: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.topbar h1 { font-size: 18px; margin: 0; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }
.mode-tag {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: #fff0f2; color: var(--xhs-red); font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  padding: 22px 28px;
  max-width: 1180px;
  margin: 0 auto;
}

/* 种子输入 */
.seed {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  align-self: start;
  position: sticky;
  top: 90px;
}
.seed h2 { font-size: 15px; margin: 0 0 14px; }
.seed h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.seed label, .panel label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.seed label small, .panel label small { color: #bbb; }
.seed input, .seed textarea, .panel input, .panel textarea, .panel select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fafafa;
}
.seed input:focus, .panel input:focus, .panel textarea:focus, .panel select:focus {
  outline: none; border-color: var(--xhs-red-soft); background: #fff;
}

/* tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: .15s;
}
.tab.active { background: var(--xhs-red); color: #fff; border-color: var(--xhs-red); }

.modules .panel { display: none; }
.modules .panel.active { display: block; }
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 16px; font-size: 16px; }
.prompt-label-row, .history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.prompt-label-row label, .history-header label { margin-bottom: 0; }
.prompt-label-row .btn, .history-header .btn { margin-top: 0; }
.history-header { margin-bottom: 6px; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* buttons */
.btn {
  border: none; border-radius: 10px; padding: 10px 20px;
  font-size: 14px; cursor: pointer; font-weight: 600; transition: .15s;
}
.btn.primary { background: var(--xhs-red); color: #fff; }
.btn.primary:hover { background: #e51e39; }
.btn.primary:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: #fff0f2; color: var(--xhs-red); margin-top: 14px; }
.btn.ghost:hover { background: #ffe0e6; }

/* history manage */
.history-manage-list { max-height: 60vh; overflow: auto; margin: 12px 0; }
.history-manage-item { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.history-manage-item textarea { flex: 1; margin-bottom: 0; resize: vertical; }
.history-manage-actions { display: flex; gap: 6px; flex-shrink: 0; }
.history-manage-actions .btn { margin-top: 0; white-space: nowrap; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 18px; }
.gitem { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fafafa; }
.gitem img { width: 100%; display: block; }
.gitem .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.gitem .meta code { display: block; word-break: break-all; color: #555; margin-bottom: 6px; }
.gitem .dl { font-size: 12px; color: var(--xhs-red); cursor: pointer; }
.gitem .tag-ok { font-size: 11px; color: #0a7d4b; background: #e6f6ee; border: 1px solid #b6e3cd; border-radius: 6px; padding: 1px 7px; margin-left: 8px; }

/* title cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 18px; }
.tcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fafafa; cursor: pointer; transition: .15s; }
.tcard:hover { border-color: var(--xhs-red-soft); background: #fff; }
.tcard .badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #fff0f2; color: var(--xhs-red); margin-bottom: 8px; }
.tcard .txt { font-size: 15px; font-weight: 600; }
.tcard .hint { font-size: 11px; color: #bbb; margin-top: 6px; }

/* body */
.body-card { display: flex; flex-direction: column; }
.body-card .badge { margin-right: 6px; }
.body-card .badge.secondary { background: #f0f0f0; color: #666; }
.body-preview {
  flex: 1;
  font-size: 14px; font-weight: 400; line-height: 1.7;
  overflow-y: auto;
  max-height: 260px;
  color: #333;
  padding-right: 4px;
}
.body-preview br { display: block; content: ""; margin-bottom: 4px; }
.body-card .copy-btn {
  align-self: flex-start;
  font-size: 11px;
  color: #bbb;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: .15s;
}
.body-card .copy-btn:hover {
  color: #38bdf8;
  background: #e0f2fe;
}

/* 正文放大弹层 */
.body-modal-card { width: min(640px, 92vw); }
.modal-badges { margin: 10px 0 6px; }
.modal-badges .badge {
  display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: #fff0f2; color: var(--xhs-red); margin-right: 6px;
}
.modal-badges .badge.secondary { background: #f0f0f0; color: #666; }
.body-modal-content {
  white-space: pre-wrap; line-height: 1.8; font-size: 15px; color: #333;
  max-height: 60vh; overflow-y: auto; padding: 12px; background: #fafafa;
  border-radius: 10px; border: 1px solid var(--line);
}

/* topic */
.tgroup { margin-top: 18px; }
.tgroup h4 { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: #fff0f2; color: var(--xhs-red); padding: 6px 12px; border-radius: 999px; font-size: 13px; }

/* toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f1f1f; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .seed { position: static; }
  .row { grid-template-columns: 1fr; }
}

/* 顶栏用户区 */
.who { font-size: 13px; color: var(--muted); }

/* 登录 / 注册 */
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.modal-card input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; margin-bottom: 12px; box-sizing: border-box; }
.btn.block { width: 100%; margin-top: 4px; }
.switch { text-align: center; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.switch a { color: var(--xhs-red); text-decoration: none; font-weight: 600; }
.login-error { color: var(--xhs-red); font-size: 13px; min-height: 18px; margin: 4px 0 6px; }

/* 附图：上传提取 */
.split-section { margin-bottom: 18px; }
.split-section h4 { font-size: 15px; margin: 0 0 8px; }
.divider { border: 0; border-top: 1px dashed var(--line); margin: 22px 0; }

.upload-zone {
  border: 2px dashed var(--line); border-radius: 14px;
  padding: 26px; text-align: center; background: #fafafa;
  transition: .2s; cursor: pointer; margin: 10px 0 14px;
}
.upload-zone.dragover { border-color: var(--xhs-red); background: #fff5f6; }
.upload-hint { color: var(--muted); font-size: 14px; line-height: 1.8; }
.upload-hint .btn { margin: 0 4px; }

.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.file-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: #333; display: inline-flex; align-items: center; gap: 6px;
}
.file-chip .rm { cursor: pointer; color: var(--muted); }
.file-chip .rm:hover { color: var(--xhs-red); }

.source-tag {
  position: absolute; bottom: 6px; left: 6px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 999px;
}
.gallery figure { position: relative; }

/* 提示词历史下拉框 */
.prompt-history {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 9px 32px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink);
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
  cursor: pointer;
  margin-bottom: 10px;
}
.prompt-history:focus {
  outline: none;
  border-color: var(--xhs-red-soft);
  background-color: #fff;
}
.prompt-history option {
  font-size: 13px;
}

/* 主图 / 附图批量操作 */
.batch-actions {
  display: none;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.batch-actions .btn {
  margin-top: 0;
}
