/* ============================================================
   QuantumRead — 全局样式
   ============================================================ */

/* 1. Reset & Variables */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-sans: 'Inter', -apple-system, 'PingFang SC', 'Noto Sans CJK SC', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-hover: #F8FAFC;
  --border: #E4E8EF;
  --border-light: #F1F4F9;

  --text-primary: #0F1923;
  --text-secondary: #4B5563;
  --text-tertiary: #9CA3AF;

  --accent: #2563EB;
  --accent-light: #EFF6FF;
  --accent-hover: #1D4ED8;

  --success: #059669;
  --success-light: #ECFDF5;
  --error: #DC2626;
  --error-light: #FEF2F2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.06);

  --nav-h: 64px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* 2. Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
}

.nav-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.3px;
  color: var(--text-primary);
}

.nav-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all .15s;
}

.nav-link:hover { color: var(--text-primary); background: var(--border-light); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }

.nav-settings {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: all .15s;
}
.nav-settings:hover { background: var(--border-light); color: var(--text-primary); }

/* 3. Page System */
.page { display: none; min-height: calc(100vh - var(--nav-h)); }
.page.active { display: block; }

/* 4. ============================================================
      HOME PAGE
   ============================================================ */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
  max-width: 680px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #BFDBFE;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -.8px;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.hero h1 .accent { color: var(--accent); }

.hero-sub {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 40px;
}

/* Generator */
.generator {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  max-width: 600px;
  margin: 0 auto 60px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.input-field::placeholder { color: var(--text-tertiary); }
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.btn-generate {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-generate:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-generate:active:not(:disabled) { transform: translateY(0); }
.btn-generate:disabled { opacity: .6; cursor: not-allowed; }

/* Generate Loading */
.generate-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0 4px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.generate-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.generate-scope-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  text-align: center;
  line-height: 1.6;
}

/* Settings Modal — 当前模型状态 */
.settings-current-model {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

/* Settings Modal — 折叠区 */
.settings-collapse-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.settings-collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 0;
}

.settings-collapse-toggle:hover {
  color: var(--accent);
}

.settings-collapse-body {
  padding-bottom: 4px;
}

/* Featured / Hot Books */
.section-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

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

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.section-link {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.section-link:hover { text-decoration: underline; }

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* 5. ============================================================
      BOOK CARD
   ============================================================ */
.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all .18s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.book-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.book-icon {
  font-size: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.book-meta-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.book-title-card {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-author-card {
  font-size: 13px;
  color: var(--text-secondary);
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}

.tag-gray {
  background: var(--border-light);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.book-oneliner {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.book-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.view-count {
  font-size: 12px;
  color: var(--text-tertiary);
}

.card-actions {
  display: flex;
  gap: 6px;
}

.btn-card {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: all .15s;
}

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

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

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

/* 6. ============================================================
      LIBRARY PAGE
   ============================================================ */
.library-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 32px 24px 24px;
}

.library-header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.library-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
}

.library-search-wrap {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

#library-search {
  flex: 1;
}

.library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

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

.filter-btn {
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
}

.filter-btn:hover { background: var(--bg); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.library-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.library-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

#library-count {
  font-size: 13px;
  color: var(--text-tertiary);
}

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

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { margin-bottom: 20px; }

/* 7. ============================================================
      BOOK DETAIL PAGE
   ============================================================ */
.book-detail-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

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

.back-link {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.back-link:hover { color: var(--text-primary); }

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
}
.btn-action:hover { background: var(--bg); color: var(--text-primary); border-color: #CBD5E1; }

/* Detail Article */
.detail-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 56px);
  box-shadow: var(--shadow-sm);
  max-width: 720px;
  margin: 0 auto;
}

.detail-title-block {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.detail-title-block h1 {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 12px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-meta span { display: flex; align-items: center; }

.oneliner-block {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 32px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-hover);
  line-height: 1.6;
}

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

.detail-section h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-section > p {
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 14px;
}

/* Argument Path — natural prose style */
.argument-prose {
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

/* Legacy arrow style (kept for backward compat) */
.argument-path {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  line-height: 1.6;
}

.arg-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.arg-arrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  align-self: center;
}

/* Structure list */
.structure-list li {
  padding: 8px 12px;
  border-left: 2px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  transition: border-color .15s;
}
.structure-list li:hover { border-left-color: var(--accent); }

/* Core Points */
.core-points {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.core-point {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.core-point h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.point-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.point-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.point-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  align-items: flex-start;
}

.point-label {
  flex-shrink: 0;
  width: 36px;
  padding: 2px 6px;
  background: var(--border-light);
  color: var(--text-tertiary);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  margin-top: 1px;
}

.insight-row { padding-top: 10px; border-top: 1px solid var(--border-light); }
.insight-label { background: #FEF3C7; color: #B45309; }

.extra-concepts {
  margin-top: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.extra-concepts h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.extra-concepts li {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.6;
}

.extra-concepts li strong { color: var(--text-primary); }

/* Questions */
.questions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.q-num {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

/* Further Reading */
.further-list li {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.65;
}
.further-list li strong { color: var(--text-primary); }

/* Reading Advice */
.reading-advice {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.reading-advice p { font-size: 13px; color: var(--text-secondary); line-height: 1.75; }
.advice-specific { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-light); }

/* Disclaimer */
.disclaimer-block {
  margin-top: 36px;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.7;
}
.model-info { margin-top: 6px; }

.page-footer-brand {
  text-align: center;
  margin-top: 28px;
  padding: 16px;
  font-size: 12px;
  color: #9CA3AF;
  font-weight: 500;
}

/* 8. ============================================================
      SETTINGS MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

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

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

.form-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 5px;
  line-height: 1.5;
}

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.btn-cancel {
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all .15s;
}
.btn-cancel:hover { background: var(--border-light); }

.btn-save {
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: all .15s;
}
.btn-save:hover { background: var(--accent-hover); }

/* Primary button (misc) */
.btn-primary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* 9. Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: #059669; }
.toast-error { background: #DC2626; }

/* 10. Footer */
.footer {
  border-top: 1px solid var(--border-light);
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.footer a { color: var(--text-tertiary); }
.footer a:hover { color: var(--text-secondary); }

/* 11. Responsive */
@media (max-width: 640px) {
  .hero { padding: 48px 16px 40px; }
  .generator { padding: 20px 16px; }
  .section-wrap { padding: 0 16px 60px; }
  .books-grid { grid-template-columns: 1fr; }
  .library-header { padding: 24px 16px 20px; }
  .library-body { padding: 20px 16px 60px; }
  .book-detail-wrap { padding: 20px 16px 60px; }
  .detail-article { padding: 20px 16px; }
  .detail-header { flex-direction: column; align-items: flex-start; }
  .detail-actions { width: 100%; justify-content: flex-start; }
  .argument-path { flex-direction: column; }
  .modal { padding: 24px 20px; }
  .nav-inner { padding: 0 16px; }
}
