/* ============== 基础 ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f7f8;
  --bg-card: #ffffff;
  --bg-soft: #fafafa;
  --border: #e5e7eb;
  --text: #1f2328;
  --text-soft: #6b7280;
  --primary: #ff2442;     /* 小红书红 */
  --primary-hover: #e01e3a;
  --primary-soft: #ffe8eb;
  --success: #10b981;
  --warn: #f59e0b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

html, body { height: auto; min-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);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* 让 body 内容超出时能整体滚(不要再走 workspace 内部滚) */
  overflow-y: auto;
}

/* ============== 顶部 ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 22px; }
.brand h1 { font-size: 18px; font-weight: 600; }
.brand .subtitle { color: var(--text-soft); font-size: 12px; margin-left: 4px; }

.actions { display: flex; gap: 8px; }

/* ============== 布局 ============== */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 8px;
}

.sidebar-header h2 { font-size: 15px; font-weight: 600; }

.search {
  margin: 0 16px 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-soft);
}

.search:focus { outline: none; border-color: var(--primary); }

.post-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.post-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.post-item:hover { background: var(--bg-soft); }
.post-item.active { background: var(--primary-soft); border-color: var(--primary); }

.post-item .title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-item .date { font-size: 11px; color: var(--text-soft); margin-top: 4px; }

.empty {
  padding: 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

/* ============== 主区 ============== */
.workspace {
  /* 不再内部滚,让 body 整体滚(更符合用户直觉) */
  padding: 16px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.card-header h3 { font-size: 14px; font-weight: 600; }
.card-header .meta { font-size: 12px; color: var(--text-soft); }
.header-actions { display: flex; align-items: center; gap: 12px; }

.card-body { padding: 16px; }

.original-content {
  font-size: 13px;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, monospace;
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.6;
}

.original-content.empty { color: var(--text-soft); font-family: inherit; }

/* ============== 控制栏 ============== */
.control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px;
}

.control-bar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); }

#style-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-card);
}

.status { font-size: 12px; color: var(--text-soft); }
.status.error { color: #dc2626; }
.status.success { color: var(--success); }

/* ============== 表单 ============== */
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin: 12px 0 6px;
  font-weight: 500;
}

.field-label:first-child { margin-top: 0; }

#result-title, #result-tags, .prompt-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
}

#result-title:focus, #result-tags:focus, .prompt-input:focus {
  outline: none; border-color: var(--primary);
}

#result-content {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  background: var(--bg-card);
  min-height: 200px;
}

#result-content:focus { outline: none; border-color: var(--primary); }

.disclosure-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
}

.disclosure-row.hidden { display: none; }

.warn-badge {
  background: var(--warn);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ============== 按钮 ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-soft); border-color: var(--text-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost { background: transparent; }
.btn-icon { padding: 4px 10px; font-size: 16px; }

.btn-mini {
  padding: 4px 8px;
  font-size: 11px;
}

/* ============== 图片 ============== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.image-slot {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 10px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-label { font-size: 12px; font-weight: 500; color: var(--text-soft); }

.slot-preview {
  aspect-ratio: 3/4;
  /* 限制最大高度,避免把 slot 撑爆(3/4 比例下 200px 宽= 267px 高,4 列布局下会过高) */
  max-height: 160px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-soft);
  overflow: hidden;
  position: relative;
}

.slot-preview:not(.empty) { border-style: solid; }

.slot-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.slot-actions { display: flex; gap: 4px; }
.file-input { display: none; }

.prompt-input { font-size: 12px; padding: 6px 8px; }

/* ============== Modal ============== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content h3 { font-size: 16px; }
.modal-tip { font-size: 12px; color: var(--text-soft); }

#paste-title, #paste-markdown {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-soft);
}

#paste-markdown { font-family: ui-monospace, monospace; resize: vertical; min-height: 200px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============== Toast ============== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: opacity 0.2s;
}

.toast.hidden { opacity: 0; pointer-events: none; }
.toast.success { background: var(--success); }
.toast.error { background: #dc2626; }

/* ============== 滚动条 ============== */
.post-list::-webkit-scrollbar,
.workspace::-webkit-scrollbar,
.original-content::-webkit-scrollbar { width: 8px; }

.post-list::-webkit-scrollbar-thumb,
.workspace::-webkit-scrollbar-thumb,
.original-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
