/* 基础重置和变量 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* 头部 */
.header { text-align: center; padding: 24px 0 16px; }
.header h1 { font-size: 26px; font-weight: 700; color: var(--primary); }
.subtitle { margin-top: 6px; color: var(--text-light); font-size: 15px; }

/* 设置面板 */
.settings-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  user-select: none;
}

.settings-title { font-size: 14px; font-weight: 600; }
.settings-hint { margin-left: 10px; font-size: 12px; color: var(--text-light); }
.settings-arrow { margin-left: auto; font-size: 12px; color: var(--text-light); transition: transform 0.2s; }
.settings-arrow.open { transform: rotate(180deg); }
.settings-body { padding: 0 20px 16px; display: none; }
.settings-body.open { display: block; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.settings-grid .form-group { margin-bottom: 0; }
.sample-section { margin-top: 14px; margin-bottom: 0; }
.label-hint { font-weight: 400; font-size: 12px; color: var(--text-light); margin-left: 6px; }
.sample-status { font-size: 12px; color: #10b981; margin-top: 4px; min-height: 16px; }

/* 两栏布局 */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* 表单通用 */
.form-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.required { color: #ef4444; margin-left: 2px; }

.form-group input[type="text"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  resize: vertical;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 字数统计 */
.char-count { text-align: right; font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* 可选标签 */
.tag-optional {
  display: inline-block;
  padding: 2px 8px;
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #fed7aa;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}

/* 引导提问 */
.guide-questions {
  margin-bottom: 12px;
  padding: 12px;
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 8px;
}

.guide-questions.hidden { display: none; }

.guide-title {
  font-size: 13px;
  font-weight: 600;
  color: #a16207;
  margin-bottom: 8px;
}

.guide-list { display: flex; flex-wrap: wrap; gap: 6px; }

.guide-item {
  padding: 4px 10px;
  background: white;
  border: 1px solid #fef08a;
  border-radius: 14px;
  font-size: 12px;
  color: #a16207;
  cursor: pointer;
  transition: all 0.15s;
}

.guide-item:hover {
  background: #fef9c3;
  border-color: #facc15;
}

/* 快捷标签 */
.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.quick-tag {
  padding: 5px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.quick-tag:hover {
  background: rgba(79, 70, 229, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

/* 文档类型 Tab */
.type-tabs { display: flex; background: #f1f5f9; border-radius: 8px; padding: 3px; }

.type-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.type-tab.active {
  background: white;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.type-tab-polish { color: #ea580c; }
.type-tab-polish.active { color: #ea580c; border: 1px solid #fed7aa; }

/* 风格选择 */
.style-options { display: flex; gap: 8px; }
.style-option { flex: 1; cursor: pointer; }
.style-option input { display: none; }

.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
  text-align: center;
}

.style-option.active .style-card,
.style-option input:checked + .style-card {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.05);
}

.style-name { font-size: 14px; font-weight: 600; }
.style-desc { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* 次数显示 */
.usage-display {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
}

/* 生成按钮 */
.btn-generate {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-generate:hover { background: var(--primary-hover); }
.btn-generate:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-generate.loading { position: relative; color: transparent; }

.btn-generate.loading::after {
  content: "AI 正在生成中...";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* 右栏：结果区域 */
.result-actions { display: flex; gap: 6px; margin-left: auto; }

.result-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 200px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.result-header h2 { font-size: 16px; font-weight: 600; }

.edit-hint {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 400;
  margin-left: 8px;
}

.btn-copy {
  padding: 6px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy:hover { background: var(--primary-hover); }
.btn-copy.copied { background: #10b981; }

.btn-share {
  padding: 6px 14px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 6px;
}
.btn-share:hover {
  background: var(--primary);
  color: white;
}

.result-content {
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.9;
  max-height: 500px;
  overflow-y: auto;
  min-height: 120px;
}

.result-placeholder { color: var(--text-light); font-size: 14px; text-align: center; padding: 40px 0; }
.result-content.hidden { display: none; }
.hidden { display: none; }

/* 拆分结果区域 */
.result-split { display: flex; flex-direction: column; gap: 12px; }
.result-split.hidden { display: none; }

.split-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.split-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.split-title { font-size: 13px; font-weight: 600; color: var(--primary); }

.btn-copy-small {
  padding: 3px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy-small:hover { background: var(--primary-hover); }
.btn-copy-small.copied { background: #10b981; }

.split-content {
  padding: 14px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.9;
  min-height: 60px;
  max-height: 300px;
  overflow-y: auto;
}

/* 骨架屏加载动画 */
.result-loading {
  padding: 20px;
}
.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 10px;
}
.skeleton-line:nth-child(odd) { width: 100%; }
.skeleton-line:nth-child(even) { width: 75%; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.btn-regenerate {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-regenerate:hover { border-color: var(--primary); color: var(--primary); }
.btn-regenerate.hidden { display: none; }

/* 历史记录 */
.history-panel {
  margin-top: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.history-header {
  display: flex; align-items: center;
  padding: 12px 20px; cursor: pointer; user-select: none;
}

.history-title { font-size: 14px; font-weight: 600; }
.history-count { margin-left: 8px; font-size: 12px; color: var(--text-light); }
.history-body { padding: 0 20px 16px; }
.history-body.hidden { display: none; }
.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; background: #f8fafc; border-radius: 8px; border: 1px solid var(--border);
}

.history-info { flex: 1; min-width: 0; }
.history-meta { font-size: 11px; color: var(--text-light); margin-bottom: 2px; }
.history-summary { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-actions { display: flex; gap: 4px; margin-left: 10px; }

.history-actions button {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: white; font-size: 11px; cursor: pointer; color: var(--text-light); transition: all 0.2s;
}

.history-actions button:hover { border-color: var(--primary); color: var(--primary); }

.btn-clear-history {
  margin-top: 8px; width: 100%; padding: 6px;
  background: transparent; color: #ef4444; border: 1px solid #fecaca;
  border-radius: 6px; font-size: 12px; cursor: pointer;
}

.btn-clear-history.hidden { display: none; }

/* 底部 */
.footer { text-align: center; padding: 20px 0 12px; color: var(--text-light); font-size: 12px; }

/* 头部标签 */
.header-tags { display: flex; justify-content: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.header-tag { font-size: 13px; color: #10b981; font-weight: 500; }

/* 示例展示区 */
.demo-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.demo-header {
  display: flex; align-items: center;
  padding: 12px 20px; cursor: pointer; user-select: none;
}

.demo-title { font-size: 14px; font-weight: 600; }
.demo-hint { margin-left: 10px; font-size: 12px; color: var(--text-light); }
.demo-body { padding: 16px 20px; }
.demo-body.hidden { display: none; }

.demo-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.demo-input, .demo-output {
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.demo-arrow-right {
  font-size: 24px; color: var(--primary);
  display: flex; align-items: center; padding-top: 0;
}

.demo-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  font-size: 14px;
}
  font-size: 12px; font-weight: 600;
  color: var(--text-light); margin-bottom: 8px;
}

.demo-content {
  padding: 12px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; line-height: 1.8; white-space: pre-wrap;
}

.demo-split-preview { display: flex; flex-direction: column; gap: 8px; }

.demo-block {
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}

.demo-block-title {
  padding: 6px 12px; background: #f1f5f9;
  font-size: 12px; font-weight: 600; color: var(--primary);
  border-bottom: 1px solid var(--border);
}

.demo-block-content {
  padding: 10px 12px; font-size: 13px; line-height: 1.8;
  color: var(--text);
}

@media (max-width: 768px) {
  .demo-flow { grid-template-columns: 1fr; }
  .demo-arrow-right { display: none; }
  .header-tags { gap: 8px; }
}
.disclaimer { margin-top: 8px; font-size: 11px; color: #94a3b8; max-width: 600px; margin-left: auto; margin-right: auto; }

/* 移动端：单栏 */
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .container { padding: 12px; }
  .header h1 { font-size: 22px; }
  .header { padding: 16px 0 12px; }
  .style-options { flex-direction: column; }
  .history-item { flex-direction: column; align-items: flex-start; }
  .history-actions { margin-left: 0; margin-top: 8px; }
  .result-header { flex-wrap: wrap; gap: 8px; }
  .col-right { order: -1; }
}

/* ========== 保存设置按钮 ========== */
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.btn-save-settings {
  padding: 8px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-save-settings:hover { background: var(--primary-hover); }

/* ========== 反馈区域 ========== */
.feedback-section {
  text-align: center;
  padding: 32px 0 20px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.feedback-question {
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 14px;
}
.feedback-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.btn-feedback {
  padding: 9px 28px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-feedback:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }
.btn-feedback:disabled { opacity: 0.45; cursor: default; }
.feedback-stats {
  font-size: 13px;
  color: #10b981;
  min-height: 20px;
  margin-bottom: 8px;
}
.feedback-bad-form {
  max-width: 360px;
  margin: 10px auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feedback-bad-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  resize: none;
}
.btn-submit-bad {
  align-self: flex-end;
  padding: 6px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.feedback-thanks {
  font-size: 14px;
  color: #10b981;
  margin-top: 10px;
}
