:root {
  --paper: #fff6eb;
  --ink: #2b2d42;
  --muted: #6d7088;
  --card: #ffffff;
  --sun: #ffd166;
  --peach: #f4a261;
  --coral: #e76f51;
  --sky: #7ec8e3;
  --mint: #8ad4a1;
  --lilac: #cbb2fe;
  --shadow: 0 12px 30px rgba(43, 45, 66, 0.1);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #ffe7c7 0%, transparent 55%),
    radial-gradient(900px 400px at 110% 0%, #d6f3ff 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Nunito", "Segoe UI", sans-serif;
}

body {
  padding: 16px 16px 32px;
}

button,
.card-btn {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

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

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.stats {
  display: flex;
  gap: 8px;
}

.pill {
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

.hero,
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.hero {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.cat {
  width: 128px;
  height: 128px;
  border-radius: 28px;
  object-fit: cover;
  display: block;
  box-shadow: 0 8px 18px rgba(183, 110, 72, 0.22);
}

.panel .cat {
  margin: 0 auto 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  min-height: 132px;
}

.mode .emoji {
  font-size: 1.8rem;
}

.mode strong {
  font-size: 1.1rem;
}

.mode span {
  color: var(--muted);
  font-size: 0.88rem;
}

.mode.listen { background: linear-gradient(180deg, #e8f8ff, #fff); }
.mode.speak { background: linear-gradient(180deg, #ffe8df, #fff); }
.mode.read { background: linear-gradient(180deg, #fff4d6, #fff); }
.mode.words { background: linear-gradient(180deg, #e9fbe9, #fff); }
.mode.speak,
.mode.book,
.mode.extra {
  grid-column: 1 / -1;
  min-height: 96px;
}
.mode.book { background: linear-gradient(180deg, #efe7ff, #fff); }
.mode.extra { background: linear-gradient(180deg, #ffe8c7, #fff); }

.book-count {
  font-weight: 800;
  color: var(--muted);
  margin: 0 0 12px;
}

.book-tools {
  margin-top: 0;
}

.book-head {
  margin: 14px 4px 8px;
  font-weight: 800;
  color: var(--muted);
}

.book-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.book-row {
  width: 100%;
  display: block;
  text-align: left;
  background: #fff;
  color: inherit;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.book-row b {
  display: block;
  font-size: 1.12rem;
  line-height: 1.35;
}

.book-row .ipa {
  display: block;
  margin-top: 2px;
  color: #c47b5a;
  font-size: 0.95rem;
  font-weight: 700;
}

.book-row small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.book-row .miss {
  color: var(--coral);
}

.book-row.on,
.book-sound.on {
  outline: 3px solid var(--sky);
  background: #e8f8ff;
}

.story-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 16px;
  flex-shrink: 0;
}

.story-cover,
.scene-art {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.story-cover {
  border-radius: 22px;
  margin: 4px 0 12px;
  box-shadow: var(--shadow);
}

.story-pages {
  display: grid;
  gap: 18px;
  margin-top: 12px;
}

.scene-card {
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.scene-card h3 {
  margin: 14px 16px 0;
  font-size: 1.05rem;
}

.scene-lines {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.scene-lines .book-row {
  background: #fbf7f2;
  box-shadow: none;
}

.scene-lines .book-row.on {
  background: #e8f8ff;
}

.book-sound {
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-align: left;
  padding: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  background: #f7f3ee;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}

.cover-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.cover-row button {
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.cover-row button.on,
.item.choice.on {
  background: #f3ebff;
  outline: 3px solid var(--lilac);
}

.listen-label {
  margin: 8px 0 0;
  font-weight: 800;
}

.paper-card {
  margin-top: 16px;
  min-height: 160px;
  border-radius: 18px;
  background-color: #fff;
  background-image: repeating-linear-gradient(#fff, #fff 31px, #f6e7d6 32px);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  text-align: center;
}

.paper-card .emoji {
  font-size: 2rem;
}

.paper-card p {
  margin: 0;
  font-weight: 800;
}

.dictation-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  position: sticky;
  bottom: 0;
  padding: 8px 0 4px;
  background: linear-gradient(transparent, var(--paper) 28%);
}

.wrote {
  margin: 6px 0 10px;
  color: var(--muted);
}

.book-kind {
  display: inline-block;
  background: #efe7ff;
  color: #5b3d8f;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.dialogue {
  background: #fff;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.dialogue .en {
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.4;
}

.dialogue .zh {
  color: var(--muted);
  margin: 2px 0 0;
}

.score-card {
  background: #fff;
  border-radius: 20px;
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.score-card .emoji {
  font-size: 2.4rem;
}

.score-card strong {
  display: block;
  font-size: 2.4rem;
  margin: 6px 0;
}

.score-card p {
  margin: 0;
  color: var(--muted);
}

.quiz .big-en {
  font-size: clamp(1.15rem, 3.2vw, 1.65rem);
}

.quiz-options button.good {
  outline: 3px solid #2a9d8f;
}

.quiz-options button.bad {
  outline: 3px solid var(--coral);
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.back,
.ghost,
.primary,
.secondary,
.danger-soft {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
}

.back,
.ghost {
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.primary {
  background: var(--peach);
  color: #fff;
}

.secondary {
  background: #2b2d42;
  color: #fff;
}

.danger-soft {
  background: #ffe8df;
  color: var(--coral);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: left;
}

.item .badge {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: #fff4d6;
  flex-shrink: 0;
}

.item b {
  display: block;
  font-size: 1.05rem;
}

.item small {
  color: var(--muted);
}

.line {
  padding: 14px 16px;
  border-radius: 18px;
  margin: 10px 0;
  background: #f7f3ee;
}

.line.active {
  background: #e8f8ff;
  outline: 3px solid var(--sky);
}

.line .en {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.line .zh {
  color: var(--muted);
}

.level-head {
  margin: 16px 4px 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.book {
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.book-scene {
  min-height: 190px;
  display: grid;
  place-items: center;
  font-size: 4.4rem;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff4d6, #fff);
}

.book-text {
  padding: 4px 22px 22px;
  text-align: center;
}

.book-text .en {
  font-size: clamp(1.35rem, 4.4vw, 1.9rem);
  font-weight: 800;
  line-height: 1.4;
  margin-top: 8px;
}

.book-text .zh {
  color: var(--muted);
  margin-top: 4px;
}

.page-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.page-dots .dot {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 99px;
  background: transparent;
}

.page-dots .dot::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 17px auto 0;
  border-radius: 99px;
  background: #efe7dc;
}

.page-dots .dot.on::after {
  width: 22px;
  margin-left: 11px;
  background: var(--peach);
}

.big-en {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.25;
  margin: 8px 0 6px;
  font-weight: 800;
}

.zh-hint {
  color: var(--muted);
  font-size: 1.05rem;
}

.status {
  min-height: 1.4em;
  margin-top: 10px;
  font-weight: 700;
}

.status.ok { color: #2a9d8f; }
.status.bad { color: var(--coral); }

.progress {
  height: 10px;
  background: #efe7dc;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 16px;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--peach), var(--sun));
  width: 0;
  transition: width 0.25s ease;
}

.word-card {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  background: linear-gradient(180deg, #fff4d6, #fff);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.word-card .emoji {
  font-size: 3.2rem;
}

.word-card .big-en {
  font-size: clamp(1.25rem, 3.6vw, 1.85rem);
  line-height: 1.35;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.quiz-options button {
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 16px 12px;
  font-size: 1.15rem;
  font-weight: 800;
}

.quiz-options.stack {
  grid-template-columns: 1fr;
}

.quiz-options.stack button {
  text-align: left;
  font-size: 1.05rem;
  line-height: 1.35;
}

.word {
  display: inline;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  border-radius: 6px;
}

.word:hover,
.word:focus {
  background: #ffe7c7;
}

.hidden { display: none !important; }

.tip {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(46vh, 420px);
  overflow: auto;
  padding: 2px 2px 8px;
}

.bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 18px;
}

.bubble.pip {
  align-self: flex-start;
  background: #e8f8ff;
  border-bottom-left-radius: 6px;
}

.bubble.me {
  align-self: flex-end;
  background: #fff4d6;
  border-bottom-right-radius: 6px;
}

.bubble .who {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 2px;
}

.bubble .en {
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.35;
}

.bubble .zh {
  color: var(--muted);
  margin-top: 2px;
}

.replies {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.replies button {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 14px 16px;
}

.replies .en {
  display: block;
  font-size: 1.08rem;
  font-weight: 800;
}

.replies .zh {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 520px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .cat {
    margin: 0 auto;
  }
}
