/* ============================ Word Tree Readers ============================ */
:root {
  --rd-ink: #292524;
  --rd-muted: #78716c;
  --rd-amber: #b45309;
  --rd-amber-soft: #fef3c7;
  --rd-card: #ffffff;
  --rd-bg: #fffbeb;
}

body { background: var(--rd-bg); }

.hidden { display: none !important; }

.rd-loading {
  padding: 80px 20px;
  text-align: center;
  color: var(--rd-muted);
  font-size: 1.05rem;
}

.rd-app { max-width: 980px; margin: 0 auto; padding: 18px 16px 60px; }

/* ------------------------------- top bar ------------------------------- */
.rd-topbar { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.rd-home {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #f3e8d8;
  text-decoration: none;
  font-size: 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.rd-kicker { font-size: .72rem; font-weight: 800; letter-spacing: .12em; color: var(--rd-amber); }
.rd-heading h1 { margin: 4px 0 6px; font-size: 1.5rem; color: var(--rd-ink); }
.rd-desc { margin: 0; color: var(--rd-muted); font-size: .92rem; max-width: 640px; }

/* ------------------------------ cast card ------------------------------ */
.rd-cast-card {
  display: flex; gap: 16px; align-items: center;
  background: var(--rd-card);
  border: 1px solid #f3e8d8;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.rd-cast-card img {
  width: 320px; max-width: 46%;
  border-radius: 12px;
  background: #fff;
}
.rd-cast-note h3 { margin: 0 0 6px; color: var(--rd-ink); font-size: 1.02rem; }
.rd-cast-note p { margin: 0; color: var(--rd-muted); font-size: .88rem; line-height: 1.6; }

/* ------------------------------- shelves ------------------------------- */
.rd-stage { margin-bottom: 26px; }
.rd-stage-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.rd-stage-head h2 { margin: 0; font-size: 1.12rem; color: var(--rd-ink); }
.rd-stage-head .rd-stage-vocab { color: var(--rd-muted); font-size: .8rem; }
.rd-stage-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }

.rd-shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.rd-book {
  cursor: pointer;
  background: var(--rd-card);
  border: 1px solid #f3e8d8;
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
  padding: 0;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  font-family: inherit;
}
.rd-book:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.10); }
.rd-book img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.rd-book-meta { padding: 10px 12px 12px; }
.rd-book-meta strong { display: block; color: var(--rd-ink); font-size: .98rem; }
.rd-book-meta .zh { color: var(--rd-muted); font-size: .84rem; }
.rd-book-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.rd-tag {
  font-size: .7rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  background: var(--rd-amber-soft); color: var(--rd-amber);
}
.rd-tag.done { background: #dcfce7; color: #15803d; }

/* -------------------------------- reader -------------------------------- */
.rd-reader-nav {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.rd-text-btn {
  background: none; border: none; cursor: pointer;
  color: var(--rd-amber); font-weight: 700; font-size: .92rem;
  padding: 8px 10px; border-radius: 10px;
  font-family: inherit;
}
.rd-text-btn:hover { background: var(--rd-amber-soft); }
.rd-reader-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rd-reader-title strong { color: var(--rd-ink); font-size: 1.05rem; }
.rd-reader-title span { color: var(--rd-muted); font-size: .85rem; }
.rd-page-pos { color: var(--rd-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.rd-page-card {
  background: var(--rd-card);
  border: 1px solid #f3e8d8;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.07);
}
.rd-illust-wrap { background: #fdf6e3; }
.rd-illust-wrap img {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  display: block;
}
.rd-page-text { padding: 18px 22px 6px; text-align: center; }
.rd-en {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.5;
  color: var(--rd-ink);
  font-weight: 600;
}
.rd-zh { margin: 8px 0 0; color: var(--rd-muted); font-size: 1rem; }
.rd-zh.rd-zh-hidden { visibility: hidden; }

.rd-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 16px 18px; flex-wrap: wrap;
}
.rd-nav-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid #f3e8d8;
  background: #fff;
  font-size: 1.5rem; line-height: 1;
  color: var(--rd-amber);
  cursor: pointer;
  font-family: inherit;
}
.rd-nav-btn:disabled { opacity: .35; cursor: default; }
.rd-play, .rd-auto {
  border: none; cursor: pointer;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: .95rem; font-weight: 700;
  font-family: inherit;
}
.rd-play { background: var(--rd-amber); color: #fff; }
.rd-play.is-playing { background: #92400e; }
.rd-auto { background: var(--rd-amber-soft); color: var(--rd-amber); }
.rd-auto.is-playing { background: #92400e; color: #fff; }
.rd-toggle {
  border: 1px solid #f3e8d8; background: #fff;
  border-radius: 999px; padding: 12px 18px;
  font-size: .9rem; font-weight: 700; color: var(--rd-muted);
  cursor: pointer;
  font-family: inherit;
}
.rd-toggle.on { background: var(--rd-amber-soft); color: var(--rd-amber); border-color: #fcd34d; }

/* ------------------------------- finish -------------------------------- */
.rd-finish {
  margin-top: 16px;
  background: var(--rd-card);
  border: 1px solid #f3e8d8;
  border-radius: 16px;
  padding: 18px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.rd-finish h3 { margin: 0 0 6px; color: var(--rd-ink); }
.rd-finish p { margin: 0 0 10px; color: var(--rd-muted); font-size: .9rem; }
.rd-target-words { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.rd-word-chip {
  background: var(--rd-amber-soft); color: var(--rd-amber);
  font-weight: 700; font-size: .88rem;
  padding: 5px 14px; border-radius: 999px;
  cursor: pointer; border: none;
  font-family: inherit;
}
.rd-word-chip:hover { background: #fde68a; }
.rd-finish-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.rd-secondary {
  border: 1px solid #f3e8d8; background: #fff; color: var(--rd-muted);
  border-radius: 999px; padding: 10px 20px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.rd-complete {
  border: none; background: #16a34a; color: #fff;
  border-radius: 999px; padding: 10px 22px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}

/* -------------------------------- toast --------------------------------- */
.rd-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(41,37,36,.92); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: .88rem;
  z-index: 50;
}

@media (max-width: 640px) {
  .rd-cast-card { flex-direction: column; }
  .rd-cast-card img { width: 100%; max-width: 100%; }
  .rd-en { font-size: 1.2rem; }
  .rd-controls { gap: 8px; }
  .rd-play, .rd-auto { padding: 10px 16px; font-size: .88rem; }
}
