/* ============================================
   Books Companion v2.0 · 治愈系手账风
   奶油 → 薄荷绿渐变 · 圆角卡片 · 柔和投影
   ============================================ */

:root {
  --cream:        #FAF6EC;
  --cream-deep:   #F2EAD3;
  --mint:         #E8F3E0;
  --mint-deep:    #C9E2BD;
  --sage:         #7CA982;
  --sage-deep:    #5B8C5F;
  --sage-soft:    #B6D1BA;
  --honey:        #E8C07D;
  --honey-deep:   #C9923E;
  --lavender:     #C8A2C8;
  --coral:        #E89B83;
  --soil:         #3A4A3F;
  --soil-soft:    #6B7B6F;
  --soil-light:   #A0AFA3;
  --line:         rgba(58, 74, 63, 0.10);
  --line-soft:    rgba(58, 74, 63, 0.05);
  --shadow-sm:    0 2px 8px rgba(58, 74, 63, 0.05);
  --shadow-md:    0 4px 16px rgba(58, 74, 63, 0.08);
  --shadow-lg:    0 8px 32px rgba(58, 74, 63, 0.12);

  --font-sans: "Noto Sans SC", "Outfit", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "DM Serif Display", serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", monospace;
}

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

html, body {
  background: linear-gradient(135deg, var(--cream) 0%, var(--mint) 100%);
  background-attachment: fixed;
  color: var(--soil);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(232, 192, 125, 0.08) 0%, transparent 30%),
    radial-gradient(circle at 90% 80%, rgba(200, 162, 200, 0.06) 0%, transparent 30%);
  z-index: 0;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: var(--soil); }
a { color: var(--sage-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ===== Login overlay ===== */
.overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--cream) 0%, var(--mint) 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-card {
  background: white;
  padding: 40px 36px 32px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 320px;
  text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h2 { font-family: var(--font-serif); font-size: 24px; color: var(--sage-deep); margin-bottom: 6px; }
.login-tip { color: var(--soil-soft); font-size: 13px; margin-bottom: 18px; }
.login-card input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; outline: none; margin-bottom: 14px;
  background: white;
}
.login-card input:focus { border-color: var(--sage); }
.login-card .btn { width: 100%; }
.error-msg { color: var(--coral); font-size: 12px; min-height: 16px; margin-top: 10px; }

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo {
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 600;
  color: var(--sage-deep);
  white-space: nowrap;
}
.user-indicator { font-size: 13px; color: var(--soil-soft); }
.topbar-search { flex: 1; max-width: 480px; }
.topbar-search input {
  width: 100%;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  outline: none;
}
.topbar-search input:focus { border-color: var(--sage); }
.topbar-right { display: flex; align-items: center; gap: 4px; }

.btn-mock {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: white;
  color: var(--soil);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-mock:hover { background: var(--mint); border-color: var(--mint-deep); }
.btn-mock.primary { background: var(--sage); color: white; border-color: var(--sage); }
.btn-mock.primary:hover { background: var(--sage-deep); }
.btn-mock.danger { color: var(--coral); border-color: rgba(232, 155, 131, 0.3); }
.btn-mock.danger:hover { background: rgba(232, 155, 131, 0.1); }
.btn-mock.ghost { background: transparent; border-color: transparent; }
.btn-mock.ghost:hover { background: var(--mint); }
.btn-mock.sm { padding: 5px 9px; font-size: 12px; min-width: 28px; }
.view-btn.active { background: var(--mint); border-color: var(--mint-deep); color: var(--sage-deep); }

/* ===== Mode bar (edit mode) ===== */
.mode-bar {
  background: var(--honey);
  color: #8B6520;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(139, 101, 32, 0.2);
}
.mode-hint-text { font-weight: 400; opacity: 0.7; font-size: 12px; }

/* ===== Main ===== */
#main { position: relative; z-index: 1; padding: 28px 24px 80px; max-width: 1280px; margin: 0 auto; }

/* ===== Hero / header for list ===== */
.list-hero { margin-bottom: 24px; }
.list-hero h1 {
  font-family: var(--font-serif);
  font-size: 32px; font-weight: 600;
  color: var(--soil);
  margin-bottom: 4px;
}
.list-hero p { color: var(--soil-soft); font-size: 14px; }

/* ===== Stats strip ===== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 768px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-num { font-family: var(--font-serif); font-size: 26px; font-weight: 600; color: var(--sage-deep); }
.stat-label { font-size: 12px; color: var(--soil-soft); margin-top: 2px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--mint);
  color: var(--sage-deep);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.chip:hover { background: var(--mint-deep); }
.chip.active { background: var(--sage); color: white; }
.chip.honey { background: #FBEED2; color: var(--honey-deep); }
.chip.lavender { background: #EDD9ED; color: #8C5C8C; }
.chip.outline { background: transparent; border-color: var(--line); }
.chip.outline.active { background: var(--sage); border-color: var(--sage); color: white; }
.chip.outline:hover { background: var(--mint); border-color: var(--mint-deep); }

/* ===== List view ===== */
.book-list { display: flex; flex-direction: column; gap: 10px; }

.book-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.book-row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--mint-deep); }
.book-row.editing { border-color: var(--honey); }
.book-row .mini-cover {
  width: 38px; height: 56px; flex-shrink: 0;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-serif); font-size: 18px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  background-size: cover;
  background-position: center;
}
.book-row .info { flex: 1; min-width: 0; }
.book-row .title { font-weight: 600; color: var(--soil); font-size: 14px; }
.book-row .meta {
  font-size: 12px; color: var(--soil-soft);
  margin-top: 3px;
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap;
}
.book-row .stars { color: var(--honey-deep); font-size: 13px; flex-shrink: 0; }
.book-row .row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
body.mode-edit .book-row .row-actions { opacity: 1; }
body.mode-edit .book-row { padding-right: 12px; }

