:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #1f2937;
  --text-2: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #f59e0b;
  --highlight: #ffe28a;
  --highlight-active: #ffd34d;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .05);
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 62px;
  flex: 0 0 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.file-name {
  font-size: 13px; color: var(--text-2); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: .15s; user-select: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- 主工作区 ---------- */
.workspace { flex: 1 1 auto; display: flex; min-height: 0; }

/* 左侧页面缩略图预览 */
.thumb-panel {
  flex: 0 0 162px; width: 162px; background: var(--surface-2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0; transition: flex-basis .18s ease, width .18s ease;
}
.thumb-head {
  height: 46px; flex: 0 0 46px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 8px 0 13px;
  border-bottom: 1px solid var(--border);
}
.thumb-title { font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: .5px; }
.icon-btn.small { width: 24px; height: 24px; font-size: 13px; border-radius: 6px; }
.thumb-list {
  flex: 1 1 auto; overflow: auto; padding: 12px 10px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.thumb-item {
  width: 100%; cursor: pointer; background: #fff; border: 2px solid transparent;
  border-radius: 5px; padding: 4px; box-shadow: 0 1px 4px rgba(16,24,40,.12);
  transition: border-color .15s, box-shadow .15s;
}
.thumb-item:hover { border-color: #93c5fd; }
.thumb-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.thumb-item canvas { display: block; width: 100%; height: auto; background: #fff; }
.thumb-num {
  display: block; text-align: center; font-size: 11px;
  color: var(--text-2); margin-top: 5px; line-height: 1;
}
.thumb-item.active .thumb-num { color: var(--primary); font-weight: 700; }

/* 折叠态 */
.thumb-panel.collapsed { flex-basis: 42px; width: 42px; }
.thumb-panel.collapsed .thumb-title,
.thumb-panel.collapsed .thumb-list { display: none; }
.thumb-panel.collapsed .thumb-head { padding: 0; justify-content: center; }

.viewer-panel { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.viewer-toolbar {
  height: 46px; flex: 0 0 46px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
}
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group.right { margin-left: auto; }
.icon-btn {
  width: 30px; height: 30px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 7px; cursor: pointer;
  font-size: 17px; color: var(--text); display: flex;
  align-items: center; justify-content: center; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); border-color: #cbd5e1; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.text-btn {
  height: 30px; padding: 0 10px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 7px; cursor: pointer;
  font-size: 12px; color: var(--text-2);
}
.text-btn:hover { background: var(--surface-2); }
.page-box { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.page-box input {
  width: 52px; height: 30px; text-align: center;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; color: var(--text); background: var(--surface);
}
.page-sep { color: var(--text-2); }
#pageCount { color: var(--text-2); min-width: 24px; }
.zoom-label { font-size: 12px; color: var(--text-2); min-width: 42px; text-align: center; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.switch-label input { accent-color: var(--primary); cursor: pointer; }

/* ---------- PDF 舞台 ---------- */
.pdf-stage {
  flex: 1 1 auto; overflow: auto; position: relative;
  padding: 24px; background: #e9edf3;
}
.pdf-stage.drag-over { outline: 3px dashed var(--primary); outline-offset: -8px; }
.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--text-2);
  gap: 10px; text-align: center;
}
.empty-icon { font-size: 54px; opacity: .85; }
.empty-state h2 { font-size: 20px; color: var(--text); margin: 6px 0 0; }
.empty-state p { font-size: 13px; margin: 0 0 8px; }
.pages-container { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.page-card {
  background: #fff; box-shadow: 0 2px 14px rgba(16,24,40,.14);
  border-radius: 3px; overflow: hidden; position: relative;
}
.page-card canvas { display: block; width: 100%; height: auto; cursor: pointer; }
.pdf-hl-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pdf-hl-rect {
  position: absolute; border-radius: 2px;
  /* 浅黄荧光笔底色：只做柔和高亮，不压住正文黑字 */
  background: rgba(255, 214, 51, .30);
  transition: background .12s;
}
.pdf-hl-rect.cur {
  /* 只保留黄底高亮，不压住正文黑字；不画底部横线 */
  background: rgba(255, 214, 51, .48);
}
.loading {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: var(--text-2);
  background: rgba(233, 237, 243, .8); z-index: 3;
}

/* ---------- 右侧面板 ---------- */
.side-panel {
  flex: 0 0 300px; width: 300px; background: var(--surface);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0;
}
.panel-title {
  flex: 0 0 46px; height: 46px; display: flex; align-items: center;
  padding: 0 16px; font-size: 14px; font-weight: 700;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  color: var(--text);
}
.settings-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.setting-row { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.setting-row label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; justify-content: space-between; }
.setting-row .val { color: var(--primary); font-weight: 600; }
.setting-row select {
  height: 36px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font-size: 13px; color: var(--text); background: var(--surface);
}
.setting-row input[type=range] { width: 100%; accent-color: var(--primary); }
.setting-note { padding: 16px; font-size: 12px; color: var(--text-2); line-height: 1.7; }

/* ---------- 播放条 ---------- */
.player-bar {
  height: 76px; flex: 0 0 76px; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(16,24,40,.05);
  display: flex; align-items: center; gap: 18px; padding: 0 22px; z-index: 5;
}
.player-controls { display: flex; align-items: center; gap: 8px; }
.player-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 15px; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.player-btn:hover { background: var(--surface-2); }
.player-btn.play {
  width: 50px; height: 50px; background: var(--primary); color: #fff;
  border-color: var(--primary); font-size: 19px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .3);
}
.player-btn.play:hover { background: var(--primary-hover); }
.player-btn:disabled { opacity: .4; cursor: not-allowed; }
.player-progress { flex: 1 1 auto; min-width: 0; }
.progress-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
#playStatus { color: var(--primary); font-weight: 600; }
.progress-track { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 4px; transition: width .2s; }
.player-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--text-2); min-width: 110px; }
#metaVoice { font-weight: 600; color: var(--text); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 20; box-shadow: var(--shadow);
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .workspace { flex-direction: column; }
  .thumb-panel { flex: 0 0 46px; width: 100%; height: 46px; border-right: 0; border-bottom: 1px solid var(--border); }
  .thumb-panel:not(.collapsed) { flex-basis: 156px; height: 156px; }
  .thumb-head { height: 46px; flex-basis: 46px; }
  .thumb-list { flex-direction: row; align-items: stretch; overflow-x: auto; overflow-y: hidden; padding: 8px; }
  .thumb-item { flex: 0 0 104px; width: 104px; }
  .viewer-panel { flex: 1 1 55%; }
  .side-panel { flex: 0 0 40%; width: 100%; border-left: 0; border-top: 1px solid var(--border); }
  .brand-sub, .file-name { display: none; }
  .topbar { padding: 0 12px; }
  .viewer-toolbar { padding: 0 10px; gap: 8px; }
  .tool-group.right { display: none; }
  .player-bar { padding: 0 12px; gap: 10px; height: 70px; flex-basis: 70px; }
  .player-meta { display: none; }
  .pdf-stage { padding: 12px; }
}
