:root {
  --bg: #f6f1e7;
  --bg-card: #fffdf8;
  --ink: #2f2a24;
  --ink-soft: #7a7060;
  --accent: #a65d2c;
  --accent-dark: #8a4b20;
  --line: #e8e0d0;
  --danger: #b3402f;
  --shadow: 0 2px 10px rgba(60, 45, 20, 0.08);
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 32px; }
.brand h1 { font-size: 20px; font-family: Georgia, "Songti SC", serif; }
.tagline { font-size: 12px; color: var(--ink-soft); }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  border: none; background: transparent; padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--ink-soft);
}
.tab.active { background: var(--bg-card); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.container { max-width: 1080px; margin: 24px auto; padding: 0 24px; }
.view { display: none; }
.view.active { display: block; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--ink-soft); font-size: 13px; }

select, input, textarea {
  font-family: inherit; font-size: 14px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-card); color: var(--ink);
}
select:focus, input:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent;
}
textarea { resize: vertical; width: 100%; }

.btn {
  border: 1px solid var(--line); background: var(--bg-card); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.book-card {
  background: var(--bg-card); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.book-cover {
  height: 130px; display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 4px; color: #fff; padding: 16px; text-align: center;
}
.cover-title { font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 700; }
.cover-author { font-size: 12px; opacity: 0.85; }
.book-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.book-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; background: var(--bg); color: var(--ink-soft); padding: 2px 8px; border-radius: 999px; }
.chip-status { background: #eef3ea; color: #4e6e52; }
.rating { font-size: 12px; color: #d19a2e; letter-spacing: 1px; }
.book-title { font-size: 15px; font-family: Georgia, "Songti SC", serif; }
.book-note { font-size: 13px; color: var(--ink-soft); flex: 1; }
.book-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.count { color: var(--ink-soft); }

.actions { display: flex; gap: 10px; }
.link-btn { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 13px; }
.link-btn.danger { color: var(--danger); }

.notes-list, .memos-list { display: flex; flex-direction: column; gap: 12px; }
.note-card, .memo-card { background: var(--bg-card); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.note-book { font-weight: 600; color: var(--accent); }
.note-date, .memo-date { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.note-content, .memo-content { font-size: 14px; white-space: pre-wrap; }
.note-foot, .memo-foot { margin-top: 10px; text-align: right; }
.memo-card { border-left: 3px solid var(--accent); }

.empty {
  text-align: center; color: var(--ink-soft); padding: 60px 20px;
  background: var(--bg-card); border-radius: 12px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(40, 30, 15, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card); border-radius: 14px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-family: Georgia, "Songti SC", serif; }
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.modal-body { padding: 20px; }
.modal-body form { display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.modal-body .row { display: flex; gap: 12px; }
.modal-body .row label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 600px) {
  .topbar-inner { padding: 12px 16px; }
  .container { padding: 0 16px; }
  .books-grid { grid-template-columns: 1fr 1fr; }
  .modal-body .row { flex-direction: column; }
}
