/* ===== 变量 ===== */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #8b5cf6;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(99,102,241,0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 60px;
  --input-h: 80px;
  --sidebar-w: 320px;
}

/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, textarea { font-family: inherit; outline: none; border: none; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  transition: opacity 0.2s;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 36px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-icon { font-size: 40px; margin-bottom: 16px; }
.modal-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.modal-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }

.modal-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
  margin-bottom: 8px;
}
.modal-box input:focus { border-color: var(--primary); }
.modal-error { font-size: 13px; color: #ef4444; min-height: 20px; margin-bottom: 12px; }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

/* ===== Header ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }

.header-right { display: flex; gap: 8px; }
.btn-icon {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.btn-icon svg { width: 15px; height: 15px; }
.btn-icon:hover { background: var(--primary-light); color: var(--primary); }

/* ===== 主布局 ===== */
.main {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 0;
  height: 100vh;
  padding-top: var(--header-h);
}

/* ===== 对话区 ===== */
.chat-section {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 16px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* 消息气泡 */
.message { display: flex; gap: 12px; max-width: 100%; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.message.user { flex-direction: row-reverse; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}
.message.ai .avatar { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.message.user .avatar { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.7;
}
.message.ai .bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.message.user .bubble {
  background: var(--primary);
  color: white;
  border-top-right-radius: 4px;
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 600; }
.bubble code {
  background: rgba(99,102,241,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', monospace;
}
.message.user .bubble code { background: rgba(255,255,255,0.2); }

/* 打字动画 */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* 输入区 */
.input-wrap {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--card);
}

.input-box {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14.5px;
  resize: none;
  max-height: 140px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
  line-height: 1.5;
}
.input-box:focus { border-color: var(--primary); }
.input-box::placeholder { color: var(--text-muted); }

.btn-send {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}
.btn-send svg { width: 17px; height: 17px; }
.btn-send:hover { background: var(--primary-hover); }
.btn-send:active { transform: scale(0.94); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* ===== 右侧边栏 ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: 20px 16px;
  background: var(--bg);
  gap: 14px;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

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

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.card-title { font-size: 13.5px; font-weight: 600; color: var(--text); }

/* Prompt 预览 */
.preview-card { flex: 1; min-height: 200px; display: flex; flex-direction: column; }

.prompt-content {
  flex: 1;
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 150px;
  max-height: 320px;
  overflow-y: auto;
}
.prompt-content::-webkit-scrollbar { width: 3px; }
.prompt-content::-webkit-scrollbar-thumb { background: var(--border); }

.placeholder-text {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
  line-height: 2;
}

.btn-copy {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  transition: background 0.15s;
}
.btn-copy:hover:not(:disabled) { background: var(--primary); color: white; }
.btn-copy:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-copy.copied { background: var(--success-bg); color: var(--success); }

.score { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* 清单 */
.checklist { list-style: none; padding: 8px 0; }
.checklist li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  transition: background 0.15s;
}
.checklist li:hover { background: var(--bg); }

.check-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: all 0.3s;
}
.checklist li.done .check-icon {
  background: var(--success);
  border-color: var(--success);
  color: white;
  content: '✓';
}
.check-label { font-size: 13px; color: var(--text-muted); transition: color 0.2s; }
.checklist li.done .check-label { color: var(--text); font-weight: 500; }

/* ===== 空状态 ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}
.empty-state .emoji { font-size: 48px; margin-bottom: 8px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 14px; line-height: 1.6; max-width: 300px; }
.examples { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; width: 100%; max-width: 340px; }
.example-btn {
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.example-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .chat-section { border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar { flex-direction: row; padding: 12px; overflow-x: auto; overflow-y: hidden; gap: 12px; }
  .sidebar .card { min-width: 280px; }
  .preview-card { min-height: auto; }
}
