/* Drama player: a WeChat-style chat screen. Only used by /drama/play. */
body[data-page="play"] { background: #d9dcdf; }
body[data-page="play"] .top,
body[data-page="play"] .tabbar { display: none; }      /* immersive: no app header or tab bar */

.phone {
  --wx-bg: #ededed;
  --wx-green: #95ec69;
  --wx-text: #191919;
  --wx-grey: #8c8c8c;
  --wx-line: #d6d6d6;
  position: relative;
  max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--wx-bg); color: var(--wx-text);
  /* Vietnamese first so diacritics render right; Chinese falls through to a CJK font */
  font-family: "Be Vietnam Pro", -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overflow: hidden;
}
@media (min-width: 520px) { .phone { box-shadow: 0 0 40px rgba(0, 0, 0, 0.12); } }

/* ── title bar ─────────────────────────────────────── */
.wx-bar {
  flex: none; height: 48px; display: grid; grid-template-columns: 76px 1fr 76px; align-items: center;
  background: var(--wx-bg); border-bottom: 1px solid var(--wx-line);
  padding-top: env(safe-area-inset-top);
}
.wx-back { font-size: 30px; line-height: 1; text-decoration: none; color: var(--wx-text); text-align: center; border: 0; background: none; cursor: pointer; }
.wx-title { text-align: center; font-weight: 600; font-size: 16px; line-height: 1.15; overflow: hidden; }
.wx-title small { display: block; font-size: 11px; font-weight: 400; color: var(--wx-grey); }
.wx-more { border: 0; background: none; font-size: 15px; color: var(--wx-text); cursor: pointer; }
.wx-more[aria-pressed="false"] { opacity: 0.4; }
.wx-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; padding-right: 6px; }
.wx-py-toggle { font: 600 14px "PingFang SC", "Noto Sans SC", sans-serif; border: 1.5px solid currentColor; border-radius: 6px; padding: 1px 5px; }
.wx-py-toggle[aria-pressed="false"] { opacity: 0.35; }

/* ── message lists ─────────────────────────────────── */
.wx-chats { flex: 1; position: relative; overflow: hidden; }
.wx-list {
  position: absolute; inset: 0; overflow-y: auto; padding: 12px 12px 20px;
  display: flex; flex-direction: column; gap: 14px;
  overscroll-behavior: contain;
}
.wx-list[hidden] { display: none; }

.wx-time { align-self: center; font-size: 12px; color: var(--wx-grey); }
.wx-sys {
  align-self: center; max-width: 85%; text-align: center; font-size: 12px; color: var(--wx-grey);
  background: rgba(0, 0, 0, 0.05); padding: 3px 8px; border-radius: 4px;
}
.wx-sys small { display: block; opacity: 0.85; }

