/* ============================================================
   语音朗读器 · 全站共用
   不依赖任何站点 CSS 变量，供主站与 academy 子站共用同一份
   ============================================================ */

/* ---- 右下角悬浮启动按钮 ---- */
.sp-launcher{
  position:fixed; right:20px; bottom:20px; z-index:9997;
  width:52px; height:52px; border-radius:50%;
  border:1px solid rgba(243,217,164,.35);
  background:#8B0000; color:#F3D9A4;
  cursor:pointer; padding:0;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 6px 18px rgba(90,10,10,.26);
  transition:transform .18s, box-shadow .18s, background .18s;
  -webkit-appearance:none; appearance:none;
}
.sp-launcher:hover{ transform:translateY(-2px); box-shadow:0 11px 26px rgba(90,10,10,.34) }
.sp-launcher:active{ transform:translateY(0) }
.sp-launcher svg{ width:24px; height:24px; fill:#F3D9A4; display:block }
.sp-launcher.sp-playing{ background:#6D4C0F }
.sp-launcher.sp-playing svg{ fill:#F3D9A4 }

/* 朗读中的呼吸光点 */
.sp-launcher .sp-dot{
  position:absolute; top:-1px; right:-1px;
  width:13px; height:13px; border-radius:50%;
  background:#B8862F; border:2px solid #fff;
  display:none;
}
.sp-launcher.sp-playing .sp-dot{ display:block; animation:sp-pulse 1.4s ease-in-out infinite }
@keyframes sp-pulse{ 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.45;transform:scale(.78)} }

/* ---- 控制面板 ---- */
.sp-panel{
  position:fixed; right:20px; bottom:82px; z-index:9998;
  width:340px; max-width:calc(100vw - 40px);
  background:#fff; border:1px solid #E5DCD0; border-radius:12px;
  box-shadow:0 16px 40px rgba(60,40,20,.17);
  padding:0; display:none; overflow:hidden;
}
.sp-panel.sp-open{ display:block }

.sp-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 16px 12px; border-bottom:1px solid #EFE8DE;
  background:linear-gradient(180deg,#FBF7F2,#fff);
}
.sp-head b{ font-size:15.5px; color:#2B2622; letter-spacing:.03em }
.sp-head .sp-sub{ font-size:11.5px; color:#8A8178; margin-top:2px; letter-spacing:.02em }
.sp-close{
  border:none; background:none; cursor:pointer; color:#8A8178;
  font-size:19px; line-height:1; padding:2px 4px; border-radius:4px;
}
.sp-close:hover{ background:#F2ECE3; color:#2B2622 }

.sp-body{ padding:14px 16px 15px }

.sp-note{
  font-size:12px; line-height:1.7; color:#8A6416;
  background:#FDF6E9; border:1px solid #EFE0BE; border-radius:6px;
  padding:8px 10px; margin-bottom:12px;
}
.sp-note:empty{ display:none }

/* 分段选择 */
.sp-bookrow{ display:flex; align-items:center; gap:8px; margin-bottom:8px }
.sp-bookrow label{
  flex:none; font-size:11.5px; color:#8A6416; letter-spacing:.04em;
  background:rgba(184,134,47,.12); border:1px solid rgba(184,134,47,.3);
  padding:3px 7px; border-radius:5px; white-space:nowrap;
}
.sp-bookrow select{
  flex:1; min-width:0; font-size:12.5px; padding:6px 8px;
  border:1px solid #DDD3C6; border-radius:6px; background:#fff;
  color:#3A342E; font-family:inherit;
}
.sp-segsel{ display:flex; gap:6px; margin-bottom:12px }
.sp-segsel select{
  flex:1; min-width:0; font-size:13px; padding:7px 8px;
  border:1px solid #DDD3C6; border-radius:6px; background:#fff;
  color:#3A342E; font-family:inherit;
}
.sp-navbtn{
  width:34px; flex:none; border:1px solid #DDD3C6; background:#fff;
  border-radius:6px; cursor:pointer; color:#5A524A;
  display:flex; align-items:center; justify-content:center;
  -webkit-appearance:none; appearance:none;
}
.sp-navbtn:hover{ border-color:#B8862F; color:#8B0000 }
.sp-navbtn svg{ width:14px; height:14px; fill:currentColor }

/* 主操作按钮 */
.sp-main{ display:flex; gap:8px; margin-bottom:12px }
.sp-btn{
  flex:1; padding:9px 10px; font-size:13.5px; border-radius:7px;
  border:1px solid #DDD3C6; background:#fff; color:#3A342E;
  cursor:pointer; font-family:inherit; letter-spacing:.02em;
  transition:all .16s;
}
.sp-btn:hover{ border-color:#B8862F; color:#8B0000 }
.sp-btn.sp-primary{
  background:#8B0000; border-color:#8B0000; color:#F3D9A4;
}
.sp-btn.sp-primary:hover{ background:#6D0000; border-color:#6D0000; color:#F3D9A4 }

/* 整站听（一键学习） */
.sp-site{ margin-bottom:12px }
.sp-site-btn{
  flex:1 0 100%; width:100%;
  padding:11px 12px; font-size:14px; border-radius:8px; font-weight:600; letter-spacing:.02em;
  border:1.5px solid #B8862F; background:linear-gradient(180deg,#FFF7E6,#FBEED2);
  color:#7A4E12; cursor:pointer; font-family:inherit;
  transition:all .16s;
}
.sp-site-btn:hover{ background:linear-gradient(180deg,#FFEFC9,#F7E3B6); color:#5A3A0E; box-shadow:0 3px 10px rgba(184,134,47,.22) }
.sp-site-btn:active{ transform:translateY(1px) }
.sp-siteprog{ font-size:11.5px; color:#8A6416; margin-top:7px; min-height:15px; line-height:1.5 }
.sp-resume-btn{
  width:100%; margin-top:8px; padding:8px 10px; font-size:13px; border-radius:7px;
  border:1px dashed #C9B48A; background:#fff; color:#7A4E12; cursor:pointer; font-family:inherit;
}
.sp-resume-btn:hover{ border-color:#B8862F; background:#FFFBF2 }
.sp-resume-btn[hidden]{ display:none }
.sp-help{
  text-decoration:none; display:inline-flex; align-items:center; height:36px;
}
.sp-help:hover{ color:#8B0000 }

/* 播放控制 */
.sp-ctrl{ display:flex; align-items:center; gap:8px; margin-bottom:12px }
.sp-play{
  width:44px; height:44px; flex:none; border-radius:50%;
  border:1px solid #C9BFAF; background:#8B0000; cursor:pointer;
  color:#F3D9A4; display:flex; align-items:center; justify-content:center;
  -webkit-appearance:none; appearance:none;
}
.sp-play:hover{ background:#6D0000 }
.sp-play svg{ width:18px; height:18px; fill:#F3D9A4 }
.sp-mini{
  height:36px; padding:0 12px; border:1px solid #DDD3C6; background:#fff;
  border-radius:18px; cursor:pointer; color:#5A524A; font-size:13px;
  font-family:inherit; display:inline-flex; align-items:center; gap:5px;
}
.sp-mini:hover{ border-color:#B8862F; color:#8B0000 }
.sp-mini svg{ width:13px; height:13px; fill:currentColor }

/* 进度条 */
.sp-bar{
  height:4px; background:#EFE8DE; border-radius:2px; overflow:hidden; margin-bottom:10px;
}
.sp-bar i{ display:block; height:100%; width:0; background:#B8862F; transition:width .3s }

/* 状态文本 */
.sp-status{
  font-size:12.5px; color:#6B6258; line-height:1.65; margin-bottom:11px;
  min-height:21px;
}
.sp-status b{ color:#8B0000; font-weight:600 }

/* 语速 */
.sp-speed{ display:flex; align-items:center; gap:10px; margin-bottom:11px }
.sp-speed label{ font-size:12.5px; color:#6B6258; flex:none; letter-spacing:.02em }
.sp-speed input[type=range]{ flex:1; accent-color:#8B0000; min-width:0 }
.sp-speed .sp-val{
  font-size:12.5px; color:#8B0000; flex:none; width:38px; text-align:right;
  font-variant-numeric:tabular-nums;
}

/* 开关 */
.sp-toggles{ display:flex; flex-wrap:wrap; gap:12px; padding-top:2px }
.sp-toggles label{
  font-size:12.5px; color:#6B6258; display:inline-flex;
  align-items:center; gap:5px; cursor:pointer;
}
.sp-toggles input{ accent-color:#8B0000; margin:0 }

/* ---- 标题旁的分段朗读按钮 ---- */
.sp-seg{
  display:inline-flex; align-items:center; justify-content:center;
  width:22px; height:22px; margin-left:8px; padding:0;
  border:1px solid #DCD2C4; border-radius:50%;
  background:#fff; color:#8B0000; cursor:pointer;
  vertical-align:middle; -webkit-appearance:none; appearance:none;
  transition:all .16s;
}
.sp-seg:hover{ background:#8B0000; border-color:#8B0000; color:#F3D9A4 }
.sp-seg svg{ width:10px; height:10px; fill:currentColor }
.sp-hide-seg .sp-seg{ display:none }

/* ---- 正在朗读的元素高亮 ---- */
.sp-active{
  background:#FFF8E9 !important;
  border-radius:3px;
  box-shadow:0 0 0 2px #FFF8E9;
}

/* ============================================================
   全局播放条（常驻底部 · 跨页可见）
   ============================================================ */
.sp-player{
  position:fixed; left:0; right:0; bottom:0; z-index:9996;
  display:none; align-items:center; gap:10px;
  padding:9px 16px;
  background:linear-gradient(180deg, rgba(139,0,0,.97), rgba(104,0,0,.99));
  border-top:1px solid rgba(243,217,164,.28);
  box-shadow:0 -6px 22px rgba(60,10,10,.28);
  color:#F3D9A4;
  font-family:inherit;
}
.sp-player.sp-show{ display:flex }

.sp-p-btn{
  flex:none; width:32px; height:32px; padding:0; border-radius:50%;
  border:1px solid rgba(243,217,164,.32); background:rgba(255,255,255,.06);
  color:#F3D9A4; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  -webkit-appearance:none; appearance:none; transition:all .16s;
}
.sp-p-btn:hover{ background:rgba(243,217,164,.18); border-color:rgba(243,217,164,.6) }
.sp-p-btn svg{ width:14px; height:14px; fill:currentColor }

/* 讲级跳转按钮：胶囊形 图标+文字 */
.sp-p-book{ width:auto; padding:0 10px; border-radius:16px; gap:5px; flex-direction:row }
.sp-p-book svg{ width:12px; height:12px }
.sp-p-bl{ font-size:10.5px; font-weight:600; letter-spacing:.5px; white-space:nowrap }

.sp-p-play{
  flex:none; width:42px; height:42px; padding:0; border-radius:50%;
  border:1.5px solid #F3D9A4; background:#F3D9A4; color:#7A0000;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  -webkit-appearance:none; appearance:none; transition:transform .16s, background .16s;
}
.sp-p-play:hover{ background:#fff; transform:scale(1.04) }
.sp-p-play svg{ width:18px; height:18px; fill:#7A0000 }

.sp-p-info{ flex:1 1 auto; min-width:0; margin:0 4px }
.sp-p-src{
  font-size:13.5px; font-weight:600; color:#FBEED2; letter-spacing:.02em;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.sp-p-meta{
  font-size:11.5px; color:rgba(243,217,164,.68); margin-top:2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  font-variant-numeric:tabular-nums;
}

.sp-p-bar{
  flex:0 1 220px; min-width:80px; height:6px; border-radius:3px;
  background:rgba(255,255,255,.2); cursor:pointer; overflow:hidden;
}
.sp-p-bar i{
  display:block; height:100%; width:0; border-radius:3px;
  background:linear-gradient(90deg,#E0B96A,#F3D9A4); transition:width .3s;
}
.sp-p-pct{
  flex:none; font-size:12px; color:rgba(243,217,164,.85); width:40px;
  text-align:right; font-variant-numeric:tabular-nums;
}
.sp-p-speed{
  flex:none; height:28px; padding:0 10px; border-radius:14px;
  border:1px solid rgba(243,217,164,.35); background:rgba(255,255,255,.06);
  color:#F3D9A4; font-size:12px; cursor:pointer; font-family:inherit;
  font-variant-numeric:tabular-nums;
}
.sp-p-speed:hover{ background:rgba(243,217,164,.18) }
.sp-p-help{ text-decoration:none }

/* 播放条出现时，避免遮挡右下角按钮与面板 */
body.sp-hasbar{ padding-bottom:64px }
body.sp-hasbar .sp-launcher{ bottom:86px }
body.sp-hasbar .sp-panel{ bottom:148px }

@media (max-width:720px){
  .sp-player{ flex-wrap:wrap; padding:8px 10px; row-gap:7px }
  .sp-p-info{ order:-1; flex:1 0 100%; margin:0 2px 2px }
  .sp-p-src{ font-size:12.5px }
  .sp-p-meta{ font-size:11px }
  .sp-p-bar{ flex:1 1 auto; order:0 }
  .sp-p-pct{ width:34px; font-size:11px }
  .sp-p-help{ display:none }
  /* 手机端：按钮整体加大，拇指好按 */
  .sp-p-bar{ flex:1 0 100%; order:9 }
  .sp-p-pct{ order:10 }
  .sp-p-speed{ order:10 }
  .sp-p-btn{ width:40px; height:40px }
  .sp-p-btn svg{ width:16px; height:16px }
  .sp-p-book{ height:40px; padding:0 12px; border-radius:20px; gap:5px }
  .sp-p-book svg{ width:13px; height:13px }
  .sp-p-bl{ font-size:11.5px }
  .sp-p-play{ width:48px; height:48px }
  .sp-p-play svg{ width:20px; height:20px }
  .sp-p-speed{ height:40px; padding:0 14px; border-radius:20px; font-size:13px; font-weight:700 }
  body.sp-hasbar{ padding-bottom:104px }
  body.sp-hasbar .sp-launcher{ bottom:126px }
  body.sp-hasbar .sp-panel{ bottom:188px }
}

/* 移动端 */
@media (max-width:640px){
  .sp-launcher{ right:14px; bottom:14px; width:48px; height:48px }
  .sp-launcher svg{ width:21px; height:21px }
  .sp-panel{ right:12px; left:12px; bottom:70px; width:auto; max-width:none }
  .sp-main{ flex-wrap:wrap }
  .sp-btn{ flex:1 0 100% }
}

/* 深链自动播放的「点此开始」按钮：移动端自动发声必须有用户手势 */
.sp-tapstart{
  position:fixed; left:50%; bottom:50%; transform:translate(-50%,50%);
  z-index:99999; border:none; border-radius:40px; padding:15px 34px;
  background:linear-gradient(135deg,#9E1414,#C01E1E); color:#FFF3D8;
  font-size:16px; font-weight:800; letter-spacing:.08em; font-family:inherit;
  box-shadow:0 12px 34px rgba(120,10,10,.42), 0 0 0 6px rgba(255,255,255,.14);
  cursor:pointer; -webkit-appearance:none; appearance:none;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation;
  animation:spPulse 1.8s ease-in-out infinite;
}
.sp-tapstart:active{ transform:translate(-50%,50%) scale(.96) }
@keyframes spPulse{
  0%,100%{ box-shadow:0 12px 34px rgba(120,10,10,.42), 0 0 0 6px rgba(255,255,255,.14) }
  50%{ box-shadow:0 12px 34px rgba(120,10,10,.42), 0 0 0 14px rgba(255,255,255,0) }
}

/* 进度条：允许横向拖动跳转，但不拦截纵向页面滚动 */
.sp-p-bar, .pb-bar{ touch-action:pan-y }

/* 全局按钮：消除移动端点击高亮与 300ms 延迟、避免双击缩放 */
.sp-launcher, .sp-panel button, .sp-player button, .sp-seg, .sp-tapstart{
  -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}

/* 打印时不显示 */
@media print{
  .sp-launcher, .sp-panel, .sp-seg, .sp-player, .sp-tapstart{ display:none !important }
  body.sp-hasbar{ padding-bottom:0 }
}
