/* ============================================================
   听写页专属样式
   —— 功能沿用「自助听写」原版，配色映射到点读暖色系
   —— 版面同样沿用原版的左右分栏（左：选词 + 控制；右：参数 + 历史）
   ============================================================ */

/* ===== 左右分栏 =================================================
   窄屏是普通单列（顺序即 DOM 顺序：左栏 → 右栏）；
   ≥1100px 才分栏：左边 1.45fr 放操作动线，右边 1fr 放参数与历史。
   右栏有最小宽度兜底，否则「声音模型」这类长文案会被省略号吃掉。 */
.dict-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: start;
}
.dict-col { display: flex; flex-direction: column; min-width: 0; }
.dict-col > .card:last-child { margin-bottom: 16px; }

@media (min-width: 1100px) {
  .dict-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(380px, 1fr);
    gap: 18px;
  }
}
/* 分栏后每栏自己成一列卡片，卡片间距由 .card 的 margin-bottom 提供 */
@media (min-width: 1400px) {
  .dict-layout { gap: 22px; }
}

/* ===== 词源切换 ===== */
.seg {
  display: flex;
  gap: 5px;
  padding: 5px;
  background: var(--pg-soft);
  border: 1px solid var(--pg-soft2);
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
}
.seg button {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 8px;
  min-height: 42px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
  white-space: nowrap;
}
.seg button:hover { color: var(--text-primary); }
.seg button.on {
  background: #FFFFFF;
  color: var(--pg-ink);
  box-shadow: 0 3px 10px rgba(93, 76, 130, 0.14);
}

/* ===== 自定义词表 ===== */
#wordInput {
  min-height: 104px;
  font-size: 15px;
}

/* ===== 词汇预览 ===== */
.word-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 2px 4px;
  min-height: 44px;
  max-height: 200px;
  overflow-y: auto;
}
.word-tag {
  display: inline-flex;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid var(--border-soft);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  color: var(--text-secondary);
  transition: 0.2s;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(93, 76, 130, 0.06);
}
.word-tag.active {
  background: var(--pg-grad);
  border-color: transparent;
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 5px 14px var(--pg-shadow);
  transform: translateY(-1px);
}
.word-tag.done {
  background: #F3F1EC;
  border-color: #E8E3D8;
  color: var(--text-muted);
  text-decoration: line-through;
}
.progress-text {
  display: inline-block;
  margin-top: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--pg-ink);
  background: var(--pg-soft);
  border: 1px solid var(--pg-soft2);
  border-radius: var(--radius-pill);
  padding: 5px 15px;
}

/* ===== 状态栏 ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 11px 16px;
  font-size: 14.5px;
  color: var(--text-secondary);
  background: var(--bg-field);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}
.status-bar strong { color: var(--text-primary); font-weight: 600; }
.status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #D9D2C4;
}
.status-bar.playing .status-dot {
  background: var(--accent-green);
  animation: dictPulse 1.6s infinite;
}
@keyframes dictPulse {
  0% { box-shadow: 0 0 0 0 rgba(60, 207, 91, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(60, 207, 91, 0); }
  100% { box-shadow: 0 0 0 0 rgba(60, 207, 91, 0); }
}

/* ===== 可折叠卡片（选词 / 语音设置：移动端省空间）===== */
/* 卡片定位 + 折叠按钮绝对定位在卡片右上角（贴边框外侧，不占布局） */
.dict-card-anchor { position: relative; }
.card .card-title .card-title-text { min-width: 0; }
.card .card-fold {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid var(--pg-soft2);
  border-radius: 10px;
  background: var(--pg-soft);
  color: var(--pg-ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: 0.18s;
}
.card .card-fold:hover { background: #fff; box-shadow: 0 3px 9px rgba(93, 76, 130, 0.14); }
.card .card-fold[aria-expanded="false"] { transform: rotate(180deg); }
/* 标题右侧的锚点折叠按钮（选词卡片 / 语音设置卡片）：
   绝对定位，贴卡片右上角圆弧内侧，与「自定义词表」seg 行 / 滑块 0.8 数字列对齐 */
.card .card-fold.anchor {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
}
/* 折叠态：正文隐藏，卡片收紧；锚点按钮位置不动，仍在右上角 */
.dict-card.folded { padding-bottom: 14px; }
.dict-card.folded > .card-title { margin-bottom: 0; }
.dict-card.folded > .card-body { display: none; }

/* 只折叠「单词选择框」：词库选择器 / 自定义区收成一行摘要，词语表保留 */
.picker-section.picker-hidden { display: none; }
.picker-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin-bottom: 12px;
  border: 1px dashed var(--pg-soft2);
  border-radius: 12px;
  background: var(--pg-soft);
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
}
.picker-summary .ps-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-summary .ps-btn { flex-shrink: 0; font-weight: 600; color: var(--pg-ink); }

/* ===== 语音设置：左右两列（左=下拉选择 / 右=滑块调整）===== */
.settings-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  align-items: start;
}
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.settings-col-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--pg-ink);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--pg-soft2);
}
.setting-cell { min-width: 0; }
.setting-cell > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.setting-cell .dd { width: 100%; }
.setting-cell .range-row { min-height: 42px; }
.divider { border: none; border-top: 1px dashed var(--border-soft); margin: 18px 0 14px; }

