/* =================================================================
 * Sight Word Kids —— 全站样式
 * 风格参考 level1.jpg / level2.jpg 海报：彩色大单词 + 插图 + 例句
 * ================================================================= */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --l1: #3fa34d;          /* level1 主色（海报绿） */
  --l1-dark: #2e7d32;
  --l1-soft: #e8f6ea;
  --l2: #1f9fd8;          /* level2 主色（海报蓝） */
  --l2-dark: #0d6f9e;
  --l2-soft: #e4f4fb;
  --ink: #2b2b2b;
  --muted: #6b7280;
  --pop: #ffd54f;
}

html, body {
  margin: 0; padding: 0;
  font-family: "Comic Sans MS", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none; -webkit-user-select: none;
  background: #fdfdf7;
}

/* 主题背景 */
body.theme-l1 {
  background:
    radial-gradient(1200px 400px at 50% -120px, #d7f0d9 0%, rgba(255,255,255,0) 70%),
    linear-gradient(180deg, #f4fbf4 0%, #eef8ef 100%);
}
body.theme-l2 {
  background:
    radial-gradient(1200px 400px at 50% -120px, #d3ecf8 0%, rgba(255,255,255,0) 70%),
    linear-gradient(180deg, #f3fafd 0%, #e9f5fb 100%);
}
body.theme-home {
  background:
    radial-gradient(1000px 460px at 50% -80px, #ffe6a7 0%, rgba(255,255,255,0) 70%),
    linear-gradient(180deg, #fff9ee 0%, #fff3d9 100%);
}

main {
  padding: 74px 14px 112px;
  max-width: 1240px;
  margin: 0 auto;
}

/* ---------------- 左上角悬浮录音条 ---------------- */
.rec-float {
  position: fixed; top: 10px; left: 10px;
  z-index: 120;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  max-width: min(74vw, 460px);
}
.rec-float .rec-btn { font-size: 16px; padding: 9px 18px; }
.rec-float .rec-status {
  font-size: 12px; line-height: 1.35;
  background: rgba(255,255,255,.94);
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: 4px 9px;
  color: #5d4037;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  max-width: 100%;
}

.rec-btn {
  border: none; background: #fff; color: #e65100;
  font-weight: bold; font-size: 18px;
  padding: 10px 22px; border-radius: 26px;
  box-shadow: 0 3px 0 #e65100;
  cursor: pointer; white-space: nowrap;
  transition: transform .1s ease, box-shadow .1s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.rec-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #e65100; }
.rec-btn.is-recording {
  background: #e53935; color: #fff; box-shadow: 0 3px 0 #b71c1c;
  animation: pulse 1.2s infinite;
}
.rec-btn.is-paused {
  background: #fb8c00; color: #fff; box-shadow: 0 3px 0 #e65100;
  animation: pulse 1.6s infinite;
}
.rec-dot { display: inline-block; width: 12px; height: 12px; background: #b71c1c; border-radius: 50%; }
.rec-btn.is-recording .rec-dot, .rec-btn.is-paused .rec-dot { background: #fff; }

@keyframes pulse {
  0%,100% { box-shadow: 0 3px 0 #b71c1c, 0 0 0 0 rgba(229,57,53,.6); }
  50%     { box-shadow: 0 3px 0 #b71c1c, 0 0 0 8px rgba(229,57,53,0); }
}

/* ---------------- 底部常驻 dock ---------------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
  background: #fff; padding: 8px; border-radius: 36px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  z-index: 130; border: 2px solid var(--pop);
}
.dock-bottom { bottom: 10px; }
.dock-btn {
  border: none; background: #fff8e1; color: #6d4c00;
  font-weight: bold; font-size: 16px; padding: 10px 18px;
  border-radius: 26px; cursor: pointer; transition: background .15s;
}
.dock-btn:hover:not(:disabled) { background: #ffe082; }
.dock-btn:disabled { opacity: .4; cursor: not-allowed; }
.dock-home { background: var(--pop); color: #4a2c00; }

body.nav-locked .dock-btn { opacity: .45; filter: grayscale(1); }
body.nav-locked .dock-btn:disabled { opacity: .25; }
body.nav-locked .dock::after {
  content: '🔒 先下载 / 分享录音';
  position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: bold;
  color: #b71c1c; background: #fff; border: 1px solid #ef9a9a;
  border-radius: 12px; padding: 3px 10px;
}
.rec-status.is-warn { color: #b71c1c !important; font-weight: bold; }

/* ---------------- 录音结果右侧悬浮框 ---------------- */
.rec-pop {
  position: fixed; top: 76px; right: 10px; width: 280px;
  background: #fff; border: 2px solid var(--l1);
  border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
  padding: 12px 14px; z-index: 140;
  animation: slideInRight .25s ease-out;
}
.rec-pop-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 15px; color: var(--l1-dark); font-weight: bold;
}
.rec-pop-close { border: none; background: transparent; font-size: 22px; cursor: pointer; color: #999; }
.rec-pop-loading { font-size: 13px; color: #ef6c00; text-align: center; padding: 14px 0; }
.rec-pop-note {
  font-size: 12px; color: #c62828; background: #ffebee;
  border-radius: 8px; padding: 6px 8px; margin-bottom: 8px;
}
.rec-pop-lock {
  font-size: 12px; color: #8d6e00; font-weight: bold;
  background: #fff8e1; border: 1px dashed #ffca28; border-radius: 8px;
  padding: 6px 8px; margin-bottom: 8px; line-height: 1.5;
}
.rec-pop.shake { animation: popShake .4s ease; }
@keyframes popShake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); }
}
.rec-pop-row { margin: 6px 0; }
.rec-pop-row audio { width: 100%; height: 38px; }
.rec-pop-action {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font-size: 15px; font-weight: bold; border-radius: 12px;
  border: 2px solid; cursor: pointer; text-align: center;
  text-decoration: none; background: #fff;
}
.rec-pop-action.dl { color: #1565c0; border-color: #1565c0; background: #e3f2fd; }
.rec-pop-action.sh { color: #2e7d32; border-color: #2e7d32; background: #e8f5e9; }
.rec-pop-action:hover { filter: brightness(.97); }
.rec-pop-qr img { max-width: 100%; }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------------- 主页 ---------------- */
.home-wrap { text-align: center; padding-top: 18px; }
.home-title {
  font-size: clamp(38px, 8vw, 76px);
  margin: 6px 0 2px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.05;
}
.home-title .t1 { color: #e53935; }
.home-title .t2 { color: #f9a825; }
.home-title .t3 { color: #43a047; }
.home-title .t4 { color: #1e88e5; }
.home-title .t5 { color: #8e24aa; }
.home-sub {
  display: inline-block;
  font-size: clamp(13px, 2.4vw, 17px);
  color: #7a5c00;
  background: #fff6d8;
  border: 2px dashed #ffca28;
  border-radius: 999px;
  padding: 8px 20px;
  margin: 14px 0 6px;
  font-weight: bold;
}
.home-encourage {
  font-size: clamp(15px, 2.6vw, 20px);
  color: #5d4037;
  margin: 12px auto 4px;
  max-width: 720px;
  line-height: 1.7;
}
.home-encourage .hl { color: #e65100; font-weight: bold; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  max-width: 880px;
  margin: 30px auto 0;
  padding: 0 6px;
}
.level-card {
  display: block; text-decoration: none; color: inherit;
  background: #fff; border-radius: 22px;
  border: 4px solid var(--l1);
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
  padding: 18px 16px 20px;
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
}
.level-card.lv2 { border-color: var(--l2); }
.level-card:hover, .level-card:active { transform: translateY(-4px); box-shadow: 0 14px 26px rgba(0,0,0,.18); }
.level-card img { width: 100%; max-width: 320px; display: block; margin: 0 auto 8px; border-radius: 12px; }
.level-card .lv-name { font-size: 26px; font-weight: 900; color: var(--l1-dark); }
.level-card.lv2 .lv-name { color: var(--l2-dark); }
.level-card .lv-desc { font-size: 14px; color: var(--muted); margin-top: 4px; }
.level-card .lv-go {
  display: inline-block; margin-top: 10px; font-weight: bold; font-size: 16px;
  background: var(--l1); color: #fff; border-radius: 999px; padding: 8px 26px;
}
.level-card.lv2 .lv-go { background: var(--l2); }

.home-tips {
  margin: 26px auto 0; max-width: 760px; text-align: left;
  background: #fff; border-radius: 16px; padding: 14px 18px;
  border: 2px solid #ffe082; font-size: 14px; color: #5d4037; line-height: 1.9;
}
.home-tips b { color: #e65100; }

/* ---------------- 内容页（Level 1 / 2）---------------- */
.page-head { text-align: center; margin-bottom: 16px; }
.page-head .pt {
  display: inline-block; font-size: clamp(24px, 4.6vw, 38px); font-weight: 900;
  margin: 0; letter-spacing: .5px;
}
body.theme-l1 .pt { color: var(--l1); }
body.theme-l2 .pt { color: var(--l2); }
.page-head .ps { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
body.theme-l2 .word-grid { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }

.card {
  background: #fff;
  border-radius: 14px;
  padding: 8px 8px 10px;
  border: 2px solid var(--l1-soft);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  transition: box-shadow .15s, transform .15s;
}
body.theme-l2 .card { border-color: var(--l2-soft); }
.card:hover { box-shadow: 0 6px 16px rgba(0,0,0,.12); }

.card .no {
  position: absolute; top: 5px; left: 8px;
  font-size: 11px; color: #bbb; font-weight: bold;
}

/* 单词按钮 */
.card .word {
  font-size: clamp(24px, 4.4vw, 34px);
  font-weight: 900;
  line-height: 1.15;
  color: var(--l1);
  cursor: pointer;
  text-align: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: "Comic Sans MS", "Segoe UI", sans-serif;
  transition: background .12s, transform .1s;
}
body.theme-l2 .card .word { color: var(--l2); }
.card .word:hover { background: var(--l1-soft); }
body.theme-l2 .card .word:hover { background: var(--l2-soft); }
.card .word.is-playing { background: #fff3c4; transform: scale(.96); }
.card .zh { font-size: 11px; color: #9aa0a6; margin-top: 1px; }

/* 插图 */
.card .pic {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 46px;
  margin: 4px 0 6px;
}
.card .pic img { max-width: 100%; height: auto; display: block; }

/* 例句按钮 */
.card .sent {
  margin-top: auto;
  width: 100%;
  font-size: clamp(12.5px, 2.1vw, 14.5px);
  line-height: 1.45;
  color: #333;
  background: var(--l1-soft);
  border: 1.5px solid #cfe9d3;
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  text-align: center;
  transition: background .12s;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
body.theme-l2 .card .sent { background: var(--l2-soft); border-color: #c6e6f5; }
.card .sent:hover { background: #d6efdb; }
body.theme-l2 .card .sent:hover { background: #cfeafa; }
.card .sent.is-playing { background: #fff3c4; border-color: #ffca28; }
.card .sent .spk { margin-right: 5px; opacity: .65; font-size: 12px; }

/* ---------------- 录音中提示 ---------------- */
.rec-indicator {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: rgba(229,57,53,.95); color: #fff;
  padding: 6px 16px; border-radius: 18px; font-size: 14px;
  z-index: 90; display: none;
}
.rec-indicator.on { display: block; animation: pulse 1.2s infinite; }

/* ---------------- 返回 Shelly 主页 ---------------- */
.ai-home-link {
  position: fixed; top: 12px; right: 12px; z-index: 95;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap;
  font-size: 14px; font-weight: bold; color: #0b3d91;
  background: linear-gradient(135deg, #ffffff 0%, #e8f4ff 100%);
  border: 2px solid #4aa3ff; border-radius: 999px;
  padding: 9px 16px;
  box-shadow: 0 4px 14px rgba(20,80,180,.22);
  transition: transform .15s, box-shadow .15s;
}
.ai-home-link:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,80,180,.3); }
.ai-home-link:active { transform: translateY(0) scale(.97); }

.home-back-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none; margin: 34px auto 0;
  font-size: clamp(15px, 2.6vw, 19px); font-weight: 900; color: #fff;
  background: linear-gradient(135deg, #00b4ff 0%, #0066ff 55%, #7b5cff 100%);
  border-radius: 999px; padding: 15px 34px;
  box-shadow: 0 10px 26px rgba(20,80,180,.32);
  transition: transform .18s, box-shadow .18s;
}
.home-back-btn:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(20,80,180,.4); }
.home-back-btn:active { transform: translateY(-1px) scale(.98); }

@media (max-width: 520px) {
  .ai-home-link { top: 8px; right: 8px; font-size: 12.5px; padding: 7px 12px; }
  .rec-float { max-width: 66vw; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  body.theme-l2 .word-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .card .pic { min-height: 34px; }
}
