:root{
  --bg0:#f6f7fb;
  --bg1:#eef2ff;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:rgba(15,23,42,.08);

  --primary:#007aff;
  --primary2:#3b82f6;

  --radius:18px;
  --radius-sm:14px;
  --shadow:0 1px 4px rgba(15,23,42,0.06), 0 0 0 1px rgba(15,23,42,0.05);
}

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

body{
  margin:0;
  color:var(--text);
  font-family:'MiSans','MiSans Normal',-apple-system,BlinkMacSystemFont,'PingFang SC',sans-serif;
  background: linear-gradient(160deg, #f0f4ff 0%, #f8f9fc 100%);
  min-height: 100%;
}

/* ===== 页面骨架 ===== */
.app{
  padding: 20px 16px;
}

.wrap{
  max-width: 560px;
  margin: 0 auto;
}

/* 顶部 */
.top{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.shelf-btn{
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  line-height: 1;
  transition: background .15s;
  flex-shrink: 0;
}
.shelf-btn:hover{ background: rgba(15,23,42,.06); }
.shelf-btn:active{ background: rgba(15,23,42,.12); }

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
}

.logo{
  width: 52px;          /* 图标容器变大 */
  height: 52px;
  border-radius: 16px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  font-size: 14px;      /* ⭐ 文字大小在这里改 */
  letter-spacing: 1px;  /* 字间距 */
  color:#fff;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 12px 26px rgba(0,122,255,.22);
  user-select:none;
}

.title{
  margin:0;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.3px;
  line-height: 1.05;
}

.sub{
  margin:8px 0 0;
  font-size: 13px;
  font-weight: 300;
  color: #94a3b8;
}

/* ===== 卡片 ===== */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 20px 0;
}

.card-hd{
  margin-bottom: 12px;
}

.card-title{
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: .2px;
}

.card-desc{
  margin-top: 6px;
  font-size: 13px;
  color: rgba(15,23,42,.52);
  line-height: 1.35;
}

/* ===== 表单 ===== */
label{
  display:block;
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.field{ min-width: 0; }

input, select, textarea{
  width:100%;
  border:1px solid rgba(15,23,42,.08);
  border-radius: var(--radius-sm);
  background: rgba(248,250,252,.95);
  padding: 14px 14px;
  font-size: 15px;
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

textarea{
  min-height: 80px;
  resize: vertical;
  line-height: 1.55;
}

input:focus, select:focus, textarea:focus{
  border-color: rgba(0,122,255,.55);
  box-shadow: 0 0 0 5px rgba(0,122,255,.14);
  background: #fff;
}

.grid3{
  display:grid;
  grid-template-columns: 1.35fr 1.15fr 0.75fr;  /* 模式略窄、语速更宽 */
  gap: 12px;
  align-items: end;
}

/* ✅ 强制在窄屏也保持三列（覆盖你之前的响应式） */
@media (max-width: 560px){
  .grid3{ grid-template-columns: 1.35fr 1.15fr 0.75fr !important; }
}
@media (max-width: 420px){
  .grid3{ grid-template-columns: 1.35fr 1.15fr 0.75fr !important; }
}

/* 语速更紧凑 */
.speedField select{
  padding-left: 10px;
  padding-right: 10px;
}

/* 朗读模式 + 语速：同一排 */
.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 420px){
  .grid2{ grid-template-columns: 1fr; }
}

/* 链接：输入 + 按钮同一排 */
.gridLink{
  display:grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 420px){
  .gridLink{ grid-template-columns: 1fr; }
  .gridLink .btn{ width:100%; }
}

/* 提示条（弱化、像图2那种层次） */
.hint{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(15,23,42,.03);
  border: 1px solid rgba(15,23,42,.06);
  color: rgba(15,23,42,.55);
  font-size: 13px;
}

/* 文件输入 */
input.file{
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(15,23,42,.18);
  background: rgba(248,250,252,.95);
}

/* ===== 按钮 ===== */
.actions{
  display:flex;
  gap:12px;
  margin-top:12px;
  align-items:center;
  flex-wrap:nowrap;
  width:100%;
}

.btn{
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  color: var(--text);
  border-radius: 999px;
  height: 44px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .04s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.btn:hover{ background: rgba(15,23,42,.03); }
.btn:active{ transform: scale(.98); }

.btn.primary{
  border: none;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 14px 32px rgba(0,122,255,.26);
}
.btn.secondary{
  background: rgba(15,23,42,.04);
  border-color: rgba(15,23,42,.08);
}
.btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  box-shadow:none;
}

/* ===== 进度 ===== */
.progress{ margin-top: 10px; }
progress{
  width: 100%;
  height: 6px;
  margin-top: 10px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
}
progress::-webkit-progress-bar{ background: rgba(15,23,42,.08); }
progress::-webkit-progress-value{
  background: linear-gradient(90deg, var(--primary), var(--primary2));
}

/* 文本辅助 */
.muted{ color: rgba(15,23,42,.55); }
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); border:0;
}