/* ===== Cover view ===== */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
}
.cover-item { position: relative; }
.cover-card {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 10px;
  position: relative;
  box-shadow: var(--shadow-md);
  font-family: var(--font-serif);
  color: white;
  background-size: cover;
  background-position: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transition: all 0.2s;
  cursor: pointer;
}
.cover-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.cover-title { font-size: 13px; font-weight: 600; line-height: 1.25; }
.cover-author { font-size: 10px; opacity: 0.85; }
.cover-item .item-meta { padding: 8px 2px 0; }
.cover-item .item-meta .title { font-size: 13px; font-weight: 600; color: var(--soil); margin-bottom: 2px; }
.cover-item .item-meta .sub { font-size: 11px; color: var(--soil-soft); display: flex; gap: 6px; align-items: center; }
.cover-item .stars { color: var(--honey-deep); font-size: 11px; }
.cover-item .item-actions {
  position: absolute; top: 6px; right: 6px;
  display: none; gap: 4px;
}
body.mode-edit .cover-item .item-actions { display: flex; }
.cover-item .item-actions .btn-mock {
  background: rgba(255,255,255,0.95);
  border: none;
  padding: 4px 6px;
  font-size: 12px;
}

/* ===== Timeline view ===== */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ''; position: absolute;
  left: 11px; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--mint-deep) 0%, var(--mint) 100%);
  border-radius: 1px;
}
.timeline-year {
  position: relative;
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 600;
  color: var(--sage-deep);
  margin: 28px 0 12px;
}
.timeline-year::before {
  content: ''; position: absolute;
  left: -28px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--sage);
  z-index: 1;
  box-shadow: var(--shadow-sm);
}
.timeline-month {
  font-size: 11px;
  color: var(--soil-light);
  margin: 12px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.timeline-book {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  margin: 4px 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.timeline-book:hover { box-shadow: var(--shadow-md); border-color: var(--mint-deep); }
.timeline-book .mini-cover {
  width: 26px; height: 38px; flex-shrink: 0;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
}
.timeline-book .stars { color: var(--honey-deep); font-size: 12px; }

/* ===== Detail view ===== */
.detail-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
}
@media (max-width: 768px) { .detail-page { grid-template-columns: 1fr; } }

.detail-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--soil-soft);
  font-size: 13px;
  margin-bottom: 16px;
  cursor: pointer;
}
.detail-back:hover { color: var(--sage-deep); }

.detail-side .cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 8px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background: var(--sage);
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-serif); font-size: 64px; font-weight: 600;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.detail-side .side-meta { font-size: 13px; }
.detail-side .side-meta dt { font-weight: 600; color: var(--soil); margin-top: 10px; }
.detail-side .side-meta dd { margin: 2px 0 0; color: var(--soil-soft); }
.detail-side .side-meta .stars { color: var(--honey-deep); font-size: 15px; }

.detail-main h2 {
  font-family: var(--font-serif);
  font-size: 28px; font-weight: 600;
  color: var(--soil);
  margin-bottom: 6px;
}
.detail-main .author { color: var(--soil-soft); font-size: 15px; margin-bottom: 14px; }
.detail-main .tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--soil-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--sage-deep); border-bottom-color: var(--sage); font-weight: 500; }
.tab:hover:not(.active) { color: var(--soil); }

