:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2f6bff;
  --accent-soft: #eaf1ff;
  --hot: #ff5a5f;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 2;
}

.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.actions { display: flex; gap: 10px; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  transition: .15s;
  font-weight: 600;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .45; cursor: not-allowed; }
#exportBtn, #importBtn, #exportAllBtn { background: #fff; color: var(--accent); }

/* 获取栏 */
.fetchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
#bookIdInput {
  flex: 1;
  max-width: 520px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  outline: none;
}
#bookIdInput:focus { border-color: var(--accent); }
.fetch-status { font-size: 13px; color: var(--muted); }
.fetchbar-hint { padding: 6px 20px; font-size: 12px; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--line); }
.fetchbar-hint code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; }

.muted { color: var(--muted); }

.layout { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-title {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 700;
}

.sort-select {
  margin-left: auto;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel, #fff);
  color: inherit;
  cursor: pointer;
}

.book-list { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }

.book-item {
  position: relative;
  padding: 12px;
  padding-right: 34px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
  transition: .12s;
}
.book-item:hover { background: var(--accent-soft); }
.book-item.active { background: var(--accent-soft); border-color: #cfe0ff; }

.book-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; line-height: 1.35; }
.book-meta { font-size: 12px; color: var(--muted); }

.book-del {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  opacity: .5;
  transition: all .15s;
}
.book-del:hover { opacity: 1; background: #fee; color: #e33; }

.empty-hint, .content-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 18px;
  line-height: 1.7;
  text-align: center;
}
.empty-hint code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }

.content { flex: 1; overflow: auto; padding: 22px 26px; min-width: 0; }

.book-header { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.book-header h2 { margin: 0 0 6px; font-size: 20px; }
.book-header .sub { color: var(--muted); font-size: 13px; }

.highlight-list { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }

.hl-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: all .2s ease;
  position: relative;
}

.hl-card.speaking {
  border-color: var(--accent);
  background: #f0f6ff;
  box-shadow: 0 4px 12px rgba(47, 107, 255, .15);
  transform: scale(1.01);
}

.hl-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }

.hl-rank {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: none;
}

.hl-card.speaking .hl-rank {
  background: #10b981;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hl-chapter { font-size: 12px; color: var(--muted); }
.hl-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--hot);
  background: #fff0f0;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.hl-play-single, .hl-del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: .7;
  transition: all .15s;
}
.hl-play-single:hover { opacity: 1; background: var(--accent-soft); color: var(--accent); }
.hl-del:hover { opacity: 1; background: #fee; color: #e33; }

.book-header .sub-author { color: var(--muted); font-size: 13px; margin-top: 2px; }

.hl-text { font-size: 15px; line-height: 1.8; color: #374151; white-space: pre-wrap; }

.hidden { display: none !important; }
.tag-sample {
  font-size: 11px;
  background: #fff7e6;
  color: #b7791f;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 600;
}

/* 底部播放控制条 */
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .05);
  z-index: 10;
  gap: 16px;
  flex-wrap: wrap;
}

.player-info {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: 320px;
}

.player-book {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.player-detail {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.player-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

.player-btn.icon-btn {
  padding: 6px 10px;
  font-size: 15px;
}

.player-btn.main-play-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 8px 18px;
  font-size: 14px;
  min-width: 90px;
}

.player-btn.main-play-btn.playing {
  background: #10b981;
  border-color: #10b981;
}

.player-btn.main-play-btn:hover {
  filter: brightness(1.08);
}

.player-settings {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.player-setting-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-setting-item select {
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.player-setting-item select:focus {
  border-color: var(--accent);
}

.page-mode-hint {
  margin: 0 20px 14px;
  padding: 10px 14px;
  background: #eef6ff;
  border: 1px solid #cfe0ff;
  border-radius: 10px;
  font-size: 13px;
  color: #3366aa;
  line-height: 1.6;
}

.syncbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 20px 14px;
  padding: 10px 14px;
  background: #f4f8ff;
  border: 1px dashed #b8cdf5;
  border-radius: 10px;
  font-size: 13px;
}

/* === 移动端适配（窄屏） === */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }
  .topbar .brand { font-size: 14px; }
  .topbar .actions { gap: 6px; flex-wrap: wrap; }
  .topbar .actions button { padding: 5px 9px; font-size: 12px; }

  .fetchbar {
    flex-wrap: wrap;
    padding: 8px 14px;
    gap: 6px;
  }
  .fetchbar input { flex: 1 1 100%; min-width: 0; }
  .fetchbar button { flex: 1; }
  .fetchbar-hint { display: none; }  /* 窄屏隐藏提示，节省空间 */

  .syncbar {
    flex-wrap: wrap;
    margin: 0 12px 12px;
    padding: 8px 10px;
  }
  .syncbar button { flex: 1; min-width: 0; }

  .page-mode-hint { margin: 0 12px 12px; font-size: 12px; padding: 8px 10px; }

  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .book-list { padding: 6px; }
  .book-item { padding: 8px 32px 8px 10px; margin-bottom: 4px; }
  .book-name { font-size: 13px; margin-bottom: 2px; }
  .book-meta { font-size: 11px; }
  .book-del { font-size: 14px; padding: 4px 6px; }

  .content { padding: 14px; }
  .book-header h2 { font-size: 17px; }
  .book-header .sub { font-size: 12px; }
  .book-header .sub-author { font-size: 12px; }

  .hl-card { padding: 12px; }
  .hl-text { font-size: 14px; line-height: 1.7; }
  .hl-top { gap: 6px; }
  .hl-chapter { font-size: 11px; }
  .hl-count { font-size: 11px; padding: 1px 6px; }
  .hl-rank { width: 22px; height: 22px; font-size: 12px; }

  .empty-hint, .content-empty { padding: 16px 12px; font-size: 12px; }
}

/* 超窄屏（手机竖屏 ≤ 480px）*/
@media (max-width: 480px) {
  .sidebar { max-height: 32vh; }
  .topbar .actions button { padding: 4px 7px; font-size: 11px; }
}

