/* public/css/styles.css — 全站统一样式：系统字体 / 卡片布局 / 微信绿主色 / 移动端可用 */

:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --green-bg: #e8f9ef;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a919f;
  --border: #e5e7eb;
  --danger: #e64340;
  --warn: #d48806;
  --radius: 10px;
}

* { box-sizing: border-box; }
/* hidden 属性必须始终生效：作者样式里的 display（如 .entry-card{display:block}）
   会盖过浏览器 UA 的 [hidden]{display:none}，用 !important 兜住，防止权限类元素误显 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1000px; margin: 0 auto; padding: 20px 16px 60px; }
.page-title { font-size: 22px; margin: 6px 0 18px; }

/* ===== 顶部导航 ===== */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.header-inner {
  max-width: 1000px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 5px 12px; border-radius: 999px; color: var(--text); font-size: 14px; white-space: nowrap; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--green-bg); color: var(--green-dark); font-weight: 600; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-left: auto; }
.header-credits b { color: var(--green-dark); }

/* ===== 卡片 ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 16px; margin: 0 0 12px; }
.section-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }

/* ===== 表单 ===== */
.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff;
}
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 2px rgba(7, 193, 96, .15); }
textarea.input { resize: vertical; }
.input-sm { padding: 5px 8px; font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 150px; margin-bottom: 0; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--green); color: var(--green-dark); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); color: var(--danger); }

/* ===== 提示 ===== */
.hint { font-size: 13px; color: var(--muted); }
.msg-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.msg-ok { color: var(--green-dark); font-size: 13px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }

