/* ============================================
   自卑与超越 · 读书对话录 — 样式表
   ============================================ */

:root {
  --bg: #faf7f2;
  --bg-card: #ffffff;
  --bg-sidebar: #f3ede4;
  --bg-hover: #f5efe6;
  --bg-input: #faf6f0;
  --text-primary: #2c2420;
  --text-secondary: #6b5d54;
  --text-muted: #a89b90;
  --accent: #8b6f47;
  --accent-hover: #745939;
  --accent-light: #c4a882;
  --accent-bg: #f5ede0;
  --accent-border: #e0d0b8;
  --border: #e5ddd2;
  --border-light: #f0eae0;
  --danger: #c0524a;
  --danger-bg: #fdf0ee;
  --success: #5a8a6a;
  --shadow-sm: 0 1px 3px rgba(44, 36, 32, 0.05);
  --shadow: 0 2px 8px rgba(44, 36, 32, 0.06);
  --shadow-md: 0 4px 16px rgba(44, 36, 32, 0.08);
  --shadow-lg: 0 12px 32px rgba(44, 36, 32, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-w: 260px;
}

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

html, body {
  height: 100%;
  font-family: var(--sans);
  color: var(--text-primary);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 28px 24px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
}

.logo-text h1 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-text p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 8px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* ============================================
   Main content
   ============================================ */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.page-header {
  padding: 36px 48px 24px;
  border-bottom: 1px solid var(--border-light);
}

.page-header h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-secondary);
  margin-top: 6px;
  font-size: 14px;
}

.page-body {
  padding: 32px 48px 64px;
  max-width: 820px;
}

/* ============================================
   Dashboard — Note cards
   ============================================ */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.note-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.note-card .quote-text {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card .quote-text::before {
  content: '"';
  font-family: var(--serif);
  font-size: 28px;
  color: var(--accent-light);
  margin-right: 4px;
  vertical-align: -6px;
}

.note-card .reflection-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card .note-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.note-card .meta-chip {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.note-card .dialogue-badge {
  position: absolute;
  top: 20px;
  right: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 24px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.15s ease;
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
}

.quote-textarea {
  font-family: var(--serif);
  font-size: 15px;
  min-height: 120px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

/* ============================================
   Note Detail
   ============================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  transition: color 0.15s;
  background: none;
  border: none;
  font-family: var(--sans);
}

.back-link:hover {
  color: var(--accent);
}

.detail-quote {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  position: relative;
}

.detail-quote .quote-mark {
  font-family: var(--serif);
  font-size: 64px;
  color: var(--accent-light);
  opacity: 0.3;
  position: absolute;
  top: 8px;
  left: 20px;
  line-height: 1;
}

.detail-quote .quote-body {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 2;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.detail-quote .quote-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-muted);
}

.detail-section {
  margin-bottom: 32px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

.reflection-box {
  background: var(--accent-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
}

/* ============================================
   Dialogue
   ============================================ */
.dialogue-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.dialogue-header {
  padding: 18px 24px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialogue-header h3 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialogue-header .dialogue-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.dialogue-body {
  padding: 24px;
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialogue-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.dialogue-empty p {
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.8;
}

.msg {
  display: flex;
  gap: 12px;
  max-width: 88%;
  animation: fadeInUp 0.3s ease;
}

.msg.user {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.msg.assistant .msg-avatar {
  background: var(--accent);
  color: #fff;
}

.msg.user .msg-avatar {
  background: var(--accent-light);
  color: #fff;
}

.msg-bubble {
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.75;
}

.msg.assistant .msg-bubble {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  font-family: var(--sans);
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-light);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.dialogue-input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: var(--bg-input);
}

.dialogue-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.dialogue-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.6;
  outline: none;
  transition: border-color 0.15s;
}

.dialogue-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.08);
}

.dialogue-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.dialogue-send:hover { background: var(--accent-hover); }
.dialogue-send:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* ============================================
   Settings
   ============================================ */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.settings-card h3 {
  font-family: var(--serif);
  font-size: 17px;
  margin-bottom: 6px;
}

.settings-card .card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.preset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-input);
}

.preset-card:hover {
  border-color: var(--accent-border);
  background: var(--bg-hover);
}

.preset-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.preset-card .preset-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.preset-card .preset-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--text-primary); color: #fff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-header { padding: 20px 10px; }
  .logo-text { display: none; }
  .nav-item span { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-footer { display: none; }
  .page-header { padding: 24px 20px 16px; }
  .page-body { padding: 20px 20px 48px; }
  .form-row { flex-direction: column; }
  .stats-row { flex-direction: column; }
}
