/* 公众号文章自动发布助手 — 页面样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* 关键修复：确保 hidden 属性始终隐藏元素（避免被 display:flex 等覆盖） */
[hidden] { display: none !important; }
:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a919f;
  --border: #e5e7eb;
  --radius: 12px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.app { max-width: 1200px; margin: 0 auto; padding: 16px 20px 60px; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; flex-wrap: wrap;
  padding: 14px 6px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 32px; }
.brand h1 { font-size: 22px; font-weight: 700; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.keybox { display: flex; align-items: center; gap: 8px; }
.keybox input {
  width: 260px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: #fff;
}
.key-status { font-size: 12px; color: var(--muted); }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: 24px;
}
.main { display: grid; grid-template-columns: 420px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .main { grid-template-columns: 1fr; } }

/* 表单 */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; resize: vertical; font-family: inherit;
  line-height: 1.6;
}
.field textarea:focus, .keybox input:focus, .custom-style input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(7,193,96,.12);
}
.styles { display: flex; flex-wrap: wrap; gap: 8px; }
.style-chip {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: #fff; font-size: 13px; cursor: pointer; color: var(--text);
  transition: all .15s;
}
.style-chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.style-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.custom-style { margin-top: 10px; }
.custom-style input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
}

/* 按钮 */
.btn {
  padding: 9px 18px; border: none; border-radius: 8px; font-size: 14px;
  cursor: pointer; font-weight: 600; transition: all .15s; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; box-sizing: border-box;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #f0f2f5; color: var(--text); }
.btn-ghost:hover { background: #e3e6ea; }
.btn-publish { background: #fa5151; color: #fff; }
.btn-publish:hover:not(:disabled) { background: #e04a4a; }
.actions { display: flex; align-items: center; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.publish-bar { display: flex; align-items: center; gap: 10px; }
.channel-select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); cursor: pointer;
}
.qr-box { text-align: center; margin: 12px 0; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 8px; }
.qr-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 预览 */
.preview-card { min-height: 420px; position: relative; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-weight: 600; flex-wrap: wrap; gap: 10px;
}
.edit-tip { font-size: 12px; color: var(--muted); font-weight: 400; font-style: normal; }

/* 封面图区域 */
.cover-box {
  margin-top: 24px; padding: 12px; background: #f7f8fa;
  border: 1px solid var(--border); border-radius: 10px;
}
.cover-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: 13px; font-weight: 600; flex-wrap: wrap; gap: 8px;
}
.cover-actions { display: flex; align-items: center; gap: 8px; }
.cover-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 140px; border: 2px dashed #d0d5dd; border-radius: 8px;
  background: #fff; cursor: pointer; transition: border-color .2s, background .2s;
  text-align: center; padding: 16px;
}
.cover-placeholder:hover { border-color: var(--primary); background: #fafdfb; }
.cover-placeholder-icon { font-size: 28px; }
.cover-placeholder-text { font-size: 14px; color: var(--text); font-weight: 500; }
.cover-hint { font-size: 12px; color: var(--muted); }
.cover-img {
  width: 100%; border-radius: 6px; display: block; cursor: pointer;
  aspect-ratio: 900 / 383; object-fit: cover;
  transition: opacity .2s;
}

/* 编辑工具栏 */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 8px 10px; background: #f7f8fa; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 14px; position: sticky; top: 8px; z-index: 20;
}
.tb {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; font-size: 13px; cursor: pointer;
  color: var(--text); line-height: 1;
}
.tb:hover { border-color: var(--primary); color: var(--primary-dark); }
.tb:active { background: var(--primary); color: #fff; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }

/* AI 修改区 */
.revise-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px; background: #f0f7f3; border: 1px solid #d3eadf;
  border-radius: 8px; margin-bottom: 10px;
}
.revise-bar input {
  flex: 1; min-width: 200px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.revise-bar input:focus { outline: none; border-color: var(--primary); }
.revise-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.revise-chip {
  padding: 5px 12px; font-size: 12px; border: 1px solid var(--border);
  background: #fff; border-radius: 999px; cursor: pointer; color: var(--text);
  transition: all .15s;
}
.revise-chip:hover { border-color: var(--primary); color: var(--primary-dark); background: #f0faf4; }
.editable-title:focus, .editable-body:focus { outline: 2px dashed rgba(7,193,96,.55); outline-offset: 3px; border-radius: 4px; }
.preview-empty { color: var(--muted); text-align: center; padding: 90px 0; font-size: 14px; line-height: 2; }
.preview { max-width: 677px; margin: 0 auto; }
.preview h1 { font-size: 20px; line-height: 1.5; margin-bottom: 16px; }
.preview-body { font-size: 15px; line-height: 1.8; }
.preview-body p { margin: 10px 0; }
.preview-body img { max-width: 100%; }
.preview-body blockquote { margin: 10px 0; }
.preview-body section, .preview-body blockquote, .preview-body ul, .preview-body ol { max-width: 100%; }

/* spinner */
.spinner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(255,255,255,.85); border-radius: var(--radius); color: var(--muted);
}
.dot {
  width: 36px; height: 36px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 弹层 */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.dialog {
  width: 520px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.dialog h3 { margin-bottom: 18px; }

/* 访问门禁 */
.auth-dialog { width: 360px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 8px; }
.auth-form input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form .btn { width: 100%; justify-content: center; margin-top: 2px; }
.auth-error { color: #e64340; font-size: 13px; margin-top: 4px; }
.auth-tip { color: var(--muted); font-size: 12px; margin-top: 10px; }
.progress-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.step .dot {
  width: 22px; height: 22px; border-radius: 50%; border: none; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  background: #eceef1; color: var(--muted); animation: none;
}
.step.active { color: var(--text); font-weight: 600; }
.step.active .dot { background: var(--primary); color: #fff; }
.step.done { color: var(--primary-dark); }
.step.done .dot { background: var(--primary); color: #fff; }
.status-text { font-size: 13px; color: var(--muted); margin-bottom: 8px; line-height: 1.7; }
.manual-tip {
  background: #fff7e6; border: 1px solid #ffd591; color: #ad6800;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; line-height: 1.6;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* 左下角配置入口 */
.config-fab {
  position: fixed; left: 20px; bottom: 20px; z-index: 100;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff; border: none; border-radius: 999px;
  cursor: pointer; box-shadow: 0 4px 14px rgba(7, 193, 96, 0.35);
  transition: transform .15s, box-shadow .15s;
}
.config-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(7, 193, 96, 0.45); }
.config-fab:active { transform: translateY(0); }

/* 配置面板 tabs */
.config-tabs { display: flex; gap: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.config-tab {
  padding: 7px 16px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  cursor: pointer; color: var(--text); transition: all .15s;
}
.config-tab:hover { border-color: var(--primary); color: var(--primary-dark); }
.config-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.config-panel { min-height: 120px; }

/* 账号添加行 */
.account-form { display: flex; gap: 8px; margin-bottom: 12px; }
.account-form input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.account-form input:focus { outline: none; border-color: var(--primary); }

/* 模型配置 */
.model-hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; line-height: 1.6; }
.model-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.model-form input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.model-form input:focus { outline: none; border-color: var(--primary); }

/* 公司信息弹窗：二维码上传 */
.qr-row { display: flex; gap: 8px; align-items: center; }
.qr-row input { flex: 1; min-width: 0; }
.qr-preview {
  width: 96px; height: 96px; object-fit: contain; margin: 4px 0 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff;
}
.footer-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; color: var(--text); }
.model-list { max-height: 200px; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.model-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; font-size: 13px;
}
.model-item em { font-style: normal; color: var(--muted); }
.model-item .model-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 手机端适配 */
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .keybox { width: 100%; }
  .keybox input { flex: 1; width: auto; }
  .main { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 16px; }
  .toolbar { position: static; padding: 6px; gap: 3px; }
  .tb { min-width: 38px; height: 38px; font-size: 14px; padding: 0 6px; }
  .tb-sep { margin: 0 3px; }
  .dialog { width: 94vw; max-height: 86vh; overflow-y: auto; }
  .qr-box img { width: 260px; height: 260px; }
  .publish-bar { width: 100%; justify-content: space-between; }
  .publish-bar .btn-publish { flex: 1; }
  .edit-tip { display: block; margin-top: 4px; }
  .brand h1 { font-size: 19px; }
  .key-status { font-size: 11px; }
}