/* ===== 状态徽标（可点击切换）===== */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid transparent; cursor: pointer; background: none; font-family: inherit; white-space: nowrap;
}
.badge.unwritten { background: #f2f3f5; color: var(--muted); border-color: var(--border); }
.badge.writing { background: #fff7e6; color: var(--warn); border-color: #ffe1a8; }
.badge.done { background: var(--green-bg); color: var(--green-dark); border-color: #b7ecce; }

/* ===== 进度日志（SSE）===== */
.log {
  background: #17191d; color: #d7dde6; border-radius: 8px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.7; max-height: 260px; overflow-y: auto; margin-top: 12px;
}
.log-line.err { color: #ff8f8f; }

/* ===== 登录 / 注册 ===== */
.auth-wrap { display: flex; justify-content: center; padding: 48px 0; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-title { font-size: 20px; margin: 0 0 4px; text-align: center; }
.auth-sub { font-size: 13px; color: var(--muted); text-align: center; margin: 0 0 20px; }
.auth-switch { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* ===== 落地入口卡片 ===== */
.entry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.entry-card { display: block; color: var(--text); padding: 22px 18px; transition: box-shadow .15s, transform .15s, border-color .15s; }
.entry-card:hover { text-decoration: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .08); transform: translateY(-2px); border-color: var(--green); }
.entry-icon { font-size: 30px; margin-bottom: 8px; }
.entry-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.entry-desc { font-size: 13px; color: var(--muted); }

/* ===== 选题页：维度编辑 ===== */
.dim-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.dim-row .dim-name { flex: 0 0 180px; }
.dim-row .dim-desc { flex: 1; }
.gen-opts { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; font-size: 14px; }
.gen-opts .num-input { width: 70px; }
.radio-group { display: inline-flex; gap: 12px; align-items: center; }
.radio-group label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }

/* ===== 选题库：两层折叠分组 ===== */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.lib-counts { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.chip { padding: 2px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.chip b { color: var(--text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 110px; }
.filters .search { flex: 1; min-width: 150px; }

.main-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.main-head {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 10px 14px;
  background: #fafbfc; border: none; cursor: pointer; font: inherit; font-weight: 700; text-align: left; color: var(--text);
}
.main-groups { padding: 4px 12px 10px; }
.main-group.collapsed .main-groups { display: none; }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); font-size: 12px; }
.main-group.collapsed > .main-head .chev,
.group.collapsed > .group-head .chev { transform: rotate(-90deg); }
.group-meta { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }

.group { margin-top: 6px; }
.group-head {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 6px;
  background: none; border: none; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px; text-align: left; color: var(--text);
}
.group.collapsed .group-items { display: none; }
.group-items { padding-left: 10px; }

.item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; }
.item:hover { background: var(--bg); }
.item-text { flex: 1; font-size: 14px; min-width: 0; word-break: break-word; }
.item-link { font-size: 13px; white-space: nowrap; }
.item-ct { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ===== 写作页 ===== */
.writer-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.steps { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.step {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); font: inherit; font-size: 14px; color: var(--muted); cursor: pointer;
}
.step:disabled { cursor: not-allowed; opacity: .6; }
.step.active { border-color: var(--green); color: var(--green-dark); background: var(--green-bg); font-weight: 700; }
.step.done { color: var(--green-dark); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--bg); font-size: 12px;
}
.step.active .step-num, .step.done .step-num { background: var(--green); color: #fff; }
.step-sep { flex: 0 0 14px; height: 1px; background: var(--border); }

.topic-box { background: var(--bg); border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 6px; word-break: break-word; }
.brief-box {
  background: var(--bg); border-radius: 8px; padding: 12px 14px; font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
}
.tag-mini { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--green-bg); color: var(--green-dark); font-size: 12px; font-weight: 400; }

.title-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; }
.title-card:hover { border-color: var(--green); }
.title-card.selected { border-color: var(--green); background: var(--green-bg); }
.title-card-title { font-weight: 600; font-size: 14.5px; }
.title-card-meta { display: flex; gap: 8px; align-items: baseline; margin-top: 4px; flex-wrap: wrap; }
.title-card-digest { font-size: 12.5px; color: var(--muted); }

.md-out { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.7; margin-top: 6px; }

/* ===== 表格（dashboard）===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafbfc; white-space: nowrap; }
.td-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.td-actions { white-space: nowrap; }

/* ===== 模型配置（端点/模型解耦布局）===== */
.mc-group { margin-bottom: 20px; }
.mc-group-title { font-size: 14px; font-weight: 700; margin: 4px 0 6px; }
.mc-col-hint { font-size: 12px; font-weight: 500; color: var(--muted); }
.mc-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.mc-label { flex: 0 0 200px; display: flex; flex-direction: column; gap: 1px; font-size: 13.5px; }
.mc-label .hint { font-size: 11.5px; }
.mc-fields { flex: 1; display: flex; gap: 8px; }
.mc-fields .input, .mc-fields select { flex: 1; min-width: 0; }
.mc-fields-2 .input { flex: 1 1 0; }
@media (max-width: 640px) {
  .mc-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .mc-label { flex-basis: auto; }
}

/* ===== 定价表单 ===== */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ===== toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(23, 25, 29, .92); color: #fff; padding: 9px 18px; border-radius: 999px; font-size: 13px; z-index: 99;
}
.toast.err { background: rgba(190, 42, 42, .95); }

/* ===== 配图（writer 第五步）===== */
.msg-warn {
  background: #fff7e6; border: 1px solid #ffe1a8; color: var(--warn);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; line-height: 1.6;
}
.img-cover-preview {
  display: block; width: 100%; max-width: 540px; border-radius: 8px;
  border: 1px solid var(--border); margin-bottom: 6px;
}
.img-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.img-thumb { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); }
.img-thumb img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.img-thumb-meta { padding: 6px 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.img-thumb-meta a { font-size: 12px; }

/* ===== 排版（writer 第六步）===== */
.format-preview {
  width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; margin-top: 12px;
}
.theme-gen {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}

/* ===== 移动端 ===== */
@media (max-width: 760px) {
  .writer-layout { grid-template-columns: 1fr; }
  .entry-grid { grid-template-columns: 1fr; }
  .dim-row { flex-wrap: wrap; }
  .dim-row .dim-name { flex: 1 1 130px; }
  .dim-row .dim-desc { flex: 1 1 100%; }
  .header-inner { gap: 10px; }
  .nav { order: 3; flex-basis: 100%; }
  .filters .input { min-width: 90px; }
}
