:root {
  --bg: #faf7f2;
  --panel: #fffdf9;
  --ink: #2b2724;
  --ink-2: #6b6259;
  --ink-3: #9c9187;
  --line: #e8e0d4;
  --accent: #8c5a34;
  --accent-soft: #f3e7da;
  --danger: #b4432f;
  --shadow: 0 1px 2px rgba(60,45,30,.06), 0 8px 24px rgba(60,45,30,.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 100; padding: 20px;
}
.login-card {
  width: 100%; max-width: 330px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: 2px; }
.login-sub { margin: 0 0 22px; color: var(--ink-3); font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; outline: none; margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 11px;
  border: 0; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-weight: 500; cursor: pointer;
}
.login-card button:disabled { opacity: .6; cursor: default; }
.login-err { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(250,247,242,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 14px; font-weight: 600;
}
.brand-text { font-weight: 600; letter-spacing: .5px; }
.search-wrap { flex: 1; max-width: 460px; }
.search-wrap input {
  width: 100%; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 20px;
  background: #fff; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.icon-btn {
  margin-left: auto; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 20px;
  background: #fff; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 55px);
}

/* ---------- 侧栏 ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px 14px 40px;
  background: rgba(255,253,249,.6);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 10px;
}
.side-head h2 { margin: 0; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.count {
  display: inline-block; margin-left: 4px; padding: 0 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 9px; font-size: 11px; font-weight: 500;
}
.btn-sm {
  padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink-2);
  font-size: 12px; cursor: pointer;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.book-list { list-style: none; margin: 0; padding: 0; }
.book-item {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 9px 10px; border-radius: 9px;
  cursor: pointer; margin-bottom: 2px;
}
.book-item:hover { background: #f6efe5; }
.book-item.active { background: var(--accent-soft); }
.book-item.active .bi-title { color: var(--accent); font-weight: 600; }
.bi-main { flex: 1; min-width: 0; }
.bi-title {
  display: block; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bi-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.bi-n {
  flex: none; font-size: 11px; color: var(--ink-3);
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 0 5px; margin-top: 2px;
}
.dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 5px; vertical-align: 1px;
}
.dot.reading { background: #d98b3a; }
.dot.done { background: #6f9c72; }
.dot.want { background: #bfb5a8; }

/* ---------- 内容区 ---------- */
.content { padding: 22px 26px 60px; min-width: 0; }
.content-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 4px;
}
.content-head h2 { margin: 0; font-size: 19px; }
.content-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.btn-primary {
  padding: 8px 18px; border: 0; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { background: #7a4c2b; }
.btn-ghost {
  padding: 8px 18px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink-2); cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink-3); }

/* 标签栏 */
.tag-bar { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 6px; }
.tag-chip {
  padding: 3px 11px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink-2);
  font-size: 12.5px; cursor: pointer;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 笔记卡片 ---------- */
.note-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.note-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.note-card:hover { box-shadow: var(--shadow); border-color: #ddd2c2; }
.nc-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.nc-title {
  margin: 0; font-size: 15.5px; font-weight: 600;
  line-height: 1.45; color: var(--ink);
}
.nc-book {
  font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px; padding: 1px 7px;
  white-space: nowrap;
}
.nc-page { font-size: 11.5px; color: var(--ink-3); }
.nc-body {
  margin: 0;
  font-size: 14.5px;
  color: #403a34;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.nc-body.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nc-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--ink-3);
  flex-wrap: wrap;
}
.nc-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.nc-tag { color: var(--ink-3); }
.nc-tag::before { content: '#'; opacity: .6; }
.nc-actions { margin-left: auto; display: flex; gap: 4px; }
.link-btn {
  border: 0; background: none; padding: 2px 6px;
  color: var(--ink-3); font-size: 12px;
  cursor: pointer; border-radius: 5px;
}
.link-btn:hover { color: var(--accent); background: var(--accent-soft); }
.link-btn.danger:hover { color: var(--danger); background: #fbece8; }

/* 空状态 */
.empty {
  padding: 60px 20px; text-align: center; color: var(--ink-3);
  font-size: 14px;
}
.empty-big { font-size: 34px; margin-bottom: 10px; opacity: .35; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(43,39,36,.32);
  backdrop-filter: blur(2px);
  padding: 20px;
  overflow-y: auto;
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: 0 20px 60px rgba(43,39,36,.22);
}
.modal-card.wide { max-width: 660px; }
.modal-card h3 { margin: 0 0 18px; font-size: 17px; }
.modal-card label {
  display: block; margin-bottom: 13px;
  font-size: 12.5px; color: var(--ink-2);
}
.modal-card input, .modal-card select, .modal-card textarea {
  display: block; width: 100%;
  margin-top: 5px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none;
}
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus {
  border-color: var(--accent);
}
.modal-card textarea { resize: vertical; line-height: 1.6; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translateX(-50%);
  padding: 9px 20px;
  background: rgba(43,39,36,.9);
  color: #fff; font-size: 13.5px;
  border-radius: 20px;
  z-index: 200;
  pointer-events: none;
}

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .brand-text { display: none; }
  .search-wrap { order: 3; width: 100%; max-width: none; flex-basis: 100%; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    max-height: 190px;
    overflow-y: auto;
  }
  .book-list { display: flex; gap: 8px; overflow-x: auto; }
  .book-item {
    flex: none; max-width: 190px;
    border: 1px solid var(--line); background: #fff;
  }
  .bi-n { display: none; }
  .content { padding: 16px 14px 60px; }
  .row2 { grid-template-columns: 1fr; }
  .modal-card { padding: 20px 18px; }
  .note-card { padding: 14px; }
}
