:root {
  --ink: #43372C;            /* 主文字 · 深可可棕 */
  --accent: #BC7A50;         /* 强调 · 陶土橘 */
  --accent-deep: #A86A42;    /* 强调深 · hover */
  --accent-soft: #F0E3D5;    /* 强调浅 · 底色 */
  --gold: #E2C38F;           /* 点缀 · 浅金 */
  --bg: #F9F3EB;             /* 页面背景 · 暖奶白 */
  --card: #FFFDF9;           /* 卡片 */
  --border: #E7D9C9;         /* 边框 · 奶油棕 */
  --border-soft: #F0E6D8;    /* 更浅的边框 */
  --text: #43372C;
  --muted: #8A7C6C;
  --danger: #C0532F;
  --ok: #7A8F6E;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 6px 24px rgba(188, 122, 80, .10);
}

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

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* 顶栏：暖奶咖渐变 + 浅金细线点缀 */
.topbar {
  background: linear-gradient(135deg, #F2E6D4 0%, #F7EEDF 55%, #F4E9D7 100%);
  color: var(--ink);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 2px 18px rgba(188, 122, 80, .08);
}
.brand { display: flex; align-items: center; gap: 10px; position: relative; }
.logo {
  font-size: 26px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: #FFFDF9;
  border-radius: 13px;
  box-shadow: 0 2px 8px rgba(188,122,80,.18);
  border: 1px solid var(--border-soft);
}
.brand-text { font-size: 20px; font-weight: 700; letter-spacing: 1px; color: var(--ink); }
.brand-sub { font-size: 12px; opacity: .7; color: var(--muted); margin-left: 6px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.req-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  background: #C9583E;
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
}
.stat { font-size: 14px; color: var(--muted); }
.user-badge {
  font-size: 12px;
  color: var(--accent);
  background: rgba(255,253,249,.6);
  border: 1px solid #E8D8BC;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}

/* 账号管理 */
.user-create {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  background: rgba(255,253,249,.7);
  border: 1px dashed var(--border);
  border-radius: 14px;
  margin-bottom: 6px;
}
.user-create input, .user-create select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: #FFFDF9;
  color: var(--ink);
}
.user-create .btn { align-self: end; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th {
  text-align: left; padding: 8px 6px; color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--border); font-size: 12px;
}
.user-table td { padding: 8px 6px; border-bottom: 1px solid rgba(214,199,174,.4); vertical-align: middle; }
.user-table .role-select, .user-table .expire-input {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; font-family: inherit; background: #FFFDF9; color: var(--ink);
}

/* 按钮：柔和圆角 */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all .18s ease;
  font-weight: 600;
}
.btn-primary {
  background: linear-gradient(135deg, #C9875B, var(--accent));
  color: #FFFDF9;
  box-shadow: 0 3px 10px rgba(188,122,80,.25);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(188,122,80,.3); }
.btn-ghost { background: rgba(255,253,249,.6); border: 1px solid #DCC9AD; color: var(--ink); }
.btn-ghost:hover { background: #FFFDF9; border-color: var(--gold); }
.btn-danger { background: var(--danger); color: #FFFDF9; font-size: 12px; padding: 5px 12px; border-radius: 999px; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { font-size: 12px; padding: 6px 14px; }
.btn-login { background: rgba(255,253,249,.55); border-color: #DCC9AD; color: var(--ink); }
.btn-login:hover { background: #FFFDF9; border-color: var(--gold); }

/* 筛选栏 */
.filters {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  flex-wrap: wrap;
  align-items: center;
}
.search-box {
  flex: 1;
  min-width: 220px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,195,143,.22); }
.filter-select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--gold); }

/* 编辑表单：单列 */
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-stack input, .form-stack select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #FFFDF9;
  color: var(--ink);
}
.form-stack input:focus, .form-stack select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(188,122,80,.12); }

/* AI 智能填表 */.ai-box {
  background: linear-gradient(135deg, rgba(188,122,80,.08), rgba(226,195,143,.10));
  border: 1px dashed rgba(188,122,80,.45);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.ai-box-head { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.ai-box-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* 书架 */
#bookshelf { display: block; width: 100%; }
.lib-section { margin-bottom: 10px; }
.lib-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 26px 6px;
}
.lib-badge {
  background: linear-gradient(135deg, #C9875B, var(--accent));
  color: #FFFDF9;
  font-size: 14px;
  font-weight: 700;
  width: 34px; height: 34px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(188,122,80,.25);
}
.lib-name { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: .5px; }
.lib-count { font-size: 12px; color: var(--muted); background: #F4E9D8; padding: 3px 10px; border-radius: 999px; }
.bookshelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 20px;
  padding: 10px 24px 30px;
}
.book-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-soft);
  transition: transform .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
}
.book-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-soft); }
.cover-wrap {
  aspect-ratio: 3/4;
  background: linear-gradient(150deg, #F4E9D6, #EADBC2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { font-size: 42px; opacity: .45; }
.copyright-badge {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #FFFDF9;
  font-weight: 600;
  letter-spacing: .3px;
  box-shadow: 0 2px 6px rgba(67,55,44,.18);
}
.copyright-badge.own { background: rgba(122,143,110,.92); }
.copyright-badge.public { background: rgba(110,96,80,.85); }
.copyright-badge.personal { background: rgba(192,83,47,.9); }
.book-info { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.book-title { font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { font-size: 12px; color: var(--muted); }
.book-cat { font-size: 11px; color: var(--accent); font-weight: 600; margin-top: auto; padding-top: 4px; }

/* 空状态 */
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state p { font-size: 18px; margin-bottom: 8px; color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* 模态框 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(67,55,44,.38);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .22s ease;
  box-shadow: 0 20px 50px rgba(67,55,44,.22);
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(135deg, #FBF5EB, #F9F1E4);
}
.modal-head h3 { font-size: 17px; color: var(--ink); }
.close { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; transition: color .15s, transform .15s; }
.close:hover { color: var(--accent); transform: rotate(90deg); }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 登录 */
.login-card { max-width: 380px; }
.login-body { padding: 26px 24px; }
.login-input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  margin-bottom: 12px;
  background: #FFFDF9;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,195,143,.22); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; border-radius: 999px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

/* 编辑 */
.edit-card { max-width: 580px; }
.edit-body { padding: 22px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #FFFDF9;
  outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,195,143,.2); }
.detail-head-actions { display: flex; gap: 8px; align-items: center; }

/* 上传 */
.drop-zone {
  margin: 18px 22px;
  border: 2px dashed #E4D2B8;
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  transition: all .18s;
  background: #FCF7EF;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(188,122,80,.07); }
.drop-hint { font-size: 15px; margin-bottom: 8px; color: var(--ink); }
.upload-list { margin: 0 22px 12px; max-height: 180px; overflow-y: auto; list-style: none; }
.upload-list li { font-size: 13px; padding: 7px 8px; border-bottom: 1px dashed var(--border-soft); display: flex; justify-content: space-between; color: var(--text); }
.upload-list .done { color: var(--ok); }

/* 详情 */
.detail-body { padding: 22px; overflow-y: auto; }
.detail-top { display: flex; gap: 22px; flex-wrap: wrap; }
.detail-cover { width: 164px; border-radius: var(--radius-md); overflow: hidden; background: linear-gradient(150deg,#F4E9D6,#EADBC2); flex-shrink: 0; border: 1px solid var(--border-soft); }
.detail-cover img { width: 100%; display: block; }
.detail-meta { flex: 1; min-width: 220px; }
.detail-meta h2 { font-size: 21px; color: var(--ink); margin-bottom: 8px; }
.meta-line { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.meta-line b { color: var(--text); font-weight: 600; }
.detail-desc { margin-top: 16px; font-size: 14px; line-height: 1.8; color: var(--text); }
.detail-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail-recommend {
  margin-top: 16px;
  background: rgba(226,195,143,.16);
  border-left: 4px solid var(--gold);
  padding: 13px 16px;
  border-radius: 0 14px 14px 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.rec-title { font-weight: 700; color: var(--accent); margin-bottom: 4px; }

/* 批注：胶囊选项卡 */
.annot-section { margin-top: 26px; }
.annot-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 16px;
  background: #F4E9D8;
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}
.annot-tab {
  padding: 8px 20px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-radius: 999px;
  transition: all .18s;
  font-weight: 500;
}
.annot-tab.active {
  background: #FFFDF9;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(188,122,80,.16);
}
.annot-editor { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.annot-editor textarea {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 66px;
  background: #FFFDF9;
  color: var(--text);
  outline: none;
}
.annot-editor textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,195,143,.2); }
.annot-editor input.page-input { width: 86px; padding: 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; background: #FFFDF9; outline: none; }
.annot-list { list-style: none; }
.annot-item {
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--card);
}
.annot-item .annot-type { font-size: 12px; font-weight: 700; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; }
.annot-item .annot-content { font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: var(--text); }
.annot-type.note { color: var(--accent); }
.annot-page { font-size: 12px; color: var(--muted); margin-top: 6px; }
.annot-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; transition: color .15s; }
.annot-del:hover { color: var(--danger); }

/* 阅读器 */
.reader-card { max-width: 900px; height: 92vh; }
.reader-body { flex: 1; overflow: auto; padding: 20px; background: #FDFAF4; }
.reader-body iframe { width: 100%; height: 100%; border: none; }
#epubView { width: 100%; height: 100%; }

/* 响应式 */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .brand-sub { display: none; }
  .filters { padding: 12px 16px; }
  .lib-head { padding: 16px 18px 4px; }
  .bookshelf { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 14px; padding: 6px 16px 26px; }
  .detail-top { flex-direction: column; }
  .detail-cover { width: 136px; }
  .form-grid { grid-template-columns: 1fr; }
}