/* ===== 历史记录 ===== */
.history-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.history-toolbar .btn { flex: 1; }
.history-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 420px;
  overflow-y: auto;
}
.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 22px 0;
}
.history-entry {
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #FFFDF8;
  cursor: pointer;
  transition: 0.18s;
}
.history-entry:hover { border-color: var(--pg-accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(93, 76, 130, 0.1); }
.history-entry.status-completed { background: #F4FDF7; border-color: #C6EDD5; }
.history-entry.status-abnormal { background: #FFF7F5; border-color: #FFD5CB; }
.history-entry.status-manual { background: #FFFBF0; border-color: #FFE3B8; }
.history-entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.history-time { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.history-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--pg-soft);
  color: var(--pg-ink);
  border: 1px solid var(--pg-soft2);
  white-space: nowrap;
}
.history-summary {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 历史详情弹窗 ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: rgba(58, 61, 92, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.overlay.open { display: flex; }
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 660px;
  max-height: 86vh;
  overflow: hidden;
  background: #FFFFFF;
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(58, 61, 92, 0.32);
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background: linear-gradient(135deg, #FFF6E9, #FFF0F3);
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 { flex: 1; margin: 0; font-size: 17px; color: var(--text-primary); }
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-settings { font-size: 12.5px; color: var(--text-muted); }
.history-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.history-word { font-size: 13px; padding: 4px 11px; cursor: pointer; }
.history-word.active { background: var(--pg-grad); border-color: transparent; color: #FFFFFF; }
.history-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 宽屏：预览区略放宽 */
@media (min-width: 1000px) {
  .word-preview { max-height: 240px; }
}

@media (max-width: 640px) {
  .seg button { font-size: 13.5px; padding: 9px 6px; }
}

/* 手机窄屏：语音设置两列改单列，避免滑块被压太窄 */
@media (max-width: 600px) {
  .settings-cols { grid-template-columns: 1fr; gap: 14px; }
  .settings-col-title { margin-top: 4px; }
  .word-preview { max-height: 168px; }
  .modal-header { flex-wrap: wrap; }
  .modal-body { padding: 14px 15px; }
}

/* ============================================================
   参照「语音工具箱」合并版自助听写统一 UI（仅本页生效）
   —— 标题胶囊 / 扁平卡片 / 纯色按钮 / 折叠卡片标题行去分隔线
   ============================================================ */

/* 标题胶囊：与 TTS+TX 自助听写同款游离式圆角条 */
.dict-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 0 28px;
  padding: 20px 40px;
  border-radius: 60px;
  background: var(--pg-soft2);
  line-height: 1.6;
}
.dict-header-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--pg-ink);
}
.dict-header-sub {
  font-size: 15px;
  font-weight: 400;
  color: var(--pg-ink);
  opacity: 0.78;
  margin-left: 6px;
}
@media (max-width: 820px) {
  .dict-header { padding: 16px 24px; border-radius: 40px; }
  .dict-header-title { font-size: 22px; }
}
@media (max-width: 640px) {
  .dict-header { padding: 14px 18px; }
  .dict-header-title { font-size: 19px; }
  .dict-header-sub { font-size: 13px; margin-left: 0; }
}
@media (max-width: 430px) {
  .dict-header { justify-content: center; gap: 2px 10px; padding: 12px 16px; }
  .dict-header-title { font-size: 17px; }
  .dict-header-sub { font-size: 12px; }
}
@media (min-width: 1700px) {
  .dict-header { padding: 24px 44px; }
  .dict-header-title { font-size: 28px; }
}

/* 卡片扁平化：去投影（对齐 TTS+TX 的纯白平卡） */
body.page-dictation .card { box-shadow: none; }

/* 有折叠按钮的卡片：标题行去掉右侧渐隐分隔线（按钮已贴右上角，线会穿到按钮下面） */
.dict-card-anchor > .card-title::after { display: none; }

/* 纯色按钮（对齐 TTS+TX：开始绿 / 暂停金 / 停止红 / 主操作品牌色） */
body.page-dictation .btn.primary { background: var(--pg-accent); border-color: transparent; color: #FFFFFF; box-shadow: none; }
body.page-dictation .btn.green { background: var(--accent-green); border-color: transparent; color: #FFFFFF; box-shadow: none; }
body.page-dictation .btn.gold { background: var(--accent-gold); border-color: transparent; color: #FFFFFF; box-shadow: none; }
body.page-dictation .btn.danger { background: var(--danger); border-color: transparent; color: #FFFFFF; box-shadow: none; }
/* 词库选择器的「清空」仍是白底描边红字（与自测页共用组件，保持原样） */
body.page-dictation .picker-bar .picker-bar-actions .btn.danger { background: transparent; border-color: var(--border-field); color: var(--danger); }

/* 词汇标签 / 历史词标签：选中态纯品牌色 */
body.page-dictation .word-tag { box-shadow: none; }
body.page-dictation .word-tag.active { background: var(--pg-accent); border-color: transparent; color: #FFFFFF; box-shadow: none; transform: none; }
body.page-dictation .history-word.active { background: var(--pg-accent); border-color: transparent; color: #FFFFFF; }

/* 历史详情弹窗头：去渐变 */
body.page-dictation .modal-header { background: var(--pg-soft); }
/* ============================================================
   高度规则（2026-09-21）：固定窗口高度，左右分栏等高满屏
   —— 历史记录随记录增多在卡片内滚动浏览；
   —— 选词卡 / 解析输入框内容超出时在各自框内滚动；
   —— 去掉解析输入框的拖拽角标（resize:none），高度由布局自动分配
   ============================================================ */
@media (min-width: 1100px) {
  /* 应用容器撑满视口剩余高度，.dict-layout 获得确定的可用高度（底部贴齐视口） */
  body.page-dictation .app {
    display: flex;
    flex-direction: column;
    /* 固定高度（而非 min-height）：flex:1 的子项才有确定的可用空间可分配 */
    height: calc(100vh - 28px); /* 回退：不支持 dvh 的旧浏览器 */
    height: calc(100dvh - 28px); /* body 底部 padding 28px */
  }
  .dict-layout {
    flex: 1;
    min-height: 0;
    align-items: stretch; /* 两列等高：点读词库 / 自定义词表下左右分栏总高度一致 */
  }
  /* 左列：选词卡 + 控制卡 */
  .dict-col-main { min-height: 0; display: flex; flex-direction: column; }
  /* 选词卡：整卡不再滚动（overflow:hidden），高度吃满左栏剩余；
     卡内区域按 flex 分配——词库框 / 输入框各自撑满并内部滚动 */
  .dict-col-main > .card:first-child {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #contentBody {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #srcSeg { flex: 0 0 auto; }
  /* 点读词库：搜索 / 筛选 / 工具条固定，词库列表（picker-words）撑满剩余并内部滚动 */
  #libPane, #pickerMount {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #pickerMount .picker-words {
    flex: 1;
    min-height: 0;
    max-height: none; /* 不再用固定 340px，改为撑满剩余高度并滚动 */
  }
  /* 自定义词表：输入框撑满剩余高度，让「当前进度」贴到卡片底部，中间空白由输入框填充 */
  #customPane {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #customPane .hint { flex: 0 0 auto; }
  #customPane .btn-row { flex: 0 0 auto; }
  #wordInput { flex: 1; min-height: 0; }
  /* 预览 + 进度固定在卡片底部（预览词多时在框内滚动，不撑高卡片） */
  #contentBody .word-preview { flex: 0 0 auto; min-height: 44px; max-height: 240px; }
  #contentBody .progress-text { flex: 0 0 auto; margin-top: 8px; }
  .dict-col-main > .card:last-child { flex: none; margin-bottom: 0; /* 与右栏历史卡一致：两列最后一张卡片底严格对齐 */ }
  /* 右列：历史记录卡撑满剩余高度，记录在卡内滚动 */
  .dict-col-side { min-height: 0; }
  .dict-col-side > .card:last-child {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
  }
  .dict-col-side .history-list {
    flex: 1;
    min-height: 0;
    max-height: none; /* 不再用固定 420px，改为撑满剩余高度 */
    overflow-y: auto;
  }
}

/* 解析输入框：去掉拖拽角标，内容超出时在框内滚动（桌面 + 移动端） */
#wordInput { resize: none; overflow-y: auto; }