/* 状态条 */
.status{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: #fff;
  font-size: 14px;
}
.status.info{ color: rgba(15,23,42,.55); }
.status.ok{
  font-size: 13px;
  color: #64748b;
  background: none;
  border: none;
  padding: 0;
}
.status.bad{
  color:#b42318;
  border-color: rgba(180,35,24,.18);
  background: rgba(180,35,24,.06);
}

/* ===== 底部播放器：推荐固定底部（更像App） ===== */
.playerbar{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  background: rgba(248,250,252,.86);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(15,23,42,.06);
}

.player-inner{
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

.player-meta{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 18px;
}

.player-book-title{
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.player-chunk-info{
  font-size: 12px;
  color: rgba(15,23,42,.45);
  white-space: nowrap;
  flex-shrink: 0;
}

audio{ width: 100%; border-radius: 14px; }

/* 给内容留出播放器高度 */
.spacer{ height: 110px; }

/* ===== PC 上用“手机画布”展示 ===== */
@media (min-width: 900px){
  body{
    min-height: 100vh;
    display:flex;
    justify-content:center;
    align-items:flex-start;
    padding: 40px 0;
  }

  .app{
    width: 420px;
    padding: 28px 0 0;
    border-radius: 28px;
    background: rgba(255,255,255,.75);
    border: 1px solid rgba(15,23,42,.10);
    box-shadow: 0 30px 90px rgba(15,23,42,.18);
    backdrop-filter: blur(18px);
    overflow: hidden;

    position: relative; /* ⭐ 关键：给播放器当定位参照 */
  }

  .wrap{ max-width: 420px; padding: 0 16px; }
  .player-inner{ max-width: 420px; }

  /* ⭐ 播放器贴在“手机壳”底部 */
  .playerbar{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
  }
}
.inline-hint {
  font-size: 12px;
  color: #999;
  margin-left: 8px;
  white-space: nowrap;
}

/* ===== 段落导航行 ===== */
.progress-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:10px;
}

.progress-row .status{
  margin-top:0;
  flex-shrink:0;
}

.chunk-nav{
  flex:1;
  min-width:0;
}

/* ===== 统一下拉框样式（模式/朗读者/语速/段落导航） ===== */
.chunk-select{
  width:100%;
  height:38px;
  padding:0 36px 0 12px;
  border:1px solid rgba(15,23,42,.10);
  border-radius:10px;
  background:rgba(15,23,42,.03);
  color:var(--text);
  font-size:13px;
  font-weight:500;
  font-family:inherit;
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath fill='%230f172a' fill-opacity='0.55' d='M5.5 7.5 10 12l4.5-4.5 1.4 1.4L10 14.8 4.1 8.9z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
  background-size:12px 12px;
}

.chunk-select:focus{
  background-color:rgba(15,23,42,.03);
}


.actions .btn{
  white-space: nowrap;        /* ✅ 防止按钮文字换行 */
}

/* ===== Actions row: unify button + select (重要：放在CSS最底部覆盖前面的select样式) ===== */
.actions{
  display:flex;
  gap:12px;
  margin-top:16px;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:nowrap;
}

/* 统一高度、视觉风格（仅按钮，select 由 chunk-select 控制） */
.actions .btn{
  height:44px;
  border-radius:999px;
  font-size:15px;
  font-weight:500;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
}

/* 播放按钮：更像 iOS 的次要按钮 */
.actions .btn.playpause{
  padding: 0 18px;
  background: rgba(15,23,42,.03);
  border: 1px solid rgba(15,23,42,.10);
  box-shadow: none;
}

/* 定时关闭：只控制布局，视觉由 .chunk-select 统一 */
.actions .sleep-select{
  flex:0 0 auto;
}

#sleepTimer{
  width:130px;
  max-width:130px;
}

/* ===== 生成动画 ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-loading-wrap{
  display:inline-flex;
  align-items:center;
  gap:6px;
}

.loading-icon{
  display:inline-block;
  animation: spin 2s linear infinite;
  color: #007aff;
  font-size: 14px;
  line-height: 1;
  transform-origin: center;
}

.status.loading .status-text{
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===== 书架底部抽屉 ===== */
.sheet-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.4);
  z-index:100;
}
.sheet-overlay.open{ display:block; }

.sheet-drawer{
  position:fixed;
  left:0; right:0; bottom:0;
  z-index:101;
  background:#fff;
  border-radius:24px 24px 0 0;
  max-height:72vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  transform:translateY(100%);
  transition:transform .3s cubic-bezier(.32,0,.67,0);
}
.sheet-drawer.open{
  transform:translateY(0);
  transition:transform .3s cubic-bezier(.33,1,.68,1);
}

