/* ============================================
   今日头条热点文章改写工具 - 样式
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2329;
  --text-sub: #7a8089;
  --primary: #ff4d4f;
  --primary-dark: #e04345;
  --primary-light: #fff1f0;
  --accent: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
  flex-shrink: 0;
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.brand h1 { font-size: 19px; font-weight: 700; line-height: 1.3; }
.subtitle { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.api-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f2f3f5;
  color: var(--text-sub);
}
.api-status.ok { background: #e8f7ee; color: #16a34a; }
.api-status.err { background: #fdecec; color: #dc2626; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:hover { border-color: #c9ced6; background: #fafbfc; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #f2f3f5; border-color: transparent; }
.btn-secondary:hover { background: #e9eaed; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f2f3f5; }
.btn-mini { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-big {
  flex: 1;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-icon { font-size: 18px; }

/* ---------- 主工作区 ---------- */
.workspace {
  flex: 1;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(360px, 5fr) minmax(420px, 7fr);
  gap: 20px;
  min-height: 0;
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
}

/* ---------- 面板 ---------- */
.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.pane-left { height: calc(100vh - 150px); min-height: 560px; }
.pane-right { height: calc(100vh - 150px); min-height: 560px; }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fcfcfd;
  flex-shrink: 0;
}
.pane-head h2 { font-size: 15px; font-weight: 600; }
.pane-actions { display: flex; gap: 6px; }

/* ---------- 左栏输入 ---------- */
.input-text {
  flex: 1;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  background: var(--panel);
  font-family: inherit;
}
.input-text::placeholder { color: #b0b5bd; }

.input-meta {
  padding: 6px 18px;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px dashed var(--border);
  flex-shrink: 0;
}

/* ---------- 图片上传区 ---------- */
.img-zone {
  flex-shrink: 0;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.img-zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.img-zone-title { font-size: 13px; font-weight: 600; color: var(--text); }
.img-zone-actions { display: flex; gap: 6px; flex-shrink: 0; }
.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.image-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: transform .12s;
}
.image-item:hover { transform: scale(1.04); }
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-item .img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-item .img-remove:hover { background: var(--primary); }
.image-item .img-status {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  line-height: 1.3;
}
.image-drop-hint {
  margin-top: 8px;
  border: 1.5px dashed #c9ced6;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  transition: all .15s;
  user-select: none;
}
.image-drop-hint.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.image-drop-hint.hidden { display: none; }

/* ---------- 写作参数 ---------- */
.options {
  padding: 14px 18px 6px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  flex-shrink: 0;
}
.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}
.opt-label { font-size: 13px; color: var(--text-sub); flex-shrink: 0; }
.opt-select {
  width: 190px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
  color: var(--text);
}
.opt-select:focus { border-color: var(--accent); outline: none; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #d4d8de;
  border-radius: 24px;
  transition: .2s;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

input[type="range"] { width: 150px; accent-color: var(--primary); }
.temp-val { font-size: 12px; color: var(--text-sub); min-width: 26px; text-align: right; }

/* ---------- 生成按钮区 ---------- */
.gen-actions {
  display: flex;
  gap: 10px;
  padding: 12px 18px 16px;
  background: #fafbfc;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.gen-actions .btn-big { width: 100%; }

/* ---------- 右栏 ---------- */
.card {
  margin: 14px 16px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fcfcfd;
  padding: 12px 16px;
  flex-shrink: 0;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.card-title-row .card-title { margin-bottom: 0; }
.btn-collapse { flex-shrink: 0; }

/* 收起状态 */
.collapsed { display: none !important; }

.analysis-body { font-size: 13px; line-height: 1.7; color: var(--text); }
.analysis-body .an-row { margin-bottom: 6px; }
.analysis-body .an-label { color: var(--accent); font-weight: 600; margin-right: 6px; }
.analysis-body .an-points { margin: 4px 0 0; padding-left: 18px; }
.analysis-body .an-points li { margin-bottom: 3px; }

/* 输出区域 */
.output-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px;
  position: relative;
}
.output-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-light);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.output-text {
  font-size: 15.5px;
  line-height: 2;
  color: #33383f;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100px;
}
.output-text:empty::before { content: ""; }

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b8bdc5;
  text-align: center;
  pointer-events: none;
}
.placeholder-icon { font-size: 46px; margin-bottom: 12px; }
.placeholder p { font-size: 15px; }
.placeholder-sub { font-size: 13px; margin-top: 8px; line-height: 1.8; }

/* 自检卡片 */
.check-body { font-size: 13px; line-height: 1.7; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.check-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.check-item .ck-name { font-size: 11px; color: var(--text-sub); }
.check-item .ck-val { font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.check-item .ck-desc { font-size: 11px; color: var(--text-sub); }
.ck-good { color: #16a34a; }
.ck-mid { color: #d97706; }
.ck-bad { color: #dc2626; }
.check-list { padding-left: 18px; }
.check-list li { margin-bottom: 4px; }

/* 状态条 */
.status-bar {
  flex-shrink: 0;
  margin: 12px 16px 16px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  background: #f0f6ff;
  color: var(--accent);
  border: 1px solid #d6e4ff;
  white-space: pre-wrap;
  word-break: break-word;
}
.status-bar.error { background: #fdecec; color: #dc2626; border-color: #f5c6c6; }
.status-bar.warn { background: #fff7e6; color: #b45309; border-color: #f5dfa8; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  width: 520px;
  max-width: 92vw;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop {
  from { transform: scale(.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input[type="text"], .field input[type="password"], .field input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.field-hint { font-size: 11.5px; color: var(--text-sub); margin-top: 5px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-divider {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 12px 0 8px;
  margin: 4px 0 12px;
  border-top: 1px dashed var(--border);
}
.cfg-status {
  padding: 9px 12px;
  border-radius: 8px;
  background: #f2f3f5;
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}
.cfg-status.ok { background: #e8f7ee; color: #16a34a; }
.cfg-status.err { background: #fdecec; color: #dc2626; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d0d4da; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b9bec6; }
::-webkit-scrollbar-track { background: transparent; }

/* 生成中光标 */
.output-text.generating::after {
  content: "▋";
  color: var(--primary);
  animation: blink 1s infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }
