/* ==================================================================
   知识百科 / 国学经典 / 唐诗宋词 / 成语接龙 —— 样式
   kid_learn.css

   类名前缀约定（避免与其他模块撞名）：
     .kl-*   三个阅读视图 + 通用件（hero / chips / list / detail / toast）
     .ki-*   成语接龙（关卡 / 对局 / 成语库）

   复用 .kid-card / .kid-btn / .kid-empty（来自 kid.css），
   保证与「睡前故事」视觉一致 —— 同一分组下不该像两个 App。
   ================================================================== */

/* ---------- 通用壳 ---------- */
.kl-page { max-width: 900px; margin: 0 auto; }

/* 头图：四个视图各一套配色 */
.kl-hero {
  display: flex; align-items: center; gap: 16px;
  padding: 22px 24px; margin-bottom: 18px;
  border-radius: 16px; color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.kl-hero h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.kl-hero p { margin: 0; font-size: 13px; opacity: .92; }
.kl-hero-ic { font-size: 40px; line-height: 1; flex: none; }
.kl-hero-wiki  { background: linear-gradient(135deg, #2f9e6f, #4fc38b); }
.kl-hero-gx    { background: linear-gradient(135deg, #9a5b2a, #c98a4b); }
.kl-hero-pm    { background: linear-gradient(135deg, #3d6fb5, #6a9fe0); }
.kl-hero-idiom { background: linear-gradient(135deg, #b03a52, #e0657f); }

/* ---------- 搜索框 ---------- */
/* ★ 2026-10-04 改造：工具栏从「只有一个搜索框」变成「搜索框 + 生成按钮」，
   所以由块级改为 flex。搜索框 flex:1 撑满剩余宽度，按钮固定宽度。
   窄屏（<560px）折行，按钮独占一行且撑满 —— 避免按钮被压成一条缝。 */
.kl-toolbar {
  margin-bottom: 12px;
  display: flex; align-items: stretch; gap: 10px;
}
.kl-search {
  flex: 1 1 auto; min-width: 0; box-sizing: border-box;
  padding: 11px 14px; font-size: 14px;
  border: 1px solid #e2e6ea; border-radius: 10px;
  background: #fff; outline: none; transition: border-color .15s;
}
.kl-search:focus { border-color: #4fc38b; }

/* ---------- 「生成」按钮（知识百科 / 成语接龙 共用） ----------
   两种状态：
     .is-ai   —— 还有 AI 额度，文案「✨ AI 智能生成」，金色渐变（这是稀缺品）
     默认      —— 额度用完，文案「🔄 换一批」，朴素描边（这是常规操作）
   视觉上刻意拉开差距：金色要显眼到「这是一次性机会」，
   素色要低调到「随便点、不要钱」。 */
.kl-gen {
  flex: 0 0 auto;
  display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px;
  padding: 7px 16px; min-width: 104px;
  border: 1px solid #e2e6ea; border-radius: 10px;
  background: #fff; color: #4a5560; cursor: pointer;
  transition: all .18s; line-height: 1.15;
}
.kl-gen:hover { border-color: #4fc38b; color: #2f9e6f; }
.kl-gen .kl-gen-ic { font-size: 15px; }
.kl-gen .kl-gen-t { font-size: 13px; font-weight: 600; white-space: nowrap; }
.kl-gen .kl-gen-n { font-size: 10px; color: #98a2ad; white-space: nowrap; }

/* 还有 AI 额度：金色渐变 + 微光 */
.kl-gen.is-ai {
  border-color: #e6b34a; color: #8a5a00;
  background: linear-gradient(135deg, #fff6e0 0%, #ffe9b8 100%);
  box-shadow: 0 2px 8px rgba(230, 179, 74, .22);
}
.kl-gen.is-ai:hover {
  border-color: #d99b1f; color: #6d4700;
  box-shadow: 0 3px 12px rgba(230, 179, 74, .34);
}
.kl-gen.is-ai .kl-gen-n { color: #b8860b; font-weight: 600; }

/* 生成中：禁止连点 + 半透明 */
.kl-gen.is-busy { opacity: .6; cursor: progress; pointer-events: none; }

/* 生成出来的卡片标一下「新」，与常规列表区分 */
.kl-item-new {
  border-color: #ffd98a;
  background: linear-gradient(180deg, #fffdf6 0%, #fff 60%);
}
.ki-idio-new {
  border-color: #ffd98a;
  background: linear-gradient(180deg, #fffdf6 0%, #fff 60%);
}

@media (max-width: 560px) {
  .kl-toolbar { flex-wrap: wrap; }
  .kl-search { flex: 1 1 100%; }
  .kl-gen { flex: 1 1 100%; flex-direction: row; gap: 7px; min-width: 0; }
}

/* ---------- 分类 chips ---------- */
.kl-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.kl-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; font-size: 13px;
  border: 1px solid #e2e6ea; border-radius: 999px;
  background: #fff; color: #4a5560; cursor: pointer;
  transition: all .15s;
}
.kl-chip:hover { border-color: #4fc38b; color: #2f9e6f; }
.kl-chip.on {
  background: #2f9e6f; border-color: #2f9e6f; color: #fff; font-weight: 600;
}
.kl-chip-n {
  font-size: 11px; padding: 0 5px; border-radius: 999px;
  background: rgba(0, 0, 0, .08);
}
.kl-chip.on .kl-chip-n { background: rgba(255, 255, 255, .25); }
.kl-loading { font-size: 13px; color: #98a2ad; }

/* ---------- 列表（百科 / 国学） ---------- */
.kl-list { display: flex; flex-direction: column; gap: 10px; }
.kl-item {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 14px 16px; text-align: left;
  border: 1px solid #ebeff2; border-radius: 12px;
  background: #fff; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.kl-item:hover {
  border-color: #4fc38b; box-shadow: 0 3px 12px rgba(47, 158, 111, .12);
  transform: translateY(-1px);
}
.kl-item-ic { font-size: 26px; flex: none; line-height: 1; }
.kl-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.kl-item-t { font-size: 15px; font-weight: 600; color: #1f2933; }
.kl-item-s {
  font-size: 13px; color: #6b7480; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.kl-item-meta { font-size: 12px; color: #98a2ad; }
.kl-item-arrow { font-size: 20px; color: #c4ccd4; flex: none; }

/* ---------- 诗词栅格 ---------- */
.kl-poems {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.kl-poem {
  padding: 16px 14px; text-align: center;
  border: 1px solid #ebeff2; border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #fff);
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.kl-poem:hover {
  border-color: #6a9fe0; box-shadow: 0 3px 14px rgba(61, 111, 181, .14);
  transform: translateY(-2px);
}
.kl-poem-t { font-size: 15px; font-weight: 600; color: #1f2933; margin-bottom: 6px; }
.kl-poem-a { font-size: 12px; color: #6b7480; margin-bottom: 4px; }
.kl-poem-f { font-size: 11px; color: #98a2ad; }

/* ---------- 详情页 ---------- */
.kl-detail { display: flex; flex-direction: column; gap: 14px; }
.kl-back {
  align-self: flex-start; padding: 6px 12px; font-size: 13px;
  border: 1px solid #e2e6ea; border-radius: 8px;
  background: #fff; color: #4a5560; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.kl-back:hover { border-color: #4fc38b; color: #2f9e6f; }

.kl-detail-card { padding: 24px 26px; }
.kl-detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.kl-detail-ic { font-size: 38px; line-height: 1; }
.kl-detail-head h2 { margin: 0 0 4px; font-size: 21px; color: #1f2933; }
.kl-detail-sub { font-size: 13px; color: #6b7480; }

.kl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.kl-tag {
  padding: 3px 10px; font-size: 12px; border-radius: 999px;
  background: #eef7f2; color: #2f9e6f;
}

.kl-body { font-size: 15px; line-height: 1.85; color: #333c45; }
.kl-body p { margin: 0 0 14px; }
.kl-body p:last-child { margin-bottom: 0; }

.kl-sec { margin-top: 22px; padding-top: 18px; border-top: 1px dashed #e8edf1; }
.kl-sec h3 {
  margin: 0 0 10px; font-size: 15px; color: #2f9e6f; font-weight: 600;
}
.kl-insight {
  background: #fffbf0; border-radius: 10px; padding: 16px 18px;
  border-top: none; margin-top: 20px;
}
.kl-insight h3 { color: #b8860b; }

.kl-detail-foot {
  margin-top: 24px; padding-top: 18px; border-top: 1px solid #eef2f5;
  display: flex; gap: 10px;
}

/* ---------- 国学：拼音 + 原文逐行 ---------- */
.kl-gx-body {
  background: #fdf9f3; border-radius: 12px;
  padding: 18px 20px; margin-bottom: 6px;
}
.kl-gx-line { margin-bottom: 14px; }
.kl-gx-line:last-child { margin-bottom: 0; }
.kl-gx-py {
  font-size: 12px; color: #b08d5a; letter-spacing: .5px; margin-bottom: 3px;
}
.kl-gx-cn {
  font-size: 18px; color: #4a3620; font-weight: 500;
  letter-spacing: 2px; line-height: 1.7;
}

/* ---------- 诗词详情 ---------- */
.kl-poem-card { text-align: center; }
.kl-poem-head { margin-bottom: 20px; }
.kl-poem-head h2 { margin: 0 0 8px; font-size: 22px; color: #1f2933; }
.kl-poem-by { font-size: 13px; color: #6b7480; }
.kl-poem-body {
  font-size: 19px; line-height: 2.1; color: #2a3540;
  letter-spacing: 3px; padding: 20px 0;
  border-top: 1px solid #eef2f5; border-bottom: 1px solid #eef2f5;
  margin-bottom: 6px;
}
.kl-poem-card .kl-sec { text-align: left; }
.kl-poem-card .kl-detail-foot { justify-content: center; }

/* ---------- 上/下一篇导航 ---------- */
.kl-nav { display: flex; gap: 12px; }
.kl-nav-btn {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; text-align: left;
  border: 1px solid #ebeff2; border-radius: 10px;
  background: #fff; cursor: pointer; font-family: inherit;
  transition: all .15s; min-width: 0;
}
.kl-nav-btn:hover { border-color: #4fc38b; background: #f7fdfa; }
.kl-nav-btn span { font-size: 12px; color: #98a2ad; }
.kl-nav-btn b {
  font-size: 14px; color: #1f2933; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kl-nav-next { text-align: right; }
.kl-nav-ph { flex: 1; }

/* ---------- toast ---------- */
.kl-toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  z-index: 9999; padding: 11px 20px; border-radius: 10px;
  background: rgba(31, 41, 51, .93); color: #fff; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
  animation: kl-in .18s ease-out;
}
.kl-toast.err { background: rgba(190, 46, 66, .95); }
@keyframes kl-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================================================================
   成语接龙
   ================================================================== */

/* ---------- Tab 切换 ---------- */
/* ★ 2026-10-04：生成按钮提到页签行（两个页签下都可见）。
   页签行加 align-items:flex-end，让按钮底部对齐页签文字基线，
   并用 .ki-tabs-sp 弹性占位把按钮推到最右。 */
.ki-tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  border-bottom: 1px solid #eef2f5;
  align-items: flex-end;
}
.ki-tab {
  padding: 10px 20px; font-size: 15px; font-family: inherit;
  border: none; background: none; cursor: pointer;
  color: #6b7480; font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  transition: all .15s;
}
.ki-tab:hover { color: #b03a52; }
.ki-tab.on { color: #b03a52; border-bottom-color: #b03a52; font-weight: 700; }
/* 弹性占位：把页签行右侧的生成按钮推到底 */
.ki-tabs-sp { flex: 1 1 auto; }
/* 页签行里的生成按钮：压扁一点，别比页签高（它是配角，页签才是主角） */
.ki-tabs .kl-gen {
  margin-bottom: 6px; padding: 5px 13px; min-width: 96px;
}
.ki-tabs .kl-gen .kl-gen-ic { font-size: 13px; }
.ki-tabs .kl-gen .kl-gen-t { font-size: 12px; }
@media (max-width: 560px) {
  /* 窄屏：页签行折行，按钮独占一行并撑满 */
  .ki-tabs { flex-wrap: wrap; }
  .ki-tabs-sp { display: none; }
  .ki-tabs .kl-gen {
    flex: 1 1 100%; flex-direction: row; gap: 7px;
    min-width: 0; margin: 8px 0 0;
  }
}

/* ---------- 统计条 ---------- */
.kl-stats { display: flex; gap: 12px; margin-bottom: 18px; }
.kl-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px; border-radius: 12px;
  background: linear-gradient(180deg, #fff7f9, #fff);
  border: 1px solid #f6e2e7;
}
.kl-stat b { font-size: 22px; color: #b03a52; font-weight: 700; }
.kl-stat span { font-size: 12px; color: #8b7378; }

/* ---------- 关卡列表 ---------- */
.ki-levels { display: flex; flex-direction: column; gap: 10px; }
.ki-level {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; text-align: left; font-family: inherit;
  border: 1px solid #f0e2e6; border-radius: 12px;
  background: #fff; cursor: pointer; transition: all .15s;
}
.ki-level:hover {
  border-color: #e0657f; box-shadow: 0 3px 14px rgba(176, 58, 82, .13);
  transform: translateY(-1px);
}
.ki-level-done { background: linear-gradient(90deg, #fffafb, #fff); }
.ki-level-no {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  background: #fdeaee; color: #b03a52;
}
.ki-level-done .ki-level-no { background: #b03a52; color: #ffd966; }
.ki-level-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ki-level-name { font-size: 16px; font-weight: 600; color: #1f2933; }
.ki-level-meta { font-size: 12px; color: #8b939c; }
.ki-level-go { font-size: 13px; color: #b03a52; font-weight: 600; flex: none; }

/* ---------- 对局 ---------- */
.ki-game { display: flex; flex-direction: column; gap: 16px; }
.ki-top { display: flex; align-items: center; gap: 14px; }
.ki-lv-name { font-size: 16px; font-weight: 700; color: #b03a52; }

.ki-hud { display: flex; gap: 10px; }
.ki-hud-cell {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 6px; border-radius: 10px; background: #fbfcfe;
  border: 1px solid #edf1f5;
}
.ki-hud-cell b { font-size: 19px; color: #1f2933; font-weight: 700; }
.ki-hud-cell span { font-size: 11px; color: #98a2ad; }
.ki-time-low { color: #d93025 !important; animation: ki-pulse .8s infinite; }
@keyframes ki-pulse { 50% { opacity: .45; } }

.ki-bar {
  height: 8px; border-radius: 999px; background: #f1f4f7; overflow: hidden;
}
.ki-bar i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #e0657f, #b03a52);
  transition: width .3s ease;
}

/* 已接龙链 */
.ki-chain {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 8px;
  padding: 16px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #fff9fa, #fff);
  border: 1px solid #f6e2e7;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  min-height: 62px;
}
.ki-word {
  flex: none; padding: 7px 13px; border-radius: 9px;
  font-size: 16px; font-weight: 600; letter-spacing: 1px;
  background: #fff; border: 1px solid #f0dfe4; color: #6b5560;
  white-space: nowrap;
}
.ki-word-cur {
  background: #b03a52; border-color: #b03a52; color: #fff;
  box-shadow: 0 3px 10px rgba(176, 58, 82, .28);
}
.ki-arrow { flex: none; color: #d9c3c9; font-size: 14px; }

/* 输入行 */
.ki-input-row { display: flex; gap: 10px; }
.ki-input {
  flex: 1; padding: 13px 16px; font-size: 17px; font-family: inherit;
  letter-spacing: 2px; border: 2px solid #f0dfe4; border-radius: 11px;
  background: #fff; outline: none; transition: border-color .15s;
}
.ki-input:focus { border-color: #b03a52; }
.ki-input-row .kid-btn { flex: none; padding: 0 26px; font-size: 15px; }

.ki-tools { display: flex; gap: 10px; }
.ki-tools .kid-btn { flex: 1; }

.ki-warn {
  min-height: 20px; font-size: 13px; color: #8b7378; text-align: center;
}
.ki-warn-ok { color: #2f9e6f; font-weight: 600; }
.ki-warn-hint { color: #b8860b; }

/* ---------- 结算 ---------- */
.ki-result {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 24px; border-radius: 16px; text-align: center;
  background: #fff; border: 1px solid #edf1f5;
}
.ki-result-ic { font-size: 58px; line-height: 1; }
.ki-result h2 { margin: 0; font-size: 22px; color: #1f2933; }
.ki-result-score { display: flex; flex-direction: column; gap: 4px; }
.ki-result-score b { font-size: 40px; color: #b03a52; font-weight: 800; }
.ki-result-score span { font-size: 12px; color: #98a2ad; }
.ki-result-meta { font-size: 13px; color: #6b7480; }
.ki-result-btns { display: flex; gap: 12px; margin-top: 10px; }
.ki-result-btns .kid-btn { padding: 10px 28px; }
.ki-result-win { background: linear-gradient(180deg, #fffdf5, #fff); }

/* ---------- 成语库 ---------- */
.ki-lib-hint { font-size: 12px; color: #98a2ad; margin-bottom: 12px; }
.ki-idioms {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.ki-idio {
  position: relative; display: flex; flex-direction: column; gap: 5px;
  padding: 14px 15px; text-align: left; font-family: inherit;
  border: 1px solid #ebeff2; border-radius: 12px;
  background: #fff; cursor: pointer; transition: all .15s;
}
.ki-idio:hover {
  border-color: #e0657f; box-shadow: 0 3px 12px rgba(176, 58, 82, .11);
  transform: translateY(-2px);
}
.ki-idio-t { font-size: 17px; font-weight: 700; color: #1f2933; letter-spacing: 1px; }
.ki-idio-p { font-size: 11px; color: #b08d5a; }
.ki-idio-m {
  font-size: 12px; color: #6b7480; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ki-diff {
  position: absolute; top: 11px; right: 11px;
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
}
.ki-diff-1 { background: #eef7f2; color: #2f9e6f; }
.ki-diff-2 { background: #fff6e5; color: #c98a09; }
.ki-diff-3 { background: #fdeaee; color: #b03a52; }

/* 成语详情 */
.ki-detail-head { text-align: center; margin-bottom: 18px; }
.ki-detail-head h2 {
  margin: 0 0 6px; font-size: 28px; letter-spacing: 4px; color: #1f2933;
}
.ki-detail-py { font-size: 13px; color: #b08d5a; letter-spacing: 1px; }

.ki-cans { display: flex; flex-wrap: wrap; gap: 8px; }
.ki-can {
  padding: 5px 12px; font-size: 14px; border-radius: 8px;
  background: #fff7f9; border: 1px solid #f6e2e7; color: #b03a52;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  .kl-hero { padding: 18px; gap: 12px; }
  .kl-hero h1 { font-size: 19px; }
  .kl-hero-ic { font-size: 32px; }
  .kl-detail-card { padding: 18px 16px; }
  .kl-poems { grid-template-columns: repeat(2, 1fr); }
  .ki-idioms { grid-template-columns: 1fr; }
  .ki-hud { flex-wrap: wrap; }
  .ki-hud-cell { flex: 1 0 40%; }
  .kl-stats { flex-wrap: wrap; }
  .kl-stat { flex: 1 0 40%; }
  .kl-nav { flex-direction: column; }
  .ki-input-row .kid-btn { padding: 0 16px; }
  .ki-result-btns { flex-direction: column; width: 100%; }
  .ki-result-btns .kid-btn { width: 100%; }
}