.sheet-handle{
  width:36px; height:4px;
  background:rgba(15,23,42,.15);
  border-radius:2px;
  margin:12px auto 0;
  flex-shrink:0;
}

.sheet-header{
  font-size:17px;
  font-weight:600;
  padding:14px 20px 12px;
  border-bottom:1px solid rgba(15,23,42,.06);
  flex-shrink:0;
}

.book-list{
  overflow-y:auto;
  flex:1;
  -webkit-overflow-scrolling:touch;
}

.book-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:14px 20px;
  cursor:pointer;
  transition:background .15s;
  min-height:60px;
}
.book-item:hover{ background:rgba(15,23,42,.03); }
.book-item:active{ background:rgba(15,23,42,.06); }
.book-item.active{ background:rgba(0,122,255,.06); }

.book-info{ flex:1; min-width:0; }

.book-title{
  font-size:15px;
  font-weight:700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.book-progress{
  font-size:12px;
  color:rgba(15,23,42,.45);
  margin-top:3px;
}
.book-item.active .book-title{ color:var(--primary); }

.book-delete{
  background:none;
  border:none;
  font-size:14px;
  cursor:pointer;
  padding:8px;
  border-radius:8px;
  opacity:.35;
  transition:opacity .15s;
  flex-shrink:0;
  color:var(--text);
}
.book-delete:hover{ opacity:.7; }

.sheet-footer{
  padding:12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top:1px solid rgba(15,23,42,.06);
  flex-shrink:0;
}

.sheet-add-btn{
  width:100%;
  height:50px;
  border:none;
  background:linear-gradient(135deg, var(--primary), var(--primary2));
  color:#fff;
  font-size:16px;
  font-weight:500;
  border-radius:999px;
  cursor:pointer;
  transition:opacity .15s;
}
.sheet-add-btn:active{ opacity:.85; }

/* PC：让抽屉在 app 框内显示 */
@media (min-width:900px){
  .sheet-overlay{
    position:absolute;
    border-radius:28px;
  }
  .sheet-drawer{
    position:absolute;
    left:0; right:0; bottom:0;
    border-radius:0;
  }
}
/* ===== 设置折叠面板 ===== */
.settings-card{
  padding: 0;
  overflow: hidden;
}

.settings-toggle{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  transition: background .15s;
}
.settings-toggle:hover{ background: rgba(15,23,42,.02); }
.settings-toggle:active{ background: rgba(15,23,42,.05); }

.settings-arrow{
  font-size: 13px;
  color: rgba(15,23,42,.4);
  transition: transform .2s ease;
}
.settings-arrow.open{
  transform: rotate(90deg);
}

.settings-body{
  display: none;
  padding: 0 22px 20px;
}
.settings-body.open{
  display: block;
}

/* ===== 完成 badge ===== */
.status-done-badge{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: rgba(34,197,94,.12);
  color: #16a34a;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(34,197,94,.2);
}

/* ===== 正在播放书名（header右上角） ===== */
.now-playing-title{
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  width: 5em;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
  position: relative;
}
.now-playing-title.visible{
  opacity: 1;
  transform: translateY(0);
}
.now-playing-title .marquee-inner{
  display: inline-block;
  white-space: nowrap;
}
.now-playing-title .marquee-inner.scrolling{
  animation: marquee-scroll 6s linear infinite;
}
@keyframes marquee-scroll{
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ===== 灵听 logo 图片 ===== */
.logo-img{
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ===== 深色模式 ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg0: #0f1117;
    --bg1: #1a1d27;
    --card: #1e2130;
    --text: #e8eaf0;
    --muted: #8b95a8;
    --line: rgba(255,255,255,.08);
    --shadow: 0 1px 4px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
  }
  body { background: linear-gradient(160deg, #0f1117 0%, #141720 100%); }
  select, .chunk-select, .sleep-select {
    background: #252838 !important;
    color: #e8eaf0 !important;
    border-color: rgba(255,255,255,.12) !important;
  }
  option { background: #252838; color: #e8eaf0; }
  textarea { background: #252838 !important; color: #e8eaf0 !important; border-color: rgba(255,255,255,.1) !important; }
  audio { filter: invert(0.85) hue-rotate(180deg); }
  .logo-img { background: transparent; border-radius: 12px; }
  .btn { background: rgba(255,255,255,.06); color: #e8eaf0; border-color: rgba(255,255,255,.1); }
  .btn:hover { background: rgba(255,255,255,.1); }
  .book-item { background: #252838; }
  .book-item:hover { background: #2d3145; }
  progress::-webkit-progress-bar { background: rgba(255,255,255,.08); }
  input.file {
    background: #252838 !important;
    border-color: rgba(255,255,255,.12) !important;
    color: #e8eaf0 !important;
  }
}