:root {
  --ink: #2b2141;
  --muted: #7c7393;
  --brand: #ff5a7a;
  --brand2: #ff8fb0;
  --accent: #4a90ff;
  --sun: #ffb52e;
  --mint: #34c89a;
  --card-radius: 22px;
  --shadow: 0 10px 30px rgba(92, 62, 140, .10);
  --shadow-press: 0 4px 14px rgba(92, 62, 140, .14);
  --bg1: #fdf4ee;
  --bg2: #eef4ff;
  --font-en: "Chalkboard SE", "Comic Sans MS", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-zh: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-zh);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffe3d2 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #dfeaff 0%, transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  min-height: 100vh;
}
.app { max-width: 980px; margin: 0 auto; padding: 0 18px 48px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 4px 12px;
  backdrop-filter: blur(8px);
}
.back-btn {
  width: 42px; height: 42px; border: none; border-radius: 14px;
  background: #fff; box-shadow: var(--shadow);
  font-size: 30px; line-height: 1; color: var(--ink);
  cursor: pointer; display: none; align-items: center; justify-content: center;
}
.back-btn.show { display: flex; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; }
.brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 15px;
  background: linear-gradient(145deg, var(--brand), #ff8a5c);
  color: #fff; font-family: var(--font-en); font-weight: 800; font-size: 13px;
  line-height: 1.05; text-align: center; box-shadow: var(--shadow-press);
}
.brand-series { font-size: 13px; color: var(--muted); letter-spacing: .5px; }
.brand-title { font-size: 19px; font-weight: 800; }
.qrcode-hint {
  border: none; background: rgba(255,255,255,.8); box-shadow: var(--shadow);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; color: var(--muted);
}