.wx-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; animation: wx-in 0.18s ease-out; }
.wx-msg.me { flex-direction: row-reverse; }
@keyframes wx-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wx-avatar { flex: none; width: 40px; height: 40px; border-radius: 5px; object-fit: cover; background: #ccc; }
.wx-body { min-width: 0; max-width: calc(100% - 100px); display: flex; flex-direction: column; align-items: flex-start; }
.wx-msg.me .wx-body { align-items: flex-end; }
.wx-name { font-size: 12px; color: var(--wx-grey); margin: 0 0 3px 2px; }

.wx-bubble {
  position: relative; background: #fff; border-radius: 5px; padding: 9px 11px;
  font-size: 16px; line-height: 1.45; word-break: break-word; cursor: pointer; text-align: left;
  border: 0; color: inherit; font-family: inherit;
}
.wx-bubble::before {           /* the little tail */
  content: ""; position: absolute; top: 13px; left: -5px;
  border: 5px solid transparent; border-left: 0; border-right-color: #fff;
}
.wx-msg.me .wx-bubble { background: var(--wx-green); }
.wx-msg.me .wx-bubble::before { left: auto; right: -5px; border-right: 0; border-left: 5px solid var(--wx-green); }
.wx-bubble.playing { filter: brightness(0.94); }

/* voice message */
.wx-voice { display: flex; align-items: center; gap: 8px; min-width: 76px; }
.wx-msg.me .wx-voice { flex-direction: row-reverse; }
.wx-wave { width: 18px; height: 18px; flex: none; }
.wx-msg.me .wx-wave { transform: scaleX(-1); }
.wx-bubble.playing .wx-wave path { animation: wx-pulse 0.9s infinite; }
.wx-bubble.playing .wx-wave path:nth-child(2) { animation-delay: 0.15s; }
.wx-bubble.playing .wx-wave path:nth-child(3) { animation-delay: 0.3s; }
@keyframes wx-pulse { 50% { opacity: 0.2; } }
.wx-secs { font-size: 14px; color: #333; }
.wx-transcript {            /* WeChat's voice-to-text box under the bubble */
  margin-top: 5px; background: #fff; border-radius: 5px; padding: 7px 10px;
  font-size: 15px; line-height: 1.45; max-width: 100%;
}
.wx-msg.me .wx-transcript { background: #dff5d0; }

/* learning panel opened by tapping a message */
.wx-learn {
  margin-top: 5px; background: rgba(255, 255, 255, 0.85); border-radius: 6px; padding: 8px 10px;
  font-size: 13px; line-height: 1.5; max-width: 100%;
}
.wx-learn .py { color: #576b95; }
.wx-learn .say {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px;
  border: 1px solid #c9d8f0; background: #fff; color: #1d4fa3; border-radius: 999px;
  padding: 3px 10px; font: 600 12px "Be Vietnam Pro", sans-serif; cursor: pointer;
}
.wx-learn .say.playing { background: #e8effa; }
/* pinyin under every message when the 拼 toggle is on */
.wx-py { display: none; margin-top: 3px; font-size: 12px; color: #576b95; line-height: 1.4; max-width: 100%; }
.show-py .wx-py { display: block; }
.wx-msg.me .wx-py { text-align: right; }
.wx-learn .vi { color: #333; margin-top: 2px; }
.wx-learn .words { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.wx-learn .word { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #e8effa; color: #1d4fa3; }
.wx-learn .word b { font-weight: 700; }
.wx-learn .word i { font-style: normal; opacity: 0.7; }

/* cards */
.wx-card { background: #fff; border-radius: 6px; padding: 10px 12px; width: 240px; max-width: 100%; cursor: pointer; }
.wx-card b { display: block; font-size: 15px; line-height: 1.4; font-weight: 500; }
.wx-card small { display: block; font-size: 11px; color: var(--wx-grey); margin-top: 8px; padding-top: 6px; border-top: 1px solid #eee; }
.wx-file { display: flex; gap: 10px; align-items: center; }
.wx-file-icon { flex: none; width: 34px; height: 40px; border-radius: 3px; background: #1d7c4b; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.wx-moment-head { display: flex; align-items: center; gap: 8px; }
.wx-moment-head img { width: 30px; height: 30px; border-radius: 4px; object-fit: cover; }
.wx-moment-head b { display: inline; font-size: 14px; color: #576b95; }
.wx-moment p { margin: 6px 0 0; font-size: 15px; line-height: 1.45; }
.wx-photo { width: 140px; height: 140px; border-radius: 6px; object-fit: cover; display: block; }

/* tagged HSK words inside a text bubble */
.wx-bubble .hsk, .wx-transcript .hsk { border-bottom: 1.5px dotted #1d4fa3; }
.w { cursor: pointer; border-radius: 3px; }
.w:hover, .w:active { background: rgba(29, 79, 163, 0.12); }
.wx-learn .word { cursor: pointer; }

/* ── banner for messages in another chat ───────────── */
.wx-banner {
  position: absolute; left: 10px; right: 10px; top: 56px; z-index: 5;
  display: flex; gap: 10px; align-items: center;
  background: rgba(255, 255, 255, 0.97); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); animation: wx-drop 0.25s ease-out;
}
.wx-banner img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.wx-banner b { display: block; font-size: 13px; }
.wx-banner span { display: block; font-size: 13px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
@keyframes wx-drop { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── bottom: next / choices ────────────────────────── */
.wx-input {
  flex: none; background: #f7f7f7; border-top: 1px solid var(--wx-line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.wx-next { display: flex; gap: 8px; align-items: center; }
.wx-fake-input { flex: 1; background: #fff; border-radius: 5px; padding: 9px 10px; font-size: 14px; color: #b2b2b2; }
.wx-send {
  border: 0; border-radius: 5px; background: #07c160; color: #fff; font-weight: 600; font-size: 15px;
  padding: 9px 16px; cursor: pointer; font-family: inherit;
}
.wx-send:disabled { background: #b5e8cc; cursor: default; }
.wx-choice-prompt { margin: 2px 2px 8px; font-size: 12px; color: var(--wx-grey); }
.wx-options { display: grid; gap: 8px; }
.wx-option {
  text-align: left; border: 1px solid var(--wx-line); background: #fff; border-radius: 8px; padding: 9px 12px;
  font-size: 15px; cursor: pointer; font-family: inherit; color: inherit;
}
.wx-option:hover { border-color: #07c160; }
.wx-option small { display: block; font-size: 12px; color: var(--wx-grey); margin-top: 2px; }

/* ── ending ────────────────────────────────────────── */
.wx-end {
  position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.wx-end-card {
  background: #fff; border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 420px;
  color: #1d4fa3; font-family: "Be Vietnam Pro", system-ui, sans-serif; text-align: center;
}
.wx-end-kicker { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: #8aa2c9; font-weight: 700; }
.wx-end-card h2 { font: 400 32px "Itim", sans-serif; margin: 6px 0 2px; }
.wx-end-card p { margin: 0; color: #4c6a85; font-size: 14px; }
.wx-end-words { text-align: left; margin: 18px 0; }
.wx-end-words h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #8aa2c9; margin-bottom: 8px; }
.wx-end-words ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 34vh; overflow-y: auto; }
.wx-end-words li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.wx-end-words li b { white-space: nowrap; font-size: 17px; font-weight: 600; font-family: "PingFang SC", "Noto Sans SC", sans-serif; }
.wx-end-words li span { color: #576b95; }
.wx-end-words li em { margin-left: auto; font-style: normal; font-size: 11px; background: #e8effa; border-radius: 999px; padding: 1px 8px; }
.wx-end-actions { display: grid; gap: 8px; }
.wx-end-actions .btn { width: 100%; text-align: center; text-decoration: none; }
.wx-end-seen { margin-top: 10px !important; font-size: 12px !important; }

/* the shared .coach guide (styles.css) sits above the chat */
.phone .coach { position: absolute; z-index: 20; font-family: "Be Vietnam Pro", system-ui, sans-serif; color: #1d4fa3; }

/* ── chat list ─────────────────────────────────────── */
.wx-home { position: absolute; inset: 48px 0 0; z-index: 6; background: #fff; display: flex; flex-direction: column; }
.wx-home-list { flex: 1; overflow-y: auto; }
.wx-home-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border: 0; border-bottom: 1px solid #eee; background: #fff; text-align: left; cursor: pointer; font-family: inherit; color: inherit;
}
.wx-home-row:active { background: #f2f2f2; }
.wx-home-av { flex: none; width: 46px; height: 46px; border-radius: 5px; object-fit: cover; background: #ddd; }
.wx-home-av.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 2px; }
.wx-home-av.grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.wx-home-main { flex: 1; min-width: 0; }
.wx-home-main b { display: block; font-size: 16px; font-weight: 500; }
.wx-home-main small { display: block; font-size: 13px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-home-time { font-size: 12px; color: #b2b2b2; align-self: flex-start; padding-top: 4px; }
.wx-home-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: #f7f7f7; border-top: 1px solid #ddd; }
.wx-home-exit { text-align: center; font-size: 13px; color: #576b95; }

/* ── word card ─────────────────────────────────────── */
.wx-sheet { position: absolute; inset: 0; z-index: 15; background: rgba(0, 0, 0, 0.35); display: flex; align-items: flex-end; }
.wx-sheet-card {
  position: relative; width: 100%; max-height: 78%; overflow-y: auto; background: #fff; border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); color: #1d4fa3; font-family: "Be Vietnam Pro", system-ui, sans-serif;
  animation: wx-up 0.2s ease-out;
}
@keyframes wx-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.wx-sheet-close { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 28px; color: #8aa2c9; cursor: pointer; }
.wx-sheet-top { display: flex; align-items: center; gap: 12px; }
.wx-sheet-hanzi { font-size: 48px; font-family: "PingFang SC", "Noto Sans SC", sans-serif; line-height: 1.1; }
.wx-sheet-py { font-size: 18px; font-weight: 600; margin: 4px 0 8px; }
.wx-sheet-py span { font-weight: 500; color: #4c6a85; font-size: 15px; }
.wx-sheet-senses { margin: 0 0 10px; padding-left: 18px; font-size: 15px; }
.wx-sheet-senses i { font-style: normal; font-size: 11px; font-weight: 700; background: #e8effa; border-radius: 999px; padding: 1px 7px; }
.wx-sheet-mn { font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.wx-sheet-mn b { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8aa2c9; }
.wx-sheet-ex { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.wx-sheet-ex li { background: #e8effa; border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.wx-sheet-ex small { display: block; color: #4c6a85; font-size: 12px; }
.wx-sheet-ex em { display: block; font-style: normal; font-size: 13px; }
.wx-sheet .say { border: 1px solid #c9d8f0; background: #fff; border-radius: 999px; padding: 2px 8px; cursor: pointer; }
.wx-sheet .say.big { font-size: 18px; padding: 6px 10px; }
.wx-sheet-add { width: 100%; }
.wx-sheet-add:disabled { background: #e8effa; color: #1d4fa3; opacity: 1; }
.wx-sheet-note { color: #4c6a85; }
.wx-sheet-src { margin: 12px 0 0; text-align: center; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8aa2c9; }