.note-block {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 14px;
}
.note-block h4 {
  font-family: var(--font-serif);
  font-size: 15px; color: var(--sage-deep);
  margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.note-block h4 .edit-note { font-size: 12px; color: var(--soil-light); cursor: pointer; }
.note-block h4 .edit-note:hover { color: var(--sage-deep); }
.note-block p, .note-block .note-content {
  font-size: 14px; color: var(--soil); line-height: 1.75;
  white-space: pre-wrap;
  font-family: var(--font-serif);
}
.note-block.empty .note-content { color: var(--soil-light); font-style: italic; }
.note-block textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  resize: vertical;
  font-family: var(--font-serif);
}

/* ===== Stats view ===== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 768px) { .stats-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.chart-card h3 {
  font-family: var(--font-serif);
  font-size: 15px; color: var(--sage-deep);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 6px;
}
.bar-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.bar-row .bar-label { width: 100px; color: var(--soil-soft); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; height: 14px; background: var(--cream-deep); border-radius: 7px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 7px; transition: width 0.3s; }
.bar-row .bar-val { width: 40px; text-align: right; color: var(--soil-soft); flex-shrink: 0; }

/* ===== Cover manager ===== */
.cover-mgr {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cover-mgr-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.cover-mgr-progress {
  height: 6px; background: var(--cream-deep); border-radius: 3px; margin-top: 12px; overflow: hidden;
}
.cover-mgr-progress-fill { height: 100%; background: var(--sage); border-radius: 3px; transition: width 0.3s; }
.cover-mgr-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.cover-mgr-row:hover { background: var(--cream); }
.cover-mgr-row .mini-cover {
  width: 30px; height: 44px; border-radius: 3px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-serif); font-size: 16px; font-weight: 600;
}
.cover-mgr-row .info { flex: 1; }
.cover-mgr-row .info .t { font-size: 13px; font-weight: 500; }
.cover-mgr-row .info .a { font-size: 11px; color: var(--soil-soft); }
.cover-mgr-row .actions { display: flex; gap: 6px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(58, 74, 63, 0.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-family: var(--font-serif); font-size: 18px; color: var(--soil); }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px; color: var(--soil-soft);
  margin-bottom: 4px;
  font-weight: 500;
}
.field label .req { color: var(--coral); }
.input-mock {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  outline: none;
  font-family: inherit;
  color: var(--soil);
}
.input-mock:focus { border-color: var(--sage); }
.input-row { display: flex; gap: 6px; }
.input-row .input-mock { flex: 1; }
.callout-inline {
  background: var(--mint);
  border-left: 3px solid var(--sage);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--soil);
  margin-bottom: 16px;
}
.callout-inline strong { color: var(--sage-deep); }
.lookup-status { font-size: 12px; margin-top: 6px; min-height: 16px; }
.lookup-status.success { color: var(--sage-deep); }
.lookup-status.error { color: var(--coral); }
.rating-input {
  font-size: 22px;
  color: var(--honey-deep);
  cursor: pointer;
  user-select: none;
  letter-spacing: 2px;
  padding: 4px 0;
}

/* ===== Command palette ===== */
.cmd-overlay {
  position: fixed; inset: 0;
  background: rgba(58, 74, 63, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
  z-index: 200;
}
.cmd-box {
  width: 580px; max-width: 90%;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 70vh;
  display: flex; flex-direction: column;
}
.cmd-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 15px;
  border: none;
  border-bottom: 1px solid var(--line);
  font-family: inherit;
  outline: none;
  background: white;
}
.cmd-list { padding: 6px; overflow-y: auto; }
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.cmd-item.active, .cmd-item:hover { background: var(--mint); }
.cmd-item .cmd-desc { color: var(--soil-light); font-size: 12px; }
.cmd-item .kbd { margin-left: auto; font-size: 11px; color: var(--soil-light); font-family: var(--font-mono); }
.cmd-empty { padding: 20px; text-align: center; color: var(--soil-light); font-size: 13px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--sage-deep);
  color: white;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--coral); }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--soil-soft);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .title { font-family: var(--font-serif); font-size: 18px; color: var(--soil); margin-bottom: 6px; }
.empty-state .hint { font-size: 13px; }

/* ===== Rating star picker ===== */
.star-pick { display: inline-block; cursor: pointer; font-size: 24px; color: var(--honey-deep); }
.star-pick .s { user-select: none; }
.star-pick .s.off { color: var(--soil-light); }

/* ===== Edit mode badges ===== */
.edit-only { display: none; }
body.mode-edit .edit-only { display: inline-flex; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .topbar-search { max-width: 100%; order: 99; flex: 0 0 100%; }
  .topbar-right .btn-mock.sm { padding: 4px 7px; font-size: 11px; }
  #main { padding: 16px 12px 80px; }
  .list-hero h1 { font-size: 24px; }
  .stat-num { font-size: 22px; }
  .book-row { padding: 10px 12px; }
  .book-row .mini-cover { width: 30px; height: 44px; font-size: 14px; }
}