/* ---------- home ---------- */
.hero {
  margin: 18px 0 26px; padding: 30px 28px;
  border-radius: 28px;
  background: linear-gradient(135deg, #fff 0%, #fff6f0 60%, #f1f6ff 100%);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.35; }
.hero h1 .hl { color: var(--brand); }
.hero p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.hero .deco { position: absolute; right: -30px; top: -30px; font-size: 150px; opacity: .08; transform: rotate(12deg); }

.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.unit-card {
  display: block; text-decoration: none; color: inherit;
  background: #fff; border-radius: var(--card-radius); padding: 22px;
  box-shadow: var(--shadow); border: 3px solid transparent;
  transition: transform .15s ease, border-color .15s ease;
  position: relative; overflow: hidden;
}
.unit-card:active { transform: scale(.98); }
.unit-card:hover { border-color: var(--brand2); }
.unit-card .no {
  font-family: var(--font-en); font-weight: 800; font-size: 15px;
  color: #fff; background: linear-gradient(145deg, var(--accent), #7b6bff);
  padding: 5px 12px; border-radius: 999px; display: inline-block;
}
.unit-card h3 { font-family: var(--font-en); margin: 14px 0 6px; font-size: 20px; line-height: 1.3; }
.unit-card p { margin: 0; color: var(--muted); font-size: 13px; }
.unit-card .go { position: absolute; right: 18px; bottom: 16px; font-size: 22px; color: var(--brand); }
.unit-card .tags { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; background: #f3efff; color: #6b55b8; border-radius: 999px; padding: 3px 10px; }

/* ---------- unit page ---------- */
.unit-head {
  margin: 10px 0 16px; padding: 24px 24px 20px;
  border-radius: 26px; color: #fff;
  background: linear-gradient(135deg, #ff6a86 0%, #ff9466 55%, #ffb347 100%);
  box-shadow: var(--shadow);
}
.unit-head .kicker { font-family: var(--font-en); font-weight: 800; font-size: 14px; opacity: .9; letter-spacing: 1px; }
.unit-head h2 { font-family: var(--font-en); margin: 8px 0 0; font-size: 23px; line-height: 1.35; }
.unit-head .zh { margin-top: 8px; font-size: 13px; opacity: .85; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: #fff; border-radius: 18px; padding: 10px 14px;
  box-shadow: var(--shadow); margin-bottom: 22px;
}
.seg { display: inline-flex; background: #f2eefb; border-radius: 999px; padding: 4px; }
.seg button {
  border: none; background: transparent; padding: 7px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow-press); }
.toolbar .spacer { flex: 1; }
.btn {
  border: none; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: #eef4ff; color: var(--accent);
}
.btn.pink { background: #fff0f4; color: var(--brand); }
.btn:active { transform: scale(.96); }

.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 6px 2px 14px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 19px; }
.section-head .en { color: var(--muted); font-family: var(--font-en); font-size: 13px; }
.section-head .spacer { flex: 1; }

/* word cards */
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.word-card {
  border: none; background: #fff; border-radius: 20px; padding: 10px 10px 12px;
  box-shadow: var(--shadow); cursor: pointer; text-align: center;
  transition: transform .12s ease; position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.word-card:active { transform: scale(.95); }
.word-card .pic {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden;
  background: #f6f2ff; display: flex; align-items: center; justify-content: center;
}
.word-card .pic img { width: 100%; height: 100%; object-fit: cover; }
.word-card .pic .big {
  font-family: var(--font-en); font-weight: 800; font-size: 34px; color: var(--accent);
  line-height: 1; word-break: break-all; padding: 8px;
}
.word-card .w { font-family: var(--font-en); font-weight: 800; font-size: 23px; margin-top: 9px; }
.word-card .sy { font-family: var(--font-en); color: var(--muted); font-size: 13px; margin-top: 2px; }
.word-card .play-dot {
  position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px;
  border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  opacity: 0; transition: opacity .15s;
}
.word-card.playing { outline: 3px solid var(--brand2); }
.word-card.playing .play-dot { opacity: 1; }

/* phonics families */
.family { margin-bottom: 18px; }
.family .rhyme {
  display: inline-block; font-family: var(--font-en); font-weight: 800; font-size: 20px;
  color: #fff; background: linear-gradient(145deg, var(--mint), #27a98a);
  padding: 6px 18px; border-radius: 999px; margin: 0 0 12px 4px;
}
.family .mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.mini-card {
  border: 3px dashed #ffd6a8; background: #fffdf8; border-radius: 18px; padding: 14px 10px;
  text-align: center; cursor: pointer; box-shadow: var(--shadow);
}
.mini-card:active { transform: scale(.96); }
.mini-card.playing { border-color: var(--brand); background: #fff; }
.mini-card .w { font-family: var(--font-en); font-weight: 800; font-size: 26px; color: #d97706; }
.mini-card .sy { font-family: var(--font-en); color: var(--muted); font-size: 13px; margin-top: 3px; }

/* sentences */
.sent-list { display: flex; flex-direction: column; gap: 10px; }
.sent-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: #fff; border: none; border-radius: 18px; padding: 14px 18px;
  box-shadow: var(--shadow); cursor: pointer;
}
.sent-card:active { transform: scale(.99); }
.sent-card .idx {
  flex: 0 0 34px; height: 34px; border-radius: 10px; background: #eef4ff; color: var(--accent);
  font-family: var(--font-en); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.sent-card .body { flex: 1; min-width: 0; }
.sent-card .en { font-family: var(--font-en); font-size: 18px; font-weight: 700; line-height: 1.35; }
.sent-card .zh { color: var(--muted); font-size: 13px; margin-top: 3px; }
.sent-card .spk { flex: 0 0 auto; font-size: 20px; color: var(--brand); }
.sent-card.playing { outline: 3px solid var(--brand2); }
.sent-card.playing .idx { background: var(--brand); color: #fff; }

/* now-playing bar */
.np {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(120%);
  background: rgba(43, 33, 65, .92); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); transition: transform .25s ease; z-index: 50;
  max-width: 92vw;
}
.np.show { transform: translateX(-50%) translateY(0); }
.np button { border: none; background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.np .bars { display: inline-flex; gap: 2px; align-items: end; height: 14px; }
.np .bars i { width: 3px; background: var(--brand2); animation: bar .8s infinite ease-in-out; }
.np .bars i:nth-child(2) { animation-delay: .15s; height: 14px; }
.np .bars i:nth-child(1) { animation-delay: 0s; height: 9px; }
.np .bars i:nth-child(3) { animation-delay: .3s; height: 11px; }
@keyframes bar { 0%,100% { transform: scaleY(.5);} 50% { transform: scaleY(1);} }

@media (max-width: 520px) {
  .hero { padding: 22px; }
  .hero h1 { font-size: 21px; }
  .unit-head h2 { font-size: 19px; }
  .qrcode-hint { display: none; }
}

/* ---------- large tablets / iPad landscape ---------- */
@media (min-width: 1100px) {
  .app { max-width: 1180px; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 16px; }
  .mini-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .hero h1 { font-size: 30px; }
}
button, a { touch-action: manipulation; }

/* section play / restart controls */
.btn-icon { padding: 9px 12px; }
.play-btn.live {
  background: var(--brand);
  color: #fff;
  animation: pulse 1.6s infinite ease-in-out;
}
.play-btn .ic { font-size: 12px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 122, .35); }
  50% { box-shadow: 0 0 0 7px rgba(255, 90, 122, 0); }
}
