:root {
  --primary: #2563eb; --primary-hover: #1d4ed8; --bg: #f0f4f8; --card: #fff;
  --text: #0f172a; --text-light: #64748b; --border: #e2e8f0; --user-bg: #dbeafe;
  --ai-bg: #f8fafc; --success: #10b981; --error: #ef4444; --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; padding: 20px; min-height: 100vh; }
.app-wrapper { max-width: 850px; margin: 0 auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-height: 80vh; }
.app-header { padding: 24px; background: linear-gradient(135deg, #eff6ff 0%, #fff 100%); border-bottom: 1px solid var(--border); }
h1 { font-size: 1.75rem; margin-bottom: 10px; font-weight: 700; }
.model-badge { display: inline-flex; align-items: center; gap: 8px; background: #f1f5f9; padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; color: var(--text-light); border: 1px solid var(--border); margin-bottom: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-light); animation: pulse 2s infinite; }
.model-badge.active { background: #ecfdf5; color: var(--success); border-color: #a7f3d0; }
.model-badge.active .dot { background: var(--success); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.guide { color: var(--text-light); font-size: 0.95rem; }
.app-main { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.input-panel { background: #f8fafc; padding: 16px; border-radius: 12px; border: 1px solid var(--border); }
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.95rem; }
input, textarea, select { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; transition: .2s; background: #fff; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
textarea { min-height: 90px; resize: vertical; margin-top: 12px; margin-bottom: 12px; }
.options-row { display: flex; gap: 10px; margin-bottom: 8px; }
.btn-group { display: flex; gap: 10px; margin-top: 4px; }
button, select { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: 500; cursor: pointer; transition: .2s; font-size: 1rem; }
#sendBtn { background: var(--primary); color: #fff; }
#sendBtn:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
#sendBtn:disabled { background: #94a3b8; cursor: not-allowed; }
.secondary { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }
.secondary:hover { background: #e2e8f0; }
.chat-container { flex: 1; display: flex; flex-direction: column; }
.chat-box { flex: 1; background: #fafbfc; border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 280px; max-height: 450px; }
.message { padding: 14px; border-radius: 10px; max-width: 85%; word-break: break-word; line-height: 1.55; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.user { align-self: flex-end; background: var(--user-bg); border-bottom-right-radius: 2px; }
.assistant { align-self: flex-start; background: var(--ai-bg); border-bottom-left-radius: 2px; }
.meta-box { margin-top: 8px; padding: 8px 12px; background: #f8fafc; border-radius: 8px; border: 1px dashed var(--border); font-size: 0.8rem; color: var(--text-light); display: flex; gap: 12px; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 4px; }
.export-bar { margin-top: 12px; padding: 10px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.export-bar button { background: var(--success); color: #fff; flex: none; padding: 8px 14px; font-size: 0.9rem; }
.export-bar button:hover { background: #059669; }
.export-bar .tip { font-size: 0.85rem; color: #166534; margin-left: auto; }
.error-msg { color: var(--error); font-size: 0.9rem; text-align: center; min-height: 20px; margin-top: 8px; }
.app-footer { padding: 16px; text-align: center; font-size: 0.8rem; color: var(--text-light); border-top: 1px solid var(--border); background: #f8fafc; }
@media (max-width: 600px) {
  body { padding: 10px; } .app-wrapper { border-radius: 12px; } h1 { font-size: 1.4rem; }
  .chat-box { min-height: 200px; max-height: 350px; } .options-row, .btn-group, .export-bar { flex-direction: column; }
  .export-bar .tip { margin-left: 0; }
}
